37 protected \ILIAS\DI\UIServices
$ui;
39 protected \Psr\Http\Message\ServerRequestInterface
$request;
48 $this->
ctrl = $DIC->ctrl();
49 $this->
ui = $DIC->ui();
50 $this->
lng = $DIC->language();
51 $this->
user = $DIC->user();
52 $this->request =
$DIC->http()->request();
53 $this->main_tpl =
$DIC->ui()->mainTemplate();
54 $this->service =
$DIC->bookingManager()->internal();
56 $this->repo = $this->service->repo()->preferences();
57 $this->
access = $DIC->bookingManager()->internal()->domain()->access();
58 $this->objects_manager =
$DIC->bookingManager()->internal()->domain()
68 if ($cmd ===
"render") {
71 switch ($next_class) {
73 if (in_array($cmd, [
"show",
"savePreferences"])) {
79 protected function show(): void
81 $preferences = $this->service->domain()->preferences($this->pool);
83 if ($preferences->isGivingPreferencesPossible()) {
98 $this->main_tpl->setContent(
$ui->renderer()->render($form));
100 $this->main_tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"book_type_warning"));
113 $preferences = $preferences->getPreferences();
115 $this->renderBookingInfo();
119 $checked = isset($preferences[$this->
user->getId()]) &&
120 in_array((
int) $book_obj[
"booking_object_id"], $preferences[$this->
user->getId()],
true);
122 $fields[
"cb_" . $book_obj[
"booking_object_id"]] =
123 $f->input()->field()->checkbox($book_obj[
"title"], $book_obj[
"description"])->withValue($checked);
127 $section1 =
$f->input()->field()->section($fields,
$lng->txt(
"book_preferences"));
129 $form_action = $ctrl->
getLinkTarget($this,
"savePreferences");
130 return $f->input()->container()->form()->standard($form_action, [
"sec" => $section1]);
135 $preferences = $this->service->domain()->preferences($this->pool);
137 if (!$preferences->isGivingPreferencesPossible()) {
142 $form = $this->initPreferenceForm();
147 if (
$request->getMethod() ===
"POST") {
148 $form = $form->withRequest(
$request);
149 $data = $form->getData();
151 if (is_array(
$data[
"sec"])) {
153 foreach (
$data[
"sec"] as $k => $v) {
155 $id = explode(
"_", $k);
156 $obj_ids[] = (
int)
$id[1];
160 if (count($obj_ids) > $this->pool->getPreferenceNumber()) {
161 $this->main_tpl->setOnScreenMessage(
'failure',
$lng->txt(
"book_too_many_preferences"),
true);
162 $this->listPreferenceOptions($form);
166 if (count($obj_ids) < $this->pool->getPreferenceNumber()) {
167 $this->main_tpl->setOnScreenMessage(
'failure',
$lng->txt(
"book_not_enough_preferences"),
true);
168 $this->listPreferenceOptions($form);
172 $preferences = $this->service->data()->preferences(
173 [$this->
user->getId() => $obj_ids]
179 $titles = implode(
", ", array_map(
static function (
$id) {
183 $this->main_tpl->setOnScreenMessage(
'success',
$lng->txt(
"book_preferences_saved") .
" (" . $titles .
")",
true);
194 $info =
$lng->txt(
"book_preference_info");
195 $info = str_replace([
"%1",
"%2"], [
196 $this->pool->getPreferenceNumber(),
201 $this->main_tpl->setOnScreenMessage(
'info',
$info);
206 $main_tpl = $this->main_tpl;
215 $info_gui->addSection(
$lng->txt(
"book_your_preferences"));
217 $preferences = $preferences->getPreferences();
219 if (isset($preferences[$this->
user->getId()])) {
220 $book_deleted_object =
"[{$this->lng->txt("book_deleted_object
")}]";
221 foreach ($preferences[$this->
user->getId()] as $book_obj_id) {
223 $info_gui->addProperty((
string) $cnt++, $book_obj->getTitle() ?: $book_deleted_object);
226 $info_gui->addProperty(
"",
$lng->txt(
"book_no_preferences_for_you"));
230 $this->service->domain()->preferences($this->pool)->storeBookings(
231 $this->repo->getPreferences($this->pool->getId())
233 $bookings = $this->service->domain()->preferences($this->pool)->readBookings();
234 $info_gui->addSection(
$lng->txt(
"book_your_bookings"));
236 if (isset($bookings[$this->
user->getId()])) {
237 foreach ($bookings[$this->
user->getId()] as $book_obj_id) {
239 $post_file = $this->objects_manager->getBookingInfoFilename($book_obj_id);
242 $post_info_button =
"";
243 if ($post_file || $book_obj->getPostText()) {
245 $b = $ui->factory()->button()->shy(
246 $lng->txt(
"book_post_booking_information"),
247 $ctrl->
getLinkTargetByClass([
"ilBookingObjectGUI",
"ilBookingProcessWithoutScheduleGUI"],
"displayPostInfo")
249 $post_info_button =
"<br>" . $ui->renderer()->render(
$b);
251 $info_gui->addProperty((
string) $cnt++, $book_obj->getTitle() . $post_info_button);
254 $info_gui->addProperty(
"",
$lng->txt(
"book_no_bookings_for_you"));
258 if ($this->
access->canManageAllReservations($this->pool->getRefId())) {
259 $info_gui->addSection(
$lng->txt(
"book_all_users"));
261 $preferences = $preferences->getPreferences();
262 $book_deleted_object =
"[{$this->lng->txt("book_deleted_object
")}]";
263 $book_deleted_booking =
"[{$this->lng->txt("book_deleted_booking
")}]";
265 $markdown = (
new DataFactory())->text()->markdown();
267 foreach ($preferences as
$user_id => $obj_ids) {
268 $booking_titles = !isset($bookings[
$user_id])
269 ? [$book_deleted_booking]
275 $booking_str =
"{$lng->txt("book_log
")}: " . implode(
", ", $booking_titles);
277 $preferences_str =
"{$lng->txt("book_preferences
")}: " . implode(
280 fn(
int $obj_id):
string
286 $info_gui->addProperty(
288 (
string) $markdown->simpleDocument(
"{$preferences_str}\n{$booking_str}")->toHTML()
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getList(int $a_pool_id, ?string $a_title=null)
Get list of booking objects.
static lookupTitle(int $object_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
savePreferencesOfUser(int $a_pool_id, int $a_user_id, ilBookingPreferences $preferences)
Save all preferences of a user for a pool.
getPreferences(int $a_pool_id)
Get booking preferences for a pool id.
getPreferencesOfUser(int $a_pool_id, int $a_user_id)
Get booking preferences for a pool id.
Booking preferences ui class.
ilBookingPreferencesDBRepository $repo
Psr Http Message ServerRequestInterface $request
__construct(ilObjBookingPool $pool)
ilGlobalTemplateInterface $main_tpl
ObjectsManager $objects_manager
listPreferenceOptions(?Form\Standard $form=null)
Class ilCtrl provides processing control methods.
getLinkTarget(object $a_gui_obj, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
@inheritDoc
getNextClass($a_gui_class=null)
@inheritDoc
redirect(object $a_gui_obj, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false)
@inheritDoc
getCmd(?string $fallback_command=null)
@inheritDoc
setParameterByClass(string $a_class, string $a_parameter, $a_value)
@inheritDoc
getLinkTargetByClass( $a_class, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
@inheritDoc
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
@classDescription Date and time handling
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getNamePresentation( $a_user_id, bool $a_user_image=false, bool $a_profile_link=false, string $a_profile_back_link='', bool $a_force_first_lastname=false, bool $a_omit_login=false, bool $a_sortable=true, bool $a_return_data_array=false, $a_ctrl_path=null)
Default behaviour is:
setContent(string $a_html)
Sets content for standard template.
$request
@ilCtrl_Calls ilObjLearningSequenceContentGUI: ilObjLearningSequenceConditionsGUI