aboutsummaryrefslogtreecommitdiff
path: root/lib/classes/Event.class.php
blob: 6254884e16d30302608227a015681c6b66ea0080 (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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

interface Event
{
    const PERMISSION_FORBIDDEN = 0;
    const PERMISSION_CONFIDENTIAL = 1;
    const PERMISSION_READABLE = 2;
    const PERMISSION_DELETABLE = 3;
    const PERMISSION_WRITABLE = 4;
    const PERMISSION_OWN = 5;
    
    /**
     * Returns a list of all categories the event belongs to.
     * Returns an empty string if no permission.
     *
     * @return string All categories as list.
     */
    public function toStringCategories();

    /**
     * Returns an array that represents the recurrence rule for this event.
     * If an index is given, returns only this field of the rule.
     * 
     * @return array|string The array with th recurrence rule or only one field.
     */
    public function getRecurrence($index = null);
    
    /**
     * TODO Wird das noch benötigt?
     */
    public function getType();
    
    /**
     * Returns the title of this event.
     * If the user has not the permission Event::PERMISSION_READABLE,
     * the title is "Keine Berechtigung.".
     * 
     * @return string 
     */
    public function getTitle();
    
    /**
     * Returns the starttime as unix timestamp of this event.
     *
     * @return int The starttime of this event as a unix timestamp
     */
    public function getStart();
    
    /**
     * Returns the endtime as unix timestamp of this event.
     *
     * @return int the endtime of this event as a unix timestamp
     */
    public function getEnd();
    
    /**
     * Returns the duration of this event in seconds.
     *
     * @return int the duration of this event in seconds
     */
    function getDuration();
    
    /**
     * Returns the location.
     * Without permission or the location is not set an empty string is returned.
     * 
     * @return string The location
     */
    function getLocation();
    
    /**
     * Returns the global uni id of this event.
     * 
     * @return string The global unique id.
     */
    public function getUid();
    
    /**
     * Returns the description of the topic.
     * If the user has no permission or the event has no topic
     * or the topics have no descritopn an empty string is returned.
     *
     * @return String the description
     */
    function getDescription();
    
    /**
     * Returns the index of the category.
     * If the user has no permission, 255 is returned.
     * 
     * @see config/config.inc.php $TERMIN_TYP
     * @return int The index of the category
     */
    public function getCategory();
    
    /**
     * Returns the user id of the last editor.
     * 
     * @return null|int The editor id.
     */
    public function getEditorId();
    
    /**
     * Returns whether the event is a all day event.
     * 
     * @return 
     */
    public function isDayEvent();
    
    /**
     * Returns the accessibility of this event. The value is not influenced by
     * the permission of the actual user.
     * 
     * According to RFC5545 the accessibility (property CLASS) is represented
     * by the 3 values PUBLIC, PRIVATE and CONFIDENTIAL. In RFC5545 the default
     * value is PUBLIC. In Stud.IP the default is PRIVATE.
     * 
     * @return string The accessibility as string.
     */
    function getAccessibility();
    
    /**
     * Returns the unix timestamp of the last change.
     *
     * @access public
     */
    public function getChangeDate();
    
    /**
     * Returns the date time the event was imported.
     * 
     * TODO not sure if we need this anymore
     * 
     * @return int Date time of import as unix timestamp:
     */
    function getImportDate();
    
    /**
     * Returns all properties of this event.
     * The name of the properties correspond to the properties of the
     * iCalendar calendar data exchange format. There are a few properties with
     * the suffix STUDIP_ which have no eqivalent in the iCalendar format.
     * 
     * DTSTART: The start date-time as unix timestamp.
     * DTEND: The end date-time as unix timestamp.
     * SUMMARY: The short description (title) that will be displayed in the views.
     * DESCRIPTION: The long description.
     * UID: The global unique id of this event.
     * CLASS:
     * CATEGORIES: A comma separated list of categories.
     * PRIORITY: The priority.
     * LOCATION: The location.
     * EXDATE: A comma separated list of unix timestamps.
     * CREATED: The creation date-time as unix timestamp.
     * LAST-MODIFIED: The date-time of last modification as unix timestamp.
     * DTSTAMP: The cration date-time of this instance of the event as unix
     * timestamp.
     * RRULE: All data for the recurrence rule for this event as array.
     * EVENT_TYPE:
     * 
     * 
     * @return array The properties of this event.
     */
    public function getProperties();
    
    /**
     * Returns the value of property with given name.
     * 
     * @param type $name See CalendarEvent::getProperties() for accepted values.
     * @return mixed The value of the property.
     * @throws InvalidArgumentException
     */
    public function getProperty($name);
    
    public function havePermission($permission, $user_id = null);
    
    public function getPermission($user_id = null);
    
    /**
     * Returns the priority in a human readable form.
     * If the user has no permission an epmty string will be returned.
     * 
     * @return string The priority as a string.
     */
    public function toStringPriority();
    
    /**
     * Returns the accessibilty in a human readable form.
     * If the user has no permission an epmty string will be returned.
     * 
     * @return string The accessibility as string.
     */
    public function toStringAccessibility();
    
    /**
     * Returns a string representation of the recurrence rule.
     * If $only_type is true returns only the type of the recurrence.
     *
     * @param bool $only_type If true returns only the type of recurrence.
     * @return string The recurrence rule - human readable
     */
    public function toStringRecurrence($only_type = false);
    
    /**
     * Returns the author of this event as user object.
     * 
     * @return User|null User object.
     */
    public function getAuthor();
    
    /**
     * Returns the editor of this event as user object.
     * 
     * @return User|null User object.
     */
    public function getEditor();
}