46 (isset($ilDB)) ? $this->
ilDB =& $ilDB : $this->
ilDB =& $ilias->db;
111 include_once
"Services/Mail/classes/class.ilMail.php";
112 if(ilMail::_usePearMail())
114 require_once
'./Services/PEAR/lib/Mail/RFC822.php';
116 $parsedList = $parser->parseAddressList($a_address_list,
"ilias",
false,
true);
117 foreach ($parsedList as $address)
119 $local_part = $address->mailbox;
120 if (strpos($local_part,
'#') !== 0 &&
121 !($local_part{0} ==
'"' && $local_part{1} ==
"#"))
128 $local_part = substr($local_part, 1);
132 if( $local_part{0} ==
'#' && $local_part{strlen($local_part) - 1} ==
'"' )
134 $local_part = substr($local_part, 1);
135 $local_part = substr($local_part, 0, strlen($local_part) - 1);
138 if (substr($local_part,0,8) ==
'il_role_')
140 $role_id = substr($local_part,8);
141 $query =
"SELECT t.tree ".
143 "JOIN tree t ON t.child = fa.parent ".
144 "WHERE fa.rol_id = ".$this->ilDB->quote($role_id,
'integer').
" ".
145 "AND fa.assign = 'y' ".
147 $r = $ilDB->query(
$query);
148 if ($r->numRows() > 0)
150 $role_ids[] = $role_id;
156 $domain = $address->host;
157 if (strpos($domain,
'[') == 0 && strrpos($domain,
']'))
159 $domain = substr($domain,1,strlen($domain) - 2);
161 if (strlen($local_part) == 0)
163 $local_part = $domain;
164 $address->host =
'ilias';
168 if (strtolower($address->host) ==
'ilias')
171 $query =
"SELECT dat.obj_id ".
172 "FROM object_data dat ".
173 "JOIN rbac_fa fa ON fa.rol_id = dat.obj_id ".
174 "JOIN tree t ON t.child = fa.parent ".
175 "WHERE dat.title =".$this->ilDB->quote($local_part,
'text').
" ".
176 "AND dat.type = 'role' ".
177 "AND fa.assign = 'y' ".
183 $query =
"SELECT rdat.obj_id ".
184 "FROM object_data odat ".
185 "JOIN object_reference oref ON oref.obj_id = odat.obj_id ".
186 "JOIN tree otree ON otree.child = oref.ref_id ".
187 "JOIN tree rtree ON rtree.parent = otree.child ".
188 "JOIN rbac_fa rfa ON rfa.parent = rtree.child ".
189 "JOIN object_data rdat ON rdat.obj_id = rfa.rol_id ".
190 "WHERE odat.title = ".$this->ilDB->quote($domain,
'text').
" ".
191 "AND otree.tree = 1 AND rtree.tree = 1 ".
192 "AND rfa.assign = 'y' ".
193 "AND rdat.title LIKE ".
194 $this->
ilDB->
quote(
'%'.preg_replace(
'/([_%])/',
'\\\\$1',$local_part).
'%',
'text');
196 $r = $ilDB->query(
$query);
201 $role_ids[] =
$row->obj_id;
207 if ($count == 0 && strtolower($address->host) ==
'ilias')
209 $q =
"SELECT dat.obj_id ".
210 "FROM object_data dat ".
211 "JOIN object_reference ref ON ref.obj_id = dat.obj_id ".
212 "JOIN tree t ON t.child = ref.ref_id ".
213 "WHERE dat.title = ".$this->ilDB->quote($domain ,
'text').
" ".
214 "AND dat.type = 'role' ".
220 $role_ids[] =
$row->obj_id;
231 $titles = explode(
',', $a_address_list);
234 foreach ($titles as
$title)
236 if (strlen($inList) > 0)
240 $title = trim($title);
241 if (strpos($title,
'#') == 0)
243 $titleList .= $this->
ilDB->
quote(substr($title, 1));
246 if (strlen($titleList) > 0)
248 $q =
"SELECT obj_id ".
250 "WHERE title IN (".$titleList.
") ".
255 $role_ids[] =
$row->obj_id;
330 include_once
"Services/Mail/classes/class.ilMail.php";
331 if (ilMail::_usePearMail())
334 $query =
"SELECT rdat.title role_title,odat.title object_title, ".
335 " oref.ref_id object_ref ".
336 "FROM object_data rdat ".
337 "JOIN rbac_fa fa ON fa.rol_id = rdat.obj_id ".
338 "JOIN tree rtree ON rtree.child = fa.parent ".
339 "JOIN object_reference oref ON oref.ref_id = rtree.parent ".
340 "JOIN object_data odat ON odat.obj_id = oref.obj_id ".
341 "WHERE rdat.obj_id = ".$this->ilDB->quote($a_role_id,
'integer').
" ".
342 "AND fa.assign = 'y' ";
343 $r = $ilDB->query(
$query);
344 if (!
$row = $ilDB->fetchObject($r))
349 $object_title =
$row->object_title;
350 $object_ref =
$row->object_ref;
351 $role_title =
$row->role_title;
357 $domain = $object_title;
358 $local_part = $role_title;
362 $q =
"SELECT COUNT(DISTINCT dat.obj_id) count ".
363 "FROM object_data dat ".
364 "JOIN object_reference ref ON ref.obj_id = dat.obj_id ".
365 "JOIN tree ON tree.child = ref.ref_id ".
366 "WHERE title = ".$this->ilDB->quote($object_title,
'text').
" ".
367 "AND tree.tree = 1 ";
381 if ($domain != null && preg_match(
'/[\[\]\\]|[\x00-\x1f]|[\x28-\x29]|[;]/',$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) count ".
422 "FROM object_data dat ".
423 "JOIN object_reference 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,
'text').
" ".
426 "AND tree.tree = 1 ";
430 $q =
"SELECT COUNT(rd.obj_id) count ".
431 "FROM object_data rd ".
432 "JOIN rbac_fa fa ON rd.obj_id = fa.rol_id ".
433 "JOIN tree t ON t.child = fa.parent ".
434 "WHERE fa.assign = 'y' ".
435 "AND t.parent = ".$this->ilDB->quote($object_ref,
'integer').
" ".
436 "AND rd.title LIKE ".$this->ilDB->quote(
437 '%'.preg_replace(
'/([_%])/',
'\\\\$1', $local_part).
'%',
'text').
" ";
447 $local_part = $unambiguous_role_title;
454 if (preg_match(
'/[\\"\x00-\x1f]/',$local_part))
456 $local_part = $unambiguous_role_title;
458 else if(!preg_match(
'/^[\\x00-\\x7E]+$/i', $local_part))
461 $local_part = $unambiguous_role_title;
466 $local_part =
'#'.$local_part;
469 if (preg_match(
'/[()<>@,;:.\[\]\x20]/',$local_part))
471 $local_part =
'"'.$local_part.
'"';
474 $mailbox = ($domain == null) ?
476 $local_part.
'@'.$domain;
480 if (substr($role_title,0,3) ==
'il_')
482 $phrase = $lng->txt(substr($role_title, 0, strrpos($role_title,
'_')));
486 $phrase = $role_title;
494 $phrase = preg_replace(
'/\s\s+/',
' ', $phrase);
495 $phrase = preg_replace(
'/[()<>@,;:\\".\[\]]/',
'', $phrase);
497 $mailbox = $phrase.
' <'.$mailbox.
'>';
505 $q =
"SELECT title ".
507 "WHERE obj_id = ".$this->ilDB->quote($a_role_id ,
'integer');
512 return '#'.$row->title;
535 $message = get_class($this).
"::roleExists(): No title given!";
536 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
539 $clause = ($a_id) ?
" AND obj_id != ".$ilDB->quote($a_id).
" " :
"";
541 $q =
"SELECT DISTINCT(obj_id) obj_id FROM object_data ".
542 "WHERE title =".$ilDB->quote($a_title).
" ".
543 "AND type IN('role','rolt')".
570 if (!isset($a_path) or !is_array($a_path))
572 $message = get_class($this).
"::getParentRoles(): No path given or wrong datatype!";
573 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
576 $parent_roles = array();
577 $role_hierarchy = array();
581 $in = $ilDB->in(
't.parent',$a_path,
false,
'integer');
583 $q =
"SELECT t.child,t.depth FROM tree t ".
584 "JOIN object_reference r ON r.ref_id = t.child ".
585 "JOIN object_data o ON o.obj_id = r.obj_id ".
587 "AND o.type= ".$ilDB->quote(
'rolf',
'text').
" ".
588 "ORDER BY t.depth ASC";
594 $role_rows = array();
598 $depth = (
$row->child == ROLE_FOLDER_ID ? 0 :
$row->depth);
599 $role_rows[$depth][
'child'] =
$row->child;
601 ksort($role_rows,SORT_NUMERIC);
603 foreach($role_rows as
$row)
606 foreach ($roles as $role)
608 $id = $role[
"obj_id"];
609 $role[
"parent"] = $row[
'child'];
610 $parent_roles[$id] = $role;
612 if (!array_key_exists($role[
'obj_id'],$role_hierarchy))
614 $role_hierarchy[$id] = $row[
'child'];
618 if (!$a_keep_protected)
622 return $parent_roles;
635 global $tree,
$log,$ilDB;
637 if (!isset($a_endnode_id))
640 $message = get_class($this).
"::getParentRoleIds(): No node_id (ref_id) given!";
641 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
646 $pathIds = $tree->getPathId($a_endnode_id);
649 $pathIds[0] = SYSTEM_FOLDER_ID;
651 #return $this->getParentRoles($a_endnode_id,$a_templates,$a_keep_protected);
666 if (!isset($a_ref_id) or !isset($a_templates))
668 $message = get_class($this).
"::getRoleListByObject(): Missing parameter!".
669 "ref_id: ".$a_ref_id.
670 "tpl_flag: ".$a_templates;
671 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
674 $role_list = array();
678 $query =
"SELECT * FROM object_data ".
679 "JOIN rbac_fa ON obj_id = rol_id ".
681 "AND object_data.obj_id = rbac_fa.rol_id ".
682 "AND rbac_fa.parent = ".$ilDB->quote($a_ref_id,
'integer').
" ";
685 while (
$row = $ilDB->fetchAssoc(
$res))
707 $role_list = array();
711 $query =
"SELECT * FROM object_data ".
712 "JOIN rbac_fa ON obj_id = rol_id ".
714 "AND rbac_fa.assign = 'y' ";
716 if(strlen($title_filter))
718 $query .= (
' AND '.$ilDB->like(
726 while (
$row = $ilDB->fetchAssoc(
$res))
748 $role_list = array();
751 $query =
"SELECT fa.*, dat.* ".
753 "JOIN tree node ON node.tree = root.tree ".
754 "AND node.lft > root.lft AND node.rgt < root.rgt ".
755 "JOIN object_reference ref ON ref.ref_id = node.child ".
756 "JOIN rbac_fa fa ON fa.parent = ref.ref_id ".
757 "JOIN object_data dat ON dat.obj_id = fa.rol_id ".
758 "WHERE root.child = ".$this->ilDB->quote(
$ref_id,
'integer').
" ".
759 "AND root.tree = 1 ".
760 "AND fa.assign = 'y' ".
761 "ORDER BY dat.title";
764 while(
$row = $ilDB->fetchAssoc(
$res))
784 $query =
"SELECT fa.*, rd.* ".
785 "FROM object_data rd ".
786 "JOIN rbac_fa fa ON rd.obj_id = fa.rol_id ".
787 "JOIN tree t ON t.child = fa.parent ".
788 "WHERE fa.assign = 'y' ".
789 "AND t.parent = ".$this->ilDB->quote($a_ref_id,
'integer').
" "
792 while(
$row = $ilDB->fetchAssoc(
$res))
794 $roles_data[] =
$row;
796 return $roles_data ? $roles_data : array();
809 if ($a_templates ===
true)
811 $where =
"WHERE ".$ilDB->in(
'object_data.type',array(
'role',
'rolt'),
false,
'text').
" ";
815 $where =
"WHERE ".$ilDB->in(
'object_data.type',array(
'role'),
false,
'text').
" ";
834 foreach ($a_role_list as $key => $val)
837 if ($val[
"type"] ==
"rolt")
839 $a_role_list[$key][
"role_type"] =
"template";
843 if ($val[
"assign"] ==
"y")
845 if ($val[
"parent"] == ROLE_FOLDER_ID)
847 $a_role_list[$key][
"role_type"] =
"global";
851 $a_role_list[$key][
"role_type"] =
"local";
856 $a_role_list[$key][
"role_type"] =
"linked";
860 if ($val[
"protected"] ==
"y")
862 $a_role_list[$key][
"protected"] =
true;
866 $a_role_list[$key][
"protected"] =
false;
883 $query =
'SELECT COUNT(DISTINCT(usr_id)) as num FROM rbac_ua '.
884 'WHERE '.$ilDB->in(
'rol_id', $a_roles,
false,
'integer').
' ';
902 $ilBench->start(
"RBAC",
"review_assignedUsers");
904 if (!isset($a_rol_id))
906 $message = get_class($this).
"::assignedUsers(): No role_id given!";
907 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
910 $result_arr = array();
912 if ($a_fields !== NULL and is_array($a_fields))
914 if (count($a_fields) == 0)
920 if (($usr_id_field = array_search(
"usr_id",$a_fields)) !==
false)
921 unset($a_fields[$usr_id_field]);
923 $select = implode(
",",$a_fields).
",usr_data.usr_id";
924 $select = addslashes($select);
927 $ilDB->enableResultBuffering(
false);
928 $query =
"SELECT ".$select.
" FROM usr_data ".
929 "LEFT JOIN rbac_ua ON usr_data.usr_id = rbac_ua.usr_id ".
930 "WHERE rbac_ua.rol_id =".$ilDB->quote($a_rol_id,
'integer');
932 while(
$row = $ilDB->fetchAssoc(
$res))
934 $result_arr[] =
$row;
936 $ilDB->enableResultBuffering(
true);
940 $ilDB->enableResultBuffering(
false);
941 $query =
"SELECT usr_id FROM rbac_ua WHERE rol_id= ".$ilDB->quote($a_rol_id,
'integer');
944 while(
$row = $ilDB->fetchAssoc(
$res))
946 array_push($result_arr,
$row[
"usr_id"]);
948 $ilDB->enableResultBuffering(
true);
951 $ilBench->stop(
"RBAC",
"review_assignedUsers");
968 $ilDB->setLimit(1,0);
969 $query =
"SELECT usr_id FROM rbac_ua WHERE ".
970 "rol_id= ".$ilDB->quote($a_role_id,
'integer').
" ".
971 "AND usr_id= ".$ilDB->quote($a_usr_id);
974 return $res->numRows() == 1;
992 $ilDB->setLimit(1,0);
993 $query =
"SELECT usr_id FROM rbac_ua WHERE ".
994 $ilDB->in(
'rol_id',$a_role_ids,
false,
'integer').
995 " AND usr_id= ".$ilDB->quote($a_usr_id);
998 return $ilDB->numRows(
$res) == 1;
1011 $role_arr = array();
1013 $query =
"SELECT rol_id FROM rbac_ua WHERE usr_id = ".$ilDB->quote($a_usr_id,
'integer');
1016 while(
$row = $ilDB->fetchObject(
$res))
1018 $role_arr[] =
$row->rol_id;
1020 return $role_arr ? $role_arr : array();
1031 $query =
"SELECT ua.rol_id FROM rbac_ua ua ".
1032 "JOIN rbac_fa fa ON ua.rol_id = fa.rol_id ".
1033 "WHERE usr_id = ".$ilDB->quote($a_usr_id,
'integer').
' '.
1034 "AND parent = ".$ilDB->quote(ROLE_FOLDER_ID).
" ".
1035 "AND assign = 'y' ";
1038 while(
$row = $ilDB->fetchObject(
$res))
1040 $role_arr[] =
$row->rol_id;
1042 return $role_arr ? $role_arr : array();
1056 $ilBench->start(
"RBAC",
"review_isAssignable");
1059 if ($a_rol_id == SYSTEM_ROLE_ID)
1061 $ilBench->stop(
"RBAC",
"review_isAssignable");
1065 if (!isset($a_rol_id) or !isset($a_ref_id))
1067 $message = get_class($this).
"::isAssignable(): Missing parameter!".
1068 " role_id: ".$a_rol_id.
" ,ref_id: ".$a_ref_id;
1069 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
1071 $query =
"SELECT * FROM rbac_fa ".
1072 "WHERE rol_id = ".$ilDB->quote($a_rol_id,
'integer').
" ".
1073 "AND parent = ".$ilDB->quote($a_ref_id,
'integer').
" ";
1077 $ilBench->stop(
"RBAC",
"review_isAssignable");
1078 return $row->assign ==
'y' ?
true :
false;
1088 $query =
"SELECT * FROM rbac_fa WHERE rol_id = ".$ilDB->quote($a_role_id,
'integer').
' '.
1089 "AND assign = ".$ilDB->quote(
'y',
'text');
1091 return $res->numRows() > 1;
1108 if (!isset($a_rol_id))
1110 $message = get_class($this).
"::getFoldersAssignedToRole(): No role_id given!";
1111 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
1116 $where =
" AND assign ='y'";
1119 $query =
"SELECT DISTINCT parent FROM rbac_fa ".
1120 "WHERE rol_id = ".$ilDB->quote($a_rol_id,
'integer').
" ".$where.
" ";
1123 while(
$row = $ilDB->fetchObject(
$res))
1125 $folders[] =
$row->parent;
1127 return $folders ? $folders : array();
1142 $ilBench->start(
"RBAC",
"review_getRolesOfRoleFolder");
1144 if (!isset($a_ref_id))
1146 $message = get_class($this).
"::getRolesOfRoleFolder(): No ref_id given!";
1147 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
1151 if ($a_nonassignable ===
false)
1153 $and =
" AND assign='y'";
1156 $query =
"SELECT rol_id FROM rbac_fa ".
1157 "WHERE parent = ".$ilDB->quote($a_ref_id,
'integer').
" ".
1161 while(
$row = $ilDB->fetchObject(
$res))
1163 $rol_id[] =
$row->rol_id;
1166 $ilBench->stop(
"RBAC",
"review_getRolesOfRoleFolder");
1168 return $rol_id ? $rol_id : array();
1200 $lroles[] = $role_id;
1215 $ga[] = array(
'obj_id' => $role_id,
1216 'role_type' =>
'global');
1218 return $ga ? $ga : array();
1228 include_once
'./Services/AccessControl/classes/class.ilObjRole.php';
1234 $ga[] = array(
'obj_id' => $role_id,
1235 'role_type' =>
'global');
1238 return $ga ? $ga : array();
1250 $query =
"SELECT DISTINCT parent FROM rbac_fa";
1254 while(
$row = $ilDB->fetchObject(
$res))
1256 $parent[] =
$row->parent;
1271 $ilBench->start(
"RBAC",
"review_getRoleFolderOfObject");
1273 if (!isset($a_ref_id))
1276 $message = get_class($this).
"::getRoleFolderOfObject(): No ref_id given!";
1277 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
1279 $childs = $tree->getChildsByType($a_ref_id,
"rolf");
1281 $ilBench->stop(
"RBAC",
"review_getRoleFolderOfObject");
1283 return $childs[0] ? $childs[0] : array();
1295 return $rolf[
'ref_id'];
1303 global $rbacreview, $ilDB;
1305 $query =
'SELECT * FROM rbac_fa '.
1306 'WHERE rol_id = '.$ilDB->quote($a_role_id,
'integer').
' '.
1307 'AND parent = '.$ilDB->quote($a_parent_id,
'integer');
1309 return $res->numRows() ?
true :
false;
1321 $query =
'SELECT * FROM rbac_operations ORDER BY ops_id ';
1323 while(
$row = $ilDB->fetchObject(
$res))
1325 $ops[] = array(
'ops_id' =>
$row->ops_id,
1326 'operation' =>
$row->operation,
1327 'description' =>
$row->description);
1330 return $ops ? $ops : array();
1342 $query =
'SELECT * FROM rbac_operations WHERE ops_id = '.$ilDB->quote($ops_id,
'integer');
1344 while(
$row = $ilDB->fetchObject(
$res))
1346 $ops = array(
'ops_id' =>
$row->ops_id,
1347 'operation' =>
$row->operation,
1348 'description' =>
$row->description);
1351 return $ops ? $ops : array();
1368 $a_parent = ROLE_FOLDER_ID;
1371 $query =
"SELECT ops_id,type FROM rbac_templates ".
1372 "WHERE rol_id = ".$ilDB->quote($a_rol_id,
'integer').
" ".
1373 "AND parent = ".$ilDB->quote($a_parent,
'integer');
1376 while (
$row = $ilDB->fetchObject(
$res))
1378 $ops_arr[
$row->type][] =
$row->ops_id;
1380 return (array) $ops_arr;
1393 $query =
'SELECT * FROM rbac_pa '.
1394 'WHERE ref_id = '.$ilDB->quote($a_ref_id,
'integer').
' '.
1395 'AND rol_id = '.$ilDB->quote($a_role_id,
'integer').
' ';
1400 return unserialize(
$row[
'ops_id']);
1419 if (!isset($a_rol_id) or !isset($a_type))
1421 $message = get_class($this).
"::getOperationsOfRole(): Missing Parameter!".
1422 "role_id: ".$a_rol_id.
1424 "parent_id: ".$a_parent;
1425 $ilLog->logStack(
"Missing parameter! ");
1426 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
1434 $a_parent = ROLE_FOLDER_ID;
1437 $query =
"SELECT ops_id FROM rbac_templates ".
1438 "WHERE type =".$ilDB->quote($a_type,
'text').
" ".
1439 "AND rol_id = ".$ilDB->quote($a_rol_id,
'integer').
" ".
1440 "AND parent = ".$ilDB->quote($a_parent,
'integer');
1442 while (
$row = $ilDB->fetchObject(
$res))
1444 $ops_arr[] =
$row->ops_id;
1454 $query =
"SELECT * FROM rbac_pa ".
1455 "WHERE rol_id = ".$ilDB->quote($a_role_id,
'integer').
" ".
1456 "AND ref_id = ".$ilDB->quote($a_ref_id,
'integer').
" ";
1459 while(
$row = $ilDB->fetchObject(
$res))
1461 $ops = unserialize(
$row->ops_id);
1464 return $ops ? $ops : array();
1477 if (!isset($a_typ_id))
1479 $message = get_class($this).
"::getOperationsOnType(): No type_id given!";
1480 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
1483 #$query = "SELECT * FROM rbac_ta WHERE typ_id = ".$ilDB->quote($a_typ_id,'integer');
1485 $query =
'SELECT * FROM rbac_ta ta JOIN rbac_operations o ON ta.ops_id = o.ops_id '.
1486 'WHERE typ_id = '.$ilDB->quote($a_typ_id,
'integer').
' '.
1487 'ORDER BY op_order';
1491 while(
$row = $ilDB->fetchObject(
$res))
1493 $ops_id[] =
$row->ops_id;
1496 return $ops_id ? $ops_id : array();
1509 $query =
"SELECT * FROM object_data WHERE type = 'typ' AND title = ".$ilDB->quote($a_type ,
'text').
" ";
1530 if($a_class !=
'create')
1532 $condition =
"AND class != ".$ilDB->quote(
'create',
'text');
1536 $condition =
"AND class = ".$ilDB->quote(
'create',
'text');
1539 $query =
"SELECT ro.ops_id FROM rbac_operations ro ".
1540 "JOIN rbac_ta rt ON ro.ops_id = rt.ops_id ".
1541 "JOIN object_data od ON rt.typ_id = od.obj_id ".
1542 "WHERE type = ".$ilDB->quote(
'typ',
'text').
" ".
1543 "AND title = ".$ilDB->quote($a_type,
'text').
" ".
1545 "ORDER BY op_order ";
1552 $ops[] =
$row->ops_id;
1570 $query =
'SELECT t.parent p FROM tree t JOIN rbac_fa fa ON fa.parent = child '.
1571 'WHERE assign = '.$ilDB->quote(
'n',
'text').
' '.
1572 'AND rol_id = '.$ilDB->quote($a_rol_id,
'integer').
' ';
1576 $query .= (
'AND '.$ilDB->in(
't.parent',(array) $a_filter,
false,
'integer'));
1583 $parent[] =
$row->p;
1598 $q =
"SELECT tree FROM tree WHERE child =".$ilDB->quote($a_node_id).
" ";
1605 $message = sprintf(
'%s::isDeleted(): Role folder with ref_id %s not found!',
1608 $this->log->write($message,$this->log->FATAL);
1641 case self::FILTER_ALL:
1646 case self::FILTER_ALL_GLOBAL:
1647 $where =
'WHERE '.$ilDB->in(
'rbac_fa.rol_id',$this->
getGlobalRoles(),
false,
'integer').
' ';
1651 case self::FILTER_ALL_LOCAL:
1652 case self::FILTER_INTERNAL:
1653 case self::FILTER_NOT_INTERNAL:
1654 $where =
'WHERE '.$ilDB->in(
'rbac_fa.rol_id',$this->
getGlobalRoles(),
true,
'integer');
1658 case self::FILTER_TEMPLATES:
1659 $where =
"WHERE object_data.type = 'rolt'";
1669 $where =
'WHERE '.$ilDB->in(
'rbac_fa.rol_id',$this->
assignedRoles($a_user_id),
false,
'integer').
' ';
1675 $query =
"SELECT * FROM object_data ".
1676 "JOIN rbac_fa ON obj_id = rol_id ".
1678 "AND rbac_fa.assign = ".$ilDB->quote($assign,
'text').
" ";
1680 if(strlen($title_filter))
1682 $query .= (
' AND '.$ilDB->like(
1685 '%'.$title_filter.
'%'
1690 while(
$row = $ilDB->fetchAssoc(
$res))
1692 $prefix = (substr(
$row[
"title"],0,3) ==
"il_") ?
true :
false;
1695 if ($a_filter == 4 and !$prefix)
1701 if ($a_filter == 5 and $prefix)
1706 $row[
"desc"] =
$row[
"description"];
1713 return $roles ? $roles : array();
1721 $q =
"SELECT obj_id FROM object_data ".
1722 "WHERE title=".$ilDB->quote($a_type ,
'text').
" AND type='typ'";
1723 $r = $ilDB->query($q);
1726 return $row->obj_id;
1742 if(!count($operations))
1747 $query =
'SELECT ops_id FROM rbac_operations '.
1748 'WHERE '.$ilDB->in(
'operation',$operations,
false,
'text');
1751 while(
$row = $ilDB->fetchObject(
$res))
1753 $ops_ids[] =
$row->ops_id;
1755 return $ops_ids ? $ops_ids : array();
1769 if (!isset($a_operation))
1771 $message =
"perm::getOperationId(): No operation given!";
1772 $ilErr->raiseError($message,$ilErr->WARNING);
1776 if (! is_array(self::$_opsCache)) {
1777 self::$_opsCache = array();
1779 $q =
"SELECT ops_id, operation FROM rbac_operations";
1780 $r = $ilDB->query($q);
1783 self::$_opsCache[
$row->operation] =
$row->ops_id;
1788 if (array_key_exists($a_operation, self::$_opsCache)) {
1789 return self::$_opsCache[$a_operation];
1803 $operations = array();
1804 foreach($a_type_arr as $type)
1806 $operations[] = (
'create_'.$type);
1809 if(!count($operations))
1814 $query =
'SELECT ops_id, operation FROM rbac_operations '.
1815 'WHERE '.$ilDB->in(
'operation',$operations,
false,
'text');
1820 while(
$row = $ilDB->fetchObject(
$res))
1822 $type_arr = explode(
'_',
$row->operation);
1823 $type = $type_arr[1];
1825 $ops_ids[$type] =
$row->ops_id;
1843 if (!isset($a_ref_id))
1845 $message = get_class($this).
"::getLinkedRolesOfRoleFolder(): No ref_id given!";
1846 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
1849 $and =
" AND assign='n'";
1851 $query =
"SELECT rol_id FROM rbac_fa ".
1852 "WHERE parent = ".$ilDB->quote($a_ref_id,
'integer').
" ".
1855 while(
$row = $ilDB->fetchObject(
$res))
1857 $rol_id[] =
$row->rol_id;
1860 return $rol_id ? $rol_id : array();
1868 $query =
"SELECT protected FROM rbac_fa ".
1869 "WHERE rol_id = ".$ilDB->quote($a_role_id,
'integer').
" ".
1870 "AND parent = ".$ilDB->quote($a_ref_id,
'integer').
" ";
1885 if (in_array(SYSTEM_ROLE_ID,$this->
assignedRoles($ilUser->getId())))
1891 $leveladmin =
false;
1893 #vd("RoleHierarchy",$a_role_hierarchy);
1894 foreach ($a_role_hierarchy as $role_id => $rolf_id)
1897 #echo "<br/>ROLF: ".$rolf_id." ROLE_ID: ".$role_id." (".$a_parent_roles[$role_id]['title'].") ";
1900 if ($leveladmin ==
true)
1902 $a_parent_roles[$role_id][
'protected'] =
false;
1906 if ($a_parent_roles[$role_id][
'protected'] ==
true)
1908 $arr_lvl_roles_user = array_intersect($this->
assignedRoles($ilUser->getId()),array_keys($a_role_hierarchy,$rolf_id));
1910 #vd("intersection",$arr_lvl_roles_user);
1912 foreach ($arr_lvl_roles_user as $lvl_role_id)
1914 #echo "<br/>level_role: ".$lvl_role_id;
1915 #echo "<br/>a_ref_id: ".$a_ref_id;
1919 $rolf = $a_parent_roles[$role_id][
'parent'];
1920 $parent_obj =
$GLOBALS[
'tree']->getParentId($rolf);
1921 if ($rbacsystem->checkPermission($parent_obj,$lvl_role_id,
'edit_permission'))
1923 #echo "<br />Permission granted";
1926 $a_parent_roles[$role_id][
'protected'] =
false;
1935 return $a_parent_roles;
1956 $query = sprintf(
'SELECT * FROM rbac_operations '.
1957 'JOIN rbac_ta ON rbac_operations.ops_id = rbac_ta.ops_id '.
1958 'JOIN object_data ON rbac_ta.typ_id = object_data.obj_id '.
1959 'WHERE object_data.title = %s '.
1960 'AND object_data.type = %s '.
1961 'ORDER BY op_order ASC',
1962 $ilDB->quote($a_type,
'text'),
1963 $ilDB->quote(
'typ',
'text'));
1967 $query =
'SELECT * FROM rbac_operations ORDER BY op_order ASC';
1970 while (
$row = $ilDB->fetchAssoc(
$res))
1973 "ops_id" =>
$row[
'ops_id'],
1974 "operation" =>
$row[
'operation'],
1975 "desc" =>
$row[
'description'],
1976 "class" =>
$row[
'class'],
1977 "order" =>
$row[
'op_order']
1987 foreach ($a_ops_arr as $ops)
1989 $arr[$ops[
'class']][] = array (
'ops_id' => $ops[
'ops_id'],
1990 'name' => $ops[
'operation']
2006 static $obj_cache = array();
2011 if(isset($obj_cache[$a_role_id]) and $obj_cache[$a_role_id])
2013 return $obj_cache[$a_role_id];
2016 $query =
"SELECT obr.obj_id FROM rbac_fa rfa ".
2017 "JOIN tree ON rfa.parent = tree.child ".
2018 "JOIN object_reference obr ON tree.parent = obr.ref_id ".
2019 "WHERE tree.tree = 1 ".
2020 "AND assign = 'y' ".
2021 "AND rol_id = ".$ilDB->quote($a_role_id,
'integer').
" ";
2024 $obj_cache[$a_role_id] = 0;
2025 while(
$row = $ilDB->fetchObject(
$res))
2027 $obj_cache[$a_role_id] =
$row->obj_id;
2029 return $obj_cache[$a_role_id];
2041 $query =
"SELECT tree.parent ref FROM rbac_fa fa ".
2042 "JOIN tree ON fa.parent = tree.child ".
2043 "WHERE tree.tree = 1 ".
2044 "AND assign = ".$ilDB->quote(
'y',
'text').
' '.
2045 "AND rol_id = ".$ilDB->quote($a_role_id,
'integer');
2064 if (count($rolf_list))
2066 foreach ($rolf_list as $rolf) {
2083 $role_list = array();
2087 $query =
"SELECT * FROM object_data ".
2088 "JOIN rbac_fa ON object_data.obj_id = rbac_fa.rol_id ".
2090 "AND rbac_fa.assign = 'y' " .
2091 'AND '.$ilDB->in(
'object_data.obj_id',$role_ids,
false,
'integer');
2094 while(
$row = $ilDB->fetchAssoc(
$res))
2096 $row[
"desc"] =
$row[
"description"];
2098 $role_list[] =
$row;
2113 $query =
'SELECT ta.typ_id, obj.title, ops.ops_id, ops.operation FROM rbac_ta ta '.
2114 'JOIN object_data obj ON obj.obj_id = ta.typ_id '.
2115 'JOIN rbac_operations ops ON ops.ops_id = ta.ops_id ';
2119 while(
$row = $ilDB->fetchObject(
$res))
2121 $info[$counter][
'typ_id'] =
$row->typ_id;
2122 $info[$counter][
'type'] =
$row->title;
2123 $info[$counter][
'ops_id'] =
$row->ops_id;
2124 $info[$counter][
'operation'] =
$row->operation;
2127 return $info ? $info : array();
2143 $query =
'SELECT DISTINCT(parent) parent FROM rbac_fa '.
2144 'WHERE '.$ilDB->in(
'parent',$a_rolf_candidates,
false,
'integer');
2146 while(
$row = $ilDB->fetchObject(
$res))
2148 $non_empty[] =
$row->parent;
2150 return $non_empty ? $non_empty : array();
2165 if($a_role_id == SYSTEM_ROLE_ID or $a_role_id == ANONYMOUS_ROLE_ID)
2184 return substr(
$title,0,3) ==
'il_' ?
true :
false;
2200 $and = (
'AND assign = '.$ilDB->quote(
'y',
'text'));
2207 $query =
'SELECT * FROM rbac_fa '.
2208 'WHERE rol_id = '.$ilDB->quote($a_role_id,
'integer').
' '.
2213 return $row->parent;
2228 $query =
"SELECT ops_id FROM rbac_pa JOIN rbac_ua ".
2229 "ON (rbac_pa.rol_id = rbac_ua.rol_id) ".
2230 "WHERE rbac_ua.usr_id = ".$ilDB->quote($a_user_id,
'integer').
" ".
2231 "AND rbac_pa.ref_id = ".$ilDB->quote($a_ref_id,
'integer').
" ";
2235 while (
$row = $ilDB->fetchObject(
$res))
2237 $ops = unserialize(
$row->ops_id);
2238 $all_ops = array_merge($all_ops, $ops);
2240 $all_ops = array_unique($all_ops);
2242 $set = $ilDB->query(
"SELECT operation FROM rbac_operations ".
2243 " WHERE ".$ilDB->in(
"ops_id", $all_ops,
false,
"integer"));
2245 while ($rec = $ilDB->fetchAssoc($set))
2247 $perms[] = $rec[
"operation"];