Name
sn_cd.cd_TodoSecurityUtils
Description
No description available
Script
var cd_TodoSecurityUtils = Class.create();
cd_TodoSecurityUtils.prototype = {
initialize: function() {
this.DELEGATION_PLUGIN_ACTIVE = GlidePluginManager().isActive('com.glide.granular_service_delegation');
},
/* function returns user access of TodoContent
* @param contentId String The ID of To Do content
* @return boolean true if user have access
* false if user don't have access
*/
canAccessToDoContent: function(contentId) {
var contentTask = new GlideRecord('sn_cd_task');
contentTask.addActiveQuery();
contentTask.addQuery("content_todo", contentId);
var encodedQuery = 'active=true^ref_sn_cd_task.content_todo=' + contentId;
var delegatedTasks = this._getDelegatedTasks({ tables: ['sn_cd_task'], encoded_query: encodedQuery });
var qc = contentTask.addQuery("assigned_to", gs.getUserID());
if (delegatedTasks.length)
qc.addOrCondition('sys_id', 'IN', delegatedTasks);
contentTask.setLimit(1);
contentTask.query();
return contentTask.hasNext();
},
/* function returns user access of link content
* @param linkId String The ID of link content
* @return boolean true if user have access
* false if user don't have access
*/
canAccessLinkContent: function(linkId) {
var grCdTask = new GlideRecord('sn_cd_task');
grCdTask.addActiveQuery();
grCdTask.addQuery('content_todo.active', true);
grCdTask.addQuery('content_todo.url_asset', linkId);
var encodedQuery = 'active=true^ref_sn_cd_task.content_todo.active=true^ref_sn_cd_task.content_todo.url_asset=' + linkId;
var delegatedTasks = this._getDelegatedTasks({ tables: ['sn_cd_task'], encoded_query: encodedQuery });
var qc = grCdTask.addQuery('assigned_to', gs.getUserID());
if (delegatedTasks.length)
qc.addOrCondition('sys_id', 'IN', delegatedTasks);
grCdTask.setLimit(1);
grCdTask.query();
return grCdTask.hasNext();
},
/* function returns user access of block content
* @param blockContentId String The ID of block content
* @return boolean true if user have access
* false if user don't have access
*/
canAccessBlockContent: function(blockContentId) {
var grCdTask = new GlideRecord('sn_cd_task');
grCdTask.addActiveQuery();
grCdTask.addQuery('content_todo.active', true);
grCdTask.addQuery('content_todo.use_block', true);
grCdTask.addQuery('content_todo.block', blockContentId);
var encodedQuery = 'active=true^ref_sn_cd_task.content_todo.active=true^ref_sn_cd_task.content_todo.use_block=true^ref_sn_cd_task.content_todo.block=' + blockContentId;
var delegatedTasks = this._getDelegatedTasks({ tables: ['sn_cd_task'], encoded_query: encodedQuery });
var qc = grCdTask.addQuery('assigned_to', gs.getUserID());
if (delegatedTasks.length)
qc.addOrCondition('sys_id', 'IN', delegatedTasks);
grCdTask.setLimit(1);
grCdTask.query();
return grCdTask.hasNext();
},
/* Get the delegated assignments for a user
@param config - Object - Object describing delegation records to retrieve
{
@param tables - Array - (optional) - The tables to get delegated records from
@param start_date - String - (optional) - Get delegate records at or after this date
@param encoded_query - String - (optional) - The condition to filter delegated records
@param limit - Number - (optional) - The maximum number of records to get
}
@param userId - String - (optional) - The user to get delegated records for
@param includeUsersRecords - boolean (optional) - Include the users assigned records as well as delegated records
@return Array - An array of delegated record sys_id's
*/
_getDelegatedTasks: function(config, userId, includeUserRecords) {
var delegatedRecords = [];
if (!this.DELEGATION_PLUGIN_ACTIVE)
return delegatedRecords;
if (!userId)
userId = gs.getUserID();
var grTasks = new sn_delegation.DelegationUtil().getDelegatedAssignmentsForUser(userId, !!includeUserRecords, config);
while (grTasks.next())
delegatedRecords.push(grTasks.getUniqueValue());
return delegatedRecords;
},
type: 'cd_TodoSecurityUtils'
};
Sys ID
f5d0cbeab7723300a251e556ee11a92a