spDelete_UserPages
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@PKID | int | IN | |
@CurrentUsersID | int | IN |
Definition
Copy
CREATE procedure [dbo].[spDelete_UserPages]
(
@PKID int,
@CurrentUsersID int
)
as
begin
/*
@CurrentUsersID needed for dataobject delete code. May add soft deletes later...
*/
--If this is a team page, delete any Event Calendars associated with Team Calendar parts on the page
declare @realmType int
select @realmType = upmt.RealmType
from dbo.UserPages up
inner join dbo.UserPageManagerPageTemplates upmt
on up.UserPageTemplateId = upmt.ID
if @realmType = 7
begin
declare @teamCalendar table (
teamCalendarID int,
xmlTextData nvarchar(max),
xmlData XML,
eventCalendarID int
)
insert into @teamCalendar (teamCalendarID, xmlTextData)
select pcd.ID,
pcd.XMLData
from dbo.PersonalizedContentData pcd
left join dbo.UserPages up
on pcd.UserPageID = up.ID
inner join dbo.SiteContent sc
on pcd.SiteContentID = sc.ID
where sc.ContentTypesID = 9023 --Team Calendar Content Type
and up.ID = @PKID
update @teamCalendar
set xmlData = cast(replace(xmlTextData, '<?xml version="1.0" encoding="UTF-16">', '') as xml)
update @teamCalendar
set eventCalendarID = xmldata.value('TeamCalendarPersonalContent[1]/EventCalendarID[1]','int')
delete from dbo.EventCalendar
where ID in (select eventCalendarID from @teamCalendar)
end
delete from UserPages where ID = @PKID
end