ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilBookingParticipantGUI.php
Go to the documentation of this file.
1<?php
2
25{
26 public const FILTER_ACTION_APPLY = 1;
27 public const FILTER_ACTION_RESET = 2;
28 public const PARTICIPANT_VIEW = 1;
29 protected \ILIAS\BookingManager\Access\AccessManager $access;
30 protected \ILIAS\BookingManager\StandardGUIRequest $book_request;
31
33 protected ilTabsGUI $tabs;
34 protected ilCtrl $ctrl;
35 protected ilLanguage $lng;
37 protected int $ref_id;
38 protected int $pool_id;
39
40 public function __construct(
41 ilObjBookingPoolGUI $a_parent_obj
42 ) {
43 global $DIC;
44
45 $this->tpl = $DIC["tpl"];
46 $this->tabs = $DIC->tabs();
47 $this->ctrl = $DIC->ctrl();
48 $this->lng = $DIC->language();
49 $this->access = $DIC->bookingManager()->internal()->domain()->access();
50 $this->toolbar = $DIC->toolbar();
51 $this->book_request = $DIC->bookingManager()
52 ->internal()
53 ->gui()
54 ->standardRequest();
55
56
57 $this->ref_id = $a_parent_obj->getRefId();
58 $this->pool_id = $a_parent_obj->getObject()->getId();
59
60 $this->lng->loadLanguageModule("book");
61 }
62
63 public function executeCommand(): void
64 {
65 $ilCtrl = $this->ctrl;
66
67 $next_class = $ilCtrl->getNextClass($this);
68
69 switch ($next_class) {
70 case 'ilrepositorysearchgui':
71 $rep_search = new ilRepositorySearchGUI();
73 $rep_search->addUserAccessFilterCallable(function ($a_user_id) {
74 return $this->access->filterManageableParticipants(
75 $this->ref_id,
76 $a_user_id
77 );
78 });
79 $rep_search->setTitle($this->lng->txt("exc_add_participant"));
80 $rep_search->setCallback($this, 'addParticipantObject');
81 $this->ctrl->setReturn($this, 'render');
82 $this->ctrl->forwardCommand($rep_search);
83 break;
84
85 default:
86 $cmd = $ilCtrl->getCmd("render");
87 $this->$cmd();
88 break;
89 }
90 }
91
96 public function render(): void
97 {
98 if ($this->access->canManageParticipants($this->ref_id)) {
100 $this,
101 $this->toolbar,
102 array(
103 'auto_complete_name' => $this->lng->txt('user'),
104 'submit_name' => $this->lng->txt('add'),
105 'add_search' => true,
106 'add_from_container' => $this->ref_id
107 )
108 );
109
110 $table = new ilBookingParticipantsTableGUI($this, 'render', $this->ref_id, $this->pool_id);
111
112 $this->tpl->setContent($table->getHTML());
113 }
114 }
115
116 public function addUserFromAutoCompleteObject(): bool
117 {
118 if (trim($this->book_request->getUserLogin()) === '') {
119 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('msg_no_search_string'));
120 $this->render();
121 return false;
122 }
123
124 $users = explode(',', $this->book_request->getUserLogin());
125
126 $user_ids = array();
127 foreach ($users as $user) {
129
130 if (!$user_id) {
131 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('user_not_known'));
132 $this->render();
133 }
134 $user_ids[] = $user_id;
135 }
136
137 return $this->addParticipantObject($user_ids);
138 }
139
145 public function addParticipantObject(
146 array $a_user_ids
147 ): bool {
148 foreach ($a_user_ids as $user_id) {
149 if (ilObject::_lookupType($user_id) === "usr") {
150 $participant_obj = new ilBookingParticipant($user_id, $this->pool_id);
151 if ($participant_obj->getIsNew()) {
152 $this->tpl->setOnScreenMessage('success', $this->lng->txt("book_participant_assigned"), true);
153 } else {
154 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("book_participant_already_assigned"), true);
155 }
156 } else {
157 $this->tpl->setOnScreenMessage('failure', "dummy error message, change me");
158 return false;
159 }
160 }
161
162 $this->ctrl->redirect($this, "render");
163 return true;
164 }
165
166 public function applyParticipantsFilter(): void
167 {
168 $this->applyFilterAction(self::FILTER_ACTION_APPLY);
169 }
170
171 public function resetParticipantsFilter(): void
172 {
173 $this->applyFilterAction(self::FILTER_ACTION_RESET);
174 }
175
176 protected function applyFilterAction(
177 int $a_filter_action
178 ): void {
179 $table = new ilBookingParticipantsTableGUI($this, 'render', $this->ref_id, $this->pool_id);
180 $table->resetOffset();
181 if ($a_filter_action === self::FILTER_ACTION_RESET) {
182 $table->resetFilter();
183 } else {
184 $table->writeFilterToSession();
185 }
186
187 $this->render();
188 }
189
190 public function assignObjects(): void
191 {
192 $this->tabs->clearTargets();
193 $this->tabs->setBackTarget($this->lng->txt('book_back_to_list'), $this->ctrl->getLinkTarget($this, 'render'));
194
195 $table = new ilBookingAssignObjectsTableGUI($this, 'assignObjects', $this->ref_id, $this->pool_id);
196
197 $this->tpl->setContent($table->getHTML());
198 }
199}
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...
addParticipantObject(array $a_user_ids)
Add new participant.
ILIAS BookingManager StandardGUIRequest $book_request
__construct(ilObjBookingPoolGUI $a_parent_obj)
render()
Render list of booking participants.
ILIAS BookingManager Access AccessManager $access
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 ilCtrl provides processing control methods.
getNextClass($a_gui_class=null)
@inheritDoc
language handling
@ilCtrl_Calls ilObjBookingPoolGUI: ilPermissionGUI, ilBookingObjectGUI @ilCtrl_Calls ilObjBookingPool...
static _lookupId(string|array $a_user_str)
static _lookupType(int $id, bool $reference=false)
static fillAutoCompleteToolbar(object $parent_object, ?ilToolbarGUI $toolbar=null, array $a_options=[], bool $a_sticky=false)
array( auto_complete_name = $lng->txt('user'), auto_complete_size = 15, user_type = array(ilCoursePar...
resetOffset(bool $a_in_determination=false)
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...
global $DIC
Definition: shib_login.php:26