ILIAS  release_8 Revision v8.24
class.ilObjStudyProgrammeMembersGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
23
34{
35 use ilTableCommandHelper;
36
37 private const DEFAULT_CMD = "view";
38
39 public const ACTION_MARK_ACCREDITED = "mark_accredited";
40 public const ACTION_UNMARK_ACCREDITED = "unmark_accredited";
41 public const ACTION_SHOW_INDIVIDUAL_PLAN = "show_individual_plan";
42 public const ACTION_REMOVE_USER = "remove_user";
43 public const ACTION_CHANGE_DEADLINE = "change_deadline";
44 public const ACTION_MARK_RELEVANT = "mark_relevant";
45 public const ACTION_UNMARK_RELEVANT = "unmark_relevant";
46 public const ACTION_UPDATE_FROM_CURRENT_PLAN = "update_from_current_plan";
47 public const ACTION_CHANGE_EXPIRE_DATE = "change_expire_date";
48 public const ACTION_ACKNOWLEDGE_COURSES = "acknowledge_completed_courses";
49
50 public const F_COMMAND_OPTION_ALL = 'select_cmd_all';
51 public const F_ALL_PROGRESS_IDS = 'all_progress_ids';
52 public const F_SELECTED_PROGRESS_IDS = 'prgs_ids';
53 public const F_SELECTED_PROGRESS_ID = 'prgs_id';
54 public const F_SELECTED_USER_IDS = 'usrids';
55
57 protected ilCtrl $ctrl;
59 protected ilLanguage $lng;
60 protected ilObjUser $user;
61 protected ilTabsGUI $tabs;
72 protected GuzzleHttp\Psr7\ServerRequest $request;
76 protected int $ref_id;
77
78 public function __construct(
80 ilCtrl $ilCtrl,
81 ilToolbarGUI $ilToolbar,
91 ILIAS\HTTP\Wrapper\WrapperFactory $http_wrapper,
92 ILIAS\Refinery\Factory $refinery,
94 ILIAS\UI\Renderer $ui_renderer,
95 GuzzleHttp\Psr7\ServerRequest $request
96 ) {
97 $this->tpl = $tpl;
98 $this->ctrl = $ilCtrl;
99 $this->toolbar = $ilToolbar;
100 $this->lng = $lng;
101 $this->user = $user;
102 $this->tabs = $tabs;
103 $this->assignment_db = $assignment_db;
104 $this->repository_search_gui = $repository_search_gui;
105 $this->individual_plan_gui = $individual_plan_gui;
106 $this->messages = $messages;
107 $this->data_factory = $data_factory;
108 $this->confirmation_gui = $confirmation_gui;
109 $this->http_wrapper = $http_wrapper;
110 $this->refinery = $refinery;
111 $this->ui_factory = $ui_factory;
112 $this->ui_renderer = $ui_renderer;
113 $this->request = $request;
114 $this->object = null;
115 $this->permissions = null;
116
117 $lng->loadLanguageModule("prg");
118 $this->toolbar->setPreventDoubleSubmission(true);
119 }
120
121 public function setParentGUI(ilObjectGUI $a_parent_gui): void
122 {
123 $this->parent_gui = $a_parent_gui;
124 }
125
126 public function setRefId(int $ref_id): void
127 {
128 $this->ref_id = $ref_id;
129 $this->object = ilObjStudyProgramme::getInstanceByRefId($ref_id);
130 $this->permissions = ilStudyProgrammeDIC::specificDicFor($this->object)['permissionhelper'];
131 }
132
133 public function executeCommand(): void
134 {
135 $cmd = $this->ctrl->getCmd();
136 $next_class = $this->ctrl->getNextClass($this);
137
138 if ($cmd === "" || $cmd === null) {
139 $cmd = $this->getDefaultCommand();
140 }
141
142 switch ($next_class) {
143 case "ilstudyprogrammerepositorysearchgui":
144 $this->repository_search_gui->setCallback($this, "addUsers");
145 $this->ctrl->setReturn($this, "view");
146 $this->ctrl->forwardCommand($this->repository_search_gui);
147 break;
148 case "ilobjstudyprogrammeindividualplangui":
149 $this->individual_plan_gui->setParentGUI($this);
150 $this->individual_plan_gui->setRefId($this->ref_id);
151 $this->ctrl->forwardCommand($this->individual_plan_gui);
152 break;
153 case "ilstudyprogrammemailmembersearchgui":
154 $this->tabs->clearTargets();
155 $this->tabs->setBackTarget(
156 $this->lng->txt('btn_back'),
157 $this->ctrl->getLinkTarget($this, $this->getDefaultCommand())
158 );
160 $mail_search = $dic['ilStudyProgrammeMailMemberSearchGUI'];
161 $mail_search->setAssignments($this->getAssignmentsById());
162 $mail_search->setBackTarget(
163 $this->ctrl->getLinkTarget($this, $this->getDefaultCommand())
164 );
165 $this->ctrl->forwardCommand($mail_search);
166 break;
167 case "ilstudyprogrammechangeexpiredategui":
168 $this->tabs->clearTargets();
169 $this->tabs->setBackTarget(
170 $this->lng->txt('btn_back'),
171 $this->ctrl->getLinkTarget($this, $this->getDefaultCommand())
172 );
174 $gui = $dic['ilStudyProgrammeChangeExpireDateGUI'];
175 $gui->setRefId($this->ref_id);
176 $gui->setProgressIds($this->getGetPrgsIds());
177 $this->ctrl->forwardCommand($gui);
178 break;
179 case "ilstudyprogrammechangedeadlinegui":
180 $this->tabs->clearTargets();
181 $this->tabs->setBackTarget(
182 $this->lng->txt('btn_back'),
183 $this->ctrl->getLinkTarget($this, $this->getDefaultCommand())
184 );
186 $gui = $dic['ilStudyProgrammeChangeDeadlineGUI'];
187 $gui->setRefId($this->ref_id);
188 $gui->setProgressIds($this->getGetPrgsIds());
189 $this->ctrl->forwardCommand($gui);
190 break;
191 case false:
192 switch ($cmd) {
193 case "view":
194 case "markAccredited":
195 case "markAccreditedMulti":
196 case "unmarkAccredited":
197 case "unmarkAccreditedMulti":
198 case "removeUser":
199 case "removeUserMulti":
200 case "markNotRelevantMulti":
201 case "markRelevant":
202 case "markRelevantMulti":
203 case "updateFromCurrentPlan":
204 case "updateFromCurrentPlanMulti":
205 case "acknowledgeCourses":
206 case "acknowledgeCoursesMulti":
207 case "applyFilter":
208 case "resetFilter":
209 case "changeDeadline":
210 case "changeDeadlineMulti":
211 case "changeExpireDate":
212 case "changeExpireDateMulti":
213 $cont = $this->$cmd();
214 $this->tpl->setContent($cont);
215 break;
216 case "confirmedRemoveUsers":
217 $this->confirmedRemoveUsers();
218 break;
219 case "confirmedUpdateFromCurrentPlan":
221 break;
222 case "confirmedAcknowledgeCourses":
224 break;
225 case "confirmedAcknowledgeAllCourses":
227 break;
228
229 case "mailUserMulti":
230 $this->mailToSelectedUsers();
231 break;
232 case "markNotRelevant":
233 $this->markRelevant();
234 break;
235
236 default:
237 throw new ilException("ilObjStudyProgrammeMembersGUI: Command not supported: $cmd");
238 }
239 break;
240 default:
241 throw new ilException(
242 "ilObjStudyProgrammeMembersGUI: Can't forward to next class $next_class"
243 );
244 }
245 }
246
247 protected function getDefaultCommand(): string
248 {
249 return self::DEFAULT_CMD;
250 }
251
252 protected function getAssignmentsById(): array
253 {
254 return $this->assignment_db->getAllForNodeIsContained($this->object->getId());
255 }
256
258 {
259 $prg_id = ilObject::_lookupObjId($this->ref_id);
262 $prg_id,
263 $this->ref_id,
264 $this,
265 $this->permissions,
266 $this->data_factory,
267 $dic['ui.factory'],
268 $dic['ui.renderer'],
269 $dic['ilStudyProgrammeUserTable'],
270 $dic['filter.assignment'],
271 $this->user,
272 "view",
273 ""
274 );
275 return $table;
276 }
277
281 protected function getPostPrgsIds(): array
282 {
283 if ($this->http_wrapper->post()->has(self::F_COMMAND_OPTION_ALL)) {
284 $pgs_ids = $this->http_wrapper->post()->retrieve(
285 self::F_ALL_PROGRESS_IDS,
286 $this->refinery->custom()->transformation(
287 fn ($ids) => explode(',', $ids)
288 )
289 );
290 } else {
291 $pgs_ids = $this->http_wrapper->post()->retrieve(
292 self::F_SELECTED_PROGRESS_IDS,
293 $this->refinery->custom()->transformation(fn ($ids) => $ids)
294 );
295 }
296 if ($pgs_ids === null) {
297 $this->showInfoMessage("no_user_selected");
298 $this->ctrl->redirect($this, "view");
299 }
300 if (is_string($pgs_ids)) {
301 $pgs_ids = [$pgs_ids];
302 }
303
304 $r = [];
305 foreach ($pgs_ids as $pgs_id) {
306 $r[] = PRGProgressId::createFromString($pgs_id);
307 }
308 return $r;
309 }
310
311 protected function getGetPrgsIds(): array
312 {
313 $prgrs_ids = $_GET['prgrs_ids'];
314 $ids = [];
315 if (!is_null($prgrs_ids)) {
316 foreach (explode(',', $prgrs_ids) as $id) {
318 };
319 }
320 return $ids;
321 }
322
323 protected function getPrgrsId(): PRGProgressId
324 {
325 if (!$_GET["prgrs_id"]) {
326 throw new ilException("Expected 'prgrs_id'");
327 }
328 return PRGProgressId::createFromString($_GET["prgrs_id"]);
329 }
330
334 protected function view(): string
335 {
336 if ($this->getStudyProgramme()->isActive() && $this->permissions->may(ilOrgUnitOperation::OP_MANAGE_MEMBERS)) {
337 $this->initSearchGUI();
338 $this->initMailToMemberButton($this->toolbar, true);
339 }
340
341 if (!$this->getStudyProgramme()->isActive()) {
342 $this->tpl->setOnScreenMessage("info", $this->lng->txt("prg_no_members_not_active"));
343 }
344 $table = $this->getMembersTableGUI();
345 return $table->getHTML();
346 }
347
348 public function applyFilter(): void
349 {
350 $table = $this->getMembersTableGUI();
351 $table->resetOffset();
352 $table->writeFilterToSession();
353 $this->ctrl->redirect($this, "view");
354 }
355
356 public function resetFilter(): void
357 {
358 $table = $this->getMembersTableGUI();
359 $table->resetOffset();
360 $table->resetFilter();
361 $this->ctrl->redirect($this, "view");
362 }
363
369 public function addUsers(array $user_ids)
370 {
371 $user_ids = $this->getAddableUsers($user_ids);
372 $prg = $this->getStudyProgramme();
373 $assignments = [];
374 $with_courses = [];
375
376 foreach ($user_ids as $user_id) {
377 $ass = $prg->assignUser((int) $user_id);
378 $assignments[] = $ass;
379 if($prg->getCompletedCourses((int) $user_id)) {
380 $with_courses[] = $ass;
381 }
382 }
383
384 if (count($assignments) === 1) {
385 $this->tpl->setOnScreenMessage("success", $this->lng->txt("prg_added_member"), true);
386 }
387 if (count($assignments) > 1) {
388 $this->tpl->setOnScreenMessage("success", $this->lng->txt("prg_added_members"), true);
389 }
390
391 if($with_courses) {
392 $this->tpl->setContent(
393 $this->ui_renderer->render(
394 $this->viewCompletedCourses($assignments)
395 )
396 );
397 return true;
398
399 } else {
400 $this->ctrl->redirect($this, "view");
401 }
402 }
403
407 public function viewCompletedCourses(array $assignments): Form
408 {
409 $prg = $this->getStudyProgramme();
410 $completed_courses = [];
411 $ass_ids = [];
412 foreach ($assignments as $ass) {
413 $ass_ids[] = $ass->getId();
414 $completed_crss = $prg->getCompletedCourses($ass->getUserId());
415
416 $label = sprintf(
417 "%s (%s)",
418 $ass->getUserInformation()->getFullname(),
419 $ass->getId()
420 );
421 $options = [];
422 foreach($completed_crss as $opt) {
423 $options[implode(';', [$ass->getId(), $opt['prg_obj_id'],$opt['crs_id']])] = $opt['title'];
424 }
425
426 $completed_courses[] = $this->ui_factory->input()->field()->multiselect($label, $options);
427 }
428
429 $form_action = $this->ctrl->getFormAction($this, 'confirmedAcknowledgeCourses')
430 . '&ass_ids=' . implode(',', $ass_ids);
431
432 $form = $this->ui_factory->input()->container()->form()->standard(
433 $form_action,
434 [
435 $this->ui_factory->input()->field()->section(
436 $completed_courses,
437 $this->lng->txt("prg_acknowledge_completed_courses")
438 )
439 ]
440 )->withAdditionalTransformation(
441 $this->refinery->custom()->transformation(
442 function ($values) {
443 $values = array_merge(...array_filter(array_shift($values)));
444 return array_map(
445 fn ($entry) => explode(';', $entry),
446 $values
447 );
448 }
449 )
450 );
451
452 $this->toolbar->addComponent(
453 $this->ui_factory->link()->standard(
454 $this->lng->txt('prg_cancel_acknowledge_completed_courses'),
455 $this->ctrl->getLinkTarget($this, self::DEFAULT_CMD)
456 )
457 );
458 $this->toolbar->addComponent(
459 $this->ui_factory->link()->standard(
460 $this->lng->txt('prg_acknowledge_all_completed_courses'),
461 $this->ctrl->getLinkTarget($this, 'confirmedAcknowledgeAllCourses')
462 . '&ass_ids=' . implode(',', $ass_ids)
463 )
464 );
465
466 return $form;
467 }
468
472 protected function getAddableUsers(array $users): array
473 {
474 $to_add = $this->permissions->filterUserIds(
475 $users,
477 );
478
479 $cnt_not_added = count($users) - count($to_add);
480 if ($cnt_not_added > 0) {
481 $this->tpl->setOnScreenMessage(
482 "info",
483 sprintf(
484 $this->lng->txt('could_not_add_users_no_permissons'),
485 $cnt_not_added
486 ),
487 true
488 );
489 }
490 return $to_add;
491 }
492
493 protected function markAccredited(): void
494 {
495 $prgrs_id = $this->getPrgrsId();
496 $msgs = $this->getMessageCollection('msg_mark_accredited');
497 $this->markAccreditedByProgressId($prgrs_id, $msgs);
498 $this->showMessages($msgs);
499 $this->ctrl->redirect($this, "view");
500 }
501
502 protected function markAccreditedMulti(): void
503 {
504 $prgrs_ids = $this->getPostPrgsIds();
505 $msgs = $this->getMessageCollection('msg_mark_accredited');
506 foreach ($prgrs_ids as $key => $prgrs_id) {
507 $this->markAccreditedByProgressId($prgrs_id, $msgs);
508 }
509 $this->showMessages($msgs);
510 $this->ctrl->redirect($this, "view");
511 }
512
513 protected function markAccreditedByProgressId(PRGProgressId $prgrs_id, ilPRGMessageCollection $msgs): void
514 {
515 $usr_id = $prgrs_id->getUsrId();
516 if (!$this->mayCurrentUserEditProgressForUser($usr_id)) {
517 $msgs->add(false, 'No permission to edit progress of user', (string) $prgrs_id);
518 } else {
519 $programme = $this->getStudyProgramme();
520 $programme->markAccredited($prgrs_id->getAssignmentId(), $this->user->getId(), $msgs);
521 }
522 }
523
524 protected function unmarkAccredited(): void
525 {
526 $prgrs_id = $this->getPrgrsId();
527 $msgs = $this->getMessageCollection('msg_unmark_accredited');
528 $this->unmarkAccreditedByProgressId($prgrs_id, $msgs);
529 $this->showMessages($msgs);
530 $this->ctrl->redirect($this, "view");
531 }
532
533 public function unmarkAccreditedMulti(): void
534 {
535 $prgrs_ids = $this->getPostPrgsIds();
536 $msgs = $this->getMessageCollection('msg_unmark_accredited');
537 foreach ($prgrs_ids as $key => $prgrs_id) {
538 $this->unmarkAccreditedByProgressId($prgrs_id, $msgs);
539 }
540 $this->showMessages($msgs);
541 $this->ctrl->redirect($this, "view");
542 }
543
544 protected function unmarkAccreditedByProgressId(PRGProgressId $prgrs_id, ilPRGMessageCollection $msgs): void
545 {
546 $usr_id = $prgrs_id->getUsrId();
547 if (!$this->mayCurrentUserEditProgressForUser($usr_id)) {
548 $msgs->add(false, 'No permission to edit progress of user', (string) $prgrs_id);
549 } else {
550 $programme = $this->getStudyProgramme();
551 $programme->unmarkAccredited($prgrs_id->getAssignmentId(), $this->user->getId(), $msgs);
552 }
553 }
554
555 public function markRelevant(): void
556 {
557 $prgrs_id = $this->getPrgrsId();
558 $msgs = $this->getMessageCollection('msg_mark_relevant');
559 $programme = $this->getStudyProgramme();
560 if (!$this->mayCurrentUserEditProgressForUser($prgrs_id->getUsrId())) {
561 $msgs->add(false, "No permission to edit progress of user", (string) $prgrs_id);
562 } else {
563 $programme->markRelevant($prgrs_id->getAssignmentId(), $this->user->getId(), $msgs);
564 }
565 $this->showMessages($msgs);
566 $this->ctrl->redirect($this, "view");
567 }
568
569 public function markRelevantMulti(): void
570 {
571 $prgrs_ids = $this->getPostPrgsIds();
572 $msgs = $this->getMessageCollection('msg_mark_relevant');
573 $programme = $this->getStudyProgramme();
574 foreach ($prgrs_ids as $key => $prgrs_id) {
575 if (!$this->mayCurrentUserEditProgressForUser($prgrs_id->getUsrId())) {
576 $msgs->add(false, 'No permission to edit progress of user', (string) $prgrs_id);
577 } else {
578 $programme->markRelevant($prgrs_id->getAssignmentId(), $this->user->getId(), $msgs);
579 }
580 }
581 $this->showMessages($msgs);
582 $this->ctrl->redirect($this, "view");
583 }
584
585 public function markNotRelevant(): void
586 {
587 $prgrs_id = $this->getPrgrsId();
588 $msgs = $this->getMessageCollection('msg_mark_not_relevant');
589 $programme = $this->getStudyProgramme();
590 if (!$this->mayCurrentUserEditProgressForUser($prgrs_id->getUsrId())) {
591 $msgs->add(false, 'No permission to edit progress of user', (string) $prgrs_id);
592 } else {
593 $programme->markNotRelevant($prgrs_id->getAssignmentId(), $this->user->getId(), $msgs);
594 }
595 $this->showMessages($msgs);
596 $this->ctrl->redirect($this, "view");
597 }
598
599 public function markNotRelevantMulti(): void
600 {
601 $prgrs_ids = $this->getPostPrgsIds();
602 $msgs = $this->getMessageCollection('msg_mark_not_relevant');
603 $programme = $this->getStudyProgramme();
604 foreach ($prgrs_ids as $key => $prgrs_id) {
605 if (!$this->mayCurrentUserEditProgressForUser($prgrs_id->getUsrId())) {
606 $msgs->add(false, 'No permission to edit progress of user', (string) $prgrs_id);
607 } else {
608 $programme->markNotRelevant($prgrs_id->getAssignmentId(), $this->user->getId(), $msgs);
609 }
610 }
611 $this->showMessages($msgs);
612 $this->ctrl->redirect($this, "view");
613 }
614
615 public function updateFromCurrentPlan(): string
616 {
617 $this->confirmation_gui->setFormAction($this->ctrl->getFormAction($this, 'confirmUpdateFromCurrentPlan'));
618 $this->confirmation_gui->setHeaderText($this->lng->txt('header_update_current_plan'));
619 $this->confirmation_gui->setConfirm($this->lng->txt('confirm'), 'confirmedUpdateFromCurrentPlan');
620 $this->confirmation_gui->setCancel($this->lng->txt('cancel'), 'view');
621
622 $prgs_id = $this->getPrgrsId();
623 $user_name = ilObjUser::_lookupFullname($prgs_id->getUsrId());
624 $this->confirmation_gui->addItem(
625 self::F_SELECTED_PROGRESS_ID,
626 (string) $prgs_id,
627 $user_name
628 );
629 return $this->confirmation_gui->getHTML();
630 }
631
632 public function updateFromCurrentPlanMulti(): string
633 {
634 $this->confirmation_gui->setFormAction($this->ctrl->getFormAction($this, 'confirmUpdateFromCurrentPlan'));
635 $this->confirmation_gui->setHeaderText($this->lng->txt('header_update_current_plan'));
636 $this->confirmation_gui->setConfirm($this->lng->txt('confirm'), 'confirmedUpdateFromCurrentPlan');
637 $this->confirmation_gui->setCancel($this->lng->txt('cancel'), 'view');
638
639 foreach ($this->getPostPrgsIds() as $progress_id) {
640 $user_name = ilObjUser::_lookupFullname($progress_id->getUsrId());
641 $this->confirmation_gui->addItem(
642 self::F_SELECTED_PROGRESS_IDS . '[]',
643 (string) $progress_id,
644 $user_name
645 );
646 }
647 return $this->confirmation_gui->getHTML();
648 }
649
651 {
652 $pgs_ids = $this->getPostPrgsIds();
653 $msgs = $this->getMessageCollection('msg_update_from_settings');
654 foreach ($pgs_ids as $idx => $pgs_id) {
655 if (!$this->mayCurrentUserEditProgressForUser($pgs_id->getUsrId())) {
656 $msgs->add(false, 'no_permission_to_update_plan_of_user', (string) $pgs_id);
657 continue;
658 } else {
659 $msgs->add(true, '', (string) $pgs_id);
660 }
661
662 $this->object->updatePlanFromRepository(
663 $pgs_id->getAssignmentId(),
664 $this->user->getId(),
665 $msgs
666 );
667 }
668 $this->showMessages($msgs);
669 $this->ctrl->redirect($this, "view");
670 }
671
672 public function acknowledgeCourses(): string
673 {
674 $progress_id = $this->getPrgrsId();
675 $assignments = [
676 $this->assignment_db->get($progress_id->getAssignmentId())
677 ];
678 return $this->ui_renderer->render(
679 $this->viewCompletedCourses($assignments)
680 );
681 }
682
683 public function acknowledgeCoursesMulti(): string
684 {
685 $assignments = [];
686 foreach ($this->getPostPrgsIds() as $progress_id) {
687 $assignments[] = $this->assignment_db->get($progress_id->getAssignmentId());
688 }
689 return $this->ui_renderer->render(
690 $this->viewCompletedCourses($assignments)
691 );
692 }
693
697 protected function getAssignmentsFromQuery(): array
698 {
699 $ass_ids = $this->http_wrapper->query()->retrieve(
700 'ass_ids',
701 $this->refinery->custom()->transformation(fn ($ids) => explode(',', $ids))
702 );
703 $prg = $this->getStudyProgramme();
704 $assignments = array_map(
705 fn ($ass_id) => $this->assignment_db->get((int) $ass_id),
706 $ass_ids
707 );
708
709 $assignments = array_filter(
710 $assignments,
711 fn ($ass) => $ass->getRootId() === $prg->getId()
712 );
713 return $assignments;
714 }
715
717 {
718 $prg = $this->getStudyProgramme();
719 $assignments = $this->getAssignmentsFromQuery();
720 $msgs = $this->getMessageCollection('msg_acknowledge_courses');
721
722 foreach ($assignments as $ass) {
723 $ass_ids[] = $ass->getId();
724 $completed_crss = $prg->getCompletedCourses($ass->getUserId());
725 $nodes = [];
726 foreach($completed_crss as $opt) {
727 $nodes[] = [$opt['prg_obj_id'], $opt['crsr_id']];
728 }
729 $prg->acknowledgeCourses(
730 $ass->getId(),
731 $nodes,
732 $msgs
733 );
734 }
735 $this->showMessages($msgs);
736 $this->ctrl->redirect($this, "view");
737 }
738
740 {
741 $assignments = $this->getAssignmentsFromQuery();
742
743 $form = $this->viewCompletedCourses($assignments)->withRequest($this->request);
744 $data = $form->getData();
745
746 $msgs = $this->getMessageCollection('msg_acknowledge_courses');
747
748 if($data) {
749 $acknowledge = [];
750 foreach ($data as $ack) {
751 [$assignment_id, $node_obj_id, $course_obj_id] = $ack;
752 if(! array_key_exists($assignment_id, $acknowledge)) {
753 $acknowledge[$assignment_id] = [];
754 }
755 $acknowledge[$assignment_id][] = [(int) $node_obj_id, (int) $course_obj_id];
756 }
757 foreach ($acknowledge as $ass_id => $nodes) {
758 $this->object->acknowledgeCourses(
759 (int) $ass_id,
760 $nodes,
761 $msgs
762 );
763 }
764 $this->showMessages($msgs);
765 }
766 $this->ctrl->redirect($this, "view");
767 }
768
769 public function changeDeadline(): void
770 {
771 $this->ctrl->setParameterByClass(
772 'ilStudyProgrammeChangeDeadlineGUI',
773 'prgrs_ids',
774 $this->getPrgrsId()
775 );
776
777 $link = $this->ctrl->getLinkTargetByClass(
778 'ilStudyProgrammeChangeDeadlineGUI',
779 'showDeadlineConfig'
780 );
781
782 $this->ctrl->clearParameterByClass('ilStudyProgrammeChangeDeadlineGUI', 'prgrs_ids');
783 $this->ctrl->redirectToURL($link);
784 }
785
786 public function changeDeadlineMulti(): void
787 {
788 $this->ctrl->setParameterByClass(
789 'ilStudyProgrammeChangeDeadlineGUI',
790 'prgrs_ids',
791 implode(',', $this->getPostPrgsIds())
792 );
793
794 $link = $this->ctrl->getLinkTargetByClass(
795 'ilStudyProgrammeChangeDeadlineGUI',
796 'showDeadlineConfig'
797 );
798
799 $this->ctrl->clearParameterByClass('ilStudyProgrammeChangeDeadlineGUI', 'prgrs_ids');
800 $this->ctrl->redirectToURL($link);
801 }
802
803 public function changeExpireDate(): void
804 {
805 $this->ctrl->setParameterByClass(
806 'ilStudyProgrammeChangeExpireDateGUI',
807 'prgrs_ids',
808 $this->getPrgrsId()
809 );
810
811 $link = $this->ctrl->getLinkTargetByClass(
812 'ilStudyProgrammeChangeExpireDateGUI',
813 'showExpireDateConfig'
814 );
815
816 $this->ctrl->clearParameterByClass('ilStudyProgrammeChangeExpireDateGUI', 'prgrs_ids');
817 $this->ctrl->redirectToURL($link);
818 }
819
820 public function changeExpireDateMulti(): void
821 {
822 $this->ctrl->setParameterByClass(
823 'ilStudyProgrammeChangeExpireDateGUI',
824 'prgrs_ids',
825 implode(',', $this->getPostPrgsIds())
826 );
827
828 $link = $this->ctrl->getLinkTargetByClass(
829 'ilStudyProgrammeChangeExpireDateGUI',
830 'showExpireDateConfig'
831 );
832
833 $this->ctrl->clearParameterByClass('ilStudyProgrammeChangeExpireDateGUI', 'prgrs_ids');
834 $this->ctrl->redirectToURL($link);
835 }
836
837 public function removeUser(): string
838 {
839 $prgrs_id = $this->getPrgrsId();
840 return $this->confirmRemoveUsers([$prgrs_id]);
841 }
842
843 protected function removeUserMulti(): string
844 {
845 $pgs_ids = $this->getPostPrgsIds();
846 return $this->confirmRemoveUsers($pgs_ids);
847 }
848
849 protected function confirmRemoveUsers(array $progress_ids): string
850 {
851 $this->confirmation_gui->setFormAction($this->ctrl->getFormAction($this));
852 $this->confirmation_gui->setHeaderText($this->lng->txt('confirm_to_remove_selected_assignments'));
853 $this->confirmation_gui->setConfirm($this->lng->txt('prg_remove_user'), 'confirmedRemoveUsers');
854 $this->confirmation_gui->setCancel($this->lng->txt('cancel'), 'view');
855
856 foreach ($progress_ids as $progress_id) {
857 $user_name = ilObjUser::_lookupFullname($progress_id->getUsrId());
858 $this->confirmation_gui->addItem(
859 self::F_SELECTED_PROGRESS_IDS . '[]',
860 (string) $progress_id,
861 $user_name
862 );
863 }
864 return $this->confirmation_gui->getHTML();
865 }
866
867 protected function confirmedRemoveUsers(): void
868 {
869 $pgs_ids = $this->getPostPrgsIds();
870 $not_removed = array();
871 foreach ($pgs_ids as $idx => $pgs_id) {
872 try {
873 $this->removeAssignment($pgs_id);
874 } catch (ilException $e) {
875 $not_removed[] = $pgs_id;
876 }
877 }
878 if (count($not_removed) === count($pgs_ids)) {
879 $this->showInfoMessage("remove_users_not_possible");
880 } elseif (count($not_removed) > 0) {
881 $this->showSuccessMessage("remove_users_partial_success");
882 } else {
883 $this->showSuccessMessage("remove_users_success");
884 }
885 $this->ctrl->redirect($this, "view");
886 }
887
891 protected function removeAssignment(PRGProgressId $pgs_id): void
892 {
893 if (!in_array(
894 $pgs_id->getUsrId(),
895 $this->permissions->getUserIdsSusceptibleTo(ilOrgUnitOperation::OP_MANAGE_MEMBERS)
896 )) {
898 'No permission to manage membership of user'
899 );
900 }
901
902 $ass = $this->assignment_db->get($pgs_id->getAssignmentId());
903 $prg_ref_id = ilObjStudyProgramme::getRefIdFor($ass->getRootId());
904 if ($prg_ref_id !== $this->ref_id) {
905 throw new ilException("Can only remove users from the node they where assigned to.");
906 }
907 $prg = ilObjStudyProgramme::getInstanceByRefId($prg_ref_id);
908 $prg->removeAssignment($ass);
909 }
910
914 protected function showSuccessMessage(string $lng_var): void
915 {
916 $this->tpl->setOnScreenMessage("success", $this->lng->txt("prg_$lng_var"), true);
917 }
918
922 protected function showInfoMessage(string $lng_var): void
923 {
924 $this->tpl->setOnScreenMessage("info", $this->lng->txt("prg_$lng_var"), true);
925 }
926
927 protected function initSearchGUI(): void
928 {
930 $this,
931 $this->toolbar,
932 array(
933 "auto_complete_name" => $this->lng->txt("user"),
934 "submit_name" => $this->lng->txt("add"),
935 "add_search" => true
936 )
937 );
938 }
939
940 protected function initMailToMemberButton(ilToolbarGUI $toolbar, bool $separator = false): void
941 {
942 if ($separator) {
944 }
945
947 $this->lng->txt('mail_assignments'),
948 $this->ctrl->getLinkTargetByClass(
949 'ilStudyProgrammeMailMemberSearchGUI',
950 'showSelectableUsers'
951 )
952 );
953 }
954
959 public function getStudyProgramme(int $ref_id = null): ilObjStudyProgramme
960 {
961 if ($ref_id === null) {
963 }
965 }
966
970 public function getLinkTargetForAction(string $action, string $prgrs_id, int $ass_id): string
971 {
972 switch ($action) {
974 $target_name = "markAccredited";
975 break;
977 $target_name = "unmarkAccredited";
978 break;
980 return $this->individual_plan_gui->getLinkTargetView($ass_id);
982 $target_name = "removeUser";
983 break;
985 $target_name = "markNotRelevant";
986 break;
988 $target_name = "markRelevant";
989 break;
991 $target_name = "updateFromCurrentPlan";
992 break;
994 $target_name = "acknowledgeCourses";
995 break;
997 $target_name = "changeDeadline";
998 break;
1000 $target_name = "changeExpireDate";
1001 break;
1002 default:
1003 throw new ilException("Unknown action: $action");
1004 }
1005
1006 $this->ctrl->setParameter($this, "prgrs_id", $prgrs_id);
1007 $link = $this->ctrl->getLinkTarget($this, $target_name);
1008 $this->ctrl->setParameter($this, "prgrs_id", null);
1009 return $link;
1010 }
1011
1012 protected function mayCurrentUserEditProgressForUser(int $usr_id): bool
1013 {
1014 return in_array(
1015 $usr_id,
1016 $this->permissions->getUserIdsSusceptibleTo(ilOrgUnitOperation::OP_EDIT_INDIVIDUAL_PLAN)
1017 );
1018 }
1019
1020 protected function getMessageCollection(string $topic): ilPRGMessageCollection
1021 {
1022 return $this->messages->getMessageCollection($topic);
1023 }
1024
1025 protected function showMessages(ilPRGMessageCollection $msg): void
1026 {
1027 $this->messages->showMessages($msg);
1028 }
1029
1030 protected function mailToSelectedUsers(): void
1031 {
1033 $gui = $dic['ilStudyProgrammeMailMemberSearchGUI'];
1034
1035 $selected = $this->getPostPrgsIds();
1036 $selected_ids = array_map(
1037 fn ($id) => $id->getAssignmentId(),
1038 $selected
1039 );
1040
1041 $assignments = array_filter(
1042 $this->getAssignmentsById(),
1043 fn ($ass) => in_array($ass->getId(), $selected_ids)
1044 );
1045 $gui->setAssignments($assignments);
1046 $this->tabs->clearTargets();
1047 $this->tabs->setBackTarget(
1048 $this->lng->txt('btn_back'),
1049 $this->ctrl->getLinkTarget($this, $this->getDefaultCommand())
1050 );
1051 $this->ctrl->forwardCommand($gui);
1052 }
1053}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
static return function(ContainerConfigurator $containerConfigurator)
Definition: basic_rector.php:9
Builds data types.
Definition: Factory.php:21
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static createFromString(string $id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilCtrl provides processing control methods.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
language handling
loadLanguageModule(string $a_module)
Load language module.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
@ilCtrl_Calls ilObjStudyProgrammeMembersGUI: ilStudyProgrammeRepositorySearchGUI @ilCtrl_Calls ilObjS...
markAccreditedByProgressId(PRGProgressId $prgrs_id, ilPRGMessageCollection $msgs)
ilStudyProgrammeRepositorySearchGUI $repository_search_gui
__construct(ilGlobalTemplateInterface $tpl, ilCtrl $ilCtrl, ilToolbarGUI $ilToolbar, ilLanguage $lng, ilObjUser $user, ilTabsGUI $tabs, ilPRGAssignmentDBRepository $assignment_db, ilStudyProgrammeRepositorySearchGUI $repository_search_gui, ilObjStudyProgrammeIndividualPlanGUI $individual_plan_gui, ilPRGMessagePrinter $messages, Factory $data_factory, ilConfirmationGUI $confirmation_gui, ILIAS\HTTP\Wrapper\WrapperFactory $http_wrapper, ILIAS\Refinery\Factory $refinery, ILIAS\UI\Factory $ui_factory, ILIAS\UI\Renderer $ui_renderer, GuzzleHttp\Psr7\ServerRequest $request)
unmarkAccreditedByProgressId(PRGProgressId $prgrs_id, ilPRGMessageCollection $msgs)
showInfoMessage(string $lng_var)
Shows ilUtil failed message.
addUsers(array $user_ids)
Assigns a users to SP.
view()
Shows table with all members of the SP.
getLinkTargetForAction(string $action, string $prgrs_id, int $ass_id)
Get the link target for an action on user progress.
ILIAS HTTP Wrapper WrapperFactory $http_wrapper
viewCompletedCourses(array $assignments)
Shows list of completed courses for each assignment.
removeAssignment(PRGProgressId $pgs_id)
Remove user.
getStudyProgramme(int $ref_id=null)
Get studyprogramm object for ref_id Use this ref_id if argument is null.
initMailToMemberButton(ilToolbarGUI $toolbar, bool $separator=false)
ilObjStudyProgrammeIndividualPlanGUI $individual_plan_gui
showSuccessMessage(string $lng_var)
Shows ilUtil success message.
static getRefIdFor(int $obj_id)
User class.
static _lookupFullname(int $a_user_id)
Class ilObjectGUI Basic methods of all Output classes.
static _lookupObjId(int $ref_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...
add(bool $success, string $message, string $record_identitifer)
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 specificDicFor(ilObjStudyProgramme $prg)
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 fillAutoCompleteToolbar( $parent_object, ilToolbarGUI $toolbar=null, $a_options=array(), $a_sticky=false)
This is just the same as in the parent class, except for the hardcoded class name.
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...
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 describes a standard form.
Definition: Standard.php:27
This is how the factory for UI elements looks.
Definition: Factory.php:38
An entity that renders components to a string output.
Definition: Renderer.php:31
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
string $key
Consumer key/client ID value.
Definition: System.php:193
Class ChatMainBarProvider \MainMenu\Provider.
Class Factory.
$dic
Definition: result.php:32
$_GET['client_id']
Definition: saml1-acs.php:21