ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilCalendarUserSettings.php
Go to the documentation of this file.
1<?php
9include_once('./Services/Calendar/classes/class.ilCalendarSettings.php');
10
12{
15
18
19 public static $instances = array();
20
21 protected $user;
22 protected $settings;
23
25 private $timezone;
27 private $weekstart;
28 private $time_format;
29 private $date_format;
30
31 private $day_start;
32 private $day_end;
33
37 private $show_weeks = true;
38
46 private function __construct($a_user_id)
47 {
48 global $ilUser;
49
50 if ($ilUser->getId() == $a_user_id) {
51 $this->user = $ilUser;
52 } else {
53 $this->user = ilObjectFactory::getInstanceByObjId($a_user_id, false);
54 }
56 $this->read();
57 }
58
67 public static function _getInstanceByUserId($a_user_id)
68 {
69 if (isset(self::$instances[$a_user_id])) {
70 return self::$instances[$a_user_id];
71 }
72 return self::$instances[$a_user_id] = new ilCalendarUserSettings($a_user_id);
73 }
74
81 public static function _getInstance()
82 {
83 global $ilUser;
84
85 return self::_getInstanceByUserId($ilUser->getId());
86 }
87
95 public function getTimeZone()
96 {
97 return $this->timezone;
98 }
99
107 public function setTimeZone($a_tz)
108 {
109 $this->timezone = $a_tz;
110 }
111
116 public function getExportTimeZoneType()
117 {
119 }
120
126 {
127 $this->export_tz_type = $a_type;
128 }
129
134 public function getExportTimeZone()
135 {
136 switch ($this->getExportTimeZoneType()) {
138 return $this->getTimeZone();
139
141 include_once './Services/Calendar/classes/class.ilTimeZone.php';
142 return ilTimeZone::UTC;
143 }
144 }
145
146
147
155 public function setWeekStart($a_weekstart)
156 {
157 $this->weekstart = $a_weekstart;
158 }
159
166 public function getWeekStart()
167 {
168 return (int) $this->weekstart;
169 }
170
176 public function setDayStart($a_start)
177 {
178 $this->day_start = $a_start;
179 }
180
185 public function getDayStart()
186 {
187 return $this->day_start;
188 }
189
195 public function setDayEnd($a_end)
196 {
197 $this->day_end = $a_end;
198 }
199
204 public function getDayEnd()
205 {
206 return $this->day_end;
207 }
208
216 public function setDateFormat($a_format)
217 {
218 $this->date_format = $a_format;
219 }
220
227 public function getDateFormat()
228 {
229 return $this->date_format;
230 }
231
239 public function setTimeFormat($a_format)
240 {
241 $this->time_format = $a_format;
242 }
243
250 public function getTimeFormat()
251 {
252 return $this->time_format;
253 }
254
261 public function getCalendarSelectionType()
262 {
264 }
265
272 {
273 $this->calendar_selection_type = $a_type;
274 }
275
281 public function setShowWeeks($a_val)
282 {
283 $this->show_weeks = $a_val;
284 }
285
291 public function getShowWeeks()
292 {
293 return $this->show_weeks;
294 }
295
301 public function save()
302 {
303 $this->user->writePref('user_tz', $this->getTimeZone());
304 $this->user->writePref('export_tz_type', $this->getExportTimeZoneType());
305 $this->user->writePref('weekstart', $this->getWeekStart());
306 $this->user->writePref('date_format', $this->getDateFormat());
307 $this->user->writePref('time_format', $this->getTimeFormat());
308 $this->user->writePref('calendar_selection_type', $this->getCalendarSelectionType());
309 $this->user->writePref('day_start', $this->getDayStart());
310 $this->user->writePref('day_end', $this->getDayEnd());
311 $this->user->writePref('show_weeks', $this->getShowWeeks());
312 }
313
314
320 protected function read()
321 {
322 $this->timezone = $this->user->getTimeZone();
323 $this->export_tz_type = (
324 ($this->user->getPref('export_tz_type') !== false) ?
325 $this->user->getPref('export_tz_type') :
327 );
328 $this->date_format = $this->user->getDateFormat();
329 $this->time_format = $this->user->getTimeFormat();
330 if (($weekstart = $this->user->getPref('weekstart')) === false) {
331 $weekstart = $this->settings->getDefaultWeekStart();
332 }
333 $this->calendar_selection_type = $this->user->getPref('calendar_selection_type') ?
334 $this->user->getPref('calendar_selection_type') :
336
337 $this->weekstart = $weekstart;
338
339 $this->setDayStart(
340 $this->user->getPref('day_start') !== false ?
341 $this->user->getPref('day_start') :
342 $this->settings->getDefaultDayStart()
343 );
344 $this->setDayEnd(
345 $this->user->getPref('day_end') !== false ?
346 $this->user->getPref('day_end') :
347 $this->settings->getDefaultDayEnd()
348 );
349 $this->setShowWeeks(
350 $this->user->getPref('show_weeks') !== false ?
351 $this->user->getPref('show_weeks') :
352 $this->settings->getShowWeeks()
353 );
354 }
355}
user()
Definition: user.php:4
An exception for terminatinating execution or to throw for unit testing.
static _getInstance()
get singleton instance
static _getInstance()
get instance for logged in user
getCalendarSelectionType()
get calendar selection type ("MyMembership" or "Selected Items")
static _getInstanceByUserId($a_user_id)
get singleton instance
setExportTimeZoneType($a_type)
Set export timezone type.
getExportTimeZoneType()
Get export timezone setting.
setTimeFormat($a_format)
set time format
__construct($a_user_id)
Constructor.
setWeekStart($a_weekstart)
set week start
getExportTimeZone()
Get export timezone.
setDateFormat($a_format)
set date format
setCalendarSelectionType($a_type)
set calendar selection type
setDayStart($a_start)
Set start of day.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
settings()
Definition: settings.php:2
$ilUser
Definition: imgupload.php:18
$a_type
Definition: workflow.php:92