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

consultation slot events are not editable/movable/deletable in fullcalendar, fixes #4375

Closes #4375

Merge request studip/studip!3188
parent 816e6c29
No related branches found
No related tags found
No related merge requests found
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
*/ */
class ConsultationSlot extends SimpleORMap class ConsultationSlot extends SimpleORMap
{ {
private const EVENT_PREFIX = 'Stud.IP-Consultation-Event#';
/** /**
* Configures the model. * Configures the model.
* @param array $config Configuration * @param array $config Configuration
...@@ -137,6 +139,14 @@ class ConsultationSlot extends SimpleORMap ...@@ -137,6 +139,14 @@ class ConsultationSlot extends SimpleORMap
]); ]);
} }
/**
* Returns whether the given event is an event for a consultation slot.
*/
public static function isSlotEvent(CalendarDate $event): bool
{
return str_starts_with($event->unique_id, self::EVENT_PREFIX);
}
/** /**
* Returns whether this slot is occupied (by a given user). * Returns whether this slot is occupied (by a given user).
* *
...@@ -195,10 +205,9 @@ class ConsultationSlot extends SimpleORMap ...@@ -195,10 +205,9 @@ class ConsultationSlot extends SimpleORMap
* @param User $user [description] * @param User $user [description]
* @return string unique event id * @return string unique event id
*/ */
protected function createEventId(User $user) protected function createEventId(User $user): string
{ {
$rand_id = md5(uniqid(self::class, true)); return self::EVENT_PREFIX . "{$this->id}:{$user->id}";
return "Termin{$rand_id}-{$user->id}";
} }
/** /**
......
...@@ -189,6 +189,15 @@ class CalendarDate extends SimpleORMap implements PrivacyObject ...@@ -189,6 +189,15 @@ class CalendarDate extends SimpleORMap implements PrivacyObject
public function isWritable(string $range_id) public function isWritable(string $range_id)
{ {
if (ConsultationSlot::isSlotEvent($this)) {
return false;
}
if ($this->author_id === $range_id) {
//The author may always modify one of their dates:
return true;
}
if (CalendarDateAssignment::exists([$range_id, $this->id])) { if (CalendarDateAssignment::exists([$range_id, $this->id])) {
//The date is in the calendar of the user/course //The date is in the calendar of the user/course
//and therefore, the user or course administrator (tutor, dozent) //and therefore, the user or course administrator (tutor, dozent)
......
...@@ -521,10 +521,6 @@ class CalendarDateAssignment extends SimpleORMap implements Event ...@@ -521,10 +521,6 @@ class CalendarDateAssignment extends SimpleORMap implements Event
public function isWritable(string $user_id): bool public function isWritable(string $user_id): bool
{ {
if ($this->calendar_date->author_id === $user_id) {
//The author may always modify one of their dates:
return true;
}
if ($this->calendar_date->isWritable($user_id)) { if ($this->calendar_date->isWritable($user_id)) {
//The date is writable. //The date is writable.
return true; return true;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment