ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 $dic;
43 protected $settings;
47 protected $rbacsystem;
51 protected $error;
52
58 public function __construct($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
59 {
60 global $DIC;
61
62 $this->type = 'cals';
63 parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
64
65 $this->dic = $DIC;
66 $this->error = $DIC['ilErr'];
67 ;
68 $this->rbacsystem = $this->dic->rbac()->system();
69 $this->lng = $this->dic->language();
70 $this->lng->loadLanguageModule('dateplaner');
71 $this->lng->loadLanguageModule('jscalendar');
72 }
73
80 public function executeCommand()
81 {
82 $next_class = $this->ctrl->getNextClass($this);
83 $cmd = $this->ctrl->getCmd();
84
85 $this->prepareOutput();
86
87 if (!$this->rbacsystem->checkAccess("visible,read", $this->object->getRefId())) {
88 $this->error->raiseError($this->lng->txt('no_permission'), $this->error->WARNING);
89 }
90
91 switch ($next_class) {
92 case 'ilpermissiongui':
93 $this->tabs_gui->setTabActive('perm_settings');
94 include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
95 $perm_gui = new ilPermissionGUI($this);
96 $ret = &$this->ctrl->forwardCommand($perm_gui);
97 break;
98
99 default:
100 $this->tabs_gui->setTabActive('settings');
101 $this->initCalendarSettings();
102 if (!$cmd || $cmd == 'view') {
103 $cmd = "settings";
104 }
105
106 $this->$cmd();
107 break;
108 }
109 return true;
110 }
111
112
119 public function getAdminTabs()
120 {
121 global $DIC;
122
123 $rbacsystem = $DIC['rbacsystem'];
124 $ilAccess = $DIC['ilAccess'];
125
126 if ($ilAccess->checkAccess("read", '', $this->object->getRefId())) {
127 $this->tabs_gui->addTarget(
128 "settings",
129 $this->ctrl->getLinkTarget($this, "settings"),
130 array("settings", "view")
131 );
132 }
133
134 if ($ilAccess->checkAccess('edit_permission', '', $this->object->getRefId())) {
135 $this->tabs_gui->addTarget(
136 "perm_settings",
137 $this->ctrl->getLinkTargetByClass('ilpermissiongui', "perm"),
138 array(),
139 'ilpermissiongui'
140 );
141 }
142 }
143
147 public function settings()
148 {
149 global $ilErr;
150
151 if (!$this->rbacsystem->checkAccess("visible,read", $this->object->getRefId())) {
152 $ilErr->raiseError($this->lng->txt('no_permission'), $ilErr->WARNING);
153 }
154
155 $this->tabs_gui->setTabActive('settings');
156 $this->initFormSettings();
157 $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.settings.html', 'Services/Calendar');
158 $this->tpl->setVariable('CAL_SETTINGS', $this->form->getHTML());
159 return true;
160 }
161
167 protected function save()
168 {
169 $this->checkPermission('write');
170
171 $this->settings->setEnabled((int) $_POST['enable']);
172 $this->settings->setDefaultWeekStart((int) $_POST['default_week_start']);
173 $this->settings->setDefaultTimeZone(ilUtil::stripSlashes($_POST['default_timezone']));
174 $this->settings->setDefaultDateFormat((int) $_POST['default_date_format']);
175 $this->settings->setDefaultTimeFormat((int) $_POST['default_time_format']);
176 $this->settings->setEnableGroupMilestones((int) $_POST['enable_grp_milestones']);
177 $this->settings->enableCourseCalendar((int) $_POST['visible_crs']);
178 $this->settings->enableGroupCalendar((int) $_POST['visible_grp']);
179 $this->settings->setDefaultDayStart((int) $_POST['dst']);
180 $this->settings->setDefaultDayEnd((int) $_POST['den']);
181 $this->settings->enableSynchronisationCache((bool) $_POST['sync_cache']);
182 $this->settings->setSynchronisationCacheMinutes((int) $_POST['sync_cache_time']);
183 $this->settings->setCacheMinutes((int) $_POST['cache_time']);
184 $this->settings->useCache((bool) $_POST['cache']);
185 $this->settings->enableNotification((bool) $_POST['cn']);
186 $this->settings->enableUserNotification((bool) $_POST['cnu']);
187 $this->settings->enableConsultationHours((bool) $_POST['ch']);
188 $this->settings->enableCGRegistration((bool) $_POST['cgr']);
189 $this->settings->enableWebCalSync((bool) $_POST['webcal']);
190 $this->settings->setWebCalSyncHours((int) $_POST['webcal_hours']);
191 $this->settings->setShowWeeks((int) $_POST['show_weeks']);
192 $this->settings->enableBatchFileDownloads((bool) $_POST['batch_files']);
193
194 if (((int) $_POST['den']) < (int) $_POST['dst']) {
195 ilUtil::sendFailure($this->lng->txt('cal_dstart_dend_warn'));
196 $this->settings();
197 return false;
198 }
199
200 $this->settings->save();
201
202 ilUtil::sendSuccess($this->lng->txt('settings_saved'));
203 $this->settings();
204 }
205
211 protected function initCalendarSettings()
212 {
213 include_once('Services/Calendar/classes/class.ilCalendarSettings.php');
215 }
216
222 protected function initFormSettings()
223 {
224 if (is_object($this->form)) {
225 return true;
226 }
227
228 $this->form = new ilPropertyFormGUI();
229 $this->form->setFormAction($this->ctrl->getFormAction($this));
230 $this->form->setTitle($this->lng->txt('cal_global_settings'));
231
232
233 if ($this->checkPermissionBool('write')) {
234 $this->form->addCommandButton('save', $this->lng->txt('save'));
235 }
236
237 $check = new ilCheckboxInputGUI($this->lng->txt('enable_calendar'), 'enable');
238 $check->setValue(1);
239 $check->setChecked($this->settings->isEnabled() ? true : false);
240 $this->form->addItem($check);
241
242 $server_tz = new ilNonEditableValueGUI($this->lng->txt('cal_server_tz'));
243 $server_tz->setValue(ilTimeZone::_getDefaultTimeZone());
244 $this->form->addItem($server_tz);
245
246 $select = new ilSelectInputGUI($this->lng->txt('cal_def_timezone'), 'default_timezone');
247 $select->setOptions(ilCalendarUtil::_getShortTimeZoneList());
248 $select->setInfo($this->lng->txt('cal_def_timezone_info'));
249 $select->setValue($this->settings->getDefaultTimeZone());
250 $this->form->addItem($select);
251
252 $year = date("Y");
253 $select = new ilSelectInputGUI($this->lng->txt('cal_def_date_format'), 'default_date_format');
254 $select->setOptions(array(
255 ilCalendarSettings::DATE_FORMAT_DMY => '31.10.' . $year,
256 ilCalendarSettings::DATE_FORMAT_YMD => $year . "-10-31",
257 ilCalendarSettings::DATE_FORMAT_MDY => "10/31/" . $year));
258 $select->setInfo($this->lng->txt('cal_def_date_format_info'));
259 $select->setValue($this->settings->getDefaultDateFormat());
260 $this->form->addItem($select);
261
262 $select = new ilSelectInputGUI($this->lng->txt('cal_def_time_format'), 'default_time_format');
263 $select->setOptions(array(
266 $select->setInfo($this->lng->txt('cal_def_time_format_info'));
267 $select->setValue($this->settings->getDefaultTimeFormat());
268 $this->form->addItem($select);
269
270 // Weekstart
271 $radio = new ilRadioGroupInputGUI($this->lng->txt('cal_def_week_start'), 'default_week_start');
272 $radio->setValue($this->settings->getDefaultWeekStart());
273
274 $option = new ilRadioOption($this->lng->txt('l_su'), 0);
275 $radio->addOption($option);
276 $option = new ilRadioOption($this->lng->txt('l_mo'), 1);
277 $radio->addOption($option);
278
279 $this->form->addItem($radio);
280
281 // show weeks
282 $cb = new ilCheckboxInputGUI($this->lng->txt("cal_def_show_weeks"), "show_weeks");
283 $cb->setInfo($this->lng->txt("cal_show_weeks_info"));
284 $cb->setValue(1);
285 $cb->setChecked($this->settings->getShowWeeks());
286 $this->form->addItem($cb);
287
288
289 // Day start
290 $day_start = new ilSelectInputGUI($this->lng->txt('cal_def_day_start'), 'dst');
291 $day_start->setOptions(
292 ilCalendarUtil::getHourSelection($this->settings->getDefaultTimeFormat())
293 );
294 $day_start->setValue($this->settings->getDefaultDayStart());
295 $this->form->addItem($day_start);
296
297 $day_end = new ilSelectInputGUI($this->lng->txt('cal_def_day_end'), 'den');
298 $day_end->setOptions(
299 ilCalendarUtil::getHourSelection($this->settings->getDefaultTimeFormat())
300 );
301 $day_end->setValue($this->settings->getDefaultDayEnd());
302 $this->form->addItem($day_end);
303
304 $sync = new ilCheckboxInputGUI($this->lng->txt('cal_webcal_sync'), 'webcal');
305 $sync->setValue(1);
306 $sync->setChecked($this->settings->isWebCalSyncEnabled());
307 $sync->setInfo($this->lng->txt('cal_webcal_sync_info'));
308
309 $sync_min = new ilNumberInputGUI('', 'webcal_hours');
310 $sync_min->setSize(2);
311 $sync_min->setMaxLength(3);
312 $sync_min->setValue($this->settings->getWebCalSyncHours());
313 $sync_min->setSuffix($this->lng->txt('hours'));
314 $sync->addSubItem($sync_min);
315
316 $this->form->addItem($sync);
317
318 //Batch File Downloads in Calendar
319 $batch_files_download = new ilCheckboxInputGUI($this->lng->txt('cal_batch_file_downloads'), "batch_files");
320 $batch_files_download->setValue(1);
321 $batch_files_download->setChecked($this->settings->isBatchFileDownloadsEnabled());
322 $batch_files_download->setInfo($this->lng->txt('cal_batch_file_downloads_info'));
323 $this->form->addItem($batch_files_download);
324
325 // enable milestone planning in groups
326 $mil = new ilFormSectionHeaderGUI();
327 $mil->setTitle($this->lng->txt('cal_milestone_settings'));
328 $this->form->addItem($mil);
329
330 $checkm = new ilCheckboxInputGUI($this->lng->txt('cal_enable_group_milestones'), 'enable_grp_milestones');
331 $checkm->setValue(1);
332 $checkm->setChecked($this->settings->getEnableGroupMilestones() ? true : false);
333 $checkm->setInfo($this->lng->txt('cal_enable_group_milestones_desc'));
334 $this->form->addItem($checkm);
335
336 // Consultation hours
337 $con = new ilFormSectionHeaderGUI();
338 $con->setTitle($this->lng->txt('cal_ch_form_header'));
339 $this->form->addItem($con);
340
341 $ch = new ilCheckboxInputGUI($this->lng->txt('cal_ch_form'), 'ch');
342 $ch->setInfo($this->lng->txt('cal_ch_form_info'));
343 $ch->setValue(1);
344 $ch->setChecked($this->settings->areConsultationHoursEnabled());
345 $this->form->addItem($ch);
346
347 // repository visibility default
348 $rep = new ilFormSectionHeaderGUI();
349 $rep->setTitle($GLOBALS['DIC']['lng']->txt('cal_setting_global_vis_repos'));
350 $this->form->addItem($rep);
351
352 $crs = new ilCheckboxInputGUI($GLOBALS['DIC']['lng']->txt('cal_setting_global_crs_vis'), 'visible_crs');
353 $crs->setInfo($GLOBALS['DIC']['lng']->txt('cal_setting_global_crs_vis_info'));
354 $crs->setValue(1);
355 $crs->setInfo($GLOBALS['DIC']['lng']->txt('cal_setting_global_crs_vis_info'));
356 $crs->setChecked($this->settings->isCourseCalendarEnabled());
357 $this->form->addItem($crs);
358
359 $grp = new ilCheckboxInputGUI($GLOBALS['DIC']['lng']->txt('cal_setting_global_grp_vis'), 'visible_grp');
360 $grp->setInfo($GLOBALS['DIC']['lng']->txt('cal_setting_global_grp_vis_info'));
361 $grp->setValue(1);
362 $grp->setInfo($GLOBALS['DIC']['lng']->txt('cal_setting_global_grp_vis_info'));
363 $grp->setChecked($this->settings->isGroupCalendarEnabled());
364 $this->form->addItem($grp);
365
366
367
368
369 // Notifications
370 $not = new ilFormSectionHeaderGUI();
371 $not->setTitle($this->lng->txt('notifications'));
372 $this->form->addItem($not);
373
374 $cgn = new ilCheckboxInputGUI($this->lng->txt('cal_notification'), 'cn');
375 $cgn->setOptionTitle($this->lng->txt('cal_notification_crsgrp'));
376 $cgn->setValue(1);
377 $cgn->setChecked($this->settings->isNotificationEnabled());
378 $cgn->setInfo($this->lng->txt('cal_adm_notification_info'));
379 $this->form->addItem($cgn);
380
381 $cnu = new ilCheckboxInputGUI('', 'cnu');
382 $cnu->setOptionTitle($this->lng->txt('cal_notification_users'));
383 $cnu->setValue(1);
384 $cnu->setChecked($this->settings->isUserNotificationEnabled());
385 $cnu->setInfo($this->lng->txt('cal_adm_notification_user_info'));
386 $this->form->addItem($cnu);
387
388
389 // Registration
390 $book = new ilFormSectionHeaderGUI();
391 $book->setTitle($this->lng->txt('cal_registrations'));
392 $this->form->addItem($book);
393
394 $cgn = new ilCheckboxInputGUI($this->lng->txt('cal_cg_registrations'), 'cgr');
395 $cgn->setValue(1);
396 $cgn->setChecked($this->settings->isCGRegistrationEnabled());
397 $cgn->setInfo($this->lng->txt('cal_cg_registration_info'));
398 $this->form->addItem($cgn);
399
400 // Synchronisation cache
401 $sec = new ilFormSectionHeaderGUI();
402 $sec->setTitle($this->lng->txt('cal_cache_settings'));
403 $this->form->addItem($sec);
404
405 $cache = new ilRadioGroupInputGUI($this->lng->txt('cal_sync_cache'), 'sync_cache');
406 $cache->setValue((int) $this->settings->isSynchronisationCacheEnabled());
407 $cache->setInfo($this->lng->txt('cal_sync_cache_info'));
408 $cache->setRequired(true);
409
410 $sync_cache = new ilRadioOption($this->lng->txt('cal_sync_disabled'), 0);
411 $cache->addOption($sync_cache);
412
413 $sync_cache = new ilRadioOption($this->lng->txt('cal_sync_enabled'), 1);
414 $cache->addOption($sync_cache);
415
416 $cache_t = new ilNumberInputGUI('', 'sync_cache_time');
417 $cache_t->setValue($this->settings->getSynchronisationCacheMinutes());
418 $cache_t->setMinValue(0);
419 $cache_t->setSize(3);
420 $cache_t->setMaxLength(3);
421 $cache_t->setSuffix($this->lng->txt('form_minutes'));
422 $sync_cache->addSubItem($cache_t);
423
424 $this->form->addItem($cache);
425
426 // Calendar cache
427 $cache = new ilRadioGroupInputGUI($this->lng->txt('cal_cache'), 'cache');
428 $cache->setValue((int) $this->settings->isCacheUsed());
429 $cache->setInfo($this->lng->txt('cal_cache_info'));
430 $cache->setRequired(true);
431
432 $sync_cache = new ilRadioOption($this->lng->txt('cal_cache_disabled'), 0);
433 $cache->addOption($sync_cache);
434
435 $sync_cache = new ilRadioOption($this->lng->txt('cal_cache_enabled'), 1);
436 $cache->addOption($sync_cache);
437
438 $cache_t = new ilNumberInputGUI('', 'cache_time');
439 $cache_t->setValue($this->settings->getCacheMinutes());
440 $cache_t->setMinValue(0);
441 $cache_t->setSize(3);
442 $cache_t->setMaxLength(3);
443 $cache_t->setSuffix($this->lng->txt('form_minutes'));
444 $sync_cache->addSubItem($cache_t);
445 $this->form->addItem($cache);
446 }
447
448 public function addToExternalSettingsForm($a_form_id)
449 {
450 switch ($a_form_id) {
452
453 $this->initCalendarSettings();
454
455 $fields = array();
456
457 $subitems = array('cal_setting_global_crs_vis' => array($this->settings->isCourseCalendarEnabled(), ilAdministrationSettingsFormHandler::VALUE_BOOL));
458 $fields['cal_setting_global_vis_repos'] = array(null, null, $subitems);
459
460 $subitems = array(
461 'cal_notification_crsgrp' => array($this->settings->isNotificationEnabled(), ilAdministrationSettingsFormHandler::VALUE_BOOL),
462 'cal_notification_users' => array($this->settings->isUserNotificationEnabled(), ilAdministrationSettingsFormHandler::VALUE_BOOL)
463 );
464 $fields['cal_notification'] = array(null, null, $subitems);
465
466 $fields['cal_cg_registrations'] = array($this->settings->isCGRegistrationEnabled(), ilAdministrationSettingsFormHandler::VALUE_BOOL);
467
468 return array(array("settings", $fields));
469
471
472 $this->initCalendarSettings();
473
474 $fields = array();
475
476 $subitems = array('cal_setting_global_grp_vis' => array($this->settings->isGroupCalendarEnabled(), ilAdministrationSettingsFormHandler::VALUE_BOOL));
477 $fields['cal_setting_global_vis_repos'] = array(null, null, $subitems);
478
479 $subitems = array(
480 'cal_notification_crsgrp' => array($this->settings->isNotificationEnabled(), ilAdministrationSettingsFormHandler::VALUE_BOOL),
481 'cal_notification_users' => array($this->settings->isUserNotificationEnabled(), ilAdministrationSettingsFormHandler::VALUE_BOOL)
482 );
483 $fields['cal_notification'] = array(null, null, $subitems);
484
485 $fields['cal_cg_registrations'] = array($this->settings->isCGRegistrationEnabled(), ilAdministrationSettingsFormHandler::VALUE_BOOL);
486
487 return array(array("settings", $fields));
488 }
489 }
490}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
error($a_errmsg)
set error message @access public
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 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
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$ret
Definition: parser.php:6
$DIC
Definition: xapitoken.php:46