aboutsummaryrefslogtreecommitdiff
path: root/lib/models/resources/ResourceBooking.class.php
diff options
context:
space:
mode:
authorViktoria Wiebe <vwiebe@uos.de>2022-05-17 14:12:55 +0200
committerViktoria Wiebe <vwiebe@uos.de>2022-05-17 15:17:59 +0200
commit1aef9a527df5ee121f8dd5bf97dc9e54f24edff2 (patch)
tree9fe1be14bb4771d5a8fd38627b31ede65ce568e0 /lib/models/resources/ResourceBooking.class.php
parent0986a50fff5c2caae35c1c7a667bbd078770fdfd (diff)
add linked error message to request list under room management and make code DRYertic-477
Diffstat (limited to 'lib/models/resources/ResourceBooking.class.php')
-rw-r--r--lib/models/resources/ResourceBooking.class.php89
1 files changed, 89 insertions, 0 deletions
diff --git a/lib/models/resources/ResourceBooking.class.php b/lib/models/resources/ResourceBooking.class.php
index 7ecf281..d9c51eb 100644
--- a/lib/models/resources/ResourceBooking.class.php
+++ b/lib/models/resources/ResourceBooking.class.php
@@ -1872,4 +1872,93 @@ class ResourceBooking extends SimpleORMap implements PrivacyObject, Studip\Calen
restoreLanguage();
}
+
+ /**
+ * This method converts overlap data about an overlapping booking
+ * to a string that can be used to output overlap information to the user.
+ * Only one overlap is converted by this method. For multiple overlaps
+ * this method must be called multiple times.
+ *
+ * @param ResourceBooking $booking The overlapping booking.
+ *
+ * @return string A string representation of the overlap.
+ */
+ public function getOverlapMessage()
+ {
+ $message = '';
+
+ if ($this->booking_type == '2') {
+ $message .= sprintf(
+ _('Vom %1$s, %2$s Uhr bis zum %3$s, %4$s Uhr (Sperrzeit)') . "\n",
+ date("d.m.Y", $this->begin),
+ date("H:i", $this->begin),
+ date("d.m.Y", $this->end),
+ date("H:i", $this->end)
+ );
+ } else {
+ $course = Course::find($this->course_id);
+
+ if ($course) {
+ $user_has_permissions = $GLOBALS['perm']->have_studip_perm(
+ 'dozent',
+ $course->id,
+ $GLOBALS['user']->id
+ );
+ $course_link = null;
+ if ($user_has_permissions) {
+ $course_link = URLHelper::getLink(
+ 'dispatch.php/course/timesrooms/index',
+ [
+ 'cid' => $course->id
+ ]
+ );
+ $planner_link = $this->resource->getLinkForAction(
+ 'booking_plan',
+ $this->resource->id,
+ ['defaultDate' => date('Y-m-d', $this->begin)]
+ );
+ $planner_msg = sprintf(
+ _('<a href="%1$s">%2$s von %3$s bis %4$s</a>'),
+ $planner_link,
+ date('d.m.Y', $this->begin),
+ date('H:i', $this->begin),
+ date('H:i', $this->end)
+ );
+ } else {
+ $course_link = URLHelper::getLink(
+ 'dispatch.php/course/details',
+ [
+ 'sem_id' => $course->id
+ ]
+ );
+ $planner_msg = sprintf(
+ _('%1$s von %2$s bis %3$s'),
+ date('d.m.Y', $this->begin),
+ date('H:i', $this->begin),
+ date('H:i', $this->end)
+ );
+ }
+
+ $message .= sprintf(
+ _('Am %1$s Uhr durch Veranstaltung %2$s') . "\n",
+ $planner_msg,
+ sprintf(
+ '<a href="%1$s">%2$s</a>',
+ $course_link,
+ htmlReady($course->name)
+ )
+ );
+ } else {
+ $message .= sprintf(
+ _('Am %1$s von %2$s bis %3$s Uhr belegt von "%4$s"') . "\n",
+ date("d.m.Y", $this->begin),
+ date("H:i", $this->begin),
+ date("H:i", $this->end),
+ htmlReady($this->description)
+ );
+ }
+ }
+
+ return $message;
+ }
}