5 require_once
"./Services/Object/classes/class.ilObject.php";
6 require_once(
'./Services/Repository/classes/class.ilObjectPlugin.php');
48 $this->disk_quota = 0;
49 $this->wsp_disk_quota = 0;
50 parent::__construct($a_id,$a_call_by_reference);
66 $res = $ilDB->query(
"SELECT obj_id FROM object_data ".
67 " WHERE type=".$ilDB->quote(
"rolt",
"text").
68 " AND title=".$ilDB->quote($a_tpl_name,
"text"));
71 $tpl_id =
$row->obj_id;
79 include_once
'./Services/AccessControl/classes/class.ilObjRole.php';
81 $role->setTitle($a_title);
82 $role->setDescription($a_description);
85 $GLOBALS[
'rbacadmin']->assignRoleToFolder($role->getId(),$a_ref_id,
'y');
87 $GLOBALS[
'rbacadmin']->copyRoleTemplatePermissions(
94 $ops =
$GLOBALS[
'rbacreview']->getOperationsOfRole(
99 $GLOBALS[
'rbacadmin']->grantPermission(
116 if(substr($this->
getTitle(),0,3) ==
'il_')
118 $ilErr->setMessage(
'msg_role_reserved_prefix');
135 $this->assign_users = (int) $a_assign_users;
139 return $this->assign_users ? $this->assign_users : 0;
146 $query =
"SELECT assign_users FROM role_data WHERE role_id = ".$ilDB->quote($a_role_id,
'integer').
" ";
148 while(
$row = $ilDB->fetchObject(
$res))
150 return $row->assign_users ? true :
false;
163 $query =
"SELECT * FROM role_data WHERE role_id= ".$ilDB->quote($this->
id,
'integer').
" ";
166 if (
$res->numRows() > 0)
175 $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);
204 $query =
"UPDATE role_data SET ".
205 "allow_register= ".$ilDB->quote($this->allow_register,
'integer').
", ".
207 "disk_quota = ".$ilDB->quote($this->
getDiskQuota(),
'integer').
", ".
209 "WHERE role_id= ".$ilDB->quote($this->
id,
'integer').
" ";
230 $this->
id = parent::create();
232 $query =
"INSERT INTO role_data ".
233 "(role_id,allow_register,assign_users,disk_quota,wsp_disk_quota) ".
235 "(".$ilDB->quote($this->
id,
'integer').
",".
254 if (empty($a_allow_register))
256 $a_allow_register == 0;
259 $this->allow_register = (int) $a_allow_register;
270 return $this->allow_register ? $this->allow_register :
false;
283 $this->disk_quota = $a_disk_quota;
311 $this->wsp_disk_quota = $a_disk_quota;
338 $query =
"SELECT * FROM role_data ".
339 "JOIN object_data ON object_data.obj_id = role_data.role_id ".
340 "WHERE allow_register = 1";
344 while($role = $ilDB->fetchAssoc(
$res))
346 $roles[] =
array(
"id" => $role[
"obj_id"],
347 "title" => $role[
"title"],
348 "auth_mode" => $role[
'auth_mode']);
364 $query =
"SELECT * FROM role_data ".
365 " WHERE role_id =".$ilDB->quote($a_role_id,
'integer');
368 if ($role_rec = $ilDB->fetchAssoc(
$res))
370 if ($role_rec[
"allow_register"])
387 $this->
parent = $a_parent_ref;
410 global $rbacadmin, $rbacreview,
$ilDB;
413 if($rbacreview->hasMultipleAssignments($this->getId()))
420 if ($rbacreview->isAssignable($this->getId(),$this->
getParent()))
430 $last_role_user_ids =
array();
431 if ($this->
getParent() == ROLE_FOLDER_ID)
437 $user_ids = $rbacreview->assignedUsers($this->
getId());
439 foreach ($user_ids as $user_id)
442 $role_ids = $rbacreview->assignedRoles($user_id);
445 if (count($role_ids) == 1)
447 $last_role_user_ids[] = $user_id;
453 if (count($last_role_user_ids) > 0)
455 $user_names =
array();
456 foreach ($last_role_user_ids as $user_id)
465 $users = implode(
', ',$user_names);
467 $this->
ilias->raiseError($this->lng->txt(
"msg_user_last_role1").
" ".
468 $users.
"<br/>".$this->lng->txt(
"msg_user_last_role2"),$this->
ilias->error_obj->WARNING);
476 include_once(
'./Services/LDAP/classes/class.ilLDAPRoleGroupMappingSettings.php');
483 $query =
"DELETE FROM role_data WHERE role_id = ".$ilDB->quote($this->
getId(),
'integer');
486 include_once
'Services/AccessControl/classes/class.ilRoleDesktopItem.php';
488 $role_desk_item_obj->deleteAll();
505 return count($rbacreview->assignedUsers($this->getId()));
512 $test_str = explode(
'_',$a_role_title);
514 if ($test_str[0] ==
'il')
516 $test2 = (int) $test_str[3];
522 return $lng->txt(implode(
'_',$test_str));
525 return $a_role_title;
534 foreach ($a_roles as $role_id => $auth_mode)
536 $query =
"UPDATE role_data SET ".
537 "auth_mode= ".$ilDB->quote($auth_mode,
'text').
" ".
538 "WHERE role_id= ".$ilDB->quote($role_id,
'integer').
" ";
547 $query =
"SELECT auth_mode FROM role_data ".
548 "WHERE role_id= ".$ilDB->quote($a_role_id,
'integer').
" ";
552 return $row[
'auth_mode'];
566 $query =
"SELECT * FROM role_data ".
567 "WHERE auth_mode = ".$ilDB->quote($a_auth_mode,
'text');
570 while(
$row = $ilDB->fetchObject(
$res))
572 $roles[] =
$row->role_id;
589 $query =
"UPDATE role_data SET auth_mode = 'default' WHERE auth_mode = ".$ilDB->quote($a_auth_mode,
'text');
597 global
$ilDB,
$lng, $objDefinition,$rbacreview;
599 $operation_info = $rbacreview->getOperationAssignment();
600 foreach($operation_info as
$info)
602 if($objDefinition->getDevMode($info[
'type']))
606 $rbac_objects[$info[
'typ_id']] =
array(
"obj_id" => $info[
'typ_id'],
607 "type" => $info[
'type']);
610 $txt = $objDefinition->isPlugin($info[
'type'])
612 : $lng->txt($info[
'type'].
"_".$info[
'operation']);
613 if (substr($info[
'operation'], 0, 7) ==
"create_" &&
614 $objDefinition->isPlugin(substr($info[
'operation'], 7)))
618 $rbac_operations[$info[
'typ_id']][$info[
'ops_id']] =
array(
619 "ops_id" => $info[
'ops_id'],
620 "title" => $info[
'operation'],
624 return array($rbac_objects,$rbac_operations);
642 global $tree,$rbacreview;
645 $nodes = $tree->getRbacSubtreeInfo($a_start_node);
648 $all_local_policies = $rbacreview->getObjectsWithStopedInheritance($this->
getId());
651 $local_policies =
array();
652 foreach($all_local_policies as $lp)
654 if(isset($nodes[$lp]))
656 $local_policies[] = $lp;
663 case self::MODE_UNPROTECTED_DELETE_LOCAL_POLICIES:
664 case self::MODE_PROTECTED_DELETE_LOCAL_POLICIES:
666 #$local_policies = array($a_start_node == ROOT_FOLDER_ID ? SYSTEM_FOLDER_ID : $a_start_node); 669 $this->
adjustPermissions($a_mode,$nodes,$local_policies,$a_filter,$a_exclusion_filter);
671 #var_dump(memory_get_peak_usage()); 672 #var_dump(memory_get_usage()); 682 global $rbacreview,$rbacadmin;
684 $local_policies =
array();
685 foreach($a_policies as $policy)
687 if($policy == $a_start
or $policy == SYSTEM_FOLDER_ID)
689 $local_policies[] = $policy;
694 $local_policies[] = $policy;
697 $rbacadmin->deleteLocalRole($this->
getId(),$policy);
699 return $local_policies;
712 global $rbacadmin, $rbacreview, $tree;
714 $operation_stack =
array();
715 $policy_stack =
array();
716 $node_stack =
array();
718 $start_node = current($a_nodes);
719 array_push($node_stack,$start_node);
723 include_once
"Services/AccessControl/classes/class.ilRbacLog.php";
726 $local_policy =
false;
727 foreach($a_nodes as $node)
729 $cmp_node = end($node_stack);
730 while($relation = $tree->getRelationOfNodes($node,$cmp_node))
736 $GLOBALS[
'ilLog']->write(__METHOD__.
': Handling sibling/none relation.');
737 array_pop($operation_stack);
738 array_pop($policy_stack);
739 array_pop($node_stack);
740 $cmp_node = end($node_stack);
741 $local_policy =
false;
748 $GLOBALS[
'ilLog']->write(__METHOD__.
': Handling child/equals/parent '. $relation);
760 if($node[
'child'] == $start_node[
'child'])
766 $rbac_log_roles = $rbacreview->getParentRoleIds($node[
'child'],
false);
771 $perms = end($operation_stack);
772 $rbacadmin->grantPermission(
774 (
array) $perms[$node[
'type']],
789 if(in_array($node[
'child'], $a_policies)
and ($node[
'child'] != SYSTEM_FOLDER_ID))
791 $local_policy =
true;
794 array_push($node_stack, $node);
806 $rbac_log_roles = $rbacreview->getParentRoleIds($node[
'child'],
false);
811 if(($a_mode == self::MODE_UNPROTECTED_DELETE_LOCAL_POLICIES
or 812 $a_mode == self::MODE_UNPROTECTED_KEEP_LOCAL_POLICIES)
and ($node[
'type'] ==
'crs'))
816 $perms = end($operation_stack);
821 array_push($node_stack, $node);
826 if(($a_mode == self::MODE_UNPROTECTED_DELETE_LOCAL_POLICIES
or 827 $a_mode == self::MODE_UNPROTECTED_KEEP_LOCAL_POLICIES)
and ($node[
'type'] ==
'grp'))
830 $perms = end($operation_stack);
835 array_push($node_stack, $node);
840 $perms = end($operation_stack);
841 $rbacadmin->grantPermission(
843 (
array) $perms[$node[
'type']],
864 if(in_array(
$a_type,$a_exclusion_filter))
869 if(in_array(
'all',$a_filter))
873 return in_array(
$a_type,$a_filter);
886 $has_policies = null;
887 $policy_origin = null;
889 if($a_node == ROOT_FOLDER_ID)
891 $has_policies = TRUE;
892 $policy_origin = ROLE_FOLDER_ID;
896 $has_policies = $rbacreview->getLocalPolicies($a_node);
897 $policy_origin = $a_node;
901 $parent_roles = $rbacreview->getParentRoleIds($a_node,
false);
902 if($parent_roles[$this->
getId()])
904 $a_stack[] = $rbacreview->getAllOperationsOfRole(
906 $parent_roles[$this->
getId()][
'parent']
919 $a_stack[] = $rbacreview->getAllOperationsOfRole(
935 $has_policies = null;
936 $policy_origin = null;
938 if($a_node == ROOT_FOLDER_ID)
940 $has_policies = TRUE;
941 $policy_origin = ROLE_FOLDER_ID;
945 $has_policies = $rbacreview->getLocalPolicies($a_node);
946 $policy_origin = $a_node;
954 $a_stack[] = $policy_origin;
967 global
$ilDB, $rbacreview,$rbacadmin;
969 static $course_non_member_id = null;
970 static $group_non_member_id = null;
971 static $group_open_id = null;
972 static $group_closed_id = null;
979 include_once
'./Modules/Group/classes/class.ilObjGroup.php';
981 #var_dump("GROUP TYPE",$type); 985 if(!$group_closed_id)
987 $query =
"SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_grp_status_closed'";
991 $group_closed_id =
$row->obj_id;
995 #var_dump("GROUP CLOSED id:" . $template_id); 1002 $query =
"SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_grp_status_open'";
1006 $group_open_id =
$row->obj_id;
1010 #var_dump("GROUP OPEN id:" . $template_id); 1016 if(!$course_non_member_id)
1018 $query =
"SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_crs_non_member'";
1022 $course_non_member_id =
$row->obj_id;
1029 $current_ops = $a_current_ops[
$a_type];
1036 $rbacadmin->copyRolePermissionIntersection(
1038 $this->
getId(), end($policy_stack),
1039 $a_id,$this->
getId()
1044 #echo "No template id for ".$a_id.' of type'.$a_type.'<br>'; 1046 #echo "ROLE ASSIGN: ".$rolf.' AID'.$a_id; 1047 if($a_id
and !
$GLOBALS[
'rbacreview']->isRoleAssignedToObject($this->
getId(),$a_id))
1049 $rbacadmin->assignRoleToFolder($this->
getId(),$a_id,
"n");
static _lookupLogin($a_user_id)
lookup login
$disk_quota
The disk quota in bytes.
static lookupTxtById($plugin_id, $lang_var)
getPresentationTitle()
return translated title for autogenerated roles
static _lookupRegisterAllowed()
get all roles that are activated in user registration
getPersonalWorkspaceDiskQuota()
Gets the minimal personal workspace disk quota imposed by this role.
const MODE_PROTECTED_DELETE_LOCAL_POLICIES
createPermissionIntersection($policy_stack, $a_current_ops, $a_id, $a_type)
Create course group permission intersection.
Class ilObject Basic functions for all objects.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
setParent($a_parent_ref)
set reference id of parent object this is neccessary for non RBAC protected objects!!! ...
toggleAssignUsersStatus($a_assign_users)
static _updateAuthMode($a_roles)
static _lookupTitle($a_id)
lookup object title
setAllowRegister($a_allow_register)
set allow_register of role
update()
updates a record "role" and write it into database public
updatePolicyStack(&$a_stack, $a_node)
Update policy stack.
static _getAuthMode($a_role_id)
static _resetAuthMode($a_auth_mode)
Reset auth mode to default.
deleteLocalPolicies($a_start, $a_policies, $a_filter)
Delete local policies.
static _getAssignUsersStatus($a_role_id)
static gatherFaPa($a_ref_id, array $a_role_ids, $a_add_action=false)
getAllowRegister()
get allow_register
static diffFaPa(array $a_old, array $a_new)
getDiskQuota()
Gets the minimal disk quota imposed by this role.
setTitle($a_title)
set object title
static createDefaultRole($a_title, $a_description, $a_tpl_name, $a_ref_id)
const MODE_PROTECTED_KEEP_LOCAL_POLICIES
static _deleteByRole($a_role_id)
static isAutoGenerated($a_role_id)
getId()
get object id public
static _lookupObjId($a_id)
isHandledObjectType($a_filter, $a_exclusion_filter, $a_type)
Check if type is filterer.
getTitle()
get object title public
static _getRolesByAuthMode($a_auth_mode)
Get roles by auth mode.
redirection script todo: (a better solution should control the processing via a xml file) ...
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
__construct($a_id=0, $a_call_by_reference=false)
Constructor public.
setPersonalWorkspaceDiskQuota($a_disk_quota)
Sets the minimal personal workspace disk quota imposed by this role.
static _getTranslation($a_role_title)
validate()
Validate role data.
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
adjustPermissions($a_mode, $a_nodes, $a_policies, $a_filter, $a_exclusion_filter=array())
Adjust permissions.
getParent()
get reference id of parent object
__getPermissionDefinitions()
const MODE_UNPROTECTED_DELETE_LOCAL_POLICIES
static add($a_action, $a_ref_id, array $a_diff, $a_source_ref_id=false)
const MODE_UNPROTECTED_KEEP_LOCAL_POLICIES
changeExistingObjects($a_start_node, $a_mode, $a_filter, $a_exclusion_filter=array())
Change existing objects.
static lookupGroupTye($a_id)
Lookup group type.
const EDIT_TEMPLATE_EXISTING
updateOperationStack(&$a_stack, $a_node, $a_init=false)
Update operation stack.
setDescription($a_desc)
set object description
static getLogger($a_component_id)
Get component logger.
read()
loads "role" from database private
static _lookupAllowRegister($a_role_id)
check whether role is allowed in user registration or not
setDiskQuota($a_disk_quota)
Sets the minimal disk quota imposed by this role.
assignData($a_data)
loads a record "role" from array public