spGetClientRolesByContentGuid

Parameters

Parameter Parameter Type Mode Description
@ClientsID int IN
@ContentGuid uniqueidentifier IN

Definition

Copy

        CREATE PROC [dbo].[spGetClientRolesByContentGuid]
        (
            @ClientsID int,
            @ContentGuid uniqueidentifier
        ) AS
        BEGIN

            declare @ViewTaskID uniqueidentifier
            set @ViewTaskID = (select ID from dbo.CMSOBJECTTASK where ENUMID = 0)

            declare @Results table ([Name] nvarchar(50), [EveryoneRole] bit)


            --Check what the everyone right is
            declare @EveryoneRight bit
            set @EveryoneRight = (select top 1 CESP.VALUE from dbo.CMSEVERYONESECURITYPRIVS CESP
                                    where CESP.SECUREDOBJECTGUID = @ContentGuid
                                    and CESP.OBJECTTASKID = @ViewTaskID)

            if @EveryoneRight = 1 
                insert into @Results
                select CR.Name, 1 from dbo.ClientRoles CR where CR.EveryoneRole = 1


            --Look for exceptions tied to roles other than the everyone role            
            insert into @Results
            select CR.Name, 0 from dbo.ClientRoles CR
            inner join dbo.CMSOBJETSECURITYEXCEPTION COSE
            on CR.Guid = COSE.EXCEPTIONOBJECTGUID
            where COSE.OBJECTTASKID = @ViewTaskID
            and CR.Deleted = 0
            and COSE.SECUREDOBJECTGUID = @ContentGuid
            and CR.EveryoneRole = 0
            order by CR.Name

            select * from @Results
            order by [EveryoneRole] desc, [Name]

            -- The total number of ROPs associated with the content is
            -- provided as the return value.  This is useful because a bug
            -- exists where sometimes 0 ROPs are found.  Site wide we map this
            -- to mean that just the Everyone role is selected.
            RETURN (SELECT COUNT(ID)
                    from dbo.CMSEVERYONESECURITYPRIVS CESP
                    where CESP.SECUREDOBJECTGUID = @ContentGuid
                    and CESP.OBJECTTASKID = @ViewTaskID)
        END