39 (isset($ilDB)) ? $this->
ilDB =& $ilDB : $this->
ilDB =& $ilias->db;
104 include_once
"Services/Mail/classes/class.ilMail.php";
107 require_once
'Mail/RFC822.php';
109 $parsedList = $parser->parseAddressList($a_address_list,
"ilias",
false,
true);
111 foreach ($parsedList as $address)
113 $local_part = $address->mailbox;
114 if (strpos($local_part,
'#') !== 0 &&
115 !($local_part{0} ==
'"' && $local_part{1} ==
"#"))
122 $local_part = substr($local_part, 1);
126 if( $local_part{0} ==
'#' && $local_part{strlen($local_part) - 1} ==
'"' )
128 $local_part = substr($local_part, 1);
129 $local_part = substr($local_part, 0, strlen($local_part) - 1);
132 if (substr($local_part,0,8) ==
'il_role_')
134 $role_id = substr($local_part,8);
135 $query =
"SELECT t.tree ".
137 "JOIN tree t ON t.child = fa.parent ".
138 "WHERE fa.rol_id = ".$this->ilDB->quote($role_id,
'integer').
" ".
139 "AND fa.assign = 'y' ".
141 $r = $ilDB->query(
$query);
142 if ($r->numRows() > 0)
144 $role_ids[] = $role_id;
150 $domain = $address->host;
151 if (strpos($domain,
'[') == 0 && strrpos($domain,
']'))
153 $domain = substr($domain,1,strlen($domain) - 2);
155 if (strlen($local_part) == 0)
157 $local_part = $domain;
158 $address->host =
'ilias';
162 if (strtolower($address->host) ==
'ilias')
165 $query =
"SELECT dat.obj_id ".
166 "FROM object_data dat ".
167 "JOIN rbac_fa fa ON fa.rol_id = dat.obj_id ".
168 "JOIN tree t ON t.child = fa.parent ".
169 "WHERE dat.title =".$this->ilDB->quote($local_part,
'text').
" ".
170 "AND dat.type = 'role' ".
171 "AND fa.assign = 'y' ".
177 $query =
"SELECT rdat.obj_id ".
178 "FROM object_data odat ".
179 "JOIN object_reference oref ON oref.obj_id = odat.obj_id ".
180 "JOIN tree otree ON otree.child = oref.ref_id ".
181 "JOIN tree rtree ON rtree.parent = otree.child ".
182 "JOIN rbac_fa rfa ON rfa.parent = rtree.child ".
183 "JOIN object_data rdat ON rdat.obj_id = rfa.rol_id ".
184 "WHERE odat.title = ".$this->ilDB->quote($domain,
'text').
" ".
185 "AND otree.tree = 1 AND rtree.tree = 1 ".
186 "AND rfa.assign = 'y' ".
187 "AND rdat.title LIKE ".
188 $this->
ilDB->
quote(
'%'.preg_replace(
'/([_%])/',
'\\\\$1',$local_part).
'%',
'text');
190 $r = $ilDB->query(
$query);
195 $role_ids[] =
$row->obj_id;
201 if ($count == 0 && strtolower($address->host) ==
'ilias')
203 $q =
"SELECT dat.obj_id ".
204 "FROM object_data dat ".
205 "JOIN object_reference ref ON ref.obj_id = dat.obj_id ".
206 "JOIN tree t ON t.child = ref.ref_id ".
207 "WHERE dat.title = ".$this->ilDB->quote($domain ,
'text').
" ".
208 "AND dat.type = 'role' ".
214 $role_ids[] =
$row->obj_id;
225 $titles = explode(
',', $a_address_list);
228 foreach ($titles as
$title)
230 if (strlen($inList) > 0)
234 $title = trim($title);
235 if (strpos($title,
'#') == 0)
237 $titleList .= $this->
ilDB->
quote(substr($title, 1));
240 if (strlen($titleList) > 0)
242 $q =
"SELECT obj_id ".
244 "WHERE title IN (".$titleList.
") ".
249 $role_ids[] =
$row->obj_id;
324 include_once
"Services/Mail/classes/class.ilMail.php";
328 $query =
"SELECT rdat.title role_title,odat.title object_title, ".
329 " oref.ref_id object_ref ".
330 "FROM object_data rdat ".
331 "JOIN rbac_fa fa ON fa.rol_id = rdat.obj_id ".
332 "JOIN tree rtree ON rtree.child = fa.parent ".
333 "JOIN object_reference oref ON oref.ref_id = rtree.parent ".
334 "JOIN object_data odat ON odat.obj_id = oref.obj_id ".
335 "WHERE rdat.obj_id = ".$this->ilDB->quote($a_role_id,
'integer').
" ".
336 "AND fa.assign = 'y' ";
337 $r = $ilDB->query(
$query);
338 if (!
$row = $ilDB->fetchObject($r))
343 $object_title =
$row->object_title;
344 $object_ref =
$row->object_ref;
345 $role_title =
$row->role_title;
351 $domain = $object_title;
352 $local_part = $role_title;
356 $q =
"SELECT COUNT(DISTINCT dat.obj_id) count ".
357 "FROM object_data dat ".
358 "JOIN object_reference ref ON ref.obj_id = dat.obj_id ".
359 "JOIN tree ON tree.child = ref.ref_id ".
360 "WHERE title = ".$this->ilDB->quote($object_title,
'text').
" ".
361 "AND tree.tree = 1 ";
374 if ($domain != null && preg_match(
'/[\[\]\\]|[\x00-\x1f]|[\x28-\x29]/',$domain))
381 if ($domain != null &&
382 (preg_match(
'/[()<>@,;:\\".\[\]]/',$domain) ||
383 preg_match(
'/[^\x21-\x8f]/',$domain))
386 $domain =
'['.$domain.
']';
392 if (strpos($role_title,
'il_') === 0 && $domain != null)
394 $unambiguous_role_title = $role_title;
396 $pos = strpos($role_title,
'_', 3) + 1;
397 $local_part = substr(
400 strrpos($role_title,
'_') -
$pos
405 $unambiguous_role_title =
'il_role_'.$a_role_id;
414 $q =
"SELECT COUNT(DISTINCT dat.obj_id) count ".
415 "FROM object_data dat ".
416 "JOIN object_reference ref ON ref.obj_id = dat.obj_id ".
417 "JOIN tree ON tree.child = ref.ref_id ".
418 "WHERE title = ".$this->ilDB->quote($local_part,
'text').
" ".
419 "AND tree.tree = 1 ";
423 $q =
"SELECT COUNT(rd.obj_id) count ".
424 "FROM object_data rd ".
425 "JOIN rbac_fa fa ON rd.obj_id = fa.rol_id ".
426 "JOIN tree t ON t.child = fa.parent ".
427 "WHERE fa.assign = 'y' ".
428 "AND t.parent = ".$this->ilDB->quote($object_ref,
'integer').
" ".
429 "AND rd.title LIKE ".$this->ilDB->quote(
430 '%'.preg_replace(
'/([_%])/',
'\\\\$1', $local_part).
'%',
'text').
" ";
440 $local_part = $unambiguous_role_title;
446 if (preg_match(
'/[\\"\x00-\x1f]/',$local_part))
448 $local_part = $unambiguous_role_title;
453 $local_part =
'#'.$local_part;
456 if (preg_match(
'/[()<>@,;:.\[\]\x20]/',$local_part))
458 $local_part =
'"'.$local_part.
'"';
461 $mailbox = ($domain == null) ?
463 $local_part.
'@'.$domain;
467 if (substr($role_title,0,3) ==
'il_')
469 $phrase = $lng->txt(substr($role_title, 0, strrpos($role_title,
'_')));
473 $phrase = $role_title;
479 $phrase = preg_replace(
'/\s\s+/',
' ', $phrase);
480 $phrase = preg_replace(
'/[()<>@,;:\\".\[\]]/',
'', $phrase);
482 $mailbox = $phrase.
' <'.$mailbox.
'>';
489 $q =
"SELECT title ".
491 "WHERE obj_id = ".$this->ilDB->quote($a_role_id ,
'integer');
496 return '#'.$row->title;
519 $message = get_class($this).
"::roleExists(): No title given!";
520 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
523 $clause = ($a_id) ?
" AND obj_id != ".$ilDB->quote($a_id).
" " :
"";
525 $q =
"SELECT DISTINCT(obj_id) obj_id FROM object_data ".
526 "WHERE title =".$ilDB->quote($a_title).
" ".
527 "AND type IN('role','rolt')".
554 if (!isset($a_path) or !is_array($a_path))
556 $message = get_class($this).
"::getParentRoles(): No path given or wrong datatype!";
557 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
560 $parent_roles = array();
561 $role_hierarchy = array();
565 $in = $ilDB->in(
't.parent',$a_path,
false,
'integer');
567 $q =
"SELECT t.child,t.depth FROM tree t ".
568 "JOIN object_reference r ON r.ref_id = t.child ".
569 "JOIN object_data o ON o.obj_id = r.obj_id ".
571 "AND o.type= ".$ilDB->quote(
'rolf',
'text').
" ".
572 "ORDER BY t.depth ASC";
578 $role_rows = array();
582 $depth = (
$row->child == ROLE_FOLDER_ID ? 0 :
$row->depth);
583 $role_rows[$depth][
'child'] =
$row->child;
585 ksort($role_rows,SORT_NUMERIC);
587 foreach($role_rows as
$row)
590 foreach ($roles as $role)
592 $id = $role[
"obj_id"];
593 $role[
"parent"] = $row[
'child'];
594 $parent_roles[$id] = $role;
596 if (!array_key_exists($role[
'obj_id'],$role_hierarchy))
598 $role_hierarchy[$id] = $row[
'child'];
602 if (!$a_keep_protected)
606 return $parent_roles;
621 if (!isset($a_endnode_id))
624 $message = get_class($this).
"::getParentRoleIds(): No node_id (ref_id) given!";
625 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
630 $pathIds = $tree->getPathId($a_endnode_id);
633 $pathIds[0] = SYSTEM_FOLDER_ID;
635 #return $this->getParentRoles($a_endnode_id,$a_templates,$a_keep_protected);
650 if (!isset($a_ref_id) or !isset($a_templates))
652 $message = get_class($this).
"::getRoleListByObject(): Missing parameter!".
653 "ref_id: ".$a_ref_id.
654 "tpl_flag: ".$a_templates;
655 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
658 $role_list = array();
662 $query =
"SELECT * FROM object_data ".
663 "JOIN rbac_fa ON obj_id = rol_id ".
665 "AND object_data.obj_id = rbac_fa.rol_id ".
666 "AND rbac_fa.parent = ".$ilDB->quote($a_ref_id,
'integer').
" ";
669 while (
$row = $ilDB->fetchAssoc(
$res))
691 $role_list = array();
695 $query =
"SELECT * FROM object_data ".
696 "JOIN rbac_fa ON obj_id = rol_id ".
698 "AND rbac_fa.assign = 'y' ";
701 while (
$row = $ilDB->fetchAssoc(
$res))
723 $role_list = array();
726 $query =
"SELECT fa.*, dat.* ".
728 "JOIN tree node ON node.tree = root.tree ".
729 "AND node.lft > root.lft AND node.rgt < root.rgt ".
730 "JOIN object_reference ref ON ref.ref_id = node.child ".
731 "JOIN rbac_fa fa ON fa.parent = ref.ref_id ".
732 "JOIN object_data dat ON dat.obj_id = fa.rol_id ".
733 "WHERE root.child = ".$this->ilDB->quote(
$ref_id,
'integer').
" ".
734 "AND root.tree = 1 ".
735 "AND fa.assign = 'y' ".
736 "ORDER BY dat.title";
739 while(
$row = $ilDB->fetchAssoc(
$res))
759 $query =
"SELECT fa.*, rd.* ".
760 "FROM object_data rd ".
761 "JOIN rbac_fa fa ON rd.obj_id = fa.rol_id ".
762 "JOIN tree t ON t.child = fa.parent ".
763 "WHERE fa.assign = 'y' ".
764 "AND t.parent = ".$this->ilDB->quote($a_ref_id,
'integer').
" "
767 while(
$row = $ilDB->fetchAssoc(
$res))
769 $roles_data[] =
$row;
771 return $roles_data ? $roles_data : array();
784 if ($a_templates ===
true)
786 $where =
"WHERE ".$ilDB->in(
'object_data.type',array(
'role',
'rolt'),
false,
'text').
" ";
790 $where =
"WHERE ".$ilDB->in(
'object_data.type',array(
'role'),
false,
'text').
" ";
809 foreach ($a_role_list as $key => $val)
812 if ($val[
"type"] ==
"rolt")
814 $a_role_list[$key][
"role_type"] =
"template";
818 if ($val[
"assign"] ==
"y")
820 if ($val[
"parent"] == ROLE_FOLDER_ID)
822 $a_role_list[$key][
"role_type"] =
"global";
826 $a_role_list[$key][
"role_type"] =
"local";
831 $a_role_list[$key][
"role_type"] =
"linked";
835 if ($val[
"protected"] ==
"y")
837 $a_role_list[$key][
"protected"] =
true;
841 $a_role_list[$key][
"protected"] =
false;
859 $ilBench->start(
"RBAC",
"review_assignedUsers");
861 if (!isset($a_rol_id))
863 $message = get_class($this).
"::assignedUsers(): No role_id given!";
864 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
867 $result_arr = array();
869 if ($a_fields !== NULL and is_array($a_fields))
871 if (count($a_fields) == 0)
877 if (($usr_id_field = array_search(
"usr_id",$a_fields)) !==
false)
878 unset($a_fields[$usr_id_field]);
880 $select = implode(
",",$a_fields).
",usr_data.usr_id";
881 $select = addslashes($select);
884 $query =
"SELECT ".$select.
" FROM usr_data ".
885 "LEFT JOIN rbac_ua ON usr_data.usr_id = rbac_ua.usr_id ".
886 "WHERE rbac_ua.rol_id =".$ilDB->quote($a_rol_id,
'integer');
888 while(
$row = $ilDB->fetchAssoc(
$res))
890 $result_arr[] =
$row;
895 $query =
"SELECT usr_id FROM rbac_ua WHERE rol_id= ".$ilDB->quote($a_rol_id,
'integer');
898 while(
$row = $ilDB->fetchAssoc(
$res))
900 array_push($result_arr,
$row[
"usr_id"]);
904 $ilBench->stop(
"RBAC",
"review_assignedUsers");
921 $ilDB->setLimit(1,0);
922 $query =
"SELECT usr_id FROM rbac_ua WHERE ".
923 "rol_id= ".$ilDB->quote($a_role_id,
'integer').
" ".
924 "AND usr_id= ".$ilDB->quote($a_usr_id);
927 return $res->numRows() == 1;
945 $ilDB->setLimit(1,0);
946 $query =
"SELECT usr_id FROM rbac_ua WHERE ".
947 $ilDB->in(
'rol_id',$a_role_ids,
false,
'integer').
948 " AND usr_id= ".$ilDB->quote($a_usr_id);
951 return $ilDB->numRows(
$res) == 1;
966 $query =
"SELECT rol_id FROM rbac_ua WHERE usr_id = ".$ilDB->quote($a_usr_id,
'integer');
969 while(
$row = $ilDB->fetchObject(
$res))
971 $role_arr[] =
$row->rol_id;
973 return $role_arr ? $role_arr : array();
984 $query =
"SELECT ua.rol_id FROM rbac_ua ua ".
985 "JOIN rbac_fa fa ON ua.rol_id = fa.rol_id ".
986 "WHERE usr_id = ".$ilDB->quote($a_usr_id,
'integer').
' '.
987 "AND parent = ".$ilDB->quote(ROLE_FOLDER_ID).
" ".
991 while(
$row = $ilDB->fetchObject(
$res))
993 $role_arr[] =
$row->rol_id;
995 return $role_arr ? $role_arr : array();
1009 $ilBench->start(
"RBAC",
"review_isAssignable");
1012 if ($a_rol_id == SYSTEM_ROLE_ID)
1014 $ilBench->stop(
"RBAC",
"review_isAssignable");
1018 if (!isset($a_rol_id) or !isset($a_ref_id))
1020 $message = get_class($this).
"::isAssignable(): Missing parameter!".
1021 " role_id: ".$a_rol_id.
" ,ref_id: ".$a_ref_id;
1022 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
1024 $query =
"SELECT * FROM rbac_fa ".
1025 "WHERE rol_id = ".$ilDB->quote($a_rol_id,
'integer').
" ".
1026 "AND parent = ".$ilDB->quote($a_ref_id,
'integer').
" ";
1030 $ilBench->stop(
"RBAC",
"review_isAssignable");
1031 return $row->assign ==
'y' ?
true :
false;
1041 $query =
"SELECT * FROM rbac_fa WHERE rol_id = ".$ilDB->quote($a_role_id,
'integer').
' '.
1042 "AND assign = ".$ilDB->quote(
'y',
'text');
1044 return $res->numRows() > 1;
1061 if (!isset($a_rol_id))
1063 $message = get_class($this).
"::getFoldersAssignedToRole(): No role_id given!";
1064 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
1069 $where =
" AND assign ='y'";
1072 $query =
"SELECT DISTINCT parent FROM rbac_fa ".
1073 "WHERE rol_id = ".$ilDB->quote($a_rol_id,
'integer').
" ".$where.
" ";
1076 while(
$row = $ilDB->fetchObject(
$res))
1078 $folders[] =
$row->parent;
1080 return $folders ? $folders : array();
1095 $ilBench->start(
"RBAC",
"review_getRolesOfRoleFolder");
1097 if (!isset($a_ref_id))
1099 $message = get_class($this).
"::getRolesOfRoleFolder(): No ref_id given!";
1100 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
1104 if ($a_nonassignable ===
false)
1106 $and =
" AND assign='y'";
1109 $query =
"SELECT rol_id FROM rbac_fa ".
1110 "WHERE parent = ".$ilDB->quote($a_ref_id,
'integer').
" ".
1114 while(
$row = $ilDB->fetchObject(
$res))
1116 $rol_id[] =
$row->rol_id;
1119 $ilBench->stop(
"RBAC",
"review_getRolesOfRoleFolder");
1121 return $rol_id ? $rol_id : array();
1143 $ga[] = array(
'obj_id' => $role_id,
1144 'role_type' =>
'global');
1146 return $ga ? $ga : array();
1156 include_once
'./Services/AccessControl/classes/class.ilObjRole.php';
1162 $ga[] = array(
'obj_id' => $role_id,
1163 'role_type' =>
'global');
1166 return $ga ? $ga : array();
1178 $query =
"SELECT DISTINCT parent FROM rbac_fa";
1182 while(
$row = $ilDB->fetchObject(
$res))
1184 $parent[] =
$row->parent;
1199 $ilBench->start(
"RBAC",
"review_getRoleFolderOfObject");
1201 if (!isset($a_ref_id))
1204 $message = get_class($this).
"::getRoleFolderOfObject(): No ref_id given!";
1205 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
1207 $childs = $tree->getChildsByType($a_ref_id,
"rolf");
1209 $ilBench->stop(
"RBAC",
"review_getRoleFolderOfObject");
1211 return $childs[0] ? $childs[0] : array();
1223 return $rolf[
'ref_id'];
1235 $query =
'SELECT * FROM rbac_operations ORDER BY ops_id ';
1237 while(
$row = $ilDB->fetchObject(
$res))
1239 $ops[] = array(
'ops_id' =>
$row->ops_id,
1240 'operation' =>
$row->operation,
1241 'description' =>
$row->description);
1244 return $ops ? $ops : array();
1256 $query =
'SELECT * FROM rbac_operations WHERE ops_id = '.$ilDB->quote($ops_id,
'integer');
1258 while(
$row = $ilDB->fetchObject(
$res))
1260 $ops = array(
'ops_id' =>
$row->ops_id,
1261 'operation' =>
$row->operation,
1262 'description' =>
$row->description);
1265 return $ops ? $ops : array();
1282 $a_parent = ROLE_FOLDER_ID;
1285 $query =
"SELECT ops_id,type FROM rbac_templates ".
1286 "WHERE rol_id = ".$ilDB->quote($a_rol_id,
'integer').
" ".
1287 "AND parent = ".$ilDB->quote($a_parent,
'integer');
1290 while (
$row = $ilDB->fetchObject(
$res))
1292 $ops_arr[
$row->type][] =
$row->ops_id;
1294 return (array) $ops_arr;
1307 $query =
'SELECT * FROM rbac_pa '.
1308 'WHERE ref_id = '.$ilDB->quote($a_ref_id,
'integer').
' '.
1309 'AND rol_id = '.$ilDB->quote($a_role_id,
'integer').
' ';
1314 return unserialize(
$row[
'ops_id']);
1333 if (!isset($a_rol_id) or !isset($a_type))
1335 $message = get_class($this).
"::getOperationsOfRole(): Missing Parameter!".
1336 "role_id: ".$a_rol_id.
1338 "parent_id: ".$a_parent;
1339 $ilLog->logStack(
"Missing parameter! ");
1340 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
1348 $a_parent = ROLE_FOLDER_ID;
1351 $query =
"SELECT ops_id FROM rbac_templates ".
1352 "WHERE type =".$ilDB->quote($a_type,
'text').
" ".
1353 "AND rol_id = ".$ilDB->quote($a_rol_id,
'integer').
" ".
1354 "AND parent = ".$ilDB->quote($a_parent,
'integer');
1356 while (
$row = $ilDB->fetchObject(
$res))
1358 $ops_arr[] =
$row->ops_id;
1368 $query =
"SELECT * FROM rbac_pa ".
1369 "WHERE rol_id = ".$ilDB->quote($a_role_id,
'integer').
" ".
1370 "AND ref_id = ".$ilDB->quote($a_ref_id,
'integer').
" ";
1373 while(
$row = $ilDB->fetchObject(
$res))
1375 $ops = unserialize(
$row->ops_id);
1378 return $ops ? $ops : array();
1391 if (!isset($a_typ_id))
1393 $message = get_class($this).
"::getOperationsOnType(): No type_id given!";
1394 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
1397 #$query = "SELECT * FROM rbac_ta WHERE typ_id = ".$ilDB->quote($a_typ_id,'integer');
1399 $query =
'SELECT * FROM rbac_ta ta JOIN rbac_operations o ON ta.ops_id = o.ops_id '.
1400 'WHERE typ_id = '.$ilDB->quote($a_typ_id,
'integer').
' '.
1401 'ORDER BY op_order';
1405 while(
$row = $ilDB->fetchObject(
$res))
1407 $ops_id[] =
$row->ops_id;
1410 return $ops_id ? $ops_id : array();
1423 $query =
"SELECT * FROM object_data WHERE type = 'typ' AND title = ".$ilDB->quote($a_type ,
'text').
" ";
1444 if($a_class !=
'create')
1446 $condition =
"AND class != ".$ilDB->quote(
'create',
'text');
1450 $condition =
"AND class = ".$ilDB->quote(
'create',
'text');
1453 $query =
"SELECT ro.ops_id FROM rbac_operations ro ".
1454 "JOIN rbac_ta rt ON ro.ops_id = rt.ops_id ".
1455 "JOIN object_data od ON rt.typ_id = od.obj_id ".
1456 "WHERE type = ".$ilDB->quote(
'typ',
'text').
" ".
1457 "AND title = ".$ilDB->quote($a_type,
'text').
" ".
1459 "ORDER BY op_order ";
1466 $ops[] =
$row->ops_id;
1481 $tree =
new ilTree(ROOT_FOLDER_ID);
1483 if (!isset($a_rol_id))
1485 $message = get_class($this).
"::getObjectsWithStopedInheritance(): No role_id given!";
1486 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
1491 foreach ($all_rolf_ids as $rolf_id)
1493 $parent[] = $tree->getParentId($rolf_id);
1496 return $parent ? $parent : array();
1509 $q =
"SELECT tree FROM tree WHERE child =".$ilDB->quote($a_node_id).
" ";
1516 $message = sprintf(
'%s::isDeleted(): Role folder with ref_id %s not found!',
1519 $this->log->write($message,$this->log->FATAL);
1553 $where =
'WHERE '.$ilDB->in(
'rbac_fa.rol_id',$this->
getGlobalRoles(),
false,
'integer').
' ';
1560 $where =
'WHERE '.$ilDB->in(
'rbac_fa.rol_id',$this->
getGlobalRoles(),
true,
'integer');
1565 $where =
"WHERE object_data.type = 'rolt'";
1575 $where =
'WHERE '.$ilDB->in(
'rbac_fa.rol_id',$this->
assignedRoles($a_user_id),
false,
'integer').
' ';
1581 $query =
"SELECT * FROM object_data ".
1582 "JOIN rbac_fa ON obj_id = rol_id ".
1584 "AND rbac_fa.assign = ".$ilDB->quote($assign,
'text').
" ";
1587 while(
$row = $ilDB->fetchAssoc(
$res))
1589 $prefix = (substr(
$row[
"title"],0,3) ==
"il_") ?
true :
false;
1592 if ($a_filter == 4 and !$prefix)
1598 if ($a_filter == 5 and $prefix)
1603 $row[
"desc"] =
$row[
"description"];
1610 return $roles ? $roles : array();
1618 $q =
"SELECT obj_id FROM object_data ".
1619 "WHERE title=".$ilDB->quote($a_type ,
'text').
" AND type='typ'";
1620 $r = $ilDB->query($q);
1623 return $row->obj_id;
1639 if(!count($operations))
1644 $query =
'SELECT ops_id FROM rbac_operations '.
1645 'WHERE '.$ilDB->in(
'operation',$operations,
false,
'text');
1648 while(
$row = $ilDB->fetchObject(
$res))
1650 $ops_ids[] =
$row->ops_id;
1652 return $ops_ids ? $ops_ids : array();
1666 if (!isset($a_operation))
1668 $message =
"perm::getOperationId(): No operation given!";
1669 $ilErr->raiseError($message,$ilErr->WARNING);
1673 if (! is_array(self::$_opsCache)) {
1674 self::$_opsCache = array();
1676 $q =
"SELECT ops_id, operation FROM rbac_operations";
1677 $r = $ilDB->query($q);
1680 self::$_opsCache[
$row->operation] =
$row->ops_id;
1685 if (array_key_exists($a_operation, self::$_opsCache)) {
1686 return self::$_opsCache[$a_operation];
1700 $operations = array();
1701 foreach($a_type_arr as
$type)
1703 $operations[] = (
'create_'.$type);
1706 if(!count($operations))
1711 $query =
'SELECT ops_id, operation FROM rbac_operations '.
1712 'WHERE '.$ilDB->in(
'operation',$operations,
false,
'text');
1717 while(
$row = $ilDB->fetchObject(
$res))
1719 $type_arr = explode(
'_',
$row->operation);
1720 $type = $type_arr[1];
1740 if (!isset($a_ref_id))
1742 $message = get_class($this).
"::getLinkedRolesOfRoleFolder(): No ref_id given!";
1743 $this->ilErr->raiseError($message,$this->ilErr->WARNING);
1746 $and =
" AND assign='n'";
1748 $query =
"SELECT rol_id FROM rbac_fa ".
1749 "WHERE parent = ".$ilDB->quote($a_ref_id,
'integer').
" ".
1752 while(
$row = $ilDB->fetchObject(
$res))
1754 $rol_id[] =
$row->rol_id;
1757 return $rol_id ? $rol_id : array();
1765 $query =
"SELECT protected FROM rbac_fa ".
1766 "WHERE rol_id = ".$ilDB->quote($a_role_id,
'integer').
" ".
1767 "AND parent = ".$ilDB->quote($a_ref_id,
'integer').
" ";
1778 #vd('refId',$a_ref_id,'parent roles',$a_parent_roles,'role-hierarchy',$a_role_hierarchy);
1780 global $rbacsystem,$ilUser,
$log;
1782 if (in_array(SYSTEM_ROLE_ID,$this->
assignedRoles($ilUser->getId())))
1788 $leveladmin =
false;
1790 #vd("RoleHierarchy",$a_role_hierarchy);
1791 foreach ($a_role_hierarchy as $role_id => $rolf_id)
1794 #echo "<br/>ROLF: ".$rolf_id." ROLE_ID: ".$role_id." (".$a_parent_roles[$role_id]['title'].") ";
1797 if ($leveladmin ==
true)
1799 $a_parent_roles[$role_id][
'protected'] =
false;
1803 if ($a_parent_roles[$role_id][
'protected'] ==
true)
1805 $arr_lvl_roles_user = array_intersect($this->
assignedRoles($ilUser->getId()),array_keys($a_role_hierarchy,$rolf_id));
1807 #vd("intersection",$arr_lvl_roles_user);
1809 foreach ($arr_lvl_roles_user as $lvl_role_id)
1811 #echo "<br/>level_role: ".$lvl_role_id;
1812 #echo "<br/>a_ref_id: ".$a_ref_id;
1817 if ($rbacsystem->checkPermission($a_ref_id,$lvl_role_id,
'edit_permission'))
1819 #echo "<br />Permission granted";
1822 $a_parent_roles[$role_id][
'protected'] =
false;
1831 return $a_parent_roles;
1852 $query = sprintf(
'SELECT * FROM rbac_operations '.
1853 'JOIN rbac_ta ON rbac_operations.ops_id = rbac_ta.ops_id '.
1854 'JOIN object_data ON rbac_ta.typ_id = object_data.obj_id '.
1855 'WHERE object_data.title = %s '.
1856 'AND object_data.type = %s '.
1857 'ORDER BY op_order ASC',
1858 $ilDB->quote($a_type,
'text'),
1859 $ilDB->quote(
'typ',
'text'));
1863 $query =
'SELECT * FROM rbac_operations ORDER BY op_order ASC';
1866 while (
$row = $ilDB->fetchAssoc(
$res))
1869 "ops_id" =>
$row[
'ops_id'],
1870 "operation" =>
$row[
'operation'],
1871 "desc" =>
$row[
'description'],
1872 "class" =>
$row[
'class'],
1873 "order" =>
$row[
'op_order']
1883 foreach ($a_ops_arr as $ops)
1885 $arr[$ops[
'class']][] = array (
'ops_id' => $ops[
'ops_id'],
1886 'name' => $ops[
'operation']
1903 $query =
"SELECT obr.obj_id FROM rbac_fa rfa ".
1904 "JOIN tree ON rfa.parent = tree.child ".
1905 "JOIN object_reference obr ON tree.parent = obr.ref_id ".
1906 "WHERE tree.tree = 1 ".
1907 "AND assign = 'y' ".
1908 "AND rol_id = ".$ilDB->quote($a_role_id,
'integer').
" ";
1910 while(
$row = $ilDB->fetchObject(
$res))
1912 $obj_id =
$row->obj_id;
1915 return $obj_id ? $obj_id : 0;
1927 $query =
"SELECT tree.parent ref FROM rbac_fa fa ".
1928 "JOIN tree ON fa.parent = tree.child ".
1929 "WHERE tree.tree = 1 ".
1930 "AND assign = ".$ilDB->quote(
'y',
'text').
' '.
1931 "AND rol_id = ".$ilDB->quote($a_role_id,
'integer');
1950 if (count($rolf_list))
1952 foreach ($rolf_list as $rolf) {
1969 $role_list = array();
1973 $query =
"SELECT * FROM object_data ".
1974 "JOIN rbac_fa ON object_data.obj_id = rbac_fa.rol_id ".
1976 "AND rbac_fa.assign = 'y' " .
1977 'AND '.$ilDB->in(
'object_data.obj_id',$role_ids,
false,
'integer');
1980 while(
$row = $ilDB->fetchAssoc(
$res))
1982 $row[
"desc"] =
$row[
"description"];
1984 $role_list[] =
$row;
1999 $query =
'SELECT ta.typ_id, obj.title, ops.ops_id, ops.operation FROM rbac_ta ta '.
2000 'JOIN object_data obj ON obj.obj_id = ta.typ_id '.
2001 'JOIN rbac_operations ops ON ops.ops_id = ta.ops_id ';
2005 while(
$row = $ilDB->fetchObject(
$res))
2007 $info[$counter][
'typ_id'] =
$row->typ_id;
2008 $info[$counter][
'type'] =
$row->title;
2009 $info[$counter][
'ops_id'] =
$row->ops_id;
2010 $info[$counter][
'operation'] =
$row->operation;
2013 return $info ? $info : array();
2029 $query =
'SELECT DISTINCT(parent) parent FROM rbac_fa '.
2030 'WHERE '.$ilDB->in(
'parent',$a_rolf_candidates,
false,
'integer');
2032 while(
$row = $ilDB->fetchObject(
$res))
2034 $non_empty[] =
$row->parent;
2036 return $non_empty ? $non_empty : array();
2051 if($a_role_id == SYSTEM_ROLE_ID or $a_role_id == ANONYMOUS_ROLE_ID)