USE StickyFish
GO
Declare @moduleID int, @name varchar(25), @localWord varchar(25), @editWord varchar(25), @moduleType char(1), @adminLevel tinyint
set @moduleID = 147
set @name = 'Get Widget Code'
set @localWord = 'GetWidgetCode'
set @editWord = 'GetWidgetCode'
set @moduleType = 'A'
set @adminLevel = 1
-- **************************************** Create a record in MODULES **********************************************************************
PRINT 'insert new module into modules table...'
insert into modules
(ModuleID,Name,LocalWord,EditWord,ModuleType,OptIn,DisplayOrder,CreatedOn,CreatedBy,ChangedOn,ChangedBy,FulfillmentHeader,FulfillmentFooter,AdminLevel,MenuItem,SystemLevel,AllModules,PointsModule,CashBackModule,CMI,CLI,networkid,FulfillmentSubject)
values
(@moduleID,@name,@localWord,@editword,@moduleType,0,0,getdate(),6,null,null,null,null,@adminLevel,1,0,0,1,0,null,null,1,null)
-- **************************************** Create a record for every site in SITEMODULES ***************************************************
PRINT 'Add module availability to special site -1'
exec spSiteModulesPostSu @SiteID=-1,@ModuleID=@moduleID,@UserID=6,@Assigned=1
PRINT 'Add module availability to all sites explicitly'
Declare @InsertSiteID int
Declare Sites_CURSOR cursor FAST_FORWARD -- so FORWARD_ONLY and READ_ONLY. Will run MUCH faster!
for
select siteid from sites WHERE networkid = 1 and inactive = 0
open Sites_CURSOR
fetch next from Sites_CURSOR into @InsertSiteID
while @@fetch_status = 0
begin
exec spSiteModulesPostSu @SiteID=@InsertSiteid,@ModuleID=@moduleID,@UserID=6,@Assigned=1
fetch next from Sites_CURSOR into @InsertSiteID
end
close Sites_CURSOR
deallocate Sites_CURSOR
PRINT 'All DONE!';
GO