ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilCalendarUserSettingsGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 include_once('Services/Calendar/classes/class.ilCalendarUserSettings.php');
25 include_once('Services/Calendar/classes/class.ilCalendarSettings.php');
26 
38 {
39  protected $tpl;
40  protected $lng;
41  protected $user;
42  protected $settings;
43 
44 
52  public function __construct()
53  {
54  global $ilUser,$tpl,$lng,$ilCtrl;
55 
56  $this->tpl = $tpl;
57  $this->lng = $lng;
58  $this->lng->loadLanguageModule('dateplaner');
59  $this->lng->loadLanguageModule('jscalendar');
60 
61  $this->ctrl = $ilCtrl;
62 
63  $this->user = $ilUser;
64  $this->settings = ilCalendarSettings::_getInstance();
65  $this->user_settings = ilCalendarUserSettings::_getInstanceByUserId($this->user->getId());
66 
67  }
68 
69 
76  public function executeCommand()
77  {
78  global $ilUser, $ilSetting;
79 
80 
81  $next_class = $this->ctrl->getNextClass();
82 
83  switch($next_class)
84  {
85  default:
86  $cmd = $this->ctrl->getCmd("show");
87  $this->$cmd();
88  break;
89  }
90  return true;
91  }
92 
100  public function show()
101  {
102  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.user_settings.html','Services/Calendar');
103 
104  $this->initSettingsForm();
105  $this->tpl->setVariable('CAL_SETTINGS',$this->form->getHTML());
106  }
107 
113  public function cancel()
114  {
115  $this->ctrl->returnToParent($this);
116  }
117 
124  public function save()
125  {
126  $this->user_settings->setTimeZone($_POST['timezone']);
127  $this->user_settings->setWeekStart((int) $_POST['weekstart']);
128  $this->user_settings->setTimeFormat((int) $_POST['time_format']);
129  $this->user_settings->save();
130 
131  ilUtil::sendInfo($this->lng->txt('settings_saved'),true);
132  $this->ctrl->returnToParent($this);
133  }
134 
141  public function initSettingsForm()
142  {
143  if(is_object($this->form))
144  {
145  return true;
146  }
147  include_once('Services/Calendar/classes/class.ilCalendarUtil.php');
148  include_once('Services/Form/classes/class.ilPropertyFormGUI.php');
149 
150  $this->form = new ilPropertyFormGUI();
151  $this->form->setFormAction($this->ctrl->getFormAction($this,'save'));
152  $this->form->setTitle($this->lng->txt('cal_user_settings'));
153  $this->form->addCommandButton('save',$this->lng->txt('save'));
154  $this->form->addCommandButton('cancel',$this->lng->txt('cancel'));
155 
156  $select = new ilSelectInputGUI($this->lng->txt('cal_user_timezone'),'timezone');
158  $select->setInfo($this->lng->txt('cal_timezone_info'));
159  $select->setValue($this->user_settings->getTimeZone());
160  $this->form->addItem($select);
161 
162  $select = new ilSelectInputGUI($this->lng->txt('cal_user_time_format'),'time_format');
163  $select->setOptions(array(
166  $select->setInfo($this->lng->txt('cal_time_format_info'));
167  $select->setValue($this->user_settings->getTimeFormat());
168  $this->form->addItem($select);
169 
170  $radio = new ilRadioGroupInputGUI($this->lng->txt('cal_week_start'),'weekstart');
171  $radio->setValue($this->user_settings->getWeekStart());
172 
173  $option = new ilRadioOption($this->lng->txt('l_su'),0);
174  $radio->addOption($option);
175  $option = new ilRadioOption($this->lng->txt('l_mo'),1);
176  $radio->addOption($option);
177  $this->form->addItem($radio);
178 
179  }
180 }
181 
182 ?>