ILIAS  release_8 Revision v8.24
class.ilSessionMembershipGUI.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
33{
34 protected array $requested_visible_participants = [];
35 protected array $requested_participated = [];
36 protected array $requested_registered = [];
37 protected array $requested_contact = [];
38 protected array $requested_excused = [];
39 protected array $requested_mark = [];
40 protected array $requested_comment = [];
41 protected array $requested_notification = [];
42 protected array $requested_participants = [];
43
44 public function __construct(ilObjectGUI $repository_gui, ilObject $repository_obj)
45 {
46 parent::__construct($repository_gui, $repository_obj);
47
48 if ($this->http->wrapper()->post()->has('visible_participants')) {
49 $this->requested_visible_participants = (array) $this->http->wrapper()->post()->retrieve(
50 'visible_participants',
51 $this->refinery->custom()->transformation(function ($v) {
52 return $v;
53 })
54 );
55 } elseif ($this->http->wrapper()->query()->has('visible_participants')) {
56 $this->requested_visible_participants = (array) $this->http->wrapper()->query()->retrieve(
57 'visible_participants',
58 $this->refinery->custom()->transformation(function ($v) {
59 return $v;
60 })
61 );
62 }
63
64 if ($this->http->wrapper()->post()->has('participated')) {
65 $this->requested_participated = (array) $this->http->wrapper()->post()->retrieve(
66 'participated',
67 $this->refinery->custom()->transformation(function ($v) {
68 return $v;
69 })
70 );
71 }
72
73 if ($this->http->wrapper()->post()->has('registered')) {
74 $this->requested_registered = (array) $this->http->wrapper()->post()->retrieve(
75 'registered',
76 $this->refinery->custom()->transformation(function ($v) {
77 return $v;
78 })
79 );
80 }
81
82 if ($this->http->wrapper()->post()->has('contact')) {
83 $this->requested_contact = (array) $this->http->wrapper()->post()->retrieve(
84 'contact',
85 $this->refinery->custom()->transformation(function ($v) {
86 return $v;
87 })
88 );
89 }
90
91 if ($this->http->wrapper()->post()->has('excused')) {
92 $this->requested_excused = (array) $this->http->wrapper()->post()->retrieve(
93 'excused',
94 $this->refinery->custom()->transformation(function ($v) {
95 return $v;
96 })
97 );
98 }
99
100 if ($this->http->wrapper()->post()->has('mark')) {
101 $this->requested_mark = (array) $this->http->wrapper()->post()->retrieve(
102 'mark',
103 $this->refinery->custom()->transformation(function ($v) {
104 return $v;
105 })
106 );
107 }
108
109 if ($this->http->wrapper()->post()->has('comment')) {
110 $this->requested_comment = (array) $this->http->wrapper()->post()->retrieve(
111 'comment',
112 $this->refinery->custom()->transformation(function ($v) {
113 return $v;
114 })
115 );
116 }
117
118 if ($this->http->wrapper()->post()->has('notification')) {
119 $this->requested_notification = (array) $this->http->wrapper()->post()->retrieve(
120 'notification',
121 $this->refinery->custom()->transformation(function ($v) {
122 return $v;
123 })
124 );
125 }
126
127 if ($this->http->wrapper()->post()->has('participants')) {
128 $this->requested_participants = (array) $this->http->wrapper()->post()->retrieve(
129 'participants',
130 $this->refinery->custom()->transformation(function ($v) {
131 return $v;
132 })
133 );
134 }
135 }
136
138 {
139 return new ilMailMemberSessionRoles();
140 }
141
146 protected function checkRbacOrPositionAccessBool(string $a_rbac_perm, string $a_pos_perm, int $a_ref_id = 0): bool
147 {
148 if (!$a_ref_id) {
149 $a_ref_id = $this->getParentObject()->getRefId();
150 }
151 return $this->checkPermissionBool($a_rbac_perm, "", "", $a_ref_id);
152 }
153
154 protected function initParticipantTemplate(): void
155 {
156 $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.sess_edit_members.html', 'Modules/Session');
157 }
158
160 {
161 $wait = new ilSessionWaitingList($this->getParentObject()->getId());
162 return $wait;
163 }
164
165 public function getParentObject(): ilObjSession
166 {
170 $parent_object = parent::getParentObject();
171 return $parent_object;
172 }
173
175 {
177 $this,
178 $this->getParentObject(),
179 'participants'
180 );
181 $table->init();
182 return $table;
183 }
184
186 {
187 $subscriber = new ilSubscriberTableGUI($this, $this->getParentObject(), true, false);
188 $subscriber->setTitle($this->lng->txt('group_new_registrations'));
189 return $subscriber;
190 }
191
192 protected function updateMembers(): void
193 {
194 $this->checkPermission('manage_members');
195
196 $part = ilParticipants::getInstance($this->getParentObject()->getRefId());
197
198
199 $wait = new ilSessionWaitingList($this->getParentObject()->getId());
200 $waiting = $wait->getUserIds();
201
202 foreach ($this->requested_visible_participants as $part_id) {
203 if (in_array($part_id, $waiting)) {
204 // so not update users on waiting list
205 continue;
206 }
207
208 $participated = (bool) ($this->requested_participated[$part_id] ?? false);
209 $registered = (bool) ($this->requested_registered[$part_id] ?? false);
210 $contact = (bool) ($this->requested_contact[$part_id] ?? false);
211 $excused = (bool) ($this->requested_excused[$part_id] ?? false);
212
213 $part_id = (int) $part_id;
214
215 if ($part->isAssigned($part_id) && !$participated && !$registered) {
216 $part->delete($part_id);
217 }
218 if (!$part->isAssigned($part_id) && ($participated || $registered)) {
219 $part->add($part_id, ilParticipants::IL_SESS_MEMBER);
220 }
221 $event_part = new ilEventParticipants($this->getParentObject()->getId());
222 $event_part->setUserId($part_id);
223 $event_part->setMark(ilUtil::stripSlashes($this->requested_mark[$part_id]));
224 $event_part->setComment(ilUtil::stripSlashes($this->requested_comment[$part_id]));
225 $event_part->setNotificationEnabled((bool) ($this->requested_notification[$part_id] ?? false));
226 $event_part->setParticipated($participated);
227 $event_part->setRegistered($registered);
228 $event_part->setContact($contact);
229 $event_part->setExcused($excused);
230 $event_part->updateUser();
231 }
232
233 $this->tpl->setOnScreenMessage('success', $this->getLanguage()->txt('settings_saved'), true);
234 $this->getCtrl()->redirect($this, 'participants');
235 }
236
237 protected function confirmDeleteParticipants(): void
238 {
240
241 if (!count($participants)) {
242 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('no_checkbox'), true);
243 $this->ctrl->redirect($this, 'participants');
244 }
245
246 $confirm = new ilConfirmationGUI();
247 $confirm->setFormAction($this->ctrl->getFormAction($this, 'confirmDeleteParticipants'));
248 $confirm->setHeaderText($this->lng->txt($this->getParentObject()->getType() . '_header_delete_members'));
249 $confirm->setConfirm($this->lng->txt('confirm'), 'deleteParticipants');
250 $confirm->setCancel($this->lng->txt('cancel'), 'participants');
251
252 foreach ($participants as $usr_id) {
253 $name = ilObjUser::_lookupName($usr_id);
254
255 $confirm->addItem(
256 'participants[]',
257 $name['user_id'],
258 $name['lastname'] . ', ' . $name['firstname'] . ' [' . $name['login'] . ']',
259 ilUtil::getImagePath('icon_usr.svg')
260 );
261 }
262
263 $this->tpl->setContent($confirm->getHTML());
264 }
265
266 protected function deleteParticipants(): void
267 {
268 $this->checkPermission('manage_members');
269
271
272 if (!is_array($participants) || !count($participants)) {
273 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("no_checkbox"), true);
274 $this->ctrl->redirect($this, 'participants');
275 }
276
277 foreach ($participants as $part_id) {
278 // delete role assignment
279 $this->getMembersObject()->delete($part_id);
280 // delete further settings
281 $event_part = new ilEventParticipants($this->getParentObject()->getId());
282 $event_part->setUserId($part_id);
283 $event_part->setParticipated(false);
284 $event_part->setRegistered(false);
285 $event_part->setMark('');
286 $event_part->setComment('');
287 $event_part->updateUser();
288 }
289
290 $this->tpl->setOnScreenMessage('success', $this->lng->txt($this->getParentObject()->getType() . "_members_deleted"), true);
291 $this->ctrl->redirect($this, "participants");
292 }
293
294 public function getPrintMemberData(array $a_members): array
295 {
296 return $a_members;
297 }
298
302 protected function canAddOrSearchUsers(): bool
303 {
304 return false;
305 }
306
307 public function getAttendanceListUserData(int $user_id, array $filters = []): array
308 {
309 $data = $this->getMembersObject()->getEventParticipants()->getUser($user_id);
310 $data['registered'] = (bool) ($data['registered'] ?? false);
311 $data['participated'] = (bool) ($data['participated'] ?? false);
312
313 if ($filters && $filters["registered"] && !$data["registered"]) {
314 return [];
315 }
316
317
318 $data['registered'] = $data['registered'] ?
319 $this->lng->txt('yes') :
320 $this->lng->txt('no');
321 $data['participated'] = $data['participated'] ?
322 $this->lng->txt('yes') :
323 $this->lng->txt('no');
324
325 return $data;
326 }
327
328 protected function getMemberTabName(): string
329 {
330 return $this->lng->txt($this->getParentObject()->getType() . '_members');
331 }
332
333 protected function getMailContextOptions(): array
334 {
335 $context_options = [
337 'ref_id' => $this->getParentObject()->getRefId(),
338 'ts' => time()
339 ];
340
341 return $context_options;
342 }
343}
Class ilAbstractMailMemberRoles.
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 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)
lookup user name
Class ilObjectGUI Basic methods of all Output classes.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstance(int $a_ref_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__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.
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...
GUI class for course/group subscriptions.
static getImagePath(string $img, 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="")
if($format !==null) $name
Definition: metadata.php:247
static http()
Fetches the global http state from ILIAS.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc