ILIAS  trunk Revision v13.0_alpha-46-gad4e41c4eac
ilRbacReview Class Reference

class ilRbacReview Contains Review functions of core Rbac. More...

+ Collaboration diagram for ilRbacReview:

Public Member Functions

 __construct (protected ilDBInterface $db, protected LoggerInterface $log)
 Constructor @access public. More...
 
 roleExists (string $a_title, int $a_id=0)
 Checks if a role already exists. More...
 
 getParentRoleIds (int $a_endnode_id, bool $a_templates=false)
 Get an array of parent role ids of all parent roles, if last parameter is set true you get also all parent templates. More...
 
 getRoleListByObject (int $a_ref_id, bool $a_templates=false)
 Returns a list of roles in an container. More...
 
 getAssignableRoles (bool $a_templates=false, bool $a_internal_roles=false, string $title_filter='')
 Returns a list of all assignable roles. More...
 
 getAssignableRolesInSubtree (int $ref_id)
 Returns a list of assignable roles in a subtree of the repository. More...
 
 getAssignableChildRoles (int $a_ref_id)
 Get all assignable roles directly under a specific node. More...
 
 getNumberOfAssignedUsers (array $a_roles)
 Get the number of assigned users to roles (not properly deleted user accounts are not counted) More...
 
 assignedUsers (int $a_rol_id)
 get all assigned users to a given role More...
 
 isAssigned (int $a_usr_id, int $a_role_id)
 check if a specific user is assigned to specific role More...
 
 isAssignedToAtLeastOneGivenRole (int $a_usr_id, array $a_role_ids)
 check if a specific user is assigned to at least one of the given role ids. More...
 
 assignedRoles (int $a_usr_id)
 get all assigned roles to a given user More...
 
 assignedGlobalRoles (int $a_usr_id)
 Get assigned global roles for an user. More...
 
 isAssignable (int $a_rol_id, int $a_ref_id)
 Check if its possible to assign users. More...
 
 hasMultipleAssignments (int $a_role_id)
 
 getFoldersAssignedToRole (int $a_rol_id, bool $a_assignable=false)
 Returns an array of objects assigned to a role. More...
 
 getRolesOfObject (int $a_ref_id, bool $a_assignable_only=false)
 Get roles of object. More...
 
 getRolesOfRoleFolder (int $a_ref_id, bool $a_nonassignable=true)
 get all roles of a role folder including linked local roles that are created due to stopped inheritance returns an array with role ids More...
 
 getGlobalRoles ()
 get only 'global' roles More...
 
 getLocalRoles (int $a_ref_id)
 Get local roles of object. More...
 
 getLocalPolicies (int $a_ref_id)
 Get all roles with local policies. More...
 
 getGlobalRolesArray ()
 get only 'global' roles More...
 
 getGlobalAssignableRoles ()
 get only 'global' roles (with flag 'assign_users') More...
 
 isRoleAssignedToObject (int $a_role_id, int $a_parent_id)
 Check if role is assigned to an object. More...
 
 getOperations ()
 get all possible operations More...
 
 getOperation (int $ops_id)
 get one operation by operation id More...
 
 getAllOperationsOfRole (int $a_rol_id, int $a_parent=0)
 get all possible operations of a specific role The ref_id of the role folder (parent object) is necessary to distinguish local roles More...
 
 getActiveOperationsOfRole (int $a_ref_id, int $a_role_id)
 
 getOperationsOfRole (int $a_rol_id, string $a_type, int $a_parent=0)
 get all possible operations of a specific role The ref_id of the role folder (parent object) is necessary to distinguish local roles More...
 
 getRoleOperationsOnObject (int $a_role_id, int $a_ref_id)
 
 getOperationsOnType (int $a_typ_id)
 all possible operations of a type More...
 
 getOperationsOnTypeString (string $a_type)
 all possible operations of a type More...
 
 getOperationsByTypeAndClass (string $a_type, string $a_class)
 Get operations by type and class. More...
 
 getObjectsWithStopedInheritance (int $a_rol_id, array $a_filter=[])
 get all objects in which the inheritance of role with role_id was stopped the function returns all reference ids of objects containing a role folder. More...
 
 isDeleted (int $a_node_id)
 Checks if a rolefolder is set as deleted (negative tree_id) More...
 
 isGlobalRole (int $a_role_id)
 Check if role is a global role. More...
 
 getRolesByFilter (int $a_filter=0, int $a_user_id=0, string $title_filter='')
 
 getTypeId (string $a_type)
 
 isProtected (int $a_ref_id, int $a_role_id)
 ref_id not used yet. More...
 
 isBlockedAtPosition (int $a_role_id, int $a_ref_id)
 
 isBlockedInUpperContext (int $a_role_id, int $a_ref_id)
 Check if role is blocked in upper context. More...
 
 getObjectOfRole (int $a_role_id)
 Get object id of objects a role is assigned to. More...
 
 getObjectReferenceOfRole (int $a_role_id)
 
 isRoleDeleted (int $a_role_id)
 return if role is only attached to deleted role folders More...
 
 getRolesForIDs (array $role_ids, bool $use_templates)
 
 getOperationAssignment ()
 get operation assignments More...
 
 isDeleteable (int $a_role_id, int $a_rolf_id)
 Check if role is deleteable at a specific position. More...
 
 isSystemGeneratedRole (int $a_role_id)
 Check if the role is system generate role or role template. More...
 
 getRoleFolderOfRole (int $a_role_id)
 
 getUserPermissionsOnObject (int $a_user_id, int $a_ref_id)
 Get all user permissions on an object. More...
 
 setAssignedCacheEntry (int $a_role_id, int $a_user_id, bool $a_value)
 set entry of assigned_chache More...
 
 getAssignedCacheEntry (int $a_role_id, int $a_user_id)
 
 clearCaches ()
 Clear assigned users caches. More...
 

Static Public Member Functions

static _getOperationIdsByName (array $operations)
 get ops_id's by name. More...
 
static _getOperationIdByName (string $a_operation)
 get operation id by name of operation More...
 
static lookupCreateOperationIds (array $a_type_arr)
 Lookup operation ids. More...
 
static _getOperationList (string $a_type='')
 get operation list by object type More...
 
static _groupOperationsByClass (array $a_ops_arr)
 
static _getCustomRBACOperationId (string $operation, ?\ilDBInterface $ilDB=null)
 
static _isRBACOperation (int $type_id, int $ops_id, ?\ilDBInterface $ilDB=null)
 

Data Fields

const FILTER_ALL = 1
 
const FILTER_ALL_GLOBAL = 2
 
const FILTER_ALL_LOCAL = 3
 
const FILTER_INTERNAL = 4
 
const FILTER_NOT_INTERNAL = 5
 
const FILTER_TEMPLATES = 6
 

Protected Member Functions

 __getParentRoles (array $a_path, bool $a_templates)
 Note: This function performs faster than the new getParentRoles function, because it uses database indexes whereas getParentRoles needs a full table space scan. More...
 
 __setTemplateFilter (bool $a_templates)
 get roles and templates or only roles; returns string for where clause More...
 
 __setRoleType (array $a_role_list)
 computes role type in role list array: global: roles in ROLE_FOLDER_ID local: assignable roles in other role folders linked: roles with stoppped inheritance template: role templates More...
 
 __setProtectedStatus (array $a_parent_roles, array $a_role_hierarchy, int $a_ref_id)
 

Static Protected Attributes

static array $assigned_users_cache = []
 
static array $is_assigned_cache = []
 

Private Member Functions

 getAssignableRolesGenerator (bool $a_templates=false, bool $a_internal_roles=false, string $title_filter='')
 
 setRoleTypeAndProtection (array $role_list_entry)
 
 buildRoleType (array $role_list_entry)
 
 buildProtectionByStringValue (string $value)
 

Static Private Attributes

static array $_opsCache = null
 

Detailed Description

class ilRbacReview Contains Review functions of core Rbac.

This class offers the possibility to view the contents of the user <-> role (UR) relation and the permission <-> role (PR) relation. For example, from the UA relation the administrator should have the facility to view all user assigned to a given role.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Sascha Hofmann sasch.nosp@m.ahof.nosp@m.mann@.nosp@m.gmx..nosp@m.de
Version
$Id$

@phpstan-type RoleListEntry array{obj_id: int, rol_id: int, parent: int, user_id: int, owner: int, title: ?string, desc: string, description: string, create_date: ?string, last_update: ?string, import_id: ?string, tile_image_rid: ?string, role_type: string, offline: ?int, type: string, assign: string, protected: bool, blocked: int, rol_id: int}

Definition at line 35 of file class.ilRbacReview.php.

Constructor & Destructor Documentation

◆ __construct()

ilRbacReview::__construct ( protected ilDBInterface  $db,
protected LoggerInterface  $log 
)

Constructor @access public.

Definition at line 54 of file class.ilRbacReview.php.

57 {
58 }

Member Function Documentation

◆ __getParentRoles()

ilRbacReview::__getParentRoles ( array  $a_path,
bool  $a_templates 
)
protected

Note: This function performs faster than the new getParentRoles function, because it uses database indexes whereas getParentRoles needs a full table space scan.

Get parent roles in a path. If last parameter is set 'true' it delivers also all templates in the path

Parameters
arrayarray with path_ids
booltrue for role templates (default: false)
Returns
array array with all parent roles (obj_ids)

Definition at line 92 of file class.ilRbacReview.php.

92 : array
93 {
94 $parent_roles = [];
95 $role_hierarchy = [];
96 foreach ($a_path as $ref_id) {
97 $roles = $this->getRoleListByObject($ref_id, $a_templates);
98 foreach ($roles as $role) {
99 $id = (int) $role["obj_id"];
100 $role["parent"] = (int) $ref_id;
101 $parent_roles[$id] = $role;
102
103 if (!array_key_exists($role['obj_id'], $role_hierarchy)) {
104 $role_hierarchy[$id] = $ref_id;
105 }
106 }
107 }
108 return $this->__setProtectedStatus($parent_roles, $role_hierarchy, (int) reset($a_path));
109 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
__setProtectedStatus(array $a_parent_roles, array $a_role_hierarchy, int $a_ref_id)
getRoleListByObject(int $a_ref_id, bool $a_templates=false)
Returns a list of roles in an container.

References $id, __setProtectedStatus(), getRoleListByObject(), and ILIAS\Repository\int().

Referenced by getParentRoleIds().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __setProtectedStatus()

ilRbacReview::__setProtectedStatus ( array  $a_parent_roles,
array  $a_role_hierarchy,
int  $a_ref_id 
)
protected

Definition at line 1105 of file class.ilRbacReview.php.

1105 : array
1106 {
1107 global $DIC;
1108
1109 $rbacsystem = $DIC->rbac()->system();
1110 $ilUser = $DIC->user();
1111 if (in_array(SYSTEM_ROLE_ID, $this->assignedRoles($ilUser->getId()))) {
1112 $leveladmin = true;
1113 } else {
1114 $leveladmin = false;
1115 }
1116 foreach ($a_role_hierarchy as $role_id => $rolf_id) {
1117 if ($leveladmin == true) {
1118 $a_parent_roles[$role_id]['protected'] = false;
1119 continue;
1120 }
1121
1122 if ($a_parent_roles[$role_id]['protected'] == true) {
1123 $arr_lvl_roles_user = array_intersect(
1124 $this->assignedRoles($ilUser->getId()),
1125 array_keys($a_role_hierarchy, $rolf_id)
1126 );
1127
1128 foreach ($arr_lvl_roles_user as $lvl_role_id) {
1129 // check if role grants 'edit_permission' to parent
1130 $rolf = $a_parent_roles[$role_id]['parent'];
1131 if ($rbacsystem->checkPermission($rolf, $lvl_role_id, 'edit_permission')) {
1132 $a_parent_roles[$role_id]['protected'] = false;
1133 }
1134 }
1135 }
1136 }
1137 return $a_parent_roles;
1138 }
assignedRoles(int $a_usr_id)
get all assigned roles to a given user
const SYSTEM_ROLE_ID
Definition: constants.php:29
global $DIC
Definition: shib_login.php:26

References $DIC, and SYSTEM_ROLE_ID.

Referenced by __getParentRoles().

+ Here is the caller graph for this function:

◆ __setRoleType()

ilRbacReview::__setRoleType ( array  $a_role_list)
protected

computes role type in role list array: global: roles in ROLE_FOLDER_ID local: assignable roles in other role folders linked: roles with stoppped inheritance template: role templates

Definition at line 283 of file class.ilRbacReview.php.

283 : array
284 {
285 foreach ($a_role_list as $key => $val) {
286 $a_role_list[$key] = $this->setRoleTypeAndProtection($val);
287 }
288 return $a_role_list;
289 }
setRoleTypeAndProtection(array $role_list_entry)

Referenced by getRoleListByObject().

+ Here is the caller graph for this function:

◆ __setTemplateFilter()

ilRbacReview::__setTemplateFilter ( bool  $a_templates)
protected

get roles and templates or only roles; returns string for where clause

Definition at line 266 of file class.ilRbacReview.php.

266 : string
267 {
268 if ($a_templates) {
269 $where = "WHERE " . $this->db->in('object_data.type', ['role', 'rolt'], false, 'text') . " ";
270 } else {
271 $where = "WHERE " . $this->db->in('object_data.type', ['role'], false, 'text') . " ";
272 }
273 return $where;
274 }

Referenced by getRoleListByObject().

+ Here is the caller graph for this function:

◆ _getCustomRBACOperationId()

static ilRbacReview::_getCustomRBACOperationId ( string  $operation,
?\ilDBInterface  $ilDB = null 
)
static

Definition at line 1419 of file class.ilRbacReview.php.

1419 : ?int
1420 {
1421 if (!$ilDB) {
1422 global $DIC;
1423 $ilDB = $DIC->database();
1424 }
1425
1426 $sql =
1427 "SELECT ops_id" . PHP_EOL
1428 . "FROM rbac_operations" . PHP_EOL
1429 . "WHERE operation = " . $ilDB->quote($operation, "text") . PHP_EOL
1430 ;
1431
1432 $res = $ilDB->query($sql);
1433 if ($ilDB->numRows($res) == 0) {
1434 return null;
1435 }
1436
1437 $row = $ilDB->fetchAssoc($res);
1438 return (int) $row["ops_id"] ?? null;
1439 }
foreach($_POST as $key=> $value) $res

References $DIC, $ilDB, and $res.

Referenced by ilAccessCustomRBACOperationAddedObjective\achieve(), ilAccessInitialPermissionGuidelineAppliedObjective\achieve(), ilAccessRbacStandardOperationsAddedObjective\achieve(), ilAccessRolePermissionSetObjective\achieve(), ILIAS\BookingManager\Setup\AccessRBACOperationClonedObjective\achieve(), ILIAS\Wiki\Setup\AccessRBACOperationClonedObjective\achieve(), ilDBUpdateNewObjectType\addCustomRBACOperation(), ilDBUpdateNewObjectType\addRBACOperations(), ilAccessCustomRBACOperationAddedObjective\isApplicable(), ilAccessInitialPermissionGuidelineAppliedObjective\isApplicable(), ilAccessRbacStandardOperationsAddedObjective\isApplicable(), and ilDBUpdateNewObjectType\setRolePermission().

+ Here is the caller graph for this function:

◆ _getOperationIdByName()

static ilRbacReview::_getOperationIdByName ( string  $a_operation)
static

get operation id by name of operation

Definition at line 985 of file class.ilRbacReview.php.

985 : int
986 {
987 global $DIC;
988
989 $ilDB = $DIC->database();
990
991 // Cache operation ids
992 if (!is_array(self::$_opsCache)) {
993 self::$_opsCache = [];
994
995 $q = "SELECT ops_id, operation FROM rbac_operations";
996 $r = $ilDB->query($q);
997 while ($row = $r->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
998 self::$_opsCache[$row->operation] = (int) $row->ops_id;
999 }
1000 }
1001
1002 // Get operation ID by name from cache
1003 if (array_key_exists($a_operation, self::$_opsCache)) {
1004 return self::$_opsCache[$a_operation];
1005 }
1006 return 0;
1007 }
const FETCHMODE_OBJECT

References $DIC, $ilDB, ilDBConstants\FETCHMODE_OBJECT, and ILIAS\Repository\int().

Referenced by ilRepositoryObjectPlugin\beforeActivation(), ilRbacSystem\checkAccessOfUser(), ilObjBlog\getRolesWithContributeOrRedact(), and ilRbacSystem\hasAnyAdminReadPermission().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getOperationIdsByName()

static ilRbacReview::_getOperationIdsByName ( array  $operations)
static

get ops_id's by name.

Example usage: $rbacadmin->grantPermission($roles,ilRbacReview::_getOperationIdsByName(array('visible','read'),$ref_id));

Parameters
list<string>$operations
Returns
list<int>

Definition at line 962 of file class.ilRbacReview.php.

962 : array
963 {
964 global $DIC;
965
966 $ilDB = $DIC->database();
967 if ($operations === []) {
968 return [];
969 }
970
971 $query = 'SELECT ops_id FROM rbac_operations ' .
972 'WHERE ' . $ilDB->in('operation', $operations, false, 'text');
973
974 $res = $ilDB->query($query);
975 $ops_ids = [];
976 while ($row = $ilDB->fetchObject($res)) {
977 $ops_ids[] = (int) $row->ops_id;
978 }
979 return $ops_ids;
980 }

References $DIC, $ilDB, $res, and ILIAS\Repository\int().

Referenced by ilLTIProviderObjectSettingGUI\createLocalRole(), and ilECSObjectSettings\handlePermissionUpdate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getOperationList()

static ilRbacReview::_getOperationList ( string  $a_type = '')
static

get operation list by object type

Returns
list<array{obj_id: int, operation: ?string, desc: ?string, class: ?string, op_order: int}>

Definition at line 1144 of file class.ilRbacReview.php.

1144 : array
1145 {
1146 global $DIC;
1147
1148 $ilDB = $DIC->database();
1149 $arr = [];
1150 if ($a_type) {
1151 $query = sprintf(
1152 'SELECT * FROM rbac_operations ' .
1153 'JOIN rbac_ta ON rbac_operations.ops_id = rbac_ta.ops_id ' .
1154 'JOIN object_data ON rbac_ta.typ_id = object_data.obj_id ' .
1155 'WHERE object_data.title = %s ' .
1156 'AND object_data.type = %s ' .
1157 'ORDER BY op_order ASC',
1158 $ilDB->quote($a_type, 'text'),
1159 $ilDB->quote('typ', 'text')
1160 );
1161 } else {
1162 $query = 'SELECT * FROM rbac_operations ORDER BY op_order ASC';
1163 }
1164 $res = $ilDB->query($query);
1165 while ($row = $ilDB->fetchAssoc($res)) {
1166 $arr[] = [
1167 "ops_id" => (int) $row['ops_id'],
1168 "operation" => $row['operation'],
1169 "desc" => $row['description'],
1170 "class" => $row['class'],
1171 "order" => (int) $row['op_order']
1172 ];
1173 }
1174 return $arr;
1175 }

References $DIC, $ilDB, $res, and ILIAS\Repository\int().

Referenced by ilSettingsPermissionGUI\__construct(), ilObjTypeDefinitionGUI\editObject(), ilObjectPermissionStatusGUI\getAccessPermissionTableData(), ilObjectPermissionStatusGUI\getAssignedValidRoles(), and ilObjTypeDefinitionGUI\viewObject().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _groupOperationsByClass()

static ilRbacReview::_groupOperationsByClass ( array  $a_ops_arr)
static
Returns
array<string, list<array{ops_id: int, name: ?string}>>

Definition at line 1180 of file class.ilRbacReview.php.

1180 : array
1181 {
1182 $arr = [];
1183 foreach ($a_ops_arr as $ops) {
1184 $arr[$ops['class']][] = ['ops_id' => (int) $ops['ops_id'],
1185 'name' => $ops['operation']
1186 ];
1187 }
1188 return $arr;
1189 }

References ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ _isRBACOperation()

static ilRbacReview::_isRBACOperation ( int  $type_id,
int  $ops_id,
?\ilDBInterface  $ilDB = null 
)
static

Definition at line 1441 of file class.ilRbacReview.php.

1441 : bool
1442 {
1443 if (!$ilDB) {
1444 global $DIC;
1445 $ilDB = $DIC->database();
1446 }
1447
1448 $sql =
1449 "SELECT typ_id" . PHP_EOL
1450 . "FROM rbac_ta" . PHP_EOL
1451 . "WHERE typ_id = " . $ilDB->quote($type_id, "integer") . PHP_EOL
1452 . "AND ops_id = " . $ilDB->quote($ops_id, "integer") . PHP_EOL
1453 ;
1454
1455 return (bool) $ilDB->numRows($ilDB->query($sql));
1456 }

References $DIC, and $ilDB.

Referenced by ilAccessRbacStandardOperationsAddedObjective\achieve(), ilTreeAdminNodeAddedObjective\achieve(), and ilAccessRbacStandardOperationsAddedObjective\isApplicable().

+ Here is the caller graph for this function:

◆ assignedGlobalRoles()

ilRbacReview::assignedGlobalRoles ( int  $a_usr_id)

Get assigned global roles for an user.

Returns
list<int>

Definition at line 424 of file class.ilRbacReview.php.

424 : array
425 {
426 $query = "SELECT ua.rol_id FROM rbac_ua ua " .
427 "JOIN rbac_fa fa ON ua.rol_id = fa.rol_id " .
428 "WHERE usr_id = " . $this->db->quote($a_usr_id, 'integer') . ' ' .
429 "AND parent = " . $this->db->quote(ROLE_FOLDER_ID, ilDBConstants::T_INTEGER) . " " .
430 "AND assign = 'y' ";
431
432 $res = $this->db->query($query);
433 $role_arr = [];
434 while ($row = $this->db->fetchObject($res)) {
435 $role_arr[] = (int) $row->rol_id;
436 }
437
438 return $role_arr;
439 }
const ROLE_FOLDER_ID
Definition: constants.php:34

References $res, ILIAS\Repository\int(), ROLE_FOLDER_ID, and ilDBConstants\T_INTEGER.

+ Here is the call graph for this function:

◆ assignedRoles()

ilRbacReview::assignedRoles ( int  $a_usr_id)

get all assigned roles to a given user

Returns
list<int> all roles (id) the user is assigned to

Definition at line 408 of file class.ilRbacReview.php.

408 : array
409 {
410 $query = "SELECT rol_id FROM rbac_ua WHERE usr_id = " . $this->db->quote($a_usr_id, 'integer');
411
412 $res = $this->db->query($query);
413 $role_arr = [];
414 while ($row = $this->db->fetchObject($res)) {
415 $role_arr[] = (int) $row->rol_id;
416 }
417 return $role_arr;
418 }

References $res, and ILIAS\Repository\int().

Referenced by ilCalendarShared\getSharedCalendarsForUser(), and ilCalendarShared\isSharedWithUser().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ assignedUsers()

ilRbacReview::assignedUsers ( int  $a_rol_id)

get all assigned users to a given role

Returns
list<int> all users (id) assigned to role

Definition at line 346 of file class.ilRbacReview.php.

346 : array
347 {
348 if (isset(self::$assigned_users_cache[$a_rol_id])) {
349 return self::$assigned_users_cache[$a_rol_id];
350 }
351
352 $result_arr = [];
353 $query = "SELECT usr_id FROM rbac_ua WHERE rol_id= " . $this->db->quote($a_rol_id, 'integer');
354 $res = $this->db->query($query);
355 while ($row = $this->db->fetchAssoc($res)) {
356 $result_arr[] = (int) $row["usr_id"];
357 }
358 self::$assigned_users_cache[$a_rol_id] = $result_arr;
359 return $result_arr;
360 }

References $res, and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ buildProtectionByStringValue()

ilRbacReview::buildProtectionByStringValue ( string  $value)
private

Definition at line 315 of file class.ilRbacReview.php.

315 : bool
316 {
317 if ($value === 'y') {
318 return true;
319 }
320 return false;
321 }

◆ buildRoleType()

ilRbacReview::buildRoleType ( array  $role_list_entry)
private

Definition at line 298 of file class.ilRbacReview.php.

298 : string
299 {
300 if ($role_list_entry['type'] === 'rolt') {
301 return 'template';
302 }
303
304 if ($role_list_entry['assign'] !== 'y') {
305 return 'linked';
306 }
307
308 if ($role_list_entry['parent'] === ROLE_FOLDER_ID) {
309 return 'global';
310 }
311
312 return 'local';
313 }

References ROLE_FOLDER_ID.

◆ clearCaches()

ilRbacReview::clearCaches ( )

Clear assigned users caches.

Definition at line 1413 of file class.ilRbacReview.php.

1413 : void
1414 {
1415 self::$is_assigned_cache = [];
1416 self::$assigned_users_cache = [];
1417 }

◆ getActiveOperationsOfRole()

ilRbacReview::getActiveOperationsOfRole ( int  $a_ref_id,
int  $a_role_id 
)
Returns
list<int>

Definition at line 690 of file class.ilRbacReview.php.

690 : array
691 {
692 $query = 'SELECT * FROM rbac_pa ' .
693 'WHERE ref_id = ' . $this->db->quote($a_ref_id, 'integer') . ' ' .
694 'AND rol_id = ' . $this->db->quote($a_role_id, 'integer') . ' ';
695
696 $res = $this->db->query($query);
697 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
698 return array_map(
699 intval(...),
700 $row['ops_id'] === ':' ? [] : unserialize($row['ops_id'], ['allowed_classes' => false])
701 );
702 }
703 return [];
704 }
const FETCHMODE_ASSOC

References $res, and ilDBConstants\FETCHMODE_ASSOC.

◆ getAllOperationsOfRole()

ilRbacReview::getAllOperationsOfRole ( int  $a_rol_id,
int  $a_parent = 0 
)

get all possible operations of a specific role The ref_id of the role folder (parent object) is necessary to distinguish local roles

Returns
array<string, list<int>>

Definition at line 670 of file class.ilRbacReview.php.

670 : array
671 {
672 if (!$a_parent) {
673 $a_parent = ROLE_FOLDER_ID;
674 }
675 $query = "SELECT ops_id,type FROM rbac_templates " .
676 "WHERE rol_id = " . $this->db->quote($a_rol_id, 'integer') . " " .
677 "AND parent = " . $this->db->quote($a_parent, 'integer');
678 $res = $this->db->query($query);
679
680 $ops_arr = [];
681 while ($row = $this->db->fetchObject($res)) {
682 $ops_arr[$row->type][] = (int) $row->ops_id;
683 }
684 return $ops_arr;
685 }

References $res, ILIAS\Repository\int(), and ROLE_FOLDER_ID.

+ Here is the call graph for this function:

◆ getAssignableChildRoles()

ilRbacReview::getAssignableChildRoles ( int  $a_ref_id)

Get all assignable roles directly under a specific node.

Definition at line 243 of file class.ilRbacReview.php.

243 : array
244 {
245 $query = "SELECT fa.*, rd.* " .
246 "FROM object_data rd " .
247 "JOIN rbac_fa fa ON rd.obj_id = fa.rol_id " .
248 "WHERE fa.assign = 'y' " .
249 "AND fa.parent = " . $this->db->quote($a_ref_id, 'integer') . " ";
250
251 $res = $this->db->query($query);
252 $roles_data = [];
253 while ($row = $this->db->fetchAssoc($res)) {
254 $row['rol_id'] = (int) $row['rol_id'];
255 $row['obj_id'] = (int) $row['obj_id'];
256
257 $roles_data[] = $row;
258 }
259
260 return $roles_data;
261 }

References $res, and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ getAssignableRoles()

ilRbacReview::getAssignableRoles ( bool  $a_templates = false,
bool  $a_internal_roles = false,
string  $title_filter = '' 
)

Returns a list of all assignable roles.

Returns
list<RoleListEntry>

Definition at line 165 of file class.ilRbacReview.php.

169 : array {
170 return iterator_to_array(
172 $a_templates,
173 $a_internal_roles,
174 $title_filter
175 )
176 );
177 }
getAssignableRolesGenerator(bool $a_templates=false, bool $a_internal_roles=false, string $title_filter='')

◆ getAssignableRolesGenerator()

ilRbacReview::getAssignableRolesGenerator ( bool  $a_templates = false,
bool  $a_internal_roles = false,
string  $title_filter = '' 
)
private
Returns
Generator<RoleListEntry>

Definition at line 182 of file class.ilRbacReview.php.

186 : Generator {
187 $where = $this->__setTemplateFilter($a_templates);
188 $query = "SELECT * FROM object_data " .
189 "JOIN rbac_fa ON obj_id = rol_id " .
190 $where .
191 "AND rbac_fa.assign = 'y' ";
192
193 if (strlen($title_filter)) {
194 $query .= (' AND ' . $this->db->like(
195 'title',
196 'text',
197 $title_filter . '%'
198 ));
199 }
200 $res = $this->db->query($query);
201
202 while ($row = $this->db->fetchAssoc($res)) {
203 $row["description"] = (string) $row["description"];
204 $row["desc"] = $row["description"];
205 $row["user_id"] = (int) $row["owner"];
206 $row['obj_id'] = (int) $row['obj_id'];
207 $row['parent'] = (int) $row['parent'];
208 yield $this->setRoleTypeAndProtection($row);
209 }
210 }
__setTemplateFilter(bool $a_templates)
get roles and templates or only roles; returns string for where clause

◆ getAssignableRolesInSubtree()

ilRbacReview::getAssignableRolesInSubtree ( int  $ref_id)

Returns a list of assignable roles in a subtree of the repository.

Todo:
move tree to construct. Currently this is not possible due to init sequence
Returns
list<int>

Definition at line 217 of file class.ilRbacReview.php.

217 : array
218 {
219 global $DIC;
220
221 $tree = $DIC->repositoryTree();
222 $query = 'SELECT rol_id FROM rbac_fa fa ' .
223 'JOIN tree t1 ON t1.child = fa.parent ' .
224 'JOIN object_data obd ON fa.rol_id = obd.obj_id ' .
225 'WHERE assign = ' . $this->db->quote('y', 'text') . ' ' .
226 'AND obd.type = ' . $this->db->quote('role', 'text') . ' ' .
227 'AND t1.child IN (' .
228 $tree->getSubTreeQuery($ref_id, ['child']) . ' ' .
229 ') ';
230
231 $res = $this->db->query($query);
232
233 $role_list = [];
234 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
235 $role_list[] = (int) $row->rol_id;
236 }
237 return $role_list;
238 }

References $DIC, $res, ilDBConstants\FETCHMODE_OBJECT, and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ getAssignedCacheEntry()

ilRbacReview::getAssignedCacheEntry ( int  $a_role_id,
int  $a_user_id 
)

Definition at line 1405 of file class.ilRbacReview.php.

1405 : bool
1406 {
1407 return self::$is_assigned_cache[$a_role_id][$a_user_id];
1408 }

◆ getFoldersAssignedToRole()

ilRbacReview::getFoldersAssignedToRole ( int  $a_rol_id,
bool  $a_assignable = false 
)

Returns an array of objects assigned to a role.

A role with stopped inheritance may be assigned to more than one objects. To get only the original location of a role, set the second parameter to true @access public

Parameters
introle id
boolget only rolefolders where role is assignable (true)
Returns
list<int> reference IDs of role folders

Definition at line 478 of file class.ilRbacReview.php.

478 : array
479 {
480 $where = '';
481 if ($a_assignable) {
482 $where = " AND assign ='y'";
483 }
484
485 $query = "SELECT DISTINCT parent FROM rbac_fa " .
486 "WHERE rol_id = " . $this->db->quote($a_rol_id, 'integer') . " " . $where . " ";
487
488 $res = $this->db->query($query);
489 $folders = [];
490 while ($row = $this->db->fetchObject($res)) {
491 $folders[] = (int) $row->parent;
492 }
493 return $folders;
494 }

References $res, and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ getGlobalAssignableRoles()

ilRbacReview::getGlobalAssignableRoles ( )

get only 'global' roles (with flag 'assign_users')

Returns
list<array{obj_id: int, role_type: string}>

Definition at line 603 of file class.ilRbacReview.php.

603 : array
604 {
605 $ga = [];
606 foreach ($this->getGlobalRoles() as $role_id) {
607 if (ilObjRole::_getAssignUsersStatus($role_id)) {
608 $ga[] = [
609 'obj_id' => $role_id,
610 'role_type' => 'global'
611 ];
612 }
613 }
614 return $ga;
615 }
static _getAssignUsersStatus(int $a_role_id)
getGlobalRoles()
get only 'global' roles

References ilObjRole\_getAssignUsersStatus().

+ Here is the call graph for this function:

◆ getGlobalRoles()

ilRbacReview::getGlobalRoles ( )

get only 'global' roles

Returns
list<int> Array with rol_ids
Todo:
refactor rolf => DONE

Definition at line 551 of file class.ilRbacReview.php.

551 : array
552 {
553 return $this->getRolesOfRoleFolder(ROLE_FOLDER_ID, false);
554 }
getRolesOfRoleFolder(int $a_ref_id, bool $a_nonassignable=true)
get all roles of a role folder including linked local roles that are created due to stopped inheritan...

References ROLE_FOLDER_ID.

◆ getGlobalRolesArray()

ilRbacReview::getGlobalRolesArray ( )

get only 'global' roles

Returns
list<array{obj_id: int, role_type: string}>

Definition at line 588 of file class.ilRbacReview.php.

588 : array
589 {
590 $ga = [];
591 foreach ($this->getRolesOfRoleFolder(ROLE_FOLDER_ID, false) as $role_id) {
592 $ga[] = ['obj_id' => $role_id,
593 'role_type' => 'global'
594 ];
595 }
596 return $ga;
597 }

References ROLE_FOLDER_ID.

◆ getLocalPolicies()

ilRbacReview::getLocalPolicies ( int  $a_ref_id)

Get all roles with local policies.

Returns
list<int>

Definition at line 575 of file class.ilRbacReview.php.

575 : array
576 {
577 $lroles = [];
578 foreach ($this->getRolesOfRoleFolder($a_ref_id) as $role_id) {
579 $lroles[] = $role_id;
580 }
581 return $lroles;
582 }

◆ getLocalRoles()

ilRbacReview::getLocalRoles ( int  $a_ref_id)

Get local roles of object.

Returns
list<int>

Definition at line 560 of file class.ilRbacReview.php.

560 : array
561 {
562 $lroles = [];
563 foreach ($this->getRolesOfRoleFolder($a_ref_id) as $role_id) {
564 if ($this->isAssignable($role_id, $a_ref_id)) {
565 $lroles[] = $role_id;
566 }
567 }
568 return $lroles;
569 }
isAssignable(int $a_rol_id, int $a_ref_id)
Check if its possible to assign users.

◆ getNumberOfAssignedUsers()

ilRbacReview::getNumberOfAssignedUsers ( array  $a_roles)

Get the number of assigned users to roles (not properly deleted user accounts are not counted)

Parameters
int[]$a_roles

Definition at line 327 of file class.ilRbacReview.php.

327 : int
328 {
329 $query = 'select count(distinct(ua.usr_id)) as num from rbac_ua ua ' .
330 'join object_data on ua.usr_id = obj_id ' .
331 'join usr_data ud on ua.usr_id = ud.usr_id ' .
332 'where ' . $this->db->in('rol_id', $a_roles, false, 'integer');
333
334 $res = $this->db->query($query);
335 if ($res->numRows() > 0) {
336 $row = $res->fetchRow(\ilDBConstants::FETCHMODE_OBJECT);
337 return isset($row->num) && is_numeric($row->num) ? (int) $row->num : 0;
338 }
339 return 0;
340 }

References $res, ilDBConstants\FETCHMODE_OBJECT, and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ getObjectOfRole()

ilRbacReview::getObjectOfRole ( int  $a_role_id)

Get object id of objects a role is assigned to.

Todo:
refactor rolf (due to performance reasons the new version does not check for deleted roles only in object reference)

Definition at line 1195 of file class.ilRbacReview.php.

1195 : int
1196 {
1197 // internal cache
1198 static $obj_cache = [];
1199
1200 if (isset($obj_cache[$a_role_id]) && $obj_cache[$a_role_id]) {
1201 return $obj_cache[$a_role_id];
1202 }
1203
1204 $query = 'SELECT obr.obj_id FROM rbac_fa rfa ' .
1205 'JOIN object_reference obr ON rfa.parent = obr.ref_id ' .
1206 'WHERE assign = ' . $this->db->quote('y', 'text') . ' ' .
1207 'AND rol_id = ' . $this->db->quote($a_role_id, 'integer') . ' ' .
1208 'AND deleted IS NULL';
1209
1210 $res = $this->db->query($query);
1211 $obj_cache[$a_role_id] = 0;
1212 while ($row = $this->db->fetchObject($res)) {
1213 $obj_cache[$a_role_id] = (int) $row->obj_id;
1214 }
1215 return $obj_cache[$a_role_id];
1216 }

References $res, and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ getObjectReferenceOfRole()

ilRbacReview::getObjectReferenceOfRole ( int  $a_role_id)

Definition at line 1218 of file class.ilRbacReview.php.

1218 : int
1219 {
1220 $query = 'SELECT parent p_ref FROM rbac_fa ' .
1221 'WHERE rol_id = ' . $this->db->quote($a_role_id, 'integer') . ' ' .
1222 'AND assign = ' . $this->db->quote('y', 'text');
1223
1224 $res = $this->db->query($query);
1225 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
1226 return (int) $row->p_ref;
1227 }
1228 return 0;
1229 }

References $res, and ilDBConstants\FETCHMODE_OBJECT.

◆ getObjectsWithStopedInheritance()

ilRbacReview::getObjectsWithStopedInheritance ( int  $a_rol_id,
array  $a_filter = [] 
)

get all objects in which the inheritance of role with role_id was stopped the function returns all reference ids of objects containing a role folder.

Returns
list<int>

Definition at line 818 of file class.ilRbacReview.php.

818 : array
819 {
820 $query = 'SELECT parent p FROM rbac_fa ' .
821 'WHERE assign = ' . $this->db->quote('n', 'text') . ' ' .
822 'AND rol_id = ' . $this->db->quote($a_rol_id, 'integer') . ' ';
823
824 if ($a_filter !== []) {
825 $query .= ('AND ' . $this->db->in('parent', (array) $a_filter, false, 'integer'));
826 }
827
828 $res = $this->db->query($query);
829 $parent = [];
830 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
831 $parent[] = (int) $row->p;
832 }
833 return $parent;
834 }

References $res, ilDBConstants\FETCHMODE_OBJECT, and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ getOperation()

ilRbacReview::getOperation ( int  $ops_id)

get one operation by operation id

Returns
array{}|array{ops_id: int, operation: ?string, description: ?string}

Definition at line 651 of file class.ilRbacReview.php.

651 : array
652 {
653 $query = 'SELECT * FROM rbac_operations WHERE ops_id = ' . $this->db->quote($ops_id, 'integer');
654 $res = $this->db->query($query);
655 $ops = [];
656 while ($row = $this->db->fetchObject($res)) {
657 $ops = ['ops_id' => (int) $row->ops_id,
658 'operation' => $row->operation,
659 'description' => $row->description
660 ];
661 }
662 return $ops;
663 }

References $res, and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ getOperationAssignment()

ilRbacReview::getOperationAssignment ( )

get operation assignments

Returns
list<array{typ_id: int, type: ?string, ops_id: int, operation: ?string}>

Definition at line 1273 of file class.ilRbacReview.php.

1273 : array
1274 {
1275 global $DIC;
1276
1277 $this->db = $DIC['ilDB'];
1278
1279 $query = 'SELECT ta.typ_id, obj.title, ops.ops_id, ops.operation FROM rbac_ta ta ' .
1280 'JOIN object_data obj ON obj.obj_id = ta.typ_id ' .
1281 'JOIN rbac_operations ops ON ops.ops_id = ta.ops_id ';
1282 $res = $this->db->query($query);
1283
1284 $counter = 0;
1285 $info = [];
1286 while ($row = $this->db->fetchObject($res)) {
1287 $info[$counter]['typ_id'] = (int) $row->typ_id;
1288 $info[$counter]['type'] = $row->title;
1289 $info[$counter]['ops_id'] = (int) $row->ops_id;
1290 $info[$counter]['operation'] = $row->operation;
1291 $counter++;
1292 }
1293
1294 return array_values($info);
1295 }
$info
Definition: entry_point.php:21

References $DIC, $info, $res, and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ getOperations()

ilRbacReview::getOperations ( )

get all possible operations

Returns
list<array{ops_id: int, operation: ?string, description: ?string}>

Definition at line 633 of file class.ilRbacReview.php.

633 : array
634 {
635 $query = 'SELECT * FROM rbac_operations ORDER BY ops_id ';
636 $res = $this->db->query($query);
637 $ops = [];
638 while ($row = $this->db->fetchObject($res)) {
639 $ops[] = ['ops_id' => (int) $row->ops_id,
640 'operation' => $row->operation,
641 'description' => $row->description
642 ];
643 }
644 return $ops;
645 }

References $res, and ILIAS\Repository\int().

Referenced by ILIAS\AccessControl\Log\Table\__construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getOperationsByTypeAndClass()

ilRbacReview::getOperationsByTypeAndClass ( string  $a_type,
string  $a_class 
)

Get operations by type and class.

Returns
list<int>

Definition at line 789 of file class.ilRbacReview.php.

789 : array
790 {
791 if ($a_class != 'create') {
792 $condition = "AND class != " . $this->db->quote('create', 'text');
793 } else {
794 $condition = "AND class = " . $this->db->quote('create', 'text');
795 }
796
797 $query = "SELECT ro.ops_id FROM rbac_operations ro " .
798 "JOIN rbac_ta rt ON ro.ops_id = rt.ops_id " .
799 "JOIN object_data od ON rt.typ_id = od.obj_id " .
800 "WHERE type = " . $this->db->quote('typ', 'text') . " " .
801 "AND title = " . $this->db->quote($a_type, 'text') . " " .
802 $condition . " " .
803 "ORDER BY op_order ";
804
805 $res = $this->db->query($query);
806 $ops = [];
807 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
808 $ops[] = (int) $row->ops_id;
809 }
810 return $ops;
811 }

References $res, ilDBConstants\FETCHMODE_OBJECT, and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ getOperationsOfRole()

ilRbacReview::getOperationsOfRole ( int  $a_rol_id,
string  $a_type,
int  $a_parent = 0 
)

get all possible operations of a specific role The ref_id of the role folder (parent object) is necessary to distinguish local roles

Returns
list<int>

Definition at line 711 of file class.ilRbacReview.php.

711 : array
712 {
713 $ops_arr = [];
714 // if no rolefolder id is given, assume global role folder as target
715 if ($a_parent == 0) {
716 $a_parent = ROLE_FOLDER_ID;
717 }
718
719 $query = "SELECT ops_id FROM rbac_templates " .
720 "WHERE type =" . $this->db->quote($a_type, 'text') . " " .
721 "AND rol_id = " . $this->db->quote($a_rol_id, 'integer') . " " .
722 "AND parent = " . $this->db->quote($a_parent, 'integer');
723 $res = $this->db->query($query);
724 while ($row = $this->db->fetchObject($res)) {
725 $ops_arr[] = $row->ops_id;
726 }
727 return $ops_arr;
728 }

References $res, and ROLE_FOLDER_ID.

◆ getOperationsOnType()

ilRbacReview::getOperationsOnType ( int  $a_typ_id)

all possible operations of a type

Returns
list<int>

Definition at line 757 of file class.ilRbacReview.php.

757 : array
758 {
759 $query = 'SELECT ta.ops_id FROM rbac_ta ta JOIN rbac_operations o ON ta.ops_id = o.ops_id ' .
760 'WHERE typ_id = ' . $this->db->quote($a_typ_id, 'integer') . ' ' .
761 'ORDER BY op_order';
762
763 $res = $this->db->query($query);
764 $ops_id = [];
765 while ($row = $this->db->fetchObject($res)) {
766 $ops_id[] = (int) $row->ops_id;
767 }
768 return $ops_id;
769 }

References $res, and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ getOperationsOnTypeString()

ilRbacReview::getOperationsOnTypeString ( string  $a_type)

all possible operations of a type

Returns
list<int>

Definition at line 775 of file class.ilRbacReview.php.

775 : array
776 {
777 $query = "SELECT * FROM object_data WHERE type = 'typ' AND title = " . $this->db->quote($a_type, 'text') . " ";
778 $res = $this->db->query($query);
779 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
780 return $this->getOperationsOnType((int) $row->obj_id);
781 }
782 return [];
783 }
getOperationsOnType(int $a_typ_id)
all possible operations of a type

References $res, and ilDBConstants\FETCHMODE_OBJECT.

◆ getParentRoleIds()

ilRbacReview::getParentRoleIds ( int  $a_endnode_id,
bool  $a_templates = false 
)

Get an array of parent role ids of all parent roles, if last parameter is set true you get also all parent templates.

Parameters
intref_id of an object which is end node
booltrue for role templates (default: false)
Returns
array array(role_ids => role_data)
Todo:
move tree to construct. Currently this is not possible due to init sequence

Definition at line 119 of file class.ilRbacReview.php.

119 : array
120 {
121 global $DIC;
122
123 $tree = $DIC->repositoryTree();
124
125 $pathIds = $tree->getPathId($a_endnode_id);
126
127 // add system folder since it may not in the path
128 //$pathIds[0] = SYSTEM_FOLDER_ID;
129 $pathIds[0] = ROLE_FOLDER_ID;
130 return $this->__getParentRoles($pathIds, $a_templates);
131 }
__getParentRoles(array $a_path, bool $a_templates)
Note: This function performs faster than the new getParentRoles function, because it uses database in...

References $DIC, __getParentRoles(), and ROLE_FOLDER_ID.

+ Here is the call graph for this function:

◆ getRoleFolderOfRole()

ilRbacReview::getRoleFolderOfRole ( int  $a_role_id)

Definition at line 1350 of file class.ilRbacReview.php.

1350 : int
1351 {
1352 if (ilObject::_lookupType($a_role_id) == 'role') {
1353 $and = ('AND assign = ' . $this->db->quote('y', 'text'));
1354 } else {
1355 $and = '';
1356 }
1357
1358 $query = 'SELECT * FROM rbac_fa ' .
1359 'WHERE rol_id = ' . $this->db->quote($a_role_id, 'integer') . ' ' .
1360 $and;
1361 $res = $this->db->query($query);
1362 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
1363 return (int) $row->parent;
1364 }
1365 return 0;
1366 }
static _lookupType(int $id, bool $reference=false)

References $res, ilObject\_lookupType(), and ilDBConstants\FETCHMODE_OBJECT.

+ Here is the call graph for this function:

◆ getRoleListByObject()

ilRbacReview::getRoleListByObject ( int  $a_ref_id,
bool  $a_templates = false 
)

Returns a list of roles in an container.

Returns
list<RoleListEntry>

Definition at line 137 of file class.ilRbacReview.php.

137 : array
138 {
139 $role_list = [];
140 $where = $this->__setTemplateFilter($a_templates);
141
142 $query = "SELECT * FROM object_data " .
143 "JOIN rbac_fa ON obj_id = rol_id " .
144 $where .
145 "AND object_data.obj_id = rbac_fa.rol_id " .
146 "AND rbac_fa.parent = " . $this->db->quote($a_ref_id, 'integer') . " ";
147
148 $res = $this->db->query($query);
149 while ($row = $this->db->fetchAssoc($res)) {
150 $row["desc"] = $row["description"];
151 $row["user_id"] = (int) $row["owner"];
152 $row['obj_id'] = (int) $row['obj_id'];
153 $row['rol_id'] = (int) $row['rol_id'];
154 $row['parent'] = (int) $row['parent'];
155 $role_list[] = $row;
156 }
157
158 return $this->__setRoleType($role_list);
159 }
__setRoleType(array $a_role_list)
computes role type in role list array: global: roles in ROLE_FOLDER_ID local: assignable roles in oth...

References $res, __setRoleType(), __setTemplateFilter(), and ILIAS\Repository\int().

Referenced by __getParentRoles().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRoleOperationsOnObject()

ilRbacReview::getRoleOperationsOnObject ( int  $a_role_id,
int  $a_ref_id 
)
Returns
list<int>

Definition at line 733 of file class.ilRbacReview.php.

733 : array
734 {
735 $query = "SELECT ops_id FROM rbac_pa " .
736 "WHERE rol_id = " . $this->db->quote($a_role_id, 'integer') . " " .
737 "AND ref_id = " . $this->db->quote($a_ref_id, 'integer') . " ";
738
739 $res = $this->db->query($query);
740 $ops = [];
741 while ($row = $this->db->fetchObject($res)) {
742 if ($row->ops_id !== ':') {
743 $ops = array_map(
744 intval(...),
745 unserialize($row->ops_id, ['allowed_classes' => false])
746 );
747 }
748 }
749
750 return $ops;
751 }

References $res.

◆ getRolesByFilter()

ilRbacReview::getRolesByFilter ( int  $a_filter = 0,
int  $a_user_id = 0,
string  $title_filter = '' 
)
Returns
Generator<RoleListEntry>

Definition at line 869 of file class.ilRbacReview.php.

869 : Generator
870 {
871 $assign = "y";
872 switch ($a_filter) {
873 case self::FILTER_ALL:
874 return yield from $this->getAssignableRolesGenerator(true, true, $title_filter);
875
877 $where = 'WHERE ' . $this->db->in('rbac_fa.rol_id', $this->getGlobalRoles(), false, 'integer') . ' ';
878 break;
879
883 $where = 'WHERE ' . $this->db->in('rbac_fa.rol_id', $this->getGlobalRoles(), true, 'integer');
884 break;
885
887 $where = "WHERE object_data.type = 'rolt'";
888 $assign = "n";
889 break;
890
891 case 0:
892 default:
893 if (!$a_user_id) {
894 return;
895 }
896
897 $where = 'WHERE ' . $this->db->in(
898 'rbac_fa.rol_id',
899 $this->assignedRoles($a_user_id),
900 false,
901 'integer'
902 ) . ' ';
903 break;
904 }
905
906 $query = "SELECT * FROM object_data " .
907 "JOIN rbac_fa ON obj_id = rol_id " .
908 $where .
909 "AND rbac_fa.assign = " . $this->db->quote($assign, 'text') . " ";
910
911 if (strlen($title_filter)) {
912 $query .= (' AND ' . $this->db->like(
913 'title',
914 'text',
915 '%' . $title_filter . '%'
916 ));
917 }
918
919 $res = $this->db->query($query);
920 while ($row = $this->db->fetchAssoc($res)) {
921 $row['title'] = $row['title'] ?? '';
922 $prefix = str_starts_with($row['title'], "il_");
923
924 // all (assignable) internal local roles only
925 if ($a_filter == 4 && !$prefix) {
926 continue;
927 }
928
929 // all (assignable) non internal local roles only
930 if ($a_filter == 5 && $prefix) {
931 continue;
932 }
933
934 $row['description'] = $row['description'] ?? '';
935 $row["desc"] = $row["description"];
936 $row["user_id"] = (int) $row["owner"];
937 $row['obj_id'] = (int) $row['obj_id'];
938 $row['rol_id'] = (int) $row['rol_id'];
939 $row['parent'] = (int) $row['parent'];
940
941 yield $this->setRoleTypeAndProtection($row);
942 }
943 }

References $res, ILIAS\ResourceStorage\Flavour\Machine\DefaultMachines\from(), and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ getRolesForIDs()

ilRbacReview::getRolesForIDs ( array  $role_ids,
bool  $use_templates 
)

Definition at line 1250 of file class.ilRbacReview.php.

1250 : array
1251 {
1252 $where = $this->__setTemplateFilter($use_templates);
1253 $query = "SELECT * FROM object_data " .
1254 "JOIN rbac_fa ON object_data.obj_id = rbac_fa.rol_id " .
1255 $where .
1256 "AND rbac_fa.assign = 'y' " .
1257 'AND ' . $this->db->in('object_data.obj_id', $role_ids, false, 'integer');
1258
1259 $res = $this->db->query($query);
1260 $role_list = [];
1261 while ($row = $this->db->fetchAssoc($res)) {
1262 $row["desc"] = $row["description"];
1263 $row["user_id"] = (int) $row["owner"];
1264 $role_list[] = $row;
1265 }
1266 return $this->__setRoleType($role_list);
1267 }

References $res, and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ getRolesOfObject()

ilRbacReview::getRolesOfObject ( int  $a_ref_id,
bool  $a_assignable_only = false 
)

Get roles of object.

Returns
list<int>

Definition at line 500 of file class.ilRbacReview.php.

500 : array
501 {
502 $and = '';
503 if ($a_assignable_only === true) {
504 $and = 'AND assign = ' . $this->db->quote('y', 'text');
505 }
506 $query = "SELECT rol_id FROM rbac_fa " .
507 "WHERE parent = " . $this->db->quote($a_ref_id, 'integer') . " " .
508 $and;
509
510 $res = $this->db->query($query);
511
512 $role_ids = [];
513 while ($row = $this->db->fetchObject($res)) {
514 $role_ids[] = (int) $row->rol_id;
515 }
516 return $role_ids;
517 }

References $res, and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ getRolesOfRoleFolder()

ilRbacReview::getRolesOfRoleFolder ( int  $a_ref_id,
bool  $a_nonassignable = true 
)

get all roles of a role folder including linked local roles that are created due to stopped inheritance returns an array with role ids

Returns
list<int> Array with rol_ids
Deprecated:
since version 4.5.0
Todo:
refactor rolf => RENAME

Definition at line 526 of file class.ilRbacReview.php.

526 : array
527 {
528 $and = '';
529 if ($a_nonassignable === false) {
530 $and = " AND assign='y'";
531 }
532
533 $query = "SELECT rol_id FROM rbac_fa " .
534 "WHERE parent = " . $this->db->quote($a_ref_id, 'integer') . " " .
535 $and;
536
537 $res = $this->db->query($query);
538 $rol_id = [];
539 while ($row = $this->db->fetchObject($res)) {
540 $rol_id[] = (int) $row->rol_id;
541 }
542
543 return $rol_id;
544 }

References $res, and ILIAS\Repository\int().

Referenced by ilObjSessionGUI\getDefaultMemberRole(), and ilObjSessionGUI\getLocalRoles().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTypeId()

ilRbacReview::getTypeId ( string  $a_type)

Definition at line 945 of file class.ilRbacReview.php.

945 : int
946 {
947 $q = "SELECT obj_id FROM object_data " .
948 "WHERE title=" . $this->db->quote($a_type, 'text') . " AND type='typ'";
949 $r = $this->db->query($q);
950 while ($row = $r->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
951 return (int) $row->obj_id;
952 }
953 return 0;
954 }

References ilDBConstants\FETCHMODE_OBJECT.

◆ getUserPermissionsOnObject()

ilRbacReview::getUserPermissionsOnObject ( int  $a_user_id,
int  $a_ref_id 
)

Get all user permissions on an object.

Returns
list<string>

Definition at line 1372 of file class.ilRbacReview.php.

1372 : array
1373 {
1374 $query = "SELECT ops_id FROM rbac_pa JOIN rbac_ua " .
1375 "ON (rbac_pa.rol_id = rbac_ua.rol_id) " .
1376 "WHERE rbac_ua.usr_id = " . $this->db->quote($a_user_id, 'integer') . " " .
1377 "AND rbac_pa.ref_id = " . $this->db->quote($a_ref_id, 'integer') . " ";
1378
1379 $res = $this->db->query($query);
1380 $all_ops = [];
1381 while ($row = $this->db->fetchObject($res)) {
1382 $ops = unserialize($row->ops_id, ['allowed_classes' => false]);
1383 $all_ops = array_merge($all_ops, $ops);
1384 }
1385 $all_ops = array_unique($all_ops);
1386
1387 $set = $this->db->query("SELECT operation FROM rbac_operations " .
1388 " WHERE " . $this->db->in("ops_id", $all_ops, false, "integer"));
1389 $perms = [];
1390 while ($rec = $this->db->fetchAssoc($set)) {
1391 $perms[] = $rec["operation"];
1392 }
1393
1394 return array_values(array_filter($perms));
1395 }

References $res.

◆ hasMultipleAssignments()

ilRbacReview::hasMultipleAssignments ( int  $a_role_id)

Definition at line 461 of file class.ilRbacReview.php.

461 : bool
462 {
463 $query = "SELECT * FROM rbac_fa WHERE rol_id = " . $this->db->quote($a_role_id, 'integer') . ' ' .
464 "AND assign = " . $this->db->quote('y', 'text');
465 $res = $this->db->query($query);
466 return $res->numRows() > 1;
467 }

References $res.

◆ isAssignable()

ilRbacReview::isAssignable ( int  $a_rol_id,
int  $a_ref_id 
)

Check if its possible to assign users.

Definition at line 444 of file class.ilRbacReview.php.

444 : bool
445 {
446 // exclude system role from rbac
447 if ($a_rol_id == SYSTEM_ROLE_ID) {
448 return true;
449 }
450
451 $query = "SELECT * FROM rbac_fa " .
452 "WHERE rol_id = " . $this->db->quote($a_rol_id, 'integer') . " " .
453 "AND parent = " . $this->db->quote($a_ref_id, 'integer') . " ";
454 $res = $this->db->query($query);
455 while ($row = $this->db->fetchObject($res)) {
456 return $row->assign == 'y';
457 }
458 return false;
459 }

References $res, and SYSTEM_ROLE_ID.

Referenced by ilRecommendedContentRoleConfigGUI\listItems().

+ Here is the caller graph for this function:

◆ isAssigned()

ilRbacReview::isAssigned ( int  $a_usr_id,
int  $a_role_id 
)

check if a specific user is assigned to specific role

Definition at line 365 of file class.ilRbacReview.php.

365 : bool
366 {
367 if (isset(self::$is_assigned_cache[$a_role_id][$a_usr_id])) {
368 return self::$is_assigned_cache[$a_role_id][$a_usr_id];
369 }
370 // Quickly determine if user is assigned to a role
371 $this->db->setLimit(1, 0);
372 $query = "SELECT usr_id FROM rbac_ua WHERE " .
373 "rol_id= " . $this->db->quote($a_role_id, 'integer') . " " .
374 "AND usr_id= " . $this->db->quote($a_usr_id, ilDBConstants::T_INTEGER);
375 $res = $this->db->query($query);
376 $is_assigned = $res->numRows() == 1;
377 self::$is_assigned_cache[$a_role_id][$a_usr_id] = $is_assigned;
378 return $is_assigned;
379 }

References $res, and ilDBConstants\T_INTEGER.

◆ isAssignedToAtLeastOneGivenRole()

ilRbacReview::isAssignedToAtLeastOneGivenRole ( int  $a_usr_id,
array  $a_role_ids 
)

check if a specific user is assigned to at least one of the given role ids.

This function is used to quickly check whether a user is member of a course or a group.

Parameters
intusr_id
int[]role_ids

Definition at line 389 of file class.ilRbacReview.php.

389 : bool
390 {
391 global $DIC;
392
393 $this->db = $DIC['ilDB'];
394
395 $this->db->setLimit(1, 0);
396 $query = "SELECT usr_id FROM rbac_ua WHERE " .
397 $this->db->in('rol_id', $a_role_ids, false, 'integer') .
398 " AND usr_id= " . $this->db->quote($a_usr_id, ilDBConstants::T_INTEGER);
399 $res = $this->db->query($query);
400
401 return $this->db->numRows($res) == 1;
402 }

References $DIC, $res, and ilDBConstants\T_INTEGER.

◆ isBlockedAtPosition()

ilRbacReview::isBlockedAtPosition ( int  $a_role_id,
int  $a_ref_id 
)

Definition at line 1060 of file class.ilRbacReview.php.

1060 : bool
1061 {
1062 $query = 'SELECT blocked from rbac_fa ' .
1063 'WHERE rol_id = ' . $this->db->quote($a_role_id, 'integer') . ' ' .
1064 'AND parent = ' . $this->db->quote($a_ref_id, 'integer');
1065 $res = $this->db->query($query);
1066 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
1067 return (bool) $row->blocked;
1068 }
1069 return false;
1070 }

References $res, and ilDBConstants\FETCHMODE_OBJECT.

◆ isBlockedInUpperContext()

ilRbacReview::isBlockedInUpperContext ( int  $a_role_id,
int  $a_ref_id 
)

Check if role is blocked in upper context.

Todo:
move tree to construct. Currently this is not possible due to init sequence

Definition at line 1076 of file class.ilRbacReview.php.

1076 : bool
1077 {
1078 global $DIC;
1079
1080 $tree = $DIC['tree'];
1081
1082 if ($this->isBlockedAtPosition($a_role_id, $a_ref_id)) {
1083 return false;
1084 }
1085 $query = 'SELECT parent from rbac_fa ' .
1086 'WHERE rol_id = ' . $this->db->quote($a_role_id, 'integer') . ' ' .
1087 'AND blocked = ' . $this->db->quote(1, 'integer');
1088 $res = $this->db->query($query);
1089
1090 $parent_ids = [];
1091 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
1092 $parent_ids[] = (int) $row->parent;
1093 }
1094
1095 foreach ($parent_ids as $parent_id) {
1096 if ($tree->isGrandChild($parent_id, $a_ref_id)) {
1097 return true;
1098 }
1099 }
1100 return false;
1101 }
isBlockedAtPosition(int $a_role_id, int $a_ref_id)

References $DIC, $res, ilDBConstants\FETCHMODE_OBJECT, and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ isDeleteable()

ilRbacReview::isDeleteable ( int  $a_role_id,
int  $a_rolf_id 
)

Check if role is deleteable at a specific position.

Definition at line 1300 of file class.ilRbacReview.php.

1300 : bool
1301 {
1302 if (!$this->isAssignable($a_role_id, $a_rolf_id)) {
1303 return false;
1304 }
1305 if ($a_role_id == SYSTEM_ROLE_ID or $a_role_id == ANONYMOUS_ROLE_ID) {
1306 return false;
1307 }
1308 if (str_starts_with(ilObject::_lookupTitle($a_role_id), 'il_')) {
1309 return false;
1310 }
1311 return true;
1312 }
static _lookupTitle(int $obj_id)
const ANONYMOUS_ROLE_ID
Definition: constants.php:28

References ilObject\_lookupTitle(), ANONYMOUS_ROLE_ID, and SYSTEM_ROLE_ID.

+ Here is the call graph for this function:

◆ isDeleted()

ilRbacReview::isDeleted ( int  $a_node_id)

Checks if a rolefolder is set as deleted (negative tree_id)

Todo:
delete this method

Definition at line 840 of file class.ilRbacReview.php.

840 : bool
841 {
842 $q = "SELECT tree FROM tree WHERE child =" . $this->db->quote($a_node_id, ilDBConstants::T_INTEGER) . " ";
843 $r = $this->db->query($q);
844 $row = $r->fetchRow(ilDBConstants::FETCHMODE_OBJECT);
845
846 if (!$row) {
847 $message = sprintf(
848 '%s::isDeleted(): Role folder with ref_id %s not found!',
849 get_class($this),
850 $a_node_id
851 );
852 $this->log->warning($message);
853 return true;
854 }
855 return $row->tree < 0;
856 }

References $message, ilDBConstants\FETCHMODE_OBJECT, and ilDBConstants\T_INTEGER.

◆ isGlobalRole()

ilRbacReview::isGlobalRole ( int  $a_role_id)

Check if role is a global role.

Definition at line 861 of file class.ilRbacReview.php.

861 : bool
862 {
863 return in_array($a_role_id, $this->getGlobalRoles());
864 }

◆ isProtected()

ilRbacReview::isProtected ( int  $a_ref_id,
int  $a_role_id 
)

ref_id not used yet.

Protected permission acts 'global' for each role,

Definition at line 1047 of file class.ilRbacReview.php.

1047 : bool
1048 {
1049 $query = 'SELECT protected FROM rbac_fa ' .
1050 'WHERE rol_id = ' . $this->db->quote($a_role_id, ilDBConstants::T_INTEGER);
1051 $res = $this->db->query($query);
1052 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
1053 if ($row->protected === 'y') {
1054 return true;
1055 }
1056 }
1057 return false;
1058 }

References $res, ilDBConstants\FETCHMODE_OBJECT, and ilDBConstants\T_INTEGER.

◆ isRoleAssignedToObject()

ilRbacReview::isRoleAssignedToObject ( int  $a_role_id,
int  $a_parent_id 
)

Check if role is assigned to an object.

Definition at line 620 of file class.ilRbacReview.php.

620 : bool
621 {
622 $query = 'SELECT * FROM rbac_fa ' .
623 'WHERE rol_id = ' . $this->db->quote($a_role_id, 'integer') . ' ' .
624 'AND parent = ' . $this->db->quote($a_parent_id, 'integer');
625 $res = $this->db->query($query);
626 return (bool) $res->numRows();
627 }

References $res.

◆ isRoleDeleted()

ilRbacReview::isRoleDeleted ( int  $a_role_id)

return if role is only attached to deleted role folders

Definition at line 1234 of file class.ilRbacReview.php.

1234 : bool
1235 {
1236 $rolf_list = $this->getFoldersAssignedToRole($a_role_id, false);
1237 $deleted = true;
1238 if ($rolf_list !== []) {
1239 foreach ($rolf_list as $rolf) {
1240 // only list roles that are not set to status "deleted"
1241 if (!$this->isDeleted($rolf)) {
1242 $deleted = false;
1243 break;
1244 }
1245 }
1246 }
1247 return $deleted;
1248 }
isDeleted(int $a_node_id)
Checks if a rolefolder is set as deleted (negative tree_id)
getFoldersAssignedToRole(int $a_rol_id, bool $a_assignable=false)
Returns an array of objects assigned to a role.

◆ isSystemGeneratedRole()

ilRbacReview::isSystemGeneratedRole ( int  $a_role_id)

Check if the role is system generate role or role template.

Definition at line 1317 of file class.ilRbacReview.php.

1317 : bool
1318 {
1319 $title = ilObject::_lookupTitle($a_role_id);
1320 return substr($title, 0, 3) == 'il_';
1321 }

References ilObject\_lookupTitle().

+ Here is the call graph for this function:

◆ lookupCreateOperationIds()

static ilRbacReview::lookupCreateOperationIds ( array  $a_type_arr)
static

Lookup operation ids.

Parameters
list<string>$a_type_arr e.g array('cat','crs','grp'). The operation name (e.g. 'create_cat') is generated automatically
Returns
array<string, int> Array with operation ids

Definition at line 1014 of file class.ilRbacReview.php.

1014 : array
1015 {
1016 global $DIC;
1017
1018 $ilDB = $DIC->database();
1019
1020 $operations = [];
1021 foreach ($a_type_arr as $type) {
1022 $operations[] = ('create_' . $type);
1023 }
1024
1025 if ($operations === []) {
1026 return [];
1027 }
1028
1029 $query = 'SELECT ops_id, operation FROM rbac_operations ' .
1030 'WHERE ' . $ilDB->in('operation', $operations, false, 'text');
1031
1032 $res = $ilDB->query($query);
1033
1034 $ops_ids = [];
1035 while ($row = $ilDB->fetchObject($res)) {
1036 $type_arr = explode('_', $row->operation);
1037 $type = $type_arr[1];
1038
1039 $ops_ids[$type] = (int) $row->ops_id;
1040 }
1041 return $ops_ids;
1042 }

References $DIC, $ilDB, $res, and ILIAS\Repository\int().

Referenced by ilObjectXMLWriter\appendOperations(), ilObjectRolePermissionTableGUI\parse(), ilObjectRoleTemplatePermissionTableGUI\parse(), and ilPermissionGUI\savePermissions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ roleExists()

ilRbacReview::roleExists ( string  $a_title,
int  $a_id = 0 
)

Checks if a role already exists.

Role title should be unique @access public

Parameters
stringrole title
?intobj_id of role to exclude in the check. Commonly this is the current role you want to edit
Returns
bool

Definition at line 67 of file class.ilRbacReview.php.

67 : ?int
68 {
69 $clause = ($a_id) ? " AND obj_id != " . $this->db->quote($a_id, ilDBConstants::T_TEXT) . " " : "";
70
71 $q = "SELECT DISTINCT(obj_id) obj_id FROM object_data " .
72 "WHERE title =" . $this->db->quote($a_title, ilDBConstants::T_TEXT) . " " .
73 "AND type IN('role','rolt')" .
74 $clause . " ";
75 $r = $this->db->query($q);
76 while ($row = $r->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
77 return (int) $row->obj_id;
78 }
79 return null;
80 }

References ilDBConstants\FETCHMODE_OBJECT, and ilDBConstants\T_TEXT.

◆ setAssignedCacheEntry()

ilRbacReview::setAssignedCacheEntry ( int  $a_role_id,
int  $a_user_id,
bool  $a_value 
)

set entry of assigned_chache

Definition at line 1400 of file class.ilRbacReview.php.

1400 : void
1401 {
1402 self::$is_assigned_cache[$a_role_id][$a_user_id] = $a_value;
1403 }

◆ setRoleTypeAndProtection()

ilRbacReview::setRoleTypeAndProtection ( array  $role_list_entry)
private

Definition at line 291 of file class.ilRbacReview.php.

291 : array
292 {
293 $role_list_entry['role_type'] = $this->buildRoleType($role_list_entry);
294 $role_list_entry['protected'] = $this->buildProtectionByStringValue($role_list_entry['protected']);
295 return $role_list_entry;
296 }
buildRoleType(array $role_list_entry)
buildProtectionByStringValue(string $value)

Field Documentation

◆ $_opsCache

array ilRbacReview::$_opsCache = null
staticprivate

Definition at line 45 of file class.ilRbacReview.php.

◆ $assigned_users_cache

array ilRbacReview::$assigned_users_cache = []
staticprotected

Definition at line 47 of file class.ilRbacReview.php.

◆ $is_assigned_cache

array ilRbacReview::$is_assigned_cache = []
staticprotected

Definition at line 48 of file class.ilRbacReview.php.

◆ FILTER_ALL

const ilRbacReview::FILTER_ALL = 1

Definition at line 37 of file class.ilRbacReview.php.

Referenced by ilRoleTableGUI\initFilter(), and ilRoleTableGUI\parse().

◆ FILTER_ALL_GLOBAL

const ilRbacReview::FILTER_ALL_GLOBAL = 2

◆ FILTER_ALL_LOCAL

const ilRbacReview::FILTER_ALL_LOCAL = 3

Definition at line 39 of file class.ilRbacReview.php.

Referenced by ilRoleTableGUI\initFilter().

◆ FILTER_INTERNAL

const ilRbacReview::FILTER_INTERNAL = 4

Definition at line 40 of file class.ilRbacReview.php.

Referenced by ilRoleTableGUI\initFilter().

◆ FILTER_NOT_INTERNAL

const ilRbacReview::FILTER_NOT_INTERNAL = 5

Definition at line 41 of file class.ilRbacReview.php.

Referenced by ilRoleTableGUI\initFilter().

◆ FILTER_TEMPLATES

const ilRbacReview::FILTER_TEMPLATES = 6

Definition at line 42 of file class.ilRbacReview.php.

Referenced by ilRoleTableGUI\initFilter().


The documentation for this class was generated from the following file: