ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilObjOrgUnitAccess.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
12{
13
26 public static function _getCommands() : array
27 {
28 $commands = [
29 [
30 'permission' => 'read',
31 'cmd' => 'view',
32 'lang_var' => 'show',
33 'default' => true,
34 ],
35 ];
36
37 return $commands;
38 }
39
40
46 public static function _checkAccessStaff($ref_id) : bool
47 {
48 global $DIC;
49
50 return ($DIC->access()->checkAccess('write', '', $ref_id)
51 || $DIC->access()->checkAccess('view_learning_progress', '', $ref_id))
52 && $DIC->access()->checkAccess('read', '', $ref_id);
53 }
54
60 public static function _checkAccessSettings(int $ref_id) : bool
61 {
62 global $DIC;
63
64 return $DIC->access()->checkAccess('write', '', $ref_id);
65 }
66
72 public static function _checkAccessExport(int $ref_id) : bool
73 {
74 global $DIC;
75
76 return $DIC->access()->checkAccess('write', '', $ref_id);
77 }
78
84 public static function _checkAccessTypes(int $ref_id) : bool
85 {
86 global $DIC;
87
88 return $DIC->access()->checkAccess('write', '', $ref_id);
89 }
90
96 public static function _checkAccessPositions(int $ref_id) : bool
97 {
98 global $DIC;
99
100 return $DIC->access()->checkAccess('write', '', $ref_id);
101 }
102
103
109 public static function _checkAccessStaffRec($ref_id) : bool
110 {
111 global $DIC;
112
113 return ($DIC->access()->checkAccess('write', '', $ref_id)
114 || $DIC->access()->checkAccess('view_learning_progress_rec', '', $ref_id))
115 && $DIC->access()->checkAccess('read', '', $ref_id);
116 }
117
118
124 public static function _checkAccessAdministrateUsers($ref_id) : bool
125 {
126 global $DIC;
127
128 return ilUserAccountSettings::getInstance()->isLocalUserAdministrationEnabled()
129 && $DIC->access()->checkAccess('cat_administrate_users', '', $ref_id);
130 }
131
132
139 public static function _checkAccessToUserLearningProgress($ref_id, $usr_id) : bool
140 {
141 global $DIC;
142
143 //Permission to view the Learning Progress of an OrgUnit: Employees
144 if ($DIC->access()->checkAccess('view_learning_progress', '', $ref_id)
145 && in_array($usr_id, ilObjOrgUnitTree::_getInstance()->getEmployees($ref_id, false))
146 ) {
147 return true;
148 }
149 //Permission to view the Learning Progress of an OrgUnit: Superiors
150 if ($DIC->access()->checkAccess('view_learning_progress', '', $ref_id)
151 && in_array($usr_id, ilObjOrgUnitTree::_getInstance()->getSuperiors($ref_id, false))
152 ) {
153 return true;
154 }
155
156 //Permission to view the Learning Progress of an OrgUnit or SubOrgUnit!: Employees
157 if ($DIC->access()->checkAccess('view_learning_progress_rec', '', $ref_id)
158 && in_array($usr_id, ilObjOrgUnitTree::_getInstance()->getEmployees($ref_id, true))
159 ) {
160 return true;
161 }
162
163 //Permission to view the Learning Progress of an OrgUnit or SubOrgUnit!: Superiors
164 if ($DIC->access()->checkAccess('view_learning_progress_rec', '', $ref_id)
165 && in_array($usr_id, ilObjOrgUnitTree::_getInstance()->getSuperiors($ref_id, true))
166 ) {
167 return true;
168 }
169
170 return false;
171 }
172
173
179 public static function _checkGoto($a_target) : bool
180 {
181 global $DIC;
182
183 $t_arr = explode('_', $a_target);
184 if ($t_arr[0] !== 'orgu' || ((int) $t_arr[1]) <= 0) {
185 return false;
186 }
187 if ($DIC->access()->checkAccess('read', '', $t_arr[1])) {
188 return true;
189 }
190
191 return false;
192 }
193}
An exception for terminatinating execution or to throw for unit testing.
Class ilObjOrgUnitAccess.
static _getCommands()
get commands
static _checkAccessStaffRec($ref_id)
static _checkAccessTypes(int $ref_id)
static _checkAccessToUserLearningProgress($ref_id, $usr_id)
static _checkAccessStaff($ref_id)
static _checkAccessExport(int $ref_id)
static _checkAccessSettings(int $ref_id)
static _checkAccessAdministrateUsers($ref_id)
static _checkAccessPositions(int $ref_id)
Class ilObjectAccess.
static getInstance()
Singelton get instance.
global $DIC
Definition: goto.php:24