ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.SettingsGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
28
33{
34 public function __construct(
35 protected InternalDataService $data,
36 protected InternalDomainService $domain,
37 protected InternalGUIService $gui,
38 protected int $obj_id,
39 protected int $ref_id,
40 protected bool $creation_mode,
41 protected object $parent_gui
42 ) {
43 }
44
45 public function executeCommand(): void
46 {
47 $ctrl = $this->gui->ctrl();
48 $next_class = $ctrl->getNextClass($this);
49 $cmd = $ctrl->getCmd("edit");
50
51 switch ($next_class) {
52 case strtolower(ilDidacticTemplateGUI::class):
53 $ctrl->setReturn($this, 'edit');
54 $did = new ilDidacticTemplateGUI(
55 $this->parent_gui,
57 );
58 $ctrl->forwardCommand($did);
59 break;
60
61 default:
62 if (in_array($cmd, ["edit", "save"])) {
63 $this->$cmd();
64 }
65 }
66 }
67
68 protected function edit(): void
69 {
70 $mt = $this->gui->ui()->mainTemplate();
71 $form = $this->getEditForm();
72 $mt->setContent($form->render());
73 }
74
75 protected function getEditForm(): FormAdapterGUI
76 {
77 $lng = $this->domain->lng();
78 $settings = $this->domain->bookingSettings()->getByObjId($this->obj_id);
79 $form = (new FormAdapterGUI(self::class, 'save'))
80 ->section("general", $lng->txt("book_edit"))
82 $this->obj_id,
83 "book"
84 );
85 $form = $form->addDidacticTemplates(
86 "book",
87 $this->ref_id,
88 $this->creation_mode
89 );
90
91 $form = $form
92 ->switch(
93 "stype",
94 $lng->txt("book_schedule_type"),
95 "",
96 (string) $settings->getScheduleType()
97 );
98 $form = $form
99 ->group(
101 $lng->txt("book_schedule_type_fixed"),
102 $lng->txt("book_schedule_type_fixed_info")
103 )
104 ->number(
105 "period",
106 $lng->txt("book_reservation_filter_period"),
107 $lng->txt("days") . " - " .
108 $lng->txt("book_reservation_filter_period_info"),
109 $settings->getReservationPeriod()
110 )
111 ->checkbox(
112 "rmd",
113 $lng->txt("book_reminder_setting"),
114 "",
115 (bool) $settings->getReminderStatus()
116 )
117 ->number(
118 "rmd_day",
119 $lng->txt("book_reminder_day"),
120 "",
121 max($settings->getReminderDay(), 1)
122 )
123 ->group(
125 $lng->txt("book_schedule_type_none_direct"),
126 $lng->txt("book_schedule_type_none_direct_info")
127 )
128 ->number(
129 "limit",
130 $lng->txt("book_bookings_per_user") . " - " .
131 $lng->txt("book_overall_limit"),
132 "",
133 $settings->getOverallLimit()
134 );
135
136 $pref_options_disabled = false;
137 if ($settings->getScheduleType() === \ilObjBookingPool::TYPE_NO_SCHEDULE_PREFERENCES) {
138 $pref_manager = $this->domain->preferences(
139 new \ilObjBookingPool($this->ref_id)
140 );
141 $pref_options_disabled = $pref_manager->hasRun();
142 }
143
144 $form = $form
145 ->group(
147 $lng->txt("book_schedule_type_none_preference"),
148 $lng->txt("book_schedule_type_none_preference_info")
149 );
150 $form = $form
151 ->number(
152 "preference_nr",
153 $lng->txt("book_nr_of_preferences"),
154 $lng->txt("book_nr_preferences") . " - " .
155 $lng->txt("book_nr_of_preferences_info"),
156 $settings->getPreferenceNr()
157 );
158 if ($pref_options_disabled) {
159 $form = $form->disabled();
160 }
161 $form = $form
162 ->dateTime(
163 "pref_deadline",
164 $lng->txt("book_pref_deadline"),
165 $lng->txt("book_pref_deadline_info"),
166 $settings->getPrefDeadline()
167 ? new \ilDateTime($settings->getPrefDeadline(), IL_CAL_UNIX) : null
168 );
169
170 // #14478
171 $mode_disabled = (count(\ilBookingObject::getList($this->obj_id)));
172
173 if ($pref_options_disabled) {
174 $form = $form->disabled();
175 } else {
176 if (!$mode_disabled) {
177 $form = $form->required();
178 }
179 }
180 $form->end();
181
182 if ($mode_disabled) {
183 $form = $form->disabledGroup(true);
184 }
185
186 $form = $form
187 ->checkbox(
188 "public",
189 $lng->txt("book_public_log"),
190 $lng->txt("book_public_log_info"),
191 $settings->getPublicLog()
192 )
193 ->checkbox(
194 "messages",
195 $lng->txt("book_messages"),
196 $lng->txt("book_messages_info"),
197 $settings->getMessages()
198 );
199
200 $lng->loadLanguageModule("rep");
201
202 $form = $form
203 ->section(
204 "rep",
205 $lng->txt('rep_activation_availability')
206 )
207 ->addOnline(
208 $this->obj_id,
209 "book"
210 );
211
212 $form = $form
213 ->section(
214 "obj_presentation",
215 $lng->txt('obj_presentation')
216 )->addStdTile(
217 $this->obj_id,
218 "book"
219 );
220
221 $form = $form->addAdditionalFeatures(
222 $this->obj_id,
223 [
225 ]
226 );
227
228 return $form;
229 }
230
231 protected function save(): void
232 {
233 $mt = $this->gui->ui()->mainTemplate();
234 $form = $this->getEditForm();
235 $ctrl = $this->gui->ctrl();
236 $lng = $this->domain->lng();
237
238 $old_settings = $this->domain->bookingSettings()->getByObjId($this->obj_id);
239
240 if ($form->isValid()) {
241 $form->saveStdTitleAndDescription(
242 $this->obj_id,
243 "book"
244 );
245 $form->saveStdTile(
246 $this->obj_id,
247 "book"
248 );
249 $form->saveOnline(
250 $this->obj_id,
251 "book"
252 );
253 $form->saveAdditionalFeatures(
254 $this->obj_id,
255 [
257 ]
258 );
259
260 $settings = $this->data->settings(
261 $this->obj_id,
262 (bool) $form->getData("public"),
263 (int) $form->getData("stype"),
264 (int) $form->getData("limit"),
265 (int) $form->getData("period"),
266 (bool) $form->getData("rmd"),
267 (int) $form->getData("rmd_day"),
268 $form->getData("pref_deadline")
269 ? (int) $form->getData("pref_deadline")->getUnixTime()
270 : 0,
271 (int) $form->getData("preference_nr"),
272 (bool) $form->getData("messages")
273 );
274
275 $this->domain->bookingSettings()->update($settings);
276
277
278 // check if template is changed
279 $form->redirectToDidacticConfirmationIfChanged(
280 $this->ref_id,
281 "book",
282 static::class
283 );
284
285 $mt->setOnScreenMessage("success", $lng->txt("msg_obj_modified"), true);
286 $ctrl->redirectByClass(self::class, "edit");
287 } else {
288 $mt = $this->gui->ui()->mainTemplate();
289 $mt->setContent($form->render());
290 }
291 }
292}
Author: Alexander Killing killing@leifos.de
@ilCtrl_Calls ILIAS\BookingManager\Settings\SettingsGUI: ilDidacticTemplateGUI
__construct(protected InternalDataService $data, protected InternalDomainService $domain, protected InternalGUIService $gui, protected int $obj_id, protected int $ref_id, protected bool $creation_mode, protected object $parent_gui)
const IL_CAL_UNIX
static getList(int $a_pool_id, ?string $a_title=null)
Get list of booking objects.
GUI class for didactic template settings inside repository objects.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ref_id
Definition: ltiauth.php:66
addStdTitleAndDescription(int $obj_id, string $type)
addOnline(int $obj_id, string $type)
addStdTile(int $obj_id, string $type)
global $lng
Definition: privfeed.php:31