UFN_SECURITY_EXPORTDEFINITION_USERCANSAVEFORQUERYVIEWS

Returns whether user has rights to export definition based on the query views that it is composed of.

Return

Return Type
bit

Parameters

Parameter Parameter Type Mode Description
@ID uniqueidentifier IN
@NEWEXPORTDEFINITIONXML xml IN
@APPUSERID uniqueidentifier IN

Definition

Copy


create function dbo.UFN_SECURITY_EXPORTDEFINITION_USERCANSAVEFORQUERYVIEWS(@ID uniqueidentifier,  
    @NEWEXPORTDEFINITIONXML xml,  
    @APPUSERID uniqueidentifier)  
   returns bit  
   as  
   begin  

    declare @RETURNVALUE bit;  

    declare @EXISTINGID uniqueidentifier;  
    declare @EXISTINGEXPORTDEFINITIONXML xml;  

    select @EXISTINGID = EXPORTDEFINITION.ID,  
     @EXISTINGEXPORTDEFINITIONXML = EXPORTDEFINITION.EXPORTDEFINITIONXML  
    from dbo.EXPORTDEFINITION   
    where EXPORTDEFINITION.ID = @ID;  

    /* Check rights to query views used in the export definition passed in */  
    set @RETURNVALUE = dbo.UFN_EXPORTDEFINITION_USERHASRIGHTSTOQUERYVIEWS(@APPUSERID, @NEWEXPORTDEFINITIONXML);  

    if @RETURNVALUE = 1 and not @EXISTINGID is null  
    begin  
     declare @ISSYSADMIN bit;  
     select @ISSYSADMIN = ISSYSADMIN from dbo.APPUSER where ID = @APPUSERID;  

     /* Check rights to query views used in the export definition that already exists to ensure he's not removing fields from query views to which  
     he doesn't have rights */  
     set @RETURNVALUE = dbo.UFN_EXPORTDEFINITION_USERHASRIGHTSTOQUERYVIEWS(@APPUSERID, @EXISTINGEXPORTDEFINITIONXML)  
    end;  

    return @RETURNVALUE;  

   end;