5 require_once
"./classes/class.ilObject.php";
44 function ilObjRole($a_id = 0,$a_call_by_reference =
false)
47 $this->disk_quota = 0;
48 $this->
ilObject($a_id,$a_call_by_reference);
59 if(substr($this->
getTitle(),0,3) ==
'il_')
61 $ilErr->setMessage(
'msg_role_reserved_prefix');
69 $this->assign_users = (int) $a_assign_users;
73 return $this->assign_users ? $this->assign_users : 0;
80 $query =
"SELECT assign_users FROM role_data WHERE role_id = ".$ilDB->quote($a_role_id,
'integer').
" ";
82 while(
$row = $ilDB->fetchObject(
$res))
84 return $row->assign_users ?
true :
false;
97 $query =
"SELECT * FROM role_data WHERE role_id= ".$ilDB->quote($this->
id,
'integer').
" ";
100 if (
$res->numRows() > 0)
109 $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);
137 $query =
"UPDATE role_data SET ".
138 "allow_register= ".$ilDB->quote($this->allow_register,
'integer').
", ".
140 "disk_quota = ".$ilDB->quote($this->
getDiskQuota(),
'integer').
" ".
141 "WHERE role_id= ".$ilDB->quote($this->
id,
'integer').
" ";
164 $query =
"INSERT INTO role_data ".
165 "(role_id,allow_register,assign_users,disk_quota) ".
167 "(".$ilDB->quote($this->
id,
'integer').
",".
185 if (empty($a_allow_register))
187 $a_allow_register == 0;
190 $this->allow_register = (int) $a_allow_register;
201 return $this->allow_register ? $this->allow_register :
false;
214 $this->disk_quota = $a_disk_quota;
240 $query =
"SELECT * FROM role_data ".
241 "JOIN object_data ON object_data.obj_id = role_data.role_id ".
242 "WHERE allow_register = 1";
246 while($role = $ilDB->fetchAssoc(
$res))
248 $roles[] = array(
"id" => $role[
"obj_id"],
249 "title" => $role[
"title"],
250 "auth_mode" => $role[
'auth_mode']);
266 $query =
"SELECT * FROM role_data ".
267 " WHERE role_id =".$ilDB->quote($a_role_id,
'integer');
270 if ($role_rec = $ilDB->fetchAssoc(
$res))
272 if ($role_rec[
"allow_register"])
289 $this->parent = $a_parent_ref;
312 global $rbacadmin, $rbacreview,
$ilDB;
314 $role_folders = $rbacreview->getFoldersAssignedToRole($this->
getId());
316 if ($rbacreview->isAssignable($this->getId(),$this->
getParent()))
325 $last_role_user_ids = array();
326 if ($this->
getParent() == ROLE_FOLDER_ID)
331 $user_ids = $rbacreview->assignedUsers($this->
getId());
333 foreach ($user_ids as $user_id)
336 $role_ids = $rbacreview->assignedRoles($user_id);
339 if (count($role_ids) == 1)
341 $last_role_user_ids[] = $user_id;
347 if (count($last_role_user_ids) > 0)
349 foreach ($last_role_user_ids as $user_id)
353 $tmp_obj = $this->ilias->obj_factory->getInstanceByObjId($user_id);
354 $user_names[] = $tmp_obj->getFullname();
361 $users = implode(
', ',$user_names);
362 $this->ilias->raiseError($this->lng->txt(
"msg_user_last_role1").
" ".
363 $users.
"<br/>".$this->lng->txt(
"msg_user_last_role2"),$this->ilias->error_obj->WARNING);
371 include_once(
'./Services/LDAP/classes/class.ilLDAPRoleGroupMappingSettings.php');
378 $query =
"DELETE FROM role_data WHERE role_id = ".$ilDB->quote($this->
getId(),
'integer');
381 include_once
'./classes/class.ilRoleDesktopItem.php';
383 $role_desk_item_obj->deleteAll();
401 $non_empty_role_folders = $rbacreview->filterEmptyRoleFolders($role_folders);
402 $role_folders = array_diff($role_folders,$non_empty_role_folders);
405 foreach ($role_folders as $rolf)
409 $rolfObj = $this->ilias->obj_factory->getInstanceByRefId($rolf);
422 return count($rbacreview->assignedUsers($this->getId()));
429 $test_str = explode(
'_',$a_role_title);
431 if ($test_str[0] ==
'il')
433 $test2 = (int) $test_str[3];
439 return $lng->txt(implode(
'_',$test_str));
442 return $a_role_title;
451 foreach ($a_roles as $role_id => $auth_mode)
453 $query =
"UPDATE role_data SET ".
454 "auth_mode= ".$ilDB->quote($auth_mode,
'text').
" ".
455 "WHERE role_id= ".$ilDB->quote($role_id,
'integer').
" ";
464 $query =
"SELECT auth_mode FROM role_data ".
465 "WHERE role_id= ".$ilDB->quote($a_role_id,
'integer').
" ";
469 return $row[
'auth_mode'];
483 $query =
"SELECT * FROM role_data ".
484 "WHERE auth_mode = ".$ilDB->quote($a_auth_mode,
'text');
486 while(
$row = $ilDB->fetchObject(
$res))
488 $roles[] =
$row->role_id;
490 return $roles ? $roles : array();
505 $query =
"UPDATE role_data SET auth_mode = 'default' WHERE auth_mode = ".$ilDB->quote($a_auth_mode,
'text');
513 global
$ilDB,
$lng, $objDefinition,$rbacreview;
515 $operation_info = $rbacreview->getOperationAssignment();
516 foreach($operation_info as $info)
518 if($objDefinition->getDevMode($info[
'type']))
522 $rbac_objects[$info[
'typ_id']] = array(
"obj_id" => $info[
'typ_id'],
523 "type" => $info[
'type']);
526 $txt = $objDefinition->isPlugin($info[
'type'])
528 : $lng->txt($info[
'type'].
"_".$info[
'operation']);
529 if (substr($info[
'operation'], 0, 7) ==
"create_" &&
530 $objDefinition->isPlugin(substr($info[
'operation'], 7)))
532 $txt =
ilPlugin::lookupTxt(
"rep_robj", substr($info[
'operation'], 7), $info[
'type'].
"_".$info[
'operation']);
534 $rbac_operations[$info[
'typ_id']][$info[
'ops_id']] = array(
535 "ops_id" => $info[
'ops_id'],
536 "title" => $info[
'operation'],
540 return array($rbac_objects,$rbac_operations);
552 if($this->
getId() == SYSTEM_ROLE_ID or $this->
getId() == ANONYMOUS_ROLE_ID)
557 if(!$rbacreview->isAssignable($this->getId(), $a_role_folder_id))
562 if(substr($this->
getTitle(),0,3) ==
'il_')
584 global $tree,$rbacreview;
587 $nodes = $tree->getRbacSubtreeInfo($a_start_node);
592 $all_local_policies = $rbacreview->getObjectsWithStopedInheritance($this->
getId());
596 $local_policies = array();
597 foreach($all_local_policies as $lp)
599 if(isset($nodes[$lp]))
601 $local_policies[] = $lp;
608 case self::MODE_UNPROTECTED_DELETE_LOCAL_POLICIES:
609 case self::MODE_PROTECTED_DELETE_LOCAL_POLICIES:
611 #$local_policies = array($a_start_node == ROOT_FOLDER_ID ? SYSTEM_FOLDER_ID : $a_start_node);
616 #var_dump(memory_get_peak_usage());
617 #var_dump(memory_get_usage());
627 global $rbacreview,$rbacadmin;
629 $local_policies = array();
630 foreach($a_policies as $policy)
632 if($policy == $a_start or $policy == SYSTEM_FOLDER_ID)
634 $local_policies[] = $policy;
639 $local_policies[] = $policy;
643 if($rolf = $rbacreview->getRoleFolderIdOfObject($policy))
645 $rbacadmin->deleteLocalRole($this->
getId(),$rolf);
648 return $local_policies;
662 $operation_stack = array();
663 $policy_stack = array();
664 $left_stack = array();
665 $right_stack = array();
667 $start_node = current($a_nodes);
668 array_push($left_stack, $start_node[
'lft']);
669 array_push($right_stack, $start_node[
'rgt']);
673 $local_policy =
false;
674 foreach($a_nodes as $node)
676 $lft = end($left_stack);
677 $rgt = end($right_stack);
679 #echo "----STACK---- ".$lft.' - '.$rgt.'<br/>';
681 if(($node[
'lft'] < $lft) or ($node[
'rgt'] > $rgt))
683 #echo "LEFT ".$node['child'].'<br>';
684 array_pop($operation_stack);
685 array_pop($policy_stack);
686 array_pop($left_stack);
687 array_pop($right_stack);
688 $local_policy =
false;
693 #echo "LOCAL ".$node['child'].' left:'.$node['lft'].' right: '.$node['rgt'].'<br>';
699 if($node[
'child'] == $start_node[
'child'])
704 $perms = end($operation_stack);
705 $rbacadmin->grantPermission(
707 (array) $perms[$node[
'type']],
715 if(in_array($node[
'child'], $a_policies) and ($node[
'child'] != SYSTEM_FOLDER_ID))
717 #echo "POLICIES ".$node['child'].' left:'.$node['lft'].' right: '.$node['rgt'].'<br>';
718 $local_policy =
true;
721 array_push($left_stack,$node[
'lft']);
722 array_push($right_stack, $node[
'rgt']);
732 #echo "MODE: ".$a_mode.'TYPE: '.$node['type'].'<br>';
734 if(($a_mode == self::MODE_UNPROTECTED_DELETE_LOCAL_POLICIES or
735 $a_mode == self::MODE_UNPROTECTED_KEEP_LOCAL_POLICIES) and ($node[
'type'] ==
'crs'))
738 #echo "CRS ".$node['child'].'<br>';
741 $perms = end($operation_stack);
745 #echo "CRS SUCCESS ".$node['child'].'<br>';
747 array_push($left_stack, $node[
'lft']);
748 array_push($right_stack, $node[
'rgt']);
753 if(($a_mode == self::MODE_UNPROTECTED_DELETE_LOCAL_POLICIES or
754 $a_mode == self::MODE_UNPROTECTED_KEEP_LOCAL_POLICIES) and ($node[
'type'] ==
'grp'))
756 #echo "GRP ".$node['child'].'<br>';
758 $perms = end($operation_stack);
762 #echo "GRP SUCCESS ".$node['child'].'<br>';
764 array_push($left_stack, $node[
'lft']);
765 array_push($right_stack, $node[
'rgt']);
769 #echo "GRANTED ".$node['child'].'<br>';
771 $perms = end($operation_stack);
772 $rbacadmin->grantPermission(
774 (array) $perms[$node[
'type']],
777 #var_dump("ALL INFO ",$this->getId(),$perms[$node['type']]);
789 if(in_array(
'all',$a_filter))
793 return in_array($a_type,$a_filter);
806 if($a_node == ROOT_FOLDER_ID)
808 $rolf = ROLE_FOLDER_ID;
812 $rolf = $rbacreview->getRoleFolderIdOfObject($a_node);
820 $a_stack[] = $rbacreview->getAllOperationsOfRole(
836 if($a_node == ROOT_FOLDER_ID)
838 $rolf = ROLE_FOLDER_ID;
842 $rolf = $rbacreview->getRoleFolderIdOfObject($a_node);
863 global
$ilDB, $rbacreview,$rbacadmin;
865 static $course_non_member_id = null;
866 static $group_non_member_id = null;
867 static $group_open_id = null;
868 static $group_closed_id = null;
875 include_once
'./Modules/Group/classes/class.ilObjGroup.php';
877 #var_dump("GROUP TYPE",$type);
881 if(!$group_closed_id)
883 $query =
"SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_grp_status_closed'";
887 $group_closed_id =
$row->obj_id;
890 $template_id = $group_closed_id;
891 #var_dump("GROUP CLOSED id:" . $template_id);
898 $query =
"SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_grp_status_open'";
902 $group_open_id =
$row->obj_id;
905 $template_id = $group_open_id;
906 #var_dump("GROUP OPEN id:" . $template_id);
912 if(!$course_non_member_id)
914 $query =
"SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_crs_non_member'";
918 $course_non_member_id =
$row->obj_id;
921 $template_id = $course_non_member_id;
925 $current_ops = $a_current_ops[$a_type];
930 $rolf = $rbacreview->getRoleFolderIdOfObject($a_id);
932 $rbacadmin->copyRolePermissionIntersection(
933 $template_id, ROLE_FOLDER_ID,
934 $this->
getId(), end($policy_stack),
940 #echo "No template id for ".$a_id.' of type'.$a_type.'<br>';
942 #echo "ROLE ASSIGN: ".$rolf.' AID'.$a_id;
945 $rbacadmin->assignRoleToFolder($this->
getId(),$rolf,
"n");