Documentation

PrivilegeUtil
in package

Table of Contents

GROUP_LOOP_LIMIT  = 5
MEMBER_TYPE_GROUPS  = 'Groups'
MEMBER_TYPE_ROLE_AND_SUBORDINATES  = 'RoleAndSubordinates'
MEMBER_TYPE_ROLES  = 'Roles'
MEMBER_TYPE_USERS  = 'Users'
$datashareRelatedCache  : mixed
$dataShareStructure  : mixed
$defaultSharingActionCache  : mixed
$membersCache  : mixed
$shareRulesTables  : array<string|int, mixed>
Tables to sharing rules.
$shareRulesTablesIndex  : array<string|int, mixed>
List tables where sharing rules are save for users, groups and roles.
deleteRelatedSharingRules()  : mixed
Function to remove sharing rules from tables.
getAllDefaultSharingAction()  : array<string|int, mixed>
This Function returns the Default Organisation Sharing Action Array for all modules.
getAllGroupsByUser()  : array<string|int, int>
Get all groups by user id.
getAllProfilePermissions()  : array<string|int, mixed>
Function to get the Standard and Utility Profile Action Permissions for the specified vtiger_profileid.
getCombinedUserActionsPermissions()  : array<string|int, mixed>
To retreive the vtiger_tab acion permissions of the specifed user from the various vtiger_profiles associated with the user.
getCombinedUserGlobalPermissions()  : array<string|int, int>
To retreive the global permission of the specifed user from the various vtiger_profiles associated with the user.
getCombinedUserModulesPermissions()  : array<string|int, mixed>
To retreive the vtiger_tab permissions of the specifed user from the various vtiger_profiles associated with the user.
getDatashare()  : array<string|int, mixed>
Get data share.
getDatashareRelatedModules()  : array<string|int, mixed>
Function to get data share related modules.
getGroupsWhereUserIsLeader()  : array<string|int, mixed>
Returns groups whose leader is the user.
getLeadersGroupByUserId()  : array<string|int, mixed>
Returns the leaders of the groups where the user is a member.
getMembers()  : array<string|int, mixed>
Function to get all members.
getParentGroups()  : array<string|int, int>
Get parent grioups by group id.
getParentRecordOwner()  : mixed
Function to get parent record owner.
getParentRole()  : parent
To retreive the parent vtiger_role of the specified vtiger_role.
getProfileGlobalPermission()  : array<string|int, int>
Function to get the Profile Global Information for the specified vtiger_profileid.
getProfilesByRole()  : array<string|int, mixed>
This function is to retreive the vtiger_profiles associated with the the specified role.
getProfilesByUser()  : array<string|int, mixed>
This function is to retreive the vtiger_profiles associated with the the specified user.
getProfileTabsPermission()  : array<string|int, int>
Function to get the Profile Tab Permissions for the specified vtiger_profileid.
getQueryToGroupsByUserId()  : Query
Creates a query to all groups where the user is a member.
getQueryToUsersByGroup()  : Query
Gets query to users by group.
getQueryToUsersByMembers()  : Query
Gets query to users by members.
getQueryToUsersByRole()  : Query
Gets query to users by role.
getQueryToUsersByRoleAndSubordinate()  : Query
Gets query to users by role and subordinate.
getRoleByUsers()  : mixed
Function to get the role related user ids.
getRoleDetail()  : array<string|int, mixed>|bool|string
Function to get the vtiger_role information of the specified vtiger_role.
getRoleName()  : string
Function to get the role name.
getRoleSubordinates()  : array<string|int, mixed>
To retreive the subordinate vtiger_roles of the specified parent vtiger_role.
getStandardPermissions()  : array<string|int, mixed>
Function to get the Profile Action Permissions for the specified vtiger_profileid.
getUserByMember()  : array<string|int, mixed>
Get list of users based on members, eg. Users:2, Roles:H2.
getUserGroups()  : array<string|int, mixed>
Function to get user groups.
getUserModuleSharingObjects()  : array<string|int, mixed>
Gives an array which contains the information for what all roles, groups and user data is to be shared with the spcified user for the specified module.
getUsersByGroup()  : array<string|int, mixed>
Get list of users based on group id.
getUsersByRole()  : array<string|int, mixed>
Function to get the vtiger_role related user ids.
getUsersByRoleAndSubordinate()  : array<string|int, mixed>
Function to get the roles and subordinate users.
getUsersNameByRole()  : array<string|int, mixed>
Function to get the users names by role.
getUtilityPermissions()  : array<string|int, mixed>
Function to get all the vtiger_tab utility action permission for the specified vtiger_profile.
isExists()  : bool
Check if element exists in organization structure.
modifyPermissions()  : bool
Modify permissions for actions and views.
recalculateSharingRulesByUser()  : mixed
Recalculate sharing rules by user id.
testPrivileges()  : mixed
Function for test to check privilege utils.
deleteSharingRule()  : mixed
This function is to delete the organisation level sharing rule It takes the following input parameters:.
getHelpDeskRelatedAccounts()  : int
Function return related account with ticket.

Constants

GROUP_LOOP_LIMIT

public int GROUP_LOOP_LIMIT = 5

Allowed group nests

MEMBER_TYPE_GROUPS

public mixed MEMBER_TYPE_GROUPS = 'Groups'

MEMBER_TYPE_ROLE_AND_SUBORDINATES

public mixed MEMBER_TYPE_ROLE_AND_SUBORDINATES = 'RoleAndSubordinates'

Properties

$datashareRelatedCache

protected static mixed $datashareRelatedCache = false

$dataShareStructure

protected static mixed $dataShareStructure = ['role2role' => ['vtiger_datashare_role2role', 'to_roleid'], 'role2rs' => ['vtiger_datashare_role2rs', 'to_roleandsubid'], 'role2group' => ['vtiger_datashare_role2group', 'to_groupid'], 'role2user' => ['vtiger_datashare_role2us', 'to_userid'], 'rs2role' => ['vtiger_datashare_rs2role', 'to_roleid'], 'rs2rs' => ['vtiger_datashare_rs2rs', 'to_roleandsubid'], 'rs2group' => ['vtiger_datashare_rs2grp', 'to_groupid'], 'rs2user' => ['vtiger_datashare_rs2us', 'to_userid'], 'group2role' => ['vtiger_datashare_grp2role', 'to_roleid'], 'group2rs' => ['vtiger_datashare_grp2rs', 'to_roleandsubid'], 'group2user' => ['vtiger_datashare_grp2us', 'to_userid'], 'group2group' => ['vtiger_datashare_grp2grp', 'to_groupid'], 'user2user' => ['vtiger_datashare_us2us', 'to_userid'], 'user2group' => ['vtiger_datashare_us2grp', 'to_groupid'], 'user2role' => ['vtiger_datashare_us2role', 'to_roleid'], 'user2rs' => ['vtiger_datashare_us2rs', 'to_roleandsubid']]

$defaultSharingActionCache

protected static mixed $defaultSharingActionCache = false

$shareRulesTables

Tables to sharing rules.

private static array<string|int, mixed> $shareRulesTables = ['US::GRP' => 'vtiger_datashare_us2grp', 'US::ROLE' => 'vtiger_datashare_us2role', 'US::RS' => 'vtiger_datashare_us2rs', 'US::US' => 'vtiger_datashare_us2us', 'GRP::GRP' => 'vtiger_datashare_grp2grp', 'GRP::ROLE' => 'vtiger_datashare_grp2role', 'GRP::RS' => 'vtiger_datashare_grp2rs', 'GRP::US' => 'vtiger_datashare_grp2us', 'ROLE::GRP' => 'vtiger_datashare_role2group', 'ROLE::ROLE' => 'vtiger_datashare_role2role', 'ROLE::RS' => 'vtiger_datashare_role2rs', 'ROLE::US' => 'vtiger_datashare_role2us', 'RS::GRP' => 'vtiger_datashare_rs2grp', 'RS::ROLE' => 'vtiger_datashare_rs2role', 'RS::RS' => 'vtiger_datashare_rs2rs', 'RS::US' => 'vtiger_datashare_rs2us']

$shareRulesTablesIndex

List tables where sharing rules are save for users, groups and roles.

private static array<string|int, mixed> $shareRulesTablesIndex = ['Users' => ['vtiger_datashare_us2us' => 'share_userid::to_userid', 'vtiger_datashare_us2grp' => 'share_userid', 'vtiger_datashare_us2role' => 'share_userid', 'vtiger_datashare_us2rs' => 'share_userid', 'vtiger_datashare_grp2us' => 'to_userid', 'vtiger_datashare_rs2us' => 'to_userid', 'vtiger_datashare_role2us' => 'to_userid'], 'Roles' => ['vtiger_datashare_us2role' => 'to_roleid', 'vtiger_datashare_us2rs' => 'to_roleandsubid', 'vtiger_datashare_grp2role' => 'to_roleid', 'vtiger_datashare_grp2rs' => 'to_roleandsubid', 'vtiger_datashare_role2group' => 'share_roleid', 'vtiger_datashare_role2us' => 'share_roleid', 'vtiger_datashare_role2role' => 'share_roleid::to_roleid', 'vtiger_datashare_role2rs' => 'share_roleid::to_roleandsubid', 'vtiger_datashare_rs2grp' => 'share_roleandsubid', 'vtiger_datashare_rs2us' => 'share_roleandsubid', 'vtiger_datashare_rs2role' => 'share_roleandsubid::to_roleid', 'vtiger_datashare_rs2rs' => 'share_roleandsubid::to_roleandsubid'], 'Groups' => ['vtiger_datashare_grp2grp' => 'share_groupid::to_groupid', 'vtiger_datashare_grp2role' => 'share_groupid', 'vtiger_datashare_grp2rs' => 'share_groupid', 'vtiger_datashare_grp2us' => 'share_groupid', 'vtiger_datashare_role2group' => 'to_groupid', 'vtiger_datashare_rs2grp' => 'to_groupid', 'vtiger_datashare_us2grp' => 'to_groupid']]

Methods

deleteRelatedSharingRules()

Function to remove sharing rules from tables.

public static deleteRelatedSharingRules(int|string $id, string $type) : mixed
Parameters
$id : int|string
$type : string
Return values
mixed

getAllDefaultSharingAction()

This Function returns the Default Organisation Sharing Action Array for all modules.

public static getAllDefaultSharingAction() : array<string|int, mixed>
Return values
array<string|int, mixed>

getAllGroupsByUser()

Get all groups by user id.

public static getAllGroupsByUser(int $userId) : array<string|int, int>
Parameters
$userId : int
Return values
array<string|int, int>

getAllProfilePermissions()

Function to get the Standard and Utility Profile Action Permissions for the specified vtiger_profileid.

public static getAllProfilePermissions(int $profileid) : array<string|int, mixed>
Parameters
$profileid : int
Return values
array<string|int, mixed>

getCombinedUserActionsPermissions()

To retreive the vtiger_tab acion permissions of the specifed user from the various vtiger_profiles associated with the user.

public static getCombinedUserActionsPermissions(int $userId) : array<string|int, mixed>
Parameters
$userId : int
Return values
array<string|int, mixed>

getCombinedUserGlobalPermissions()

To retreive the global permission of the specifed user from the various vtiger_profiles associated with the user.

public static getCombinedUserGlobalPermissions(int $userId) : array<string|int, int>
Parameters
$userId : int
Return values
array<string|int, int>

getCombinedUserModulesPermissions()

To retreive the vtiger_tab permissions of the specifed user from the various vtiger_profiles associated with the user.

public static getCombinedUserModulesPermissions(int $userId) : array<string|int, mixed>
Parameters
$userId : int
Return values
array<string|int, mixed>

getDatashare()

Get data share.

public static getDatashare(mixed $type, int $tabId, mixed $data) : array<string|int, mixed>
Parameters
$type : mixed
$tabId : int
$data : mixed
Return values
array<string|int, mixed>

getDatashareRelatedModules()

Function to get data share related modules.

public static getDatashareRelatedModules() : array<string|int, mixed>
Return values
array<string|int, mixed>

getGroupsWhereUserIsLeader()

Returns groups whose leader is the user.

public static getGroupsWhereUserIsLeader(int $userId) : array<string|int, mixed>
Parameters
$userId : int
Return values
array<string|int, mixed>

getLeadersGroupByUserId()

Returns the leaders of the groups where the user is a member.

public static getLeadersGroupByUserId(int $userId) : array<string|int, mixed>
Parameters
$userId : int
Return values
array<string|int, mixed>

getMembers()

Function to get all members.

public static getMembers() : array<string|int, mixed>
Return values
array<string|int, mixed>

getParentGroups()

Get parent grioups by group id.

public static getParentGroups(int $groupId, int $i) : array<string|int, int>
Parameters
$groupId : int
$i : int
Return values
array<string|int, int>

getParentRecordOwner()

Function to get parent record owner.

public static getParentRecordOwner( $tabid,  $parModId,  $recordId) : mixed
Parameters
$tabid :

-- tabid :: Type integer

$parModId :

-- parent module id :: Type integer

$recordId :

-- record id :: Type integer

Tags
returns

$parentRecOwner -- parentRecOwner:: Type integer

Return values
mixed

getParentRole()

To retreive the parent vtiger_role of the specified vtiger_role.

public static getParentRole(mixed $roleId) : parent
Parameters
$roleId : mixed
Return values
parent

vtiger_role array in the following format:

getProfileGlobalPermission()

Function to get the Profile Global Information for the specified vtiger_profileid.

public static getProfileGlobalPermission(int $profileid) : array<string|int, int>
Parameters
$profileid : int
Return values
array<string|int, int>

getProfilesByRole()

This function is to retreive the vtiger_profiles associated with the the specified role.

public static getProfilesByRole(string $roleId) : array<string|int, mixed>
Parameters
$roleId : string
Return values
array<string|int, mixed>

getProfilesByUser()

This function is to retreive the vtiger_profiles associated with the the specified user.

public static getProfilesByUser(int $userId) : array<string|int, mixed>
Parameters
$userId : int
Return values
array<string|int, mixed>

getProfileTabsPermission()

Function to get the Profile Tab Permissions for the specified vtiger_profileid.

public static getProfileTabsPermission(int $profileid) : array<string|int, int>
Parameters
$profileid : int
Return values
array<string|int, int>

getQueryToGroupsByUserId()

Creates a query to all groups where the user is a member.

public static getQueryToGroupsByUserId(int $userId) : Query

.

Parameters
$userId : int
Return values
Query

getQueryToUsersByGroup()

Gets query to users by group.

public static getQueryToUsersByGroup(int $groupId[, bool $recursive = true ], int $depth) : Query
Parameters
$groupId : int
$recursive : bool = true
$depth : int
Return values
Query

getQueryToUsersByMembers()

Gets query to users by members.

public static getQueryToUsersByMembers(array<string|int, mixed> $members) : Query
Parameters
$members : array<string|int, mixed>
Return values
Query

getQueryToUsersByRole()

Gets query to users by role.

public static getQueryToUsersByRole(string $roleId) : Query
Parameters
$roleId : string
Return values
Query

getQueryToUsersByRoleAndSubordinate()

Gets query to users by role and subordinate.

public static getQueryToUsersByRoleAndSubordinate(string $roleId) : Query
Parameters
$roleId : string
Return values
Query

getRoleByUsers()

Function to get the role related user ids.

public static getRoleByUsers(int $userId) : mixed
Parameters
$userId : int

RoleId :: Type varchar

Return values
mixed

getRoleDetail()

Function to get the vtiger_role information of the specified vtiger_role.

public static getRoleDetail( $roleId) : array<string|int, mixed>|bool|string
Parameters
$roleId :
Return values
array<string|int, mixed>|bool|string

getRoleName()

Function to get the role name.

public static getRoleName(int $roleId) : string
Parameters
$roleId : int
Return values
string

getRoleSubordinates()

To retreive the subordinate vtiger_roles of the specified parent vtiger_role.

public static getRoleSubordinates(int $roleId) : array<string|int, mixed>
Parameters
$roleId : int
Return values
array<string|int, mixed>

getStandardPermissions()

Function to get the Profile Action Permissions for the specified vtiger_profileid.

public static getStandardPermissions(int $profileid) : array<string|int, mixed>
Parameters
$profileid : int
Return values
array<string|int, mixed>

getUserByMember()

Get list of users based on members, eg. Users:2, Roles:H2.

public static getUserByMember(string $member) : array<string|int, mixed>
Parameters
$member : string
Return values
array<string|int, mixed>

getUserGroups()

Function to get user groups.

public static getUserGroups(int $userId) : array<string|int, mixed>
Parameters
$userId : int
Return values
array<string|int, mixed>
  • groupId's

getUserModuleSharingObjects()

Gives an array which contains the information for what all roles, groups and user data is to be shared with the spcified user for the specified module.

public static getUserModuleSharingObjects(string $module, int $userid, array<string|int, mixed> $defOrgShare, string $currentUserRoles, string $parentRoles, int $currentUserGroups) : array<string|int, mixed>
Parameters
$module : string

module name

$userid : int

user id

$defOrgShare : array<string|int, mixed>

default organization sharing permission array

$currentUserRoles : string

roleid

$parentRoles : string

parent roles

$currentUserGroups : int

user id

Return values
array<string|int, mixed>

array which contains the id of roles,group and users data shared with specifed user for the specified module

getUsersByGroup()

Get list of users based on group id.

public static getUsersByGroup(int $groupId[, array<string|int, mixed>|bool $subGroups = false ], int $i) : array<string|int, mixed>
Parameters
$groupId : int
$subGroups : array<string|int, mixed>|bool = false
$i : int
Return values
array<string|int, mixed>

getUsersByRole()

Function to get the vtiger_role related user ids.

public static getUsersByRole(string $roleId) : array<string|int, mixed>
Parameters
$roleId : string

Role ID

Return values
array<string|int, mixed>

$users Role related user array

getUsersByRoleAndSubordinate()

Function to get the roles and subordinate users.

public static getUsersByRoleAndSubordinate(string $roleId) : array<string|int, mixed>
Parameters
$roleId : string
Return values
array<string|int, mixed>

getUsersNameByRole()

Function to get the users names by role.

public static getUsersNameByRole(int $roleId) : array<string|int, mixed>
Parameters
$roleId : int
Return values
array<string|int, mixed>

$users

getUtilityPermissions()

Function to get all the vtiger_tab utility action permission for the specified vtiger_profile.

public static getUtilityPermissions(int $profileid) : array<string|int, mixed>
Parameters
$profileid : int
Return values
array<string|int, mixed>

isExists()

Check if element exists in organization structure.

public static isExists(int|string $member) : bool
Parameters
$member : int|string
Return values
bool

modifyPermissions()

Modify permissions for actions and views.

public static modifyPermissions(string $moduleName, array<string|int, mixed> $actions, bool $mode) : bool
Parameters
$moduleName : string
$actions : array<string|int, mixed>
$mode : bool

true: add, false: remove

Return values
bool

recalculateSharingRulesByUser()

Recalculate sharing rules by user id.

public static recalculateSharingRulesByUser(int $id) : mixed
Parameters
$id : int
Return values
mixed

testPrivileges()

Function for test to check privilege utils.

public static testPrivileges(int $recordId) : mixed
Parameters
$recordId : int
Return values
mixed

deleteSharingRule()

This function is to delete the organisation level sharing rule It takes the following input parameters:.

private static deleteSharingRule(int $shareid) : mixed
Parameters
$shareid : int

Id of the Sharing Rule to be updated

Return values
mixed

getHelpDeskRelatedAccounts()

Function return related account with ticket.

private static getHelpDeskRelatedAccounts(int $recordId) : int
Parameters
$recordId : int
Return values
int

        

Search results