24 require_once
"./classes/class.ilObject.php";
54 function ilObjRole($a_id = 0,$a_call_by_reference =
false)
57 $this->
ilObject($a_id,$a_call_by_reference);
62 $this->assign_users = (int) $a_assign_users;
73 $query =
"SELECT assign_users FROM role_data WHERE role_id = ".$ilDB->quote($a_role_id).
" ";
75 $res = $ilDB->query($query);
78 return $row->assign_users ?
true :
false;
91 $q =
"SELECT * FROM role_data WHERE role_id= ".$ilDB->quote($this->
id).
" ";
92 $r = $this->ilias->db->query($q);
94 if ($r->numRows() > 0)
103 $this->ilias->raiseError(
"<b>Error: There is no dataset with id ".$this->
id.
"!</b><br />class: ".get_class($this).
"<br />Script: ".__FILE__.
"<br />Line: ".__LINE__, $this->ilias->FATAL);
130 $q =
"UPDATE role_data SET ".
131 "allow_register= ".$ilDB->quote($this->allow_register).
", ".
133 "WHERE role_id= ".$ilDB->quote($this->
id).
" ";
135 $this->ilias->db->query($q);
157 $q =
"INSERT INTO role_data ".
158 "(role_id,allow_register,assign_users) ".
161 $this->ilias->db->query($q);
174 if (empty($a_allow_register))
176 $a_allow_register == 0;
179 $this->allow_register = (int) $a_allow_register;
203 $q =
"SELECT * FROM role_data ".
204 "LEFT JOIN object_data ON object_data.obj_id = role_data.role_id ".
205 "WHERE allow_register = 1";
207 $r = $ilDB->query($q);
212 $roles[] = array(
"id" => $role[
"obj_id"],
213 "title" => $role[
"title"],
214 "auth_mode" => $role[
'auth_mode']);
230 $q =
"SELECT * FROM role_data ".
231 " WHERE role_id =".$ilDB->quote($a_role_id);
233 $role_set = $ilDB->query($q);
237 if ($role_rec[
"allow_register"])
254 $this->parent = $a_parent_ref;
277 global $rbacadmin, $rbacreview,$ilDB;
279 $role_folders = $rbacreview->getFoldersAssignedToRole($this->
getId());
281 if ($rbacreview->isAssignable($this->getId(),$this->
getParent()))
290 $last_role_user_ids = array();
291 if ($this->
getParent() == ROLE_FOLDER_ID)
296 $user_ids = $rbacreview->assignedUsers($this->
getId());
298 foreach ($user_ids as $user_id)
301 $role_ids = $rbacreview->assignedRoles($user_id);
304 if (count($role_ids) == 1)
306 $last_role_user_ids[] = $user_id;
312 if (count($last_role_user_ids) > 0)
314 foreach ($last_role_user_ids as $user_id)
318 $tmp_obj = $this->ilias->obj_factory->getInstanceByObjId($user_id);
319 $user_names[] = $tmp_obj->getFullname();
326 $users = implode(
', ',$user_names);
327 $this->ilias->raiseError($this->lng->txt(
"msg_user_last_role1").
" ".
328 $users.
"<br/>".$this->lng->txt(
"msg_user_last_role2"),$this->ilias->error_obj->WARNING);
336 include_once(
'./Services/LDAP/classes/class.ilLDAPRoleGroupMappingSettings.php');
343 $q =
"DELETE FROM role_data WHERE role_id = ".$ilDB->quote($this->
getId()).
" ";
344 $this->ilias->db->query($q);
346 include_once
'./classes/class.ilRoleDesktopItem.php';
348 $role_desk_item_obj->deleteAll();
365 $q =
"SELECT DISTINCT parent FROM rbac_fa ".
366 "WHERE parent IN (".implode(
',',$role_folders).
")";
368 $r = $ilDB->query($q);
369 $non_empty_role_folders = array();
372 $non_empty_role_folders[] = $row->parent;
374 $role_folders = array_diff($role_folders,$non_empty_role_folders);
377 foreach ($role_folders as $rolf)
381 $rolfObj = $this->ilias->obj_factory->getInstanceByRefId($rolf);
394 return count($rbacreview->assignedUsers($this->getId()));
411 $where_condition = $a_search_obj->getWhereCondition(
"like",array(
"title",
"description"));
414 $query =
"SELECT obj_id FROM object_data AS od ".
415 $where_condition.
" ".
416 "AND od.type = 'role' ";
418 $ilBench->start(
"Search",
"ilObjRole_search");
419 $res = $a_search_obj->ilias->db->query($query);
420 $ilBench->stop(
"Search",
"ilObjRole_search");
426 $result_data[$counter++][
"id"] = $row->obj_id;
429 return $result_data ? $result_data : array();
437 $test_str = explode(
'_',$a_role_title);
439 if ($test_str[0] ==
'il')
441 $test2 = (int) $test_str[3];
447 return $lng->txt(implode(
'_',$test_str));
450 return $a_role_title;
459 foreach ($a_roles as $role_id => $auth_mode)
461 $q =
"UPDATE role_data SET ".
462 "auth_mode= ".$ilDB->quote($auth_mode).
" ".
463 "WHERE role_id= ".$ilDB->quote($role_id).
" ";
472 $q =
"SELECT auth_mode FROM role_data ".
473 "WHERE role_id= ".$ilDB->quote($a_role_id).
" ";
474 $r = $ilDB->query($q);
475 $row = $r->fetchRow();
491 $query =
"SELECT * FROM role_data ".
492 "WHERE auth_mode = ".$ilDB->quote($a_auth_mode);
493 $res = $ilDB->query($query);
496 $roles[] = $row->role_id;
498 return $roles ? $roles : array();
513 $query =
"UPDATE role_data SET auth_mode = 'default' WHERE auth_mode = ".$ilDB->quote($a_auth_mode);
514 $ilDB->query($query);
521 global $ilDB,
$lng, $objDefinition;
524 $q =
"SELECT ta.typ_id,obj.title,ops.ops_id,ops.operation FROM rbac_ta AS ta ".
525 "JOIN object_data AS obj ON obj.obj_id=ta.typ_id ".
526 "JOIN rbac_operations AS ops ON ops.ops_id=ta.ops_id";
527 $r = $ilDB->query($q);
531 if($objDefinition->getDevMode($row->title))
536 #if(in_array($row->title,$to_filter))
540 $rbac_objects[$row->typ_id] = array(
"obj_id" => $row->typ_id,
541 "type" => $row->title
544 $rbac_operations[$row->typ_id][$row->ops_id] = array(
545 "ops_id" => $row->ops_id,
546 "title" => $row->operation,
547 "name" => $lng->txt($row->title.
"_".$row->operation)
550 return array($rbac_objects,$rbac_operations);