Skip to content

Commit

Permalink
42613: BookingPool/Schedule: Editing a schedule is not protected with…
Browse files Browse the repository at this point in the history
… RBAC permissions / schedule is bound to other booking pool

Signed-off-by: Releasemanager <[email protected]>
  • Loading branch information
alex40724 authored and Releasemanager committed Dec 10, 2024
1 parent 41d326d commit 67787eb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Modules/BookingManager/Objects/class.ilBookingObjectGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ public function __construct(
$this->ref_id = $this->book_request->getRefId();
$this->ctrl->saveParameter($this, "object_id");

if ($this->object_id > 0 && ilBookingObject::lookupPoolId($this->object_id) !== $this->pool_gui->getObject()->getId()) {
throw new ilPermissionException("Booking object pool id does not match pool id.");
}

$this->rsv_ids = array_map('intval', $this->book_request->getReservationIdsFromString());
}

Expand Down
15 changes: 15 additions & 0 deletions Modules/BookingManager/Schedule/class.ilBookingSchedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,21 @@ protected function saveDefinition(): bool
return true;
}

public static function lookupPoolId(int $schedule_id): int
{
global $DIC;

$ilDB = $DIC->database();

$set = $ilDB->query("SELECT pool_id " .
" FROM booking_schedule" .
" WHERE booking_schedule_id = " . $ilDB->quote($schedule_id, 'integer'));
if ($rec = $ilDB->fetchAssoc($set)) {
return (int) $rec['pool_id'];
}
return 0;
}

/**
* Check if given pool has any defined schedules
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ public function __construct(
->gui()
->standardRequest();
$this->schedule_id = $this->book_request->getScheduleId();

if ($this->schedule_id > 0 && ilBookingSchedule::lookupPoolId($this->schedule_id) !== ilObject::_lookupObjId($this->ref_id)) {
throw new ilPermissionException("Schedule pool id does not match pool id.");
}

}

public function executeCommand(): void
Expand Down

0 comments on commit 67787eb

Please sign in to comment.