ILIAS  release_8 Revision v8.24
class.ilBookingParticipantGUI.php
Go to the documentation of this file.
1<?php
2
25{
26 public const FILTER_ACTION_APPLY = 1;
27 public const FILTER_ACTION_RESET = 2;
28 public const PARTICIPANT_VIEW = 1;
29 protected \ILIAS\BookingManager\StandardGUIRequest $book_request;
30
32 protected ilTabsGUI $tabs;
33 protected ilCtrl $ctrl;
34 protected ilLanguage $lng;
37 protected int $ref_id;
38 protected int $pool_id;
39
40 public function __construct(
41 ilObjBookingPoolGUI $a_parent_obj
42 ) {
43 global $DIC;
44
45 $this->tpl = $DIC["tpl"];
46 $this->tabs = $DIC->tabs();
47 $this->ctrl = $DIC->ctrl();
48 $this->lng = $DIC->language();
49 $this->access = $DIC->access();
50 $this->toolbar = $DIC->toolbar();
51 $this->book_request = $DIC->bookingManager()
52 ->internal()
53 ->gui()
54 ->standardRequest();
55
56
57 $this->ref_id = $a_parent_obj->getRefId();
58 $this->pool_id = $a_parent_obj->getObject()->getId();
59
60 $this->lng->loadLanguageModule("book");
61 }
62
63 public function executeCommand(): void
64 {
65 $ilCtrl = $this->ctrl;
66
67 $next_class = $ilCtrl->getNextClass($this);
68
69 switch ($next_class) {
70 case 'ilrepositorysearchgui':
71 $rep_search = new ilRepositorySearchGUI();
73 $rep_search->addUserAccessFilterCallable(function ($a_user_id) {
74 return $this->access->filterUserIdsByRbacOrPositionOfCurrentUser(
75 'render',
76 'render',
77 $this->ref_id,
78 $a_user_id
79 );
80 });
81 $rep_search->setTitle($this->lng->txt("exc_add_participant"));
82 $rep_search->setCallback($this, 'addParticipantObject');
83 $this->ctrl->setReturn($this, 'render');
84 $this->ctrl->forwardCommand($rep_search);
85 break;
86
87 default:
88 $cmd = $ilCtrl->getCmd("render");
89 $this->$cmd();
90 break;
91 }
92 }
93
98 public function render(): void
99 {
100 if ($this->access->checkAccess('write', '', $this->ref_id)) {
102 $this,
103 $this->toolbar,
104 array(
105 'auto_complete_name' => $this->lng->txt('user'),
106 'submit_name' => $this->lng->txt('add'),
107 'add_search' => true,
108 'add_from_container' => $this->ref_id
109 )
110 );
111
112 $table = new ilBookingParticipantsTableGUI($this, 'render', $this->ref_id, $this->pool_id);
113
114 $this->tpl->setContent($table->getHTML());
115 }
116 }
117
118 public function addUserFromAutoCompleteObject(): bool
119 {
120 if (trim($this->book_request->getUserLogin()) === '') {
121 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('msg_no_search_string'));
122 $this->render();
123 return false;
124 }
125
126 $users = explode(',', $this->book_request->getUserLogin());
127
128 $user_ids = array();
129 foreach ($users as $user) {
130 $user_id = ilObjUser::_lookupId($user);
131
132 if (!$user_id) {
133 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('user_not_known'));
134 $this->render();
135 }
136 $user_ids[] = $user_id;
137 }
138
139 return $this->addParticipantObject($user_ids);
140 }
141
147 public function addParticipantObject(
148 array $a_user_ids
149 ): bool {
150 foreach ($a_user_ids as $user_id) {
151 if (ilObject::_lookupType($user_id) === "usr") {
152 $participant_obj = new ilBookingParticipant($user_id, $this->pool_id);
153 if ($participant_obj->getIsNew()) {
154 $this->tpl->setOnScreenMessage('success', $this->lng->txt("book_participant_assigned"), true);
155 } else {
156 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("book_participant_already_assigned"));
157 }
158 } else {
159 $this->tpl->setOnScreenMessage('failure', "dummy error message, change me");
160 return false;
161 }
162 }
163
164 $this->ctrl->redirect($this, "render");
165 return true;
166 }
167
168 public function applyParticipantsFilter(): void
169 {
170 $this->applyFilterAction(self::FILTER_ACTION_APPLY);
171 }
172
173 public function resetParticipantsFilter(): void
174 {
175 $this->applyFilterAction(self::FILTER_ACTION_RESET);
176 }
177
178 protected function applyFilterAction(
179 int $a_filter_action
180 ): void {
181 $table = new ilBookingParticipantsTableGUI($this, 'render', $this->ref_id, $this->pool_id);
182 $table->resetOffset();
183 if ($a_filter_action === self::FILTER_ACTION_RESET) {
184 $table->resetFilter();
185 } else {
186 $table->writeFilterToSession();
187 }
188
189 $this->render();
190 }
191
192 public function assignObjects(): void
193 {
194 $this->tabs->clearTargets();
195 $this->tabs->setBackTarget($this->lng->txt('book_back_to_list'), $this->ctrl->getLinkTarget($this, 'render'));
196
197 $table = new ilBookingAssignObjectsTableGUI($this, 'assignObjects', $this->ref_id, $this->pool_id);
198
199 $this->tpl->setContent($table->getHTML());
200 }
201}
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...
addParticipantObject(array $a_user_ids)
Add new participant.
ILIAS BookingManager StandardGUIRequest $book_request
__construct(ilObjBookingPoolGUI $a_parent_obj)
render()
Render list of booking participants.
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...
Class ilCtrl provides processing control methods.
getNextClass($a_gui_class=null)
@inheritDoc
language handling
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupId($a_user_str)
static _lookupType(int $id, bool $reference=false)
static fillAutoCompleteToolbar(object $parent_object, ilToolbarGUI $toolbar=null, array $a_options=[], bool $a_sticky=false)
array( auto_complete_name = $lng->txt('user'), auto_complete_size = 15, user_type = array(ilCoursePar...
resetOffset(bool $a_in_determination=false)
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...
global $DIC
Definition: feed.php:28
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...