ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
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  $this->rbacsystem = $this->dic->rbac()->system();
68  $this->lng = $this->dic->language();
69  $this->lng->loadLanguageModule('dateplaner');
70  $this->lng->loadLanguageModule('jscalendar');
71  }
72 
79  public function executeCommand()
80  {
81  $next_class = $this->ctrl->getNextClass($this);
82  $cmd = $this->ctrl->getCmd();
83 
84  $this->prepareOutput();
85 
86  if (!$this->rbacsystem->checkAccess("visible,read", $this->object->getRefId())) {
87  $this->error->raiseError($this->lng->txt('no_permission'), $this->error->WARNING);
88  }
89 
90  switch ($next_class) {
91  case 'ilpermissiongui':
92  $this->tabs_gui->setTabActive('perm_settings');
93  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
94  $perm_gui = new ilPermissionGUI($this);
95  $ret = &$this->ctrl->forwardCommand($perm_gui);
96  break;
97 
98  default:
99  $this->tabs_gui->setTabActive('settings');
100  $this->initCalendarSettings();
101  if (!$cmd || $cmd == 'view') {
102  $cmd = "settings";
103  }
104 
105  $this->$cmd();
106  break;
107  }
108  return true;
109  }
110 
111 
118  public function getAdminTabs()
119  {
120  global $DIC;
121 
122  $rbacsystem = $DIC['rbacsystem'];
123  $ilAccess = $DIC['ilAccess'];
124 
125  if ($ilAccess->checkAccess("read", '', $this->object->getRefId())) {
126  $this->tabs_gui->addTarget(
127  "settings",
128  $this->ctrl->getLinkTarget($this, "settings"),
129  array("settings", "view")
130  );
131  }
132 
133  if ($ilAccess->checkAccess('edit_permission', '', $this->object->getRefId())) {
134  $this->tabs_gui->addTarget(
135  "perm_settings",
136  $this->ctrl->getLinkTargetByClass('ilpermissiongui', "perm"),
137  array(),
138  'ilpermissiongui'
139  );
140  }
141  }
142 
146  public function settings()
147  {
148  global $ilErr;
149 
150  if (!$this->rbacsystem->checkAccess("visible,read", $this->object->getRefId())) {
151  $ilErr->raiseError($this->lng->txt('no_permission'), $ilErr->WARNING);
152  }
153 
154  $this->tabs_gui->setTabActive('settings');
155  $this->initFormSettings();
156  $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.settings.html', 'Services/Calendar');
157  $this->tpl->setVariable('CAL_SETTINGS', $this->form->getHTML());
158  return true;
159  }
160 
166  protected function save()
167  {
168  $this->checkPermission('write');
169 
170  $this->settings->setEnabled((int) $_POST['enable']);
171  $this->settings->setDefaultWeekStart((int) $_POST['default_week_start']);
172  $this->settings->setDefaultTimeZone(ilUtil::stripSlashes($_POST['default_timezone']));
173  $this->settings->setDefaultDateFormat((int) $_POST['default_date_format']);
174  $this->settings->setDefaultTimeFormat((int) $_POST['default_time_format']);
175  $this->settings->setEnableGroupMilestones((int) $_POST['enable_grp_milestones']);
176  $this->settings->enableCourseCalendar((int) $_POST['enabled_crs']);
177  $this->settings->setCourseCalendarVisible((int) $_POST['visible_crs']);
178  $this->settings->enableGroupCalendar((int) $_POST['enabled_grp']);
179  $this->settings->setGroupCalendarVisible((int) $_POST['visible_grp']);
180  $this->settings->setDefaultDayStart((int) $_POST['dst']);
181  $this->settings->setDefaultDayEnd((int) $_POST['den']);
182  $this->settings->enableSynchronisationCache((bool) $_POST['sync_cache']);
183  $this->settings->setSynchronisationCacheMinutes((int) $_POST['sync_cache_time']);
184  $this->settings->setCacheMinutes((int) $_POST['cache_time']);
185  $this->settings->useCache((bool) $_POST['cache']);
186  $this->settings->enableNotification((bool) $_POST['cn']);
187  $this->settings->enableUserNotification((bool) $_POST['cnu']);
188  $this->settings->enableConsultationHours((bool) $_POST['ch']);
189  $this->settings->enableCGRegistration((bool) $_POST['cgr']);
190  $this->settings->enableWebCalSync((bool) $_POST['webcal']);
191  $this->settings->setWebCalSyncHours((int) $_POST['webcal_hours']);
192  $this->settings->setShowWeeks((int) $_POST['show_weeks']);
193  $this->settings->enableBatchFileDownloads((bool) $_POST['batch_files']);
194  $this->settings->setDefaultCal((int) $_POST['default_calendar_view']);
195  $this->settings->setDefaultPeriod((int) $_POST['default_period']);
196 
197  if (((int) $_POST['den']) < (int) $_POST['dst']) {
198  ilUtil::sendFailure($this->lng->txt('cal_dstart_dend_warn'));
199  $this->settings();
200  return false;
201  }
202 
203  $this->settings->save();
204 
205  ilUtil::sendSuccess($this->lng->txt('settings_saved'));
206  $this->settings();
207  }
208 
214  protected function initCalendarSettings()
215  {
216  include_once('Services/Calendar/classes/class.ilCalendarSettings.php');
218  }
219 
225  protected function initFormSettings()
226  {
227  if (is_object($this->form)) {
228  return true;
229  }
230 
231  $this->form = new ilPropertyFormGUI();
232  $this->form->setFormAction($this->ctrl->getFormAction($this));
233  $this->form->setTitle($this->lng->txt('cal_global_settings'));
234 
235 
236  if ($this->checkPermissionBool('write')) {
237  $this->form->addCommandButton('save', $this->lng->txt('save'));
238  }
239 
240  $check = new ilCheckboxInputGUI($this->lng->txt('enable_calendar'), 'enable');
241  $check->setValue(1);
242  $check->setChecked($this->settings->isEnabled() ? true : false);
243  $this->form->addItem($check);
244 
245  // show weeks
246  $cb = new ilCheckboxInputGUI($this->lng->txt("cal_def_show_weeks"), "show_weeks");
247  $cb->setInfo($this->lng->txt("cal_show_weeks_info"));
248  $cb->setValue(1);
249  $cb->setChecked($this->settings->getShowWeeks());
250  $this->form->addItem($cb);
251 
252  $sync = new ilCheckboxInputGUI($this->lng->txt('cal_webcal_sync'), 'webcal');
253  $sync->setValue(1);
254  $sync->setChecked($this->settings->isWebCalSyncEnabled());
255  $sync->setInfo($this->lng->txt('cal_webcal_sync_info'));
256 
257  $sync_min = new ilNumberInputGUI('', 'webcal_hours');
258  $sync_min->setSize(2);
259  $sync_min->setMaxLength(3);
260  $sync_min->setValue($this->settings->getWebCalSyncHours());
261  $sync_min->setSuffix($this->lng->txt('hours'));
262  $sync->addSubItem($sync_min);
263 
264  $this->form->addItem($sync);
265 
266  //Batch File Downloads in Calendar
267  $batch_files_download = new ilCheckboxInputGUI($this->lng->txt('cal_batch_file_downloads'), "batch_files");
268  $batch_files_download->setValue(1);
269  $batch_files_download->setChecked($this->settings->isBatchFileDownloadsEnabled());
270  $batch_files_download->setInfo($this->lng->txt('cal_batch_file_downloads_info'));
271  $this->form->addItem($batch_files_download);
272 
273  $def = new ilFormSectionHeaderGUI();
274  $def->setTitle($this->lng->txt('cal_default_settings'));
275  $this->form->addItem($def);
276 
277  $server_tz = new ilNonEditableValueGUI($this->lng->txt('cal_server_tz'));
279  $this->form->addItem($server_tz);
280 
281  $select = new ilSelectInputGUI($this->lng->txt('cal_def_timezone'), 'default_timezone');
282  $select->setOptions(ilCalendarUtil::_getShortTimeZoneList());
283  $select->setInfo($this->lng->txt('cal_def_timezone_info'));
284  $select->setValue($this->settings->getDefaultTimeZone());
285  $this->form->addItem($select);
286 
287  $year = date("Y");
288  $select = new ilSelectInputGUI($this->lng->txt('cal_def_date_format'), 'default_date_format');
289  $select->setOptions(array(
290  ilCalendarSettings::DATE_FORMAT_DMY => '31.10.' . $year,
291  ilCalendarSettings::DATE_FORMAT_YMD => $year . "-10-31",
292  ilCalendarSettings::DATE_FORMAT_MDY => "10/31/" . $year));
293  $select->setInfo($this->lng->txt('cal_def_date_format_info'));
294  $select->setValue($this->settings->getDefaultDateFormat());
295  $this->form->addItem($select);
296 
297  $select = new ilSelectInputGUI($this->lng->txt('cal_def_time_format'), 'default_time_format');
298  $select->setOptions(array(
301  $select->setInfo($this->lng->txt('cal_def_time_format_info'));
302  $select->setValue($this->settings->getDefaultTimeFormat());
303  $this->form->addItem($select);
304 
305  // Weekstart
306  $radio = new ilRadioGroupInputGUI($this->lng->txt('cal_def_week_start'), 'default_week_start');
307  $radio->setValue($this->settings->getDefaultWeekStart());
308 
309  $option = new ilRadioOption($this->lng->txt('l_su'), 0);
310  $radio->addOption($option);
311  $option = new ilRadioOption($this->lng->txt('l_mo'), 1);
312  $radio->addOption($option);
313 
314  $this->form->addItem($radio);
315 
316  $default_cal_view = new ilRadioGroupInputGUI($this->lng->txt('cal_def_view'), 'default_calendar_view');
317 
318  $option = new ilRadioOption($this->lng->txt("day"), ilCalendarSettings::DEFAULT_CAL_DAY);
319  $default_cal_view->addOption($option);
320  $option = new ilRadioOption($this->lng->txt("week"), ilCalendarSettings::DEFAULT_CAL_WEEK);
321  $default_cal_view->addOption($option);
322  $option = new ilRadioOption($this->lng->txt("month"), ilCalendarSettings::DEFAULT_CAL_MONTH);
323  $default_cal_view->addOption($option);
324 
325  $option = new ilRadioOption($this->lng->txt("cal_list"), ilCalendarSettings::DEFAULT_CAL_LIST);
326 
327  $list_views = new ilSelectInputGUI($this->lng->txt("cal_list"), "default_period");
328  $list_views->setOptions([
329  ilCalendarAgendaListGUI::PERIOD_DAY => "1 " . $this->lng->txt("day"),
330  ilCalendarAgendaListGUI::PERIOD_WEEK => "1 " . $this->lng->txt("week"),
331  ilCalendarAgendaListGUI::PERIOD_MONTH => "1 " . $this->lng->txt("month"),
332  ilCalendarAgendaListGUI::PERIOD_HALF_YEAR => "6 " . $this->lng->txt("months")
333  ]);
334 
335 
336  $list_views->setValue($this->settings->getDefaultPeriod());
337  $option->addSubItem($list_views);
338  $default_cal_view->addOption($option);
339  $default_cal_view->setValue($this->settings->getDefaultCal());
340 
341  $this->form->addItem($default_cal_view);
342 
343  // Day start
344  $day_start = new ilSelectInputGUI($this->lng->txt('cal_def_day_start'), 'dst');
345  $day_start->setOptions(
346  ilCalendarUtil::getHourSelection($this->settings->getDefaultTimeFormat())
347  );
348  $day_start->setValue($this->settings->getDefaultDayStart());
349  $this->form->addItem($day_start);
350 
351  $day_end = new ilSelectInputGUI($this->lng->txt('cal_def_day_end'), 'den');
352  $day_end->setOptions(
353  ilCalendarUtil::getHourSelection($this->settings->getDefaultTimeFormat())
354  );
355  $day_end->setValue($this->settings->getDefaultDayEnd());
356  $this->form->addItem($day_end);
357 
358  // enable milestone planning in groups
359  $mil = new ilFormSectionHeaderGUI();
360  $mil->setTitle($this->lng->txt('cal_milestone_settings'));
361  $this->form->addItem($mil);
362 
363  $checkm = new ilCheckboxInputGUI($this->lng->txt('cal_enable_group_milestones'), 'enable_grp_milestones');
364  $checkm->setValue(1);
365  $checkm->setChecked($this->settings->getEnableGroupMilestones() ? true : false);
366  $checkm->setInfo($this->lng->txt('cal_enable_group_milestones_desc'));
367  $this->form->addItem($checkm);
368 
369  // Consultation hours
370  $con = new ilFormSectionHeaderGUI();
371  $con->setTitle($this->lng->txt('cal_ch_form_header'));
372  $this->form->addItem($con);
373 
374  $ch = new ilCheckboxInputGUI($this->lng->txt('cal_ch_form'), 'ch');
375  $ch->setInfo($this->lng->txt('cal_ch_form_info'));
376  $ch->setValue(1);
377  $ch->setChecked($this->settings->areConsultationHoursEnabled());
378  $this->form->addItem($ch);
379 
380  // repository visibility default
381  $rep = new ilFormSectionHeaderGUI();
382  $rep->setTitle($GLOBALS['DIC']['lng']->txt('cal_setting_global_vis_repos'));
383  $this->form->addItem($rep);
384 
385  $crs_active = new ilCheckboxInputGUI(
386  $this->lng->txt('cal_setting_global_crs_act'),
387  'enabled_crs'
388  );
389  $crs_active->setInfo($this->lng->txt('cal_setting_global_crs_act_info'));
390  $crs_active->setValue(1);
391  $crs_active->setChecked($this->settings->isCourseCalendarEnabled());
392  $this->form->addItem($crs_active);
393 
394  $crs = new ilCheckboxInputGUI($GLOBALS['DIC']['lng']->txt('cal_setting_global_crs_vis'), 'visible_crs');
395  $crs->setInfo($GLOBALS['DIC']['lng']->txt('cal_setting_global_crs_vis_info'));
396  $crs->setValue(1);
397  $crs->setChecked($this->settings->isCourseCalendarVisible());
398  $crs_active->addSubItem($crs);
399 
400  $grp_active = new ilCheckboxInputGUI(
401  $this->lng->txt('cal_setting_global_grp_act'),
402  'enabled_grp'
403  );
404  $grp_active->setInfo($this->lng->txt('cal_setting_global_grp_act_info'));
405  $grp_active->setValue(1);
406  $grp_active->setChecked($this->settings->isGroupCalendarEnabled());
407  $this->form->addItem($grp_active);
408 
409  $grp = new ilCheckboxInputGUI($GLOBALS['DIC']['lng']->txt('cal_setting_global_grp_vis'), 'visible_grp');
410  $grp->setInfo($GLOBALS['DIC']['lng']->txt('cal_setting_global_grp_vis_info'));
411  $grp->setValue(1);
412  $grp->setInfo($GLOBALS['DIC']['lng']->txt('cal_setting_global_grp_vis_info'));
413  $grp->setChecked($this->settings->isGroupCalendarVisible());
414  $grp_active->addSubItem($grp);
415 
416  // Notifications
417  $not = new ilFormSectionHeaderGUI();
418  $not->setTitle($this->lng->txt('notifications'));
419  $this->form->addItem($not);
420 
421  $cgn = new ilCheckboxInputGUI($this->lng->txt('cal_notification'), 'cn');
422  $cgn->setOptionTitle($this->lng->txt('cal_notification_crsgrp'));
423  $cgn->setValue(1);
424  $cgn->setChecked($this->settings->isNotificationEnabled());
425  $cgn->setInfo($this->lng->txt('cal_adm_notification_info'));
426  $this->form->addItem($cgn);
427 
428  $cnu = new ilCheckboxInputGUI('', 'cnu');
429  $cnu->setOptionTitle($this->lng->txt('cal_notification_users'));
430  $cnu->setValue(1);
431  $cnu->setChecked($this->settings->isUserNotificationEnabled());
432  $cnu->setInfo($this->lng->txt('cal_adm_notification_user_info'));
433  $this->form->addItem($cnu);
434 
435 
436  // Registration
437  $book = new ilFormSectionHeaderGUI();
438  $book->setTitle($this->lng->txt('cal_registrations'));
439  $this->form->addItem($book);
440 
441  $cgn = new ilCheckboxInputGUI($this->lng->txt('cal_cg_registrations'), 'cgr');
442  $cgn->setValue(1);
443  $cgn->setChecked($this->settings->isCGRegistrationEnabled());
444  $cgn->setInfo($this->lng->txt('cal_cg_registration_info'));
445  $this->form->addItem($cgn);
446 
447  // Synchronisation cache
448  $sec = new ilFormSectionHeaderGUI();
449  $sec->setTitle($this->lng->txt('cal_cache_settings'));
450  $this->form->addItem($sec);
451 
452  $cache = new ilRadioGroupInputGUI($this->lng->txt('cal_sync_cache'), 'sync_cache');
453  $cache->setValue((int) $this->settings->isSynchronisationCacheEnabled());
454  $cache->setInfo($this->lng->txt('cal_sync_cache_info'));
455  $cache->setRequired(true);
456 
457  $sync_cache = new ilRadioOption($this->lng->txt('cal_sync_disabled'), 0);
458  $cache->addOption($sync_cache);
459 
460  $sync_cache = new ilRadioOption($this->lng->txt('cal_sync_enabled'), 1);
461  $cache->addOption($sync_cache);
462 
463  $cache_t = new ilNumberInputGUI('', 'sync_cache_time');
464  $cache_t->setValue($this->settings->getSynchronisationCacheMinutes());
465  $cache_t->setMinValue(0);
466  $cache_t->setSize(3);
467  $cache_t->setMaxLength(3);
468  $cache_t->setSuffix($this->lng->txt('form_minutes'));
469  $sync_cache->addSubItem($cache_t);
470 
471  $this->form->addItem($cache);
472 
473  // Calendar cache
474  $cache = new ilRadioGroupInputGUI($this->lng->txt('cal_cache'), 'cache');
475  $cache->setValue((int) $this->settings->isCacheUsed());
476  $cache->setInfo($this->lng->txt('cal_cache_info'));
477  $cache->setRequired(true);
478 
479  $sync_cache = new ilRadioOption($this->lng->txt('cal_cache_disabled'), 0);
480  $cache->addOption($sync_cache);
481 
482  $sync_cache = new ilRadioOption($this->lng->txt('cal_cache_enabled'), 1);
483  $cache->addOption($sync_cache);
484 
485  $cache_t = new ilNumberInputGUI('', 'cache_time');
486  $cache_t->setValue($this->settings->getCacheMinutes());
487  $cache_t->setMinValue(0);
488  $cache_t->setSize(3);
489  $cache_t->setMaxLength(3);
490  $cache_t->setSuffix($this->lng->txt('form_minutes'));
491  $sync_cache->addSubItem($cache_t);
492  $this->form->addItem($cache);
493  }
494 
495  public function addToExternalSettingsForm($a_form_id)
496  {
497  switch ($a_form_id) {
499 
500  $this->initCalendarSettings();
501 
502  $fields = array();
503 
504  $subitems = array(
505  'cal_setting_global_crs_act' => [
506  $this->settings->isCourseCalendarEnabled(), ilAdministrationSettingsFormHandler::VALUE_BOOL
507  ],
508  'cal_setting_global_crs_vis' =>
509  array($this->settings->isCourseCalendarVisible(), ilAdministrationSettingsFormHandler::VALUE_BOOL),
510 
511  );
512  $fields['cal_setting_global_vis_repos'] = array(null, null, $subitems);
513 
514  $subitems = array(
515  'cal_notification_crsgrp' => array($this->settings->isNotificationEnabled(), ilAdministrationSettingsFormHandler::VALUE_BOOL),
516  'cal_notification_users' => array($this->settings->isUserNotificationEnabled(), ilAdministrationSettingsFormHandler::VALUE_BOOL)
517  );
518  $fields['cal_notification'] = array(null, null, $subitems);
519 
520  $fields['cal_cg_registrations'] = array($this->settings->isCGRegistrationEnabled(), ilAdministrationSettingsFormHandler::VALUE_BOOL);
521 
522  return array(array("settings", $fields));
523 
525 
526  $this->initCalendarSettings();
527 
528  $fields = array();
529 
530  $subitems = array(
531  'cal_setting_global_grp_act' => [
532  $this->settings->isGroupCalendarEnabled(), ilAdministrationSettingsFormHandler::VALUE_BOOL
533  ],
534  'cal_setting_global_grp_vis' =>
535  array($this->settings->isGroupCalendarVisible(), ilAdministrationSettingsFormHandler::VALUE_BOOL),
536 
537  );
538 
539  $fields['cal_setting_global_vis_repos'] = array(null, null, $subitems);
540 
541  $subitems = array(
542  'cal_notification_crsgrp' => array($this->settings->isNotificationEnabled(), ilAdministrationSettingsFormHandler::VALUE_BOOL),
543  'cal_notification_users' => array($this->settings->isUserNotificationEnabled(), ilAdministrationSettingsFormHandler::VALUE_BOOL)
544  );
545  $fields['cal_notification'] = array(null, null, $subitems);
546 
547  $fields['cal_cg_registrations'] = array($this->settings->isCGRegistrationEnabled(), ilAdministrationSettingsFormHandler::VALUE_BOOL);
548 
549  return array(array("settings", $fields));
550  }
551  }
552 }
static _getDefaultTimeZone()
Calculate and set default time zone.
This class represents an option in a radio group.
static _getInstance()
get singleton instance
This class represents a property form user interface.
static getHourSelection($a_format)
Get hour selectio depending on user specific hour format.
This class represents a section header in a property form.
This class represents a checkbox property in a property form.
static _getShortTimeZoneList()
get short timezone list
setInfo($a_info)
Set Information Text.
prepareOutput($a_show_subobjects=true)
prepare output
__construct($a_data, $a_id, $a_call_by_reference=true, $a_prepare_output=true)
Constructor.
This class represents a property in a property form.
setValue($a_value)
Set Value.
This class represents a number property in a property form.
Class ilObjectGUI Basic methods of all Output classes.
setValue($a_value)
Set Value.
global $DIC
Definition: goto.php:24
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
This class represents a non editable value in a property form.
__construct(Container $dic, ilPlugin $plugin)
$ret
Definition: parser.php:6
checkPermission($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission and redirect on error.
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
initCalendarSettings()
init calendar settings
setOptionTitle($a_optiontitle)
Set Option Title (optional).
initFormSettings()
Init settings property form.
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission.
$_POST["username"]