ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 $DIC;
49
50 $ilUser = $DIC['ilUser'];
51
52 if ($ilUser->getId() == $a_user_id) {
53 $this->user = $ilUser;
54 } else {
55 $this->user = ilObjectFactory::getInstanceByObjId($a_user_id, false);
56 }
58 $this->read();
59 }
60
69 public static function _getInstanceByUserId($a_user_id)
70 {
71 if (isset(self::$instances[$a_user_id])) {
72 return self::$instances[$a_user_id];
73 }
74 return self::$instances[$a_user_id] = new ilCalendarUserSettings($a_user_id);
75 }
76
83 public static function _getInstance()
84 {
85 global $DIC;
86
87 $ilUser = $DIC['ilUser'];
88
89 return self::_getInstanceByUserId($ilUser->getId());
90 }
91
99 public function getTimeZone()
100 {
101 return $this->timezone;
102 }
103
111 public function setTimeZone($a_tz)
112 {
113 $this->timezone = $a_tz;
114 }
115
120 public function getExportTimeZoneType()
121 {
123 }
124
130 {
131 $this->export_tz_type = $a_type;
132 }
133
138 public function getExportTimeZone()
139 {
140 switch ($this->getExportTimeZoneType()) {
142 return $this->getTimeZone();
143
145 include_once './Services/Calendar/classes/class.ilTimeZone.php';
146 return ilTimeZone::UTC;
147 }
148 }
149
150
151
159 public function setWeekStart($a_weekstart)
160 {
161 $this->weekstart = $a_weekstart;
162 }
163
170 public function getWeekStart()
171 {
172 return (int) $this->weekstart;
173 }
174
180 public function setDayStart($a_start)
181 {
182 $this->day_start = $a_start;
183 }
184
189 public function getDayStart()
190 {
191 return $this->day_start;
192 }
193
199 public function setDayEnd($a_end)
200 {
201 $this->day_end = $a_end;
202 }
203
208 public function getDayEnd()
209 {
210 return $this->day_end;
211 }
212
220 public function setDateFormat($a_format)
221 {
222 $this->date_format = $a_format;
223 }
224
231 public function getDateFormat()
232 {
233 return $this->date_format;
234 }
235
243 public function setTimeFormat($a_format)
244 {
245 $this->time_format = $a_format;
246 }
247
254 public function getTimeFormat()
255 {
256 return $this->time_format;
257 }
258
265 public function getCalendarSelectionType()
266 {
268 }
269
276 {
277 $this->calendar_selection_type = $a_type;
278 }
279
285 public function setShowWeeks($a_val)
286 {
287 $this->show_weeks = $a_val;
288 }
289
295 public function getShowWeeks()
296 {
297 return $this->show_weeks;
298 }
299
305 public function save()
306 {
307 $this->user->writePref('user_tz', $this->getTimeZone());
308 $this->user->writePref('export_tz_type', $this->getExportTimeZoneType());
309 $this->user->writePref('weekstart', $this->getWeekStart());
310 $this->user->writePref('date_format', $this->getDateFormat());
311 $this->user->writePref('time_format', $this->getTimeFormat());
312 $this->user->writePref('calendar_selection_type', $this->getCalendarSelectionType());
313 $this->user->writePref('day_start', $this->getDayStart());
314 $this->user->writePref('day_end', $this->getDayEnd());
315 $this->user->writePref('show_weeks', $this->getShowWeeks());
316 }
317
318
324 protected function read()
325 {
326 $this->timezone = $this->user->getTimeZone();
327 $this->export_tz_type = (
328 ($this->user->getPref('export_tz_type') !== false) ?
329 $this->user->getPref('export_tz_type') :
331 );
332 $this->date_format = $this->user->getDateFormat();
333 $this->time_format = $this->user->getTimeFormat();
334 if (($weekstart = $this->user->getPref('weekstart')) === false) {
335 $weekstart = $this->settings->getDefaultWeekStart();
336 }
337 $this->calendar_selection_type = $this->user->getPref('calendar_selection_type') ?
338 $this->user->getPref('calendar_selection_type') :
340
341 $this->weekstart = $weekstart;
342
343 $this->setDayStart(
344 $this->user->getPref('day_start') !== false ?
345 $this->user->getPref('day_start') :
346 $this->settings->getDefaultDayStart()
347 );
348 $this->setDayEnd(
349 $this->user->getPref('day_end') !== false ?
350 $this->user->getPref('day_end') :
351 $this->settings->getDefaultDayEnd()
352 );
353 $this->setShowWeeks(
354 $this->user->getPref('show_weeks') !== false ?
355 $this->user->getPref('show_weeks') :
356 $this->settings->getShowWeeks()
357 );
358 }
359}
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
$DIC
Definition: xapitoken.php:46