ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $ilUser,$tpl,$lng,$ilCtrl;
59
60 $this->tpl = $tpl;
61 $this->lng = $lng;
62 $this->lng->loadLanguageModule('dateplaner');
63 $this->lng->loadLanguageModule('jscalendar');
64
65 $this->ctrl = $ilCtrl;
66
67 $this->user = $ilUser;
69 $this->user_settings = ilCalendarUserSettings::_getInstanceByUserId($this->user->getId());
70 }
71
72
79 public function executeCommand()
80 {
81 global $ilUser, $ilSetting;
82
83
84 $next_class = $this->ctrl->getNextClass();
85
86 switch ($next_class) {
87 default:
88 $cmd = $this->ctrl->getCmd("show");
89 $this->$cmd();
90 break;
91 }
92 return true;
93 }
94
102 public function show()
103 {
104 $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.user_settings.html', 'Services/Calendar');
105
106 $this->initSettingsForm();
107 $this->tpl->setVariable('CAL_SETTINGS', $this->form->getHTML());
108 }
109
115 public function cancel()
116 {
117 $this->ctrl->returnToParent($this);
118 }
119
126 public function save()
127 {
128 $this->user_settings->setTimeZone($_POST['timezone']);
129 $this->user_settings->setExportTimeZoneType((int) $_POST['export_tz']);
130 $this->user_settings->setWeekStart((int) $_POST['weekstart']);
131 $this->user_settings->setDateFormat((int) $_POST['date_format']);
132 $this->user_settings->setTimeFormat((int) $_POST['time_format']);
133 $this->user_settings->setDayStart((int) $_POST['dst']);
134 $this->user_settings->setDayEnd((int) $_POST['den']);
135 if ($this->settings->getShowWeeks()) {
136 $this->user_settings->setShowWeeks((int) $_POST['show_weeks']);
137 }
138
139 if (((int) $_POST['den']) < (int) $_POST['dst']) {
140 ilUtil::sendFailure($this->lng->txt('cal_dstart_dend_warn'));
141 $this->show();
142 return false;
143 }
144
145 $this->user_settings->save();
146
147 ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
148 $this->ctrl->redirect($this, "show");
149 }
150
157 public function initSettingsForm()
158 {
159 if (is_object($this->form)) {
160 return true;
161 }
162 include_once('Services/Calendar/classes/class.ilCalendarUtil.php');
163 include_once('Services/Form/classes/class.ilPropertyFormGUI.php');
164
165 $this->form = new ilPropertyFormGUI();
166 $this->form->setFormAction($this->ctrl->getFormAction($this, 'save'));
167 $this->form->setTitle($this->lng->txt('cal_user_settings'));
168 $this->form->addCommandButton('save', $this->lng->txt('save'));
169 //$this->form->addCommandButton('cancel',$this->lng->txt('cancel'));
170
171 $select = new ilSelectInputGUI($this->lng->txt('cal_user_timezone'), 'timezone');
172 $select->setOptions(ilCalendarUtil::_getShortTimeZoneList());
173 $select->setInfo($this->lng->txt('cal_timezone_info'));
174 $select->setValue($this->user_settings->getTimeZone());
175 $this->form->addItem($select);
176
177 $export_type = new ilRadioGroupInputGUI($this->lng->txt('cal_export_timezone'), 'export_tz');
178 $export_type->setValue($this->user_settings->getExportTimeZoneType());
179
180 $export_tz = new ilRadioOption($this->lng->txt('cal_export_timezone_tz'), ilCalendarUserSettings::CAL_EXPORT_TZ_TZ);
181 $export_type->addOption($export_tz);
182 $export_utc = new ilRadioOption($this->lng->txt('cal_export_timezone_utc'), ilCalendarUserSettings::CAL_EXPORT_TZ_UTC);
183 $export_type->addOption($export_utc);
184 $this->form->addItem($export_type);
185
186 $year = date("Y");
187 $select = new ilSelectInputGUI($this->lng->txt('cal_user_date_format'), 'date_format');
188 $select->setOptions(array(
189 ilCalendarSettings::DATE_FORMAT_DMY => '31.10.' . $year,
190 ilCalendarSettings::DATE_FORMAT_YMD => $year . "-10-31",
191 ilCalendarSettings::DATE_FORMAT_MDY => "10/31/" . $year));
192 $select->setInfo($this->lng->txt('cal_date_format_info'));
193 $select->setValue($this->user_settings->getDateFormat());
194 $this->form->addItem($select);
195
196 $select = new ilSelectInputGUI($this->lng->txt('cal_user_time_format'), 'time_format');
197 $select->setOptions(array(
200 $select->setInfo($this->lng->txt('cal_time_format_info'));
201 $select->setValue($this->user_settings->getTimeFormat());
202 $this->form->addItem($select);
203
204 // Week/Month View
205 $week_month = new ilFormSectionHeaderGUI();
206 $week_month->setTitle($this->lng->txt('cal_week_month_view'));
207 $this->form->addItem($week_month);
208
209 $radio = new ilRadioGroupInputGUI($this->lng->txt('cal_week_start'), 'weekstart');
210 $radio->setValue($this->user_settings->getWeekStart());
211
212 $option = new ilRadioOption($this->lng->txt('l_su'), 0);
213 $radio->addOption($option);
214 $option = new ilRadioOption($this->lng->txt('l_mo'), 1);
215 $radio->addOption($option);
216 $this->form->addItem($radio);
217
218 if ($this->settings->getShowWeeks()) {
219 //
220 $cb = new ilCheckboxInputGUI($this->lng->txt("cal_usr_show_weeks"), "show_weeks");
221 $cb->setInfo($this->lng->txt("cal_usr_show_weeks_info"));
222 $cb->setValue(1);
223 $cb->setChecked($this->user_settings->getShowWeeks());
224 $this->form->addItem($cb);
225 }
226
227 // Day/Week View
228 $week_month = new ilFormSectionHeaderGUI();
229 $week_month->setTitle($this->lng->txt('cal_day_week_view'));
230 $this->form->addItem($week_month);
231
232 $day_start = new ilSelectInputGUI($this->lng->txt('cal_day_start'), 'dst');
233 $day_start->setOptions(
234 ilCalendarUtil::getHourSelection($this->user_settings->getTimeFormat())
235 );
236 $day_start->setValue($this->user_settings->getDayStart());
237 $this->form->addItem($day_start);
238
239 $day_end = new ilSelectInputGUI($this->lng->txt('cal_day_end'), 'den');
240 $day_end->setOptions(
241 ilCalendarUtil::getHourSelection($this->user_settings->getTimeFormat())
242 );
243 $day_end->setValue($this->user_settings->getDayEnd());
244 $this->form->addItem($day_end);
245 }
246}
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
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 sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
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