spClone_ClientSites

Parameters

Parameter Parameter Type Mode Description
@PKID int INOUT
@CurrentUsersID int IN
@NewName nvarchar(50) IN
@NewGuid uniqueidentifier IN
@CopyBatchGUID uniqueidentifier IN

Definition

Copy


CREATE PROCEDURE [dbo].[spClone_ClientSites]
  (
  @PKID        int OUTPUT,
  @CurrentUsersID int,
  @NewName    nvarchar(50),
  @NewGuid        uniqueidentifier,
  @CopyBatchGUID uniqueidentifier
  )

  AS

  begin try
    INSERT INTO ClientSites
    (
    Name, Deleted, ClientsID, Guid, OwnerID, SiteTrackingScript, ParentSiteID, CopySourceID, CopyBatchGUID, FavIconImageID
    )
    SELECT
    @NewName,
    Deleted,
    ClientsID,
    @NewGuid,
    OwnerID,
    SiteTrackingScript,
    ParentSiteID,
    @PKID,
    @CopyBatchGUID,
    FavIconImageID
    FROM
    ClientSites
    WHERE
    ID = @PKID AND Deleted = 0

    declare @oldPKID int
    set @oldPKID = @PKID

    SELECT  @PKID = @@Identity

    insert into CMSSITESETTING
    (
        ENUMID, SETTING, CLIENTSITESID, VALUE
    )
    select ENUMID, Setting, @PKID, VALUE
    from CMSSITESETTING
    where
    CLIENTSITESID = @oldPKID

    --Need to clear out these settings such as home page/login page that have to point

    --to pages within the site itself, so there is no use in copying the values from another site

    update dbo.CMSSITESETTING
    set VALUE = 0 where ENUMID IN (1,2,3,4,5) and CLIENTSITESID = @PKID

    -- FAF uses these settings but need clear out these settings as site end date and redirect URL does not need to be copied.

    update dbo.CMSSITESETTING
    set VALUE = '' where ENUMID IN (33,34) and CLIENTSITESID = @PKID

    insert into dbo.SiteCultures
    select Name, Description, @PKID from dbo.SiteCultures where ClientSitesId = @oldPKID

    insert into dbo.ClientSSO (Description,SharedKey,UserNameParameter,TimeParameter,MD5Parameter,ClientSiteID,Delta,IncludeIP,RequireSsl)
    select 
    [Description],
    SharedKey,
    UserNameParameter,
    TimeParameter,
    MD5Parameter,
    @PKID,
    Delta,
    IncludeIP,
    RequireSsl
    from dbo.ClientSSO
    where ClientSiteID = @oldPKID

    --Copy the default ack email template

    declare @DEFAULTACKTABLE table (ID int)
    insert into @DEFAULTACKTABLE
    exec dbo.spDefaultAcknowledgmentTemplateID 1, @oldPKID

    declare @IDs xml
    set @IDs = 
    (
        select ID from @DEFAULTACKTABLE
        FOR XML RAW, ELEMENTS
    )

    exec dbo.spCloneSite_EmailTemplate @PKID,@CurrentUsersID, @CopyBatchGUID, @IDs

    exec spAuditThis @CurrentUsersID, 1, @NewGuid, 8

end try

begin catch
    exec dbo.USP_RAISE_ERROR;
    return 1;
end catch

return 0;