spGetEventCalendars_ForHighlight

Parameters

Parameter Parameter Type Mode Description
@iEvtCalHighlightID int IN
@ClientUsersID int IN
@ClientsID int IN
@FunctionMode int IN

Definition

Copy


        CREATE   PROCEDURE [dbo].[spGetEventCalendars_ForHighlight]
        (
            @iEvtCalHighlightID    int,
            @ClientUsersID    int,
            @ClientsID        int,
            @FunctionMode    int        -- display: 0; editor: 1
        )
        AS
        -- This proc returns a table of all the event calendars in the database to Calendar View editor; and 
        -- indicates which ones are the source calendars of the calendar event highlight (identified by @iEvtCalHighlightID)
        -- However, it returns to Calendar View display a table of the event calendars that the user has view rights only.
        -- note: the Calendar View editor is used by both the Event Calendar Group part and the Event Calendar Highlight part

        -- The table has 4 columns:
        -- ID: the event calendar ID
        -- Name: the event calendar name
        -- IsSrcCalendar: returns 1 if the calendar is a source calender 
        -- CalSiteContentGUID: guid of the calendar part in the SiteContent table
        begin 
            set nocount on
            IF @FunctionMode = 1 -- don't check calendar security if coming from editor, or supervisor login
                begin
                    SELECT c.ID, c.Name, 'IsSrcCalendar' = 
                        CASE hd.EventCalendarHighlightID
                            WHEN @iEvtCalHighlightID THEN 1
                            ELSE 0
                        END,
                        sc.guid as 'CalSiteContentGUID'
                    FROM dbo.EventCalendar c
                    LEFT JOIN dbo.EventCalendarHighlightDetail hd
                        ON c.id = hd.SrcCalendarID AND hd.EventCalendarHighlightID = @iEvtCalHighlightID 
                    INNER JOIN dbo.SiteContent sc 
                        ON sc.id = c.SiteContentID
                    WHERE c.SiteContentID NOT IN (SELECT ppe.SiteContentID FROM dbo.PersonalPageElements ppe)
                    ORDER BY c.Name
                end
            ELSE
                begin
                    SELECT c.ID, c.Name, 'IsSrcCalendar' = 
                        CASE hd.EventCalendarHighlightID
                            WHEN @iEvtCalHighlightID THEN 1
                            ELSE 0
                        END,
                        sc.guid as 'CalSiteContentGUID'                    
                    FROM dbo.EventCalendar c
                    LEFT JOIN dbo.EventCalendarHighlightDetail hd
                        ON c.id = hd.SrcCalendarID AND hd.EventCalendarHighlightID = @iEvtCalHighlightID 
                    INNER JOIN dbo.SiteContent sc 
                        ON sc.id = c.SiteContentID
                    WHERE ((select canView from dbo.fnUserPrivs(@ClientUsersID, @ClientsID, 1) priv 
                            where sc.guid = priv.ObjectGuid) <> 0)
                    ORDER BY c.Name
                end
        end