ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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
24include_once('Services/Calendar/classes/class.ilCalendarUserSettings.php');
25include_once('Services/Calendar/classes/class.ilCalendarSettings.php');
26
37{
38 protected $tpl;
39 protected $lng;
40 protected $user;
41 protected $settings;
42
46 protected $user_settings;
47
48
56 public function __construct()
57 {
58 global $DIC;
59
60 $ilUser = $DIC['ilUser'];
61 $tpl = $DIC['tpl'];
62 $lng = $DIC['lng'];
63 $ilCtrl = $DIC['ilCtrl'];
64
65 $this->tpl = $tpl;
66 $this->lng = $lng;
67 $this->lng->loadLanguageModule('dateplaner');
68 $this->lng->loadLanguageModule('jscalendar');
69
70 $this->ctrl = $ilCtrl;
71
72 $this->user = $ilUser;
74 $this->user_settings = ilCalendarUserSettings::_getInstanceByUserId($this->user->getId());
75 }
76
77
84 public function executeCommand()
85 {
86 global $DIC;
87
88 $ilUser = $DIC['ilUser'];
89 $ilSetting = $DIC['ilSetting'];
90
91
92 $next_class = $this->ctrl->getNextClass();
93
94 switch ($next_class) {
95 default:
96 $cmd = $this->ctrl->getCmd("show");
97 $this->$cmd();
98 break;
99 }
100 return true;
101 }
102
110 public function show()
111 {
112 $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.user_settings.html', 'Services/Calendar');
113
114 $this->initSettingsForm();
115 $this->tpl->setVariable('CAL_SETTINGS', $this->form->getHTML());
116 }
117
123 public function cancel()
124 {
125 $this->ctrl->returnToParent($this);
126 }
127
134 public function save()
135 {
136 $this->user_settings->setTimeZone($_POST['timezone']);
137 $this->user_settings->setExportTimeZoneType((int) $_POST['export_tz']);
138 $this->user_settings->setWeekStart((int) $_POST['weekstart']);
139 $this->user_settings->setDateFormat((int) $_POST['date_format']);
140 $this->user_settings->setTimeFormat((int) $_POST['time_format']);
141 $this->user_settings->setDayStart((int) $_POST['dst']);
142 $this->user_settings->setDayEnd((int) $_POST['den']);
143 if ($this->settings->getShowWeeks()) {
144 $this->user_settings->setShowWeeks((int) $_POST['show_weeks']);
145 }
146
147 if (((int) $_POST['den']) < (int) $_POST['dst']) {
148 ilUtil::sendFailure($this->lng->txt('cal_dstart_dend_warn'));
149 $this->show();
150 return false;
151 }
152
153 $this->user_settings->save();
154
155 ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
156 $this->ctrl->redirect($this, "show");
157 }
158
165 public function initSettingsForm()
166 {
167 if (is_object($this->form)) {
168 return true;
169 }
170 include_once('Services/Calendar/classes/class.ilCalendarUtil.php');
171 include_once('Services/Form/classes/class.ilPropertyFormGUI.php');
172
173 $this->form = new ilPropertyFormGUI();
174 $this->form->setFormAction($this->ctrl->getFormAction($this, 'save'));
175 $this->form->setTitle($this->lng->txt('cal_user_settings'));
176 $this->form->addCommandButton('save', $this->lng->txt('save'));
177 //$this->form->addCommandButton('cancel',$this->lng->txt('cancel'));
178
179 $select = new ilSelectInputGUI($this->lng->txt('cal_user_timezone'), 'timezone');
180 $select->setOptions(ilCalendarUtil::_getShortTimeZoneList());
181 $select->setInfo($this->lng->txt('cal_timezone_info'));
182 $select->setValue($this->user_settings->getTimeZone());
183 $this->form->addItem($select);
184
185 $export_type = new ilRadioGroupInputGUI($this->lng->txt('cal_export_timezone'), 'export_tz');
186 $export_type->setValue($this->user_settings->getExportTimeZoneType());
187
188 $export_tz = new ilRadioOption($this->lng->txt('cal_export_timezone_tz'), ilCalendarUserSettings::CAL_EXPORT_TZ_TZ);
189 $export_type->addOption($export_tz);
190 $export_utc = new ilRadioOption($this->lng->txt('cal_export_timezone_utc'), ilCalendarUserSettings::CAL_EXPORT_TZ_UTC);
191 $export_type->addOption($export_utc);
192 $this->form->addItem($export_type);
193
194 $year = date("Y");
195 $select = new ilSelectInputGUI($this->lng->txt('cal_user_date_format'), 'date_format');
196 $select->setOptions(array(
197 ilCalendarSettings::DATE_FORMAT_DMY => '31.10.' . $year,
198 ilCalendarSettings::DATE_FORMAT_YMD => $year . "-10-31",
199 ilCalendarSettings::DATE_FORMAT_MDY => "10/31/" . $year));
200 $select->setInfo($this->lng->txt('cal_date_format_info'));
201 $select->setValue($this->user_settings->getDateFormat());
202 $this->form->addItem($select);
203
204 $select = new ilSelectInputGUI($this->lng->txt('cal_user_time_format'), 'time_format');
205 $select->setOptions(array(
208 $select->setInfo($this->lng->txt('cal_time_format_info'));
209 $select->setValue($this->user_settings->getTimeFormat());
210 $this->form->addItem($select);
211
212 // Week/Month View
213 $week_month = new ilFormSectionHeaderGUI();
214 $week_month->setTitle($this->lng->txt('cal_week_month_view'));
215 $this->form->addItem($week_month);
216
217 $radio = new ilRadioGroupInputGUI($this->lng->txt('cal_week_start'), 'weekstart');
218 $radio->setValue($this->user_settings->getWeekStart());
219
220 $option = new ilRadioOption($this->lng->txt('l_su'), 0);
221 $radio->addOption($option);
222 $option = new ilRadioOption($this->lng->txt('l_mo'), 1);
223 $radio->addOption($option);
224 $this->form->addItem($radio);
225
226 if ($this->settings->getShowWeeks()) {
227 //
228 $cb = new ilCheckboxInputGUI($this->lng->txt("cal_usr_show_weeks"), "show_weeks");
229 $cb->setInfo($this->lng->txt("cal_usr_show_weeks_info"));
230 $cb->setValue(1);
231 $cb->setChecked($this->user_settings->getShowWeeks());
232 $this->form->addItem($cb);
233 }
234
235 // Day/Week View
236 $week_month = new ilFormSectionHeaderGUI();
237 $week_month->setTitle($this->lng->txt('cal_day_week_view'));
238 $this->form->addItem($week_month);
239
240 $day_start = new ilSelectInputGUI($this->lng->txt('cal_day_start'), 'dst');
241 $day_start->setOptions(
242 ilCalendarUtil::getHourSelection($this->user_settings->getTimeFormat())
243 );
244 $day_start->setValue($this->user_settings->getDayStart());
245 $this->form->addItem($day_start);
246
247 $day_end = new ilSelectInputGUI($this->lng->txt('cal_day_end'), 'den');
248 $day_end->setOptions(
249 ilCalendarUtil::getHourSelection($this->user_settings->getTimeFormat())
250 );
251 $day_end->setValue($this->user_settings->getDayEnd());
252 $this->form->addItem($day_end);
253 }
254}
user()
Definition: user.php:4
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
static _getInstance()
get singleton instance
static _getInstanceByUserId($a_user_id)
get singleton instance
static _getShortTimeZoneList()
get short timezone list
static getHourSelection($a_format)
Get hour selectio depending on user specific hour format.
This class represents a checkbox property in a property form.
This class represents a section header in a property form.
This class represents a property form user interface.
This class represents a property in a property form.
This class represents an option in a radio group.
This class represents a selection list property in a property form.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $ilCtrl
Definition: ilias.php:18
global $ilSetting
Definition: privfeed.php:17
settings()
Definition: settings.php:2
$ilUser
Definition: imgupload.php:18
$DIC
Definition: xapitoken.php:46