aboutsummaryrefslogtreecommitdiff
path: root/lib/calendar/EventData.class.php
blob: 9ab4377d8317b1544e6f5d81b8a2f337ef30da79 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?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 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 = ''
    )
    {
        $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;
    }


    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!
        return [
            'resourceId' => $this->range_id,
            'start' => $this->begin->format('Y-m-d\TH:i:s'),
            'end' => $this->end->format('Y-m-d\TH:i:s'),
            'title' => $this->title,
            'classNames' => $this->event_classes,
            'textColor' => $this->text_colour,
            'color' => $this->background_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
        ];
    }
}