ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilSessionMembershipGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
32{
33 protected array $requested_visible_participants = [];
34 protected array $requested_participated = [];
35 protected array $requested_registered = [];
36 protected array $requested_contact = [];
37 protected array $requested_excused = [];
38 protected array $requested_mark = [];
39 protected array $requested_comment = [];
40 protected array $requested_notification = [];
41 protected array $requested_participants = [];
42
43 public function __construct(ilObjectGUI $repository_gui, ilObject $repository_obj)
44 {
45 parent::__construct($repository_gui, $repository_obj);
46
47 if ($this->http->wrapper()->post()->has('visible_participants')) {
48 $this->requested_visible_participants = (array) $this->http->wrapper()->post()->retrieve(
49 'visible_participants',
50 $this->refinery->custom()->transformation(function ($v) {
51 return $v;
52 })
53 );
54 } elseif ($this->http->wrapper()->query()->has('visible_participants')) {
55 $this->requested_visible_participants = (array) $this->http->wrapper()->query()->retrieve(
56 'visible_participants',
57 $this->refinery->custom()->transformation(function ($v) {
58 return $v;
59 })
60 );
61 }
62
63 if ($this->http->wrapper()->post()->has('participated')) {
64 $this->requested_participated = (array) $this->http->wrapper()->post()->retrieve(
65 'participated',
66 $this->refinery->custom()->transformation(function ($v) {
67 return $v;
68 })
69 );
70 }
71
72 if ($this->http->wrapper()->post()->has('registered')) {
73 $this->requested_registered = (array) $this->http->wrapper()->post()->retrieve(
74 'registered',
75 $this->refinery->custom()->transformation(function ($v) {
76 return $v;
77 })
78 );
79 }
80
81 if ($this->http->wrapper()->post()->has('contact')) {
82 $this->requested_contact = (array) $this->http->wrapper()->post()->retrieve(
83 'contact',
84 $this->refinery->custom()->transformation(function ($v) {
85 return $v;
86 })
87 );
88 }
89
90 if ($this->http->wrapper()->post()->has('excused')) {
91 $this->requested_excused = (array) $this->http->wrapper()->post()->retrieve(
92 'excused',
93 $this->refinery->custom()->transformation(function ($v) {
94 return $v;
95 })
96 );
97 }
98
99 if ($this->http->wrapper()->post()->has('mark')) {
100 $this->requested_mark = (array) $this->http->wrapper()->post()->retrieve(
101 'mark',
102 $this->refinery->custom()->transformation(function ($v) {
103 return $v;
104 })
105 );
106 }
107
108 if ($this->http->wrapper()->post()->has('comment')) {
109 $this->requested_comment = (array) $this->http->wrapper()->post()->retrieve(
110 'comment',
111 $this->refinery->custom()->transformation(function ($v) {
112 return $v;
113 })
114 );
115 }
116
117 if ($this->http->wrapper()->post()->has('notification')) {
118 $this->requested_notification = (array) $this->http->wrapper()->post()->retrieve(
119 'notification',
120 $this->refinery->custom()->transformation(function ($v) {
121 return $v;
122 })
123 );
124 }
125
126 if ($this->http->wrapper()->post()->has('participants')) {
127 $this->requested_participants = (array) $this->http->wrapper()->post()->retrieve(
128 'participants',
129 $this->refinery->custom()->transformation(function ($v) {
130 return $v;
131 })
132 );
133 }
134 }
135
137 {
138 return new ilMailMemberSessionRoles();
139 }
140
145 protected function checkRbacOrPositionAccessBool(string $a_rbac_perm, string $a_pos_perm, int $a_ref_id = 0): bool
146 {
147 if (!$a_ref_id) {
148 $a_ref_id = $this->getParentObject()->getRefId();
149 }
150 return $this->checkPermissionBool($a_rbac_perm, "", "", $a_ref_id);
151 }
152
153 protected function initParticipantTemplate(): void
154 {
155 $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.sess_edit_members.html', 'components/ILIAS/Session');
156 }
157
159 {
160 $wait = new ilSessionWaitingList($this->getParentObject()->getId());
161 return $wait;
162 }
163
164 public function getParentObject(): ilObjSession
165 {
169 $parent_object = parent::getParentObject();
170 return $parent_object;
171 }
172
174 {
176 $this,
177 $this->getParentObject(),
178 'participants'
179 );
180 $table->init();
181 return $table;
182 }
183
184 protected function getParticipantTableTitle(): string
185 {
186 /*
187 * TODO this exact logic is also in ilSessionParticipantsTableGUI and ilMembershipGUI,
188 * should be centralized.
189 */
190 if ($member_ref = $this->tree->checkForParentType(
191 $this->getParentObject()->getRefId(),
192 'grp'
193 )) {
194 $member_ref_id = $member_ref;
195 } elseif ($member_ref = $this->tree->checkForParentType(
196 $this->getParentObject()->getRefId(),
197 'crs'
198 )) {
199 $member_ref_id = $member_ref;
200 } else {
201 $this->logger->warning('Cannot find parent course or group for ref_id: ' . $this->getParentObject()->getRefId());
202 $member_ref_id = $this->getParentObject()->getRefId();
203 }
204
205 return sprintf(
206 $this->lng->txt('sess_mem_tbl_header'),
207 ilObjectFactory::getInstanceByRefId($member_ref_id)->getTitle(),
208 );
209 }
210
212 {
213 $subscriber = new ilSubscriberTableGUI($this, $this->getParentObject(), true, false);
214 $subscriber->setTitle($this->lng->txt('group_new_registrations'));
215 return $subscriber;
216 }
217
218 protected function updateMembers(): void
219 {
220 $this->checkPermission('manage_members');
221
222 $part = ilParticipants::getInstance($this->getParentObject()->getRefId());
223
224
225 $wait = new ilSessionWaitingList($this->getParentObject()->getId());
226 $waiting = $wait->getUserIds();
227
228 foreach ($this->requested_visible_participants as $part_id) {
229 if (in_array($part_id, $waiting)) {
230 // so not update users on waiting list
231 continue;
232 }
233
234 $participated = (bool) ($this->requested_participated[$part_id] ?? false);
235 $registered = (bool) ($this->requested_registered[$part_id] ?? false);
236 $contact = (bool) ($this->requested_contact[$part_id] ?? false);
237 $excused = (bool) ($this->requested_excused[$part_id] ?? false);
238
239 $part_id = (int) $part_id;
240
241 if ($part->isAssigned($part_id) && !$participated && !$registered) {
242 $part->delete($part_id);
243 }
244 if (!$part->isAssigned($part_id) && ($participated || $registered)) {
245 $part->add($part_id, ilParticipants::IL_SESS_MEMBER);
246 }
247 $event_part = new ilEventParticipants($this->getParentObject()->getId());
248 $event_part->setUserId($part_id);
249 $event_part->setMark(ilUtil::stripSlashes($this->requested_mark[$part_id]));
250 $event_part->setComment(ilUtil::stripSlashes($this->requested_comment[$part_id]));
251 $event_part->setNotificationEnabled((bool) ($this->requested_notification[$part_id] ?? false));
252 $event_part->setParticipated($participated);
253 $event_part->setRegistered($registered);
254 $event_part->setContact($contact);
255 $event_part->setExcused($excused);
256 $event_part->updateUser();
257 }
258
259 $this->tpl->setOnScreenMessage('success', $this->getLanguage()->txt('settings_saved'), true);
260 $this->getCtrl()->redirect($this, 'participants');
261 }
262
263 protected function confirmDeleteParticipants(): void
264 {
266
267 if (!count($participants)) {
268 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('no_checkbox'), true);
269 $this->ctrl->redirect($this, 'participants');
270 }
271
272 $confirm = new ilConfirmationGUI();
273 $confirm->setFormAction($this->ctrl->getFormAction($this, 'confirmDeleteParticipants'));
274 $confirm->setHeaderText($this->lng->txt($this->getParentObject()->getType() . '_header_delete_members'));
275 $confirm->setConfirm($this->lng->txt('confirm'), 'deleteParticipants');
276 $confirm->setCancel($this->lng->txt('cancel'), 'participants');
277
278 foreach ($participants as $usr_id) {
279 $name = ilObjUser::_lookupName($usr_id);
280
281 $confirm->addItem(
282 'participants[]',
283 $name['user_id'],
284 $name['lastname'] . ', ' . $name['firstname'] . ' [' . $name['login'] . ']',
285 ilUtil::getImagePath('standard/icon_usr.svg')
286 );
287 }
288
289 $this->tpl->setContent($confirm->getHTML());
290 }
291
292 protected function deleteParticipants(): void
293 {
294 $this->checkPermission('manage_members');
295
297
298 if (!is_array($participants) || !count($participants)) {
299 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("no_checkbox"), true);
300 $this->ctrl->redirect($this, 'participants');
301 }
302
303 foreach ($participants as $part_id) {
304 // delete role assignment
305 $this->getMembersObject()->delete($part_id);
306 // delete further settings
307 $event_part = new ilEventParticipants($this->getParentObject()->getId());
308 $event_part->setUserId($part_id);
309 $event_part->setParticipated(false);
310 $event_part->setRegistered(false);
311 $event_part->setMark('');
312 $event_part->setComment('');
313 $event_part->updateUser();
314 }
315
316 $this->tpl->setOnScreenMessage('success', $this->lng->txt($this->getParentObject()->getType() . "_members_deleted"), true);
317 $this->ctrl->redirect($this, "participants");
318 }
319
320 public function getPrintMemberData(array $a_members): array
321 {
322 return $a_members;
323 }
324
328 protected function canAddOrSearchUsers(): bool
329 {
330 return false;
331 }
332
333 public function getAttendanceListUserData(int $user_id, array $filters = []): array
334 {
335 $data = $this->getMembersObject()->getEventParticipants()->getUser($user_id);
336 $data['registered'] = (bool) ($data['registered'] ?? false);
337 $data['participated'] = (bool) ($data['participated'] ?? false);
338
339 if ($filters && $filters["registered"] && !$data["registered"]) {
340 return [];
341 }
342
343
344 $data['registered'] = $data['registered'] ?
345 $this->lng->txt('yes') :
346 $this->lng->txt('no');
347 $data['participated'] = $data['participated'] ?
348 $this->lng->txt('yes') :
349 $this->lng->txt('no');
350
351 return $data;
352 }
353
354 protected function getMemberTabName(): string
355 {
356 return $this->lng->txt($this->getParentObject()->getType() . '_members');
357 }
358
359 protected function getMailButtonLabel(): string
360 {
361 return $this->lng->txt("sess_mail_type");
362 }
363
364 protected function getMailContextOptions(): array
365 {
366 $context_options = [
368 'ref_id' => $this->getParentObject()->getRefId(),
369 'ts' => time()
370 ];
371
372 return $context_options;
373 }
374}
Class ilAbstractMailMemberRoles.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
class ilEventParticipants
final const string CONTEXT_KEY
Class ilMailMemberSessionRoles.
Base class for member tab content.
checkPermissionBool(string $a_permission, string $a_cmd='', string $a_type='', int $a_ref_id=0)
checkPermission(string $a_permission, string $a_cmd="")
Check permission If not granted redirect to parent gui.
ilParticipants $participants
static _lookupName(int $a_user_id)
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
Class ilObjectGUI Basic methods of all Output classes.
Class ilObject Basic functions for all objects.
static getInstance(int $a_ref_id)
GUI class for membership features.
__construct(ilObjectGUI $repository_gui, ilObject $repository_obj)
getAttendanceListUserData(int $user_id, array $filters=[])
checkRbacOrPositionAccessBool(string $a_rbac_perm, string $a_pos_perm, int $a_ref_id=0)
No support for positions in sessions Check if rbac or position access is granted.
confirmDeleteParticipants()
Show confirmation screen for participants deletion.
canAddOrSearchUsers()
Check if current user is allowed to add / search users.
GUI class for course/group subscriptions.
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
static http()
Fetches the global http state from ILIAS.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc