aboutsummaryrefslogtreecommitdiff
path: root/lib/classes/calendar/EventData.php
diff options
context:
space:
mode:
authorMarcus Eibrink-Lunzenauer <lunzenauer@elan-ev.de>2024-06-18 13:18:06 +0000
committerMarcus Eibrink-Lunzenauer <lunzenauer@elan-ev.de>2024-06-18 13:18:06 +0000
commit33fd1358507b4a5abb3dcebe78d407d0567717c1 (patch)
tree6bd8f6959da4c3fc1b8907c0bbc28eb9e10d4a5a /lib/classes/calendar/EventData.php
parent42d46671c0309bddb71a91bbfdc5f2fa2e44384e (diff)
Deprecate `StudipAutoloader` and use composer's `autoload`
Closes #4282 Merge request studip/studip!3099
Diffstat (limited to 'lib/classes/calendar/EventData.php')
-rw-r--r--lib/classes/calendar/EventData.php114
1 files changed, 114 insertions, 0 deletions
diff --git a/lib/classes/calendar/EventData.php b/lib/classes/calendar/EventData.php
new file mode 100644
index 0000000..95e89b0
--- /dev/null
+++ b/lib/classes/calendar/EventData.php
@@ -0,0 +1,114 @@
+<?php
+
+
+namespace Studip\Calendar;
+
+
+class EventData
+{
+ public $begin;
+ public $end;
+ public $title;
+ public $event_classes;
+ public $text_colour;
+ public $background_colour;
+ public $editable;
+ public $object_class;
+ public $object_id;
+ public $parent_object_class;
+ public $parent_object_id;
+ public $range_type;
+ public $range_id;
+ public $view_urls;
+ public $api_urls;
+ public $icon;
+ public $border_colour;
+ public $all_day;
+
+ public function __construct(
+ \DateTime $begin,
+ \DateTime $end,
+ string $title,
+ Array $event_classes,
+ string $text_colour,
+ string $background_colour,
+ bool $editable,
+ string $object_class,
+ string $object_id,
+ string $parent_object_class,
+ string $parent_object_id,
+ string $range_type,
+ string $range_id,
+ Array $view_urls = [],
+ Array $api_urls = [],
+ string $icon = '',
+ string $border_colour = '',
+ bool $all_day = false
+ )
+ {
+ $this->begin = $begin;
+ $this->end = $end;
+ $this->title = $title;
+ $this->event_classes = $event_classes;
+ $this->text_colour = $text_colour;
+ $this->background_colour = $background_colour;
+ $this->editable = $editable;
+ $this->object_class = $object_class;
+ $this->object_id = $object_id;
+ $this->parent_object_class = $parent_object_class;
+ $this->parent_object_id = $parent_object_id;
+ $this->range_type = $range_type;
+ $this->range_id = $range_id;
+ $this->view_urls = $view_urls;
+ $this->api_urls = $api_urls;
+ $this->icon = $icon;
+ $this->border_colour = $border_colour ?: $background_colour;
+ $this->all_day = $all_day;
+ }
+
+
+ public function toFullcalendarEvent()
+ {
+ // Note: The timezone must not be transmitted or
+ // the events may be shifted when there is a timezone
+ // or daylight saving time difference between the server
+ // and the client!
+ // To display all-day events correctly in fullcalendar
+ // reduce the start and end to date without time and add one day
+ // to the end date...
+ if ($this->all_day) {
+ $fc_date = [
+ 'allDay' => true,
+ 'start' => $this->begin->format('Y-m-d'),
+ 'end' => $this->end->modify('+1 day')->format('Y-m-d')
+ ];
+ } else {
+ $fc_date = [
+ 'allDay' => false,
+ 'start' => $this->begin->format('Y-m-d\TH:i:s'),
+ 'end' => $this->end->format('Y-m-d\TH:i:s')
+ ];
+ }
+
+ return $fc_date + [
+ 'resourceId' => $this->range_id,
+ 'title' => $this->title,
+ 'classNames' => $this->event_classes,
+ 'textColor' => $this->text_colour,
+ 'color' => $this->background_colour,
+ 'borderColor' => $this->border_colour,
+ 'editable' => $this->editable,
+ 'studip_weekday_begin' => $this->begin->format('N'),
+ 'studip_weekday_end' => $this->end->format('N'),
+ 'studip_object_class' => $this->object_class,
+ 'studip_object_id' => $this->object_id,
+ 'studip_parent_object_class' => $this->parent_object_class,
+ 'studip_parent_object_id' => $this->parent_object_id,
+ 'studip_range_type' => $this->range_type,
+ 'studip_range_id' => $this->range_id,
+ 'studip_view_urls' => $this->view_urls,
+ 'studip_api_urls' => $this->api_urls,
+ 'icon' => $this->icon
+ ];
+ }
+}