ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilCalendarUserSettings.php
Go to the documentation of this file.
1 <?php
2 /*
3  * Created on 06.03.2008
4  *
5  * To change the template for this generated file go to
6  * Window - Preferences - PHPeclipse - PHP - Code Templates
7  */
8 
9 include_once('./Services/Calendar/classes/class.ilCalendarSettings.php');
10 
12 {
15 
16  public static $instances = array();
17 
18  protected $user;
19  protected $settings;
20 
22  private $timezone;
23  private $weekstart;
24  private $time_format;
25 
33  private function __construct($a_user_id)
34  {
35  global $ilUser;
36 
37  if($ilUser->getId() == $a_user_id)
38  {
39  $this->user = $ilUser;
40  }
41  else
42  {
43  $this->user = ilObjectFactory::getInstanceByObjId($a_user_id,false);
44  }
45  $this->settings = ilCalendarSettings::_getInstance();
46  $this->read();
47  }
48 
57  public static function _getInstanceByUserId($a_user_id)
58  {
59  if(isset(self::$instances[$a_user_id]))
60  {
61  return self::$instances[$a_user_id];
62  }
63  return self::$instances[$a_user_id] = new ilCalendarUserSettings($a_user_id);
64  }
65 
72  public static function _getInstance()
73  {
74  global $ilUser;
75 
76  return self::_getInstanceByUserId($ilUser->getId());
77  }
78 
86  public function getTimeZone()
87  {
88  return $this->timezone;
89  }
90 
98  public function setTimeZone($a_tz)
99  {
100  $this->timezone = $a_tz;
101  }
102 
110  public function setWeekStart($a_weekstart)
111  {
112  $this->weekstart = $a_weekstart;
113  }
114 
121  public function getWeekStart()
122  {
123  return (int) $this->weekstart;
124  }
125 
133  public function setTimeFormat($a_format)
134  {
135  $this->time_format = $a_format;
136  }
137 
144  public function getTimeFormat()
145  {
146  return $this->time_format;
147  }
148 
155  public function getCalendarSelectionType()
156  {
158  }
159 
165  public function setCalendarSelectionType($a_type)
166  {
167  $this->calendar_selection_type = $a_type;
168  }
169 
175  public function save()
176  {
177  $this->user->writePref('user_tz',$this->getTimeZone());
178  $this->user->writePref('weekstart',$this->getWeekStart());
179  $this->user->writePref('time_format',$this->getTimeFormat());
180  $this->user->writePref('calendar_selection_type',$this->getCalendarSelectionType());
181  }
182 
183 
189  protected function read()
190  {
191  $this->timezone = $this->user->getTimeZone();
192  $this->time_format = $this->user->getTimeFormat();
193  if(($weekstart = $this->user->getPref('weekstart')) === false)
194  {
195  $weekstart = $this->settings->getDefaultWeekStart();
196  }
197  $this->calendar_selection_type = $this->user->getPref('calendar_selection_type') ?
198  $this->user->getPref('calendar_selection_type') :
200 
201  $this->weekstart = $weekstart;
202  }
203 
204 }
205 ?>