5 require_once
"./Services/Object/classes/class.ilObject.php";
6 require_once(
'./Services/Repository/classes/class.ilObjectPlugin.php');
53 public function __construct($a_id = 0, $a_call_by_reference =
false)
57 $this->logger = $DIC->logger()->ac();
59 $this->disk_quota = 0;
60 $this->wsp_disk_quota = 0;
61 parent::__construct($a_id, $a_call_by_reference);
79 $res =
$ilDB->query(
"SELECT obj_id FROM object_data " .
80 " WHERE type=" .
$ilDB->quote(
"rolt",
"text") .
81 " AND title=" .
$ilDB->quote($a_tpl_name,
"text"));
83 $tpl_id =
$row->obj_id;
90 include_once
'./Services/AccessControl/classes/class.ilObjRole.php';
92 $role->setTitle($a_title);
93 $role->setDescription($a_description);
96 $GLOBALS[
'DIC'][
'rbacadmin']->assignRoleToFolder($role->getId(), $a_ref_id,
'y');
98 $GLOBALS[
'DIC'][
'rbacadmin']->copyRoleTemplatePermissions(
105 $ops =
$GLOBALS[
'DIC'][
'rbacreview']->getOperationsOfRole(
110 $GLOBALS[
'DIC'][
'rbacadmin']->grantPermission(
129 if (substr($this->
getTitle(), 0, 3) ==
'il_') {
130 $ilErr->setMessage(
'msg_role_reserved_prefix');
147 $this->assign_users = (int) $a_assign_users;
151 return $this->assign_users ? $this->assign_users : 0;
158 $ilDB = $DIC[
'ilDB'];
160 $query =
"SELECT assign_users FROM role_data WHERE role_id = " .
$ilDB->quote($a_role_id,
'integer') .
" ";
163 return $row->assign_users ? true :
false;
176 $ilDB = $DIC[
'ilDB'];
178 $query =
"SELECT * FROM role_data WHERE role_id= " .
$ilDB->quote($this->
id,
'integer') .
" ";
181 if (
$res->numRows() > 0) {
187 $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);
216 $ilDB = $DIC[
'ilDB'];
218 $query =
"UPDATE role_data SET " .
219 "allow_register= " .
$ilDB->quote($this->allow_register,
'integer') .
", " .
223 "WHERE role_id= " .
$ilDB->quote($this->
id,
'integer') .
" ";
244 $ilDB = $DIC[
'ilDB'];
246 $this->
id = parent::create();
248 $query =
"INSERT INTO role_data " .
249 "(role_id,allow_register,assign_users,disk_quota,wsp_disk_quota) " .
251 "(" .
$ilDB->quote($this->
id,
'integer') .
"," .
270 if (empty($a_allow_register)) {
271 $a_allow_register == 0;
274 $this->allow_register = (int) $a_allow_register;
285 return $this->allow_register ? $this->allow_register :
false;
298 $this->disk_quota = $a_disk_quota;
326 $this->wsp_disk_quota = $a_disk_quota;
353 $ilDB = $DIC[
'ilDB'];
355 $query =
"SELECT * FROM role_data " .
356 "JOIN object_data ON object_data.obj_id = role_data.role_id " .
357 "WHERE allow_register = 1";
361 while ($role =
$ilDB->fetchAssoc(
$res)) {
362 $roles[] = array(
"id" => $role[
"obj_id"],
363 "title" => $role[
"title"],
364 "auth_mode" => $role[
'auth_mode']);
380 $ilDB = $DIC[
'ilDB'];
382 $query =
"SELECT * FROM role_data " .
383 " WHERE role_id =" .
$ilDB->quote($a_role_id,
'integer');
386 if ($role_rec =
$ilDB->fetchAssoc(
$res)) {
387 if ($role_rec[
"allow_register"]) {
403 $this->
parent = $a_parent_ref;
424 public function delete()
430 $ilDB = $DIC[
'ilDB'];
433 if (
$rbacreview->hasMultipleAssignments($this->getId())) {
448 $last_role_user_ids = array();
449 if ($this->
getParent() == ROLE_FOLDER_ID) {
456 foreach ($user_ids as $user_id) {
461 if (count($role_ids) == 1) {
462 $last_role_user_ids[] = $user_id;
468 if (count($last_role_user_ids) > 0) {
469 $user_names = array();
470 foreach ($last_role_user_ids as $user_id) {
478 $users = implode(
', ', $user_names);
480 $this->
ilias->raiseError($this->lng->txt(
"msg_user_last_role1") .
" " .
481 $users .
"<br/>" . $this->lng->txt(
"msg_user_last_role2"), $this->
ilias->error_obj->WARNING);
487 include_once(
'./Services/LDAP/classes/class.ilLDAPRoleGroupMappingSettings.php');
494 $query =
"DELETE FROM role_data WHERE role_id = " .
$ilDB->quote($this->
getId(),
'integer');
497 include_once
'Services/AccessControl/classes/class.ilRoleDesktopItem.php';
499 $role_desk_item_obj->deleteAll();
515 return count(
$rbacreview->assignedUsers($this->getId()));
524 $role_title = self::_removeObjectId($a_role_title);
526 if (preg_match(
"/^il_./", $role_title)) {
527 return $lng->txt($role_title);
530 return $a_role_title;
535 $role_title_parts = explode(
'_', $a_role_title);
537 $test2 = (int) $role_title_parts[3];
539 unset($role_title_parts[3]);
542 return implode(
'_', $role_title_parts);
552 public static function getSubObjects($a_obj_type, $a_add_admin_objects)
559 $lng = $DIC->language();
560 $subs =
$objDefinition->getSubObjectsRecursively($a_obj_type,
true, $a_add_admin_objects);
570 foreach ($subs as $subtype =>
$def) {
571 if (in_array(
$def[
"name"], $filter)) {
578 $translation =
$lng->txt(
"obj_" . $subtype);
580 $translation =
$lng->txt(
'objs_' . $subtype);
583 $sorted[$subtype] =
$def;
584 $sorted[$subtype][
'translation'] = $translation;
594 $ilDB = $DIC[
'ilDB'];
596 foreach ($a_roles as $role_id => $auth_mode) {
597 $query =
"UPDATE role_data SET " .
598 "auth_mode= " .
$ilDB->quote($auth_mode,
'text') .
" " .
599 "WHERE role_id= " .
$ilDB->quote($role_id,
'integer') .
" ";
608 $ilDB = $DIC[
'ilDB'];
610 $query =
"SELECT auth_mode FROM role_data " .
611 "WHERE role_id= " .
$ilDB->quote($a_role_id,
'integer') .
" ";
615 return $row[
'auth_mode'];
629 $ilDB = $DIC[
'ilDB'];
631 $query =
"SELECT * FROM role_data " .
632 "WHERE auth_mode = " .
$ilDB->quote($a_auth_mode,
'text');
636 $roles[] =
$row->role_id;
653 $ilDB = $DIC[
'ilDB'];
655 $query =
"UPDATE role_data SET auth_mode = 'default' WHERE auth_mode = " .
$ilDB->quote($a_auth_mode,
'text');
665 $ilDB = $DIC[
'ilDB'];
670 $operation_info =
$rbacreview->getOperationAssignment();
671 foreach ($operation_info as
$info) {
675 $rbac_objects[$info[
'typ_id']] = array(
"obj_id" => $info[
'typ_id'],
676 "type" => $info[
'type']);
681 :
$lng->txt($info[
'type'] .
"_" . $info[
'operation']);
682 if (substr($info[
'operation'], 0, 7) ==
"create_" &&
686 $rbac_operations[$info[
'typ_id']][$info[
'ops_id']] = array(
687 "ops_id" => $info[
'ops_id'],
688 "title" => $info[
'operation'],
691 return array($rbac_objects,$rbac_operations);
707 public function changeExistingObjects($a_start_node, $a_mode, $a_filter, $a_exclusion_filter = array(),$a_operation_mode = self::MODE_READ_OPERATIONS, $a_operation_stack = [])
711 $tree = $DIC->repositoryTree();
718 $all_local_policies =
$rbacreview->getObjectsWithStopedInheritance($this->
getId());
721 $local_policies = array();
722 foreach ($all_local_policies as $lp) {
724 $local_policies[] = $lp;
730 case self::MODE_UNPROTECTED_DELETE_LOCAL_POLICIES:
731 case self::MODE_PROTECTED_DELETE_LOCAL_POLICIES:
733 #$local_policies = array($a_start_node == ROOT_FOLDER_ID ? SYSTEM_FOLDER_ID : $a_start_node); 736 $this->
adjustPermissions($a_mode,
$nodes, $local_policies, $a_filter, $a_exclusion_filter, $a_operation_mode, $a_operation_stack);
739 #var_dump(memory_get_peak_usage()); 740 #var_dump(memory_get_usage()); 755 $local_policies = array();
756 foreach ($a_policies as $policy) {
757 if ($policy == $a_start
or $policy == SYSTEM_FOLDER_ID) {
758 $local_policies[] = $policy;
762 $local_policies[] = $policy;
767 return $local_policies;
778 protected function adjustPermissions($a_mode, $a_nodes, $a_policies, $a_filter, $a_exclusion_filter = array(), $a_operation_mode = self::MODE_READ_OPERATIONS, $a_operation_stack = [])
784 $tree = $DIC[
'tree'];
786 $operation_stack = array();
787 $policy_stack = array();
788 $node_stack = array();
790 $start_node = current($a_nodes);
791 array_push($node_stack, $start_node);
794 if ($a_operation_mode == self::MODE_READ_OPERATIONS) {
798 $operation_stack = $a_operation_stack;
801 $this->logger->debug(
'adjust permissions operation stack');
802 $this->logger->dump($operation_stack);
804 include_once
"Services/AccessControl/classes/class.ilRbacLog.php";
807 $local_policy =
false;
808 foreach ($a_nodes as $node) {
809 $cmp_node = end($node_stack);
810 while ($relation =
$tree->getRelationOfNodes($node, $cmp_node)) {
814 $GLOBALS[
'DIC'][
'ilLog']->write(__METHOD__ .
': Handling sibling/none relation.');
815 array_pop($operation_stack);
816 array_pop($policy_stack);
817 array_pop($node_stack);
818 $cmp_node = end($node_stack);
819 $local_policy =
false;
826 $GLOBALS[
'DIC'][
'ilLog']->write(__METHOD__ .
': Handling child/equals/parent ' . $relation);
836 if ($node[
'child'] == $start_node[
'child']) {
838 if ($rbac_log_active) {
839 $rbac_log_roles =
$rbacreview->getParentRoleIds($node[
'child'],
false);
844 $perms = end($operation_stack);
847 (array) $perms[$node[
'type']],
852 if ($rbac_log_active) {
862 if (in_array($node[
'child'], $a_policies)
and ($node[
'child'] != SYSTEM_FOLDER_ID)) {
863 $local_policy =
true;
866 array_push($node_stack, $node);
875 if ($rbac_log_active) {
876 $rbac_log_roles =
$rbacreview->getParentRoleIds($node[
'child'],
false);
881 if (($a_mode == self::MODE_UNPROTECTED_DELETE_LOCAL_POLICIES
or 882 $a_mode == self::MODE_UNPROTECTED_KEEP_LOCAL_POLICIES)
and ($node[
'type'] ==
'crs')) {
884 $perms = end($operation_stack);
888 array_push($node_stack, $node);
893 if (($a_mode == self::MODE_UNPROTECTED_DELETE_LOCAL_POLICIES
or 894 $a_mode == self::MODE_UNPROTECTED_KEEP_LOCAL_POLICIES)
and ($node[
'type'] ==
'grp')) {
896 $perms = end($operation_stack);
900 array_push($node_stack, $node);
905 $perms = end($operation_stack);
909 (array) $perms[$node[
'type']],
913 if ($rbac_log_active) {
931 $admin = $DIC->rbac()->admin();
932 $review = $DIC->rbac()->review();
933 if ($a_operation_mode == self::MODE_READ_OPERATIONS) {
934 $admin->grantPermission(
940 elseif ($a_operation_mode == self::MODE_ADD_OPERATIONS) {
941 $current_operations = $review->getRoleOperationsOnObject(
945 $this->logger->debug(
'Current operations');
946 $this->logger->dump($current_operations);
948 $new_ops = array_unique(array_merge($a_permissions, $current_operations));
949 $this->logger->debug(
'New operations');
950 $this->logger->dump($new_ops);
952 $admin->grantPermission(
958 elseif ($a_operation_mode == self::MODE_REMOVE_OPERATIONS) {
959 $current_operations = $review->getRoleOperationsOnObject(
963 $this->logger->debug(
'Current operations');
964 $this->logger->dump($current_operations);
966 $new_ops = array_diff($current_operations, $a_permissions);
968 $admin->grantPermission(
985 if (in_array(
$a_type, $a_exclusion_filter)) {
989 if (in_array(
'all', $a_filter)) {
992 return in_array(
$a_type, $a_filter);
1007 $has_policies = null;
1008 $policy_origin = null;
1010 if ($a_node == ROOT_FOLDER_ID) {
1011 $has_policies =
true;
1012 $policy_origin = ROLE_FOLDER_ID;
1014 $has_policies =
$rbacreview->getLocalPolicies($a_node);
1015 $policy_origin = $a_node;
1018 $parent_roles =
$rbacreview->getParentRoleIds($a_node,
false);
1019 if ($parent_roles[$this->
getId()]) {
1022 $parent_roles[$this->
getId()][
'parent']
1029 if (!$has_policies) {
1051 $has_policies = null;
1052 $policy_origin = null;
1054 if ($a_node == ROOT_FOLDER_ID) {
1055 $has_policies =
true;
1056 $policy_origin = ROLE_FOLDER_ID;
1058 $has_policies =
$rbacreview->getLocalPolicies($a_node);
1059 $policy_origin = $a_node;
1062 if (!$has_policies) {
1066 $a_stack[] = $policy_origin;
1081 $ilDB = $DIC[
'ilDB'];
1085 static $course_non_member_id = null;
1086 static $group_non_member_id = null;
1087 static $group_open_id = null;
1088 static $group_closed_id = null;
1094 include_once
'./Modules/Group/classes/class.ilObjGroup.php';
1096 #var_dump("GROUP TYPE",$type); 1099 if (!$group_closed_id) {
1100 $query =
"SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_grp_status_closed'";
1103 $group_closed_id =
$row->obj_id;
1107 #var_dump("GROUP CLOSED id:" . $template_id); 1112 if (!$group_open_id) {
1113 $query =
"SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_grp_status_open'";
1116 $group_open_id =
$row->obj_id;
1120 #var_dump("GROUP OPEN id:" . $template_id); 1126 if (!$course_non_member_id) {
1127 $query =
"SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_crs_non_member'";
1130 $course_non_member_id =
$row->obj_id;
1137 $current_ops = $a_current_ops[
$a_type];
1152 #echo "No template id for ".$a_id.' of type'.$a_type.'<br>'; 1154 #echo "ROLE ASSIGN: ".$rolf.' AID'.$a_id; 1155 if ($a_id
and !
$GLOBALS[
'DIC'][
'rbacreview']->isRoleAssignedToObject($this->
getId(), $a_id)) {
static _lookupLogin($a_user_id)
lookup login
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
$disk_quota
The disk quota in bytes.
static getPossibleRemoteTypes($a_with_captions=false)
Get all possible remote object types.
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.
static ecsConfigured()
Checks if an ecs server is configured.
const MODE_PROTECTED_DELETE_LOCAL_POLICIES
createPermissionIntersection($policy_stack, $a_current_ops, $a_id, $a_type)
Create course group permission intersection.
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.
const MODE_REMOVE_OPERATIONS
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
const MODE_READ_OPERATIONS
static _deleteByRole($a_role_id)
static isAutoGenerated($a_role_id)
foreach($_POST as $key=> $value) $res
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.
static _lookupType($a_id, $a_reference=false)
lookup object type
getParent()
get reference id of parent object
const MODE_ADD_OPERATIONS
__getPermissionDefinitions()
update($pash, $contents, Config $config)
changeExistingObjects($a_start_node, $a_mode, $a_filter, $a_exclusion_filter=array(), $a_operation_mode=self::MODE_READ_OPERATIONS, $a_operation_stack=[])
Change existing objects.
static _removeObjectId($a_role_title)
const MODE_UNPROTECTED_DELETE_LOCAL_POLICIES
adjustPermissions($a_mode, $a_nodes, $a_policies, $a_filter, $a_exclusion_filter=array(), $a_operation_mode=self::MODE_READ_OPERATIONS, $a_operation_stack=[])
Adjust permissions.
static add($a_action, $a_ref_id, array $a_diff, $a_source_ref_id=false)
const MODE_UNPROTECTED_KEEP_LOCAL_POLICIES
changeExistingObjectsGrantPermissions($a_role_id, $a_permissions, $a_ref_id, $a_operation_mode)
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.
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
assignData($a_data)
loads a record "role" from array public