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' ".
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');
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' ";
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');
542 if(count($ids_for_role_title) > 1)
544 return '#il_role_' . $a_role_id;
548 return '#' .
$row->title;
573 $message = get_class($this).
"::roleExists(): No title given!";
574 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
577 $clause = ($a_id) ?
" AND obj_id != ".$ilDB->quote($a_id).
" " :
"";
579 $q =
"SELECT DISTINCT(obj_id) obj_id FROM object_data ".
580 "WHERE title =".$ilDB->quote($a_title).
" ".
581 "AND type IN('role','rolt')".
607 if (!isset($a_path) or !is_array($a_path))
609 $message = get_class($this).
"::getParentRoles(): No path given or wrong datatype!";
610 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
613 $parent_roles = array();
614 $role_hierarchy = array();
619 foreach($roles as $role)
621 $id = $role[
"obj_id"];
623 $parent_roles[$id] = $role;
625 if (!array_key_exists($role[
'obj_id'],$role_hierarchy))
627 $role_hierarchy[$id] =
$ref_id;
647 if (!isset($a_endnode_id))
650 $message = get_class($this).
"::getParentRoleIds(): No node_id (ref_id) given!";
651 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
656 $pathIds = $tree->getPathId($a_endnode_id);
660 $pathIds[0] = ROLE_FOLDER_ID;
662 #return $this->getParentRoles($a_endnode_id,$a_templates,$a_keep_protected); 678 if (!isset($a_ref_id) or !isset($a_templates))
680 $message = get_class($this).
"::getRoleListByObject(): Missing parameter!".
681 "ref_id: ".$a_ref_id.
682 "tpl_flag: ".$a_templates;
683 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
686 $role_list = array();
690 $query =
"SELECT * FROM object_data ".
691 "JOIN rbac_fa ON obj_id = rol_id ".
693 "AND object_data.obj_id = rbac_fa.rol_id ".
694 "AND rbac_fa.parent = ".$ilDB->quote($a_ref_id,
'integer').
" ";
697 while (
$row = $ilDB->fetchAssoc(
$res))
720 $role_list = array();
724 $query =
"SELECT * FROM object_data ".
725 "JOIN rbac_fa ON obj_id = rol_id ".
727 "AND rbac_fa.assign = 'y' ";
729 if(strlen($title_filter))
731 $query .= (
' AND '.$ilDB->like(
739 while (
$row = $ilDB->fetchAssoc(
$res))
762 $query =
'SELECT rol_id FROM rbac_fa fa '.
763 'JOIN tree t1 ON t1.child = fa.parent '.
764 'JOIN object_data obd ON fa.rol_id = obd.obj_id ' .
765 'WHERE assign = '.$ilDB->quote(
'y',
'text').
' '.
766 'AND obd.type = '.$ilDB->quote(
'role',
'text').
' '.
774 $role_list = array();
777 $role_list[] =
$row->rol_id;
793 $query =
"SELECT fa.*, rd.* ".
794 "FROM object_data rd ".
795 "JOIN rbac_fa fa ON rd.obj_id = fa.rol_id ".
796 "WHERE fa.assign = 'y' ".
797 "AND fa.parent = ".$this->ilDB->quote($a_ref_id,
'integer').
" " 801 while(
$row = $ilDB->fetchAssoc(
$res))
803 $roles_data[] =
$row;
805 return $roles_data ? $roles_data : array();
819 if ($a_templates ===
true)
821 $where =
"WHERE ".$ilDB->in(
'object_data.type',array(
'role',
'rolt'),
false,
'text').
" ";
825 $where =
"WHERE ".$ilDB->in(
'object_data.type',array(
'role'),
false,
'text').
" ";
845 foreach ($a_role_list as $key => $val)
848 if ($val[
"type"] ==
"rolt")
850 $a_role_list[$key][
"role_type"] =
"template";
854 if ($val[
"assign"] ==
"y")
856 if ($val[
"parent"] == ROLE_FOLDER_ID)
858 $a_role_list[$key][
"role_type"] =
"global";
862 $a_role_list[$key][
"role_type"] =
"local";
867 $a_role_list[$key][
"role_type"] =
"linked";
871 if ($val[
"protected"] ==
"y")
873 $a_role_list[$key][
"protected"] =
true;
877 $a_role_list[$key][
"protected"] =
false;
895 $query =
'SELECT COUNT(DISTINCT(usr_id)) as num FROM rbac_ua '.
896 'WHERE '.$ilDB->in(
'rol_id', $a_roles,
false,
'integer').
' ';
916 $ilBench->start(
"RBAC",
"review_assignedUsers");
918 if (!isset($a_rol_id))
920 $message = get_class($this).
"::assignedUsers(): No role_id given!";
921 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
923 if (! $a_fields AND isset(self::$assigned_users_cache[$a_rol_id])) {
924 return self::$assigned_users_cache[$a_rol_id];
927 $result_arr = array();
929 if ($a_fields !== NULL and is_array($a_fields))
931 if (count($a_fields) == 0)
937 if (($usr_id_field = array_search(
"usr_id",$a_fields)) !==
false)
938 unset($a_fields[$usr_id_field]);
940 $select = implode(
",",$a_fields).
",usr_data.usr_id";
941 $select = addslashes($select);
944 $ilDB->enableResultBuffering(
false);
945 $query =
"SELECT ".$select.
" FROM usr_data ".
946 "LEFT JOIN rbac_ua ON usr_data.usr_id = rbac_ua.usr_id ".
947 "WHERE rbac_ua.rol_id =".$ilDB->quote($a_rol_id,
'integer');
949 while(
$row = $ilDB->fetchAssoc(
$res))
951 $result_arr[] =
$row;
953 $ilDB->enableResultBuffering(
true);
957 $ilDB->enableResultBuffering(
false);
958 $query =
"SELECT usr_id FROM rbac_ua WHERE rol_id= ".$ilDB->quote($a_rol_id,
'integer');
961 while(
$row = $ilDB->fetchAssoc(
$res))
963 array_push($result_arr,
$row[
"usr_id"]);
965 $ilDB->enableResultBuffering(
true);
968 $ilBench->stop(
"RBAC",
"review_assignedUsers");
971 self::$assigned_users_cache[$a_rol_id] = $result_arr;
988 if(isset(self::$is_assigned_cache[$a_role_id][$a_usr_id])) {
989 return self::$is_assigned_cache[$a_role_id][$a_usr_id];
994 $ilDB->setLimit(1,0);
995 $query =
"SELECT usr_id FROM rbac_ua WHERE ".
996 "rol_id= ".$ilDB->quote($a_role_id,
'integer').
" ".
997 "AND usr_id= ".$ilDB->quote($a_usr_id);
1000 $is_assigned =
$res->numRows() == 1;
1001 self::$is_assigned_cache[$a_role_id][$a_usr_id] = $is_assigned;
1003 return $is_assigned;
1022 $ilDB->setLimit(1,0);
1023 $query =
"SELECT usr_id FROM rbac_ua WHERE ".
1024 $ilDB->in(
'rol_id',$a_role_ids,
false,
'integer').
1025 " AND usr_id= ".$ilDB->quote($a_usr_id);
1028 return $ilDB->numRows(
$res) == 1;
1042 $role_arr = array();
1044 $query =
"SELECT rol_id FROM rbac_ua WHERE usr_id = ".$ilDB->quote($a_usr_id,
'integer');
1047 while(
$row = $ilDB->fetchObject(
$res))
1049 $role_arr[] =
$row->rol_id;
1051 return $role_arr ? $role_arr : array();
1063 $query =
"SELECT ua.rol_id FROM rbac_ua ua ".
1064 "JOIN rbac_fa fa ON ua.rol_id = fa.rol_id ".
1065 "WHERE usr_id = ".$ilDB->quote($a_usr_id,
'integer').
' '.
1066 "AND parent = ".$ilDB->quote(ROLE_FOLDER_ID).
" ".
1067 "AND assign = 'y' ";
1070 while(
$row = $ilDB->fetchObject(
$res))
1072 $role_arr[] =
$row->rol_id;
1074 return $role_arr ? $role_arr : array();
1089 $ilBench->start(
"RBAC",
"review_isAssignable");
1092 if ($a_rol_id == SYSTEM_ROLE_ID)
1094 $ilBench->stop(
"RBAC",
"review_isAssignable");
1098 if (!isset($a_rol_id) or !isset($a_ref_id))
1100 $message = get_class($this).
"::isAssignable(): Missing parameter!".
1101 " role_id: ".$a_rol_id.
" ,ref_id: ".$a_ref_id;
1102 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
1104 $query =
"SELECT * FROM rbac_fa ".
1105 "WHERE rol_id = ".$ilDB->quote($a_rol_id,
'integer').
" ".
1106 "AND parent = ".$ilDB->quote($a_ref_id,
'integer').
" ";
1110 $ilBench->stop(
"RBAC",
"review_isAssignable");
1111 return $row->assign ==
'y' ? true :
false;
1123 $query =
"SELECT * FROM rbac_fa WHERE rol_id = ".$ilDB->quote($a_role_id,
'integer').
' '.
1124 "AND assign = ".$ilDB->quote(
'y',
'text');
1126 return $res->numRows() > 1;
1144 if (!isset($a_rol_id))
1146 $message = get_class($this).
"::getFoldersAssignedToRole(): No role_id given!";
1147 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
1152 $where =
" AND assign ='y'";
1155 $query =
"SELECT DISTINCT parent FROM rbac_fa ".
1156 "WHERE rol_id = ".$ilDB->quote($a_rol_id,
'integer').
" ".$where.
" ";
1159 while(
$row = $ilDB->fetchObject(
$res))
1161 $folders[] =
$row->parent;
1163 return $folders ? $folders : array();
1177 if(!isset($a_ref_id))
1182 if($a_assignable_only === TRUE)
1184 $and =
'AND assign = '.$ilDB->quote(
'y',
'text');
1186 $query =
"SELECT rol_id FROM rbac_fa ".
1187 "WHERE parent = ".$ilDB->quote($a_ref_id,
'integer').
" ".
1192 $role_ids = array();
1193 while(
$row = $ilDB->fetchObject(
$res))
1195 $role_ids[] =
$row->rol_id;
1217 $ilBench->start(
"RBAC",
"review_getRolesOfRoleFolder");
1219 if (!isset($a_ref_id))
1221 $message = get_class($this).
"::getRolesOfRoleFolder(): No ref_id given!";
1222 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
1226 if ($a_nonassignable ===
false)
1228 $and =
" AND assign='y'";
1231 $query =
"SELECT rol_id FROM rbac_fa ".
1232 "WHERE parent = ".$ilDB->quote($a_ref_id,
'integer').
" ".
1236 while(
$row = $ilDB->fetchObject(
$res))
1238 $rol_id[] =
$row->rol_id;
1241 $ilBench->stop(
"RBAC",
"review_getRolesOfRoleFolder");
1243 return $rol_id ? $rol_id : array();
1271 $lroles[] = $role_id;
1287 $lroles[] = $role_id;
1302 $ga[] = array(
'obj_id' => $role_id,
1303 'role_type' =>
'global');
1305 return $ga ? $ga : array();
1316 include_once
'./Services/AccessControl/classes/class.ilObjRole.php';
1322 $ga[] = array(
'obj_id' => $role_id,
1323 'role_type' =>
'global');
1326 return $ga ? $ga : array();
1336 global $rbacreview,
$ilDB;
1338 $query =
'SELECT * FROM rbac_fa '.
1339 'WHERE rol_id = '.$ilDB->quote($a_role_id,
'integer').
' '.
1340 'AND parent = '.$ilDB->quote($a_parent_id,
'integer');
1342 return $res->numRows() ? true :
false;
1355 $query =
'SELECT * FROM rbac_operations ORDER BY ops_id ';
1357 while(
$row = $ilDB->fetchObject(
$res))
1359 $ops[] = array(
'ops_id' =>
$row->ops_id,
1360 'operation' =>
$row->operation,
1361 'description' =>
$row->description);
1364 return $ops ? $ops : array();
1377 $query =
'SELECT * FROM rbac_operations WHERE ops_id = '.$ilDB->quote($ops_id,
'integer');
1379 while(
$row = $ilDB->fetchObject(
$res))
1381 $ops = array(
'ops_id' =>
$row->ops_id,
1382 'operation' =>
$row->operation,
1383 'description' =>
$row->description);
1386 return $ops ? $ops : array();
1404 $a_parent = ROLE_FOLDER_ID;
1407 $query =
"SELECT ops_id,type FROM rbac_templates ".
1408 "WHERE rol_id = ".$ilDB->quote($a_rol_id,
'integer').
" ".
1409 "AND parent = ".$ilDB->quote($a_parent,
'integer');
1413 while (
$row = $ilDB->fetchObject(
$res))
1415 $ops_arr[
$row->type][] =
$row->ops_id;
1417 return (array) $ops_arr;
1431 $query =
'SELECT * FROM rbac_pa '.
1432 'WHERE ref_id = '.$ilDB->quote($a_ref_id,
'integer').
' '.
1433 'AND rol_id = '.$ilDB->quote($a_role_id,
'integer').
' ';
1438 return unserialize(
$row[
'ops_id']);
1458 if (!isset($a_rol_id) or !isset($a_type))
1460 $message = get_class($this).
"::getOperationsOfRole(): Missing Parameter!".
1461 "role_id: ".$a_rol_id.
1463 "parent_id: ".$a_parent;
1464 $ilLog->logStack(
"Missing parameter! ");
1465 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
1473 $a_parent = ROLE_FOLDER_ID;
1476 $query =
"SELECT ops_id FROM rbac_templates ".
1477 "WHERE type =".$ilDB->quote($a_type,
'text').
" ".
1478 "AND rol_id = ".$ilDB->quote($a_rol_id,
'integer').
" ".
1479 "AND parent = ".$ilDB->quote($a_parent,
'integer');
1481 while (
$row = $ilDB->fetchObject(
$res))
1483 $ops_arr[] =
$row->ops_id;
1500 $query =
"SELECT * FROM rbac_pa ".
1501 "WHERE rol_id = ".$ilDB->quote($a_role_id,
'integer').
" ".
1502 "AND ref_id = ".$ilDB->quote($a_ref_id,
'integer').
" ";
1505 while(
$row = $ilDB->fetchObject(
$res))
1507 $ops = unserialize(
$row->ops_id);
1510 return $ops ? $ops : array();
1524 if (!isset($a_typ_id))
1526 $message = get_class($this).
"::getOperationsOnType(): No type_id given!";
1527 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
1530 #$query = "SELECT * FROM rbac_ta WHERE typ_id = ".$ilDB->quote($a_typ_id,'integer'); 1532 $query =
'SELECT * FROM rbac_ta ta JOIN rbac_operations o ON ta.ops_id = o.ops_id '.
1533 'WHERE typ_id = '.$ilDB->quote($a_typ_id,
'integer').
' '.
1534 'ORDER BY op_order';
1538 while(
$row = $ilDB->fetchObject(
$res))
1540 $ops_id[] =
$row->ops_id;
1543 return $ops_id ? $ops_id : array();
1558 $query =
"SELECT * FROM object_data WHERE type = 'typ' AND title = ".$ilDB->quote($a_type ,
'text').
" ";
1580 if($a_class !=
'create')
1582 $condition =
"AND class != ".$ilDB->quote(
'create',
'text');
1586 $condition =
"AND class = ".$ilDB->quote(
'create',
'text');
1589 $query =
"SELECT ro.ops_id FROM rbac_operations ro ".
1590 "JOIN rbac_ta rt ON ro.ops_id = rt.ops_id ".
1591 "JOIN object_data od ON rt.typ_id = od.obj_id ".
1592 "WHERE type = ".$ilDB->quote(
'typ',
'text').
" ".
1593 "AND title = ".$ilDB->quote($a_type,
'text').
" ".
1595 "ORDER BY op_order ";
1602 $ops[] =
$row->ops_id;
1621 #$query = 'SELECT t.parent p FROM tree t JOIN rbac_fa fa ON fa.parent = child '. 1622 # 'WHERE assign = '.$ilDB->quote('n','text').' '. 1623 # 'AND rol_id = '.$ilDB->quote($a_rol_id,'integer').' '; 1625 $query =
'SELECT parent p FROM rbac_fa '.
1626 'WHERE assign = '.$ilDB->quote(
'n',
'text').
' '.
1627 'AND rol_id = '.$ilDB->quote($a_rol_id,
'integer').
' ';
1631 $query .= (
'AND '.$ilDB->in(
'parent',(array) $a_filter,
false,
'integer'));
1638 $parent[] =
$row->p;
1654 $q =
"SELECT tree FROM tree WHERE child =".$ilDB->quote($a_node_id).
" ";
1661 $message = sprintf(
'%s::isDeleted(): Role folder with ref_id %s not found!',
1664 $this->log->write($message,$this->log->FATAL);
1707 case self::FILTER_ALL:
1712 case self::FILTER_ALL_GLOBAL:
1713 $where =
'WHERE '.$ilDB->in(
'rbac_fa.rol_id',$this->
getGlobalRoles(),
false,
'integer').
' ';
1717 case self::FILTER_ALL_LOCAL:
1718 case self::FILTER_INTERNAL:
1719 case self::FILTER_NOT_INTERNAL:
1720 $where =
'WHERE '.$ilDB->in(
'rbac_fa.rol_id',$this->
getGlobalRoles(),
true,
'integer');
1724 case self::FILTER_TEMPLATES:
1725 $where =
"WHERE object_data.type = 'rolt'";
1735 $where =
'WHERE '.$ilDB->in(
'rbac_fa.rol_id',$this->
assignedRoles($a_user_id),
false,
'integer').
' ';
1741 $query =
"SELECT * FROM object_data ".
1742 "JOIN rbac_fa ON obj_id = rol_id ".
1744 "AND rbac_fa.assign = ".$ilDB->quote($assign,
'text').
" ";
1746 if(strlen($title_filter))
1748 $query .= (
' AND '.$ilDB->like(
1751 '%'.$title_filter.
'%' 1756 while(
$row = $ilDB->fetchAssoc(
$res))
1758 $prefix = (substr(
$row[
"title"],0,3) ==
"il_") ?
true :
false;
1761 if ($a_filter == 4 and !$prefix)
1767 if ($a_filter == 5 and $prefix)
1772 $row[
"desc"] =
$row[
"description"];
1779 return $roles ? $roles : array();
1793 $q =
"SELECT obj_id FROM object_data ".
1794 "WHERE title=".$ilDB->quote($a_type ,
'text').
" AND type='typ'";
1795 $r = $ilDB->query($q);
1798 return $row->obj_id;
1815 if(!count($operations))
1820 $query =
'SELECT ops_id FROM rbac_operations '.
1821 'WHERE '.$ilDB->in(
'operation',$operations,
false,
'text');
1824 while(
$row = $ilDB->fetchObject(
$res))
1826 $ops_ids[] =
$row->ops_id;
1828 return $ops_ids ? $ops_ids : array();
1843 if (!isset($a_operation))
1845 $message =
"perm::getOperationId(): No operation given!";
1846 $ilErr->raiseError($message,$ilErr->WARNING);
1850 if (! is_array(self::$_opsCache)) {
1851 self::$_opsCache = array();
1853 $q =
"SELECT ops_id, operation FROM rbac_operations";
1854 $r = $ilDB->query($q);
1857 self::$_opsCache[
$row->operation] =
$row->ops_id;
1862 if (array_key_exists($a_operation, self::$_opsCache)) {
1863 return self::$_opsCache[$a_operation];
1878 $operations = array();
1879 foreach($a_type_arr as $type)
1881 $operations[] = (
'create_'.$type);
1884 if(!count($operations))
1889 $query =
'SELECT ops_id, operation FROM rbac_operations '.
1890 'WHERE '.$ilDB->in(
'operation',$operations,
false,
'text');
1895 while(
$row = $ilDB->fetchObject(
$res))
1897 $type_arr = explode(
'_',
$row->operation);
1898 $type = $type_arr[1];
1900 $ops_ids[$type] =
$row->ops_id;
1920 $query =
"SELECT protected FROM rbac_fa ".
1921 "WHERE rol_id = ".$ilDB->quote($a_role_id,
'integer').
" ";
1939 $query =
'SELECT blocked from rbac_fa '.
1940 'WHERE rol_id = '. $ilDB->quote($a_role_id,
'integer').
' '.
1941 'AND parent = '.$ilDB->quote($a_ref_id,
'integer');
1945 return (
bool)
$row->blocked;
1957 global
$ilDB, $tree;
1963 $query =
'SELECT parent from rbac_fa '.
1964 'WHERE rol_id = '.$ilDB->quote($a_role_id,
'integer').
' '.
1965 'AND blocked = '.$ilDB->quote(1,
'integer');
1968 $parent_ids = array();
1971 $parent_ids[] =
$row->parent;
1974 foreach($parent_ids as $parent_id)
1976 if($tree->isGrandChild($parent_id, $a_ref_id))
2004 if (in_array(SYSTEM_ROLE_ID,$this->
assignedRoles($ilUser->getId())))
2010 $leveladmin =
false;
2012 #vd("RoleHierarchy",$a_role_hierarchy); 2013 foreach ($a_role_hierarchy as $role_id => $rolf_id)
2016 #echo "<br/>ROLF: ".$rolf_id." ROLE_ID: ".$role_id." (".$a_parent_roles[$role_id]['title'].") "; 2019 if ($leveladmin ==
true)
2021 $a_parent_roles[$role_id][
'protected'] =
false;
2025 if ($a_parent_roles[$role_id][
'protected'] ==
true)
2027 $arr_lvl_roles_user = array_intersect($this->
assignedRoles($ilUser->getId()),array_keys($a_role_hierarchy,$rolf_id));
2029 #vd("intersection",$arr_lvl_roles_user); 2031 foreach ($arr_lvl_roles_user as $lvl_role_id)
2033 #echo "<br/>level_role: ".$lvl_role_id; 2034 #echo "<br/>a_ref_id: ".$a_ref_id; 2038 $rolf = $a_parent_roles[$role_id][
'parent'];
2039 #$parent_obj = $GLOBALS['tree']->getParentId($rolf); 2040 if ($rbacsystem->checkPermission($rolf,$lvl_role_id,
'edit_permission'))
2042 #echo "<br />Permission granted"; 2045 $a_parent_roles[$role_id][
'protected'] =
false;
2053 return $a_parent_roles;
2074 $query = sprintf(
'SELECT * FROM rbac_operations '.
2075 'JOIN rbac_ta ON rbac_operations.ops_id = rbac_ta.ops_id '.
2076 'JOIN object_data ON rbac_ta.typ_id = object_data.obj_id '.
2077 'WHERE object_data.title = %s '.
2078 'AND object_data.type = %s '.
2079 'ORDER BY op_order ASC',
2080 $ilDB->quote($a_type,
'text'),
2081 $ilDB->quote(
'typ',
'text'));
2085 $query =
'SELECT * FROM rbac_operations ORDER BY op_order ASC';
2088 while (
$row = $ilDB->fetchAssoc(
$res))
2091 "ops_id" =>
$row[
'ops_id'],
2092 "operation" =>
$row[
'operation'],
2093 "desc" =>
$row[
'description'],
2094 "class" =>
$row[
'class'],
2095 "order" =>
$row[
'op_order']
2111 foreach ($a_ops_arr as $ops)
2113 $arr[$ops[
'class']][] = array (
'ops_id' => $ops[
'ops_id'],
2114 'name' => $ops[
'operation']
2132 static $obj_cache = array();
2137 if(isset($obj_cache[$a_role_id]) and $obj_cache[$a_role_id])
2139 return $obj_cache[$a_role_id];
2142 $query =
'SELECT obr.obj_id FROM rbac_fa rfa '.
2143 'JOIN object_reference obr ON rfa.parent = obr.ref_id '.
2144 'WHERE assign = '.$ilDB->quote(
'y',
'text').
' '.
2145 'AND rol_id = '.$ilDB->quote($a_role_id,
'integer').
' '.
2146 'AND deleted IS NULL';
2148 #$query = "SELECT obr.obj_id FROM rbac_fa rfa ". 2149 # "JOIN tree ON rfa.parent = tree.child ". 2150 # "JOIN object_reference obr ON tree.parent = obr.ref_id ". 2151 # "WHERE tree.tree = 1 ". 2152 # "AND assign = 'y' ". 2153 # "AND rol_id = ".$ilDB->quote($a_role_id,'integer')." "; 2156 $obj_cache[$a_role_id] = 0;
2157 while(
$row = $ilDB->fetchObject(
$res))
2159 $obj_cache[$a_role_id] =
$row->obj_id;
2161 return $obj_cache[$a_role_id];
2174 $query =
'SELECT parent p_ref FROM rbac_fa '.
2175 'WHERE rol_id = '.$ilDB->quote($a_role_id,
'integer').
' '.
2176 'AND assign = '.$ilDB->quote(
'y',
'text');
2197 if (count($rolf_list))
2199 foreach ($rolf_list as $rolf) {
2223 $role_list = array();
2227 $query =
"SELECT * FROM object_data ".
2228 "JOIN rbac_fa ON object_data.obj_id = rbac_fa.rol_id ".
2230 "AND rbac_fa.assign = 'y' " .
2231 'AND '.$ilDB->in(
'object_data.obj_id',$role_ids,
false,
'integer');
2234 while(
$row = $ilDB->fetchAssoc(
$res))
2236 $row[
"desc"] =
$row[
"description"];
2238 $role_list[] =
$row;
2254 $query =
'SELECT ta.typ_id, obj.title, ops.ops_id, ops.operation FROM rbac_ta ta '.
2255 'JOIN object_data obj ON obj.obj_id = ta.typ_id '.
2256 'JOIN rbac_operations ops ON ops.ops_id = ta.ops_id ';
2260 while(
$row = $ilDB->fetchObject(
$res))
2262 $info[$counter][
'typ_id'] =
$row->typ_id;
2264 $info[$counter][
'ops_id'] =
$row->ops_id;
2265 $info[$counter][
'operation'] =
$row->operation;
2285 if($a_role_id == SYSTEM_ROLE_ID or $a_role_id == ANONYMOUS_ROLE_ID)
2305 return substr($title,0,3) ==
'il_' ? true :
false;
2322 $and = (
'AND assign = '.$ilDB->quote(
'y',
'text'));
2329 $query =
'SELECT * FROM rbac_fa '.
2330 'WHERE rol_id = '.$ilDB->quote($a_role_id,
'integer').
' '.
2335 return $row->parent;
2351 $query =
"SELECT ops_id FROM rbac_pa JOIN rbac_ua ".
2352 "ON (rbac_pa.rol_id = rbac_ua.rol_id) ".
2353 "WHERE rbac_ua.usr_id = ".$ilDB->quote($a_user_id,
'integer').
" ".
2354 "AND rbac_pa.ref_id = ".$ilDB->quote($a_ref_id,
'integer').
" ";
2358 while (
$row = $ilDB->fetchObject(
$res))
2360 $ops = unserialize(
$row->ops_id);
2361 $all_ops = array_merge($all_ops, $ops);
2363 $all_ops = array_unique($all_ops);
2365 $set = $ilDB->query(
"SELECT operation FROM rbac_operations ".
2366 " WHERE ".$ilDB->in(
"ops_id", $all_ops,
false,
"integer"));
2368 while ($rec = $ilDB->fetchAssoc($set))
2370 $perms[] = $rec[
"operation"];
2384 self::$is_assigned_cache[$a_role_id][$a_user_id] = $a_value;
2395 return self::$is_assigned_cache[$a_role_id][$a_user_id];
2403 self::$is_assigned_cache = array();
2404 self::$assigned_users_cache = array();
clearCaches()
Clear assigned users caches.
roleExists($a_title, $a_id=0)
Checks if a role already exists.
getLocalPolicies($a_ref_id)
Get all roles with local policies.
getObjectReferenceOfRole($a_role_id)
Get reference of role.
isDeleteable($a_role_id, $a_rolf_id)
Check if role is deleteable at a specific position.
static $assigned_users_cache
isDeleted($a_node_id)
Checks if a rolefolder is set as deleted (negative tree_id) public.
const PEAR_ERROR_CALLBACK
getOperationsOfRole($a_rol_id, $a_type, $a_parent=0)
get all possible operations of a specific role The ref_id of the role folder (parent object) is neces...
static _getOperationIdsByName($operations)
get ops_id's by name.
getNumberOfAssignedUsers(Array $a_roles)
Get the number of assigned users to roles ilDB $ilDB.
query($sql, $a_handle_error=true)
Query.
getRolesByFilter($a_filter=0, $a_user_id=0, $title_filter='')
ilDB $ilDB
getRoleListByObject($a_ref_id, $a_templates=false)
Returns a list of roles in an container public.
getRolesOfRoleFolder($a_ref_id, $a_nonassignable=true)
get all roles of a role folder including linked local roles that are created due to stopped inheritan...
assignedGlobalRoles($a_usr_id)
Get assigned global roles for an user.
getAssignableRoles($a_templates=false, $a_internal_roles=false, $title_filter='')
Returns a list of all assignable roles public.
getOperationsByTypeAndClass($a_type, $a_class)
Get operations by type and class.
static _getOperationList($a_type=null)
get operation list by object type public static
static _lookupTitle($a_id)
lookup object title
getOperationAssignment()
get operation assignments
const FILTER_NOT_INTERNAL
isBlockedInUpperContext($a_role_id, $a_ref_id)
Check if role is blocked in upper context.
isGlobalRole($a_role_id)
Check if role is a global role.
__setTemplateFilter($a_templates)
get roles and templates or only roles; returns string for where clause private
__setProtectedStatus($a_parent_roles, $a_role_hierarchy, $a_ref_id)
Set protected status type $rbacsystem type $ilUser type $log.
getRoleOperationsOnObject($a_role_id, $a_ref_id)
ilDB $ilDB
assignedUsers($a_rol_id, $a_fields=NULL)
get all assigned users to a given role public
static $is_assigned_cache
getAssignableChildRoles($a_ref_id)
Get all assignable roles directly under a specific node public.
const DB_FETCHMODE_OBJECT
static lookupCreateOperationIds($a_type_arr)
Lookup operation ids.
__getParentRoles($a_path, $a_templates)
Note: This function performs faster than the new getParentRoles function, because it uses database in...
getActiveOperationsOfRole($a_ref_id, $a_role_id)
Get active operations for a role.
isProtected($a_ref_id, $a_role_id)
searchRolesByMailboxAddressList($a_address_list)
Finds all role ids that match the specified user friendly role mailbox address list.
quote($a_query, $a_type=null)
Wrapper for quote method.
isAssignable($a_rol_id, $a_ref_id)
Check if its possible to assign users public.
getGlobalRolesArray()
get only 'global' roles public
isBlockedAtPosition($a_role_id, $a_ref_id)
Check if role is blocked at position ilDB $ilDB.
getRolesOfObject($a_ref_id, $a_assignable_only=FALSE)
Get roles of object.
getAssignedCacheEntry($a_role_id, $a_user_id)
get entry of assigned_chache
getRolesForIDs($role_ids, $use_templates)
ilDB $ilDB
getOperation($ops_id)
get one operation by operation id public
setAssignedCacheEntry($a_role_id, $a_user_id, $a_value)
set entry of assigned_chache
isRoleAssignedToObject($a_role_id, $a_parent_id)
Check if role is assigned to an object.
getRoleMailboxAddress($a_role_id, $is_localize=true)
Returns the mailbox address of a role.
getGlobalRoles()
get only 'global' roles public
getTypeId($a_type)
Get type id of object ilDB $ilDB.
isRoleDeleted($a_role_id)
return if role is only attached to deleted role folders
getObjectOfRole($a_role_id)
Get object id of objects a role is assigned to.
isAssignedToAtLeastOneGivenRole($a_usr_id, $a_role_ids)
check if a specific user is assigned to at least one of the given role ids.
static _lookupType($a_id, $a_reference=false)
lookup object type
getAllOperationsOfRole($a_rol_id, $a_parent=0)
get all possible operations of a specific role The ref_id of the role folder (parent object) is neces...
getParentRoleIds($a_endnode_id, $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...
hasMultipleAssignments($a_role_id)
Temporary bugfix.
getFoldersAssignedToRole($a_rol_id, $a_assignable=false)
Returns an array of objects assigned to a role.
if(!file_exists(getcwd().'/ilias.ini.php')) if(isset( $_GET["client_id"]))
registration confirmation script for ilias
static _getOperationIdByName($a_operation)
get operation id by name of operation public static
isAssigned($a_usr_id, $a_role_id)
check if a specific user is assigned to specific role public
getGlobalAssignableRoles()
get only 'global' roles (with flag 'assign_users') public
__construct()
Constructor public.
getOperations()
get all possible operations public
getRoleFolderOfRole($a_role_id)
Get role folder of role ilDB $ilDB.
_getAssignUsersStatus($a_role_id)
getOperationsOnTypeString($a_type)
all possible operations of a type public
assignedRoles($a_usr_id)
get all assigned roles to a given user public
static _getIdsForTitle($title, $type='', $partialmatch=false)
getAssignableRolesInSubtree($ref_id)
Returns a list of assignable roles in a subtree of the repository public.
getUserPermissionsOnObject($a_user_id, $a_ref_id)
Get all user permissions on an object.
__setRoleType($a_role_list)
computes role type in role list array: global: roles in ROLE_FOLDER_ID local: assignable roles in oth...
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
static yn2tf($a_yn)
convert "y"/"n" to true/false
static _groupOperationsByClass($a_ops_arr)
isSystemGeneratedRole($a_role_id)
Check if the role is system generate role or role template.
getOperationsOnType($a_typ_id)
all possible operations of a type public
getLocalRoles($a_ref_id)
Get local roles of object.
getObjectsWithStopedInheritance($a_rol_id, $a_filter=array())
get all objects in which the inheritance of role with role_id was stopped the function returns all re...
class ilRbacReview Contains Review functions of core Rbac.