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