ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilObjCalendarSettingsGUI.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
34{
35
39 protected $settings;
40
46 public function __construct($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
47 {
48 global $lng;
49
50 $this->type = 'cals';
51 parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
52
53 $this->lng = $lng;
54 $this->lng->loadLanguageModule('dateplaner');
55 $this->lng->loadLanguageModule('jscalendar');
56 }
57
64 public function executeCommand()
65 {
66 global $ilErr,$ilAccess;
67
68 $next_class = $this->ctrl->getNextClass($this);
69 $cmd = $this->ctrl->getCmd();
70
71 $this->prepareOutput();
72
73 if (!$ilAccess->checkAccess('read', '', $this->object->getRefId())) {
74 $ilErr->raiseError($this->lng->txt('no_permission'), $ilErr->WARNING);
75 }
76
77 switch ($next_class) {
78 case 'ilpermissiongui':
79 $this->tabs_gui->setTabActive('perm_settings');
80 include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
81 $perm_gui = new ilPermissionGUI($this);
82 $ret =&$this->ctrl->forwardCommand($perm_gui);
83 break;
84
85 default:
86 $this->tabs_gui->setTabActive('settings');
87 $this->initCalendarSettings();
88 if (!$cmd || $cmd == 'view') {
89 $cmd = "settings";
90 }
91
92 $this->$cmd();
93 break;
94 }
95 return true;
96 }
97
98
105 public function getAdminTabs()
106 {
107 global $rbacsystem, $ilAccess;
108
109 if ($ilAccess->checkAccess("read", '', $this->object->getRefId())) {
110 $this->tabs_gui->addTarget(
111 "settings",
112 $this->ctrl->getLinkTarget($this, "settings"),
113 array("settings", "view")
114 );
115 }
116
117 if ($ilAccess->checkAccess('edit_permission', '', $this->object->getRefId())) {
118 $this->tabs_gui->addTarget(
119 "perm_settings",
120 $this->ctrl->getLinkTargetByClass('ilpermissiongui', "perm"),
121 array(),
122 'ilpermissiongui'
123 );
124 }
125 }
126
130 public function settings()
131 {
132 $this->checkPermission('read');
133
134 $this->tabs_gui->setTabActive('settings');
135 $this->initFormSettings();
136 $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.settings.html', 'Services/Calendar');
137 $this->tpl->setVariable('CAL_SETTINGS', $this->form->getHTML());
138 return true;
139 }
140
146 protected function save()
147 {
148 $this->checkPermission('write');
149
150 $this->settings->setEnabled((int) $_POST['enable']);
151 $this->settings->setDefaultWeekStart((int) $_POST['default_week_start']);
152 $this->settings->setDefaultTimeZone(ilUtil::stripSlashes($_POST['default_timezone']));
153 $this->settings->setDefaultDateFormat((int) $_POST['default_date_format']);
154 $this->settings->setDefaultTimeFormat((int) $_POST['default_time_format']);
155 $this->settings->setEnableGroupMilestones((int) $_POST['enable_grp_milestones']);
156 $this->settings->enableCourseCalendar((int) $_POST['visible_crs']);
157 $this->settings->enableGroupCalendar((int) $_POST['visible_grp']);
158 $this->settings->setDefaultDayStart((int) $_POST['dst']);
159 $this->settings->setDefaultDayEnd((int) $_POST['den']);
160 $this->settings->enableSynchronisationCache((bool) $_POST['sync_cache']);
161 $this->settings->setSynchronisationCacheMinutes((int) $_POST['sync_cache_time']);
162 $this->settings->setCacheMinutes((int) $_POST['cache_time']);
163 $this->settings->useCache((bool) $_POST['cache']);
164 $this->settings->enableNotification((bool) $_POST['cn']);
165 $this->settings->enableUserNotification((bool) $_POST['cnu']);
166 $this->settings->enableConsultationHours((bool) $_POST['ch']);
167 $this->settings->enableCGRegistration((bool) $_POST['cgr']);
168 $this->settings->enableWebCalSync((bool) $_POST['webcal']);
169 $this->settings->setWebCalSyncHours((int) $_POST['webcal_hours']);
170 $this->settings->setShowWeeks((int) $_POST['show_weeks']);
171 $this->settings->enableBatchFileDownloads((bool) $_POST['batch_files']);
172
173 if (((int) $_POST['den']) < (int) $_POST['dst']) {
174 ilUtil::sendFailure($this->lng->txt('cal_dstart_dend_warn'));
175 $this->settings();
176 return false;
177 }
178
179 $this->settings->save();
180
181 ilUtil::sendSuccess($this->lng->txt('settings_saved'));
182 $this->settings();
183 }
184
190 protected function initCalendarSettings()
191 {
192 include_once('Services/Calendar/classes/class.ilCalendarSettings.php');
194 }
195
201 protected function initFormSettings()
202 {
203 if (is_object($this->form)) {
204 return true;
205 }
206
207 $this->form = new ilPropertyFormGUI();
208 $this->form->setFormAction($this->ctrl->getFormAction($this));
209 $this->form->setTitle($this->lng->txt('cal_global_settings'));
210
211
212 if ($this->checkPermissionBool('write')) {
213 $this->form->addCommandButton('save', $this->lng->txt('save'));
214 }
215
216 $check = new ilCheckboxInputGUI($this->lng->txt('enable_calendar'), 'enable');
217 $check->setValue(1);
218 $check->setChecked($this->settings->isEnabled() ? true : false);
219 $this->form->addItem($check);
220
221 $server_tz = new ilNonEditableValueGUI($this->lng->txt('cal_server_tz'));
222 $server_tz->setValue(ilTimeZone::_getDefaultTimeZone());
223 $this->form->addItem($server_tz);
224
225 $select = new ilSelectInputGUI($this->lng->txt('cal_def_timezone'), 'default_timezone');
226 $select->setOptions(ilCalendarUtil::_getShortTimeZoneList());
227 $select->setInfo($this->lng->txt('cal_def_timezone_info'));
228 $select->setValue($this->settings->getDefaultTimeZone());
229 $this->form->addItem($select);
230
231 $year = date("Y");
232 $select = new ilSelectInputGUI($this->lng->txt('cal_def_date_format'), 'default_date_format');
233 $select->setOptions(array(
234 ilCalendarSettings::DATE_FORMAT_DMY => '31.10.' . $year,
235 ilCalendarSettings::DATE_FORMAT_YMD => $year . "-10-31",
236 ilCalendarSettings::DATE_FORMAT_MDY => "10/31/" . $year));
237 $select->setInfo($this->lng->txt('cal_def_date_format_info'));
238 $select->setValue($this->settings->getDefaultDateFormat());
239 $this->form->addItem($select);
240
241 $select = new ilSelectInputGUI($this->lng->txt('cal_def_time_format'), 'default_time_format');
242 $select->setOptions(array(
245 $select->setInfo($this->lng->txt('cal_def_time_format_info'));
246 $select->setValue($this->settings->getDefaultTimeFormat());
247 $this->form->addItem($select);
248
249 // Weekstart
250 $radio = new ilRadioGroupInputGUI($this->lng->txt('cal_def_week_start'), 'default_week_start');
251 $radio->setValue($this->settings->getDefaultWeekStart());
252
253 $option = new ilRadioOption($this->lng->txt('l_su'), 0);
254 $radio->addOption($option);
255 $option = new ilRadioOption($this->lng->txt('l_mo'), 1);
256 $radio->addOption($option);
257
258 $this->form->addItem($radio);
259
260 // show weeks
261 $cb = new ilCheckboxInputGUI($this->lng->txt("cal_def_show_weeks"), "show_weeks");
262 $cb->setInfo($this->lng->txt("cal_show_weeks_info"));
263 $cb->setValue(1);
264 $cb->setChecked($this->settings->getShowWeeks());
265 $this->form->addItem($cb);
266
267
268 // Day start
269 $day_start = new ilSelectInputGUI($this->lng->txt('cal_def_day_start'), 'dst');
270 $day_start->setOptions(
271 ilCalendarUtil::getHourSelection($this->settings->getDefaultTimeFormat())
272 );
273 $day_start->setValue($this->settings->getDefaultDayStart());
274 $this->form->addItem($day_start);
275
276 $day_end = new ilSelectInputGUI($this->lng->txt('cal_def_day_end'), 'den');
277 $day_end->setOptions(
278 ilCalendarUtil::getHourSelection($this->settings->getDefaultTimeFormat())
279 );
280 $day_end->setValue($this->settings->getDefaultDayEnd());
281 $this->form->addItem($day_end);
282
283 $sync = new ilCheckboxInputGUI($this->lng->txt('cal_webcal_sync'), 'webcal');
284 $sync->setValue(1);
285 $sync->setChecked($this->settings->isWebCalSyncEnabled());
286 $sync->setInfo($this->lng->txt('cal_webcal_sync_info'));
287
288 $sync_min = new ilNumberInputGUI('', 'webcal_hours');
289 $sync_min->setSize(2);
290 $sync_min->setMaxLength(3);
291 $sync_min->setValue($this->settings->getWebCalSyncHours());
292 $sync_min->setSuffix($this->lng->txt('hours'));
293 $sync->addSubItem($sync_min);
294
295 $this->form->addItem($sync);
296
297 //Batch File Downloads in Calendar
298 $batch_files_download = new ilCheckboxInputGUI($this->lng->txt('cal_batch_file_downloads'), "batch_files");
299 $batch_files_download->setValue(1);
300 $batch_files_download->setChecked($this->settings->isBatchFileDownloadsEnabled());
301 $batch_files_download->setInfo($this->lng->txt('cal_batch_file_downloads_info'));
302 $this->form->addItem($batch_files_download);
303
304 // enable milestone planning in groups
305 $mil = new ilFormSectionHeaderGUI();
306 $mil->setTitle($this->lng->txt('cal_milestone_settings'));
307 $this->form->addItem($mil);
308
309 $checkm = new ilCheckboxInputGUI($this->lng->txt('cal_enable_group_milestones'), 'enable_grp_milestones');
310 $checkm->setValue(1);
311 $checkm->setChecked($this->settings->getEnableGroupMilestones() ? true : false);
312 $checkm->setInfo($this->lng->txt('cal_enable_group_milestones_desc'));
313 $this->form->addItem($checkm);
314
315 // Consultation hours
316 $con = new ilFormSectionHeaderGUI();
317 $con->setTitle($this->lng->txt('cal_ch_form_header'));
318 $this->form->addItem($con);
319
320 $ch = new ilCheckboxInputGUI($this->lng->txt('cal_ch_form'), 'ch');
321 $ch->setInfo($this->lng->txt('cal_ch_form_info'));
322 $ch->setValue(1);
323 $ch->setChecked($this->settings->areConsultationHoursEnabled());
324 $this->form->addItem($ch);
325
326 // repository visibility default
327 $rep = new ilFormSectionHeaderGUI();
328 $rep->setTitle($GLOBALS['lng']->txt('cal_setting_global_vis_repos'));
329 $this->form->addItem($rep);
330
331 $crs = new ilCheckboxInputGUI($GLOBALS['lng']->txt('cal_setting_global_crs_vis'), 'visible_crs');
332 $crs->setInfo($GLOBALS['lng']->txt('cal_setting_global_crs_vis_info'));
333 $crs->setValue(1);
334 $crs->setInfo($GLOBALS['lng']->txt('cal_setting_global_crs_vis_info'));
335 $crs->setChecked($this->settings->isCourseCalendarEnabled());
336 $this->form->addItem($crs);
337
338 $grp = new ilCheckboxInputGUI($GLOBALS['lng']->txt('cal_setting_global_grp_vis'), 'visible_grp');
339 $grp->setInfo($GLOBALS['lng']->txt('cal_setting_global_grp_vis_info'));
340 $grp->setValue(1);
341 $grp->setInfo($GLOBALS['lng']->txt('cal_setting_global_grp_vis_info'));
342 $grp->setChecked($this->settings->isGroupCalendarEnabled());
343 $this->form->addItem($grp);
344
345
346
347
348 // Notifications
349 $not = new ilFormSectionHeaderGUI();
350 $not->setTitle($this->lng->txt('notifications'));
351 $this->form->addItem($not);
352
353 $cgn = new ilCheckboxInputGUI($this->lng->txt('cal_notification'), 'cn');
354 $cgn->setOptionTitle($this->lng->txt('cal_notification_crsgrp'));
355 $cgn->setValue(1);
356 $cgn->setChecked($this->settings->isNotificationEnabled());
357 $cgn->setInfo($this->lng->txt('cal_adm_notification_info'));
358 $this->form->addItem($cgn);
359
360 $cnu = new ilCheckboxInputGUI('', 'cnu');
361 $cnu->setOptionTitle($this->lng->txt('cal_notification_users'));
362 $cnu->setValue(1);
363 $cnu->setChecked($this->settings->isUserNotificationEnabled());
364 $cnu->setInfo($this->lng->txt('cal_adm_notification_user_info'));
365 $this->form->addItem($cnu);
366
367
368 // Registration
369 $book = new ilFormSectionHeaderGUI();
370 $book->setTitle($this->lng->txt('cal_registrations'));
371 $this->form->addItem($book);
372
373 $cgn = new ilCheckboxInputGUI($this->lng->txt('cal_cg_registrations'), 'cgr');
374 $cgn->setValue(1);
375 $cgn->setChecked($this->settings->isCGRegistrationEnabled());
376 $cgn->setInfo($this->lng->txt('cal_cg_registration_info'));
377 $this->form->addItem($cgn);
378
379 // Synchronisation cache
380 $sec = new ilFormSectionHeaderGUI();
381 $sec->setTitle($this->lng->txt('cal_cache_settings'));
382 $this->form->addItem($sec);
383
384 $cache = new ilRadioGroupInputGUI($this->lng->txt('cal_sync_cache'), 'sync_cache');
385 $cache->setValue((int) $this->settings->isSynchronisationCacheEnabled());
386 $cache->setInfo($this->lng->txt('cal_sync_cache_info'));
387 $cache->setRequired(true);
388
389 $sync_cache = new ilRadioOption($this->lng->txt('cal_sync_disabled'), 0);
390 $cache->addOption($sync_cache);
391
392 $sync_cache = new ilRadioOption($this->lng->txt('cal_sync_enabled'), 1);
393 $cache->addOption($sync_cache);
394
395 $cache_t = new ilNumberInputGUI('', 'sync_cache_time');
396 $cache_t->setValue($this->settings->getSynchronisationCacheMinutes());
397 $cache_t->setMinValue(0);
398 $cache_t->setSize(3);
399 $cache_t->setMaxLength(3);
400 $cache_t->setSuffix($this->lng->txt('form_minutes'));
401 $sync_cache->addSubItem($cache_t);
402
403 $this->form->addItem($cache);
404
405 // Calendar cache
406 $cache = new ilRadioGroupInputGUI($this->lng->txt('cal_cache'), 'cache');
407 $cache->setValue((int) $this->settings->isCacheUsed());
408 $cache->setInfo($this->lng->txt('cal_cache_info'));
409 $cache->setRequired(true);
410
411 $sync_cache = new ilRadioOption($this->lng->txt('cal_cache_disabled'), 0);
412 $cache->addOption($sync_cache);
413
414 $sync_cache = new ilRadioOption($this->lng->txt('cal_cache_enabled'), 1);
415 $cache->addOption($sync_cache);
416
417 $cache_t = new ilNumberInputGUI('', 'cache_time');
418 $cache_t->setValue($this->settings->getCacheMinutes());
419 $cache_t->setMinValue(0);
420 $cache_t->setSize(3);
421 $cache_t->setMaxLength(3);
422 $cache_t->setSuffix($this->lng->txt('form_minutes'));
423 $sync_cache->addSubItem($cache_t);
424 $this->form->addItem($cache);
425 }
426
427 public function addToExternalSettingsForm($a_form_id)
428 {
429 switch ($a_form_id) {
431
432 $this->initCalendarSettings();
433
434 $fields = array();
435
436 $subitems = array('cal_setting_global_crs_vis' => array($this->settings->isCourseCalendarEnabled(), ilAdministrationSettingsFormHandler::VALUE_BOOL));
437 $fields['cal_setting_global_vis_repos'] = array(null, null, $subitems);
438
439 $subitems = array(
440 'cal_notification_crsgrp' => array($this->settings->isNotificationEnabled(), ilAdministrationSettingsFormHandler::VALUE_BOOL),
441 'cal_notification_users' => array($this->settings->isUserNotificationEnabled(), ilAdministrationSettingsFormHandler::VALUE_BOOL)
442 );
443 $fields['cal_notification'] = array(null, null, $subitems);
444
445 $fields['cal_cg_registrations'] = array($this->settings->isCGRegistrationEnabled(), ilAdministrationSettingsFormHandler::VALUE_BOOL);
446
447 return array(array("settings", $fields));
448
450
451 $this->initCalendarSettings();
452
453 $fields = array();
454
455 $subitems = array('cal_setting_global_grp_vis' => array($this->settings->isGroupCalendarEnabled(), ilAdministrationSettingsFormHandler::VALUE_BOOL));
456 $fields['cal_setting_global_vis_repos'] = array(null, null, $subitems);
457
458 $subitems = array(
459 'cal_notification_crsgrp' => array($this->settings->isNotificationEnabled(), ilAdministrationSettingsFormHandler::VALUE_BOOL),
460 'cal_notification_users' => array($this->settings->isUserNotificationEnabled(), ilAdministrationSettingsFormHandler::VALUE_BOOL)
461 );
462 $fields['cal_notification'] = array(null, null, $subitems);
463
464 $fields['cal_cg_registrations'] = array($this->settings->isCGRegistrationEnabled(), ilAdministrationSettingsFormHandler::VALUE_BOOL);
465
466 return array(array("settings", $fields));
467 }
468 }
469}
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
static _getInstance()
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 non editable value in a property form.
This class represents a number property in a property form.
initFormSettings()
Init settings property form.
initCalendarSettings()
init calendar settings
__construct($a_data, $a_id, $a_call_by_reference=true, $a_prepare_output=true)
Constructor.
Class ilObjectGUI Basic methods of all Output classes.
checkPermission($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission and redirect on error.
prepareOutput($a_show_subobjects=true)
prepare output
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission.
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
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 _getDefaultTimeZone()
Calculate and set default time zone.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
$sync
$ret
Definition: parser.php:6