59 (isset($ilDB)) ? $this->ilDB =& $ilDB : $this->ilDB =& $ilias->db;
64 $ilErr->setErrorHandling(PEAR_ERROR_CALLBACK,array($ilErr,
'errorHandler'));
122 include_once
"Services/Mail/classes/class.ilMail.php";
125 require_once
'Mail/RFC822.php';
126 $parser = &
new Mail_RFC822();
127 $parsedList = $parser->parseAddressList($a_address_list,
"ilias",
false,
true);
129 foreach ($parsedList as $address)
131 $local_part = $address->mailbox;
132 if (strpos($local_part,
'#') !== 0)
139 $local_part = substr($local_part, 1);
141 if (substr($local_part,0,8) ==
'il_role_')
143 $role_id = substr($local_part,8);
144 $q =
"SELECT t.tree ".
145 "FROM rbac_fa AS fa ".
146 "JOIN tree AS t ON t.child=fa.parent ".
147 "WHERE fa.rol_id=".$this->ilDB->quote($role_id).
" ".
148 "AND fa.assign='y' ".
150 $r = $this->ilDB->query($q);
151 if ($r->numRows() > 0)
153 $role_ids[] = $role_id;
159 $domain = $address->host;
160 if (strpos($domain,
'[') == 0 && strrpos($domain,
']'))
162 $domain = substr($domain,1,strlen($domain) - 2);
164 if (strlen($local_part) == 0)
166 $local_part = $domain;
167 $address->host =
'ilias';
171 if (strtolower($address->host) ==
'ilias')
174 $q =
"SELECT dat.obj_id ".
175 "FROM object_data AS dat ".
176 "JOIN rbac_fa AS fa ON fa.rol_id = dat.obj_id ".
177 "JOIN tree AS t ON t.child = fa.parent ".
178 "WHERE dat.title =".$this->ilDB->quote($local_part).
" ".
179 "AND dat.type = 'role' ".
180 "AND fa.assign = 'y' ".
186 $q =
"SELECT rdat.obj_id ".
187 "FROM object_data AS odat ".
188 "JOIN object_reference AS oref ON oref.obj_id = odat.obj_id ".
189 "JOIN tree AS otree ON otree.child = oref.ref_id ".
190 "JOIN tree AS rtree ON rtree.parent = otree.child ".
191 "JOIN rbac_fa AS rfa ON rfa.parent = rtree.child ".
192 "JOIN object_data AS rdat ON rdat.obj_id = rfa.rol_id ".
193 "WHERE odat.title = ".$this->ilDB->quote($domain).
" ".
194 "AND otree.tree = 1 AND rtree.tree = 1 ".
195 "AND rfa.assign = 'y' ".
196 "AND rdat.title LIKE ".
197 $this->ilDB->quote(
'%'.preg_replace(
'/([_%])/',
'\\\\$1',$local_part).
'%');
199 $r = $this->ilDB->query($q);
204 $role_ids[] = $row->obj_id;
210 if ($count == 0 && strtolower($address->host) ==
'ilias')
212 $q =
"SELECT dat.obj_id ".
213 "FROM object_data AS dat ".
214 "JOIN object_reference AS ref ON ref.obj_id = dat.obj_id ".
215 "JOIN tree AS t ON t.child = ref.ref_id ".
216 "WHERE dat.title = ".$this->ilDB->quote($domain).
" ".
217 "AND dat.type = 'role' ".
219 $r = $this->ilDB->query($q);
223 $role_ids[] = $row->obj_id;
234 $titles = explode(
',', $a_address_list);
237 foreach ($titles as
$title)
239 if (strlen($inList) > 0)
243 $title = trim($title);
244 if (strpos($title,
'#') == 0)
246 $titleList .= $this->ilDB->quote(substr($title, 1));
249 if (strlen($titleList) > 0)
251 $q =
"SELECT obj_id ".
253 "WHERE title IN (".$titleList.
") ".
255 $r = $this->ilDB->query($q);
258 $role_ids[] = $row->obj_id;
333 include_once
"Services/Mail/classes/class.ilMail.php";
337 $q =
"SELECT rdat.title AS role_title,odat.title AS object_title, ".
338 " oref.ref_id AS object_ref ".
339 "FROM object_data AS rdat ".
340 "JOIN rbac_fa AS fa ON fa.rol_id = rdat.obj_id ".
341 "JOIN tree AS rtree ON rtree.child = fa.parent ".
342 "JOIN object_reference AS oref ON oref.ref_id = rtree.parent ".
343 "JOIN object_data AS odat ON odat.obj_id = oref.obj_id ".
344 "WHERE rdat.obj_id = ".$this->ilDB->quote($a_role_id).
" ".
345 "AND fa.assign = 'y' ";
346 $r = $this->ilDB->query($q);
352 $object_title = $row->object_title;
353 $object_ref = $row->object_ref;
354 $role_title = $row->role_title;
360 $domain = $object_title;
361 $local_part = $role_title;
365 $q =
"SELECT COUNT(DISTINCT dat.obj_id) AS count ".
366 "FROM object_data AS dat ".
367 "JOIN object_reference AS ref ON ref.obj_id = dat.obj_id ".
368 "JOIN tree ON tree.child = ref.ref_id ".
369 "WHERE title = ".$this->ilDB->quote($object_title).
" ".
371 $r = $this->ilDB->query($q);
381 if (domain != null && preg_match(
'/[\[\]\\]|[\x00-\x1f]/',$domain))
388 if ($domain != null &&
389 (preg_match(
'/[()<>@,;:\\".\[\]]/',$domain) ||
390 preg_match(
'/[^\x21-\x8f]/',$domain))
393 $domain =
'['.$domain.
']';
399 if (strpos($role_title,
'il_') === 0 && $domain != null)
401 $unambiguous_role_title = $role_title;
403 $pos = strpos($role_title,
'_', 3) + 1;
404 $local_part = substr(
407 strrpos($role_title,
'_') - $pos
412 $unambiguous_role_title =
'il_role_'.$a_role_id;
421 $q =
"SELECT COUNT(DISTINCT dat.obj_id) AS count ".
422 "FROM object_data AS dat ".
423 "JOIN object_reference AS ref ON ref.obj_id = dat.obj_id ".
424 "JOIN tree ON tree.child = ref.ref_id ".
425 "WHERE title = ".$this->ilDB->quote($local_part).
" ".
430 $q =
"SELECT COUNT(rd.obj_id) AS count ".
431 "FROM object_data AS rd ".
432 "JOIN rbac_fa AS fa ON rd.obj_id = fa.rol_id ".
433 "JOIN tree AS t ON t.child = fa.parent ".
434 "WHERE fa.assign = 'y' ".
435 "AND t.parent = ".$this->ilDB->quote($object_ref).
" ".
436 "AND rd.title LIKE ".$this->ilDB->quote(
437 '%'.preg_replace(
'/([_%])/',
'\\\\$1', $local_part).
'%')
441 $r = $this->ilDB->query($q);
448 $local_part = $unambiguous_role_title;
454 if (preg_match(
'/[\\"\x00-\x1f]/',$local_part))
456 $local_part = $unambiguous_role_title;
461 $local_part =
'#'.$local_part;
464 if (preg_match(
'/[()<>@,;:.\[\]\x20]/',$local_part))
466 $local_part =
'"'.$local_part.
'"';
469 $mailbox = ($domain == null) ?
471 $local_part.
'@'.$domain;
475 if (substr($role_title,0,3) ==
'il_')
477 $phrase = $lng->txt(substr($role_title, 0, strrpos($role_title,
'_')));
481 $phrase = $role_title;
487 $phrase = preg_replace(
'/\s\s+/',
' ', $phrase);
488 $phrase = preg_replace(
'/[()<>@,;:\\".\[\]]/',
'', $phrase);
490 $mailbox = $phrase.
' <'.$mailbox.
'>';
497 $q =
"SELECT title ".
499 "WHERE obj_id = ".$this->ilDB->quote($a_role_id);
500 $r = $this->ilDB->query($q);
504 return '#'.$row->title;
527 $message = get_class($this).
"::roleExists(): No title given!";
528 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
531 $clause = ($a_id) ?
" AND obj_id != ".$ilDB->quote($a_id).
" " :
"";
533 $q =
"SELECT DISTINCT(obj_id) as obj_id FROM object_data ".
534 "WHERE title =".$ilDB->quote($a_title).
" ".
535 "AND type IN('role','rolt')".
537 $r = $this->ilDB->query($q);
555 global
$log,$ilDB,$tree;
557 $parent_roles = array();
558 $role_hierarchy = array();
560 $node = $tree->getNodeData($a_path);
566 $relevant_rolfs[] = ROLE_FOLDER_ID;
571 $relevant_rolfs[] = $rolf;
575 $query =
"SELECT * FROM tree ".
576 "JOIN object_reference as obr ON child = ref_id ".
577 "JOIN object_data as obd ON obr.obj_id = obd.obj_id ".
578 "WHERE type = 'rolf' ".
579 "AND lft < ".$lft.
" ".
583 $res = $ilDB->query($query);
586 $relevant_rolfs[] = $row->child;
588 foreach($relevant_rolfs as $rolf)
592 foreach ($roles as $role)
594 $id = $role[
"obj_id"];
595 $role[
"parent"] = $rolf;
596 $parent_roles[$id] = $role;
598 if (!array_key_exists($role[
'obj_id'],$role_hierarchy))
600 $role_hierarchy[$id] = $rolf;
605 if (!$a_keep_protected)
609 return $parent_roles;
628 if (!isset($a_path) or !is_array($a_path))
630 $message = get_class($this).
"::getParentRoles(): No path given or wrong datatype!";
631 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
634 $parent_roles = array();
635 $role_hierarchy = array();
644 $q =
"SELECT t.child,t.depth FROM tree AS t ".
645 "JOIN object_reference AS r ON r.ref_id=t.child ".
646 "JOIN object_data AS o ON o.obj_id=r.obj_id ".
647 "WHERE t.parent ".$in.
" ".
648 "AND o.type='rolf' ".
649 "ORDER BY t.depth ASC ";
650 $r = $this->ilDB->query($q);
653 $role_rows = array();
657 $depth = ($row->child == ROLE_FOLDER_ID ? 0 : $row->depth);
658 $role_rows[$depth][
'child'] = $row->child;
660 ksort($role_rows,SORT_NUMERIC);
661 foreach($role_rows as $row)
664 foreach ($roles as $role)
666 $id = $role[
"obj_id"];
667 $role[
"parent"] = $row[
'child'];
668 $parent_roles[$id] = $role;
670 if (!array_key_exists($role[
'obj_id'],$role_hierarchy))
672 $role_hierarchy[$id] = $row[
'child'];
676 if (!$a_keep_protected)
680 return $parent_roles;
693 global $tree,
$log,$ilDB;
695 if (!isset($a_endnode_id))
697 $message = get_class($this).
"::getParentRoleIds(): No node_id (ref_id) given!";
698 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
703 $pathIds = $tree->getPathId($a_endnode_id);
706 $pathIds[0] = SYSTEM_FOLDER_ID;
708 #return $this->getParentRoles($a_endnode_id,$a_templates,$a_keep_protected);
723 if (!isset($a_ref_id) or !isset($a_templates))
725 $message = get_class($this).
"::getRoleListByObject(): Missing parameter!".
726 "ref_id: ".$a_ref_id.
727 "tpl_flag: ".$a_templates;
728 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
731 $role_list = array();
735 $q =
"SELECT * FROM object_data ".
736 "JOIN rbac_fa ".$where.
737 "AND object_data.obj_id = rbac_fa.rol_id ".
738 "AND rbac_fa.parent = ".$ilDB->quote($a_ref_id).
" ";
739 $r = $this->ilDB->query($q);
743 $row[
"desc"] = $row[
"description"];
744 $row[
"user_id"] = $row[
"owner"];
763 $role_list = array();
767 $q =
"SELECT DISTINCT * FROM object_data ".
768 "JOIN rbac_fa ".$where.
769 "AND object_data.obj_id = rbac_fa.rol_id ".
770 "AND rbac_fa.assign = 'y'";
771 $r = $this->ilDB->query($q);
775 $row[
"desc"] = $row[
"description"];
776 $row[
"user_id"] = $row[
"owner"];
793 $role_list = array();
797 $q =
"SELECT fa.*, dat.* ".
798 "FROM tree AS root ".
799 "JOIN tree AS node ON node.tree = root.tree AND node.lft > root.lft AND node.rgt < root.rgt ".
800 "JOIN object_reference AS ref ON ref.ref_id = node.child ".
801 "JOIN rbac_fa AS fa ON fa.parent = ref.ref_id ".
802 "JOIN object_data AS dat ON dat.obj_id = fa.rol_id ".
803 "WHERE root.child = ".$this->ilDB->quote(
$ref_id).
" AND root.tree = 1 ".
804 "AND fa.assign = 'y' ".
805 "ORDER BY dat.title";
806 $r = $this->ilDB->query($q);
829 $q =
"SELECT fa.*, rd.* ".
830 "FROM object_data AS rd ".
831 "JOIN rbac_fa AS fa ON rd.obj_id = fa.rol_id ".
832 "JOIN tree AS t ON t.child = fa.parent ".
833 "WHERE fa.assign = 'y' ".
834 "AND t.parent = ".$this->ilDB->quote($a_ref_id).
" "
836 $r = $this->ilDB->query($q);
840 $roles_data[] = $row;
843 return $roles_data ? $roles_data : array();
854 if ($a_templates ===
true)
856 $where =
"WHERE object_data.type IN ('role','rolt') ";
860 $where =
"WHERE object_data.type = 'role' ";
879 foreach ($a_role_list as $key => $val)
882 if ($val[
"type"] ==
"rolt")
884 $a_role_list[$key][
"role_type"] =
"template";
888 if ($val[
"assign"] ==
"y")
890 if ($val[
"parent"] == ROLE_FOLDER_ID)
892 $a_role_list[$key][
"role_type"] =
"global";
896 $a_role_list[$key][
"role_type"] =
"local";
901 $a_role_list[$key][
"role_type"] =
"linked";
905 if ($val[
"protected"] ==
"y")
907 $a_role_list[$key][
"protected"] =
true;
911 $a_role_list[$key][
"protected"] =
false;
929 $ilBench->start(
"RBAC",
"review_assignedUsers");
931 if (!isset($a_rol_id))
933 $message = get_class($this).
"::assignedUsers(): No role_id given!";
934 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
937 $result_arr = array();
939 if ($a_fields !== NULL and is_array($a_fields))
941 if (count($a_fields) == 0)
947 if (($usr_id_field = array_search(
"usr_id",$a_fields)) !==
false)
948 unset($a_fields[$usr_id_field]);
950 $select = implode(
",",$a_fields).
",usr_data.usr_id";
951 $select = addslashes($select);
954 $q =
"SELECT ".$select.
" FROM usr_data ".
955 "LEFT JOIN rbac_ua ON usr_data.usr_id=rbac_ua.usr_id ".
956 "WHERE rbac_ua.rol_id=".$ilDB->quote($a_rol_id).
" ";
957 $r = $this->ilDB->query($q);
961 $result_arr[] = $row;
966 $q =
"SELECT usr_id FROM rbac_ua WHERE rol_id=".$ilDB->quote($a_rol_id).
" ";
967 $r = $this->ilDB->query($q);
971 array_push($result_arr,$row[
"usr_id"]);
975 $ilBench->stop(
"RBAC",
"review_assignedUsers");
992 $query =
"SELECT usr_id FROM rbac_ua WHERE ".
993 "rol_id= ".$ilDB->quote($a_role_id,
'integer').
" ".
994 "AND usr_id= ".$ilDB->quote($a_usr_id).
998 $res = $ilDB->query($query);
1000 return $res->numRows() == 1;
1019 foreach ($a_role_ids as $v)
1021 if ($inClause !=
'') {
1024 $inClause .= $ilDB->quote($v);
1028 $query =
"SELECT COUNT(usr_id) AS num_found FROM rbac_ua WHERE ".
1029 " rol_id IN(".$inClause.
")".
1030 " AND usr_id= ".$ilDB->quote($a_usr_id).
" ";
1032 $res = $ilDB->query($query);
1035 if((
int)$row->num_found >= 1)
1056 $role_arr = array();
1058 $q =
"SELECT rol_id FROM rbac_ua WHERE usr_id = ".$ilDB->quote($a_usr_id).
" ";
1059 $r = $this->ilDB->query($q);
1063 $role_arr[] = $row->rol_id;
1066 if (!count($role_arr))
1068 $message = get_class($this).
"::assignedRoles(): No assigned roles found or user does not exist!";
1070 return $role_arr ? $role_arr : array();
1084 $ilBench->start(
"RBAC",
"review_isAssignable");
1087 if ($a_rol_id == SYSTEM_ROLE_ID)
1089 $ilBench->stop(
"RBAC",
"review_isAssignable");
1094 if (!isset($a_rol_id) or !isset($a_ref_id))
1096 $message = get_class($this).
"::isAssignable(): Missing parameter!".
1097 " role_id: ".$a_rol_id.
" ,ref_id: ".$a_ref_id;
1098 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
1101 $q =
"SELECT * FROM rbac_fa ".
1102 "WHERE rol_id = ".$ilDB->quote($a_rol_id).
" ".
1103 "AND parent = ".$ilDB->quote($a_ref_id).
" ";
1104 $row = $this->ilDB->getRow($q);
1106 $ilBench->stop(
"RBAC",
"review_isAssignable");
1108 return $row->assign ==
'y' ?
true :
false;
1125 if (!isset($a_rol_id))
1127 $message = get_class($this).
"::getFoldersAssignedToRole(): No role_id given!";
1128 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
1133 $where =
" AND assign ='y'";
1136 $q =
"SELECT DISTINCT parent FROM rbac_fa ".
1137 "WHERE rol_id = ".$ilDB->quote($a_rol_id).
" ".$where;
1138 $r = $this->ilDB->query($q);
1142 $folders[] = $row->parent;
1145 return $folders ? $folders : array();
1160 $ilBench->start(
"RBAC",
"review_getRolesOfRoleFolder");
1162 if (!isset($a_ref_id))
1164 $message = get_class($this).
"::getRolesOfRoleFolder(): No ref_id given!";
1165 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
1169 if ($a_nonassignable ===
false)
1171 $and =
" AND assign='y'";
1174 $q =
"SELECT rol_id FROM rbac_fa ".
1175 "WHERE parent = ".$ilDB->quote($a_ref_id).
" ".
1178 $r = $this->ilDB->query($q);
1182 $rol_id[] = $row->rol_id;
1185 $ilBench->stop(
"RBAC",
"review_getRolesOfRoleFolder");
1187 return $rol_id ? $rol_id : array();
1209 $ga[] = array(
'obj_id' => $role_id,
1210 'role_type' =>
'global');
1212 return $ga ? $ga : array();
1222 include_once
'./Services/AccessControl/classes/class.ilObjRole.php';
1228 $ga[] = array(
'obj_id' => $role_id,
1229 'role_type' =>
'global');
1232 return $ga ? $ga : array();
1244 $q =
"SELECT DISTINCT parent FROM rbac_fa";
1245 $r = $this->ilDB->query($q);
1249 $parent[] = $row->parent;
1265 $ilBench->start(
"RBAC",
"review_getRoleFolderOfObject");
1267 if (!isset($a_ref_id))
1269 $message = get_class($this).
"::getRoleFolderOfObject(): No ref_id given!";
1270 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
1273 $childs = $tree->getChildsByType($a_ref_id,
"rolf");
1275 $ilBench->stop(
"RBAC",
"review_getRoleFolderOfObject");
1277 return $childs[0] ? $childs[0] : array();
1289 return $rolf[
'ref_id'];
1301 $query =
"SELECT * FROM rbac_operations ORDER BY ops_id ";
1303 $res = $this->ilDB->query($query);
1306 $ops[] = array(
'ops_id' => $row->ops_id,
1307 'operation' => $row->operation,
1308 'description' => $row->description);
1311 return $ops ? $ops : array();
1323 $query =
"SELECT * FROM rbac_operations WHERE ops_id = ".$ilDB->quote($ops_id).
" ";
1325 $res = $this->ilDB->query($query);
1328 $ops = array(
'ops_id' => $row->ops_id,
1329 'operation' => $row->operation,
1330 'description' => $row->description);
1333 return $ops ? $ops : array();
1349 if (!isset($a_rol_id) or !isset($a_type))
1351 $message = get_class($this).
"::getOperationsOfRole(): Missing Parameter!".
1352 "role_id: ".$a_rol_id.
1354 "parent_id: ".$a_parent;
1355 $ilLog->logStack(
"Missing parameter! ");
1356 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
1364 $a_parent = ROLE_FOLDER_ID;
1367 $q =
"SELECT ops_id FROM rbac_templates ".
1368 "WHERE type =".$ilDB->quote($a_type).
" ".
1369 "AND rol_id = ".$ilDB->quote($a_rol_id).
" ".
1370 "AND parent = ".$ilDB->quote($a_parent).
"";
1371 $r = $this->ilDB->query($q);
1376 $ops_arr[] = $row->ops_id;
1386 $query =
"SELECT * FROM rbac_pa ".
1387 "WHERE rol_id = ".$ilDB->quote($a_role_id).
" ".
1388 "AND ref_id = ".$ilDB->quote($a_ref_id).
" ";
1390 $res = $this->ilDB->query($query);
1393 $ops = unserialize(stripslashes($row->ops_id));
1396 return $ops ? $ops : array();
1409 if (!isset($a_typ_id))
1411 $message = get_class($this).
"::getOperationsOnType(): No type_id given!";
1412 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
1415 $q =
"SELECT * FROM rbac_ta WHERE typ_id = ".$ilDB->quote($a_typ_id).
" ";
1416 $r = $this->ilDB->query($q);
1420 $ops_id[] = $row->ops_id;
1423 return $ops_id ? $ops_id : array();
1436 $query =
"SELECT * FROM object_data WHERE type = 'typ' AND title = ".$ilDB->quote($a_type).
" ";
1438 $res = $this->ilDB->query($query);
1454 $tree =
new ilTree(ROOT_FOLDER_ID);
1456 if (!isset($a_rol_id))
1458 $message = get_class($this).
"::getObjectsWithStopedInheritance(): No role_id given!";
1459 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
1464 foreach ($all_rolf_ids as $rolf_id)
1466 $parent[] = $tree->getParentId($rolf_id);
1469 return $parent ? $parent : array();
1482 $q =
"SELECT tree FROM tree WHERE child =".$ilDB->quote($a_node_id).
" ";
1483 $r = $this->ilDB->query($q);
1489 $message = sprintf(
'%s::isDeleted(): Role folder with ref_id %s not found!',
1492 $this->log->write($message,$this->log->FATAL);
1521 $where =
"WHERE rbac_fa.rol_id IN ";
1531 $where =
"WHERE rbac_fa.rol_id NOT IN ";
1539 $where =
"WHERE object_data.type = 'rolt'";
1546 if (!$a_user_id)
return array();
1548 $where =
"WHERE rbac_fa.rol_id IN ";
1557 $q =
"SELECT DISTINCT * FROM object_data ".
1558 "JOIN rbac_fa ".$where.
1559 "AND object_data.obj_id = rbac_fa.rol_id ".
1560 "AND rbac_fa.assign = ".$ilDB->quote($assign).
" ";
1561 $r = $this->ilDB->query($q);
1565 $prefix = (substr($row[
"title"],0,3) ==
"il_") ?
true :
false;
1568 if ($a_filter == 4 and !$prefix)
1574 if ($a_filter == 5 and $prefix)
1579 $row[
"desc"] = $row[
"description"];
1580 $row[
"user_id"] = $row[
"owner"];
1586 return $roles ? $roles : array();
1594 $q =
"SELECT obj_id FROM object_data ".
1595 "WHERE title=".$ilDB->quote($a_type).
" AND type='typ'";
1596 $r = $ilDB->query($q);
1599 return $row->obj_id;
1615 if(!count($operations))
1619 $where =
"WHERE operation IN (";
1623 $query =
"SELECT ops_id FROM rbac_operations ".$where;
1624 $res = $ilDB->query($query);
1627 $ops_ids[] = $row->ops_id;
1629 return $ops_ids ? $ops_ids : array();
1643 if (!isset($a_operation))
1645 $message =
"perm::getOperationId(): No operation given!";
1646 $ilErr->raiseError($message,$ilErr->WARNING);
1650 if (! is_array(self::$_opsCache)) {
1651 self::$_opsCache = array();
1653 $q =
"SELECT ops_id, operation FROM rbac_operations";
1654 $r = $ilDB->query($q);
1657 self::$_opsCache[$row->operation] = $row->ops_id;
1662 if (array_key_exists($a_operation, self::$_opsCache)) {
1663 return self::$_opsCache[$a_operation];
1681 if (!isset($a_ref_id))
1683 $message = get_class($this).
"::getLinkedRolesOfRoleFolder(): No ref_id given!";
1684 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
1687 $and =
" AND assign='n'";
1689 $q =
"SELECT rol_id FROM rbac_fa ".
1690 "WHERE parent = ".$ilDB->quote($a_ref_id).
" ".
1692 $r = $this->ilDB->query($q);
1696 $rol_id[] = $row->rol_id;
1699 return $rol_id ? $rol_id : array();
1707 $q =
"SELECT protected FROM rbac_fa ".
1708 "WHERE rol_id= ".$ilDB->quote($a_role_id).
" ".
1709 "AND parent= ".$ilDB->quote($a_ref_id).
" ";
1710 $r = $this->ilDB->query($q);
1711 $row = $r->fetchRow();
1720 global $rbacsystem,$ilUser,
$log;
1722 if (in_array(SYSTEM_ROLE_ID,$this->
assignedRoles($ilUser->getId())))
1728 $leveladmin =
false;
1733 foreach ($a_role_hierarchy as $role_id => $rolf_id)
1739 if ($leveladmin ==
true)
1741 $a_parent_roles[$role_id][
'protected'] =
false;
1745 if ($a_parent_roles[$role_id][
'protected'] ==
true)
1747 $arr_lvl_roles_user = array_intersect($this->
assignedRoles($ilUser->getId()),array_keys($a_role_hierarchy,$rolf_id));
1749 foreach ($arr_lvl_roles_user as $lvl_role_id)
1756 if ($rbacsystem->checkPermission($a_ref_id,$lvl_role_id,
'edit_permission'))
1760 $a_parent_roles[$role_id][
'protected'] =
false;
1769 return $a_parent_roles;
1790 $q =
"SELECT * FROM rbac_operations ".
1791 "LEFT JOIN rbac_ta ON rbac_operations.ops_id = rbac_ta.ops_id ".
1792 "LEFT JOIN object_data ON rbac_ta.typ_id = object_data.obj_id ".
1793 "WHERE object_data.title= ".$ilDB->quote($a_type).
" AND object_data.type='typ' ".
1794 "ORDER BY 'op_order' ASC";
1798 $q =
"SELECT * FROM rbac_operations ".
1799 "ORDER BY 'op_order' ASC";
1802 $r = $ilDB->query($q);
1804 while ($row = $r->fetchRow())
1807 "ops_id" => $row[0],
1808 "operation" => $row[1],
1822 foreach ($a_ops_arr as $ops)
1824 $arr[$ops[
'class']][] = array (
'ops_id' => $ops[
'ops_id'],
1825 'name' => $ops[
'operation']
1842 $query =
"SELECT obr.obj_id FROM rbac_fa as rfa ".
1843 "JOIN tree ON rfa.parent = tree.child ".
1844 "JOIN object_reference AS obr ON tree.parent = obr.ref_id ".
1845 "WHERE tree.tree = 1 ".
1846 "AND assign = 'y' ".
1847 "AND rol_id = ".$ilDB->quote($a_role_id).
" ";
1848 $res = $ilDB->query($query);
1851 $obj_id = $row->obj_id;
1854 return $obj_id ? $obj_id : 0;
1866 if (count($rolf_list))
1868 foreach ($rolf_list as $rolf) {
1885 $role_list = array();
1889 $q =
"SELECT DISTINCT * FROM object_data ".
1890 "JOIN rbac_fa ".$where.
1891 "AND object_data.obj_id = rbac_fa.rol_id ".
1892 "AND rbac_fa.assign = 'y' " .
1893 "AND object_data.obj_id IN (".implode(
",", $role_ids).
")";
1895 $r = $this->ilDB->query($q);
1899 $row[
"desc"] = $row[
"description"];
1900 $row[
"user_id"] = $row[
"owner"];
1901 $role_list[] = $row;