ILIAS  trunk Revision v13.0_alpha-52-g21c366bbdd4
class.ilBookingParticipantGUI.php
Go to the documentation of this file.
1<?php
2
25use ILIAS\Refinery\Factory as Refinery;
26use ILIAS\UI\Factory as UIFactory;
27use ILIAS\UI\Renderer as UIRenderer;
29
34{
35 public const PARTICIPANT_VIEW = 1;
38
40 protected ilTabsGUI $tabs;
41 protected ilCtrl $ctrl;
42 protected ilLanguage $lng;
44 protected int $ref_id;
45 protected int $pool_id;
46
47 private readonly Refinery $refinery;
48 private readonly UIFactory $ui_factory;
49 private readonly UIRenderer $ui_renderer;
50 private readonly HttpService $http;
51 private readonly ilUIService $ui_service;
52 private readonly Factory $data_factory;
54
55 public function __construct(ilObjBookingPoolGUI $a_parent_obj)
56 {
57 global $DIC;
58
59 $this->tpl = $DIC->ui()->mainTemplate();
60 $this->tabs = $DIC->tabs();
61 $this->ctrl = $DIC->ctrl();
62 $this->lng = $DIC->language();
63 $this->access = $DIC->bookingManager()->internal()->domain()->access();
64 $this->toolbar = $DIC->toolbar();
65 $this->book_request = $DIC
66 ->bookingManager()
67 ->internal()
68 ->gui()
69 ->standardRequest();
70 $this->refinery = $DIC->refinery();
71 $this->ui_factory = $DIC->ui()->factory();
72 $this->ui_renderer = $DIC->ui()->renderer();
73 $this->http = new HttpService($DIC->http(), $this->refinery);
74 $this->ui_service = $DIC->uiService();
75 $this->data_factory = new Factory();
76 $this->participant_repository = new ParticipantRepository($DIC->database());
77
78 $this->ref_id = $a_parent_obj->getRefId();
79 $this->pool_id = $a_parent_obj->getObject()->getId();
80
81 $this->lng->loadLanguageModule('book');
82 $this->lng->loadLanguageModule('exc');
83 }
84
85 public function executeCommand(): void
86 {
87 switch ($this->ctrl->getNextClass($this)) {
88 case strtolower(ilRepositorySearchGUI::class):
89 $rep_search = new ilRepositorySearchGUI();
90 $rep_search->addUserAccessFilterCallable(
91 fn(array $a_user_id): array => $this->access->filterManageableParticipants($this->ref_id, $a_user_id)
92 );
93 $rep_search->setTitle($this->lng->txt('book_add_participant'));
94 $rep_search->setCallback($this, 'addParticipantObject');
95 $this->ctrl->setReturn($this, 'render');
96 $this->ctrl->forwardCommand($rep_search);
97 break;
98
99 default:
100 $cmd = $this->ctrl->getCmd('render');
101 if (method_exists($this, $cmd)) {
102 $this->$cmd();
103 }
104 break;
105 }
106 }
107
108 public function executeTableAction(): void
109 {
110 $this->configureParticipantTable()->execute($this->getTableActionUrlBuilder());
111 $this->render();
112 }
113
114 public function render(): void
115 {
116 if (!$this->access->canManageParticipants($this->ref_id)) {
117 return;
118 }
119
121 $this,
122 $this->toolbar,
123 [
124 'auto_complete_name' => $this->lng->txt('user'),
125 'submit_name' => $this->lng->txt('add'),
126 'add_search' => true,
127 'add_from_container' => $this->ref_id
128 ]
129 );
130
131 $this->tpl->setContent(
132 $this->ui_renderer->render(
133 $this->configureParticipantTable()->getComponents($this->getTableActionUrlBuilder())
134 )
135 );
136 }
137
138 public function addUserFromAutoCompleteObject(): bool
139 {
140 if (trim($this->book_request->getUserLogin()) === '') {
141 $this->tpl->setOnScreenMessage(
143 $this->lng->txt('msg_no_search_string')
144 );
145 $this->render();
146 return false;
147 }
148
149 $user_ids = [];
150 foreach (explode(',', $this->book_request->getUserLogin()) as $user) {
152
153 if (!$user_id) {
154 $this->tpl->setOnScreenMessage(
156 $this->lng->txt('user_not_known')
157 );
158 $this->render();
159 }
160
161 $user_ids[] = $user_id;
162 }
163
164 return $this->addParticipantObject($user_ids);
165 }
166
170 public function addParticipantObject(array $a_user_ids): bool
171 {
172 foreach ($a_user_ids as $user_id) {
173 if (ilObject::_lookupType($user_id) === 'usr') {
174 $participant_obj = new ilBookingParticipant($user_id, $this->pool_id);
175
176 if ($participant_obj->getIsNew()) {
177 $this->tpl->setOnScreenMessage(
179 $this->lng->txt('book_participant_assigned'),
180 true
181 );
182 continue;
183 }
184
185 $this->tpl->setOnScreenMessage(
187 $this->lng->txt('book_participant_already_assigned'),
188 true
189 );
190 continue;
191 }
192
193 $this->tpl->setOnScreenMessage(
195 'dummy error message, change me'
196 );
197 return false;
198 }
199
200 $this->ctrl->redirect($this, 'render');
201 return true;
202 }
203
204 public function assignObjects(): void
205 {
206 $this->tabs->clearTargets();
207 $this->tabs->setBackTarget($this->lng->txt('book_back_to_list'), $this->ctrl->getLinkTarget($this, 'render'));
208
209 $table = new ilBookingAssignObjectsTableGUI($this, 'assignObjects', $this->ref_id, $this->pool_id);
210 $this->tpl->setContent($table->getHTML());
211 }
212
213
215 {
216 return new ParticipantTable(
217 $this->ui_factory,
218 $this->ui_renderer,
219 $this->lng,
220 $this->http,
221 $this->ui_service,
222 $this->ctrl,
223 $this->tpl,
224 $this->refinery,
225 $this->access,
226 $this->participant_repository,
227 $this->ref_id,
228 $this->pool_id,
229 );
230 }
231
233 {
234 return new URLBuilder($this->data_factory->uri(
235 ILIAS_HTTP_PATH . '/' . $this->ctrl->getLinkTargetByClass(self::class, 'executeTableAction')
236 ));
237 }
238}
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
Builds data types.
Definition: Factory.php:36
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
@ilCtrl_Calls ilBookingParticipantGUI: ilRepositorySearchGUI
__construct(ilObjBookingPoolGUI $a_parent_obj)
readonly ParticipantRepository $participant_repository
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilCtrl provides processing control methods.
language handling
@ilCtrl_Calls ilObjBookingPoolGUI: ilPermissionGUI, ilBookingObjectGUI @ilCtrl_Calls ilObjBookingPool...
static _lookupId(string|array $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...
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...
Filter service.
An entity that renders components to a string output.
Definition: Renderer.php:31
static http()
Fetches the global http state from ILIAS.
global $DIC
Definition: shib_login.php:26