UFN_SMARTQUERYINSTANCE_USERGRANTEDEDIT

Returns true if the user has been granted and not denied access to edit the smart query instance for a System Role.

Return

Return Type
bit

Parameters

Parameter Parameter Type Mode Description
@SMARTQUERYINSTANCEID uniqueidentifier IN
@APPUSERID uniqueidentifier IN

Definition

Copy


CREATE function dbo.UFN_SMARTQUERYINSTANCE_USERGRANTEDEDIT
(
    @SMARTQUERYINSTANCEID uniqueidentifier,
    @APPUSERID uniqueidentifier
)
returns bit
with execute as caller
as 
/*Returns true if the user has been granted and not denied access to edit the smart query instance for a System Role.*/
begin
    declare @SMARTQUERYID uniqueidentifier,
            @OWNERID uniqueidentifier,
            @OTHERSCANMODIFY bit

    select @SMARTQUERYID = SMARTQUERYCATALOGID,
            @OWNERID = OWNERID, 
            @OTHERSCANMODIFY = OTHERSCANMODIFY
    from SMARTQUERYINSTANCE 
    where ID=@SMARTQUERYINSTANCEID

    return (case when dbo.UFN_SECURITY_APPUSER_GRANTED_SMARTQUERY_IN_SYSTEMROLE(@APPUSERID, @SMARTQUERYID) = 1
                    and dbo.UFN_SECURITY_APPUSER_GRANTED_SMARTQUERYINSTANCE_IN_SYSTEMROLE(@APPUSERID, @SMARTQUERYINSTANCEID) = 1
                    and (@APPUSERID = @OWNERID
                        or @OTHERSCANMODIFY = 1)
                then 1
            else 0
            end)
end