ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilCalendarUserSettingsGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
26{
29 protected ilLanguage $lng;
30 protected ilObjUser $user;
33
39 public function __construct()
40 {
41 global $DIC;
42
43 $this->tpl = $DIC->ui()->mainTemplate();
44 $this->lng = $DIC->language();
45 $this->lng->loadLanguageModule('dateplaner');
46 $this->lng->loadLanguageModule('jscalendar');
47
48 $this->ctrl = $DIC->ctrl();
49 $this->user = $DIC->user();
51 $this->user_settings = ilCalendarUserSettings::_getInstanceByUserId($this->user->getId());
52 }
53
54 public function executeCommand(): void
55 {
56 $next_class = $this->ctrl->getNextClass();
57 switch ($next_class) {
58 default:
59 $cmd = $this->ctrl->getCmd("show");
60 $this->$cmd();
61 break;
62 }
63 }
64
65 public function show(?ilPropertyFormGUI $form = null): void
66 {
67 if (!$form instanceof ilPropertyFormGUI) {
68 $form = $this->initSettingsForm();
69 }
70 $this->tpl->setContent($form->getHTML());
71 }
72
73 public function cancel(): void
74 {
75 $this->ctrl->returnToParent($this);
76 }
77
78 public function save()
79 {
80 $form = $this->initSettingsForm();
81 if ($form->checkInput()) {
82 $this->user_settings->setTimeZone($form->getInput('timezone'));
83 $this->user_settings->setExportTimeZoneType((int) $form->getInput('export_tz'));
84 $this->user_settings->setWeekStart((int) $form->getInput('weekstart'));
85 $this->user_settings->setDateFormat((int) $form->getInput('date_format'));
86 $this->user_settings->setTimeFormat((int) $form->getInput('time_format'));
87 $this->user_settings->setDayStart((int) $form->getInput('dst'));
88 $this->user_settings->setDayEnd((int) $form->getInput('den'));
89 $this->user_settings->setShowWeeks((bool) $form->getInput('show_weeks'));
90 $this->user_settings->save();
91 $this->tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true);
92 $this->ctrl->redirect($this, "show");
93 } else {
94 $form->setValuesByPost();
95 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('err_check_input'), true);
96 $this->show();
97 }
98 }
99
101 {
102 $form = new ilPropertyFormGUI();
103 $form->setFormAction($this->ctrl->getFormAction($this, 'save'));
104 $form->setTitle($this->lng->txt('cal_user_settings'));
105 $form->addCommandButton('save', $this->lng->txt('save'));
106 //$form->addCommandButton('cancel',$this->lng->txt('cancel'));
107
108 $select = new ilSelectInputGUI($this->lng->txt('cal_user_timezone'), 'timezone');
109 $select->setOptions(ilCalendarUtil::_getShortTimeZoneList());
110 $select->setInfo($this->lng->txt('cal_timezone_info'));
111 $select->setValue($this->user_settings->getTimeZone());
112 $form->addItem($select);
113
114 $export_type = new ilRadioGroupInputGUI($this->lng->txt('cal_export_timezone'), 'export_tz');
115 $export_type->setValue((string) $this->user_settings->getExportTimeZoneType());
116
117 $export_tz = new ilRadioOption(
118 $this->lng->txt('cal_export_timezone_tz'),
120 );
121 $export_type->addOption($export_tz);
122 $export_utc = new ilRadioOption(
123 $this->lng->txt('cal_export_timezone_utc'),
125 );
126 $export_type->addOption($export_utc);
127 $form->addItem($export_type);
128
129 $year = date("Y");
130 $select = new ilSelectInputGUI($this->lng->txt('cal_user_date_format'), 'date_format');
131 $select->setOptions(array(
132 ilCalendarSettings::DATE_FORMAT_DMY => '31.10.' . $year,
133 ilCalendarSettings::DATE_FORMAT_YMD => $year . "-10-31",
134 ilCalendarSettings::DATE_FORMAT_MDY => "10/31/" . $year
135 ));
136 $select->setInfo($this->lng->txt('cal_date_format_info'));
137 $select->setValue($this->user_settings->getDateFormat());
138 $form->addItem($select);
139
140 $select = new ilSelectInputGUI($this->lng->txt('cal_user_time_format'), 'time_format');
141 $select->setOptions(array(
144 ));
145 $select->setInfo($this->lng->txt('cal_time_format_info'));
146 $select->setValue($this->user_settings->getTimeFormat());
147 $form->addItem($select);
148
149 // Week/Month View
150 $week_month = new ilFormSectionHeaderGUI();
151 $week_month->setTitle($this->lng->txt('cal_week_month_view'));
152 $form->addItem($week_month);
153
154 $radio = new ilRadioGroupInputGUI($this->lng->txt('cal_week_start'), 'weekstart');
155 $radio->setValue((string) $this->user_settings->getWeekStart());
156
157 $option = new ilRadioOption($this->lng->txt('l_su'), "0");
158 $radio->addOption($option);
159 $option = new ilRadioOption($this->lng->txt('l_mo'), "1");
160 $radio->addOption($option);
161 $form->addItem($radio);
162
163 if ($this->settings->getShowWeeks()) {
164 //
165 $cb = new ilCheckboxInputGUI($this->lng->txt("cal_usr_show_weeks"), "show_weeks");
166 $cb->setInfo($this->lng->txt("cal_usr_show_weeks_info"));
167 $cb->setValue("1");
168 $cb->setChecked($this->user_settings->getShowWeeks());
169 $form->addItem($cb);
170 }
171
172 // Day/Week View
173 $week_month = new ilFormSectionHeaderGUI();
174 $week_month->setTitle($this->lng->txt('cal_day_week_view'));
175 $form->addItem($week_month);
176
177 $day_start = new ilSelectInputGUI($this->lng->txt('cal_day_start'), 'dst');
178 $day_start->setOptions(
179 ilCalendarUtil::getHourSelection($this->user_settings->getTimeFormat())
180 );
181 $day_start->setValue($this->user_settings->getDayStart());
182 $form->addItem($day_start);
183
184 $day_end = new ilSelectInputGUI($this->lng->txt('cal_day_end'), 'den');
185 $day_end->setOptions(
186 ilCalendarUtil::getHourSelection($this->user_settings->getTimeFormat())
187 );
188 $day_end->setValue($this->user_settings->getDayEnd());
189 $form->addItem($day_end);
190 return $form;
191 }
192}
Stores all calendar relevant settings.
show(?ilPropertyFormGUI $form=null)
__construct()
Constructor @access public.
static _getInstanceByUserId(int $a_user_id)
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.
language handling
User class.
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.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:26