Small width layout Medium width layout Maximum width layout Small text Medium text Large text
     Search
Downloads Downloads Directory Directory Forums Forums Forge Forge Blogs Blogs        Marketplace Marketplace Careers Program Careers
Community › Forums Register  |  

telerik -- supercharge your DNN websites
  Ads  
 


  Sponsors  

Meet Our Sponsors

R2integrated - formerly bi4ce
Jango Studios - Skins, Modules and Hosting for DotNetNuke
eUKhost.com is commited to offer exceptional UK Windows Web Hosting solutions with quality 24x7 technical support.Our plans support ASP.Net, ASP, ASP.NET Ajax extensions, XML, MSSQL, MySQL, PHP,DNN, multiple domains and Shared SSL as standard.
SmarterTools
Verndale
The Official Microsoft ASP.NET Website
 


DotNetNuke Forums
 
  Forum  DotNetNuke® Pro...  Forum Module [L...  Copying module settings, groups, forums, and posts to a new portal (SQL)
Previous Previous
 
Next Next
New Post 5/20/2008 11:25 PM
Informative
User is offline Gaines Kergosien
40 posts
www.SprintMogul.net
10th Ranked


Copying module settings, groups, forums, and posts to a new portal (SQL) 
Modified By Gaines Kergosien  on 5/21/2008 1:41:52 AM)

I run a series of cell phone sites, all of which are based on the same structure. Since the dotnetnuke template functionality doesn't carry over forum module content, I wrote the following SQL script to copy the settings, groups, forums and certain posts from an existing portal. It works great for me so please feel free to use some or all of the script, however I make no guarantees and you do so at your own risk.

NOTE: You'll need to set the @OldPortalID variable's value on line 3 and PostID parameter for each post you want to copy. The script assumes the newest portal (with the highest PortalID) is the one you want to copy everything to.

DECLARE @MODULEID INT, @PORTALID INT, @PORTALNAME NVARCHAR(50), @OLDPORTALID INT, @OLDPORTALNAME NVARCHAR(50), @OLDMODULEID INT, @CURRENTDATE DATETIME
SET @CURRENTDATE = GETDATE()
SET @OLDPORTALID = 9   -- Change this to the PortalID of the portal you wish to copy from
SELECT @OLDMODULEID = FROM Modules WHERE (ModuleTitle LIKE '%FORUM%') AND PORTALID = @OLDPORTALID
SELECT @OLDPORTALNAME = PORTALNAME FROM PORTALS WHERE PORTALID = @OLDPORTALID
SELECT @MODULEID = MAX(MODULEID) FROM Modules WHERE (ModuleTitle LIKE '%FORUM%')
SELECT @PORTALID = MAX(PORTALID) FROM Portals
SELECT @PORTALNAME = PORTALNAME FROM PORTALS WHERE PORTALID = @PORTALID

------------------------------------------------------------------------------------------------
-- COPY SETTINGS
DELETE FROM MODULESETTINGS WHERE MODULEID = @MODULEID
INSERT INTO [ModuleSettings]
           ([ModuleID]
           ,[SettingName]
           ,[SettingValue])
SELECT @MODULEID
      ,[SettingName]
      ,REPLACE([SettingValue], @OLDPORTALNAME, @PORTALNAME)
FROM [ModuleSettings]
WHERE MODULEID = @OLDMODULEID

------------------------------------------------------------------------------------------------
-- COPY GROUPS
INSERT INTO [Forum_Groups]
           ([Name]
           ,[PortalID]
           ,[ModuleID]
           ,[SortOrder]
           ,[CreatedDate]
           ,[CreatedByUser]
           ,[UpdatedByUser]
           ,[UpdatedDate])
SELECT [Name]
      ,@PORTALID
      ,@MODULEID
      ,[SortOrder]
      ,GETDATE() AS [CreatedDate]
      ,[CreatedByUser]
      ,[UpdatedByUser]
      ,GETDATE() AS [UpdatedDate]
FROM [Forum_Groups]
WHERE PORTALID = @OLDPORTALID
AND [Name] NOT IN (SELECT [Name] FROM FORUM_GROUPS WHERE PORTALID = @PORTALID)

------------------------------------------------------------------------------------------------
-- COPY FORUMS
INSERT INTO [Forum_Forums]
           ([GroupID]
           ,[IsActive]
           ,[ParentID]
           ,[Name]
           ,[Description]
           ,[CreatedDate]
           ,[CreatedByUser]
           ,[UpdatedByUser]
           ,[UpdatedDate]
           ,[IsModerated]
           ,[SortOrder]
           ,[TotalPosts]
           ,[TotalThreads]
           ,[EnablePostStatistics]
           ,[MostRecentPostID]
           ,[MostRecentThreadID]
           ,[MostRecentPostAuthorID]
           ,[MostRecentPostDate]
           ,[PostsToModerate]
           ,[ForumType]
           ,[IsIntegrated]
           ,[IntegratedModuleID]
           ,[AuthorizedRoles]
           ,[AuthorizedEditRoles]
           ,[PublicView]
           ,[PublicPosting]
           ,[EnableForumsThreadStatus]
           ,[EnableForumsRating]
           ,[ForumLink]
           ,[ForumBehavior]
           ,[AllowPolls])
SELECT G2.[GroupID]
      ,F1.[IsActive]
      ,F1.[ParentID]
      ,F1.[Name]
      ,F1.[Description]
      ,GETDATE() AS [CreatedDate]
      ,F1.[CreatedByUser]
      ,F1.[UpdatedByUser]
      ,GETDATE() AS [UpdatedDate]
      ,F1.[IsModerated]
      ,F1.[SortOrder]
      ,0 AS [TotalPosts]
      ,0 AS [TotalThreads]
      ,F1.[EnablePostStatistics]
      ,NULL AS [MostRecentPostID]
      ,NULL AS [MostRecentThreadID]
      ,NULL AS [MostRecentPostAuthorID]
      ,NULL AS [MostRecentPostDate]
      ,0 AS [PostsToModerate]
      ,F1.[ForumType]
      ,F1.[IsIntegrated]
      ,F1.[IntegratedModuleID]
      ,F1.[AuthorizedRoles]
      ,F1.[AuthorizedEditRoles]
      ,F1.[PublicView]
      ,F1.[PublicPosting]
      ,F1.[EnableForumsThreadStatus]
      ,F1.[EnableForumsRating]
      ,F1.[ForumLink]
      ,F1.[ForumBehavior]
      ,F1.[AllowPolls]
FROM [Forum_Forums] F1
INNER JOIN FORUM_GROUPS G1
ON F1.GROUPID = G1.GROUPID
AND G1.PORTALID = @OLDPORTALID
INNER JOIN FORUM_GROUPS G2
ON G1.NAME = G2.NAME
AND G2.PORTALID = @PORTALID
LEFT OUTER JOIN FORUM_FORUMS F2
ON G2.GROUPID = F2.GROUPID
AND F1.[NAME] = F2.[NAME]
WHERE F2.FORUMID IS NULL

------------------------------------------------------------------------------------------------
-- ADD POSTS
DECLARE @RC int, @POSTID INT, @ParentPostID int, @ForumID int, @UserID int, @Notify bit, @Subject nvarchar(255), @Body NVARCHAR(MAX), @IsPinned bit
DECLARE @IsClosed bit, @ObjectID int, @FileAttachmentURL nvarchar(50), @PollID int, @NEWFORUMID INT

-- Duplicate the code below for each post you wish to copy into the new portal

-- NOTE: Be sure to change the PostID for each one
SELECT @POSTID = P.POSTID, @FORUMID = T.FORUMID, @USERID = P.USERID, @NOTIFY = P.NOTIFY, @SUBJECT = P.SUBJECT, @BODY = P.BODY, @ISPINNED = T.ISPINNED
    , @ISCLOSED = P.ISCLOSED, @OBJECTID = T.OBJECTID, @FILEATTACHMENTURL = P.FILEATTACHMENTURL, @POLLID = T.POLLID
FROM FORUM_POSTS P INNER JOIN FORUM_THREADS T ON P.THREADID = T.THREADID WHERE P.POSTID = 0000 -- Change this to the PostID <--
SELECT @NEWFORUMID = F2.FORUMID FROM FORUM_FORUMS F1
INNER JOIN FORUM_GROUPS G1 ON F1.GROUPID = G1.GROUPID
INNER JOIN FORUM_GROUPS G2 ON G1.[NAME] = G2.[NAME] AND G2.PORTALID = @PORTALID
INNER JOIN FORUM_FORUMS F2 ON G2.GROUPID = F2.GROUPID AND F1.[NAME] = F2.[NAME]
WHERE F1.FORUMID = @FORUMID
EXECUTE @RC = [Forum_Post_Add] 0, @NEWForumID, @UserID, '127.0.0.1', @Notify, @Subject, @Body, @IsPinned, @CURRENTDATE, @IsClosed, @ObjectID
    , @FileAttachmentURL, @PortalID, 0, @PollID


HTCTouchDiamond.com - HTCTouchPro.com - HTCTouchDual.net - SprintMogul.net - SprintTouch.net - MySprintInstinct.com - VerizonXV6900.com - VerizonXV6800.net - VerizonGlyde.net
 
Previous Previous
 
Next Next
  Forum  DotNetNuke® Pro...  Forum Module [L...  Copying module settings, groups, forums, and posts to a new portal (SQL)
 


Forum Policy

These Discussion Forums are dedicated to the discussion of the DotNetNuke Web Application Framework.

For the benefit of the community and to protect the integrity of the project, please observe the following posting guidelines:

1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DotNetNuke.
2. Discussion or promotion of DotNetNuke product releases under a different brand name are strictly prohibited.
3. No Flaming or Trolling.
4. No Profanity, Racism, or Prejudice.
5. Site Moderators have the final word on approving/removing a thread or post or comment.
6. English language posting only, please.

 


DNNMasters - modules, consulting, development
DNNMasters developers are involved in DNN development since DNN 1.0.9 and today we offer a broad range of DNN related products and services including custom development of modules, help with ing third party modules for specific needs, general DNN technical support and administrative services.
www.dnnmasters.com
Cygnusoft Custom Software
Cygnusoft has been providing cutting-edge custom software solutions for 20 years. Cygnusoft is also a leading start-up incubator, helping our partners build successful new businesses.
www.cygnusoft.com
Digicon: DotNetNuke design and development
Digicon is based in Brisbane, Queensland, Australia
digicon.com.au

DotNetNuke Corporation   Terms Of Use  Privacy Statement
DotNetNuke®, DNN®, and the DotNetNuke logo are trademarks of DotNetNuke Corporation
Hosted by MaximumASP