46 (isset($ilDB)) ? $this->
ilDB =& $ilDB : $this->
ilDB =& $ilias->db;
111 include_once
"Services/Mail/classes/class.ilMail.php";
114 require_once
'Mail/RFC822.php';
116 $parsedList = $parser->parseAddressList($a_address_list,
"ilias",
false,
true);
118 foreach ($parsedList as $address)
120 $local_part = $address->mailbox;
121 if (strpos($local_part,
'#') !== 0 &&
122 !($local_part{0} ==
'"' && $local_part{1} ==
"#"))
129 $local_part = substr($local_part, 1);
133 if( $local_part{0} ==
'#' && $local_part{strlen($local_part) - 1} ==
'"' )
135 $local_part = substr($local_part, 1);
136 $local_part = substr($local_part, 0, strlen($local_part) - 1);
139 if (substr($local_part,0,8) ==
'il_role_')
141 $role_id = substr($local_part,8);
142 $query =
"SELECT t.tree ".
144 "JOIN tree t ON t.child = fa.parent ".
145 "WHERE fa.rol_id = ".$this->ilDB->quote($role_id,
'integer').
" ".
146 "AND fa.assign = 'y' ".
148 $r = $ilDB->query(
$query);
149 if ($r->numRows() > 0)
151 $role_ids[] = $role_id;
157 $domain = $address->host;
158 if (strpos($domain,
'[') == 0 && strrpos($domain,
']'))
160 $domain = substr($domain,1,strlen($domain) - 2);
162 if (strlen($local_part) == 0)
164 $local_part = $domain;
165 $address->host =
'ilias';
169 if (strtolower($address->host) ==
'ilias')
172 $query =
"SELECT dat.obj_id ".
173 "FROM object_data dat ".
174 "JOIN rbac_fa fa ON fa.rol_id = dat.obj_id ".
175 "JOIN tree t ON t.child = fa.parent ".
176 "WHERE dat.title =".$this->ilDB->quote($local_part,
'text').
" ".
177 "AND dat.type = 'role' ".
178 "AND fa.assign = 'y' ".
184 $query =
"SELECT rdat.obj_id ".
185 "FROM object_data odat ".
186 "JOIN object_reference oref ON oref.obj_id = odat.obj_id ".
187 "JOIN tree otree ON otree.child = oref.ref_id ".
188 "JOIN tree rtree ON rtree.parent = otree.child ".
189 "JOIN rbac_fa rfa ON rfa.parent = rtree.child ".
190 "JOIN object_data rdat ON rdat.obj_id = rfa.rol_id ".
191 "WHERE odat.title = ".$this->ilDB->quote($domain,
'text').
" ".
192 "AND otree.tree = 1 AND rtree.tree = 1 ".
193 "AND rfa.assign = 'y' ".
194 "AND rdat.title LIKE ".
195 $this->
ilDB->
quote(
'%'.preg_replace(
'/([_%])/',
'\\\\$1',$local_part).
'%',
'text');
197 $r = $ilDB->query(
$query);
202 $role_ids[] =
$row->obj_id;
208 if ($count == 0 && strtolower($address->host) ==
'ilias')
210 $q =
"SELECT dat.obj_id ".
211 "FROM object_data dat ".
212 "JOIN object_reference ref ON ref.obj_id = dat.obj_id ".
213 "JOIN tree t ON t.child = ref.ref_id ".
214 "WHERE dat.title = ".$this->ilDB->quote($domain ,
'text').
" ".
215 "AND dat.type = 'role' ".
221 $role_ids[] =
$row->obj_id;
232 $titles = explode(
',', $a_address_list);
235 foreach ($titles as
$title)
237 if (strlen($inList) > 0)
241 $title = trim($title);
242 if (strpos($title,
'#') == 0)
244 $titleList .= $this->
ilDB->
quote(substr($title, 1));
247 if (strlen($titleList) > 0)
249 $q =
"SELECT obj_id ".
251 "WHERE title IN (".$titleList.
") ".
256 $role_ids[] =
$row->obj_id;
331 include_once
"Services/Mail/classes/class.ilMail.php";
335 $query =
"SELECT rdat.title role_title,odat.title object_title, ".
336 " oref.ref_id object_ref ".
337 "FROM object_data rdat ".
338 "JOIN rbac_fa fa ON fa.rol_id = rdat.obj_id ".
339 "JOIN tree rtree ON rtree.child = fa.parent ".
340 "JOIN object_reference oref ON oref.ref_id = rtree.parent ".
341 "JOIN object_data odat ON odat.obj_id = oref.obj_id ".
342 "WHERE rdat.obj_id = ".$this->ilDB->quote($a_role_id,
'integer').
" ".
343 "AND fa.assign = 'y' ";
344 $r = $ilDB->query(
$query);
345 if (!
$row = $ilDB->fetchObject($r))
350 $object_title =
$row->object_title;
351 $object_ref =
$row->object_ref;
352 $role_title =
$row->role_title;
358 $domain = $object_title;
359 $local_part = $role_title;
363 $q =
"SELECT COUNT(DISTINCT dat.obj_id) count ".
364 "FROM object_data dat ".
365 "JOIN object_reference ref ON ref.obj_id = dat.obj_id ".
366 "JOIN tree ON tree.child = ref.ref_id ".
367 "WHERE title = ".$this->ilDB->quote($object_title,
'text').
" ".
368 "AND tree.tree = 1 ";
382 if ($domain != null && preg_match(
'/[\[\]\\]|[\x00-\x1f]|[\x28-\x29]|[;]/',$domain))
389 if ($domain != null &&
390 (preg_match(
'/[()<>@,;:\\".\[\]]/',$domain) ||
391 preg_match(
'/[^\x21-\x8f]/',$domain))
394 $domain =
'['.$domain.
']';
400 if (strpos($role_title,
'il_') === 0 && $domain != null)
402 $unambiguous_role_title = $role_title;
404 $pos = strpos($role_title,
'_', 3) + 1;
405 $local_part = substr(
408 strrpos($role_title,
'_') - $pos
413 $unambiguous_role_title =
'il_role_'.$a_role_id;
422 $q =
"SELECT COUNT(DISTINCT dat.obj_id) count ".
423 "FROM object_data dat ".
424 "JOIN object_reference ref ON ref.obj_id = dat.obj_id ".
425 "JOIN tree ON tree.child = ref.ref_id ".
426 "WHERE title = ".$this->ilDB->quote($local_part,
'text').
" ".
427 "AND tree.tree = 1 ";
431 $q =
"SELECT COUNT(rd.obj_id) count ".
432 "FROM object_data rd ".
433 "JOIN rbac_fa fa ON rd.obj_id = fa.rol_id ".
434 "JOIN tree t ON t.child = fa.parent ".
435 "WHERE fa.assign = 'y' ".
436 "AND t.parent = ".$this->ilDB->quote($object_ref,
'integer').
" ".
437 "AND rd.title LIKE ".$this->ilDB->quote(
438 '%'.preg_replace(
'/([_%])/',
'\\\\$1', $local_part).
'%',
'text').
" ";
448 $local_part = $unambiguous_role_title;
454 if (preg_match(
'/[\\"\x00-\x1f]/',$local_part))
458 $local_part = $unambiguous_role_title;
463 $local_part =
'#'.$local_part;
466 if (preg_match(
'/[()<>@,;:.\[\]\x20]/',$local_part))
468 $local_part =
'"'.$local_part.
'"';
471 $mailbox = ($domain == null) ?
473 $local_part.
'@'.$domain;
477 if (substr($role_title,0,3) ==
'il_')
479 $phrase = $lng->txt(substr($role_title, 0, strrpos($role_title,
'_')));
483 $phrase = $role_title;
489 $phrase = preg_replace(
'/\s\s+/',
' ', $phrase);
490 $phrase = preg_replace(
'/[()<>@,;:\\".\[\]]/',
'', $phrase);
492 $mailbox = $phrase.
' <'.$mailbox.
'>';
499 $q =
"SELECT title ".
501 "WHERE obj_id = ".$this->ilDB->quote($a_role_id ,
'integer');
506 return '#'.$row->title;
529 $message = get_class($this).
"::roleExists(): No title given!";
530 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
533 $clause = ($a_id) ?
" AND obj_id != ".$ilDB->quote($a_id).
" " :
"";
535 $q =
"SELECT DISTINCT(obj_id) obj_id FROM object_data ".
536 "WHERE title =".$ilDB->quote($a_title).
" ".
537 "AND type IN('role','rolt')".
564 if (!isset($a_path) or !is_array($a_path))
566 $message = get_class($this).
"::getParentRoles(): No path given or wrong datatype!";
567 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
570 $parent_roles = array();
571 $role_hierarchy = array();
575 $in = $ilDB->in(
't.parent',$a_path,
false,
'integer');
577 $q =
"SELECT t.child,t.depth FROM tree t ".
578 "JOIN object_reference r ON r.ref_id = t.child ".
579 "JOIN object_data o ON o.obj_id = r.obj_id ".
581 "AND o.type= ".$ilDB->quote(
'rolf',
'text').
" ".
582 "ORDER BY t.depth ASC";
588 $role_rows = array();
592 $depth = (
$row->child == ROLE_FOLDER_ID ? 0 :
$row->depth);
593 $role_rows[$depth][
'child'] =
$row->child;
595 ksort($role_rows,SORT_NUMERIC);
597 foreach($role_rows as
$row)
600 foreach ($roles as $role)
602 $id = $role[
"obj_id"];
603 $role[
"parent"] = $row[
'child'];
604 $parent_roles[$id] = $role;
606 if (!array_key_exists($role[
'obj_id'],$role_hierarchy))
608 $role_hierarchy[$id] = $row[
'child'];
612 if (!$a_keep_protected)
616 return $parent_roles;
631 if (!isset($a_endnode_id))
634 $message = get_class($this).
"::getParentRoleIds(): No node_id (ref_id) given!";
635 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
640 $pathIds = $tree->getPathId($a_endnode_id);
643 $pathIds[0] = SYSTEM_FOLDER_ID;
645 #return $this->getParentRoles($a_endnode_id,$a_templates,$a_keep_protected);
660 if (!isset($a_ref_id) or !isset($a_templates))
662 $message = get_class($this).
"::getRoleListByObject(): Missing parameter!".
663 "ref_id: ".$a_ref_id.
664 "tpl_flag: ".$a_templates;
665 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
668 $role_list = array();
672 $query =
"SELECT * FROM object_data ".
673 "JOIN rbac_fa ON obj_id = rol_id ".
675 "AND object_data.obj_id = rbac_fa.rol_id ".
676 "AND rbac_fa.parent = ".$ilDB->quote($a_ref_id,
'integer').
" ";
679 while (
$row = $ilDB->fetchAssoc(
$res))
701 $role_list = array();
705 $query =
"SELECT * FROM object_data ".
706 "JOIN rbac_fa ON obj_id = rol_id ".
708 "AND rbac_fa.assign = 'y' ";
710 if(strlen($title_filter))
712 $query .= (
' AND '.$ilDB->like(
720 while (
$row = $ilDB->fetchAssoc(
$res))
742 $role_list = array();
745 $query =
"SELECT fa.*, dat.* ".
747 "JOIN tree node ON node.tree = root.tree ".
748 "AND node.lft > root.lft AND node.rgt < root.rgt ".
749 "JOIN object_reference ref ON ref.ref_id = node.child ".
750 "JOIN rbac_fa fa ON fa.parent = ref.ref_id ".
751 "JOIN object_data dat ON dat.obj_id = fa.rol_id ".
752 "WHERE root.child = ".$this->ilDB->quote(
$ref_id,
'integer').
" ".
753 "AND root.tree = 1 ".
754 "AND fa.assign = 'y' ".
755 "ORDER BY dat.title";
758 while(
$row = $ilDB->fetchAssoc(
$res))
778 $query =
"SELECT fa.*, rd.* ".
779 "FROM object_data rd ".
780 "JOIN rbac_fa fa ON rd.obj_id = fa.rol_id ".
781 "JOIN tree t ON t.child = fa.parent ".
782 "WHERE fa.assign = 'y' ".
783 "AND t.parent = ".$this->ilDB->quote($a_ref_id,
'integer').
" "
786 while(
$row = $ilDB->fetchAssoc(
$res))
788 $roles_data[] =
$row;
790 return $roles_data ? $roles_data : array();
803 if ($a_templates ===
true)
805 $where =
"WHERE ".$ilDB->in(
'object_data.type',array(
'role',
'rolt'),
false,
'text').
" ";
809 $where =
"WHERE ".$ilDB->in(
'object_data.type',array(
'role'),
false,
'text').
" ";
828 foreach ($a_role_list as $key => $val)
831 if ($val[
"type"] ==
"rolt")
833 $a_role_list[$key][
"role_type"] =
"template";
837 if ($val[
"assign"] ==
"y")
839 if ($val[
"parent"] == ROLE_FOLDER_ID)
841 $a_role_list[$key][
"role_type"] =
"global";
845 $a_role_list[$key][
"role_type"] =
"local";
850 $a_role_list[$key][
"role_type"] =
"linked";
854 if ($val[
"protected"] ==
"y")
856 $a_role_list[$key][
"protected"] =
true;
860 $a_role_list[$key][
"protected"] =
false;
877 $query =
'SELECT COUNT(DISTINCT(usr_id)) as num FROM rbac_ua '.
878 'WHERE '.$ilDB->in(
'rol_id', $a_roles,
false,
'integer').
' ';
896 $ilBench->start(
"RBAC",
"review_assignedUsers");
898 if (!isset($a_rol_id))
900 $message = get_class($this).
"::assignedUsers(): No role_id given!";
901 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
904 $result_arr = array();
906 if ($a_fields !== NULL and is_array($a_fields))
908 if (count($a_fields) == 0)
914 if (($usr_id_field = array_search(
"usr_id",$a_fields)) !==
false)
915 unset($a_fields[$usr_id_field]);
917 $select = implode(
",",$a_fields).
",usr_data.usr_id";
918 $select = addslashes($select);
921 $ilDB->enableResultBuffering(
false);
922 $query =
"SELECT ".$select.
" FROM usr_data ".
923 "LEFT JOIN rbac_ua ON usr_data.usr_id = rbac_ua.usr_id ".
924 "WHERE rbac_ua.rol_id =".$ilDB->quote($a_rol_id,
'integer');
926 while(
$row = $ilDB->fetchAssoc(
$res))
928 $result_arr[] =
$row;
930 $ilDB->enableResultBuffering(
true);
934 $ilDB->enableResultBuffering(
false);
935 $query =
"SELECT usr_id FROM rbac_ua WHERE rol_id= ".$ilDB->quote($a_rol_id,
'integer');
938 while(
$row = $ilDB->fetchAssoc(
$res))
940 array_push($result_arr,
$row[
"usr_id"]);
942 $ilDB->enableResultBuffering(
true);
945 $ilBench->stop(
"RBAC",
"review_assignedUsers");
962 $ilDB->setLimit(1,0);
963 $query =
"SELECT usr_id FROM rbac_ua WHERE ".
964 "rol_id= ".$ilDB->quote($a_role_id,
'integer').
" ".
965 "AND usr_id= ".$ilDB->quote($a_usr_id);
968 return $res->numRows() == 1;
986 $ilDB->setLimit(1,0);
987 $query =
"SELECT usr_id FROM rbac_ua WHERE ".
988 $ilDB->in(
'rol_id',$a_role_ids,
false,
'integer').
989 " AND usr_id= ".$ilDB->quote($a_usr_id);
992 return $ilDB->numRows(
$res) == 1;
1005 $role_arr = array();
1007 $query =
"SELECT rol_id FROM rbac_ua WHERE usr_id = ".$ilDB->quote($a_usr_id,
'integer');
1010 while(
$row = $ilDB->fetchObject(
$res))
1012 $role_arr[] =
$row->rol_id;
1014 return $role_arr ? $role_arr : array();
1025 $query =
"SELECT ua.rol_id FROM rbac_ua ua ".
1026 "JOIN rbac_fa fa ON ua.rol_id = fa.rol_id ".
1027 "WHERE usr_id = ".$ilDB->quote($a_usr_id,
'integer').
' '.
1028 "AND parent = ".$ilDB->quote(ROLE_FOLDER_ID).
" ".
1029 "AND assign = 'y' ";
1032 while(
$row = $ilDB->fetchObject(
$res))
1034 $role_arr[] =
$row->rol_id;
1036 return $role_arr ? $role_arr : array();
1050 $ilBench->start(
"RBAC",
"review_isAssignable");
1053 if ($a_rol_id == SYSTEM_ROLE_ID)
1055 $ilBench->stop(
"RBAC",
"review_isAssignable");
1059 if (!isset($a_rol_id) or !isset($a_ref_id))
1061 $message = get_class($this).
"::isAssignable(): Missing parameter!".
1062 " role_id: ".$a_rol_id.
" ,ref_id: ".$a_ref_id;
1063 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
1065 $query =
"SELECT * FROM rbac_fa ".
1066 "WHERE rol_id = ".$ilDB->quote($a_rol_id,
'integer').
" ".
1067 "AND parent = ".$ilDB->quote($a_ref_id,
'integer').
" ";
1071 $ilBench->stop(
"RBAC",
"review_isAssignable");
1072 return $row->assign ==
'y' ?
true :
false;
1082 $query =
"SELECT * FROM rbac_fa WHERE rol_id = ".$ilDB->quote($a_role_id,
'integer').
' '.
1083 "AND assign = ".$ilDB->quote(
'y',
'text');
1085 return $res->numRows() > 1;
1102 if (!isset($a_rol_id))
1104 $message = get_class($this).
"::getFoldersAssignedToRole(): No role_id given!";
1105 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
1110 $where =
" AND assign ='y'";
1113 $query =
"SELECT DISTINCT parent FROM rbac_fa ".
1114 "WHERE rol_id = ".$ilDB->quote($a_rol_id,
'integer').
" ".$where.
" ";
1117 while(
$row = $ilDB->fetchObject(
$res))
1119 $folders[] =
$row->parent;
1121 return $folders ? $folders : array();
1136 $ilBench->start(
"RBAC",
"review_getRolesOfRoleFolder");
1138 if (!isset($a_ref_id))
1140 $message = get_class($this).
"::getRolesOfRoleFolder(): No ref_id given!";
1141 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
1145 if ($a_nonassignable ===
false)
1147 $and =
" AND assign='y'";
1150 $query =
"SELECT rol_id FROM rbac_fa ".
1151 "WHERE parent = ".$ilDB->quote($a_ref_id,
'integer').
" ".
1155 while(
$row = $ilDB->fetchObject(
$res))
1157 $rol_id[] =
$row->rol_id;
1160 $ilBench->stop(
"RBAC",
"review_getRolesOfRoleFolder");
1162 return $rol_id ? $rol_id : array();
1194 $lroles[] = $role_id;
1209 $ga[] = array(
'obj_id' => $role_id,
1210 'role_type' =>
'global');
1212 return $ga ? $ga : array();
1222 include_once
'./Services/AccessControl/classes/class.ilObjRole.php';
1228 $ga[] = array(
'obj_id' => $role_id,
1229 'role_type' =>
'global');
1232 return $ga ? $ga : array();
1244 $query =
"SELECT DISTINCT parent FROM rbac_fa";
1248 while(
$row = $ilDB->fetchObject(
$res))
1250 $parent[] =
$row->parent;
1265 $ilBench->start(
"RBAC",
"review_getRoleFolderOfObject");
1267 if (!isset($a_ref_id))
1270 $message = get_class($this).
"::getRoleFolderOfObject(): No ref_id given!";
1271 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
1273 $childs = $tree->getChildsByType($a_ref_id,
"rolf");
1275 $ilBench->stop(
"RBAC",
"review_getRoleFolderOfObject");
1277 return $childs[0] ? $childs[0] : array();
1289 return $rolf[
'ref_id'];
1297 global $rbacreview,
$ilDB;
1299 $query =
'SELECT * FROM rbac_fa '.
1300 'WHERE rol_id = '.$ilDB->quote($a_role_id,
'integer').
' '.
1301 'AND parent = '.$ilDB->quote($a_parent_id,
'integer');
1303 return $res->numRows() ?
true :
false;
1315 $query =
'SELECT * FROM rbac_operations ORDER BY ops_id ';
1317 while(
$row = $ilDB->fetchObject(
$res))
1319 $ops[] = array(
'ops_id' =>
$row->ops_id,
1320 'operation' =>
$row->operation,
1321 'description' =>
$row->description);
1324 return $ops ? $ops : array();
1336 $query =
'SELECT * FROM rbac_operations WHERE ops_id = '.$ilDB->quote($ops_id,
'integer');
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();
1362 $a_parent = ROLE_FOLDER_ID;
1365 $query =
"SELECT ops_id,type FROM rbac_templates ".
1366 "WHERE rol_id = ".$ilDB->quote($a_rol_id,
'integer').
" ".
1367 "AND parent = ".$ilDB->quote($a_parent,
'integer');
1370 while (
$row = $ilDB->fetchObject(
$res))
1372 $ops_arr[
$row->type][] =
$row->ops_id;
1374 return (array) $ops_arr;
1387 $query =
'SELECT * FROM rbac_pa '.
1388 'WHERE ref_id = '.$ilDB->quote($a_ref_id,
'integer').
' '.
1389 'AND rol_id = '.$ilDB->quote($a_role_id,
'integer').
' ';
1394 return unserialize(
$row[
'ops_id']);
1413 if (!isset($a_rol_id) or !isset($a_type))
1415 $message = get_class($this).
"::getOperationsOfRole(): Missing Parameter!".
1416 "role_id: ".$a_rol_id.
1418 "parent_id: ".$a_parent;
1419 $ilLog->logStack(
"Missing parameter! ");
1420 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
1428 $a_parent = ROLE_FOLDER_ID;
1431 $query =
"SELECT ops_id FROM rbac_templates ".
1432 "WHERE type =".$ilDB->quote($a_type,
'text').
" ".
1433 "AND rol_id = ".$ilDB->quote($a_rol_id,
'integer').
" ".
1434 "AND parent = ".$ilDB->quote($a_parent,
'integer');
1436 while (
$row = $ilDB->fetchObject(
$res))
1438 $ops_arr[] =
$row->ops_id;
1448 $query =
"SELECT * FROM rbac_pa ".
1449 "WHERE rol_id = ".$ilDB->quote($a_role_id,
'integer').
" ".
1450 "AND ref_id = ".$ilDB->quote($a_ref_id,
'integer').
" ";
1453 while(
$row = $ilDB->fetchObject(
$res))
1455 $ops = unserialize(
$row->ops_id);
1458 return $ops ? $ops : array();
1471 if (!isset($a_typ_id))
1473 $message = get_class($this).
"::getOperationsOnType(): No type_id given!";
1474 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
1477 #$query = "SELECT * FROM rbac_ta WHERE typ_id = ".$ilDB->quote($a_typ_id,'integer');
1479 $query =
'SELECT * FROM rbac_ta ta JOIN rbac_operations o ON ta.ops_id = o.ops_id '.
1480 'WHERE typ_id = '.$ilDB->quote($a_typ_id,
'integer').
' '.
1481 'ORDER BY op_order';
1485 while(
$row = $ilDB->fetchObject(
$res))
1487 $ops_id[] =
$row->ops_id;
1490 return $ops_id ? $ops_id : array();
1503 $query =
"SELECT * FROM object_data WHERE type = 'typ' AND title = ".$ilDB->quote($a_type ,
'text').
" ";
1524 if($a_class !=
'create')
1526 $condition =
"AND class != ".$ilDB->quote(
'create',
'text');
1530 $condition =
"AND class = ".$ilDB->quote(
'create',
'text');
1533 $query =
"SELECT ro.ops_id FROM rbac_operations ro ".
1534 "JOIN rbac_ta rt ON ro.ops_id = rt.ops_id ".
1535 "JOIN object_data od ON rt.typ_id = od.obj_id ".
1536 "WHERE type = ".$ilDB->quote(
'typ',
'text').
" ".
1537 "AND title = ".$ilDB->quote($a_type,
'text').
" ".
1539 "ORDER BY op_order ";
1546 $ops[] =
$row->ops_id;
1564 $query =
'SELECT t.parent p FROM tree t JOIN rbac_fa fa ON fa.parent = child '.
1565 'WHERE assign = '.$ilDB->quote(
'n',
'text').
' '.
1566 'AND rol_id = '.$ilDB->quote($a_rol_id,
'integer').
' ';
1570 $query .= (
'AND '.$ilDB->in(
't.parent',(array) $a_filter,
false,
'integer'));
1577 $parent[] =
$row->p;
1592 $q =
"SELECT tree FROM tree WHERE child =".$ilDB->quote($a_node_id).
" ";
1599 $message = sprintf(
'%s::isDeleted(): Role folder with ref_id %s not found!',
1602 $this->log->write($message,$this->log->FATAL);
1628 $query =
'SELECT assign FROM rbac_fa '.
1629 'WHERE rol_id = '.$ilDB->quote($a_role_id,
'integer').
' '.
1630 'AND parent = '.$ilDB->quote($a_role_folder_id,
'integer');
1634 return $row->assign ==
'y' ?
true :
false;
1646 case self::FILTER_ALL:
1651 case self::FILTER_ALL_GLOBAL:
1652 $where =
'WHERE '.$ilDB->in(
'rbac_fa.rol_id',$this->
getGlobalRoles(),
false,
'integer').
' ';
1656 case self::FILTER_ALL_LOCAL:
1657 case self::FILTER_INTERNAL:
1658 case self::FILTER_NOT_INTERNAL:
1659 $where =
'WHERE '.$ilDB->in(
'rbac_fa.rol_id',$this->
getGlobalRoles(),
true,
'integer');
1663 case self::FILTER_TEMPLATES:
1664 $where =
"WHERE object_data.type = 'rolt'";
1674 $where =
'WHERE '.$ilDB->in(
'rbac_fa.rol_id',$this->
assignedRoles($a_user_id),
false,
'integer').
' ';
1680 $query =
"SELECT * FROM object_data ".
1681 "JOIN rbac_fa ON obj_id = rol_id ".
1683 "AND rbac_fa.assign = ".$ilDB->quote($assign,
'text').
" ";
1685 if(strlen($title_filter))
1687 $query .= (
' AND '.$ilDB->like(
1690 '%'.$title_filter.
'%'
1695 while(
$row = $ilDB->fetchAssoc(
$res))
1697 $prefix = (substr(
$row[
"title"],0,3) ==
"il_") ?
true :
false;
1700 if ($a_filter == 4 and !$prefix)
1706 if ($a_filter == 5 and $prefix)
1711 $row[
"desc"] =
$row[
"description"];
1718 return $roles ? $roles : array();
1726 $q =
"SELECT obj_id FROM object_data ".
1727 "WHERE title=".$ilDB->quote($a_type ,
'text').
" AND type='typ'";
1728 $r = $ilDB->query($q);
1731 return $row->obj_id;
1747 if(!count($operations))
1752 $query =
'SELECT ops_id FROM rbac_operations '.
1753 'WHERE '.$ilDB->in(
'operation',$operations,
false,
'text');
1756 while(
$row = $ilDB->fetchObject(
$res))
1758 $ops_ids[] =
$row->ops_id;
1760 return $ops_ids ? $ops_ids : array();
1774 if (!isset($a_operation))
1776 $message =
"perm::getOperationId(): No operation given!";
1777 $ilErr->raiseError($message,$ilErr->WARNING);
1781 if (! is_array(self::$_opsCache)) {
1782 self::$_opsCache = array();
1784 $q =
"SELECT ops_id, operation FROM rbac_operations";
1785 $r = $ilDB->query($q);
1788 self::$_opsCache[
$row->operation] =
$row->ops_id;
1793 if (array_key_exists($a_operation, self::$_opsCache)) {
1794 return self::$_opsCache[$a_operation];
1808 $operations = array();
1809 foreach($a_type_arr as $type)
1811 $operations[] = (
'create_'.$type);
1814 if(!count($operations))
1819 $query =
'SELECT ops_id, operation FROM rbac_operations '.
1820 'WHERE '.$ilDB->in(
'operation',$operations,
false,
'text');
1825 while(
$row = $ilDB->fetchObject(
$res))
1827 $type_arr = explode(
'_',
$row->operation);
1828 $type = $type_arr[1];
1830 $ops_ids[$type] =
$row->ops_id;
1848 if (!isset($a_ref_id))
1850 $message = get_class($this).
"::getLinkedRolesOfRoleFolder(): No ref_id given!";
1851 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
1854 $and =
" AND assign='n'";
1856 $query =
"SELECT rol_id FROM rbac_fa ".
1857 "WHERE parent = ".$ilDB->quote($a_ref_id,
'integer').
" ".
1860 while(
$row = $ilDB->fetchObject(
$res))
1862 $rol_id[] =
$row->rol_id;
1865 return $rol_id ? $rol_id : array();
1873 $query =
"SELECT protected FROM rbac_fa ".
1874 "WHERE rol_id = ".$ilDB->quote($a_role_id,
'integer').
" ".
1875 "AND parent = ".$ilDB->quote($a_ref_id,
'integer').
" ";
1886 #vd('refId',$a_ref_id,'parent roles',$a_parent_roles,'role-hierarchy',$a_role_hierarchy);
1888 global $rbacsystem,$ilUser,
$log;
1890 if (in_array(SYSTEM_ROLE_ID,$this->
assignedRoles($ilUser->getId())))
1896 $leveladmin =
false;
1898 #vd("RoleHierarchy",$a_role_hierarchy);
1899 foreach ($a_role_hierarchy as $role_id => $rolf_id)
1902 #echo "<br/>ROLF: ".$rolf_id." ROLE_ID: ".$role_id." (".$a_parent_roles[$role_id]['title'].") ";
1905 if ($leveladmin ==
true)
1907 $a_parent_roles[$role_id][
'protected'] =
false;
1911 if ($a_parent_roles[$role_id][
'protected'] ==
true)
1913 $arr_lvl_roles_user = array_intersect($this->
assignedRoles($ilUser->getId()),array_keys($a_role_hierarchy,$rolf_id));
1915 #vd("intersection",$arr_lvl_roles_user);
1917 foreach ($arr_lvl_roles_user as $lvl_role_id)
1919 #echo "<br/>level_role: ".$lvl_role_id;
1920 #echo "<br/>a_ref_id: ".$a_ref_id;
1925 if ($rbacsystem->checkPermission($a_ref_id,$lvl_role_id,
'edit_permission'))
1927 #echo "<br />Permission granted";
1930 $a_parent_roles[$role_id][
'protected'] =
false;
1939 return $a_parent_roles;
1960 $query = sprintf(
'SELECT * FROM rbac_operations '.
1961 'JOIN rbac_ta ON rbac_operations.ops_id = rbac_ta.ops_id '.
1962 'JOIN object_data ON rbac_ta.typ_id = object_data.obj_id '.
1963 'WHERE object_data.title = %s '.
1964 'AND object_data.type = %s '.
1965 'ORDER BY op_order ASC',
1966 $ilDB->quote($a_type,
'text'),
1967 $ilDB->quote(
'typ',
'text'));
1971 $query =
'SELECT * FROM rbac_operations ORDER BY op_order ASC';
1974 while (
$row = $ilDB->fetchAssoc(
$res))
1977 "ops_id" =>
$row[
'ops_id'],
1978 "operation" =>
$row[
'operation'],
1979 "desc" =>
$row[
'description'],
1980 "class" =>
$row[
'class'],
1981 "order" =>
$row[
'op_order']
1991 foreach ($a_ops_arr as $ops)
1993 $arr[$ops[
'class']][] = array (
'ops_id' => $ops[
'ops_id'],
1994 'name' => $ops[
'operation']
2011 $query =
"SELECT obr.obj_id FROM rbac_fa rfa ".
2012 "JOIN tree ON rfa.parent = tree.child ".
2013 "JOIN object_reference obr ON tree.parent = obr.ref_id ".
2014 "WHERE tree.tree = 1 ".
2015 "AND assign = 'y' ".
2016 "AND rol_id = ".$ilDB->quote($a_role_id,
'integer').
" ";
2018 while(
$row = $ilDB->fetchObject(
$res))
2020 $obj_id =
$row->obj_id;
2023 return $obj_id ? $obj_id : 0;
2035 $query =
"SELECT tree.parent ref FROM rbac_fa fa ".
2036 "JOIN tree ON fa.parent = tree.child ".
2037 "WHERE tree.tree = 1 ".
2038 "AND assign = ".$ilDB->quote(
'y',
'text').
' '.
2039 "AND rol_id = ".$ilDB->quote($a_role_id,
'integer');
2058 if (count($rolf_list))
2060 foreach ($rolf_list as $rolf) {
2077 $role_list = array();
2081 $query =
"SELECT * FROM object_data ".
2082 "JOIN rbac_fa ON object_data.obj_id = rbac_fa.rol_id ".
2084 "AND rbac_fa.assign = 'y' " .
2085 'AND '.$ilDB->in(
'object_data.obj_id',$role_ids,
false,
'integer');
2088 while(
$row = $ilDB->fetchAssoc(
$res))
2090 $row[
"desc"] =
$row[
"description"];
2092 $role_list[] =
$row;
2107 $query =
'SELECT ta.typ_id, obj.title, ops.ops_id, ops.operation FROM rbac_ta ta '.
2108 'JOIN object_data obj ON obj.obj_id = ta.typ_id '.
2109 'JOIN rbac_operations ops ON ops.ops_id = ta.ops_id ';
2113 while(
$row = $ilDB->fetchObject(
$res))
2115 $info[$counter][
'typ_id'] =
$row->typ_id;
2116 $info[$counter][
'type'] =
$row->title;
2117 $info[$counter][
'ops_id'] =
$row->ops_id;
2118 $info[$counter][
'operation'] =
$row->operation;
2121 return $info ? $info : array();
2137 $query =
'SELECT DISTINCT(parent) parent FROM rbac_fa '.
2138 'WHERE '.$ilDB->in(
'parent',$a_rolf_candidates,
false,
'integer');
2140 while(
$row = $ilDB->fetchObject(
$res))
2142 $non_empty[] =
$row->parent;
2144 return $non_empty ? $non_empty : array();
2159 if($a_role_id == SYSTEM_ROLE_ID or $a_role_id == ANONYMOUS_ROLE_ID)
2178 return substr(
$title,0,3) ==
'il_' ?
true :
false;
2194 $and = (
'AND assign = '.$ilDB->quote(
'y',
'text'));
2201 $query =
'SELECT * FROM rbac_fa '.
2202 'WHERE rol_id = '.$ilDB->quote($a_role_id,
'integer').
' '.
2207 return $row->parent;