55 (isset($ilDB)) ? $this->
ilDB =& $ilDB : $this->
ilDB =& $ilias->db;
121 include_once
"Services/Mail/classes/class.ilMail.php";
122 if(ilMail::_usePearMail())
124 require_once
'./Services/PEAR/lib/Mail/RFC822.php';
126 $parsedList = $parser->parseAddressList($a_address_list,
ilMail::ILIAS_HOST,
false,
true);
127 foreach ($parsedList as $address)
129 $local_part = $address->mailbox;
130 if (strpos($local_part,
'#') !== 0 &&
131 !($local_part{0} ==
'"' && $local_part{1} ==
"#"))
138 $local_part = substr($local_part, 1);
142 if( $local_part{0} ==
'#' && $local_part{strlen($local_part) - 1} ==
'"' )
144 $local_part = substr($local_part, 1);
145 $local_part = substr($local_part, 0, strlen($local_part) - 1);
148 if (substr($local_part,0,8) ==
'il_role_')
150 $role_id = substr($local_part,8);
151 $query =
"SELECT t.tree ".
153 "JOIN tree t ON t.child = fa.parent ".
154 "WHERE fa.rol_id = ".$this->ilDB->quote($role_id,
'integer').
" ".
155 "AND fa.assign = 'y' ".
157 $r = $ilDB->query(
$query);
158 if ($r->numRows() > 0)
160 $role_ids[] = $role_id;
166 $domain = $address->host;
167 if (strpos($domain,
'[') == 0 && strrpos($domain,
']'))
169 $domain = substr($domain,1,strlen($domain) - 2);
171 if (strlen($local_part) == 0)
173 $local_part = $domain;
181 $query =
"SELECT dat.obj_id ".
182 "FROM object_data dat ".
183 "JOIN rbac_fa fa ON fa.rol_id = dat.obj_id ".
184 "JOIN tree t ON t.child = fa.parent ".
185 "WHERE dat.title =".$this->ilDB->quote($local_part,
'text').
" ".
186 "AND dat.type = 'role' ".
187 "AND fa.assign = 'y' ".
193 $query =
"SELECT rdat.obj_id ".
194 "FROM object_data odat ".
195 "JOIN object_reference oref ON oref.obj_id = odat.obj_id ".
196 "JOIN tree otree ON otree.child = oref.ref_id ".
197 "JOIN rbac_fa rfa ON rfa.parent = otree.child ".
198 "JOIN object_data rdat ON rdat.obj_id = rfa.rol_id ".
199 "WHERE odat.title = ".$this->ilDB->quote($domain,
'text').
" ".
200 "AND otree.tree = 1 ".
201 "AND rfa.assign = 'y' ".
202 "AND rdat.title LIKE ".
203 $this->
ilDB->
quote(
'%'.preg_replace(
'/([_%])/',
'\\\\$1',$local_part).
'%',
'text');
205 $r = $ilDB->query(
$query);
210 $role_ids[] =
$row->obj_id;
218 $q =
"SELECT dat.obj_id ".
219 "FROM object_data dat ".
220 "JOIN object_reference ref ON ref.obj_id = dat.obj_id ".
221 "JOIN tree t ON t.child = ref.ref_id ".
222 "WHERE dat.title = ".$this->ilDB->quote($domain ,
'text').
" ".
223 "AND dat.type = 'role' ".
229 $role_ids[] =
$row->obj_id;
240 $titles = explode(
',', $a_address_list);
243 foreach ($titles as $title)
245 if (strlen($inList) > 0)
249 $title = trim($title);
250 if (strpos($title,
'#') == 0)
252 $titleList .= $this->
ilDB->
quote(substr($title, 1));
255 if (strlen($titleList) > 0)
257 $q =
"SELECT obj_id ".
259 "WHERE title IN (".$titleList.
") ".
264 $role_ids[] =
$row->obj_id;
340 include_once
"Services/Mail/classes/class.ilMail.php";
341 if (ilMail::_usePearMail())
344 $query =
"SELECT rdat.title role_title,odat.title object_title, ".
345 " oref.ref_id object_ref ".
346 "FROM object_data rdat ".
347 "JOIN rbac_fa fa ON fa.rol_id = rdat.obj_id ".
348 "JOIN tree rtree ON rtree.child = fa.parent ".
349 "JOIN object_reference oref ON oref.ref_id = rtree.child ".
350 "JOIN object_data odat ON odat.obj_id = oref.obj_id ".
351 "WHERE rdat.obj_id = ".$this->ilDB->quote($a_role_id,
'integer').
" ".
352 "AND fa.assign = 'y' ";
353 $r = $ilDB->query(
$query);
354 if (!
$row = $ilDB->fetchObject($r))
359 $object_title =
$row->object_title;
360 $object_ref =
$row->object_ref;
361 $role_title =
$row->role_title;
367 $domain = $object_title;
368 $local_part = $role_title;
372 $q =
"SELECT COUNT(DISTINCT dat.obj_id) count ".
373 "FROM object_data dat ".
374 "JOIN object_reference ref ON ref.obj_id = dat.obj_id ".
375 "JOIN tree ON tree.child = ref.ref_id ".
376 "WHERE title = ".$this->ilDB->quote($object_title,
'text').
" ".
377 "AND tree.tree = 1 ";
391 if ($domain != null && preg_match(
'/[\[\]\\]|[\x00-\x1f]|[\x28-\x29]|[;]/',$domain))
398 if ($domain != null &&
399 (preg_match(
'/[()<>@,;:\\".\[\]]/',$domain) ||
400 preg_match(
'/[^\x21-\x8f]/',$domain))
403 $domain =
'['.$domain.
']';
409 if (strpos($role_title,
'il_') === 0 && $domain != null)
411 $unambiguous_role_title = $role_title;
413 $pos = strpos($role_title,
'_', 3) + 1;
414 $local_part = substr(
417 strrpos($role_title,
'_') - $pos
422 $unambiguous_role_title =
'il_role_'.$a_role_id;
431 $q =
"SELECT COUNT(DISTINCT dat.obj_id) count ".
432 "FROM object_data dat ".
433 "JOIN object_reference ref ON ref.obj_id = dat.obj_id ".
434 "JOIN tree ON tree.child = ref.ref_id ".
435 "WHERE title = ".$this->ilDB->quote($local_part,
'text').
" ".
436 "AND tree.tree = 1 ";
440 $q =
"SELECT COUNT(rd.obj_id) count ".
441 "FROM object_data rd ".
442 "JOIN rbac_fa fa ON rd.obj_id = fa.rol_id ".
443 "JOIN tree t ON t.child = fa.parent ".
444 "WHERE fa.assign = 'y' ".
445 "AND t.child = ".$this->ilDB->quote($object_ref,
'integer').
" ".
446 "AND rd.title LIKE ".$this->ilDB->quote(
447 '%'.preg_replace(
'/([_%])/',
'\\\\$1', $local_part).
'%',
'text').
" ";
457 $local_part = $unambiguous_role_title;
464 if (preg_match(
'/[\\"\x00-\x1f]/',$local_part))
466 $local_part = $unambiguous_role_title;
468 else if(!preg_match(
'/^[\\x00-\\x7E]+$/i', $local_part))
471 $local_part = $unambiguous_role_title;
476 $local_part =
'#'.$local_part;
479 if (preg_match(
'/[()<>@,;:.\[\]\x20]/',$local_part))
481 $local_part =
'"'.$local_part.
'"';
484 $mailbox = ($domain == null) ?
486 $local_part.
'@'.$domain;
490 if (substr($role_title,0,3) ==
'il_')
492 $phrase = $lng->txt(substr($role_title, 0, strrpos($role_title,
'_')));
496 $phrase = $role_title;
504 $phrase = preg_replace(
'/\s\s+/',
' ', $phrase);
505 $phrase = preg_replace(
'/[()<>@,;:\\".\[\]]/',
'', $phrase);
507 $mailbox = $phrase.
' <'.$mailbox.
'>';
511 require_once
'./Services/PEAR/lib/Mail/RFC822.php';
513 if(@$obj->parseAddressList() instanceof
PEAR_Error)
515 $q =
"SELECT title ".
517 "WHERE obj_id = ".$this->ilDB->quote($a_role_id ,
'integer');
522 return '#'.$row->title;
534 $q =
"SELECT title ".
536 "WHERE obj_id = ".$this->ilDB->quote($a_role_id ,
'integer');
541 return '#'.$row->title;
565 $message = get_class($this).
"::roleExists(): No title given!";
566 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
569 $clause = ($a_id) ?
" AND obj_id != ".$ilDB->quote($a_id).
" " :
"";
571 $q =
"SELECT DISTINCT(obj_id) obj_id FROM object_data ".
572 "WHERE title =".$ilDB->quote($a_title).
" ".
573 "AND type IN('role','rolt')".
599 if (!isset($a_path) or !is_array($a_path))
601 $message = get_class($this).
"::getParentRoles(): No path given or wrong datatype!";
602 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
605 $parent_roles = array();
606 $role_hierarchy = array();
611 foreach($roles as $role)
613 $id = $role[
"obj_id"];
615 $parent_roles[$id] = $role;
617 if (!array_key_exists($role[
'obj_id'],$role_hierarchy))
619 $role_hierarchy[$id] =
$ref_id;
639 if (!isset($a_endnode_id))
642 $message = get_class($this).
"::getParentRoleIds(): No node_id (ref_id) given!";
643 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
648 $pathIds = $tree->getPathId($a_endnode_id);
652 $pathIds[0] = ROLE_FOLDER_ID;
654 #return $this->getParentRoles($a_endnode_id,$a_templates,$a_keep_protected);
670 if (!isset($a_ref_id) or !isset($a_templates))
672 $message = get_class($this).
"::getRoleListByObject(): Missing parameter!".
673 "ref_id: ".$a_ref_id.
674 "tpl_flag: ".$a_templates;
675 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
678 $role_list = array();
682 $query =
"SELECT * FROM object_data ".
683 "JOIN rbac_fa ON obj_id = rol_id ".
685 "AND object_data.obj_id = rbac_fa.rol_id ".
686 "AND rbac_fa.parent = ".$ilDB->quote($a_ref_id,
'integer').
" ";
689 while (
$row = $ilDB->fetchAssoc(
$res))
712 $role_list = array();
716 $query =
"SELECT * FROM object_data ".
717 "JOIN rbac_fa ON obj_id = rol_id ".
719 "AND rbac_fa.assign = 'y' ";
721 if(strlen($title_filter))
723 $query .= (
' AND '.$ilDB->like(
731 while (
$row = $ilDB->fetchAssoc(
$res))
754 $query =
'SELECT rol_id FROM rbac_fa fa '.
755 'JOIN tree t1 ON t1.child = fa.parent '.
756 'JOIN object_data obd ON fa.rol_id = obd.obj_id ' .
757 'WHERE assign = '.$ilDB->quote(
'y',
'text').
' '.
758 'AND obd.type = '.$ilDB->quote(
'role',
'text').
' '.
766 $role_list = array();
769 $role_list[] =
$row->rol_id;
785 $query =
"SELECT fa.*, rd.* ".
786 "FROM object_data rd ".
787 "JOIN rbac_fa fa ON rd.obj_id = fa.rol_id ".
788 "WHERE fa.assign = 'y' ".
789 "AND fa.parent = ".$this->ilDB->quote($a_ref_id,
'integer').
" "
793 while(
$row = $ilDB->fetchAssoc(
$res))
795 $roles_data[] =
$row;
797 return $roles_data ? $roles_data : array();
811 if ($a_templates ===
true)
813 $where =
"WHERE ".$ilDB->in(
'object_data.type',array(
'role',
'rolt'),
false,
'text').
" ";
817 $where =
"WHERE ".$ilDB->in(
'object_data.type',array(
'role'),
false,
'text').
" ";
837 foreach ($a_role_list as $key => $val)
840 if ($val[
"type"] ==
"rolt")
842 $a_role_list[$key][
"role_type"] =
"template";
846 if ($val[
"assign"] ==
"y")
848 if ($val[
"parent"] == ROLE_FOLDER_ID)
850 $a_role_list[$key][
"role_type"] =
"global";
854 $a_role_list[$key][
"role_type"] =
"local";
859 $a_role_list[$key][
"role_type"] =
"linked";
863 if ($val[
"protected"] ==
"y")
865 $a_role_list[$key][
"protected"] =
true;
869 $a_role_list[$key][
"protected"] =
false;
887 $query =
'SELECT COUNT(DISTINCT(usr_id)) as num FROM rbac_ua '.
888 'WHERE '.$ilDB->in(
'rol_id', $a_roles,
false,
'integer').
' ';
908 $ilBench->start(
"RBAC",
"review_assignedUsers");
910 if (!isset($a_rol_id))
912 $message = get_class($this).
"::assignedUsers(): No role_id given!";
913 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
915 if (! $a_fields AND isset(self::$assigned_users_cache[$a_rol_id])) {
916 return self::$assigned_users_cache[$a_rol_id];
919 $result_arr = array();
921 if ($a_fields !== NULL and is_array($a_fields))
923 if (count($a_fields) == 0)
929 if (($usr_id_field = array_search(
"usr_id",$a_fields)) !==
false)
930 unset($a_fields[$usr_id_field]);
932 $select = implode(
",",$a_fields).
",usr_data.usr_id";
933 $select = addslashes($select);
936 $ilDB->enableResultBuffering(
false);
937 $query =
"SELECT ".$select.
" FROM usr_data ".
938 "LEFT JOIN rbac_ua ON usr_data.usr_id = rbac_ua.usr_id ".
939 "WHERE rbac_ua.rol_id =".$ilDB->quote($a_rol_id,
'integer');
941 while(
$row = $ilDB->fetchAssoc(
$res))
943 $result_arr[] =
$row;
945 $ilDB->enableResultBuffering(
true);
949 $ilDB->enableResultBuffering(
false);
950 $query =
"SELECT usr_id FROM rbac_ua WHERE rol_id= ".$ilDB->quote($a_rol_id,
'integer');
953 while(
$row = $ilDB->fetchAssoc(
$res))
955 array_push($result_arr,
$row[
"usr_id"]);
957 $ilDB->enableResultBuffering(
true);
960 $ilBench->stop(
"RBAC",
"review_assignedUsers");
963 self::$assigned_users_cache[$a_rol_id] = $result_arr;
980 if(isset(self::$is_assigned_cache[$a_role_id][$a_usr_id])) {
981 return self::$is_assigned_cache[$a_role_id][$a_usr_id];
986 $ilDB->setLimit(1,0);
987 $query =
"SELECT usr_id FROM rbac_ua WHERE ".
988 "rol_id= ".$ilDB->quote($a_role_id,
'integer').
" ".
989 "AND usr_id= ".$ilDB->quote($a_usr_id);
992 $is_assigned =
$res->numRows() == 1;
993 self::$is_assigned_cache[$a_role_id][$a_usr_id] = $is_assigned;
1014 $ilDB->setLimit(1,0);
1015 $query =
"SELECT usr_id FROM rbac_ua WHERE ".
1016 $ilDB->in(
'rol_id',$a_role_ids,
false,
'integer').
1017 " AND usr_id= ".$ilDB->quote($a_usr_id);
1020 return $ilDB->numRows(
$res) == 1;
1034 $role_arr = array();
1036 $query =
"SELECT rol_id FROM rbac_ua WHERE usr_id = ".$ilDB->quote($a_usr_id,
'integer');
1039 while(
$row = $ilDB->fetchObject(
$res))
1041 $role_arr[] =
$row->rol_id;
1043 return $role_arr ? $role_arr : array();
1055 $query =
"SELECT ua.rol_id FROM rbac_ua ua ".
1056 "JOIN rbac_fa fa ON ua.rol_id = fa.rol_id ".
1057 "WHERE usr_id = ".$ilDB->quote($a_usr_id,
'integer').
' '.
1058 "AND parent = ".$ilDB->quote(ROLE_FOLDER_ID).
" ".
1059 "AND assign = 'y' ";
1062 while(
$row = $ilDB->fetchObject(
$res))
1064 $role_arr[] =
$row->rol_id;
1066 return $role_arr ? $role_arr : array();
1081 $ilBench->start(
"RBAC",
"review_isAssignable");
1084 if ($a_rol_id == SYSTEM_ROLE_ID)
1086 $ilBench->stop(
"RBAC",
"review_isAssignable");
1090 if (!isset($a_rol_id) or !isset($a_ref_id))
1092 $message = get_class($this).
"::isAssignable(): Missing parameter!".
1093 " role_id: ".$a_rol_id.
" ,ref_id: ".$a_ref_id;
1094 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
1096 $query =
"SELECT * FROM rbac_fa ".
1097 "WHERE rol_id = ".$ilDB->quote($a_rol_id,
'integer').
" ".
1098 "AND parent = ".$ilDB->quote($a_ref_id,
'integer').
" ";
1102 $ilBench->stop(
"RBAC",
"review_isAssignable");
1103 return $row->assign ==
'y' ?
true :
false;
1115 $query =
"SELECT * FROM rbac_fa WHERE rol_id = ".$ilDB->quote($a_role_id,
'integer').
' '.
1116 "AND assign = ".$ilDB->quote(
'y',
'text');
1118 return $res->numRows() > 1;
1136 if (!isset($a_rol_id))
1138 $message = get_class($this).
"::getFoldersAssignedToRole(): No role_id given!";
1139 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
1144 $where =
" AND assign ='y'";
1147 $query =
"SELECT DISTINCT parent FROM rbac_fa ".
1148 "WHERE rol_id = ".$ilDB->quote($a_rol_id,
'integer').
" ".$where.
" ";
1151 while(
$row = $ilDB->fetchObject(
$res))
1153 $folders[] =
$row->parent;
1155 return $folders ? $folders : array();
1169 if(!isset($a_ref_id))
1172 throw new InvalidArgumentException(__METHOD__.
': No ref_id given!');
1174 if($a_assignable_only === TRUE)
1176 $and =
'AND assign = '.$ilDB->quote(
'y',
'text');
1178 $query =
"SELECT rol_id FROM rbac_fa ".
1179 "WHERE parent = ".$ilDB->quote($a_ref_id,
'integer').
" ".
1184 $role_ids = array();
1185 while(
$row = $ilDB->fetchObject(
$res))
1187 $role_ids[] =
$row->rol_id;
1209 $ilBench->start(
"RBAC",
"review_getRolesOfRoleFolder");
1211 if (!isset($a_ref_id))
1213 $message = get_class($this).
"::getRolesOfRoleFolder(): No ref_id given!";
1214 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
1218 if ($a_nonassignable ===
false)
1220 $and =
" AND assign='y'";
1223 $query =
"SELECT rol_id FROM rbac_fa ".
1224 "WHERE parent = ".$ilDB->quote($a_ref_id,
'integer').
" ".
1228 while(
$row = $ilDB->fetchObject(
$res))
1230 $rol_id[] =
$row->rol_id;
1233 $ilBench->stop(
"RBAC",
"review_getRolesOfRoleFolder");
1235 return $rol_id ? $rol_id : array();
1263 $lroles[] = $role_id;
1279 $lroles[] = $role_id;
1294 $ga[] = array(
'obj_id' => $role_id,
1295 'role_type' =>
'global');
1297 return $ga ? $ga : array();
1308 include_once
'./Services/AccessControl/classes/class.ilObjRole.php';
1314 $ga[] = array(
'obj_id' => $role_id,
1315 'role_type' =>
'global');
1318 return $ga ? $ga : array();
1328 global $rbacreview,
$ilDB;
1330 $query =
'SELECT * FROM rbac_fa '.
1331 'WHERE rol_id = '.$ilDB->quote($a_role_id,
'integer').
' '.
1332 'AND parent = '.$ilDB->quote($a_parent_id,
'integer');
1334 return $res->numRows() ?
true :
false;
1347 $query =
'SELECT * FROM rbac_operations ORDER BY ops_id ';
1349 while(
$row = $ilDB->fetchObject(
$res))
1351 $ops[] = array(
'ops_id' =>
$row->ops_id,
1352 'operation' =>
$row->operation,
1353 'description' =>
$row->description);
1356 return $ops ? $ops : array();
1369 $query =
'SELECT * FROM rbac_operations WHERE ops_id = '.$ilDB->quote($ops_id,
'integer');
1371 while(
$row = $ilDB->fetchObject(
$res))
1373 $ops = array(
'ops_id' =>
$row->ops_id,
1374 'operation' =>
$row->operation,
1375 'description' =>
$row->description);
1378 return $ops ? $ops : array();
1396 $a_parent = ROLE_FOLDER_ID;
1399 $query =
"SELECT ops_id,type FROM rbac_templates ".
1400 "WHERE rol_id = ".$ilDB->quote($a_rol_id,
'integer').
" ".
1401 "AND parent = ".$ilDB->quote($a_parent,
'integer');
1405 while (
$row = $ilDB->fetchObject(
$res))
1407 $ops_arr[
$row->type][] =
$row->ops_id;
1409 return (array) $ops_arr;
1423 $query =
'SELECT * FROM rbac_pa '.
1424 'WHERE ref_id = '.$ilDB->quote($a_ref_id,
'integer').
' '.
1425 'AND rol_id = '.$ilDB->quote($a_role_id,
'integer').
' ';
1430 return unserialize(
$row[
'ops_id']);
1450 if (!isset($a_rol_id) or !isset($a_type))
1452 $message = get_class($this).
"::getOperationsOfRole(): Missing Parameter!".
1453 "role_id: ".$a_rol_id.
1455 "parent_id: ".$a_parent;
1456 $ilLog->logStack(
"Missing parameter! ");
1457 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
1465 $a_parent = ROLE_FOLDER_ID;
1468 $query =
"SELECT ops_id FROM rbac_templates ".
1469 "WHERE type =".$ilDB->quote($a_type,
'text').
" ".
1470 "AND rol_id = ".$ilDB->quote($a_rol_id,
'integer').
" ".
1471 "AND parent = ".$ilDB->quote($a_parent,
'integer');
1473 while (
$row = $ilDB->fetchObject(
$res))
1475 $ops_arr[] =
$row->ops_id;
1492 $query =
"SELECT * FROM rbac_pa ".
1493 "WHERE rol_id = ".$ilDB->quote($a_role_id,
'integer').
" ".
1494 "AND ref_id = ".$ilDB->quote($a_ref_id,
'integer').
" ";
1497 while(
$row = $ilDB->fetchObject(
$res))
1499 $ops = unserialize(
$row->ops_id);
1502 return $ops ? $ops : array();
1516 if (!isset($a_typ_id))
1518 $message = get_class($this).
"::getOperationsOnType(): No type_id given!";
1519 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
1522 #$query = "SELECT * FROM rbac_ta WHERE typ_id = ".$ilDB->quote($a_typ_id,'integer');
1524 $query =
'SELECT * FROM rbac_ta ta JOIN rbac_operations o ON ta.ops_id = o.ops_id '.
1525 'WHERE typ_id = '.$ilDB->quote($a_typ_id,
'integer').
' '.
1526 'ORDER BY op_order';
1530 while(
$row = $ilDB->fetchObject(
$res))
1532 $ops_id[] =
$row->ops_id;
1535 return $ops_id ? $ops_id : array();
1550 $query =
"SELECT * FROM object_data WHERE type = 'typ' AND title = ".$ilDB->quote($a_type ,
'text').
" ";
1572 if($a_class !=
'create')
1574 $condition =
"AND class != ".$ilDB->quote(
'create',
'text');
1578 $condition =
"AND class = ".$ilDB->quote(
'create',
'text');
1581 $query =
"SELECT ro.ops_id FROM rbac_operations ro ".
1582 "JOIN rbac_ta rt ON ro.ops_id = rt.ops_id ".
1583 "JOIN object_data od ON rt.typ_id = od.obj_id ".
1584 "WHERE type = ".$ilDB->quote(
'typ',
'text').
" ".
1585 "AND title = ".$ilDB->quote($a_type,
'text').
" ".
1587 "ORDER BY op_order ";
1594 $ops[] =
$row->ops_id;
1613 #$query = 'SELECT t.parent p FROM tree t JOIN rbac_fa fa ON fa.parent = child '.
1614 # 'WHERE assign = '.$ilDB->quote('n','text').' '.
1615 # 'AND rol_id = '.$ilDB->quote($a_rol_id,'integer').' ';
1617 $query =
'SELECT parent p FROM rbac_fa '.
1618 'WHERE assign = '.$ilDB->quote(
'n',
'text').
' '.
1619 'AND rol_id = '.$ilDB->quote($a_rol_id,
'integer').
' ';
1623 $query .= (
'AND '.$ilDB->in(
'parent',(array) $a_filter,
false,
'integer'));
1630 $parent[] =
$row->p;
1646 $q =
"SELECT tree FROM tree WHERE child =".$ilDB->quote($a_node_id).
" ";
1653 $message = sprintf(
'%s::isDeleted(): Role folder with ref_id %s not found!',
1656 $this->log->write($message,$this->log->FATAL);
1699 case self::FILTER_ALL:
1704 case self::FILTER_ALL_GLOBAL:
1705 $where =
'WHERE '.$ilDB->in(
'rbac_fa.rol_id',$this->
getGlobalRoles(),
false,
'integer').
' ';
1709 case self::FILTER_ALL_LOCAL:
1710 case self::FILTER_INTERNAL:
1711 case self::FILTER_NOT_INTERNAL:
1712 $where =
'WHERE '.$ilDB->in(
'rbac_fa.rol_id',$this->
getGlobalRoles(),
true,
'integer');
1716 case self::FILTER_TEMPLATES:
1717 $where =
"WHERE object_data.type = 'rolt'";
1727 $where =
'WHERE '.$ilDB->in(
'rbac_fa.rol_id',$this->
assignedRoles($a_user_id),
false,
'integer').
' ';
1733 $query =
"SELECT * FROM object_data ".
1734 "JOIN rbac_fa ON obj_id = rol_id ".
1736 "AND rbac_fa.assign = ".$ilDB->quote($assign,
'text').
" ";
1738 if(strlen($title_filter))
1740 $query .= (
' AND '.$ilDB->like(
1743 '%'.$title_filter.
'%'
1748 while(
$row = $ilDB->fetchAssoc(
$res))
1750 $prefix = (substr(
$row[
"title"],0,3) ==
"il_") ?
true :
false;
1753 if ($a_filter == 4 and !$prefix)
1759 if ($a_filter == 5 and $prefix)
1764 $row[
"desc"] =
$row[
"description"];
1771 return $roles ? $roles : array();
1785 $q =
"SELECT obj_id FROM object_data ".
1786 "WHERE title=".$ilDB->quote($a_type ,
'text').
" AND type='typ'";
1787 $r = $ilDB->query($q);
1790 return $row->obj_id;
1807 if(!count($operations))
1812 $query =
'SELECT ops_id FROM rbac_operations '.
1813 'WHERE '.$ilDB->in(
'operation',$operations,
false,
'text');
1816 while(
$row = $ilDB->fetchObject(
$res))
1818 $ops_ids[] =
$row->ops_id;
1820 return $ops_ids ? $ops_ids : array();
1835 if (!isset($a_operation))
1837 $message =
"perm::getOperationId(): No operation given!";
1838 $ilErr->raiseError($message,$ilErr->WARNING);
1842 if (! is_array(self::$_opsCache)) {
1843 self::$_opsCache = array();
1845 $q =
"SELECT ops_id, operation FROM rbac_operations";
1846 $r = $ilDB->query($q);
1849 self::$_opsCache[
$row->operation] =
$row->ops_id;
1854 if (array_key_exists($a_operation, self::$_opsCache)) {
1855 return self::$_opsCache[$a_operation];
1870 $operations = array();
1871 foreach($a_type_arr as $type)
1873 $operations[] = (
'create_'.$type);
1876 if(!count($operations))
1881 $query =
'SELECT ops_id, operation FROM rbac_operations '.
1882 'WHERE '.$ilDB->in(
'operation',$operations,
false,
'text');
1887 while(
$row = $ilDB->fetchObject(
$res))
1889 $type_arr = explode(
'_',
$row->operation);
1890 $type = $type_arr[1];
1892 $ops_ids[$type] =
$row->ops_id;
1912 $query =
"SELECT protected FROM rbac_fa ".
1913 "WHERE rol_id = ".$ilDB->quote($a_role_id,
'integer').
" ";
1940 if (in_array(SYSTEM_ROLE_ID,$this->
assignedRoles($ilUser->getId())))
1946 $leveladmin =
false;
1948 #vd("RoleHierarchy",$a_role_hierarchy);
1949 foreach ($a_role_hierarchy as $role_id => $rolf_id)
1952 #echo "<br/>ROLF: ".$rolf_id." ROLE_ID: ".$role_id." (".$a_parent_roles[$role_id]['title'].") ";
1955 if ($leveladmin ==
true)
1957 $a_parent_roles[$role_id][
'protected'] =
false;
1961 if ($a_parent_roles[$role_id][
'protected'] ==
true)
1963 $arr_lvl_roles_user = array_intersect($this->
assignedRoles($ilUser->getId()),array_keys($a_role_hierarchy,$rolf_id));
1965 #vd("intersection",$arr_lvl_roles_user);
1967 foreach ($arr_lvl_roles_user as $lvl_role_id)
1969 #echo "<br/>level_role: ".$lvl_role_id;
1970 #echo "<br/>a_ref_id: ".$a_ref_id;
1974 $rolf = $a_parent_roles[$role_id][
'parent'];
1975 #$parent_obj = $GLOBALS['tree']->getParentId($rolf);
1976 if ($rbacsystem->checkPermission($rolf,$lvl_role_id,
'edit_permission'))
1978 #echo "<br />Permission granted";
1981 $a_parent_roles[$role_id][
'protected'] =
false;
1989 return $a_parent_roles;
2010 $query = sprintf(
'SELECT * FROM rbac_operations '.
2011 'JOIN rbac_ta ON rbac_operations.ops_id = rbac_ta.ops_id '.
2012 'JOIN object_data ON rbac_ta.typ_id = object_data.obj_id '.
2013 'WHERE object_data.title = %s '.
2014 'AND object_data.type = %s '.
2015 'ORDER BY op_order ASC',
2016 $ilDB->quote($a_type,
'text'),
2017 $ilDB->quote(
'typ',
'text'));
2021 $query =
'SELECT * FROM rbac_operations ORDER BY op_order ASC';
2024 while (
$row = $ilDB->fetchAssoc(
$res))
2027 "ops_id" =>
$row[
'ops_id'],
2028 "operation" =>
$row[
'operation'],
2029 "desc" =>
$row[
'description'],
2030 "class" =>
$row[
'class'],
2031 "order" =>
$row[
'op_order']
2047 foreach ($a_ops_arr as $ops)
2049 $arr[$ops[
'class']][] = array (
'ops_id' => $ops[
'ops_id'],
2050 'name' => $ops[
'operation']
2068 static $obj_cache = array();
2073 if(isset($obj_cache[$a_role_id]) and $obj_cache[$a_role_id])
2075 return $obj_cache[$a_role_id];
2078 $query =
'SELECT obr.obj_id FROM rbac_fa rfa '.
2079 'JOIN object_reference obr ON rfa.parent = obr.ref_id '.
2080 'WHERE assign = '.$ilDB->quote(
'y',
'text').
' '.
2081 'AND rol_id = '.$ilDB->quote($a_role_id,
'integer').
' '.
2082 'AND deleted IS NULL';
2084 #$query = "SELECT obr.obj_id FROM rbac_fa rfa ".
2085 # "JOIN tree ON rfa.parent = tree.child ".
2086 # "JOIN object_reference obr ON tree.parent = obr.ref_id ".
2087 # "WHERE tree.tree = 1 ".
2088 # "AND assign = 'y' ".
2089 # "AND rol_id = ".$ilDB->quote($a_role_id,'integer')." ";
2092 $obj_cache[$a_role_id] = 0;
2093 while(
$row = $ilDB->fetchObject(
$res))
2095 $obj_cache[$a_role_id] =
$row->obj_id;
2097 return $obj_cache[$a_role_id];
2110 $query =
'SELECT parent role_ref FROM rbac_fa '.
2111 'WHERE rol_id = '.$ilDB->quote($a_role_id,
'integer').
' '.
2112 'AND assign = '.$ilDB->quote(
'y',
'text');
2117 return $row->role_ref;
2133 if (count($rolf_list))
2135 foreach ($rolf_list as $rolf) {
2159 $role_list = array();
2163 $query =
"SELECT * FROM object_data ".
2164 "JOIN rbac_fa ON object_data.obj_id = rbac_fa.rol_id ".
2166 "AND rbac_fa.assign = 'y' " .
2167 'AND '.$ilDB->in(
'object_data.obj_id',$role_ids,
false,
'integer');
2170 while(
$row = $ilDB->fetchAssoc(
$res))
2172 $row[
"desc"] =
$row[
"description"];
2174 $role_list[] =
$row;
2190 $query =
'SELECT ta.typ_id, obj.title, ops.ops_id, ops.operation FROM rbac_ta ta '.
2191 'JOIN object_data obj ON obj.obj_id = ta.typ_id '.
2192 'JOIN rbac_operations ops ON ops.ops_id = ta.ops_id ';
2196 while(
$row = $ilDB->fetchObject(
$res))
2198 $info[$counter][
'typ_id'] =
$row->typ_id;
2199 $info[$counter][
'type'] =
$row->title;
2200 $info[$counter][
'ops_id'] =
$row->ops_id;
2201 $info[$counter][
'operation'] =
$row->operation;
2204 return $info ? $info : array();
2221 if($a_role_id == SYSTEM_ROLE_ID or $a_role_id == ANONYMOUS_ROLE_ID)
2241 return substr($title,0,3) ==
'il_' ?
true :
false;
2258 $and = (
'AND assign = '.$ilDB->quote(
'y',
'text'));
2265 $query =
'SELECT * FROM rbac_fa '.
2266 'WHERE rol_id = '.$ilDB->quote($a_role_id,
'integer').
' '.
2271 return $row->parent;
2287 $query =
"SELECT ops_id FROM rbac_pa JOIN rbac_ua ".
2288 "ON (rbac_pa.rol_id = rbac_ua.rol_id) ".
2289 "WHERE rbac_ua.usr_id = ".$ilDB->quote($a_user_id,
'integer').
" ".
2290 "AND rbac_pa.ref_id = ".$ilDB->quote($a_ref_id,
'integer').
" ";
2294 while (
$row = $ilDB->fetchObject(
$res))
2296 $ops = unserialize(
$row->ops_id);
2297 $all_ops = array_merge($all_ops, $ops);
2299 $all_ops = array_unique($all_ops);
2301 $set = $ilDB->query(
"SELECT operation FROM rbac_operations ".
2302 " WHERE ".$ilDB->in(
"ops_id", $all_ops,
false,
"integer"));
2304 while ($rec = $ilDB->fetchAssoc($set))
2306 $perms[] = $rec[
"operation"];
2320 self::$is_assigned_cache[$a_role_id][$a_user_id] = $a_value;
2331 return self::$is_assigned_cache[$a_role_id][$a_user_id];