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