ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilOrgUnitPositionAccess Class Reference

Class ilOrgUnitPositionAccess. More...

+ Inheritance diagram for ilOrgUnitPositionAccess:
+ Collaboration diagram for ilOrgUnitPositionAccess:

Public Member Functions

 __construct ()
 ilOrgUnitPositionAccess constructor. More...
 
 filterUserIdsForCurrentUsersPositionsAndPermission (array $user_ids, $permission)
 
Parameters
int[]$user_ids List of ILIAS-User-IDs which shall be filtered
string$permission
See also
getAvailablePositionRelatedPermissions for available permissions
Exceptions
More...
 
 filterUserIdsForUsersPositionsAndPermission (array $user_ids, $for_user_id, $permission)
 
Parameters
int[]$user_ids List of ILIAS-User-IDs which shall be filtered
int$for_user_id
string$permission
See also
getAvailablePositionRelatedPermissions for available permissions
Exceptions
More...
 
 isCurrentUserBasedOnPositionsAllowedTo ($permission, array $on_user_ids)
 
Parameters
string$permission
int[]$on_user_ids List of ILIAS-User-IDs
See also
getAvailablePositionRelatedPermissions for available permissions
Returns
bool
More...
 
 isUserBasedOnPositionsAllowedTo ($which_user_id, $permission, array $on_user_ids)
 
Parameters
int$which_user_idPermission check for this ILIAS-User-ID
string$permission
int[]$on_user_ids List of ILIAS-User-IDs
See also
getAvailablePositionRelatedPermissions for available permissions
Returns
bool
More...
 
 filterUserIdsByPositionOfCurrentUser ($pos_perm, $ref_id, array $user_ids)
 
Parameters
string$pos_perm
int$ref_id
int[]$user_ids
See also
getAvailablePositionRelatedPermissions for available permissions
Returns
int[]
More...
 
 filterUserIdsByPositionOfUser ($user_id, $pos_perm, $ref_id, array $user_ids)
 
Parameters
int$user_id
string$pos_perm
int$ref_id
int[]$user_ids
See also
getAvailablePositionRelatedPermissions for available permissions
Returns
int[]
More...
 
 checkPositionAccess ($pos_perm, $ref_id)
 
Parameters
string$pos_perm
int$ref_idReference-ID of the desired Object in the tree
See also
getAvailablePositionRelatedPermissions for available permissions
Returns
bool
More...
 
 hasCurrentUserAnyPositionAccess ($ref_id)
 
Parameters
int$ref_id
Returns
bool
More...
 
 checkRbacOrPositionPermissionAccess ($rbac_perm, $pos_perm, $ref_id)
 
Parameters
string$rbac_perm
string$pos_permSee the list of available permissions in interface ilOrgUnitPositionAccessHandler
int$ref_idReference-ID of the desired Object in the tree
Returns
bool
More...
 
 filterUserIdsByRbacOrPositionOfCurrentUser ($rbac_perm, $pos_perm, $ref_id, array $user_ids)
 
Parameters
string$rbac_perm
string$pos_permSee the list of available permissions in interface ilOrgUnitPositionAccessHandler
int$ref_idReference-ID of the desired Object in the tree
int[]$user_ids
Returns
int[]
More...
 
 hasUserRBACorAnyPositionAccess ($rbac_perm, $ref_id)
 
Parameters
string$rbac_perm
int$ref_id
Returns
bool
More...
 

Protected Attributes

 $ua
 
 $set
 

Static Protected Attributes

static $ref_id_obj_type_map = array()
 

Private Member Functions

 dic ()
 
 getCurrentUsersId ()
 
 getTypeForRefId ($ref_id)
 
 getObjIdForRefId ($ref_id)
 
 isPositionActiveForRefId ($ref_id)
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilOrgUnitPositionAccess::__construct ( )

Member Function Documentation

◆ checkPositionAccess()

ilOrgUnitPositionAccess::checkPositionAccess (   $pos_perm,
  $ref_id 
)

Parameters
string$pos_perm
int$ref_idReference-ID of the desired Object in the tree
See also
getAvailablePositionRelatedPermissions for available permissions
Returns
bool

Implements ilOrgUnitPositionAccessHandler.

Definition at line 161 of file class.ilOrgUnitPositionAccess.php.

References ilOrgUnitOperationQueries\findByOperationString(), getCurrentUsersId(), getTypeForRefId(), and isPositionActiveForRefId().

Referenced by ilAccess\checkPositionAccess(), and checkRbacOrPositionPermissionAccess().

162  {
163  // If context is not activated, return same array of $user_ids
164  if (!$this->isPositionActiveForRefId($ref_id)) {
165  return false;
166  }
167 
168  $operation = ilOrgUnitOperationQueries::findByOperationString($pos_perm, $this->getTypeForRefId($ref_id));
169  if (!$operation) {
170  return false;
171  }
172  $current_user_id = $this->getCurrentUsersId();
173 
174  foreach ($this->ua->getPositionsOfUserId($current_user_id) as $position) {
175  $permissions = ilOrgUnitPermissionQueries::getSetForRefId($ref_id, $position->getId());
176  if ($permissions->isOperationIdSelected($operation->getOperationId())) {
177  return true;
178  }
179  }
180 
181  return false;
182  }
static findByOperationString($operation_string, $context_name)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkRbacOrPositionPermissionAccess()

ilOrgUnitPositionAccess::checkRbacOrPositionPermissionAccess (   $rbac_perm,
  $pos_perm,
  $ref_id 
)

Parameters
string$rbac_perm
string$pos_permSee the list of available permissions in interface ilOrgUnitPositionAccessHandler
int$ref_idReference-ID of the desired Object in the tree
Returns
bool

Implements ilOrgUnitPositionAndRBACAccessHandler.

Definition at line 211 of file class.ilOrgUnitPositionAccess.php.

References $DIC, checkPositionAccess(), and isPositionActiveForRefId().

Referenced by ilAccess\checkRbacOrPositionPermissionAccess().

212  {
213  global $DIC;
214  // If RBAC allows, just return true
215  if ($DIC->access()->checkAccess($rbac_perm, '', $ref_id)) {
216  return true;
217  }
218 
219  // If context is not activated, return same array of $user_ids
220  if (!$this->isPositionActiveForRefId($ref_id)) {
221  return false;
222  }
223 
224  return $this->checkPositionAccess($pos_perm, $ref_id);
225  }
checkPositionAccess($pos_perm, $ref_id)
Reference-ID of the desired Object in the treegetAvailablePositionRelatedPermissions for available pe...
global $DIC
Definition: saml.php:7
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dic()

ilOrgUnitPositionAccess::dic ( )
private
Returns

Definition at line 268 of file class.ilOrgUnitPositionAccess.php.

References $GLOBALS.

Referenced by getCurrentUsersId().

269  {
270  return $GLOBALS['DIC'];
271  }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
+ Here is the caller graph for this function:

◆ filterUserIdsByPositionOfCurrentUser()

ilOrgUnitPositionAccess::filterUserIdsByPositionOfCurrentUser (   $pos_perm,
  $ref_id,
array  $user_ids 
)

Parameters
string$pos_perm
int$ref_id
int[]$user_ids
See also
getAvailablePositionRelatedPermissions for available permissions
Returns
int[]

Implements ilOrgUnitPositionAccessHandler.

Definition at line 88 of file class.ilOrgUnitPositionAccess.php.

References filterUserIdsByPositionOfUser(), and getCurrentUsersId().

Referenced by ilAccess\filterUserIdsByPositionOfCurrentUser(), and filterUserIdsByRbacOrPositionOfCurrentUser().

89  {
90  // If context is not activated, return same array of $user_ids
91  if (!$this->set->getObjectPositionSettingsByType($this->getTypeForRefId($ref_id))->isActive()) {
92  return $user_ids;
93  }
94 
95  $current_user_id = $this->getCurrentUsersId();
96 
97  return $this->filterUserIdsByPositionOfUser($current_user_id, $pos_perm, $ref_id, $user_ids);
98  }
filterUserIdsByPositionOfUser($user_id, $pos_perm, $ref_id, array $user_ids)
$user_idsgetAvailablePositionRelatedPermissions for available permissionsint[]
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ filterUserIdsByPositionOfUser()

ilOrgUnitPositionAccess::filterUserIdsByPositionOfUser (   $user_id,
  $pos_perm,
  $ref_id,
array  $user_ids 
)

Parameters
int$user_id
string$pos_perm
int$ref_id
int[]$user_ids
See also
getAvailablePositionRelatedPermissions for available permissions
Returns
int[]

Implements ilOrgUnitPositionAccessHandler.

Definition at line 104 of file class.ilOrgUnitPositionAccess.php.

References $authority, ilOrgUnitOperationQueries\findByOperationString(), getTypeForRefId(), ilOrgUnitAuthority\OVER_EVERYONE, ilOrgUnitAuthority\SCOPE_SAME_ORGU, and ilOrgUnitAuthority\SCOPE_SUBSEQUENT_ORGUS.

Referenced by filterUserIdsByPositionOfCurrentUser(), and ilAccess\filterUserIdsByPositionOfUser().

105  {
106  // If context is not activated, return same array of $user_ids
107  if (!$this->set->getObjectPositionSettingsByType($this->getTypeForRefId($ref_id))->isActive()) {
108  return $user_ids;
109  }
110 
111  // $all_available_users = $this->ua->getUserIdsOfOrgUnit()
112  $operation = ilOrgUnitOperationQueries::findByOperationString($pos_perm, $this->getTypeForRefId($ref_id));
113  if (!$operation) {
114  return $user_ids;
115  }
116 
117  $allowed_user_ids = [];
118  foreach ($this->ua->getPositionsOfUserId($user_id) as $position) {
119  $permissions = ilOrgUnitPermissionQueries::getSetForRefId($ref_id, $position->getId());
120  if (!$permissions->isOperationIdSelected($operation->getOperationId())) {
121  continue;
122  }
123 
124  foreach ($position->getAuthorities() as $authority) {
125  switch ($authority->getOver()) {
127  switch ($authority->getScope()) {
129  $allowed = $this->ua->getUserIdsOfOrgUnitsOfUsersPosition($position->getId(), $user_id);
130  $allowed_user_ids = $allowed_user_ids + $allowed;
131  break;
133  $allowed = $this->ua->getUserIdsOfOrgUnitsOfUsersPosition($position->getId(), $user_id, true);
134  $allowed_user_ids = $allowed_user_ids + $allowed;
135  break;
136  }
137  break;
138  default:
139  switch ($authority->getScope()) {
141  $allowed = $this->ua->getUserIdsOfUsersOrgUnitsInPosition($user_id, $position->getId(), $authority->getOver());
142  $allowed_user_ids = $allowed_user_ids + $allowed;
143  break;
145  $allowed = $this->ua->getUserIdsOfUsersOrgUnitsInPosition($user_id, $position->getId(), $authority->getOver(), true);
146  $allowed_user_ids = $allowed_user_ids + $allowed;
147  break;
148  }
149  break;
150  }
151  }
152  }
153 
154  return array_intersect($user_ids, $allowed_user_ids);
155  }
static findByOperationString($operation_string, $context_name)
$authority
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ filterUserIdsByRbacOrPositionOfCurrentUser()

ilOrgUnitPositionAccess::filterUserIdsByRbacOrPositionOfCurrentUser (   $rbac_perm,
  $pos_perm,
  $ref_id,
array  $user_ids 
)

Parameters
string$rbac_perm
string$pos_permSee the list of available permissions in interface ilOrgUnitPositionAccessHandler
int$ref_idReference-ID of the desired Object in the tree
int[]$user_ids
Returns
int[]

Implements ilOrgUnitPositionAndRBACAccessHandler.

Definition at line 231 of file class.ilOrgUnitPositionAccess.php.

References $DIC, filterUserIdsByPositionOfCurrentUser(), and isPositionActiveForRefId().

Referenced by ilAccess\filterUserIdsByRbacOrPositionOfCurrentUser().

232  {
233  global $DIC;
234  // If RBAC allows, just return true
235  if ($DIC->access()->checkAccess($rbac_perm, '', $ref_id)) {
236  return $user_ids;
237  }
238  // If context is not activated, return same array of $user_ids
239  if (!$this->isPositionActiveForRefId($ref_id)) {
240  return $user_ids;
241  }
242 
243  return $this->filterUserIdsByPositionOfCurrentUser($pos_perm, $ref_id, $user_ids);
244  }
filterUserIdsByPositionOfCurrentUser($pos_perm, $ref_id, array $user_ids)
$user_idsgetAvailablePositionRelatedPermissions for available permissionsint[]
global $DIC
Definition: saml.php:7
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ filterUserIdsForCurrentUsersPositionsAndPermission()

ilOrgUnitPositionAccess::filterUserIdsForCurrentUsersPositionsAndPermission ( array  $user_ids,
  $permission 
)

Parameters
int[]$user_ids List of ILIAS-User-IDs which shall be filtered
string$permission
See also
getAvailablePositionRelatedPermissions for available permissions
Exceptions

Implements ilOrgUnitPositionAccessHandler.

Definition at line 38 of file class.ilOrgUnitPositionAccess.php.

References filterUserIdsForUsersPositionsAndPermission(), and getCurrentUsersId().

Referenced by ilAccess\filterUserIdsForCurrentUsersPositionsAndPermission().

39  {
40  $current_user_id = $this->getCurrentUsersId();
41 
42  return $this->filterUserIdsForUsersPositionsAndPermission($user_ids, $current_user_id, $permission);
43  }
filterUserIdsForUsersPositionsAndPermission(array $user_ids, $for_user_id, $permission)
$user_ids List of ILIAS-User-IDs which shall be filtered getAvailablePositionRelatedPermissions for a...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ filterUserIdsForUsersPositionsAndPermission()

ilOrgUnitPositionAccess::filterUserIdsForUsersPositionsAndPermission ( array  $user_ids,
  $for_user_id,
  $permission 
)

Parameters
int[]$user_ids List of ILIAS-User-IDs which shall be filtered
int$for_user_id
string$permission
See also
getAvailablePositionRelatedPermissions for available permissions
Exceptions

Implements ilOrgUnitPositionAccessHandler.

Definition at line 49 of file class.ilOrgUnitPositionAccess.php.

Referenced by filterUserIdsForCurrentUsersPositionsAndPermission(), ilAccess\filterUserIdsForUsersPositionsAndPermission(), and isUserBasedOnPositionsAllowedTo().

50  {
51  // FSX TODO no permission is checked or existing
52  $assignment_of_user = $this->ua->getAssignmentsOfUserId($for_user_id);
53  $other_users_in_same_org_units = [];
54  foreach ($assignment_of_user as $assignment) {
55  $other_users_in_same_org_units = $other_users_in_same_org_units + $this->ua->getUserIdsOfOrgUnit($assignment->getOrguId());
56  }
57 
58  return array_intersect($user_ids, $other_users_in_same_org_units);
59  }
+ Here is the caller graph for this function:

◆ getCurrentUsersId()

ilOrgUnitPositionAccess::getCurrentUsersId ( )
private
Returns
int

Definition at line 277 of file class.ilOrgUnitPositionAccess.php.

References dic().

Referenced by checkPositionAccess(), filterUserIdsByPositionOfCurrentUser(), filterUserIdsForCurrentUsersPositionsAndPermission(), hasCurrentUserAnyPositionAccess(), and isCurrentUserBasedOnPositionsAllowedTo().

278  {
279  return $this->dic()->user()->getId();
280  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getObjIdForRefId()

ilOrgUnitPositionAccess::getObjIdForRefId (   $ref_id)
private
Parameters
$ref_id
Returns
int

Definition at line 303 of file class.ilOrgUnitPositionAccess.php.

References ilObject2\_lookupObjectId().

Referenced by isPositionActiveForRefId().

304  {
305  return ilObject2::_lookupObjectId($ref_id);
306  }
static _lookupObjectId($a_ref_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTypeForRefId()

ilOrgUnitPositionAccess::getTypeForRefId (   $ref_id)
private
Parameters
$ref_id
Returns
mixed

Definition at line 288 of file class.ilOrgUnitPositionAccess.php.

References ilObject2\_lookupType().

Referenced by checkPositionAccess(), and filterUserIdsByPositionOfUser().

289  {
290  if (!isset(self::$ref_id_obj_type_map[$ref_id])) {
291  self::$ref_id_obj_type_map[$ref_id] = ilObject2::_lookupType($ref_id, true);
292  }
293 
294  return self::$ref_id_obj_type_map[$ref_id];
295  }
static _lookupType($a_id, $a_reference=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasCurrentUserAnyPositionAccess()

ilOrgUnitPositionAccess::hasCurrentUserAnyPositionAccess (   $ref_id)

Parameters
int$ref_id
Returns
bool

Implements ilOrgUnitPositionAccessHandler.

Definition at line 188 of file class.ilOrgUnitPositionAccess.php.

References getCurrentUsersId(), and isPositionActiveForRefId().

Referenced by ilAccess\hasCurrentUserAnyPositionAccess(), and hasUserRBACorAnyPositionAccess().

189  {
190  // If context is not activated, return same array of $user_ids
191  if (!$this->isPositionActiveForRefId($ref_id)) {
192  return false;
193  }
194 
195  $current_user_id = $this->getCurrentUsersId();
196 
197  foreach ($this->ua->getPositionsOfUserId($current_user_id) as $position) {
198  $permissions = ilOrgUnitPermissionQueries::getSetForRefId($ref_id, $position->getId());
199  if (count($permissions->getOperations()) > 0) {
200  return true;
201  }
202  }
203 
204  return false;
205  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasUserRBACorAnyPositionAccess()

ilOrgUnitPositionAccess::hasUserRBACorAnyPositionAccess (   $rbac_perm,
  $ref_id 
)

Parameters
string$rbac_perm
int$ref_id
Returns
bool

Implements ilOrgUnitPositionAndRBACAccessHandler.

Definition at line 250 of file class.ilOrgUnitPositionAccess.php.

References $DIC, and hasCurrentUserAnyPositionAccess().

Referenced by ilAccess\hasUserRBACorAnyPositionAccess().

251  {
252  global $DIC;
253  if ($DIC->access()->checkAccess($rbac_perm, '', $ref_id)) {
254  return true;
255  }
256 
257  return $this->hasCurrentUserAnyPositionAccess($ref_id);
258  }
global $DIC
Definition: saml.php:7
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isCurrentUserBasedOnPositionsAllowedTo()

ilOrgUnitPositionAccess::isCurrentUserBasedOnPositionsAllowedTo (   $permission,
array  $on_user_ids 
)

Parameters
string$permission
int[]$on_user_ids List of ILIAS-User-IDs
See also
getAvailablePositionRelatedPermissions for available permissions
Returns
bool

Implements ilOrgUnitPositionAccessHandler.

Definition at line 65 of file class.ilOrgUnitPositionAccess.php.

References getCurrentUsersId(), and isUserBasedOnPositionsAllowedTo().

Referenced by ilAccess\isCurrentUserBasedOnPositionsAllowedTo().

66  {
67  $current_user_id = $this->getCurrentUsersId();
68 
69  return $this->isUserBasedOnPositionsAllowedTo($current_user_id, $permission, $on_user_ids);
70  }
isUserBasedOnPositionsAllowedTo($which_user_id, $permission, array $on_user_ids)
Permission check for this ILIAS-User-ID $on_user_ids List of ILIAS-User-IDsgetAvailablePositionRelate...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isPositionActiveForRefId()

ilOrgUnitPositionAccess::isPositionActiveForRefId (   $ref_id)
private
Parameters
$ref_id
Returns
bool

Definition at line 314 of file class.ilOrgUnitPositionAccess.php.

References getObjIdForRefId().

Referenced by checkPositionAccess(), checkRbacOrPositionPermissionAccess(), filterUserIdsByRbacOrPositionOfCurrentUser(), and hasCurrentUserAnyPositionAccess().

315  {
316  $obj_id = $this->getObjIdForRefId($ref_id); // TODO this will change to ref_id!!
317 
318  return $this->set->isPositionAccessActiveForObject($obj_id);
319  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isUserBasedOnPositionsAllowedTo()

ilOrgUnitPositionAccess::isUserBasedOnPositionsAllowedTo (   $which_user_id,
  $permission,
array  $on_user_ids 
)

Parameters
int$which_user_idPermission check for this ILIAS-User-ID
string$permission
int[]$on_user_ids List of ILIAS-User-IDs
See also
getAvailablePositionRelatedPermissions for available permissions
Returns
bool

Implements ilOrgUnitPositionAccessHandler.

Definition at line 76 of file class.ilOrgUnitPositionAccess.php.

References filterUserIdsForUsersPositionsAndPermission().

Referenced by isCurrentUserBasedOnPositionsAllowedTo(), and ilAccess\isUserBasedOnPositionsAllowedTo().

77  {
78  $filtered_user_ids = $this->filterUserIdsForUsersPositionsAndPermission($on_user_ids, $which_user_id, $permission);
79 
80  return ($on_user_ids === array_intersect($on_user_ids, $filtered_user_ids)
81  && $filtered_user_ids === array_intersect($filtered_user_ids, $on_user_ids));
82  }
filterUserIdsForUsersPositionsAndPermission(array $user_ids, $for_user_id, $permission)
$user_ids List of ILIAS-User-IDs which shall be filtered getAvailablePositionRelatedPermissions for a...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $ref_id_obj_type_map

ilOrgUnitPositionAccess::$ref_id_obj_type_map = array()
staticprotected

Definition at line 22 of file class.ilOrgUnitPositionAccess.php.

◆ $set

ilOrgUnitPositionAccess::$set
protected

Definition at line 18 of file class.ilOrgUnitPositionAccess.php.

◆ $ua

ilOrgUnitPositionAccess::$ua
protected

Definition at line 14 of file class.ilOrgUnitPositionAccess.php.


The documentation for this class was generated from the following file: