Skip to content
Snippets Groups Projects
Commit b0741c7c authored by Elmar Ludwig's avatar Elmar Ludwig Committed by Jan-Hendrik Willms
Browse files

check if the user needs booking rights on the resource, fixes #2570

Closes #2570

Merge request studip/studip!2159
parent 85f00e97
No related branches found
No related tags found
No related merge requests found
...@@ -485,11 +485,21 @@ class ResourceBooking extends SimpleORMap implements PrivacyObject, Studip\Calen ...@@ -485,11 +485,21 @@ class ResourceBooking extends SimpleORMap implements PrivacyObject, Studip\Calen
$this->booking_user = User::findCurrent(); $this->booking_user = User::findCurrent();
} }
$derived_resource = $this->resource->getDerivedClassInstance();
// check if the user needs booking rights on the resource
if (
$this->isFieldDirty('resource_id')
|| $this->isFieldDirty('repetition_interval')
|| $this->begin < $this->getPristineValue('begin')
|| $this->end > $this->getPristineValue('end')
|| $this->preparation_time > $this->getPristineValue('preparation_time')
|| $this->repeat_end > $this->getPristineValue('repeat_end')
) {
//Check if the user has booking rights on the resource. //Check if the user has booking rights on the resource.
//The user must have either permanent permissions or they have to //The user must have either permanent permissions or they have to
//have booking rights by a temporary permission in this moment //have booking rights by a temporary permission in this moment
//(the moment this booking is saved).
$derived_resource = $this->resource->getDerivedClassInstance();
$user_has_booking_rights = $derived_resource->userHasBookingRights( $user_has_booking_rights = $derived_resource->userHasBookingRights(
$this->booking_user, $this->begin, $this->end $this->booking_user, $this->begin, $this->end
); );
...@@ -501,6 +511,7 @@ class ResourceBooking extends SimpleORMap implements PrivacyObject, Studip\Calen ...@@ -501,6 +511,7 @@ class ResourceBooking extends SimpleORMap implements PrivacyObject, Studip\Calen
) )
); );
} }
}
$time_intervals = $this->calculateTimeIntervals(true); $time_intervals = $this->calculateTimeIntervals(true);
$time_interval_overlaps = []; $time_interval_overlaps = [];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment