ILIAS  release_8 Revision v8.24
class.ilMembershipGUI.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
23
29{
33 protected Factory $refinery;
34 protected ilLanguage $lng;
36 protected ilLogger $logger;
39 protected ?ilParticipants $participants = null;
40 protected ilObjUser $user;
42 protected ilTabsGUI $tabs;
46 protected ilTree $tree;
47 protected array $member_data = [];
48
49 public function __construct(ilObjectGUI $repository_gui, ilObject $repository_obj)
50 {
51 global $DIC;
52
53 $this->repository_gui = $repository_gui;
54 $this->repository_object = $repository_obj;
55
56 $this->lng = $DIC->language();
57 $this->lng->loadLanguageModule('crs');
58 $this->lng->loadLanguageModule($this->getParentObject()->getType());
59 $this->tpl = $DIC->ui()->mainTemplate();
60 $this->ctrl = $DIC->ctrl();
61 $this->lng->loadLanguageModule('trac');
62 $this->logger = $DIC->logger()->mmbr();
63 $this->access = $DIC->access();
64 $this->user = $DIC->user();
65 $this->error = $DIC['ilErr'];
66 $this->tabs = $DIC->tabs();
67 $this->toolbar = $DIC->toolbar();
68 $this->rbacsystem = $DIC->rbac()->system();
69 $this->rbacreview = $DIC->rbac()->review();
70 $this->tree = $DIC->repositoryTree();
71 $this->http = $DIC->http();
72 $this->refinery = $DIC->refinery();
73 }
74
78 protected function initParticipantsFromPost(): array
79 {
80 if ($this->http->wrapper()->post()->has('participants')) {
81 return $this->http->wrapper()->post()->retrieve(
82 'participants',
83 $this->refinery->kindlyTo()->listOf(
84 $this->refinery->kindlyTo()->int()
85 )
86 );
87 }
88 return [];
89 }
90
91 protected function initMemberIdFromGet(): int
92 {
93 if ($this->http->wrapper()->query()->has('member_id')) {
94 return $this->http->wrapper()->query()->retrieve(
95 'member_id',
96 $this->refinery->kindlyTo()->int()
97 );
98 }
99 return 0;
100 }
101
102 protected function initSubscribersFromPost(): array
103 {
104 if ($this->http->wrapper()->post()->has('subscribers')) {
105 return $this->http->wrapper()->post()->retrieve(
106 'subscribers',
107 $this->refinery->kindlyTo()->listOf(
108 $this->refinery->kindlyTo()->int()
109 )
110 );
111 }
112 return [];
113 }
114
115 protected function initWaitingListIdsFromPost(): array
116 {
117 if ($this->http->wrapper()->post()->has('waiting')) {
118 return $this->http->wrapper()->post()->retrieve(
119 'waiting',
120 $this->refinery->kindlyTo()->listOf(
121 $this->refinery->kindlyTo()->int()
122 )
123 );
124 }
125 return [];
126 }
127
128 protected function getLanguage(): ilLanguage
129 {
130 return $this->lng;
131 }
132
133 protected function getCtrl(): ilCtrlInterface
134 {
135 return $this->ctrl;
136 }
137
138 protected function getLogger(): ilLogger
139 {
140 return $this->logger;
141 }
142
143 public function getParentGUI(): ilObjectGUI
144 {
146 }
147
148 public function getParentObject(): ilObject
149 {
151 }
152
154 {
155 if ($this->participants instanceof ilParticipants) {
156 return $this->participants;
157 }
158 return $this->participants = ilParticipants::getInstance($this->getParentObject()->getRefId());
159 }
160
162 {
163 return null;
164 }
165
166 protected function checkPermissionBool(
167 string $a_permission,
168 string $a_cmd = '',
169 string $a_type = '',
170 int $a_ref_id = 0
171 ): bool {
172 if ($a_ref_id === 0) {
173 $a_ref_id = $this->getParentObject()->getRefId();
174 }
175 return $this->access->checkAccess($a_permission, $a_cmd, $a_ref_id);
176 }
177
179 string $a_rbac_perm,
180 string $a_pos_perm,
181 int $a_ref_id = 0
182 ): bool {
183 if ($a_ref_id === 0) {
184 $a_ref_id = $this->getParentObject()->getRefId();
185 }
186 return $this->access->checkRbacOrPositionPermissionAccess($a_rbac_perm, $a_pos_perm, $a_ref_id);
187 }
188
193 protected function checkPermission(string $a_permission, string $a_cmd = ""): void
194 {
195 if (!$this->checkPermissionBool($a_permission, $a_cmd)) {
196 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('no_permission'), true);
197 $this->ctrl->redirect($this->getParentGUI());
198 }
199 }
200
204 protected function checkRbacOrPermissionAccess(string $a_rbac_perm, string $a_pos_perm): void
205 {
206 if (!$this->checkRbacOrPositionAccessBool($a_rbac_perm, $a_pos_perm)) {
207 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('no_permission'), true);
208 $this->ctrl->redirect($this->getParentGUI());
209 }
210 }
211
215 protected function canAddOrSearchUsers(): bool
216 {
217 return $this->checkPermissionBool('manage_members');
218 }
219
225 public function filterUserIdsByRbacOrPositionOfCurrentUser(array $a_user_ids): array
226 {
227 return $a_user_ids;
228 }
229
230 public function executeCommand(): void
231 {
232 $cmd = $this->ctrl->getCmd('participants');
233 $next_class = $this->ctrl->getNextClass();
234
235 switch ($next_class) {
236 case 'ilrepositorysearchgui':
237
238 $this->checkPermission('manage_members');
239
240 $rep_search = new ilRepositorySearchGUI();
241 $rep_search->addUserAccessFilterCallable([$this, 'filterUserIdsByRbacOrPositionOfCurrentUser']);
242
243 $participants = $this->getMembersObject();
244 if (
245 $participants->isAdmin($this->user->getId()) ||
246 $this->access->checkAccess('manage_members', '', $this->getParentObject()->getRefId())
247 ) {
248 $rep_search->setCallback(
249 $this,
250 'assignMembers',
251 $this->getParentGUI()->getLocalRoles(),
252 (string) $this->getDefaultRole()
253 );
254 } else {
255 //#18445 excludes admin role
256 $rep_search->setCallback(
257 $this,
258 'assignMembers',
259 $this->getLocalRoles(),
260 (string) $this->getDefaultRole()
261 );
262 }
263
264 // Set tabs
265 $this->ctrl->setReturn($this, 'participants');
266 $ret = $this->ctrl->forwardCommand($rep_search);
267 break;
268
269 case 'ilmailmembersearchgui':
270 $this->tabs->clearTargets();
271 $this->tabs->setBackTarget(
272 $this->lng->txt('btn_back'),
273 $this->ctrl->getLinkTarget($this, $this->getDefaultCommand())
274 );
275
276 $mail = new ilMail($this->user->getId());
277 if (!(
278 $this->getParentObject()->getMailToMembersType() === ilCourseConstants::MAIL_ALLOWED_ALL ||
279 $this->access->checkAccess('manage_members', "", $this->getParentObject()->getRefId())
280 ) ||
281 !$this->rbacsystem->checkAccess(
282 'internal_mail',
283 $mail->getMailObjectReferenceId()
284 )) {
285 $this->error->raiseError($this->lng->txt("msg_no_perm_read"), $this->error->MESSAGE);
286 }
287
288 $mail_search = new ilMailMemberSearchGUI(
289 $this,
290 $this->getParentObject()->getRefId(),
291 $this->getMailMemberRoles()
292 );
293 $mail_search->setObjParticipants(
294 ilParticipants::getInstance($this->getParentObject()->getRefId())
295 );
296 $this->ctrl->forwardCommand($mail_search);
297 break;
298
299 case 'ilusersgallerygui':
300
301 $this->setSubTabs($this->tabs);
302 $this->tabs->setSubTabActive(
303 $this->getParentObject()->getType() . '_members_gallery'
304 );
305 $is_admin = $this->checkRbacOrPositionAccessBool('manage_members', 'manage_members');
306 $is_participant = ilParticipants::_isParticipant(
307 $this->getParentObject()->getRefId(),
308 $this->user->getId()
309 );
310 if (
311 !$is_admin &&
312 (
313 $this->getParentObject()->getShowMembers() === 0 ||
314 !$is_participant
315 )
316 ) {
317 $this->error->raiseError($this->lng->txt('msg_no_perm_read'), $this->error->MESSAGE);
318 }
319
320 $this->showMailToMemberToolbarButton($this->toolbar, 'jump2UsersGallery');
321 $this->showMemberExportToolbarButton($this->toolbar, 'jump2UsersGallery');
322
323 $provider = new ilUsersGalleryParticipants($this->getParentObject()->getMembersObject());
324 $gallery_gui = new ilUsersGalleryGUI($provider);
325 $this->ctrl->forwardCommand($gallery_gui);
326 break;
327
328 case 'ilcourseparticipantsgroupsgui':
329
330 $this->setSubTabs($this->tabs);
331 $this->checkRbacOrPermissionAccess('manage_members', 'manage_members');
332
333 $cmg_gui = new ilCourseParticipantsGroupsGUI($this->getParentObject()->getRefId());
334 if ($cmd === "show" || $cmd = "") {
335 $this->showMailToMemberToolbarButton($this->toolbar);
336 }
337 $this->ctrl->forwardCommand($cmg_gui);
338 break;
339
340 case 'ilsessionoverviewgui':
341
342 $this->setSubTabs($this->tabs);
343 $this->checkRbacOrPermissionAccess('manage_members', 'manage_members');
344
345 $prt = ilParticipants::getInstance($this->getParentObject()->getRefId());
346
347 $overview = new ilSessionOverviewGUI($this->getParentObject()->getRefId(), $prt);
348 $this->ctrl->forwardCommand($overview);
349 break;
350
351 case 'ilmemberexportgui':
352
353 $this->setSubTabs($this->tabs);
354 $this->checkRbacOrPermissionAccess('manage_members', 'manage_members');
355
356 $export = new ilMemberExportGUI($this->getParentObject()->getRefId());
357 $this->ctrl->forwardCommand($export);
358 break;
359
360 case 'ilobjectcustomuserfieldsgui':
361
362 $this->setSubTabs($this->tabs);
363 $this->checkRbacOrPermissionAccess('manage_members', 'manage_members');
364 $this->activateSubTab($this->getParentObject()->getType() . "_member_administration");
365 $this->ctrl->setReturn($this, 'participants');
366 $cdf_gui = new ilObjectCustomUserFieldsGUI($this->getParentGUI()->getObject()->getId());
367 $this->ctrl->forwardCommand($cdf_gui);
368 break;
369
370 default:
371 $this->setSubTabs($this->tabs);
372 //exclude mailMembersBtn cmd from this check
373 if (
374 $cmd === "mailMembersBtn" ||
375 $cmd === 'membersMap' ||
376 $cmd === 'printForMembersOutput' ||
377 $cmd === 'jump2UsersGallery'
378 ) {
379 $this->checkPermission('read');
380 } else {
381 $this->checkRbacOrPermissionAccess('manage_members', 'manage_members');
382 }
383 $this->$cmd();
384 break;
385 }
386 }
387
391 protected function participants(): void
392 {
393 $this->initParticipantTemplate();
394 $this->showParticipantsToolbar();
395 $this->activateSubTab($this->getParentObject()->getType() . "_member_administration");
396
397 // show waiting list table
398 $waiting = $this->parseWaitingListTable();
399 if ($waiting instanceof ilWaitingListTableGUI) {
400 $this->tpl->setVariable('TABLE_WAIT', $waiting->getHTML());
401 }
402
403 // show subscriber table
404 $subscriber = $this->parseSubscriberTable();
405 if ($subscriber instanceof ilSubscriberTableGUI) {
406 $this->tpl->setVariable('TABLE_SUB', $subscriber->getHTML());
407 }
408
409 // show member table
410 $table = $this->initParticipantTableGUI();
411 $table->setTitle($this->lng->txt($this->getParentObject()->getType() . '_mem_tbl_header'));
412 $table->setFormAction($this->ctrl->getFormAction($this));
413 $table->parse();
414
415 // filter commands
416 $table->setFilterCommand('participantsApplyFilter');
417 $table->setResetCommand('participantsResetFilter');
418
419 $this->tpl->setVariable('MEMBERS', $table->getHTML());
420 }
421
422 public function getAttendanceListUserData(int $user_id, array $filters = []): array
423 {
424 return [];
425 }
426
430 protected function participantsApplyFilter(): void
431 {
432 $table = $this->initParticipantTableGUI();
433 $table->resetOffset();
434 $table->writeFilterToSession();
435
436 $this->participants();
437 }
438
442 protected function participantsResetFilter(): void
443 {
444 $table = $this->initParticipantTableGUI();
445 $table->resetOffset();
446 $table->resetFilter();
447
448 $this->participants();
449 }
450
454 protected function editMember(): void
455 {
456 $this->activateSubTab($this->getParentObject()->getType() . "_member_administration");
457 $this->editParticipants(array($this->initMemberIdFromGet()));
458 }
459
464 protected function editParticipants(array $post_participants = array()): void
465 {
466 if (!$post_participants) {
467 $post_participants = $this->initParticipantsFromPost();
468 }
469
470 $real_participants = $this->getMembersObject()->getParticipants();
471 $participants = array_intersect($post_participants, $real_participants);
472
473 if (!count($participants)) {
474 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('no_checkbox'), true);
475 $this->ctrl->redirect($this, 'participants');
476 }
477 $table = $this->initEditParticipantTableGUI($participants);
478 $this->tpl->setContent($table->getHTML());
479 }
480
484 public function updateParticipants(): void
485 {
486 $participants = $this->initParticipantsFromPost();
487 if (!count($participants)) {
488 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('no_checkbox'), true);
489 $this->ctrl->redirect($this, 'participants');
490 }
491 $notifications = $passed = $blocked = $contact = [];
492 if ($this->http->wrapper()->post()->has('notification')) {
493 $notifications = $this->http->wrapper()->post()->retrieve(
494 'notification',
495 $this->refinery->kindlyTo()->listOf(
496 $this->refinery->kindlyTo()->int()
497 )
498 );
499 }
500 if ($this->http->wrapper()->post()->has('passed')) {
501 $passed = $this->http->wrapper()->post()->retrieve(
502 'passed',
503 $this->refinery->kindlyTo()->listOf(
504 $this->refinery->kindlyTo()->int()
505 )
506 );
507 }
508 if ($this->http->wrapper()->post()->has('blocked')) {
509 $blocked = $this->http->wrapper()->post()->retrieve(
510 'blocked',
511 $this->refinery->kindlyTo()->listOf(
512 $this->refinery->kindlyTo()->int()
513 )
514 );
515 }
516 if ($this->http->wrapper()->post()->has('contact')) {
517 $contact = $this->http->wrapper()->post()->retrieve(
518 'contact',
519 $this->refinery->kindlyTo()->listOf(
520 $this->refinery->kindlyTo()->int()
521 )
522 );
523 }
524
525 // Determine whether the user has the 'edit_permission' permission
526 $hasEditPermissionAccess =
527 (
528 $this->access->checkAccess('edit_permission', '', $this->getParentObject()->getRefId()) or
529 $this->getMembersObject()->isAdmin($this->user->getId())
530 );
531
532 // Get all assignable local roles of the object, and
533 // determine the role id of the course administrator role.
534 $assignableLocalRoles = array();
535 $adminRoleId = $this->getParentObject()->getDefaultAdminRole();
536 foreach ($this->getLocalTypeRole(false) as $title => $role_id) {
537 $assignableLocalRoles[$role_id] = $title;
538 }
539
540 $post_roles = [];
541 if ($this->http->wrapper()->post()->has('roles')) {
542 $post_roles = $this->http->wrapper()->post()->retrieve(
543 'roles',
544 $this->refinery->kindlyTo()->dictOf(
545 $this->refinery->kindlyTo()->dictOf(
546 $this->refinery->kindlyTo()->int()
547 )
548 )
549 );
550 }
551
552 // Validate the user ids and role ids in the post data
553 foreach ($participants as $usr_id) {
554 $memberIsAdmin = $this->rbacreview->isAssigned($usr_id, (int) $adminRoleId);
555
556 // If the current user doesn't have the 'edit_permission'
557 // permission, make sure he doesn't remove the course
558 // administrator role of members who are course administrator.
559 if (
560 !$hasEditPermissionAccess &&
561 $memberIsAdmin &&
562 (
563 !is_array($post_roles[$usr_id]) ||
564 !in_array($adminRoleId, $post_roles[$usr_id])
565 )
566 ) {
567 $post_roles[$usr_id][] = $adminRoleId;
568 }
569
570 // Validate the role ids in the post data
571 foreach ((array) $post_roles[$usr_id] as $role_id) {
572 if (!array_key_exists($role_id, $assignableLocalRoles)) {
573 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('msg_no_perm_perm'), true);
574 $this->ctrl->redirect($this, 'participants');
575 }
576 if (!$hasEditPermissionAccess &&
577 $role_id == $adminRoleId &&
578 !$memberIsAdmin) {
579 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('msg_no_perm_perm'));
580 $this->ctrl->redirect($this, 'participants');
581 }
582 }
583 }
584
585 $has_admin = false;
586 foreach ($this->getMembersObject()->getAdmins() as $admin_id) {
587 if (!isset($post_roles[$admin_id])) {
588 $has_admin = true;
589 break;
590 }
591 if (in_array($adminRoleId, (array) $post_roles[$admin_id])) {
592 $has_admin = true;
593 break;
594 }
595 }
596
597 if (!$has_admin && is_array($post_roles)) {
598 // TODO PHP8 Review: Check change of SuperGlobals
599 foreach ($post_roles as $roleIdsToBeAssigned) {
600 if (in_array($adminRoleId, $roleIdsToBeAssigned)) {
601 $has_admin = true;
602 break;
603 }
604 }
605 }
606
607 if (!$has_admin) {
608 $this->tpl->setOnScreenMessage('failure', $this->lng->txt($this->getParentObject()->getType() . '_min_one_admin'), true);
609 $this->ctrl->redirect($this, 'participants');
610 }
611
612 foreach ($participants as $usr_id) {
613 $this->getMembersObject()->updateRoleAssignments($usr_id, (array) $post_roles[$usr_id]);
614
615 // Disable notification for all of them
616 $this->getMembersObject()->updateNotification($usr_id, false);
617 if (($this->getMembersObject()->isTutor($usr_id) || $this->getMembersObject()->isAdmin($usr_id)) && in_array(
618 $usr_id,
619 $notifications
620 )) {
621 $this->getMembersObject()->updateNotification($usr_id, true);
622 }
623
624 $this->getMembersObject()->updateBlocked($usr_id, false);
625 if ((!$this->getMembersObject()->isAdmin($usr_id) && !$this->getMembersObject()->isTutor($usr_id)) && in_array(
626 $usr_id,
627 $blocked
628 )) {
629 $this->getMembersObject()->updateBlocked($usr_id, true);
630 }
631
632 if ($this instanceof ilCourseMembershipGUI) {
633 $this->getMembersObject()->updatePassed($usr_id, in_array($usr_id, $passed), true);
634 $this->getMembersObject()->sendNotification(
636 $usr_id
637 );
638 }
639
640 if (
641 ($this->getMembersObject()->isAdmin($usr_id) || $this->getMembersObject()->isTutor($usr_id)) &&
642 in_array($usr_id, $contact)
643 ) {
644 $this->getMembersObject()->updateContact($usr_id, true);
645 } else {
646 $this->getMembersObject()->updateContact($usr_id, false);
647 }
648
649 $this->updateLPFromStatus($usr_id, in_array($usr_id, $passed));
650 }
651 $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
652 $this->ctrl->redirect($this, "participants");
653 }
654
655 protected function updateLPFromStatus(int $usr_id, bool $has_passed): void
656 {
657 }
658
662 protected function confirmDeleteParticipants(): void
663 {
664 $participants = $this->initParticipantsFromPost();
665
666 if (!count($participants)) {
667 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('no_checkbox'), true);
668 $this->ctrl->redirect($this, 'participants');
669 }
670
671 // Check last admin
672 if (!$this->getMembersObject()->checkLastAdmin($participants)) {
673 $this->tpl->setOnScreenMessage('failure', $this->lng->txt($this->getParentObject()->getType() . '_at_least_one_admin'), true);
674 $this->ctrl->redirect($this, 'participants');
675 }
676
677 // if only position access is granted, show additional info
678 if (!$this->checkPermissionBool('manage_members')) {
679 $this->lng->loadLanguageModule('rbac');
680 $this->tpl->setOnScreenMessage('info', $this->lng->txt('rbac_info_only_position_access'));
681 }
682
683 // Access check for admin deletion
684 if (
685 !$this->access->checkAccess(
686 'edit_permission',
687 '',
688 $this->getParentObject()->getRefId()
689 ) &&
690 !$this->getMembersObject()->isAdmin($this->user->getId())
691 ) {
692 foreach ($participants as $usr_id) {
693 if ($this->getMembersObject()->isAdmin($usr_id)) {
694 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("msg_no_perm_perm"), true);
695 $this->ctrl->redirect($this, 'participants');
696 }
697 }
698 }
699
701 $this->repository_object->getRefId(),
702 $participants
703 )) {
704 $this->showDeleteParticipantsConfirmationWithLinkedCourses($participants);
705 return;
706 }
707
708 $confirm = new ilConfirmationGUI();
709 $confirm->setFormAction($this->ctrl->getFormAction($this, 'confirmDeleteParticipants'));
710 $confirm->setHeaderText($this->lng->txt($this->getParentObject()->getType() . '_header_delete_members'));
711 $confirm->setConfirm($this->lng->txt('confirm'), 'deleteParticipants');
712 $confirm->setCancel($this->lng->txt('cancel'), 'participants');
713
714 foreach ($participants as $usr_id) {
715 $name = ilObjUser::_lookupName($usr_id);
716
717 $confirm->addItem(
718 'participants[]',
719 (string) $name['user_id'],
720 $name['lastname'] . ', ' . $name['firstname'] . ' [' . $name['login'] . ']',
721 ilUtil::getImagePath('icon_usr.svg')
722 );
723 }
724 $this->tpl->setContent($confirm->getHTML());
725 }
726
727 protected function deleteParticipants(): void
728 {
729 $participants = $this->initParticipantsFromPost();
730 if (!count($participants)) {
731 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("no_checkbox"), true);
732 $this->ctrl->redirect($this, 'participants');
733 }
734
735 // If the user doesn't have the edit_permission and is not administrator, he may not remove
736 // members who have the course administrator role
737 if (
738 !$this->access->checkAccess('edit_permission', '', $this->getParentObject()->getRefId()) &&
739 !$this->getMembersObject()->isAdmin($this->user->getId())
740 ) {
741 foreach ($participants as $part) {
742 if ($this->getMembersObject()->isAdmin($part)) {
743 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('msg_no_perm_perm'), true);
744 $this->ctrl->redirect($this, 'participants');
745 }
746 }
747 }
748
749 if (!$this->getMembersObject()->deleteParticipants($participants)) {
750 $this->tpl->setOnScreenMessage('failure', 'Error deleting participants.', true);
751 $this->ctrl->redirect($this, 'participants');
752 } else {
753 foreach ($participants as $usr_id) {
754 $mail_type = 0;
755 // @todo more generic
756 switch ($this->getParentObject()->getType()) {
757 case 'crs':
759 break;
760 case 'grp':
762 break;
763 case 'lso':
765 break;
766 }
767 $this->getMembersObject()->sendNotification($mail_type, $usr_id);
768 }
769 }
770 $this->tpl->setOnScreenMessage('success', $this->lng->txt($this->getParentObject()->getType() . "_members_deleted"), true);
771 $this->ctrl->redirect($this, "participants");
772 }
773
774 protected function sendMailToSelectedUsers(): void
775 {
776 $participants = [];
777 if ($this->http->wrapper()->post()->has('participants')) {
778 $participants = $this->initParticipantsFromPost();
779 } elseif ($this->http->wrapper()->post()->has('subscribers')) {
780 $participants = $this->initSubscribersFromPost();
781 } elseif ($this->http->wrapper()->post()->has('waiting')) {
782 $participants = $this->initWaitingListIdsFromPost();
783 } elseif ($this->http->wrapper()->query()->has('member_id')) {
784 $participants = [$this->initMemberIdFromGet()];
785 }
786 if (!count($participants)) {
787 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("no_checkbox"), true);
788 $this->ctrl->redirect($this, 'participants');
789 }
790
791 $rcps = [];
792 foreach ($participants as $usr_id) {
793 $rcps[] = ilObjUser::_lookupLogin($usr_id);
794 }
795 $context_options = $this->getMailContextOptions();
796
800 $this,
801 'participants',
802 array(),
803 array(
804 'type' => 'new',
805 'sig' => $this->createMailSignature()
806 ),
807 $context_options
808 )
809 );
810 }
811
812 protected function getMailContextOptions(): array
813 {
814 return [];
815 }
816
820 protected function membersMap(): void
821 {
822 $this->activateSubTab($this->getParentObject()->getType() . "_members_map");
823 if (!ilMapUtil::isActivated() || !$this->getParentObject()->getEnableMap()) {
824 return;
825 }
826
827 $map = ilMapUtil::getMapGUI();
828 $map->setMapId("course_map")
829 ->setWidth("700px")
830 ->setHeight("500px")
831 ->setLatitude($this->getParentObject()->getLatitude())
832 ->setLongitude($this->getParentObject()->getLongitude())
833 ->setZoom($this->getParentObject()->getLocationZoom())
834 ->setEnableTypeControl(true)
835 ->setEnableNavigationControl(true)
836 ->setEnableCentralMarker(true);
837
838 $members = ilParticipants::getInstanceByObjId($this->getParentObject()->getId())->getParticipants();
839 foreach ($members as $user_id) {
840 $map->addUserMarker($user_id);
841 }
842
843 $this->tpl->setContent($map->getHtml());
844 $this->tpl->setLeftContent($map->getUserListHtml());
845 }
846
847 protected function mailMembersBtn(): void
848 {
849 $this->showMailToMemberToolbarButton($this->toolbar, 'mailMembersBtn');
850 }
851
855 protected function showParticipantsToolbar(): void
856 {
857 if ($this->canAddOrSearchUsers()) {
859 $this,
860 $this->toolbar,
861 array(
862 'auto_complete_name' => $this->lng->txt('user'),
863 'user_type' => $this->getParentGUI()->getLocalRoles(),
864 'user_type_default' => $this->getDefaultRole(),
865 'submit_name' => $this->lng->txt('add')
866 )
867 );
868
869 // spacer
870 $this->toolbar->addSeparator();
871
872 // search button
873 $this->toolbar->addButton(
874 $this->lng->txt($this->getParentObject()->getType() . "_search_users"),
875 $this->ctrl->getLinkTargetByClass(
876 'ilRepositorySearchGUI',
877 'start'
878 )
879 );
880
881 // separator
882 $this->toolbar->addSeparator();
883 }
884
885 // print button
886 $this->toolbar->addButton(
887 $this->lng->txt($this->getParentObject()->getType() . "_print_list"),
888 $this->ctrl->getLinkTarget($this, 'printMembers')
889 );
890 $this->showMailToMemberToolbarButton($this->toolbar, 'participants', false);
891 }
892
894 ilToolbarGUI $toolbar,
895 ?string $a_back_cmd = null,
896 bool $a_separator = false
897 ): void {
898 if (
899 $this->getParentObject()->getType() === 'crs' &&
900 $this->getParentObject()->getShowMembersExport()) {
901 if ($a_separator) {
902 $toolbar->addSeparator();
903 }
904
905 if ($a_back_cmd) {
906 $this->ctrl->setParameter($this, "back_cmd", $a_back_cmd);
907 }
908 $toolbar->addButton(
909 $this->lng->txt($this->getParentObject()->getType() . '_print_list'),
910 $this->ctrl->getLinkTarget($this, 'printForMembersOutput')
911 );
912 }
913 }
914
919 ilToolbarGUI $toolbar,
920 ?string $a_back_cmd = null,
921 bool $a_separator = false
922 ): void {
923 $mail = new ilMail($this->user->getId());
924
925 if (
926 ($this->getParentObject()->getMailToMembersType() === 1) ||
927 (
928 $this->access->checkAccess('manage_members', "", $this->getParentObject()->getRefId()) &&
929 $this->rbacsystem->checkAccess('internal_mail', $mail->getMailObjectReferenceId())
930 )
931 ) {
932 if ($a_separator) {
933 $toolbar->addSeparator();
934 }
935
936 if ($a_back_cmd !== null) {
937 $this->ctrl->setParameter($this, "back_cmd", $a_back_cmd);
938 }
939
940 $toolbar->addButton(
941 $this->lng->txt("mail_members"),
942 $this->ctrl->getLinkTargetByClass('ilMailMemberSearchGUI', '')
943 );
944 }
945 }
946
951 public function createMailSignature(): string
952 {
953 return $this->getParentGUI()->createMailSignature();
954 }
955
956 protected function getDefaultCommand(): string
957 {
958 $has_manage_members_permission = $this->checkRbacOrPositionAccessBool(
959 'manage_members',
960 'manage_members',
961 $this->getParentObject()->getRefId()
962 );
963 if ($has_manage_members_permission) {
964 return 'participants';
965 }
966
967 if ($this->getParentObject()->getShowMembers()) {
968 return 'jump2UsersGallery';
969 }
970 return 'mailMembersBtn';
971 }
972
973 public function addMemberTab(ilTabsGUI $tabs, bool $a_is_participant = false): void
974 {
975 $mail = new ilMail($this->user->getId());
976
977 $member_tab_name = $this->getMemberTabName();
978
979 $has_manage_members_permission = $this->checkRbacOrPositionAccessBool(
980 'manage_members',
981 'manage_members',
982 $this->getParentObject()->getRefId()
983 );
984
985 if ($has_manage_members_permission) {
986 $tabs->addTab(
987 'members',
988 $member_tab_name,
989 $this->ctrl->getLinkTarget($this, '')
990 );
991 } elseif (
992 $this->getParentObject()->getShowMembers() &&
993 $a_is_participant
994 ) {
995 $tabs->addTab(
996 'members',
997 $member_tab_name,
998 $this->ctrl->getLinkTargetByClass(array(get_class($this), 'ilusersgallerygui'), 'view')
999 );
1000 } elseif (
1001 $this->getParentObject()->getMailToMembersType() === 1 &&
1002 $this->rbacsystem->checkAccess('internal_mail', $mail->getMailObjectReferenceId()) &&
1003 $a_is_participant
1004 ) {
1005 $tabs->addTab(
1006 'members',
1007 $member_tab_name,
1008 $this->ctrl->getLinkTarget($this, "mailMembersBtn")
1009 );
1010 }
1011 }
1012
1013 protected function getMemberTabName(): string
1014 {
1015 return $this->lng->txt('members');
1016 }
1017
1021 protected function setSubTabs(ilTabsGUI $tabs): void
1022 {
1023 if ($this->checkRbacOrPositionAccessBool(
1024 'manage_members',
1025 'manage_members',
1026 $this->getParentObject()->getRefId()
1027 )) {
1028 $tabs->addSubTabTarget(
1029 $this->getParentObject()->getType() . "_member_administration",
1030 $this->ctrl->getLinkTarget($this, 'participants'),
1031 "members",
1032 get_class($this)
1033 );
1034
1035 // show group overview
1036 if ($this instanceof ilCourseMembershipGUI) {
1037 $tabs->addSubTabTarget(
1038 "crs_members_groups",
1039 $this->ctrl->getLinkTargetByClass("ilCourseParticipantsGroupsGUI", "show"),
1040 "",
1041 "ilCourseParticipantsGroupsGUI"
1042 );
1043 }
1044
1045 $children = $this->tree->getSubTree(
1046 $this->tree->getNodeData($this->getParentObject()->getRefId()),
1047 false,
1048 ['sess']
1049 );
1050 if (count($children)) {
1051 $tabs->addSubTabTarget(
1052 'events',
1053 $this->ctrl->getLinkTargetByClass(array(get_class($this), 'ilsessionoverviewgui'), 'listSessions'),
1054 '',
1055 'ilsessionoverviewgui'
1056 );
1057 }
1058 $tabs->addSubTabTarget(
1059 $this->getParentObject()->getType() . '_members_gallery',
1060 $this->ctrl->getLinkTargetByClass(array(get_class($this), 'ilUsersGalleryGUI')),
1061 'view',
1062 'ilUsersGalleryGUI'
1063 );
1064 } elseif ($this->getParentObject()->getShowMembers()) {
1065 // gallery
1066 $tabs->addSubTabTarget(
1067 $this->getParentObject()->getType() . '_members_gallery',
1068 $this->ctrl->getLinkTargetByClass(array(get_class($this), 'ilUsersGalleryGUI')),
1069 'view',
1070 'ilUsersGalleryGUI'
1071 );
1072 }
1073
1074 if (ilMapUtil::isActivated() && $this->getParentObject()->getEnableMap()) {
1075 $tabs->addSubTabTarget(
1076 $this->getParentObject()->getType() . '_members_map',
1077 $this->ctrl->getLinkTarget($this, 'membersMap'),
1078 "membersMap",
1079 get_class($this)
1080 );
1081 }
1082
1083 if (ilPrivacySettings::getInstance()->checkExportAccess($this->getParentObject()->getRefId())) {
1084 $tabs->addSubTabTarget(
1085 'export_members',
1086 $this->ctrl->getLinkTargetByClass(array(get_class($this), 'ilmemberexportgui'), 'show'),
1087 '',
1088 'ilmemberexportgui'
1089 );
1090 }
1091 }
1092
1097 public function readMemberData(array $usr_ids, array $columns): array
1098 {
1099 return $this->getParentGUI()->readMemberData($usr_ids, $columns);
1100 }
1101
1105 public function getLocalRoles(): array
1106 {
1107 return $this->getParentGUI()->getLocalRoles();
1108 }
1109
1114 {
1115 $subscribers = $this->getMembersObject()->getSubscribers();
1116 $filtered_subscribers = $this->filterUserIdsByRbacOrPositionOfCurrentUser($subscribers);
1117 if (!count($filtered_subscribers)) {
1118 return null;
1119 }
1120 $subscriber = $this->initSubscriberTable();
1121 $subscriber->readSubscriberData(
1122 $filtered_subscribers
1123 );
1124 return $subscriber;
1125 }
1126
1128 {
1129 $subscriber = new ilSubscriberTableGUI($this, $this->getParentObject(), true, true);
1130 $subscriber->setTitle($this->lng->txt('group_new_registrations'));
1131 return $subscriber;
1132 }
1133
1137 public function confirmAssignSubscribers(): void
1138 {
1139 $subscribers = $this->initSubscribersFromPost();
1140 if (!count($subscribers)) {
1141 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("crs_no_subscribers_selected"), true);
1142 $this->ctrl->redirect($this, 'participants');
1143 }
1144
1145 $c_gui = new ilConfirmationGUI();
1146
1147 // set confirm/cancel commands
1148 $c_gui->setFormAction($this->ctrl->getFormAction($this, "assignSubscribers"));
1149 $c_gui->setHeaderText($this->lng->txt("info_assign_sure"));
1150 $c_gui->setCancel($this->lng->txt("cancel"), "participants");
1151 $c_gui->setConfirm($this->lng->txt("confirm"), "assignSubscribers");
1152
1153 foreach ($subscribers as $subscriber) {
1154 $name = ilObjUser::_lookupName($subscriber);
1155
1156 $c_gui->addItem(
1157 'subscribers[]',
1158 (string) $name['user_id'],
1159 $name['lastname'] . ', ' . $name['firstname'] . ' [' . $name['login'] . ']',
1160 ilUtil::getImagePath('icon_usr.svg')
1161 );
1162 }
1163 $this->tpl->setContent($c_gui->getHTML());
1164 }
1165
1169 public function confirmRefuseSubscribers(): void
1170 {
1171 $subscribers = $this->initSubscribersFromPost();
1172 if (!count($subscribers)) {
1173 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("crs_no_subscribers_selected"), true);
1174 $this->ctrl->redirect($this, 'participants');
1175 }
1176 $this->lng->loadLanguageModule('mmbr');
1177 $c_gui = new ilConfirmationGUI();
1178 // set confirm/cancel commands
1179 $c_gui->setFormAction($this->ctrl->getFormAction($this, "refuseSubscribers"));
1180 $c_gui->setHeaderText($this->lng->txt("info_refuse_sure"));
1181 $c_gui->setCancel($this->lng->txt("cancel"), "participants");
1182 $c_gui->setConfirm($this->lng->txt("confirm"), "refuseSubscribers");
1183
1184 foreach ($subscribers as $subscriber_id) {
1185 $name = ilObjUser::_lookupName($subscriber_id);
1186
1187 $c_gui->addItem(
1188 'subscribers[]',
1189 (string) $name['user_id'],
1190 $name['lastname'] . ', ' . $name['firstname'] . ' [' . $name['login'] . ']',
1191 ilUtil::getImagePath('icon_usr.svg')
1192 );
1193 }
1194
1195 $this->tpl->setContent($c_gui->getHTML());
1196 }
1197
1198 protected function refuseSubscribers(): void
1199 {
1200 $subscribers = $this->initSubscribersFromPost();
1201 if (!count($subscribers)) {
1202 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("crs_no_subscribers_selected"), true);
1203 $this->ctrl->redirect($this, 'participants');
1204 }
1205
1206 if (!$this->getMembersObject()->deleteSubscribers($subscribers)) {
1207 $this->tpl->setOnScreenMessage('failure', $this->error->getMessage(), true);
1208 $this->ctrl->redirect($this, 'participants');
1209 } else {
1210 foreach ($subscribers as $usr_id) {
1211 if ($this instanceof ilCourseMembershipGUI) {
1212 $this->getMembersObject()->sendNotification(
1214 $usr_id
1215 );
1216 }
1217 if ($this instanceof ilGroupMembershipGUI) {
1218 $this->getMembersObject()->sendNotification(
1220 $usr_id
1221 );
1222 }
1223 if ($this instanceof ilSessionMembershipGUI) {
1225 $noti->setRefId($this->getParentObject()->getRefId());
1226 $noti->setRecipients(array($usr_id));
1228 $noti->send();
1229 }
1230 if ($this instanceof ilLearningSequenceMembershipGUI) {
1231 $this->getMembersObject()->sendNotification(
1233 $usr_id
1234 );
1235 }
1236 }
1237 }
1238
1239 $this->tpl->setOnScreenMessage('success', $this->lng->txt("crs_subscribers_deleted"), true);
1240 $this->ctrl->redirect($this, 'participants');
1241 }
1242
1246 public function assignSubscribers(): void
1247 {
1248 $subscribers = $this->initSubscribersFromPost();
1249 if (!count($subscribers)) {
1250 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("crs_no_subscribers_selected"), true);
1251 $this->ctrl->redirect($this, 'participants');
1252 }
1253
1254 if (!$this->getMembersObject()->assignSubscribers($subscribers)) {
1255 $this->tpl->setOnScreenMessage('failure', $this->error->getMessage(), true);
1256 $this->ctrl->redirect($this, 'participants');
1257 } else {
1258 foreach ($subscribers as $usr_id) {
1259 if ($this instanceof ilCourseMembershipGUI) {
1260 $this->getMembersObject()->sendNotification(
1262 $usr_id
1263 );
1264 $this->getParentObject()->checkLPStatusSync($usr_id);
1265 }
1266 if ($this instanceof ilGroupMembershipGUI) {
1267 $this->getMembersObject()->sendNotification(
1269 $usr_id
1270 );
1271 }
1272 if ($this instanceof ilSessionMembershipGUI) {
1273 // todo refactor to participants
1275 $noti->setRefId($this->getParentObject()->getRefId());
1276 $noti->setRecipients(array($usr_id));
1278 $noti->send();
1279 }
1280 }
1281 }
1282 $this->tpl->setOnScreenMessage('success', $this->lng->txt("crs_subscribers_assigned"), true);
1283 $this->ctrl->redirect($this, 'participants');
1284 }
1285
1290 {
1291 $wait = $this->initWaitingList();
1292
1293 $wait_users = $this->filterUserIdsByRbacOrPositionOfCurrentUser($wait->getUserIds());
1294 if (!count($wait_users)) {
1295 return null;
1296 }
1297
1298 $waiting_table = new ilWaitingListTableGUI($this, $this->getParentObject(), $wait);
1299 $waiting_table->setUserIds(
1300 $wait_users
1301 );
1302 $waiting_table->readUserData();
1303 $waiting_table->setTitle($this->lng->txt('crs_waiting_list'));
1304
1305 return $waiting_table;
1306 }
1307
1311 public function confirmAssignFromWaitingList(): void
1312 {
1313 $waiting_list_ids = $this->initWaitingListIdsFromPost();
1314 if (!count($waiting_list_ids)) {
1315 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("crs_no_users_selected"), true);
1316 $this->ctrl->redirect($this, 'participants');
1317 }
1318 $c_gui = new ilConfirmationGUI();
1319 // set confirm/cancel commands
1320 $c_gui->setFormAction($this->ctrl->getFormAction($this, "assignFromWaitingList"));
1321 $c_gui->setHeaderText($this->lng->txt("info_assign_sure"));
1322 $c_gui->setCancel($this->lng->txt("cancel"), "participants");
1323 $c_gui->setConfirm($this->lng->txt("confirm"), "assignFromWaitingList");
1324
1325 foreach ($waiting_list_ids as $waiting) {
1326 $name = ilObjUser::_lookupName($waiting);
1327
1328 $c_gui->addItem(
1329 'waiting[]',
1330 (string) $name['user_id'],
1331 $name['lastname'] . ', ' . $name['firstname'] . ' [' . $name['login'] . ']',
1332 ilUtil::getImagePath('icon_usr.svg')
1333 );
1334 }
1335
1336 $this->tpl->setContent($c_gui->getHTML());
1337 }
1338
1342 public function assignFromWaitingList(): void
1343 {
1344 $waiting_list_ids = $this->initWaitingListIdsFromPost();
1345 if (!count($waiting_list_ids)) {
1346 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("crs_no_users_selected"), true);
1347 $this->ctrl->redirect($this, 'participants');
1348 }
1349
1350 $waiting_list = $this->initWaitingList();
1351
1352 $added_users = 0;
1353 foreach ($waiting_list_ids as $user_id) {
1354 if (!$tmp_obj = ilObjectFactory::getInstanceByObjId((int) $user_id, false)) {
1355 continue;
1356 }
1357 if ($this->getMembersObject()->isAssigned((int) $user_id)) {
1358 continue;
1359 }
1360
1361 if ($this instanceof ilCourseMembershipGUI) {
1362 $this->getMembersObject()->add($user_id, ilParticipants::IL_CRS_MEMBER);
1363 $this->getMembersObject()->sendNotification(
1365 (int) $user_id,
1366 true
1367 );
1368 $this->getParentObject()->checkLPStatusSync((int) $user_id);
1369 }
1370 if ($this instanceof ilGroupMembershipGUI) {
1371 $this->getMembersObject()->add($user_id, ilParticipants::IL_GRP_MEMBER);
1372 $this->getMembersObject()->sendNotification(
1374 (int) $user_id,
1375 true
1376 );
1377 }
1378 if ($this instanceof ilSessionMembershipGUI) {
1379 $this->getMembersObject()->register((int) $user_id);
1381 $noti->setRefId($this->getParentObject()->getRefId());
1382 $noti->setRecipients(array($user_id));
1384 $noti->send();
1385 }
1386
1387 $waiting_list->removeFromList((int) $user_id);
1388 ++$added_users;
1389 }
1390
1391 if ($added_users) {
1392 $this->tpl->setOnScreenMessage('success', $this->lng->txt("crs_users_added"), true);
1393 } else {
1394 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("crs_users_already_assigned"), true);
1395 }
1396 $this->ctrl->redirect($this, 'participants');
1397 }
1398
1402 public function confirmRefuseFromList(): void
1403 {
1404 $waiting_list_ids = $this->initWaitingListIdsFromPost();
1405 if (!count($waiting_list_ids)) {
1406 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("no_checkbox"), true);
1407 $this->ctrl->redirect($this, 'participants');
1408 }
1409 $this->lng->loadLanguageModule('mmbr');
1410 $c_gui = new ilConfirmationGUI();
1411
1412 // set confirm/cancel commands
1413 $c_gui->setFormAction($this->ctrl->getFormAction($this, "refuseFromList"));
1414 $c_gui->setHeaderText($this->lng->txt("info_refuse_sure"));
1415 $c_gui->setCancel($this->lng->txt("cancel"), "participants");
1416 $c_gui->setConfirm($this->lng->txt("confirm"), "refuseFromList");
1417
1418 foreach ($waiting_list_ids as $waiting) {
1419 $name = ilObjUser::_lookupName($waiting);
1420
1421 $c_gui->addItem(
1422 'waiting[]',
1423 (string) $name['user_id'],
1424 $name['lastname'] . ', ' . $name['firstname'] . ' [' . $name['login'] . ']',
1425 ilUtil::getImagePath('icon_usr.svg')
1426 );
1427 }
1428 $this->tpl->setContent($c_gui->getHTML());
1429 }
1430
1434 protected function refuseFromList(): void
1435 {
1436 $waiting_list_ids = $this->initWaitingListIdsFromPost();
1437 if (!count($waiting_list_ids)) {
1438 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('no_checkbox'), true);
1439 $this->ctrl->redirect($this, 'participants');
1440 }
1441
1442 $waiting_list = $this->initWaitingList();
1443
1444 foreach ($waiting_list_ids as $user_id) {
1445 $waiting_list->removeFromList((int) $user_id);
1446
1447 if ($this instanceof ilCourseMembershipGUI) {
1448 $this->getMembersObject()->sendNotification(
1450 (int) $user_id,
1451 true
1452 );
1453 }
1454 if ($this instanceof ilGroupMembershipGUI) {
1455 $this->getMembersObject()->sendNotification(
1457 (int) $user_id,
1458 true
1459 );
1460 }
1461 if ($this instanceof ilSessionMembershipGUI) {
1463 $noti->setRefId($this->getParentObject()->getRefId());
1464 $noti->setRecipients(array($user_id));
1466 $noti->send();
1467 }
1468 }
1469 $this->tpl->setOnScreenMessage('success', $this->lng->txt('crs_users_removed_from_list'), true);
1470 $this->ctrl->redirect($this, 'participants');
1471 }
1472
1476 protected function addToClipboard(): void
1477 {
1478 // begin-patch clipboard
1479 $users = [];
1480 if ($this->http->wrapper()->post()->has('participants')) {
1481 $users = $this->initParticipantsFromPost();
1482 } elseif ($this->http->wrapper()->post()->has('subscribers')) {
1483 $users = $this->initSubscribersFromPost();
1484 } elseif ($this->http->wrapper()->post()->has('waiting')) {
1485 $users = $this->initWaitingListIdsFromPost();
1486 }
1487 // end-patch clipboard
1488 if (!count($users)) {
1489 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'), true);
1490 $this->ctrl->redirect($this, 'participants');
1491 }
1492 $clip = ilUserClipboard::getInstance($this->user->getId());
1493 $clip->add($users);
1494 $clip->save();
1495
1496 $this->lng->loadLanguageModule('user');
1497 $this->tpl->setOnScreenMessage('success', $this->lng->txt('clipboard_user_added'), true);
1498 $this->ctrl->redirect($this, 'participants');
1499 }
1500
1501 protected function getDefaultRole(): ?int
1502 {
1503 return null;
1504 }
1505
1506 protected function activateSubTab(string $a_sub_tab): void
1507 {
1508 $this->tabs->activateSubTab($a_sub_tab);
1509 }
1510
1514 protected function printMembers(): void
1515 {
1516 $this->checkPermission('read');
1517
1518 $this->tabs->clearTargets();
1519
1520 $this->tabs->setBackTarget(
1521 $this->lng->txt('back'),
1522 $this->ctrl->getLinkTarget($this, 'participants')
1523 );
1524
1525 $list = $this->initAttendanceList();
1526 $form = $list->initForm('printMembersOutput');
1527 $this->tpl->setContent($form->getHTML());
1528 }
1529
1533 protected function printMembersOutput(): void
1534 {
1535 $this->tabs->clearTargets();
1536 $this->tabs->setBackTarget(
1537 $this->lng->txt('back'),
1538 $this->ctrl->getLinkTarget($this, 'participants')
1539 );
1540
1541 $list = $this->initAttendanceList();
1542 $list->initFromForm();
1543 $list->setCallback([$this, 'getAttendanceListUserData']);
1544 $this->member_data = $this->getPrintMemberData(
1545 $this->filterUserIdsByRbacOrPositionOfCurrentUser(
1546 $this->getMembersObject()->getParticipants()
1547 )
1548 );
1549
1550 $list->getNonMemberUserData($this->member_data);
1551 $list->getFullscreenHTML();
1552 }
1553
1557 protected function printForMembersOutput(): void
1558 {
1559 $this->tabs->clearTargets();
1560 $this->tabs->setBackTarget(
1561 $this->lng->txt('back'),
1562 $this->ctrl->getLinkTarget($this, 'jump2UsersGallery')
1563 );
1564
1565 $list = $this->initAttendanceList();
1566 $list->setTitle($this->lng->txt('obj_' . $this->getParentObject()->getType()) . ': ' . $this->getParentObject()->getTitle());
1567 $list->initFromSettings();
1568 $list->setCallback([$this, 'getAttendanceListUserData']);
1569 $this->member_data = $this->getPrintMemberData($this->getMembersObject()->getParticipants());
1570 $list->getNonMemberUserData($this->member_data);
1571 $list->getFullscreenHTML();
1572 }
1573
1574 protected function jump2UsersGallery(): void
1575 {
1576 $this->ctrl->redirectByClass('ilUsersGalleryGUI');
1577 }
1578
1579 protected function initAttendanceList(bool $a_for_members = false): ?ilAttendanceList
1580 {
1581 global $DIC;
1582
1583 $waiting_list = $this->initWaitingList();
1584
1585 if ($this instanceof ilSessionMembershipGUI) {
1586 $member_id = $DIC->repositoryTree()->checkForParentType(
1587 $this->getParentObject()->getRefId(),
1588 'grp'
1589 );
1590 if (!$member_id) {
1591 $member_id = $DIC->repositoryTree()->checkForParentType(
1592 $this->getParentObject()->getRefId(),
1593 'crs'
1594 );
1595 }
1596 if (!$member_id) {
1597 $DIC->logger()->sess()->warning('Cannot find parent course or group for ref_id: ' . $this->getParentObject()->getRefId());
1598 $member_id = $this->getParentObject()->getRefId();
1599 }
1600 $part = ilParticipants::getInstance($member_id);
1601
1602 $list = new ilAttendanceList(
1603 $this,
1604 $this->getParentObject(),
1605 $part,
1606 $waiting_list
1607 );
1608 } else {
1609 $list = new ilAttendanceList(
1610 $this,
1611 $this->getParentObject(),
1612 $this->getMembersObject(),
1613 $waiting_list
1614 );
1615 }
1616 $list->setId($this->getParentObject()->getType() . '_memlist_' . $this->getParentObject()->getId());
1617
1618 $list->setTitle(
1619 $this->lng->txt($this->getParentObject()->getType() . '_members_print_title'),
1620 $this->lng->txt('obj_' . $this->getParentObject()->getType()) . ': ' . $this->getParentObject()->getTitle()
1621 );
1622
1623 $show_tracking =
1625 if ($show_tracking) {
1626 $olp = ilObjectLP::getInstance($this->getParentObject()->getId());
1627 $show_tracking = $olp->isActive();
1628 }
1629 if ($show_tracking && $this->getParentObject()->getType() !== 'sess') {
1630 $list->addPreset('progress', $this->lng->txt('learning_progress'), true);
1631 }
1632
1633 $privacy = ilPrivacySettings::getInstance();
1634 if ($privacy->enabledAccessTimesByType($this->getParentObject()->getType())) {
1635 $list->addPreset('access', $this->lng->txt('last_access'), true);
1636 }
1637
1638 switch ($this->getParentObject()->getType()) {
1639 case 'crs':
1640 $list->addPreset('status', $this->lng->txt('crs_status'), true);
1641 $list->addPreset('passed', $this->lng->txt('crs_passed'), true);
1642 break;
1643
1644 case 'sess':
1645 $list->addPreset('mark', $this->lng->txt('trac_mark'), true);
1646 $list->addPreset('comment', $this->lng->txt('trac_comment'), true);
1647 if ($this->getParentObject()->enabledRegistration()) {
1648 $list->addPreset('registered', $this->lng->txt('event_tbl_registered'), true);
1649 }
1650 $list->addPreset('participated', $this->lng->txt('event_tbl_participated'), true);
1651 $list->addBlank($this->lng->txt('sess_signature'));
1652
1653 $list->addUserFilter('registered', $this->lng->txt('event_list_registered_only'));
1654 break;
1655
1656 case 'grp':
1657 default:
1658 break;
1659 }
1660 return $list;
1661 }
1662}
Builds data types.
Definition: Factory.php:21
error(string $a_errmsg)
Class ilAbstractMailMemberRoles.
Base class for attendance lists.
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 ilCourseParticipantsGroupsGUI.
static isReferenceMemberUpdateConfirmationRequired(int $course_ref_id, array $participants)
Error Handling & global info handling uses PEAR error class.
GUI class for membership features.
language handling
GUI class for learning sequence membership features.
Component logger with individual log levels by component id.
static getRedirectTarget( $gui, string $cmd, array $gui_params=[], array $mail_params=[], array $context_params=[])
static setRecipients(array $recipients, string $type='to')
Class ilMailMemberSearchGUI.
static isActivated()
Checks whether Map feature is activated.
static getMapGUI()
Get an instance of the GUI class.
Base class for member tab content.
checkPermissionBool(string $a_permission, string $a_cmd='', string $a_type='', int $a_ref_id=0)
assignFromWaitingList()
Assign from waiting list.
printMembersOutput()
print members output
participantsApplyFilter()
Apply filter for participant table.
GlobalHttpState $http
checkPermission(string $a_permission, string $a_cmd="")
Check permission If not granted redirect to parent gui.
parseWaitingListTable()
Parse table of subscription request.
assignSubscribers()
Do assignment of subscription request.
printForMembersOutput()
print members output
participantsResetFilter()
reset participants filter
confirmAssignFromWaitingList()
Assign from waiting list (confirmatoin)
updateParticipants()
update members
showParticipantsToolbar()
Show participants toolbar.
ilParticipants $participants
addMemberTab(ilTabsGUI $tabs, bool $a_is_participant=false)
participants()
Show participant table, subscriber table, wating list table;.
parseSubscriberTable()
Parse table of subscription request.
updateLPFromStatus(int $usr_id, bool $has_passed)
checkRbacOrPermissionAccess(string $a_rbac_perm, string $a_pos_perm)
check rbac or position access
initAttendanceList(bool $a_for_members=false)
ilErrorHandling $error
editMember()
Edit one participant.
checkRbacOrPositionAccessBool(string $a_rbac_perm, string $a_pos_perm, int $a_ref_id=0)
__construct(ilObjectGUI $repository_gui, ilObject $repository_obj)
editParticipants(array $post_participants=array())
Edit participants.
confirmRefuseSubscribers()
Refuse subscriber confirmation.
activateSubTab(string $a_sub_tab)
createMailSignature()
Create Mail signature.
ilGlobalTemplateInterface $tpl
confirmDeleteParticipants()
Show confirmation screen for participants deletion.
confirmAssignSubscribers()
Show subscription confirmation.
filterUserIdsByRbacOrPositionOfCurrentUser(array $a_user_ids)
Filter user ids by access.
showMailToMemberToolbarButton(ilToolbarGUI $toolbar, ?string $a_back_cmd=null, bool $a_separator=false)
Show mail to member toolbar button.
ilCtrlInterface $ctrl
ilAccessHandler $access
addToClipboard()
Add selected users to user clipboard.
readMemberData(array $usr_ids, array $columns)
Required for member table guis.
setSubTabs(ilTabsGUI $tabs)
Set sub tabs.
refuseFromList()
refuse from waiting list
confirmRefuseFromList()
Refuse from waiting list (confirmation)
canAddOrSearchUsers()
Check if current user is allowed to add / search users.
showMemberExportToolbarButton(ilToolbarGUI $toolbar, ?string $a_back_cmd=null, bool $a_separator=false)
getAttendanceListUserData(int $user_id, array $filters=[])
User class.
static _lookupName(int $a_user_id)
lookup user name
static _lookupLogin(int $a_user_id)
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
Class ilObjectGUI Basic methods of all Output classes.
static getInstance(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Base class for course and group participants.
static getInstanceByObjId(int $a_obj_id)
Get instance by obj type.
static getInstance(int $a_ref_id)
static _isParticipant(int $a_ref_id, int $a_usr_id)
Static function to check if a user is a participant of the container object.
isAdmin(int $a_usr_id)
check if user is admin
class ilRbacReview Contains Review functions of core Rbac.
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
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...
GUI class for course/group subscriptions.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addTab(string $a_id, string $a_text, string $a_link, string $a_frame="")
Add a Tab.
addSubTabTarget(string $a_text, string $a_link, $a_cmd="", $a_cmdClass="", string $a_frame="", bool $a_activate=false, bool $a_dir_text=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addButton(string $a_txt, string $a_cmd, string $a_target="", ?int $a_acc_key=null, string $a_additional_attrs='', string $a_id="", string $a_class='submit')
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstance(int $a_usr_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...
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static redirect(string $a_script)
GUI class for course/group waiting list.
if(!file_exists(getcwd() . '/ilias.ini.php'))
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: confirmReg.php:20
global $DIC
Definition: feed.php:28
Interface GlobalHttpState.
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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$provider
Definition: ltitoken.php:83
if($format !==null) $name
Definition: metadata.php:247
static http()
Fetches the global http state from ILIAS.