ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjCalendarSettingsGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
27{
29
34 public function __construct($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
35 {
36 global $DIC;
37
38 $this->type = 'cals';
39 parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
40 $this->initCalendarSettings();
41
42 $this->lng->loadLanguageModule('dateplaner');
43 $this->lng->loadLanguageModule('jscalendar');
44 }
45
46 public function executeCommand(): void
47 {
48 $next_class = $this->ctrl->getNextClass($this);
49 $cmd = $this->ctrl->getCmd();
50
51 $this->prepareOutput();
52
53 if (!$this->rbac_system->checkAccess("visible,read", $this->object->getRefId())) {
54 $this->error->raiseError($this->lng->txt('no_permission'), $this->error->WARNING);
55 }
56
57 switch ($next_class) {
58 case 'ilpermissiongui':
59 $this->tabs_gui->setTabActive('perm_settings');
60 $perm_gui = new ilPermissionGUI($this);
61 $ret = $this->ctrl->forwardCommand($perm_gui);
62 break;
63
64 default:
65 $this->tabs_gui->setTabActive('settings');
66 $this->initCalendarSettings();
67 if (!$cmd || $cmd == 'view') {
68 $cmd = "settings";
69 }
70 $this->$cmd();
71 break;
72 }
73 }
74
75 public function getAdminTabs(): void
76 {
77 if ($this->access->checkAccess("read", '', $this->object->getRefId())) {
78 $this->tabs_gui->addTarget(
79 "settings",
80 $this->ctrl->getLinkTarget($this, "settings"),
81 array("settings", "view")
82 );
83 }
84
85 if ($this->access->checkAccess('edit_permission', '', $this->object->getRefId())) {
86 $this->tabs_gui->addTarget(
87 "perm_settings",
88 $this->ctrl->getLinkTargetByClass('ilpermissiongui', "perm"),
89 array(),
90 'ilpermissiongui'
91 );
92 }
93 }
94
95 public function settings(?ilPropertyFormGUI $form = null): void
96 {
97 if (!$this->rbac_system->checkAccess("visible,read", $this->object->getRefId())) {
98 $this->error->raiseError($this->lng->txt('no_permission'), $this->error->WARNING);
99 }
100 $this->tabs_gui->setTabActive('settings');
101 if (!$form instanceof ilPropertyFormGUI) {
102 $form = $this->initFormSettings();
103 }
104 $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.settings.html', 'components/ILIAS/Calendar');
105 $this->tpl->setVariable('CAL_SETTINGS', $form->getHTML());
106 }
107
112 protected function save()
113 {
114 $this->checkPermission('write');
115
116 $form = $this->initFormSettings();
117 if ($form->checkInput()) {
118 $this->calendar_settings->setEnabled((bool) $form->getInput('enable'));
119 $this->calendar_settings->setDefaultWeekStart((int) $form->getInput('default_week_start'));
120 $this->calendar_settings->setDefaultTimeZone($form->getInput('default_timezone'));
121 $this->calendar_settings->setDefaultDateFormat((int) $form->getInput('default_date_format'));
122 $this->calendar_settings->setDefaultTimeFormat((int) $form->getInput('default_time_format'));
123 $this->calendar_settings->enableCourseCalendar((bool) $form->getInput('enabled_crs'));
124 $this->calendar_settings->setCourseCalendarVisible((bool) $form->getInput('visible_crs'));
125 $this->calendar_settings->enableGroupCalendar((bool) $form->getInput('enabled_grp'));
126 $this->calendar_settings->setGroupCalendarVisible((bool) $form->getInput('visible_grp'));
127 $this->calendar_settings->setDefaultDayStart((int) $form->getInput('dst'));
128 $this->calendar_settings->setDefaultDayEnd((int) $form->getInput('den'));
129 $this->calendar_settings->enableSynchronisationCache((bool) $form->getInput('sync_cache'));
130 $this->calendar_settings->setSynchronisationCacheMinutes((int) $form->getInput('sync_cache_time'));
131 $this->calendar_settings->setCacheMinutes((int) $form->getInput('cache_time'));
132 $this->calendar_settings->useCache((bool) $form->getInput('cache'));
133 $this->calendar_settings->enableNotification((bool) $form->getInput('cn'));
134 $this->calendar_settings->enableUserNotification((bool) $form->getInput('cnu'));
135 $this->calendar_settings->enableConsultationHours((bool) $form->getInput('ch'));
136 $this->calendar_settings->enableCGRegistration((bool) $form->getInput('cgr'));
137 $this->calendar_settings->enableWebCalSync((bool) $form->getInput('webcal'));
138 $this->calendar_settings->setWebCalSyncHours((int) $form->getInput('webcal_hours'));
139 $this->calendar_settings->setShowWeeks((bool) $form->getInput('show_weeks'));
140 $this->calendar_settings->enableBatchFileDownloads((bool) $form->getInput('batch_files'));
141 $this->calendar_settings->setDefaultCal((int) $form->getInput('default_calendar_view'));
142 $this->calendar_settings->setDefaultPeriod((int) $form->getInput('default_period'));
143 $this->calendar_settings->save();
144 $this->tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true);
145 $this->ctrl->redirect($this, 'settings');
146 }
147 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('err_check_input'), true);
148 $this->settings($form);
149 }
150
154 protected function initCalendarSettings(): void
155 {
156 $this->calendar_settings = ilCalendarSettings::_getInstance();
157 }
158
164 {
165 $form = new ilPropertyFormGUI();
166 $form->setFormAction($this->ctrl->getFormAction($this));
167 $form->setTitle($this->lng->txt('cal_global_settings'));
168
169 if ($this->checkPermissionBool('write')) {
170 $form->addCommandButton('save', $this->lng->txt('save'));
171 }
172
173 $check = new ilCheckboxInputGUI($this->lng->txt('enable_calendar'), 'enable');
174 $check->setValue('1');
175 $check->setChecked($this->calendar_settings->isEnabled() ? true : false);
176 $form->addItem($check);
177
178 // show weeks
179 $cb = new ilCheckboxInputGUI($this->lng->txt("cal_def_show_weeks"), "show_weeks");
180 $cb->setInfo($this->lng->txt("cal_show_weeks_info"));
181 $cb->setValue('1');
182 $cb->setChecked($this->calendar_settings->getShowWeeks());
183 $form->addItem($cb);
184
187 $form,
188 $this
189 );
190
191 //Batch File Downloads in Calendar
192 $batch_files_download = new ilCheckboxInputGUI($this->lng->txt('cal_batch_file_downloads'), "batch_files");
193 $batch_files_download->setValue('1');
194 $batch_files_download->setChecked($this->calendar_settings->isBatchFileDownloadsEnabled());
195 $batch_files_download->setInfo($this->lng->txt('cal_batch_file_downloads_info'));
196 $form->addItem($batch_files_download);
197
198 $def = new ilFormSectionHeaderGUI();
199 $def->setTitle($this->lng->txt('cal_default_settings'));
200 $form->addItem($def);
201
202 $server_tz = new ilNonEditableValueGUI($this->lng->txt('cal_server_tz'));
203 $server_tz->setValue(ilTimeZone::_getDefaultTimeZone());
204 $form->addItem($server_tz);
205
206 $select = new ilSelectInputGUI($this->lng->txt('cal_def_timezone'), 'default_timezone');
207 $select->setOptions(ilCalendarUtil::_getShortTimeZoneList());
208 $select->setInfo($this->lng->txt('cal_def_timezone_info'));
209 $select->setValue($this->calendar_settings->getDefaultTimeZone());
210 $form->addItem($select);
211
212 $year = date("Y");
213 $select = new ilSelectInputGUI($this->lng->txt('cal_def_date_format'), 'default_date_format');
214 $select->setOptions(array(
215 ilCalendarSettings::DATE_FORMAT_DMY => '31.10.' . $year,
216 ilCalendarSettings::DATE_FORMAT_YMD => $year . "-10-31",
217 ilCalendarSettings::DATE_FORMAT_MDY => "10/31/" . $year
218 ));
219 $select->setInfo($this->lng->txt('cal_def_date_format_info'));
220 $select->setValue($this->calendar_settings->getDefaultDateFormat());
221 $form->addItem($select);
222
223 $select = new ilSelectInputGUI($this->lng->txt('cal_def_time_format'), 'default_time_format');
224 $select->setOptions(array(
227 ));
228 $select->setInfo($this->lng->txt('cal_def_time_format_info'));
229 $select->setValue($this->calendar_settings->getDefaultTimeFormat());
230 $form->addItem($select);
231
232 // Weekstart
233 $radio = new ilRadioGroupInputGUI($this->lng->txt('cal_def_week_start'), 'default_week_start');
234 $radio->setValue((string) $this->calendar_settings->getDefaultWeekStart());
235
236 $option = new ilRadioOption($this->lng->txt('l_su'), '0');
237 $radio->addOption($option);
238 $option = new ilRadioOption($this->lng->txt('l_mo'), '1');
239 $radio->addOption($option);
240
241 $form->addItem($radio);
242
243 $default_cal_view = new ilRadioGroupInputGUI($this->lng->txt('cal_def_view'), 'default_calendar_view');
244
245 $option = new ilRadioOption($this->lng->txt("day"), (string) ilCalendarSettings::DEFAULT_CAL_DAY);
246 $default_cal_view->addOption($option);
247 $option = new ilRadioOption($this->lng->txt("week"), (string) ilCalendarSettings::DEFAULT_CAL_WEEK);
248 $default_cal_view->addOption($option);
249 $option = new ilRadioOption($this->lng->txt("month"), (string) ilCalendarSettings::DEFAULT_CAL_MONTH);
250 $default_cal_view->addOption($option);
251
252 $option = new ilRadioOption($this->lng->txt("cal_list"), (string) ilCalendarSettings::DEFAULT_CAL_LIST);
253
254 $list_views = new ilSelectInputGUI($this->lng->txt("cal_list"), "default_period");
255 $list_views->setOptions([
256 ilCalendarAgendaListGUI::PERIOD_DAY => "1 " . $this->lng->txt("day"),
257 ilCalendarAgendaListGUI::PERIOD_WEEK => "1 " . $this->lng->txt("week"),
258 ilCalendarAgendaListGUI::PERIOD_MONTH => "1 " . $this->lng->txt("month"),
259 ilCalendarAgendaListGUI::PERIOD_HALF_YEAR => "6 " . $this->lng->txt("months")
260 ]);
261
262 $list_views->setValue($this->calendar_settings->getDefaultPeriod());
263 $option->addSubItem($list_views);
264 $default_cal_view->addOption($option);
265 $default_cal_view->setValue((string) $this->calendar_settings->getDefaultCal());
266
267 $form->addItem($default_cal_view);
268
269 // Day start
270 $day_start = new ilSelectInputGUI($this->lng->txt('cal_def_day_start'), 'dst');
271 $day_start->setOptions(
272 ilCalendarUtil::getHourSelection($this->calendar_settings->getDefaultTimeFormat())
273 );
274 $day_start->setValue($this->calendar_settings->getDefaultDayStart());
275 $form->addItem($day_start);
276
277 $day_end = new ilSelectInputGUI($this->lng->txt('cal_def_day_end'), 'den');
278 $day_end->setOptions(
279 ilCalendarUtil::getHourSelection($this->calendar_settings->getDefaultTimeFormat())
280 );
281 $day_end->setValue($this->calendar_settings->getDefaultDayEnd());
282 $form->addItem($day_end);
283
284 // Consultation hours
285 $con = new ilFormSectionHeaderGUI();
286 $con->setTitle($this->lng->txt('cal_ch_form_header'));
287 $form->addItem($con);
288
289 $ch = new ilCheckboxInputGUI($this->lng->txt('cal_ch_form'), 'ch');
290 $ch->setInfo($this->lng->txt('cal_ch_form_info'));
291 $ch->setValue('1');
292 $ch->setChecked($this->calendar_settings->areConsultationHoursEnabled());
293 $form->addItem($ch);
294
295 // repository visibility default
296 $rep = new ilFormSectionHeaderGUI();
297 $rep->setTitle($GLOBALS['DIC']['lng']->txt('cal_setting_global_vis_repos'));
298 $form->addItem($rep);
299
300 $crs_active = new ilCheckboxInputGUI(
301 $this->lng->txt('cal_setting_global_crs_act'),
302 'enabled_crs'
303 );
304 $crs_active->setInfo($this->lng->txt('cal_setting_global_crs_act_info'));
305 $crs_active->setValue('1');
306 $crs_active->setChecked($this->calendar_settings->isCourseCalendarEnabled());
307 $form->addItem($crs_active);
308
309 $crs = new ilCheckboxInputGUI($GLOBALS['DIC']['lng']->txt('cal_setting_global_crs_vis'), 'visible_crs');
310 $crs->setInfo($GLOBALS['DIC']['lng']->txt('cal_setting_global_crs_vis_info'));
311 $crs->setValue('1');
312 $crs->setChecked($this->calendar_settings->isCourseCalendarVisible());
313 $crs_active->addSubItem($crs);
314
315 $grp_active = new ilCheckboxInputGUI(
316 $this->lng->txt('cal_setting_global_grp_act'),
317 'enabled_grp'
318 );
319 $grp_active->setInfo($this->lng->txt('cal_setting_global_grp_act_info'));
320 $grp_active->setValue('1');
321 $grp_active->setChecked($this->calendar_settings->isGroupCalendarEnabled());
322 $form->addItem($grp_active);
323
324 $grp = new ilCheckboxInputGUI($GLOBALS['DIC']['lng']->txt('cal_setting_global_grp_vis'), 'visible_grp');
325 $grp->setInfo($GLOBALS['DIC']['lng']->txt('cal_setting_global_grp_vis_info'));
326 $grp->setValue('1');
327 $grp->setInfo($GLOBALS['DIC']['lng']->txt('cal_setting_global_grp_vis_info'));
328 $grp->setChecked($this->calendar_settings->isGroupCalendarVisible());
329 $grp_active->addSubItem($grp);
330
331 // Notifications
332 $not = new ilFormSectionHeaderGUI();
333 $not->setTitle($this->lng->txt('notifications'));
334 $form->addItem($not);
335
336 $cgn = new ilCheckboxInputGUI($this->lng->txt('cal_notification'), 'cn');
337 $cgn->setOptionTitle($this->lng->txt('cal_notification_crsgrp'));
338 $cgn->setValue('1');
339 $cgn->setChecked($this->calendar_settings->isNotificationEnabled());
340 $cgn->setInfo($this->lng->txt('cal_adm_notification_info'));
341 $form->addItem($cgn);
342
343 $cnu = new ilCheckboxInputGUI('', 'cnu');
344 $cnu->setOptionTitle($this->lng->txt('cal_notification_users'));
345 $cnu->setValue('1');
346 $cnu->setChecked($this->calendar_settings->isUserNotificationEnabled());
347 $cnu->setInfo($this->lng->txt('cal_adm_notification_user_info'));
348 $form->addItem($cnu);
349
350 // Registration
351 $book = new ilFormSectionHeaderGUI();
352 $book->setTitle($this->lng->txt('cal_registrations'));
353 $form->addItem($book);
354
355 $cgn = new ilCheckboxInputGUI($this->lng->txt('cal_cg_registrations'), 'cgr');
356 $cgn->setValue('1');
357 $cgn->setChecked($this->calendar_settings->isCGRegistrationEnabled());
358 $cgn->setInfo($this->lng->txt('cal_cg_registration_info'));
359 $form->addItem($cgn);
360
361 // Synchronisation cache
362 $sec = new ilFormSectionHeaderGUI();
363 $sec->setTitle($this->lng->txt('cal_cache_settings'));
364 $form->addItem($sec);
365
366 $cache = new ilRadioGroupInputGUI($this->lng->txt('cal_sync_cache'), 'sync_cache');
367 $cache->setValue((string) (int) $this->calendar_settings->isSynchronisationCacheEnabled());
368 $cache->setInfo($this->lng->txt('cal_sync_cache_info'));
369 $cache->setRequired(true);
370
371 $sync_cache = new ilRadioOption($this->lng->txt('cal_sync_disabled'), '0');
372 $cache->addOption($sync_cache);
373
374 $sync_cache = new ilRadioOption($this->lng->txt('cal_sync_enabled'), '1');
375 $cache->addOption($sync_cache);
376
377 $cache_t = new ilNumberInputGUI('', 'sync_cache_time');
378 $cache_t->setValue((string) $this->calendar_settings->getSynchronisationCacheMinutes());
379 $cache_t->setMinValue(0);
380 $cache_t->setSize(3);
381 $cache_t->setMaxLength(3);
382 $cache_t->setSuffix($this->lng->txt('form_minutes'));
383 $sync_cache->addSubItem($cache_t);
384
385 $form->addItem($cache);
386
387 // Calendar cache
388 $cache = new ilRadioGroupInputGUI($this->lng->txt('cal_cache'), 'cache');
389 $cache->setValue((string) (int) $this->calendar_settings->isCacheUsed());
390 $cache->setInfo($this->lng->txt('cal_cache_info'));
391 $cache->setRequired(true);
392
393 $sync_cache = new ilRadioOption($this->lng->txt('cal_cache_disabled'), '0');
394 $cache->addOption($sync_cache);
395
396 $sync_cache = new ilRadioOption($this->lng->txt('cal_cache_enabled'), '1');
397 $cache->addOption($sync_cache);
398
399 $cache_t = new ilNumberInputGUI('', 'cache_time');
400 $cache_t->setValue((string) $this->calendar_settings->getCacheMinutes());
401 $cache_t->setMinValue(0);
402 $cache_t->setSize(3);
403 $cache_t->setMaxLength(3);
404 $cache_t->setSuffix($this->lng->txt('form_minutes'));
405 $sync_cache->addSubItem($cache_t);
406 $form->addItem($cache);
407 return $form;
408 }
409
410 public function addToExternalSettingsForm(int $a_form_id): array
411 {
412 switch ($a_form_id) {
414
415 $this->initCalendarSettings();
416
417 $fields = array();
418
419 $subitems = array(
420 'cal_setting_global_crs_act' => [
421 $this->calendar_settings->isCourseCalendarEnabled(),
423 ],
424 'cal_setting_global_crs_vis' =>
425 array($this->calendar_settings->isCourseCalendarVisible(),
427 ),
428
429 );
430 $fields['cal_setting_global_vis_repos'] = array(null, null, $subitems);
431
432 $subitems = array(
433 'cal_notification_crsgrp' => array($this->calendar_settings->isNotificationEnabled(),
435 ),
436 'cal_notification_users' => array($this->calendar_settings->isUserNotificationEnabled(),
438 )
439 );
440 $fields['cal_notification'] = array(null, null, $subitems);
441
442 $fields['cal_cg_registrations'] = array($this->calendar_settings->isCGRegistrationEnabled(),
444 );
445
446 return array(array("settings", $fields));
447
449
450 $this->initCalendarSettings();
451
452 $fields = array();
453
454 $subitems = array(
455 'cal_setting_global_grp_act' => [
456 $this->calendar_settings->isGroupCalendarEnabled(),
458 ],
459 'cal_setting_global_grp_vis' =>
460 array($this->calendar_settings->isGroupCalendarVisible(),
462 ),
463
464 );
465
466 $fields['cal_setting_global_vis_repos'] = array(null, null, $subitems);
467
468 $subitems = array(
469 'cal_notification_crsgrp' => array($this->calendar_settings->isNotificationEnabled(),
471 ),
472 'cal_notification_users' => array($this->calendar_settings->isUserNotificationEnabled(),
474 )
475 );
476 $fields['cal_notification'] = array(null, null, $subitems);
477
478 $fields['cal_cg_registrations'] = array($this->calendar_settings->isCGRegistrationEnabled(),
480 );
481
482 return array(array("settings", $fields));
483 }
484 return [];
485 }
486}
$check
Definition: buildRTE.php:81
error(string $a_errmsg)
static addFieldsToForm(int $a_form_id, ilPropertyFormGUI $a_form, ilObjectGUI $a_parent_gui)
Stores all calendar relevant settings.
static _getShortTimeZoneList()
get short timezone list
static getHourSelection(int $a_format)
Get hour selection 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 @access protected.
initCalendarSettings()
init calendar settings
settings(?ilPropertyFormGUI $form=null)
save()
save settings @access protected
__construct($a_data, $a_id, $a_call_by_reference=true, $a_prepare_output=true)
Constructor @access public.
getAdminTabs()
administration tabs show only permissions and trash folder
Class ilObjectGUI Basic methods of all Output classes.
checkPermission(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
checkPermissionBool(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
prepareOutput(bool $show_sub_objects=true)
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.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26
$GLOBALS["DIC"]
Definition: wac.php:54