5 require_once
"./Services/Object/classes/class.ilObject.php";
44 function ilObjRole($a_id = 0,$a_call_by_reference =
false)
47 $this->disk_quota = 0;
48 $this->wsp_disk_quota = 0;
49 $this->
ilObject($a_id,$a_call_by_reference);
60 if(substr($this->
getTitle(),0,3) ==
'il_')
62 $ilErr->setMessage(
'msg_role_reserved_prefix');
79 $this->assign_users = (int) $a_assign_users;
83 return $this->assign_users ? $this->assign_users : 0;
90 $query =
"SELECT assign_users FROM role_data WHERE role_id = ".$ilDB->quote($a_role_id,
'integer').
" ";
92 while(
$row = $ilDB->fetchObject(
$res))
94 return $row->assign_users ?
true :
false;
107 $query =
"SELECT * FROM role_data WHERE role_id= ".$ilDB->quote($this->
id,
'integer').
" ";
110 if (
$res->numRows() > 0)
112 $data = $ilDB->fetchAssoc(
$res);
119 $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);
148 $query =
"UPDATE role_data SET ".
149 "allow_register= ".$ilDB->quote($this->allow_register,
'integer').
", ".
151 "disk_quota = ".$ilDB->quote($this->
getDiskQuota(),
'integer').
", ".
153 "WHERE role_id= ".$ilDB->quote($this->
id,
'integer').
" ";
176 $query =
"INSERT INTO role_data ".
177 "(role_id,allow_register,assign_users,disk_quota,wsp_disk_quota) ".
179 "(".$ilDB->quote($this->
id,
'integer').
",".
198 if (empty($a_allow_register))
200 $a_allow_register == 0;
203 $this->allow_register = (int) $a_allow_register;
214 return $this->allow_register ? $this->allow_register :
false;
227 $this->disk_quota = $a_disk_quota;
255 $this->wsp_disk_quota = $a_disk_quota;
282 $query =
"SELECT * FROM role_data ".
283 "JOIN object_data ON object_data.obj_id = role_data.role_id ".
284 "WHERE allow_register = 1";
288 while($role = $ilDB->fetchAssoc(
$res))
290 $roles[] = array(
"id" => $role[
"obj_id"],
291 "title" => $role[
"title"],
292 "auth_mode" => $role[
'auth_mode']);
308 $query =
"SELECT * FROM role_data ".
309 " WHERE role_id =".$ilDB->quote($a_role_id,
'integer');
312 if ($role_rec = $ilDB->fetchAssoc(
$res))
314 if ($role_rec[
"allow_register"])
331 $this->parent = $a_parent_ref;
354 global $rbacadmin, $rbacreview,$ilDB;
356 $role_folders = $rbacreview->getFoldersAssignedToRole($this->
getId());
359 if($rbacreview->hasMultipleAssignments($this->getId()))
361 $GLOBALS[
'ilLog']->write(__METHOD__.
': Found role with multiple assignments: '.$this->getId());
365 if ($rbacreview->isAssignable($this->getId(),$this->
getParent()))
374 $last_role_user_ids = array();
375 if ($this->
getParent() == ROLE_FOLDER_ID)
380 $user_ids = $rbacreview->assignedUsers($this->
getId());
382 foreach ($user_ids as $user_id)
385 $role_ids = $rbacreview->assignedRoles($user_id);
388 if (count($role_ids) == 1)
390 $last_role_user_ids[] = $user_id;
396 if (count($last_role_user_ids) > 0)
398 foreach ($last_role_user_ids as $user_id)
402 $tmp_obj = $this->ilias->obj_factory->getInstanceByObjId($user_id);
403 $user_names[] = $tmp_obj->getFullname();
410 $users = implode(
', ',$user_names);
411 $this->ilias->raiseError($this->lng->txt(
"msg_user_last_role1").
" ".
412 $users.
"<br/>".$this->lng->txt(
"msg_user_last_role2"),$this->ilias->error_obj->WARNING);
420 include_once(
'./Services/LDAP/classes/class.ilLDAPRoleGroupMappingSettings.php');
427 $query =
"DELETE FROM role_data WHERE role_id = ".$ilDB->quote($this->
getId(),
'integer');
430 include_once
'Services/AccessControl/classes/class.ilRoleDesktopItem.php';
432 $role_desk_item_obj->deleteAll();
450 $non_empty_role_folders = $rbacreview->filterEmptyRoleFolders($role_folders);
451 $role_folders = array_diff($role_folders,$non_empty_role_folders);
454 foreach ($role_folders as $rolf)
458 $rolfObj = $this->ilias->obj_factory->getInstanceByRefId($rolf);
471 return count($rbacreview->assignedUsers($this->getId()));
478 $test_str = explode(
'_',$a_role_title);
480 if ($test_str[0] ==
'il')
482 $test2 = (int) $test_str[3];
488 return $lng->txt(implode(
'_',$test_str));
491 return $a_role_title;
500 foreach ($a_roles as $role_id => $auth_mode)
502 $query =
"UPDATE role_data SET ".
503 "auth_mode= ".$ilDB->quote($auth_mode,
'text').
" ".
504 "WHERE role_id= ".$ilDB->quote($role_id,
'integer').
" ";
513 $query =
"SELECT auth_mode FROM role_data ".
514 "WHERE role_id= ".$ilDB->quote($a_role_id,
'integer').
" ";
518 return $row[
'auth_mode'];
532 $query =
"SELECT * FROM role_data ".
533 "WHERE auth_mode = ".$ilDB->quote($a_auth_mode,
'text');
536 while(
$row = $ilDB->fetchObject(
$res))
538 $roles[] =
$row->role_id;
555 $query =
"UPDATE role_data SET auth_mode = 'default' WHERE auth_mode = ".$ilDB->quote($a_auth_mode,
'text');
563 global $ilDB,
$lng, $objDefinition,$rbacreview;
565 $operation_info = $rbacreview->getOperationAssignment();
566 foreach($operation_info as $info)
568 if($objDefinition->getDevMode($info[
'type']))
572 $rbac_objects[$info[
'typ_id']] = array(
"obj_id" => $info[
'typ_id'],
573 "type" => $info[
'type']);
576 $txt = $objDefinition->isPlugin($info[
'type'])
578 : $lng->txt($info[
'type'].
"_".$info[
'operation']);
579 if (substr($info[
'operation'], 0, 7) ==
"create_" &&
580 $objDefinition->isPlugin(substr($info[
'operation'], 7)))
582 $txt =
ilPlugin::lookupTxt(
"rep_robj", substr($info[
'operation'], 7), $info[
'type'].
"_".$info[
'operation']);
584 $rbac_operations[$info[
'typ_id']][$info[
'ops_id']] = array(
585 "ops_id" => $info[
'ops_id'],
586 "title" => $info[
'operation'],
590 return array($rbac_objects,$rbac_operations);
602 if(!$rbacreview->isAssignable($this->getId(), $a_role_folder_id))
607 if(substr($this->
getTitle(),0,3) ==
'il_')
629 global $tree,$rbacreview;
632 $nodes = $tree->getRbacSubtreeInfo($a_start_node);
636 $all_local_policies = $rbacreview->getObjectsWithStopedInheritance($this->
getId());
639 $local_policies = array();
640 foreach($all_local_policies as $lp)
642 if(isset($nodes[$lp]))
644 $local_policies[] = $lp;
651 case self::MODE_UNPROTECTED_DELETE_LOCAL_POLICIES:
652 case self::MODE_PROTECTED_DELETE_LOCAL_POLICIES:
654 #$local_policies = array($a_start_node == ROOT_FOLDER_ID ? SYSTEM_FOLDER_ID : $a_start_node);
657 $this->
adjustPermissions($a_mode,$nodes,$local_policies,$a_filter,$a_exclusion_filter);
659 #var_dump(memory_get_peak_usage());
660 #var_dump(memory_get_usage());
670 global $rbacreview,$rbacadmin;
672 $local_policies = array();
673 foreach($a_policies as $policy)
675 if($policy == $a_start or $policy == SYSTEM_FOLDER_ID)
677 $local_policies[] = $policy;
682 $local_policies[] = $policy;
686 if($rolf = $rbacreview->getRoleFolderIdOfObject($policy))
688 $rbacadmin->deleteLocalRole($this->
getId(),$rolf);
691 return $local_policies;
702 protected function adjustPermissions($a_mode,$a_nodes,$a_policies,$a_filter,$a_exclusion_filter = array())
704 global $rbacadmin, $rbacreview, $tree;
706 $operation_stack = array();
707 $policy_stack = array();
708 $node_stack = array();
710 $start_node = current($a_nodes);
711 array_push($node_stack,$start_node);
715 include_once
"Services/AccessControl/classes/class.ilRbacLog.php";
718 $local_policy =
false;
719 foreach($a_nodes as $node)
721 $cmp_node = end($node_stack);
722 while($relation = $tree->getRelationOfNodes($node,$cmp_node))
728 $GLOBALS[
'ilLog']->write(__METHOD__.
': Handling sibling/none relation.');
729 array_pop($operation_stack);
730 array_pop($policy_stack);
731 array_pop($node_stack);
732 $cmp_node = end($node_stack);
733 $local_policy =
false;
740 $GLOBALS[
'ilLog']->write(__METHOD__.
': Handling child/equals/parent '. $relation);
752 if($node[
'child'] == $start_node[
'child'])
758 $rbac_log_roles = $rbacreview->getParentRoleIds($node[
'child'],
false);
763 $perms = end($operation_stack);
764 $rbacadmin->grantPermission(
766 (array) $perms[$node[
'type']],
781 if(in_array($node[
'child'], $a_policies) and ($node[
'child'] != SYSTEM_FOLDER_ID))
783 $local_policy =
true;
786 array_push($node_stack, $node);
798 $rbac_log_roles = $rbacreview->getParentRoleIds($node[
'child'],
false);
803 if(($a_mode == self::MODE_UNPROTECTED_DELETE_LOCAL_POLICIES or
804 $a_mode == self::MODE_UNPROTECTED_KEEP_LOCAL_POLICIES) and ($node[
'type'] ==
'crs'))
808 $perms = end($operation_stack);
813 array_push($node_stack, $node);
818 if(($a_mode == self::MODE_UNPROTECTED_DELETE_LOCAL_POLICIES or
819 $a_mode == self::MODE_UNPROTECTED_KEEP_LOCAL_POLICIES) and ($node[
'type'] ==
'grp'))
822 $perms = end($operation_stack);
827 array_push($node_stack, $node);
832 $perms = end($operation_stack);
833 $rbacadmin->grantPermission(
835 (array) $perms[$node[
'type']],
856 if(in_array($a_type,$a_exclusion_filter))
861 if(in_array(
'all',$a_filter))
865 return in_array($a_type,$a_filter);
878 if($a_node == ROOT_FOLDER_ID)
880 $rolf = ROLE_FOLDER_ID;
884 $rolf = $rbacreview->getRoleFolderIdOfObject($a_node);
888 $parent_roles = $rbacreview->getParentRoleIds($a_node,
false);
889 if($parent_roles[$this->
getId()])
891 $a_stack[] = $rbacreview->getAllOperationsOfRole(
893 $parent_roles[$this->
getId()][
'parent']
905 $a_stack[] = $rbacreview->getAllOperationsOfRole(
921 if($a_node == ROOT_FOLDER_ID)
923 $rolf = ROLE_FOLDER_ID;
927 $rolf = $rbacreview->getRoleFolderIdOfObject($a_node);
948 global $ilDB, $rbacreview,$rbacadmin;
950 static $course_non_member_id = null;
951 static $group_non_member_id = null;
952 static $group_open_id = null;
953 static $group_closed_id = null;
960 include_once
'./Modules/Group/classes/class.ilObjGroup.php';
962 #var_dump("GROUP TYPE",$type);
966 if(!$group_closed_id)
968 $query =
"SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_grp_status_closed'";
972 $group_closed_id =
$row->obj_id;
975 $template_id = $group_closed_id;
976 #var_dump("GROUP CLOSED id:" . $template_id);
983 $query =
"SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_grp_status_open'";
987 $group_open_id =
$row->obj_id;
990 $template_id = $group_open_id;
991 #var_dump("GROUP OPEN id:" . $template_id);
997 if(!$course_non_member_id)
999 $query =
"SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_crs_non_member'";
1003 $course_non_member_id =
$row->obj_id;
1006 $template_id = $course_non_member_id;
1010 $current_ops = $a_current_ops[$a_type];
1015 $rolf = $rbacreview->getRoleFolderIdOfObject($a_id);
1017 $rbacadmin->copyRolePermissionIntersection(
1018 $template_id, ROLE_FOLDER_ID,
1019 $this->
getId(), end($policy_stack),
1020 $rolf,$this->
getId()
1025 #echo "No template id for ".$a_id.' of type'.$a_type.'<br>';
1027 #echo "ROLE ASSIGN: ".$rolf.' AID'.$a_id;
1028 if($rolf and !
$GLOBALS[
'rbacreview']->isRoleAssignedToFolder($this->
getId(),$rolf))
1030 $rbacadmin->assignRoleToFolder($this->
getId(),$rolf,
"n");