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.
'>';
501 require_once
'./Services/PEAR/lib/Mail/RFC822.php';
503 if(@$obj->parseAddressList() instanceof
PEAR_Error)
505 $q =
"SELECT title ".
507 "WHERE obj_id = ".$this->ilDB->quote($a_role_id ,
'integer');
512 return '#'.$row->title;
524 $q =
"SELECT title ".
526 "WHERE obj_id = ".$this->ilDB->quote($a_role_id ,
'integer');
531 return '#'.$row->title;
554 $message = get_class($this).
"::roleExists(): No title given!";
555 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
558 $clause = ($a_id) ?
" AND obj_id != ".$ilDB->quote($a_id).
" " :
"";
560 $q =
"SELECT DISTINCT(obj_id) obj_id FROM object_data ".
561 "WHERE title =".$ilDB->quote($a_title).
" ".
562 "AND type IN('role','rolt')".
589 if (!isset($a_path) or !is_array($a_path))
591 $message = get_class($this).
"::getParentRoles(): No path given or wrong datatype!";
592 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
595 $parent_roles = array();
596 $role_hierarchy = array();
600 $in = $ilDB->in(
't.parent',$a_path,
false,
'integer');
602 $q =
"SELECT t.child,t.depth FROM tree t ".
603 "JOIN object_reference r ON r.ref_id = t.child ".
604 "JOIN object_data o ON o.obj_id = r.obj_id ".
606 "AND o.type= ".$ilDB->quote(
'rolf',
'text').
" ".
607 "ORDER BY t.depth ASC";
613 $role_rows = array();
617 $depth = (
$row->child == ROLE_FOLDER_ID ? 0 :
$row->depth);
618 $role_rows[$depth][
'child'] =
$row->child;
620 ksort($role_rows,SORT_NUMERIC);
622 foreach($role_rows as
$row)
625 foreach ($roles as $role)
627 $id = $role[
"obj_id"];
628 $role[
"parent"] = $row[
'child'];
629 $parent_roles[$id] = $role;
631 if (!array_key_exists($role[
'obj_id'],$role_hierarchy))
633 $role_hierarchy[$id] = $row[
'child'];
637 if (!$a_keep_protected)
641 return $parent_roles;
654 global $tree,
$log,$ilDB;
656 if (!isset($a_endnode_id))
659 $message = get_class($this).
"::getParentRoleIds(): No node_id (ref_id) given!";
660 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
665 $pathIds = $tree->getPathId($a_endnode_id);
668 $pathIds[0] = SYSTEM_FOLDER_ID;
670 #return $this->getParentRoles($a_endnode_id,$a_templates,$a_keep_protected);
685 if (!isset($a_ref_id) or !isset($a_templates))
687 $message = get_class($this).
"::getRoleListByObject(): Missing parameter!".
688 "ref_id: ".$a_ref_id.
689 "tpl_flag: ".$a_templates;
690 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
693 $role_list = array();
697 $query =
"SELECT * FROM object_data ".
698 "JOIN rbac_fa ON obj_id = rol_id ".
700 "AND object_data.obj_id = rbac_fa.rol_id ".
701 "AND rbac_fa.parent = ".$ilDB->quote($a_ref_id,
'integer').
" ";
704 while (
$row = $ilDB->fetchAssoc(
$res))
726 $role_list = array();
730 $query =
"SELECT * FROM object_data ".
731 "JOIN rbac_fa ON obj_id = rol_id ".
733 "AND rbac_fa.assign = 'y' ";
735 if(strlen($title_filter))
737 $query .= (
' AND '.$ilDB->like(
745 while (
$row = $ilDB->fetchAssoc(
$res))
768 $query =
'SELECT rol_id FROM rbac_fa fa '.
769 'JOIN tree t1 ON t1.child = fa.parent '.
770 'JOIN object_data obd ON fa.rol_id = obd.obj_id ' .
771 'WHERE assign = '.$ilDB->quote(
'y',
'text').
' '.
772 'AND obd.type = '.$ilDB->quote(
'role',
'text').
' '.
773 'AND t1.parent IN ('.
780 $role_list = array();
783 $role_list[] =
$row->rol_id;
799 $query =
"SELECT fa.*, rd.* ".
800 "FROM object_data rd ".
801 "JOIN rbac_fa fa ON rd.obj_id = fa.rol_id ".
802 "JOIN tree t ON t.child = fa.parent ".
803 "WHERE fa.assign = 'y' ".
804 "AND t.parent = ".$this->ilDB->quote($a_ref_id,
'integer').
" "
807 while(
$row = $ilDB->fetchAssoc(
$res))
809 $roles_data[] =
$row;
811 return $roles_data ? $roles_data : array();
824 if ($a_templates ===
true)
826 $where =
"WHERE ".$ilDB->in(
'object_data.type',array(
'role',
'rolt'),
false,
'text').
" ";
830 $where =
"WHERE ".$ilDB->in(
'object_data.type',array(
'role'),
false,
'text').
" ";
849 foreach ($a_role_list as $key => $val)
852 if ($val[
"type"] ==
"rolt")
854 $a_role_list[$key][
"role_type"] =
"template";
858 if ($val[
"assign"] ==
"y")
860 if ($val[
"parent"] == ROLE_FOLDER_ID)
862 $a_role_list[$key][
"role_type"] =
"global";
866 $a_role_list[$key][
"role_type"] =
"local";
871 $a_role_list[$key][
"role_type"] =
"linked";
875 if ($val[
"protected"] ==
"y")
877 $a_role_list[$key][
"protected"] =
true;
881 $a_role_list[$key][
"protected"] =
false;
898 $query =
'SELECT COUNT(DISTINCT(usr_id)) as num FROM rbac_ua '.
899 'WHERE '.$ilDB->in(
'rol_id', $a_roles,
false,
'integer').
' ';
917 $ilBench->start(
"RBAC",
"review_assignedUsers");
919 if (!isset($a_rol_id))
921 $message = get_class($this).
"::assignedUsers(): No role_id given!";
922 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
925 $result_arr = array();
927 if ($a_fields !== NULL and is_array($a_fields))
929 if (count($a_fields) == 0)
935 if (($usr_id_field = array_search(
"usr_id",$a_fields)) !==
false)
936 unset($a_fields[$usr_id_field]);
938 $select = implode(
",",$a_fields).
",usr_data.usr_id";
939 $select = addslashes($select);
942 $ilDB->enableResultBuffering(
false);
943 $query =
"SELECT ".$select.
" FROM usr_data ".
944 "LEFT JOIN rbac_ua ON usr_data.usr_id = rbac_ua.usr_id ".
945 "WHERE rbac_ua.rol_id =".$ilDB->quote($a_rol_id,
'integer');
947 while(
$row = $ilDB->fetchAssoc(
$res))
949 $result_arr[] =
$row;
951 $ilDB->enableResultBuffering(
true);
955 $ilDB->enableResultBuffering(
false);
956 $query =
"SELECT usr_id FROM rbac_ua WHERE rol_id= ".$ilDB->quote($a_rol_id,
'integer');
959 while(
$row = $ilDB->fetchAssoc(
$res))
961 array_push($result_arr,
$row[
"usr_id"]);
963 $ilDB->enableResultBuffering(
true);
966 $ilBench->stop(
"RBAC",
"review_assignedUsers");
983 $ilDB->setLimit(1,0);
984 $query =
"SELECT usr_id FROM rbac_ua WHERE ".
985 "rol_id= ".$ilDB->quote($a_role_id,
'integer').
" ".
986 "AND usr_id= ".$ilDB->quote($a_usr_id);
989 return $res->numRows() == 1;
1007 $ilDB->setLimit(1,0);
1008 $query =
"SELECT usr_id FROM rbac_ua WHERE ".
1009 $ilDB->in(
'rol_id',$a_role_ids,
false,
'integer').
1010 " AND usr_id= ".$ilDB->quote($a_usr_id);
1013 return $ilDB->numRows(
$res) == 1;
1026 $role_arr = array();
1028 $query =
"SELECT rol_id FROM rbac_ua WHERE usr_id = ".$ilDB->quote($a_usr_id,
'integer');
1031 while(
$row = $ilDB->fetchObject(
$res))
1033 $role_arr[] =
$row->rol_id;
1035 return $role_arr ? $role_arr : array();
1046 $query =
"SELECT ua.rol_id FROM rbac_ua ua ".
1047 "JOIN rbac_fa fa ON ua.rol_id = fa.rol_id ".
1048 "WHERE usr_id = ".$ilDB->quote($a_usr_id,
'integer').
' '.
1049 "AND parent = ".$ilDB->quote(ROLE_FOLDER_ID).
" ".
1050 "AND assign = 'y' ";
1053 while(
$row = $ilDB->fetchObject(
$res))
1055 $role_arr[] =
$row->rol_id;
1057 return $role_arr ? $role_arr : array();
1071 $ilBench->start(
"RBAC",
"review_isAssignable");
1074 if ($a_rol_id == SYSTEM_ROLE_ID)
1076 $ilBench->stop(
"RBAC",
"review_isAssignable");
1080 if (!isset($a_rol_id) or !isset($a_ref_id))
1082 $message = get_class($this).
"::isAssignable(): Missing parameter!".
1083 " role_id: ".$a_rol_id.
" ,ref_id: ".$a_ref_id;
1084 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
1086 $query =
"SELECT * FROM rbac_fa ".
1087 "WHERE rol_id = ".$ilDB->quote($a_rol_id,
'integer').
" ".
1088 "AND parent = ".$ilDB->quote($a_ref_id,
'integer').
" ";
1092 $ilBench->stop(
"RBAC",
"review_isAssignable");
1093 return $row->assign ==
'y' ?
true :
false;
1103 $query =
"SELECT * FROM rbac_fa WHERE rol_id = ".$ilDB->quote($a_role_id,
'integer').
' '.
1104 "AND assign = ".$ilDB->quote(
'y',
'text');
1106 return $res->numRows() > 1;
1123 if (!isset($a_rol_id))
1125 $message = get_class($this).
"::getFoldersAssignedToRole(): No role_id given!";
1126 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
1131 $where =
" AND assign ='y'";
1134 $query =
"SELECT DISTINCT parent FROM rbac_fa ".
1135 "WHERE rol_id = ".$ilDB->quote($a_rol_id,
'integer').
" ".$where.
" ";
1138 while(
$row = $ilDB->fetchObject(
$res))
1140 $folders[] =
$row->parent;
1142 return $folders ? $folders : array();
1157 $ilBench->start(
"RBAC",
"review_getRolesOfRoleFolder");
1159 if (!isset($a_ref_id))
1161 $message = get_class($this).
"::getRolesOfRoleFolder(): No ref_id given!";
1162 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
1166 if ($a_nonassignable ===
false)
1168 $and =
" AND assign='y'";
1171 $query =
"SELECT rol_id FROM rbac_fa ".
1172 "WHERE parent = ".$ilDB->quote($a_ref_id,
'integer').
" ".
1176 while(
$row = $ilDB->fetchObject(
$res))
1178 $rol_id[] =
$row->rol_id;
1181 $ilBench->stop(
"RBAC",
"review_getRolesOfRoleFolder");
1183 return $rol_id ? $rol_id : array();
1215 $lroles[] = $role_id;
1230 $ga[] = array(
'obj_id' => $role_id,
1231 'role_type' =>
'global');
1233 return $ga ? $ga : array();
1243 include_once
'./Services/AccessControl/classes/class.ilObjRole.php';
1249 $ga[] = array(
'obj_id' => $role_id,
1250 'role_type' =>
'global');
1253 return $ga ? $ga : array();
1265 $query =
"SELECT DISTINCT parent FROM rbac_fa";
1269 while(
$row = $ilDB->fetchObject(
$res))
1271 $parent[] =
$row->parent;
1286 $ilBench->start(
"RBAC",
"review_getRoleFolderOfObject");
1288 if (!isset($a_ref_id))
1291 $message = get_class($this).
"::getRoleFolderOfObject(): No ref_id given!";
1292 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
1294 $childs = $tree->getChildsByType($a_ref_id,
"rolf");
1296 $ilBench->stop(
"RBAC",
"review_getRoleFolderOfObject");
1298 return $childs[0] ? $childs[0] : array();
1310 return $rolf[
'ref_id'];
1318 global $rbacreview, $ilDB;
1320 $query =
'SELECT * FROM rbac_fa '.
1321 'WHERE rol_id = '.$ilDB->quote($a_role_id,
'integer').
' '.
1322 'AND parent = '.$ilDB->quote($a_parent_id,
'integer');
1324 return $res->numRows() ?
true :
false;
1336 $query =
'SELECT * FROM rbac_operations ORDER BY ops_id ';
1338 while(
$row = $ilDB->fetchObject(
$res))
1340 $ops[] = array(
'ops_id' =>
$row->ops_id,
1341 'operation' =>
$row->operation,
1342 'description' =>
$row->description);
1345 return $ops ? $ops : array();
1357 $query =
'SELECT * FROM rbac_operations WHERE ops_id = '.$ilDB->quote($ops_id,
'integer');
1359 while(
$row = $ilDB->fetchObject(
$res))
1361 $ops = array(
'ops_id' =>
$row->ops_id,
1362 'operation' =>
$row->operation,
1363 'description' =>
$row->description);
1366 return $ops ? $ops : array();
1383 $a_parent = ROLE_FOLDER_ID;
1386 $query =
"SELECT ops_id,type FROM rbac_templates ".
1387 "WHERE rol_id = ".$ilDB->quote($a_rol_id,
'integer').
" ".
1388 "AND parent = ".$ilDB->quote($a_parent,
'integer');
1391 while (
$row = $ilDB->fetchObject(
$res))
1393 $ops_arr[
$row->type][] =
$row->ops_id;
1395 return (array) $ops_arr;
1408 $query =
'SELECT * FROM rbac_pa '.
1409 'WHERE ref_id = '.$ilDB->quote($a_ref_id,
'integer').
' '.
1410 'AND rol_id = '.$ilDB->quote($a_role_id,
'integer').
' ';
1415 return unserialize(
$row[
'ops_id']);
1434 if (!isset($a_rol_id) or !isset($a_type))
1436 $message = get_class($this).
"::getOperationsOfRole(): Missing Parameter!".
1437 "role_id: ".$a_rol_id.
1439 "parent_id: ".$a_parent;
1440 $ilLog->logStack(
"Missing parameter! ");
1441 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
1449 $a_parent = ROLE_FOLDER_ID;
1452 $query =
"SELECT ops_id FROM rbac_templates ".
1453 "WHERE type =".$ilDB->quote($a_type,
'text').
" ".
1454 "AND rol_id = ".$ilDB->quote($a_rol_id,
'integer').
" ".
1455 "AND parent = ".$ilDB->quote($a_parent,
'integer');
1457 while (
$row = $ilDB->fetchObject(
$res))
1459 $ops_arr[] =
$row->ops_id;
1469 $query =
"SELECT * FROM rbac_pa ".
1470 "WHERE rol_id = ".$ilDB->quote($a_role_id,
'integer').
" ".
1471 "AND ref_id = ".$ilDB->quote($a_ref_id,
'integer').
" ";
1474 while(
$row = $ilDB->fetchObject(
$res))
1476 $ops = unserialize(
$row->ops_id);
1479 return $ops ? $ops : array();
1492 if (!isset($a_typ_id))
1494 $message = get_class($this).
"::getOperationsOnType(): No type_id given!";
1495 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
1498 #$query = "SELECT * FROM rbac_ta WHERE typ_id = ".$ilDB->quote($a_typ_id,'integer');
1500 $query =
'SELECT * FROM rbac_ta ta JOIN rbac_operations o ON ta.ops_id = o.ops_id '.
1501 'WHERE typ_id = '.$ilDB->quote($a_typ_id,
'integer').
' '.
1502 'ORDER BY op_order';
1506 while(
$row = $ilDB->fetchObject(
$res))
1508 $ops_id[] =
$row->ops_id;
1511 return $ops_id ? $ops_id : array();
1524 $query =
"SELECT * FROM object_data WHERE type = 'typ' AND title = ".$ilDB->quote($a_type ,
'text').
" ";
1545 if($a_class !=
'create')
1547 $condition =
"AND class != ".$ilDB->quote(
'create',
'text');
1551 $condition =
"AND class = ".$ilDB->quote(
'create',
'text');
1554 $query =
"SELECT ro.ops_id FROM rbac_operations ro ".
1555 "JOIN rbac_ta rt ON ro.ops_id = rt.ops_id ".
1556 "JOIN object_data od ON rt.typ_id = od.obj_id ".
1557 "WHERE type = ".$ilDB->quote(
'typ',
'text').
" ".
1558 "AND title = ".$ilDB->quote($a_type,
'text').
" ".
1560 "ORDER BY op_order ";
1567 $ops[] =
$row->ops_id;
1585 $query =
'SELECT t.parent p FROM tree t JOIN rbac_fa fa ON fa.parent = child '.
1586 'WHERE assign = '.$ilDB->quote(
'n',
'text').
' '.
1587 'AND rol_id = '.$ilDB->quote($a_rol_id,
'integer').
' ';
1591 $query .= (
'AND '.$ilDB->in(
't.parent',(array) $a_filter,
false,
'integer'));
1598 $parent[] =
$row->p;
1613 $q =
"SELECT tree FROM tree WHERE child =".$ilDB->quote($a_node_id).
" ";
1620 $message = sprintf(
'%s::isDeleted(): Role folder with ref_id %s not found!',
1623 $this->log->write($message,$this->log->FATAL);
1656 case self::FILTER_ALL:
1661 case self::FILTER_ALL_GLOBAL:
1662 $where =
'WHERE '.$ilDB->in(
'rbac_fa.rol_id',$this->
getGlobalRoles(),
false,
'integer').
' ';
1666 case self::FILTER_ALL_LOCAL:
1667 case self::FILTER_INTERNAL:
1668 case self::FILTER_NOT_INTERNAL:
1669 $where =
'WHERE '.$ilDB->in(
'rbac_fa.rol_id',$this->
getGlobalRoles(),
true,
'integer');
1673 case self::FILTER_TEMPLATES:
1674 $where =
"WHERE object_data.type = 'rolt'";
1684 $where =
'WHERE '.$ilDB->in(
'rbac_fa.rol_id',$this->
assignedRoles($a_user_id),
false,
'integer').
' ';
1690 $query =
"SELECT * FROM object_data ".
1691 "JOIN rbac_fa ON obj_id = rol_id ".
1693 "AND rbac_fa.assign = ".$ilDB->quote($assign,
'text').
" ";
1695 if(strlen($title_filter))
1697 $query .= (
' AND '.$ilDB->like(
1700 '%'.$title_filter.
'%'
1705 while(
$row = $ilDB->fetchAssoc(
$res))
1707 $prefix = (substr(
$row[
"title"],0,3) ==
"il_") ?
true :
false;
1710 if ($a_filter == 4 and !$prefix)
1716 if ($a_filter == 5 and $prefix)
1721 $row[
"desc"] =
$row[
"description"];
1728 return $roles ? $roles : array();
1736 $q =
"SELECT obj_id FROM object_data ".
1737 "WHERE title=".$ilDB->quote($a_type ,
'text').
" AND type='typ'";
1738 $r = $ilDB->query($q);
1741 return $row->obj_id;
1757 if(!count($operations))
1762 $query =
'SELECT ops_id FROM rbac_operations '.
1763 'WHERE '.$ilDB->in(
'operation',$operations,
false,
'text');
1766 while(
$row = $ilDB->fetchObject(
$res))
1768 $ops_ids[] =
$row->ops_id;
1770 return $ops_ids ? $ops_ids : array();
1784 if (!isset($a_operation))
1786 $message =
"perm::getOperationId(): No operation given!";
1787 $ilErr->raiseError($message,$ilErr->WARNING);
1791 if (! is_array(self::$_opsCache)) {
1792 self::$_opsCache = array();
1794 $q =
"SELECT ops_id, operation FROM rbac_operations";
1795 $r = $ilDB->query($q);
1798 self::$_opsCache[
$row->operation] =
$row->ops_id;
1803 if (array_key_exists($a_operation, self::$_opsCache)) {
1804 return self::$_opsCache[$a_operation];
1818 $operations = array();
1819 foreach($a_type_arr as $type)
1821 $operations[] = (
'create_'.$type);
1824 if(!count($operations))
1829 $query =
'SELECT ops_id, operation FROM rbac_operations '.
1830 'WHERE '.$ilDB->in(
'operation',$operations,
false,
'text');
1835 while(
$row = $ilDB->fetchObject(
$res))
1837 $type_arr = explode(
'_',
$row->operation);
1838 $type = $type_arr[1];
1840 $ops_ids[$type] =
$row->ops_id;
1858 if (!isset($a_ref_id))
1860 $message = get_class($this).
"::getLinkedRolesOfRoleFolder(): No ref_id given!";
1861 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
1864 $and =
" AND assign='n'";
1866 $query =
"SELECT rol_id FROM rbac_fa ".
1867 "WHERE parent = ".$ilDB->quote($a_ref_id,
'integer').
" ".
1870 while(
$row = $ilDB->fetchObject(
$res))
1872 $rol_id[] =
$row->rol_id;
1875 return $rol_id ? $rol_id : array();
1883 $query =
"SELECT protected FROM rbac_fa ".
1884 "WHERE rol_id = ".$ilDB->quote($a_role_id,
'integer').
" ".
1885 "AND parent = ".$ilDB->quote($a_ref_id,
'integer').
" ";
1900 if (in_array(SYSTEM_ROLE_ID,$this->
assignedRoles($ilUser->getId())))
1906 $leveladmin =
false;
1908 #vd("RoleHierarchy",$a_role_hierarchy);
1909 foreach ($a_role_hierarchy as $role_id => $rolf_id)
1912 #echo "<br/>ROLF: ".$rolf_id." ROLE_ID: ".$role_id." (".$a_parent_roles[$role_id]['title'].") ";
1915 if ($leveladmin ==
true)
1917 $a_parent_roles[$role_id][
'protected'] =
false;
1921 if ($a_parent_roles[$role_id][
'protected'] ==
true)
1923 $arr_lvl_roles_user = array_intersect($this->
assignedRoles($ilUser->getId()),array_keys($a_role_hierarchy,$rolf_id));
1925 #vd("intersection",$arr_lvl_roles_user);
1927 foreach ($arr_lvl_roles_user as $lvl_role_id)
1929 #echo "<br/>level_role: ".$lvl_role_id;
1930 #echo "<br/>a_ref_id: ".$a_ref_id;
1934 $rolf = $a_parent_roles[$role_id][
'parent'];
1935 $parent_obj =
$GLOBALS[
'tree']->getParentId($rolf);
1936 if ($rbacsystem->checkPermission($parent_obj,$lvl_role_id,
'edit_permission'))
1938 #echo "<br />Permission granted";
1941 $a_parent_roles[$role_id][
'protected'] =
false;
1950 return $a_parent_roles;
1971 $query = sprintf(
'SELECT * FROM rbac_operations '.
1972 'JOIN rbac_ta ON rbac_operations.ops_id = rbac_ta.ops_id '.
1973 'JOIN object_data ON rbac_ta.typ_id = object_data.obj_id '.
1974 'WHERE object_data.title = %s '.
1975 'AND object_data.type = %s '.
1976 'ORDER BY op_order ASC',
1977 $ilDB->quote($a_type,
'text'),
1978 $ilDB->quote(
'typ',
'text'));
1982 $query =
'SELECT * FROM rbac_operations ORDER BY op_order ASC';
1985 while (
$row = $ilDB->fetchAssoc(
$res))
1988 "ops_id" =>
$row[
'ops_id'],
1989 "operation" =>
$row[
'operation'],
1990 "desc" =>
$row[
'description'],
1991 "class" =>
$row[
'class'],
1992 "order" =>
$row[
'op_order']
2002 foreach ($a_ops_arr as $ops)
2004 $arr[$ops[
'class']][] = array (
'ops_id' => $ops[
'ops_id'],
2005 'name' => $ops[
'operation']
2021 static $obj_cache = array();
2026 if(isset($obj_cache[$a_role_id]) and $obj_cache[$a_role_id])
2028 return $obj_cache[$a_role_id];
2031 $query =
"SELECT obr.obj_id FROM rbac_fa rfa ".
2032 "JOIN tree ON rfa.parent = tree.child ".
2033 "JOIN object_reference obr ON tree.parent = obr.ref_id ".
2034 "WHERE tree.tree = 1 ".
2035 "AND assign = 'y' ".
2036 "AND rol_id = ".$ilDB->quote($a_role_id,
'integer').
" ";
2039 $obj_cache[$a_role_id] = 0;
2040 while(
$row = $ilDB->fetchObject(
$res))
2042 $obj_cache[$a_role_id] =
$row->obj_id;
2044 return $obj_cache[$a_role_id];
2056 $query =
"SELECT tree.parent ref FROM rbac_fa fa ".
2057 "JOIN tree ON fa.parent = tree.child ".
2058 "WHERE tree.tree = 1 ".
2059 "AND assign = ".$ilDB->quote(
'y',
'text').
' '.
2060 "AND rol_id = ".$ilDB->quote($a_role_id,
'integer');
2079 if (count($rolf_list))
2081 foreach ($rolf_list as $rolf) {
2098 $role_list = array();
2102 $query =
"SELECT * FROM object_data ".
2103 "JOIN rbac_fa ON object_data.obj_id = rbac_fa.rol_id ".
2105 "AND rbac_fa.assign = 'y' " .
2106 'AND '.$ilDB->in(
'object_data.obj_id',$role_ids,
false,
'integer');
2109 while(
$row = $ilDB->fetchAssoc(
$res))
2111 $row[
"desc"] =
$row[
"description"];
2113 $role_list[] =
$row;
2128 $query =
'SELECT ta.typ_id, obj.title, ops.ops_id, ops.operation FROM rbac_ta ta '.
2129 'JOIN object_data obj ON obj.obj_id = ta.typ_id '.
2130 'JOIN rbac_operations ops ON ops.ops_id = ta.ops_id ';
2134 while(
$row = $ilDB->fetchObject(
$res))
2136 $info[$counter][
'typ_id'] =
$row->typ_id;
2137 $info[$counter][
'type'] =
$row->title;
2138 $info[$counter][
'ops_id'] =
$row->ops_id;
2139 $info[$counter][
'operation'] =
$row->operation;
2142 return $info ? $info : array();
2158 $query =
'SELECT DISTINCT(parent) parent FROM rbac_fa '.
2159 'WHERE '.$ilDB->in(
'parent',$a_rolf_candidates,
false,
'integer');
2161 while(
$row = $ilDB->fetchObject(
$res))
2163 $non_empty[] =
$row->parent;
2165 return $non_empty ? $non_empty : array();
2180 if($a_role_id == SYSTEM_ROLE_ID or $a_role_id == ANONYMOUS_ROLE_ID)
2199 return substr($title,0,3) ==
'il_' ?
true :
false;
2215 $and = (
'AND assign = '.$ilDB->quote(
'y',
'text'));
2222 $query =
'SELECT * FROM rbac_fa '.
2223 'WHERE rol_id = '.$ilDB->quote($a_role_id,
'integer').
' '.
2228 return $row->parent;
2243 $query =
"SELECT ops_id FROM rbac_pa JOIN rbac_ua ".
2244 "ON (rbac_pa.rol_id = rbac_ua.rol_id) ".
2245 "WHERE rbac_ua.usr_id = ".$ilDB->quote($a_user_id,
'integer').
" ".
2246 "AND rbac_pa.ref_id = ".$ilDB->quote($a_ref_id,
'integer').
" ";
2250 while (
$row = $ilDB->fetchObject(
$res))
2252 $ops = unserialize(
$row->ops_id);
2253 $all_ops = array_merge($all_ops, $ops);
2255 $all_ops = array_unique($all_ops);
2257 $set = $ilDB->query(
"SELECT operation FROM rbac_operations ".
2258 " WHERE ".$ilDB->in(
"ops_id", $all_ops,
false,
"integer"));
2260 while ($rec = $ilDB->fetchAssoc($set))
2262 $perms[] = $rec[
"operation"];