ILIAS  release_8 Revision v8.24
class.ilLearningSequenceMembershipGUI.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
22
33{
35 protected ilObject $obj;
44
45 public function __construct(
53 ILIAS\HTTP\Wrapper\RequestWrapper $request_wrapper,
55 ILIAS\Refinery\Factory $refinery
56 ) {
58
59 $this->obj = $obj;
60 $this->obj_user_tracking = $obj_user_tracking;
61 $this->privacy_settings = $privacy_settings;
62 $this->rbac_review = $rbac_review;
63 $this->settings = $settings;
64 $this->toolbar = $toolbar;
65 $this->request_wrapper = $request_wrapper;
66 $this->post_wrapper = $post_wrapper;
67 $this->refinery = $refinery;
68 }
69
70 protected function printMembers(): void
71 {
72 $this->checkPermission('read');
73 if ($this->checkRbacOrPositionAccessBool('manage_members', 'manage_members')) {
74 $back_cmd = 'participants';
75 } else {
76 $back_cmd = 'jump2UsersGallery';
77 }
78
79 global $DIC;
80 $ilTabs = $DIC['ilTabs'];
81 $ilTabs->clearTargets();
82 $ilTabs->setBackTarget(
83 $this->lng->txt('back'),
84 $this->ctrl->getLinkTarget($this, $back_cmd)
85 );
86
87 $list = $this->initAttendanceList();
88 $form = $list->initForm('printMembersOutput');
89 $this->tpl->setContent($form->getHTML());
90 }
91
92 protected function getDefaultCommand(): string
93 {
94 $r = $this->refinery;
95 return $this->request_wrapper->retrieve("back_cmd", $r->byTrying([$r->kindlyTo()->string(), $r->always("members")]));
96 }
97
103 public function filterUserIdsByRbacOrPositionOfCurrentUser(array $a_user_ids): array
104 {
105 return $this->access->filterUserIdsByRbacOrPositionOfCurrentUser(
106 'manage_members',
107 'manage_members',
108 $this->getParentObject()->getRefId(),
109 $a_user_ids
110 );
111 }
112
116 public function assignMembers(array $user_ids, string $type): bool
117 {
118 $object = $this->getParentObject();
119 $members = $this->getParentObject()->getLSParticipants();
120
121 if (count($user_ids) == 0) {
122 $this->lng->loadLanguageModule('search');
123 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('search_err_user_not_exist'), true);
124 return false;
125 }
126
127 $assigned = false;
128 foreach ($user_ids as $new_member) {
129 $new_member = (int) $new_member;
130
131 if ($members->isAssigned($new_member)) {
132 continue;
133 }
134
135 switch ($type) {
136 case $object->getDefaultAdminRole():
137 $members->add($new_member, ilParticipants::IL_LSO_ADMIN);
138 $members->sendNotification(
140 $new_member
141 );
142 $assigned = true;
143 break;
144 case $object->getDefaultMemberRole():
145 $members->add($new_member, ilParticipants::IL_LSO_MEMBER);
146 $members->sendNotification(
148 $new_member
149 );
150 $assigned = true;
151 break;
152 default:
153 if (in_array($type, $object->getLocalLearningSequenceRoles(true))) {
154 $members->add($new_member, ilParticipants::IL_LSO_MEMBER);
155 $members->updateRoleAssignments($new_member, array($type));
156 } else {
157 ilLoggerFactory::getLogger('lso')->notice(
158 'Can not find role with id .' . $type . ' to assign users.'
159 );
160 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("lso_cannot_find_role"), true);
161 return false;
162 }
163
164 $members->sendNotification(
166 $new_member
167 );
168 $assigned = true;
169 break;
170 }
171 }
172
173 if ($assigned) {
174 $this->tpl->setOnScreenMessage('success', $this->lng->txt("lso_msg_member_assigned"), true);
175 } else {
176 $this->tpl->setOnScreenMessage('success', $this->lng->txt('lso_users_already_assigned'), true);
177 }
178
179 $this->ctrl->redirect($this, 'participants');
180 return $assigned;
181 }
182
186 protected function updateParticipantsStatus(): void
187 {
188 $members = $this->getParentObject()->getLSParticipants();
189
190 $participants = $this->post_wrapper->retrieve(
191 "visible_member_ids",
192 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())
193 );
194
195 $notification = [];
196 if ($this->post_wrapper->has('notification')) {
197 $notification = $this->post_wrapper->retrieve(
198 "notification",
199 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())
200 );
201 }
202
203 foreach ($participants as $participant) {
204 if ($members->isAdmin($participant)) {
205 $members->updateNotification($participant, in_array($participant, $notification));
206 continue;
207 }
208 $members->updateNotification($participant, false);
209 }
210
211 $this->tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true);
212 $this->ctrl->redirect($this, 'participants');
213 }
214
216 {
218 $this,
219 $this->getParentObject(),
220 $this->obj_user_tracking,
221 $this->privacy_settings,
222 $this->lng,
223 $this->access,
224 $this->rbac_review,
225 $this->settings
226 );
227 }
228
230 {
231 $obj = parent::getParentObject();
232 if (!$obj instanceof ilObjLearningSequence) {
233 throw new Exception('Invalid class type ' . get_class($obj) . ". Expected ilObjLearningSequence.");
234 }
235 return $obj;
236 }
237
239 {
241 $this,
242 $this->getParentObject(),
243 $this->getParentObject()->getLSParticipants(),
244 $this->privacy_settings
245 );
246
247 $table->setTitle($this->lng->txt($this->getParentObject()->getType() . '_header_edit_members'));
248 $table->setData($this->readMemberData($participants));
249
250 return $table;
251 }
252
256 protected function initParticipantTemplate(): void
257 {
258 $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.lso_edit_members.html', 'Modules/LearningSequence');
259 }
260
264 public function getLocalTypeRole(bool $translation = false): array
265 {
266 return $this->getParentObject()->getLocalLearningSequenceRoles($translation);
267 }
268
274 public function readMemberData(array $usr_ids, array $columns = null): array
275 {
276 return $this->getParentObject()->readMemberData($usr_ids, $columns);
277 }
278
279
281 {
283 }
284
285 protected function getDefaultRole(): ?int
286 {
287 return $this->getParentObject()->getDefaultMemberRole();
288 }
289
293 public function getPrintMemberData(array $members): array
294 {
295 $member_data = $this->readMemberData($members, array());
296
297 return $this->getParentGUI()->addCustomData($member_data);
298 }
299
303 public function getAttendanceListUserData(int $user_id, array $filters = []): array
304 {
305 $data = array();
306
307 if ($this->filterUserIdsByRbacOrPositionOfCurrentUser([$user_id])) {
308 $data = $this->member_data[$user_id];
309 if (array_key_exists('access_time', $data)) {
310 $data['access'] = $data['access_time'];
311 }
312 $data['progress'] = $this->lng->txt($data['progress']);
313 }
314
315 return $data;
316 }
317
319 {
321 }
322
323 protected function setSubTabs(ilTabsGUI $tabs): void
324 {
326 'manage_members',
327 'manage_members',
328 $this->getParentObject()->getRefId()
329 );
330
331 if ($access) {
333 $this->getParentObject()->getType() . "_member_administration",
334 $this->ctrl->getLinkTarget($this, 'participants'),
335 "members",
336 get_class($this)
337 );
338
340 $this->getParentObject()->getType() . '_members_gallery',
341 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilUsersGalleryGUI')),
342 'view',
343 'ilUsersGalleryGUI'
344 );
345 } elseif ($this->getParentObject()->getShowMembers()) {
347 $this->getParentObject()->getType() . '_members_gallery',
348 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilUsersGalleryGUI')),
349 'view',
350 'ilUsersGalleryGUI'
351 );
352 }
353 }
354
355 protected function showParticipantsToolbar(): void
356 {
357 $toolbar_entries = [
358 'auto_complete_name' => $this->lng->txt('user'),
359 'user_type' => $this->getParentGUI()->getLocalRoles(),
360 'user_type_default' => $this->getDefaultRole(),
361 'submit_name' => $this->lng->txt('add'),
362 'add_search' => true
363 ];
364
365 $search_params = ['crs', 'grp'];
366 $parent_container = $this->obj->getParentObjectInfo(
367 $this->obj->getRefId(),
368 $search_params
369 );
370 if (!is_null($parent_container)) {
371 $container_id = $parent_container['ref_id'];
372 $toolbar_entries['add_from_container'] = $container_id;
373 }
374
376 $this,
377 $this->toolbar,
378 $toolbar_entries
379 );
380
381 $this->toolbar->addSeparator();
382
383 $this->toolbar->addButton(
384 $this->lng->txt($this->getParentObject()->getType() . "_print_list"),
385 $this->ctrl->getLinkTarget($this, 'printMembers')
386 );
387
388 $this->showMailToMemberToolbarButton($this->toolbar, 'participants');
389 }
390}
Builds data types.
Definition: Factory.php:21
return true
Class ilAbstractMailMemberRoles.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
GUI class for learning sequence membership features.
filterUserIdsByRbacOrPositionOfCurrentUser(array $a_user_ids)
Filter user ids by access.
readMemberData(array $usr_ids, array $columns=null)
initParticipantTemplate()
Init participant view template.
getAttendanceListUserData(int $user_id, array $filters=[])
__construct(ilObjectGUI $repository_gui, ilObject $obj, ilObjUserTracking $obj_user_tracking, ilPrivacySettings $privacy_settings, ilRbacReview $rbac_review, ilSetting $settings, ilToolbarGUI $toolbar, ILIAS\HTTP\Wrapper\RequestWrapper $request_wrapper, ArrayBasedRequestWrapper $post_wrapper, ILIAS\Refinery\Factory $refinery)
ILIAS HTTP Wrapper RequestWrapper $request_wrapper
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getLogger(string $a_component_id)
Get component logger.
Base class for member tab content.
checkPermission(string $a_permission, string $a_cmd="")
Check permission If not granted redirect to parent gui.
ilParticipants $participants
initAttendanceList(bool $a_for_members=false)
checkRbacOrPositionAccessBool(string $a_rbac_perm, string $a_pos_perm, int $a_ref_id=0)
showMailToMemberToolbarButton(ilToolbarGUI $toolbar, ?string $a_back_cmd=null, bool $a_separator=false)
Show mail to member toolbar button.
ilAccessHandler $access
Class ilObjectGUI Basic methods of all Output classes.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
updateNotification(int $a_usr_id, bool $a_notification)
Update notification status.
Singleton class that stores all privacy settings.
class ilRbacReview Contains Review functions of core Rbac.
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...
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...
global $DIC
Definition: feed.php:28
Interface RequestWrapper.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Class ChatMainBarProvider \MainMenu\Provider.
$type