USP_DATAFORMTEMPLATE_EDITLOAD_ADHOCQUERYFOLDERPERMISSIONS
The load procedure used by the edit dataform template "Ad-Hoc Query Folder Permissions Edit Form"
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@ID | uniqueidentifier | IN | The input ID parameter used to load the fields defined on the form. |
@DATALOADED | bit | INOUT | Output parameter indicating whether or not data was actually loaded. |
@TSLONG | bigint | INOUT | Output parameter indicating the TSLONG value of the record being edited. This is used to manage multi-user concurrency issues when multiple users access the same record. |
@NAME | nvarchar(100) | INOUT | Folder |
@APPLYASDEFAULTPERMISSIONSFORALLSUBFOLDERS | bit | INOUT | Apply the following as default permissions to all subfolders |
@SECURITYLEVEL | tinyint | INOUT | This folder is available to |
@SYSTEMROLELIST | xml | INOUT | System role list |
@QUERYDEFAULTALLOWALLUSERSTORUN | bit | INOUT | Allow all users to run this query |
@QUERYDEFAULTALLOWALLUSERSTOEDIT | bit | INOUT | Allow all users to edit this query |
@APPLYQUERYDEFAULTSTOEXISTINGQUERIES | bit | INOUT | Apply default query permissions to existing queries |
@QUERYDEFAULTRUNROLES | xml | INOUT | Query default run roles |
@QUERYDEFAULTEDITROLES | xml | INOUT | Query default edit roles |
@SMARTQUERYDEFAULTALLOWALLUSERSTORUN | bit | INOUT | Allow all users to run this query |
@SMARTQUERYDEFAULTALLOWALLUSERSTOEDIT | bit | INOUT | Allow other users to modify this query |
@SMARTQUERYDEFAULTRUNROLES | xml | INOUT | Smart Query default run roles |
@SMARTQUERYAVAILABLE | bit | INOUT |
Definition
Copy
CREATE procedure dbo.USP_DATAFORMTEMPLATE_EDITLOAD_ADHOCQUERYFOLDERPERMISSIONS
(
@ID uniqueidentifier,
@DATALOADED bit = 0 output,
@TSLONG bigint = 0 output,
@NAME nvarchar(100) = null output,
@APPLYASDEFAULTPERMISSIONSFORALLSUBFOLDERS bit = null output,
@SECURITYLEVEL tinyint = null output,
@SYSTEMROLELIST xml = null output,
@QUERYDEFAULTALLOWALLUSERSTORUN bit = null output,
@QUERYDEFAULTALLOWALLUSERSTOEDIT bit = null output,
@APPLYQUERYDEFAULTSTOEXISTINGQUERIES bit = null output,
@QUERYDEFAULTRUNROLES xml = null output,
@QUERYDEFAULTEDITROLES xml = null output,
@SMARTQUERYDEFAULTALLOWALLUSERSTORUN bit = null output,
@SMARTQUERYDEFAULTALLOWALLUSERSTOEDIT bit = null output,
@SMARTQUERYDEFAULTRUNROLES xml = null output,
@SMARTQUERYAVAILABLE bit = null output
)
as
set nocount on;
set @DATALOADED = 0
set @TSLONG = 0
set @APPLYQUERYDEFAULTSTOEXISTINGQUERIES = 0
select
@DATALOADED = 1,
@TSLONG = TSLONG,
@NAME = NAME,
@SECURITYLEVEL = SECURITYLEVELCODE,
@SYSTEMROLELIST =
(select
SR.ID as SYSTEMROLEID,
SR.NAME,
newid() as ID,
coalesce((select GRANTORDENY
from dbo.SYSTEMROLEPERM_ADHOCQUERYFOLDER as SRP
where
ADHOCQUERYFOLDER.SECURITYLEVELCODE = 1 and -- The folder is setup for selected roles
SRP.SYSTEMROLEID = SR.ID and
SRP.ADHOCQUERYFOLDERID = @ID), 2) as GRANTORDENY
from
dbo.SYSTEMROLE as SR
order by SR.NAME
for xml raw('ITEM'), type, elements, root('SYSTEMROLELIST'), BINARY BASE64),
@QUERYDEFAULTALLOWALLUSERSTORUN = QUERYDEFAULTALLOWALLUSERSTORUN,
@QUERYDEFAULTALLOWALLUSERSTOEDIT = QUERYDEFAULTALLOWALLUSERSTOEDIT,
@SMARTQUERYDEFAULTALLOWALLUSERSTORUN = SMARTQUERYDEFAULTALLOWALLUSERSTORUN,
@SMARTQUERYDEFAULTALLOWALLUSERSTOEDIT = SMARTQUERYDEFAULTALLOWALLUSERSTOEDIT,
@APPLYASDEFAULTPERMISSIONSFORALLSUBFOLDERS = APPLYASDEFAULTPERMISSIONSFORALLSUBFOLDERS,
@QUERYDEFAULTRUNROLES =
(select
@ID as ADHOCQUERYFOLDERID,
ID as SYSTEMROLEID,
NAME,
coalesce((select GRANTORDENY
from dbo.ADHOCQUERYFOLDERDEFAULTQUERYROLE as SRP
where
ADHOCQUERYFOLDER.QUERYDEFAULTALLOWALLUSERSTORUN = 0 and
SRP.SYSTEMROLEID = SYSTEMROLE.ID and
SRP.ADHOCQUERYFOLDERID = @ID and
PERMISSIONTYPECODE = 0 -- Run
), 2) as GRANTORDENY
from
dbo.SYSTEMROLE
order by NAME
for xml raw('ITEM'), type, elements, root('QUERYDEFAULTRUNROLES'), BINARY BASE64),
@QUERYDEFAULTEDITROLES =
(select
@ID as ADHOCQUERYFOLDERID,
ID as SYSTEMROLEID,
NAME,
coalesce((select GRANTORDENY
from dbo.ADHOCQUERYFOLDERDEFAULTQUERYROLE as SRP
where
ADHOCQUERYFOLDER.QUERYDEFAULTALLOWALLUSERSTOEDIT = 0 and
SRP.SYSTEMROLEID = SYSTEMROLE.ID and
SRP.ADHOCQUERYFOLDERID = @ID and
PERMISSIONTYPECODE = 1 -- Edit
), 2) as GRANTORDENY
from
dbo.SYSTEMROLE
order by NAME
for xml raw('ITEM'), type, elements, root('QUERYDEFAULTEDITROLES'), BINARY BASE64),
@SMARTQUERYDEFAULTRUNROLES =
(select
@ID as ADHOCQUERYFOLDERID,
ID as SYSTEMROLEID,
NAME,
coalesce((select GRANTORDENY
from dbo.ADHOCQUERYFOLDERDEFAULTQUERYROLE as SRP
where
ADHOCQUERYFOLDER.SMARTQUERYDEFAULTALLOWALLUSERSTORUN = 0 and
SRP.SYSTEMROLEID = SYSTEMROLE.ID and
SRP.ADHOCQUERYFOLDERID = @ID and
PERMISSIONTYPECODE = 2 -- RunSmartQuery
), 2) as GRANTORDENY
from
dbo.SYSTEMROLE
order by NAME
for xml raw('ITEM'), type, elements, root('SMARTQUERYDEFAULTRUNROLES'), BINARY BASE64)
from dbo.ADHOCQUERYFOLDER
where ID = @ID;
select @SMARTQUERYAVAILABLE = dbo.UFN_SMARTQUERY_AVAILABLE()
return 0;