ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\BookingManager\Access\AccessManager Class Reference
+ Collaboration diagram for ILIAS\BookingManager\Access\AccessManager:

Public Member Functions

 __construct (InternalDomainService $domain, \ilAccessHandler $access)
 
 canManageObjects (int $ref_id, int $current_user=0)
 
 canManageSettings (int $ref_id, int $current_user=0)
 
 canManageParticipants (int $ref_id, int $current_user=0)
 
 filterManageableParticipants (int $ref_id, array $participant_ids)
 
 canManageAllReservations (int $ref_id, int $current_user=0)
 
 canManageOwnReservations (int $ref_id, int $current_user=0)
 
 canManageReservationForUser (int $ref_id, int $target_user, int $current_user=0)
 
 canRetrieveNotificationsForOwnReservationsByObjId (int $book_obj_id, int $current_user=0)
 
 canRetrieveNotificationsForAllReservationsByObjId (int $book_obj_id, int $current_user=0)
 
 getParentGroupCourse (int $ref_id)
 
 canManageMembersOfParent (int $ref_id)
 
 validateBookingObjId (int $book_obj_id, int $pool_id)
 
 validateScheduleId (int $schedule_id, int $pool_id)
 

Protected Member Functions

 getCurrentUserId (int $user_id)
 
 hasPermissionOnAnyReference (string $perm, int $uid, int $obj_id)
 

Protected Attributes

ilTree $tree
 
int $user_id
 
int $ref_id
 
ilAccessHandler $access
 
InternalDomainService $domain
 

Detailed Description

Definition at line 25 of file AccessManager.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\BookingManager\Access\AccessManager::__construct ( InternalDomainService  $domain,
\ilAccessHandler  $access 
)

Definition at line 33 of file AccessManager.php.

36 {
37 $this->domain = $domain;
38 $this->access = $access;
39 $this->tree = $this->domain->repositoryTree();
40 }

References ILIAS\BookingManager\Access\AccessManager\$access, ILIAS\BookingManager\Access\AccessManager\$domain, and ILIAS\Repository\access().

+ Here is the call graph for this function:

Member Function Documentation

◆ canManageAllReservations()

ILIAS\BookingManager\Access\AccessManager::canManageAllReservations ( int  $ref_id,
int  $current_user = 0 
)

Definition at line 86 of file AccessManager.php.

89 : bool {
90 $current_user = $this->getCurrentUserId($current_user);
91 return $this->access->checkAccessOfUser($current_user, "manage_all_reservations", "", $ref_id);
92 }

◆ canManageMembersOfParent()

ILIAS\BookingManager\Access\AccessManager::canManageMembersOfParent ( int  $ref_id)

Definition at line 164 of file AccessManager.php.

164 : bool
165 {
166 if (($parent = $this->getParentGroupCourse($ref_id)) !== null) {
167 return ($this->access->checkAccess("manage_members", "", (int) $parent["ref_id"])) ;
168 }
169 return false;
170 }

References $ref_id, and ILIAS\Repository\access().

+ Here is the call graph for this function:

◆ canManageObjects()

ILIAS\BookingManager\Access\AccessManager::canManageObjects ( int  $ref_id,
int  $current_user = 0 
)

Definition at line 50 of file AccessManager.php.

53 : bool {
54 $current_user = $this->getCurrentUserId($current_user);
55 return $this->access->checkAccessOfUser($current_user, "write", "", $ref_id);
56 }

◆ canManageOwnReservations()

ILIAS\BookingManager\Access\AccessManager::canManageOwnReservations ( int  $ref_id,
int  $current_user = 0 
)

Definition at line 94 of file AccessManager.php.

97 : bool {
98 $current_user = $this->getCurrentUserId($current_user);
99 return $this->access->checkAccessOfUser($current_user, "manage_own_reservations", "", $ref_id) ||
100 $this->access->checkAccessOfUser($current_user, "manage_all_reservations", "", $ref_id);
101 }

◆ canManageParticipants()

ILIAS\BookingManager\Access\AccessManager::canManageParticipants ( int  $ref_id,
int  $current_user = 0 
)

Definition at line 66 of file AccessManager.php.

69 : bool {
70 $current_user = $this->getCurrentUserId($current_user);
71 return $this->access->checkAccessOfUser($current_user, "write", "", $ref_id);
72 }

◆ canManageReservationForUser()

ILIAS\BookingManager\Access\AccessManager::canManageReservationForUser ( int  $ref_id,
int  $target_user,
int  $current_user = 0 
)

Definition at line 103 of file AccessManager.php.

107 : bool {
108 $current_user = $this->getCurrentUserId($current_user);
109 if ($target_user === $current_user) {
110 return $this->access->checkAccessOfUser($current_user, "manage_own_reservations", "", $ref_id) ||
111 $this->access->checkAccessOfUser($current_user, "manage_all_reservations", "", $ref_id);
112 }
113 return $this->access->checkAccessOfUser($current_user, "manage_all_reservations", "", $ref_id);
114 }

References $ref_id, and ILIAS\Repository\access().

+ Here is the call graph for this function:

◆ canManageSettings()

ILIAS\BookingManager\Access\AccessManager::canManageSettings ( int  $ref_id,
int  $current_user = 0 
)

Definition at line 58 of file AccessManager.php.

61 : bool {
62 $current_user = $this->getCurrentUserId($current_user);
63 return $this->access->checkAccessOfUser($current_user, "write", "", $ref_id);
64 }

◆ canRetrieveNotificationsForAllReservationsByObjId()

ILIAS\BookingManager\Access\AccessManager::canRetrieveNotificationsForAllReservationsByObjId ( int  $book_obj_id,
int  $current_user = 0 
)

Definition at line 124 of file AccessManager.php.

127 : bool {
128 $current_user = $this->getCurrentUserId($current_user);
129 return $this->hasPermissionOnAnyReference("manage_all_reservations", $current_user, $book_obj_id);
130 }
hasPermissionOnAnyReference(string $perm, int $uid, int $obj_id)

◆ canRetrieveNotificationsForOwnReservationsByObjId()

ILIAS\BookingManager\Access\AccessManager::canRetrieveNotificationsForOwnReservationsByObjId ( int  $book_obj_id,
int  $current_user = 0 
)

Definition at line 116 of file AccessManager.php.

119 : bool {
120 $current_user = $this->getCurrentUserId($current_user);
121 return $this->hasPermissionOnAnyReference("manage_own_reservations", $current_user, $book_obj_id);
122 }

◆ filterManageableParticipants()

ILIAS\BookingManager\Access\AccessManager::filterManageableParticipants ( int  $ref_id,
array  $participant_ids 
)

Definition at line 74 of file AccessManager.php.

77 : array {
78 return $this->access->filterUserIdsByRbacOrPositionOfCurrentUser(
79 'render',
80 'render',
81 $ref_id,
82 $participant_ids
83 );
84 }

◆ getCurrentUserId()

ILIAS\BookingManager\Access\AccessManager::getCurrentUserId ( int  $user_id)
protected

Definition at line 42 of file AccessManager.php.

42 : int
43 {
44 if ($user_id > 0) {
45 return $user_id;
46 }
47 return $this->domain->user()->getId();
48 }

References ILIAS\BookingManager\Access\AccessManager\$user_id.

◆ getParentGroupCourse()

ILIAS\BookingManager\Access\AccessManager::getParentGroupCourse ( int  $ref_id)

Definition at line 146 of file AccessManager.php.

146 : ?array
147 {
149 if (($par_ref_id = $tree->checkForParentType($ref_id, "grp")) > 0) {
150 return [
151 "ref_id" => $par_ref_id,
152 "type" => "grp"
153 ];
154 }
155 if (($par_ref_id = $tree->checkForParentType($ref_id, "crs")) > 0) {
156 return [
157 "ref_id" => $par_ref_id,
158 "type" => "crs"
159 ];
160 }
161 return null;
162 }
checkForParentType(int $a_ref_id, string $a_type, bool $a_exclude_source_check=false)
Check for parent type e.g check if a folder (ref_id 3) is in a parent course obj => checkForParentTyp...

References $ref_id.

◆ hasPermissionOnAnyReference()

ILIAS\BookingManager\Access\AccessManager::hasPermissionOnAnyReference ( string  $perm,
int  $uid,
int  $obj_id 
)
protected

Definition at line 132 of file AccessManager.php.

136 : bool {
138 foreach (\ilObject::_getAllReferences($obj_id) as $ref_id) {
139 if ($access->checkAccessOfUser($uid, $perm, "", $ref_id)) {
140 return true;
141 }
142 }
143 return false;
144 }
static _getAllReferences(int $id)
get all reference ids for object ID
checkAccessOfUser(int $a_user_id, string $a_permission, string $a_cmd, int $a_ref_id, string $a_type="", ?int $a_obj_id=null, ?int $a_tree_id=null)
check access for an object (provide $a_type and $a_obj_id if available for better performance)

References $ref_id.

◆ validateBookingObjId()

ILIAS\BookingManager\Access\AccessManager::validateBookingObjId ( int  $book_obj_id,
int  $pool_id 
)

Definition at line 172 of file AccessManager.php.

172 : void
173 {
174 if ($book_obj_id > 0 && \ilBookingObject::lookupPoolId($book_obj_id) !== $pool_id) {
175 throw new \ilPermissionException("Booking object pool id does not match pool id.");
176 }
177 }
static lookupPoolId(int $object_id)

References ilBookingObject\lookupPoolId().

+ Here is the call graph for this function:

◆ validateScheduleId()

ILIAS\BookingManager\Access\AccessManager::validateScheduleId ( int  $schedule_id,
int  $pool_id 
)

Definition at line 179 of file AccessManager.php.

179 : void
180 {
181 $sm = $this->domain->schedules($pool_id);
182 if (!$sm->hasScheduleId($schedule_id)) {
183 throw new \ilPermissionException("Schedule id does not match pool id.");
184 }
185 }

Field Documentation

◆ $access

ilAccessHandler ILIAS\BookingManager\Access\AccessManager::$access
protected

◆ $domain

InternalDomainService ILIAS\BookingManager\Access\AccessManager::$domain
protected

◆ $ref_id

int ILIAS\BookingManager\Access\AccessManager::$ref_id
protected

Definition at line 29 of file AccessManager.php.

◆ $tree

ilTree ILIAS\BookingManager\Access\AccessManager::$tree
protected

Definition at line 27 of file AccessManager.php.

◆ $user_id

int ILIAS\BookingManager\Access\AccessManager::$user_id
protected

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