19declare(strict_types=1);
71 $q =
"SELECT DISTINCT(obj_id) obj_id FROM object_data " .
73 "AND type IN('role','rolt')" .
75 $r = $this->db->query($q);
77 return (
int) $row->obj_id;
96 foreach ($a_path as $ref_id) {
98 foreach ($roles as $role) {
99 $id = (
int) $role[
"obj_id"];
100 $role[
"parent"] = (
int) $ref_id;
101 $parent_roles[
$id] = $role;
103 if (!array_key_exists($role[
'obj_id'], $role_hierarchy)) {
104 $role_hierarchy[
$id] = $ref_id;
123 $tree =
$DIC->repositoryTree();
125 $pathIds = $tree->getPathId($a_endnode_id);
142 $query =
"SELECT * FROM object_data " .
143 "JOIN rbac_fa ON obj_id = rol_id " .
145 "AND object_data.obj_id = rbac_fa.rol_id " .
146 "AND rbac_fa.parent = " . $this->db->quote($a_ref_id,
'integer') .
" ";
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'];
166 bool $a_templates =
false,
167 bool $a_internal_roles =
false,
168 string $title_filter =
''
183 bool $a_templates =
false,
184 bool $a_internal_roles =
false,
185 string $title_filter =
''
187 $where = $this->__setTemplateFilter($a_templates);
188 $query =
"SELECT * FROM object_data " .
189 "JOIN rbac_fa ON obj_id = rol_id " .
191 "AND rbac_fa.assign = 'y' ";
193 if (strlen($title_filter)) {
194 $query .= (
' AND ' . $this->db->like(
200 $res = $this->db->query($query);
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);
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']) .
' ' .
231 $res = $this->db->query($query);
235 $role_list[] = (
int) $row->rol_id;
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') .
" ";
251 $res = $this->db->query($query);
253 while ($row = $this->db->fetchAssoc(
$res)) {
254 $row[
'rol_id'] = (
int) $row[
'rol_id'];
255 $row[
'obj_id'] = (
int) $row[
'obj_id'];
257 $roles_data[] = $row;
269 $where =
"WHERE " . $this->db->in(
'object_data.type', [
'role',
'rolt'],
false,
'text') .
" ";
271 $where =
"WHERE " . $this->db->in(
'object_data.type', [
'role'],
false,
'text') .
" ";
285 foreach ($a_role_list as $key => $val) {
286 $a_role_list[$key] = $this->setRoleTypeAndProtection($val);
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;
300 if ($role_list_entry[
'type'] ===
'rolt') {
304 if ($role_list_entry[
'assign'] !==
'y') {
317 if ($value ===
'y') {
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');
334 $res = $this->db->query($query);
335 if (
$res->numRows() > 0) {
337 return isset($row->num) && is_numeric($row->num) ? (
int) $row->num : 0;
348 if (isset(self::$assigned_users_cache[$a_rol_id])) {
349 return self::$assigned_users_cache[$a_rol_id];
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"];
358 self::$assigned_users_cache[$a_rol_id] = $result_arr;
365 public function isAssigned(
int $a_usr_id,
int $a_role_id): bool
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];
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') .
" " .
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;
393 $this->db =
$DIC[
'ilDB'];
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') .
399 $res = $this->db->query($query);
401 return $this->db->numRows(
$res) == 1;
410 $query =
"SELECT rol_id FROM rbac_ua WHERE usr_id = " . $this->db->quote($a_usr_id,
'integer');
412 $res = $this->db->query($query);
414 while ($row = $this->db->fetchObject(
$res)) {
415 $role_arr[] = (
int) $row->rol_id;
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') .
' ' .
432 $res = $this->db->query($query);
434 while ($row = $this->db->fetchObject(
$res)) {
435 $role_arr[] = (
int) $row->rol_id;
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';
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;
482 $where =
" AND assign ='y'";
485 $query =
"SELECT DISTINCT parent FROM rbac_fa " .
486 "WHERE rol_id = " . $this->db->quote($a_rol_id,
'integer') .
" " . $where .
" ";
488 $res = $this->db->query($query);
490 while ($row = $this->db->fetchObject(
$res)) {
491 $folders[] = (
int) $row->parent;
503 if ($a_assignable_only ===
true) {
504 $and =
'AND assign = ' . $this->db->quote(
'y',
'text');
506 $query =
"SELECT rol_id FROM rbac_fa " .
507 "WHERE parent = " . $this->db->quote($a_ref_id,
'integer') .
" " .
510 $res = $this->db->query($query);
513 while ($row = $this->db->fetchObject(
$res)) {
514 $role_ids[] = (
int) $row->rol_id;
529 if ($a_nonassignable ===
false) {
530 $and =
" AND assign='y'";
533 $query =
"SELECT rol_id FROM rbac_fa " .
534 "WHERE parent = " . $this->db->quote($a_ref_id,
'integer') .
" " .
537 $res = $this->db->query($query);
539 while ($row = $this->db->fetchObject(
$res)) {
540 $rol_id[] = (
int) $row->rol_id;
563 foreach ($this->getRolesOfRoleFolder($a_ref_id) as $role_id) {
564 if ($this->isAssignable($role_id, $a_ref_id)) {
565 $lroles[] = $role_id;
578 foreach ($this->getRolesOfRoleFolder($a_ref_id) as $role_id) {
579 $lroles[] = $role_id;
591 foreach ($this->getRolesOfRoleFolder(
ROLE_FOLDER_ID,
false) as $role_id) {
592 $ga[] = [
'obj_id' => $role_id,
593 'role_type' =>
'global'
606 foreach ($this->getGlobalRoles() as $role_id) {
609 'obj_id' => $role_id,
610 'role_type' =>
'global'
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();
635 $query =
'SELECT * FROM rbac_operations ORDER BY ops_id ';
636 $res = $this->db->query($query);
638 while ($row = $this->db->fetchObject(
$res)) {
639 $ops[] = [
'ops_id' => (
int) $row->ops_id,
640 'operation' => $row->operation,
641 'description' => $row->description
653 $query =
'SELECT * FROM rbac_operations WHERE ops_id = ' . $this->db->quote($ops_id,
'integer');
654 $res = $this->db->query($query);
656 while ($row = $this->db->fetchObject(
$res)) {
657 $ops = [
'ops_id' => (
int) $row->ops_id,
658 'operation' => $row->operation,
659 'description' => $row->description
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);
681 while ($row = $this->db->fetchObject(
$res)) {
682 $ops_arr[$row->type][] = (
int) $row->ops_id;
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') .
' ';
696 $res = $this->db->query($query);
700 $row[
'ops_id'] ===
':' ? [] : unserialize($row[
'ops_id'], [
'allowed_classes' =>
false])
715 if ($a_parent == 0) {
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;
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') .
" ";
739 $res = $this->db->query($query);
741 while ($row = $this->db->fetchObject(
$res)) {
742 if ($row->ops_id !==
':') {
745 unserialize($row->ops_id, [
'allowed_classes' =>
false])
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') .
' ' .
763 $res = $this->db->query($query);
765 while ($row = $this->db->fetchObject(
$res)) {
766 $ops_id[] = (
int) $row->ops_id;
777 $query =
"SELECT * FROM object_data WHERE type = 'typ' AND title = " . $this->db->quote($a_type,
'text') .
" ";
778 $res = $this->db->query($query);
780 return $this->getOperationsOnType((
int) $row->obj_id);
791 if ($a_class !=
'create') {
792 $condition =
"AND class != " . $this->db->quote(
'create',
'text');
794 $condition =
"AND class = " . $this->db->quote(
'create',
'text');
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') .
" " .
803 "ORDER BY op_order ";
805 $res = $this->db->query($query);
808 $ops[] = (
int) $row->ops_id;
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') .
' ';
824 if ($a_filter !== []) {
825 $query .= (
'AND ' . $this->db->in(
'parent', (array) $a_filter,
false,
'integer'));
828 $res = $this->db->query($query);
831 $parent[] = (
int) $row->p;
843 $r = $this->db->query($q);
848 '%s::isDeleted(): Role folder with ref_id %s not found!',
855 return $row->tree < 0;
863 return in_array($a_role_id, $this->getGlobalRoles());
869 public function getRolesByFilter(
int $a_filter = 0,
int $a_user_id = 0,
string $title_filter =
''): Generator
873 case self::FILTER_ALL:
874 return yield
from $this->getAssignableRolesGenerator(
true,
true, $title_filter);
876 case self::FILTER_ALL_GLOBAL:
877 $where =
'WHERE ' . $this->db->in(
'rbac_fa.rol_id', $this->getGlobalRoles(),
false,
'integer') .
' ';
880 case self::FILTER_ALL_LOCAL:
881 case self::FILTER_INTERNAL:
882 case self::FILTER_NOT_INTERNAL:
883 $where =
'WHERE ' . $this->db->in(
'rbac_fa.rol_id', $this->getGlobalRoles(),
true,
'integer');
886 case self::FILTER_TEMPLATES:
887 $where =
"WHERE object_data.type = 'rolt'";
897 $where =
'WHERE ' . $this->db->in(
899 $this->assignedRoles($a_user_id),
906 $query =
"SELECT * FROM object_data " .
907 "JOIN rbac_fa ON obj_id = rol_id " .
909 "AND rbac_fa.assign = " . $this->db->quote($assign,
'text') .
" ";
911 if (strlen($title_filter)) {
912 $query .= (
' AND ' . $this->db->like(
915 '%' . $title_filter .
'%'
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_");
925 if ($a_filter == 4 && !$prefix) {
930 if ($a_filter == 5 && $prefix) {
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'];
941 yield $this->setRoleTypeAndProtection($row);
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);
951 return (
int) $row->obj_id;
967 if ($operations === []) {
971 $query =
'SELECT ops_id FROM rbac_operations ' .
972 'WHERE ' .
$ilDB->in(
'operation', $operations,
false,
'text');
976 while ($row =
$ilDB->fetchObject(
$res)) {
977 $ops_ids[] = (
int) $row->ops_id;
992 if (!is_array(self::$_opsCache)) {
993 self::$_opsCache = [];
995 $q =
"SELECT ops_id, operation FROM rbac_operations";
996 $r =
$ilDB->query($q);
998 self::$_opsCache[$row->operation] = (
int) $row->ops_id;
1003 if (array_key_exists($a_operation, self::$_opsCache)) {
1004 return self::$_opsCache[$a_operation];
1021 foreach ($a_type_arr as $type) {
1022 $operations[] = (
'create_' . $type);
1025 if ($operations === []) {
1029 $query =
'SELECT ops_id, operation FROM rbac_operations ' .
1030 'WHERE ' .
$ilDB->in(
'operation', $operations,
false,
'text');
1035 while ($row =
$ilDB->fetchObject(
$res)) {
1036 $type_arr = explode(
'_', $row->operation);
1037 $type = $type_arr[1];
1039 $ops_ids[$type] = (
int) $row->ops_id;
1049 $query =
'SELECT protected FROM rbac_fa ' .
1051 $res = $this->db->query($query);
1053 if ($row->protected ===
'y') {
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);
1067 return (
bool) $row->blocked;
1080 $tree =
$DIC[
'tree'];
1082 if ($this->isBlockedAtPosition($a_role_id, $a_ref_id)) {
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);
1092 $parent_ids[] = (
int) $row->parent;
1095 foreach ($parent_ids as $parent_id) {
1096 if ($tree->isGrandChild($parent_id, $a_ref_id)) {
1109 $rbacsystem =
$DIC->rbac()->system();
1110 $ilUser =
$DIC->user();
1111 if (in_array(
SYSTEM_ROLE_ID, $this->assignedRoles($ilUser->getId()))) {
1114 $leveladmin =
false;
1116 foreach ($a_role_hierarchy as $role_id => $rolf_id) {
1117 if ($leveladmin ==
true) {
1118 $a_parent_roles[$role_id][
'protected'] =
false;
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)
1128 foreach ($arr_lvl_roles_user as $lvl_role_id) {
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;
1137 return $a_parent_roles;
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')
1162 $query =
'SELECT * FROM rbac_operations ORDER BY op_order ASC';
1165 while ($row =
$ilDB->fetchAssoc(
$res)) {
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']
1183 foreach ($a_ops_arr as $ops) {
1184 $arr[$ops[
'class']][] = [
'ops_id' => (
int) $ops[
'ops_id'],
1185 'name' => $ops[
'operation']
1198 static $obj_cache = [];
1200 if (isset($obj_cache[$a_role_id]) && $obj_cache[$a_role_id]) {
1201 return $obj_cache[$a_role_id];
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';
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;
1215 return $obj_cache[$a_role_id];
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');
1224 $res = $this->db->query($query);
1226 return (
int) $row->p_ref;
1236 $rolf_list = $this->getFoldersAssignedToRole($a_role_id,
false);
1238 if ($rolf_list !== []) {
1239 foreach ($rolf_list as $rolf) {
1241 if (!$this->isDeleted($rolf)) {
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 " .
1256 "AND rbac_fa.assign = 'y' " .
1257 'AND ' . $this->db->in(
'object_data.obj_id', $role_ids,
false,
'integer');
1259 $res = $this->db->query($query);
1261 while ($row = $this->db->fetchAssoc(
$res)) {
1262 $row[
"desc"] = $row[
"description"];
1263 $row[
"user_id"] = (
int) $row[
"owner"];
1264 $role_list[] = $row;
1266 return $this->__setRoleType($role_list);
1277 $this->db =
$DIC[
'ilDB'];
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);
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;
1294 return array_values(
$info);
1302 if (!$this->isAssignable($a_role_id, $a_rolf_id)) {
1320 return substr($title, 0, 3) ==
'il_';
1323 public function getParentOfRole(
int $role_id, ?
int $object_ref =
null): ?
int
1327 $tree =
$DIC[
'tree'];
1330 return $this->getRoleFolderOfRole($role_id);
1334 $path_ids = $tree->getPathId($object_ref);
1337 while ($ref_id = array_pop($path_ids)) {
1338 $roles = $this->getRoleListByObject($ref_id,
false);
1339 foreach ($roles as $role) {
1340 if ((
int) $role[
'obj_id'] === $role_id) {
1353 $and = (
'AND assign = ' . $this->db->quote(
'y',
'text'));
1358 $query =
'SELECT * FROM rbac_fa ' .
1359 'WHERE rol_id = ' . $this->db->quote($a_role_id,
'integer') .
' ' .
1361 $res = $this->db->query($query);
1363 return (
int) $row->parent;
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') .
" ";
1379 $res = $this->db->query($query);
1381 while ($row = $this->db->fetchObject(
$res)) {
1382 $ops = unserialize($row->ops_id, [
'allowed_classes' =>
false]);
1383 $all_ops = array_merge($all_ops, $ops);
1385 $all_ops = array_unique($all_ops);
1387 $set = $this->db->query(
"SELECT operation FROM rbac_operations " .
1388 " WHERE " . $this->db->in(
"ops_id", $all_ops,
false,
"integer"));
1390 while ($rec = $this->db->fetchAssoc($set)) {
1391 $perms[] = $rec[
"operation"];
1394 return array_values(array_filter($perms));
1402 self::$is_assigned_cache[$a_role_id][$a_user_id] = $a_value;
1407 return self::$is_assigned_cache[$a_role_id][$a_user_id];
1415 self::$is_assigned_cache = [];
1416 self::$assigned_users_cache = [];
1427 "SELECT ops_id" . PHP_EOL
1428 .
"FROM rbac_operations" . PHP_EOL
1429 .
"WHERE operation = " .
$ilDB->quote($operation,
"text") . PHP_EOL
1438 return (
int) $row[
"ops_id"] ??
null;
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
1455 return (
bool)
$ilDB->numRows(
$ilDB->query($sql));
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
static _getAssignUsersStatus(int $a_role_id)
static _lookupType(int $id, bool $reference=false)
static _lookupTitle(int $obj_id)
class ilRbacReview Contains Review functions of core Rbac.
getAssignableRoles(bool $a_templates=false, bool $a_internal_roles=false, string $title_filter='')
Returns a list of all assignable roles.
buildRoleType(array $role_list_entry)
getAssignableRolesGenerator(bool $a_templates=false, bool $a_internal_roles=false, string $title_filter='')
getTypeId(string $a_type)
isDeleted(int $a_node_id)
Checks if a rolefolder is set as deleted (negative tree_id)
static array $assigned_users_cache
getAssignedCacheEntry(int $a_role_id, int $a_user_id)
static _getOperationIdsByName(array $operations)
get ops_id's by name.
getRolesForIDs(array $role_ids, bool $use_templates)
hasMultipleAssignments(int $a_role_id)
isBlockedAtPosition(int $a_role_id, int $a_ref_id)
isRoleDeleted(int $a_role_id)
return if role is only attached to deleted role folders
getObjectReferenceOfRole(int $a_role_id)
__getParentRoles(array $a_path, bool $a_templates)
Note: This function performs faster than the new getParentRoles function, because it uses database in...
__setRoleType(array $a_role_list)
computes role type in role list array: global: roles in ROLE_FOLDER_ID local: assignable roles in oth...
assignedRoles(int $a_usr_id)
get all assigned roles to a given user
getAssignableRolesInSubtree(int $ref_id)
Returns a list of assignable roles in a subtree of the repository.
getGlobalRoles()
get only 'global' roles
const FILTER_NOT_INTERNAL
static lookupCreateOperationIds(array $a_type_arr)
Lookup operation ids.
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 re...
static _getCustomRBACOperationId(string $operation, ?\ilDBInterface $ilDB=null)
isProtected(int $a_ref_id, int $a_role_id)
ref_id not used yet.
isBlockedInUpperContext(int $a_role_id, int $a_ref_id)
Check if role is blocked in upper context.
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 neces...
setRoleTypeAndProtection(array $role_list_entry)
getAssignableChildRoles(int $a_ref_id)
Get all assignable roles directly under a specific node.
static _groupOperationsByClass(array $a_ops_arr)
getRolesOfObject(int $a_ref_id, bool $a_assignable_only=false)
Get roles of object.
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 p...
roleExists(string $a_title, int $a_id=0)
Checks if a role already exists.
clearCaches()
Clear assigned users caches.
__setProtectedStatus(array $a_parent_roles, array $a_role_hierarchy, int $a_ref_id)
assignedUsers(int $a_rol_id)
get all assigned users to a given role
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.
static _isRBACOperation(int $type_id, int $ops_id, ?\ilDBInterface $ilDB=null)
getUserPermissionsOnObject(int $a_user_id, int $a_ref_id)
Get all user permissions on an object.
getRoleFolderOfRole(int $a_role_id)
isAssigned(int $a_usr_id, int $a_role_id)
check if a specific user is assigned to specific role
__construct(protected ilDBInterface $db, protected LoggerInterface $log)
Constructor @access public.
getFoldersAssignedToRole(int $a_rol_id, bool $a_assignable=false)
Returns an array of objects assigned to a role.
getGlobalAssignableRoles()
get only 'global' roles (with flag 'assign_users')
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...
buildProtectionByStringValue(string $value)
isSystemGeneratedRole(int $a_role_id)
Check if the role is system generate role or role template.
__setTemplateFilter(bool $a_templates)
get roles and templates or only roles; returns string for where clause
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 neces...
getNumberOfAssignedUsers(array $a_roles)
Get the number of assigned users to roles (not properly deleted user accounts are not counted)
isRoleAssignedToObject(int $a_role_id, int $a_parent_id)
Check if role is assigned to an object.
assignedGlobalRoles(int $a_usr_id)
Get assigned global roles for an user.
getLocalPolicies(int $a_ref_id)
Get all roles with local policies.
isAssignable(int $a_rol_id, int $a_ref_id)
Check if its possible to assign users.
getRoleListByObject(int $a_ref_id, bool $a_templates=false)
Returns a list of roles in an container.
static array $is_assigned_cache
getOperationsOnTypeString(string $a_type)
all possible operations of a type
getOperation(int $ops_id)
get one operation by operation id
getGlobalRolesArray()
get only 'global' roles
getRolesByFilter(int $a_filter=0, int $a_user_id=0, string $title_filter='')
setAssignedCacheEntry(int $a_role_id, int $a_user_id, bool $a_value)
set entry of assigned_chache
getOperationsByTypeAndClass(string $a_type, string $a_class)
Get operations by type and class.
getOperationAssignment()
get operation assignments
getActiveOperationsOfRole(int $a_ref_id, int $a_role_id)
isGlobalRole(int $a_role_id)
Check if role is a global role.
getRoleOperationsOnObject(int $a_role_id, int $a_ref_id)
getObjectOfRole(int $a_role_id)
Get object id of objects a role is assigned to.
getOperations()
get all possible operations
getLocalRoles(int $a_ref_id)
Get local roles of object.
getOperationsOnType(int $a_typ_id)
all possible operations of a type
static _getOperationIdByName(string $a_operation)
get operation id by name of operation
static _getOperationList(string $a_type='')
get operation list by object type
isDeleteable(int $a_role_id, int $a_rolf_id)
Check if role is deleteable at a specific position.
return['3gp', '7z', 'ai', 'aif', 'aifc', 'aiff', 'au', 'arw', 'avi', 'backup', 'bak', 'bas', 'bpmn', 'bpmn2', 'bmp', 'bib', 'bibtex', 'bz', 'bz2', 'c', 'c++', 'cc', 'cct', 'cdf', 'cer', 'class', 'cls', 'conf', 'cpp', 'crt', 'crs', 'crw', 'cr2', 'css', 'cst', 'csv', 'cur', 'db', 'dcr', 'des', 'dng', 'doc', 'docx', 'dot', 'dotx', 'dtd', 'dvi', 'el', 'eps', 'epub', 'f', 'f77', 'f90', 'flv', 'for', 'g3', 'gif', 'gl', 'gan', 'ggb', 'gsd', 'gsm', 'gtar', 'gz', 'gzip', 'h', 'hpp', 'htm', 'html', 'htmls', 'ibooks', 'ico', 'ics', 'ini', 'ipynb', 'java', 'jbf', 'jpeg', 'jpg', 'js', 'jsf', 'jso', 'json', 'latex', 'lang', 'less', 'log', 'lsp', 'ltx', 'm1v', 'm2a', 'm2v', 'm3u', 'm4a', 'm4v', 'markdown', 'm', 'mat', 'md', 'mdl', 'mdown', 'mid', 'min', 'midi', 'mobi', 'mod', 'mov', 'movie', 'mp2', 'mp3', 'mp4', 'mpa', 'mpeg', 'mpg', 'mph', 'mpga', 'mpp', 'mpt', 'mpv', 'mpx', 'mv', 'mw', 'mv4', 'nb', 'nbp', 'nef', 'nif', 'niff', 'obj', 'obm', 'odt', 'ods', 'odp', 'odg', 'odf', 'oga', 'ogg', 'ogv', 'old', 'p', 'pas', 'pbm', 'pcl', 'pct', 'pcx', 'pdf', 'pgm', 'pic', 'pict', 'png', 'por', 'pov', 'project', 'properties', 'ppa', 'ppm', 'pps', 'ppsx', 'ppt', 'pptx', 'ppz', 'ps', 'psd', 'pwz', 'qt', 'qtc', 'qti', 'qtif', 'r', 'ra', 'ram', 'rar', 'rast', 'rda', 'rev', 'rexx', 'ris', 'rf', 'rgb', 'rm', 'rmd', 'rmi', 'rmm', 'rmp', 'rt', 'rtf', 'rtx', 'rv', 's', 's3m', 'sav', 'sbs', 'sec', 'sdml', 'sgm', 'sgml', 'smi', 'smil', 'srt', 'sps', 'spv', 'stl', 'svg', 'swa', 'swf', 'swz', 'tar', 'tex', 'texi', 'texinfo', 'text', 'tgz', 'tif', 'tiff', 'ttf', 'txt', 'tmp', 'uvproj', 'vdf', 'vimeo', 'viv', 'vivo', 'vrml', 'vsdx', 'vtt', 'wav', 'webm', 'wmv', 'wmx', 'wmz', 'woff', 'wwd', 'xhtml', 'xif', 'xls', 'xlsx', 'xmind', 'xml', 'xsl', 'xsd', 'zip']
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
foreach($_POST as $key=> $value) $res