ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilSkillProfileGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
26use ILIAS\UI;
27use Psr\Http\Message\ServerRequestInterface;
33use ILIAS\Export\ExportHandler\I\FactoryInterface as ExportFactoryInterface;
34use ILIAS\Export\ExportHandler\Factory as ExportFactory;
36
44{
45 protected ilCtrl $ctrl;
46 protected ilLanguage $lng;
47 protected ilTabsGUI $tabs;
49 protected ilHelpGUI $help;
51 protected UI\Factory $ui_fac;
52 protected UI\Renderer $ui_ren;
53 protected \ILIAS\Data\Factory $df;
54 protected ServerRequestInterface $request;
56 protected int $id = 0;
57 protected ?Profile\SkillProfile $profile = null;
60 protected int $skill_tree_id = 0;
62 protected int $requested_ref_id = 0;
63 protected int $requested_sprof_id = 0;
67 protected Table\TableManager $table_manager;
70 protected ExportFactoryInterface $export_factory;
71 protected ilObjUser $usr;
72
76 protected array $requested_profile_ids = [];
77 protected bool $requested_local_context = false;
78 protected string $requested_cskill_id = "";
79
83 protected array $requested_level_ass_ids = [];
84
88 protected array $requested_level_order = [];
89 protected string $requested_user_login = "";
90
94 protected array $requested_users = [];
95
99 protected array $requested_user_ids = [];
100 protected string $requested_table_profile_action = "";
101
105 protected array $requested_table_profile_ids = [];
106 protected int $requested_level_id = 0;
107 protected bool $local_context = false;
108
110 {
111 global $DIC;
112
113 $this->data_factory = new DataFactory();
114 $this->export_factory = new ExportFactory();
115 $this->usr = $DIC->user();
116 $this->ctrl = $DIC->ctrl();
117 $this->lng = $DIC->language();
118 $this->tabs = $DIC->tabs();
119 $this->tpl = $DIC["tpl"];
120 $this->help = $DIC["ilHelp"];
121 $this->toolbar = $DIC->toolbar();
122 $this->ui_fac = $DIC->ui()->factory();
123 $this->ui_ren = $DIC->ui()->renderer();
124 $this->df = new \ILIAS\Data\Factory();
125 $this->request = $DIC->http()->request();
126 $this->query = $DIC->http()->wrapper()->query();
127 $this->tree_service = $DIC->skills()->tree();
128 $this->skill_tree_access_manager = $skill_tree_access_manager;
129 $this->skill_tree_id = $skill_tree_id;
130 $this->admin_gui_request = $DIC->skills()->internal()->gui()->admin_request();
131 $this->skill_factory = $DIC->skills()->internal()->factory();
132 $this->profile_manager = $DIC->skills()->internal()->manager()->getProfileManager();
133 $this->profile_completion_manager = $DIC->skills()->internal()->manager()->getProfileCompletionManager();
134 $this->table_manager = $DIC->skills()->internal()->manager()->getTableManager();
135 $this->usage_manager = $DIC->skills()->internal()->manager()->getUsageManager();
136
137 $this->ctrl->saveParameter($this, ["sprof_id", "local_context"]);
138
139 $this->requested_ref_id = $this->admin_gui_request->getRefId();
140 $this->requested_sprof_id = $this->admin_gui_request->getSkillProfileId();
141 $this->requested_profile_ids = $this->admin_gui_request->getProfileIds();
142 $this->requested_local_context = $this->admin_gui_request->getLocalContext();
143 $this->requested_cskill_id = $this->admin_gui_request->getCombinedSkillId();
144 $this->requested_level_ass_ids = $this->admin_gui_request->getAssignedLevelIds();
145 $this->requested_level_order = $this->admin_gui_request->getOrder();
146 $this->requested_user_login = $this->admin_gui_request->getUserLogin();
147 $this->requested_users = $this->admin_gui_request->getUsers();
148 $this->requested_user_ids = $this->admin_gui_request->getUserIds();
149 $this->requested_table_profile_action = $this->admin_gui_request->getTableProfileAction();
150 $this->requested_table_profile_ids = $this->admin_gui_request->getTableProfileIds();
151 $this->requested_level_id = $this->admin_gui_request->getLevelId();
152
153 if ($this->requested_sprof_id > 0) {
154 $this->id = $this->requested_sprof_id;
155 }
156
157 if ($this->id > 0) {
158 $this->profile = $this->profile_manager->getProfile($this->id);
159 if ($this->skill_tree_id == 0) {
160 $this->skill_tree_id = $this->profile->getSkillTreeId();
161 }
162 if ($this->profile->getRefId() > 0 && $this->requested_local_context) {
163 $this->local_context = true;
164 }
165 }
166 }
167
168 public function executeCommand(): void
169 {
170 $ilCtrl = $this->ctrl;
172
173 $cmd = $ilCtrl->getCmd("listProfiles");
174 $next_class = $ilCtrl->getNextClass();
175 switch ($next_class) {
176 case 'ilrepositorysearchgui':
177 $user_search = new ilRepositorySearchGUI();
178 $user_search->setTitle($lng->txt('skmg_add_user_to_profile'));
179 $user_search->setCallback($this, 'assignUser');
180 $user_search->setRoleCallback($this, 'assignRole');
181
182 // Set tabs
183 //$this->tabs_gui->setTabActive('user_assignment');
184 $ilCtrl->setReturn($this, 'showUsers');
185 $ret = $ilCtrl->forwardCommand($user_search);
186 break;
187
188 default:
189 if (in_array($cmd, array("listProfiles", "create", "edit", "save", "update",
190 "deleteProfiles", "showLevels", "assignLevel",
191 "assignLevelSelectSkill", "updateLevelOfSelectedSkill",
192 "assignLevelToProfile", "updateLevelOfProfile",
193 "confirmLevelAssignmentRemoval", "removeLevelAssignments",
194 "showUsers", "assignUser", "assignRole",
195 "confirmUserRemoval", "removeUsers", "exportProfiles", "showImportForm",
196 "importProfiles", "saveLevelOrder", "createLocal", "saveLocal",
197 "listLocalProfiles", "showLevelsWithLocalContext", "showObjects"))) {
198 $this->$cmd();
199 }
200 break;
201 }
202 }
203
204 public function setTabs(string $a_active): void
205 {
206 $ilTabs = $this->tabs;
208 $ilCtrl = $this->ctrl;
210 $ilHelp = $this->help;
211
212 $tpl->setTitle($lng->txt("skmg_profile") . ": " .
213 $this->profile->getTitle());
214 $tpl->setDescription($this->profile->getDescription());
215
216 $ilTabs->clearTargets();
217 $ilHelp->setScreenIdComponent("skmg_prof");
218
219 $ilCtrl->clearParameterByClass(self::class, "sprof_id");
220 $ilTabs->setBackTarget(
221 $lng->txt("skmg_skill_profiles"),
222 $ilCtrl->getLinkTarget($this, "")
223 );
224 $ilCtrl->setParameter($this, "sprof_id", $this->requested_sprof_id);
225
226 // levels
227 $ilTabs->addTab(
228 "levels",
229 $lng->txt("skmg_assigned_skill_levels"),
230 $ilCtrl->getLinkTarget($this, "showLevels")
231 );
232
233 // users
234 $ilTabs->addTab(
235 "users",
236 $lng->txt("skmg_assigned_users"),
237 $ilCtrl->getLinkTarget($this, "showUsers")
238 );
239
240 // objects
241 $ilTabs->addTab(
242 "objects",
243 $lng->txt("skmg_assigned_objects"),
244 $ilCtrl->getLinkTarget($this, "showObjects")
245 );
246
247 // settings
248 if ($this->skill_tree_access_manager->hasManageProfilesPermission()) {
249 $ilTabs->addTab(
250 "settings",
251 $lng->txt("settings"),
252 $ilCtrl->getLinkTarget($this, "edit")
253 );
254 }
255
256 $ilTabs->activateTab($a_active);
257 }
258
259 public function listProfiles(): void
260 {
262 $ilToolbar = $this->toolbar;
264 $ilCtrl = $this->ctrl;
265
266 if ($this->skill_tree_access_manager->hasManageProfilesPermission()) {
267 $ilToolbar->addButton(
268 $lng->txt("skmg_add_profile"),
269 $ilCtrl->getLinkTarget($this, "create")
270 );
271
272 $ilToolbar->addButton(
273 $lng->txt("import"),
274 $ilCtrl->getLinkTarget($this, "showImportForm")
275 );
276 }
277
278 $table = $this->table_manager->getProfileTable($this->requested_ref_id, $this->skill_tree_id)->getComponent();
279
280 $tpl->setContent($this->ui_ren->render($table));
281 }
282
283 public function listLocalProfiles(): void
284 {
285 $ilCtrl = $this->ctrl;
286
287 $ilCtrl->redirectByClass("ilcontskilladmingui", "listProfiles");
288 }
289
290 public function create(): void
291 {
293
294 $form = $this->initProfileForm("create");
295 $tpl->setContent($this->ui_ren->render($form));
296 }
297
298 public function createLocal(): void
299 {
304
307 $lng->txt("back_to_course"),
308 $ctrl->getLinkTargetByClass("ilcontskilladmingui", "listProfiles")
309 );
310
311 $form = $this->initProfileForm("createLocal");
312 $tpl->setContent($this->ui_ren->render($form));
313 }
314
315 public function edit(): void
316 {
318
319 $this->setTabs("settings");
320 $form = $this->initProfileForm("edit");
321 $tpl->setContent($this->ui_ren->render($form));
322 }
323
324 public function initProfileForm(string $a_mode = "edit"): \ILIAS\UI\Component\Input\Container\Form\Form
325 {
327 $ilCtrl = $this->ctrl;
328
329 $ilCtrl->setParameter(
330 $this,
331 "profile",
332 "profile_settings"
333 );
334
335 // title
336 $ti = $this->ui_fac->input()->field()->text($lng->txt("title"))
337 ->withRequired(true);
338
339 // description
340 $desc = $this->ui_fac->input()->field()->textarea($lng->txt("description"));
341
342 // skill trees (if local profile)
343 $se = null;
344 if ($a_mode == "createLocal") {
345 $options = [];
346 $trees = $this->tree_service->getObjSkillTrees();
347 foreach ($trees as $tree) {
348 $options[$tree->getId()] = $tree->getTitle();
349 }
350 $se = $this->ui_fac->input()->field()->select($lng->txt("skmg_skill_tree"), $options)->withRequired(true);
351 }
352
353 // image
354 $img = $this->ui_fac->input()->field()->file(new ilSkillProfileUploadHandlerGUI(), $lng->txt("image"))
355 ->withAcceptedMimeTypes([MimeType::IMAGE__PNG, MimeType::IMAGE__JPEG]);
356
357 // save commands
358 $sec_des = "";
359 $form_action = "";
360 if ($this->skill_tree_access_manager->hasManageProfilesPermission()) {
361 if ($a_mode == "create") {
362 $sec_des = $lng->txt("skmg_add_profile");
363 $form_action = $ilCtrl->getFormAction($this, "save");
364 } elseif ($a_mode == "createLocal") {
365 $sec_des = $lng->txt("skmg_add_local_profile");
366 $form_action = $ilCtrl->getFormAction($this, "saveLocal");
367 } else {
368 // set values
369 $ti = $ti->withValue($this->profile->getTitle());
370 $desc = $desc->withValue($this->profile->getDescription());
371 $img = $this->profile->getImageId() ? $img->withValue([$this->profile->getImageId()]) : $img;
372
373 $sec_des = $lng->txt("skmg_edit_profile");
374 $form_action = $ilCtrl->getFormAction($this, "update");
375 }
376 }
377
378 if (is_null($se)) {
379 $section_basic = $this->ui_fac->input()->field()->section(
380 ["title" => $ti, "description" => $desc],
381 $sec_des
382 );
383 } else {
384 $section_basic = $this->ui_fac->input()->field()->section(
385 ["title" => $ti, "description" => $desc, "skill_tree" => $se],
386 $sec_des
387 );
388 }
389 $section_advanced = $this->ui_fac->input()->field()->section(["image" => $img], $lng->txt("skmg_form_presentation"));
390
391 $form = $this->ui_fac->input()->container()->form()->standard(
392 $form_action,
393 ["section_basic" => $section_basic, "section_advanced" => $section_advanced]
394 );
395
396 return $form;
397 }
398
399 public function save(): void
400 {
403 $ilCtrl = $this->ctrl;
404
405 if (!$this->skill_tree_access_manager->hasManageProfilesPermission()) {
406 return;
407 }
408
409 $form = $this->initProfileForm("create");
410 if ($this->request->getMethod() == "POST"
411 && $this->request->getQueryParams()["profile"] == "profile_settings") {
412 $form = $form->withRequest($this->request);
413 $result = $form->getData();
414 if (is_null($result)) {
415 $tpl->setContent($this->ui_ren->render($form));
416 return;
417 }
418 $profile = $this->skill_factory->profile()->profile(
419 0,
420 $result["section_basic"]["title"],
421 $result["section_basic"]["description"],
422 $this->skill_tree_id,
423 $result["section_advanced"]["image"][0] ?? ""
424 );
425 $this->profile_manager->createProfile($profile);
426
427 $this->tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
428 $ilCtrl->redirect($this, "listProfiles");
429 }
430 $ilCtrl->redirect($this, "listProfiles");
431 }
432
433 public function saveLocal(): void
434 {
437 $ilCtrl = $this->ctrl;
438
439 if (!$this->skill_tree_access_manager->hasManageProfilesPermission()) {
440 return;
441 }
442
443 $form = $this->initProfileForm("createLocal");
444 if ($this->request->getMethod() == "POST"
445 && $this->request->getQueryParams()["profile"] == "profile_settings") {
446 $form = $form->withRequest($this->request);
447 $result = $form->getData();
448 if (is_null($result)) {
449 $tpl->setContent($this->ui_ren->render($form));
450 return;
451 }
452 $profile = $this->skill_factory->profile()->profile(
453 0,
454 $result["section_basic"]["title"],
455 $result["section_basic"]["description"],
456 (int) $result["section_basic"]["skill_tree"],
457 $result["section_advanced"]["image"][0] ?? "",
458 $this->requested_ref_id
459 );
460 $new_profile = $this->profile_manager->createProfile($profile);
461 $this->profile_manager->addRoleToProfile(
462 $new_profile->getId(),
463 ilParticipants::getDefaultMemberRole($this->requested_ref_id)
464 );
465 $this->tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
466 $ilCtrl->redirectByClass("ilcontskilladmingui", "listProfiles");
467 }
468 $ilCtrl->redirectByClass("ilcontskilladmingui", "listProfiles");
469 }
470
471 public function update(): void
472 {
474 $ilCtrl = $this->ctrl;
476
477 if (!$this->skill_tree_access_manager->hasManageProfilesPermission()) {
478 return;
479 }
480
481 $form = $this->initProfileForm("edit");
482 if ($this->request->getMethod() == "POST"
483 && $this->request->getQueryParams()["profile"] == "profile_settings") {
484 $form = $form->withRequest($this->request);
485 $result = $form->getData();
486 if (is_null($result)) {
487 $tpl->setContent($this->ui_ren->render($form));
488 return;
489 }
490 $profile = $this->skill_factory->profile()->profile(
491 $this->profile->getId(),
492 $result["section_basic"]["title"],
493 $result["section_basic"]["description"],
494 $this->profile->getSkillTreeId(),
495 $result["section_advanced"]["image"][0] ?? "",
496 $this->profile->getRefId()
497 );
498 $this->profile_manager->updateProfile($profile);
499
500 $this->tpl->setOnScreenMessage('info', $lng->txt("msg_obj_modified"), true);
501 $ilCtrl->redirect($this, "edit");
502 }
503 $ilCtrl->redirect($this, "listProfiles");
504 }
505
506 public function deleteProfiles(): void
507 {
508 $ilCtrl = $this->ctrl;
511
512 if (!$this->skill_tree_access_manager->hasManageProfilesPermission()) {
513 return;
514 }
515
516 if (!empty($this->requested_profile_ids)) {
517 foreach ($this->requested_profile_ids as $i) {
518 $this->profile_manager->delete($i);
519 $this->profile_completion_manager->deleteEntriesForProfile($i);
520 }
521 $this->tpl->setOnScreenMessage('info', $lng->txt("msg_obj_modified"), true);
522 }
523
524 $ilCtrl->redirect($this, "listProfiles");
525 }
526
530
531 public function showLevels(): void
532 {
534 $ilCtrl = $this->ctrl;
536 $ilToolbar = $this->toolbar;
537
538 $this->setTabs("levels");
539
540 if ($this->skill_tree_access_manager->hasManageProfilesPermission()) {
541 $ilToolbar->addButton(
542 $lng->txt("skmg_assign_level"),
543 $ilCtrl->getLinkTarget($this, "assignLevel")
544 );
545 }
546
548 $this,
549 "showLevels",
550 $this->profile
551 );
552 $tpl->setContent($tab->getHTML());
553 }
554
555 public function showLevelsWithLocalContext(): void
556 {
562
565 $lng->txt("back_to_course"),
566 $ctrl->getLinkTargetByClass("ilcontskilladmingui", "listProfiles")
567 );
568
569 if ($this->skill_tree_access_manager->hasManageProfilesPermission()) {
571 $lng->txt("skmg_assign_level"),
572 $ctrl->getLinkTarget($this, "assignLevel")
573 );
574 }
575
577 $this,
578 "showLevelsWithLocalContext",
579 $this->profile
580 );
581 $tpl->setContent($tab->getHTML());
582 }
583
584 public function assignLevel(): void
585 {
587 $ilTabs = $this->tabs;
588 $ilCtrl = $this->ctrl;
590 $local = $this->local_context;
591
592 $tpl->setTitle($lng->txt("skmg_profile") . ": " .
593 $this->profile->getTitle());
594 $tpl->setDescription("");
595
596 //$this->setTabs("levels");
597
598 $this->tpl->setOnScreenMessage('info', $lng->txt("skmg_select_skill_level_assign"));
599
600 $ilTabs->clearTargets();
601 if ($local) {
602 $ilTabs->setBackTarget(
603 $lng->txt("back"),
604 $ilCtrl->getLinkTarget($this, "showLevelsWithLocalContext")
605 );
606 } else {
607 $ilTabs->setBackTarget(
608 $lng->txt("back"),
609 $ilCtrl->getLinkTarget($this, "showLevels")
610 );
611 }
612
613
614 $exp = new ilSkillSelectorGUI(
615 $this,
616 "assignLevel",
617 $this,
618 "assignLevelSelectSkill",
619 "cskill_id",
620 $this->skill_tree_id
621 );
622 if (!$exp->handleCommand()) {
623 $tpl->setContent($exp->getHTML());
624 }
625 }
626
630 public function assignLevelSelectSkill(bool $update = false): void
631 {
634 $ilCtrl = $this->ctrl;
635 $ilTabs = $this->tabs;
636 $local = $this->local_context;
637
638 $ilCtrl->saveParameter($this, "cskill_id");
639
640 $tpl->setTitle($lng->txt("skmg_profile") . ": " .
641 $this->profile->getTitle());
642 $tpl->setDescription("");
643
644 $ilTabs->clearTargets();
645 if ($local) {
646 $ilTabs->setBackTarget(
647 $lng->txt("back"),
648 $ilCtrl->getLinkTarget($this, "showLevelsWithLocalContext")
649 );
650 } else {
651 $ilTabs->setBackTarget(
652 $lng->txt("back"),
653 $ilCtrl->getLinkTarget($this, "showLevels")
654 );
655 }
656
657 $id_parts = explode(":", $this->requested_cskill_id);
658 $skill_id = (int) $id_parts[0];
659 $skill = new ilBasicSkill($skill_id);
660 $level_data = $skill->getLevelData();
661
662 $items = [];
663 foreach ($level_data as $levels) {
664 $ilCtrl->setParameterByClass(self::class, "level_id", $levels["id"]);
665 $items[] = $this->ui_fac->item()->standard($levels["title"])->withMainAction(
666 $this->ui_fac->link()->standard(
667 $lng->txt("skmg_assign_level"),
668 $ilCtrl->getLinkTarget($this, $update ? "updateLevelOfProfile" : "assignLevelToProfile")
669 )
670 );
671 $ilCtrl->clearParameterByClass(self::class, "level_id");
672 }
673
674 $list = $this->ui_fac->panel()->listing()->standard(
675 $skill->getTitle() . ", " . $lng->txt("skmg_skill_levels"),
676 [
677 $this->ui_fac->item()->group("", $items)
678 ]
679 );
680
681 $tpl->setContent($this->ui_ren->render($list));
682 }
683
684 public function updateLevelOfSelectedSkill(): void
685 {
686 $this->assignLevelSelectSkill(true);
687 }
688
689 public function assignLevelToProfile(?Profile\SkillProfileLevel $level = null): void
690 {
691 $ilCtrl = $this->ctrl;
693 $local = $this->local_context;
694
695 if (!$this->skill_tree_access_manager->hasManageProfilesPermission()) {
696 return;
697 }
698
699 if ($level) {
700 $this->profile_manager->updateSkillLevel($level);
701 } else {
702 $parts = explode(":", $this->requested_cskill_id);
703 $level = $this->skill_factory->profile()->profileLevel(
704 $this->profile->getId(),
705 (int) $parts[0],
706 (int) $parts[1],
707 $this->requested_level_id,
708 $this->profile_manager->getMaxLevelOrderNr($this->profile->getId()) + 10
709 );
710 $this->profile_manager->addSkillLevel($level);
711 }
712
713 // profile completion check because of profile editing
714 $this->profile_completion_manager->writeCompletionEntryForAllAssignedUsersOfProfile($this->profile->getId());
715
716 $this->tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
717 if ($local) {
718 $ilCtrl->redirect($this, "showLevelsWithLocalContext");
719 }
720 $ilCtrl->redirect($this, "showLevels");
721 }
722
723 public function updateLevelOfProfile(): void
724 {
725 $parts = explode(":", $this->requested_cskill_id);
726 $level = $this->profile_manager->getSkillLevel($this->profile->getId(), (int) $parts[0], (int) $parts[1]);
727 $level_updated = $this->skill_factory->profile()->profileLevel(
728 $level->getProfileId(),
729 $level->getBaseSkillId(),
730 $level->getTrefId(),
731 $this->requested_level_id,
732 $level->getOrderNr()
733 );
734 $this->assignLevelToProfile($level_updated);
735 }
736
737 public function confirmLevelAssignmentRemoval(): void
738 {
739 $ilCtrl = $this->ctrl;
743 $local = $this->local_context;
744
745 if ($local) {
747 } else {
748 $this->setTabs("levels");
749 }
750
751 if (empty($this->requested_level_ass_ids)) {
752 $this->tpl->setOnScreenMessage('info', $lng->txt("no_checkbox"), true);
753 if ($local) {
754 $ilCtrl->redirect($this, "showLevelsWithLocalContext");
755 }
756 $ilCtrl->redirect($this, "showLevels");
757 } else {
758 $cgui = new ilConfirmationGUI();
759 $cgui->setFormAction($ilCtrl->getFormAction($this));
760 $cgui->setHeaderText($lng->txt("skmg_confirm_remove_level_ass"));
761 if ($local) {
762 $cgui->setCancel($lng->txt("cancel"), "showLevelsWithLocalContext");
763 } else {
764 $cgui->setCancel($lng->txt("cancel"), "showLevels");
765 }
766 $cgui->setConfirm($lng->txt("remove"), "removeLevelAssignments");
767
768 foreach ($this->requested_level_ass_ids as $i) {
769 $id_arr = explode(":", $i);
770 $cgui->addItem(
771 "ass_id[]",
772 $i,
773 ilBasicSkill::_lookupTitle((int) $id_arr[0]) . ": " .
774 ilBasicSkill::lookupLevelTitle((int) $id_arr[2])
775 );
776 }
777
778 $tpl->setContent($cgui->getHTML());
779 }
780 }
781
782 public function removeLevelAssignments(): void
783 {
784 $ilCtrl = $this->ctrl;
785 $local = $this->local_context;
786
787 if (!$this->skill_tree_access_manager->hasManageProfilesPermission()) {
788 return;
789 }
790
791 if (!empty($this->requested_level_ass_ids)) {
792 foreach ($this->requested_level_ass_ids as $i) {
793 $id_arr = explode(":", $i);
794 $level = $this->skill_factory->profile()->profileLevel(
795 $this->profile->getId(),
796 (int) $id_arr[0],
797 (int) $id_arr[1],
798 (int) $id_arr[2],
799 (int) $id_arr[3]
800 );
801 $this->profile_manager->removeSkillLevel($level);
802 }
803 $this->profile_manager->fixSkillOrderNumbering($this->profile->getId());
804 }
805
806 // profile completion check because of profile editing
807 $this->profile_completion_manager->writeCompletionEntryForAllAssignedUsersOfProfile($this->profile->getId());
808
809 if ($local) {
810 $ilCtrl->redirect($this, "showLevelsWithLocalContext");
811 }
812 $ilCtrl->redirect($this, "showLevels");
813 }
814
815 public function saveLevelOrder(): void
816 {
818 $ilCtrl = $this->ctrl;
819 $local = $this->local_context;
820
821 if (!$this->skill_tree_access_manager->hasManageProfilesPermission()) {
822 return;
823 }
824
825 $order = ilArrayUtil::stripSlashesArray($this->requested_level_order);
826 $this->profile_manager->updateSkillOrder($this->profile->getId(), $order);
827
828 $this->tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
829 if ($local) {
830 $ilCtrl->redirect($this, "showLevelsWithLocalContext");
831 }
832 $ilCtrl->redirect($this, "showLevels");
833 }
834
835 public function showUsers(): void
836 {
839 $ilToolbar = $this->toolbar;
840
841 // add member
842 if ($this->skill_tree_access_manager->hasManageProfilesPermission() && !$this->profile->getRefId() > 0) {
844 $this,
845 $ilToolbar,
846 array(
847 'auto_complete_name' => $lng->txt('user'),
848 'submit_name' => $lng->txt('skmg_assign_user')
849 )
850 );
851
852 $ilToolbar->addSeparator();
853
854 $button = $this->ui_fac->button()->standard(
855 $this->lng->txt("skmg_add_assignment"),
856 $this->ctrl->getLinkTargetByClass("ilRepositorySearchGUI", "start")
857 );
858 $ilToolbar->addComponent($button);
859 }
860
861 $this->setTabs("users");
862
863 $table = $this->table_manager->getProfileUserAssignmentTable(
864 $this->profile,
865 $this->skill_tree_access_manager
866 )->getComponent();
867 $tpl->setContent($this->ui_ren->render($table));
868 }
869
870 public function assignUser(): void
871 {
872 $ilCtrl = $this->ctrl;
874
875 if (!$this->skill_tree_access_manager->hasManageProfilesPermission()) {
876 return;
877 }
878
879 // user assignment with toolbar
880 $user_id = ilObjUser::_lookupId($this->requested_user_login);
881 if ($user_id > 0) {
882 $this->profile_manager->addUserToProfile($this->profile->getId(), $user_id);
883 // profile completion check for added user
884 $this->profile_completion_manager->writeCompletionEntryForSingleProfileOfUser($user_id, $this->profile->getId());
885 $this->tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
886 }
887
888 // user assignment with ilRepositorySearchGUI
889 $users = $this->requested_users;
890 if (!empty($users)) {
891 foreach ($users as $id) {
892 if ($id > 0) {
893 $this->profile_manager->addUserToProfile($this->profile->getId(), $id);
894 // profile completion check for added user
895 $this->profile_completion_manager->writeCompletionEntryForSingleProfileOfUser($id, $this->profile->getId());
896 }
897 }
898 $this->tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
899 }
900
901 $ilCtrl->redirect($this, "showUsers");
902 }
903
904 public function assignRole(array $role_ids): void
905 {
906 $ilCtrl = $this->ctrl;
908
909 if (!$this->skill_tree_access_manager->hasManageProfilesPermission()) {
910 return;
911 }
912
913 $success = false;
914 foreach ($role_ids as $id) {
915 if ($id > 0) {
916 $this->profile_manager->addRoleToProfile($this->profile->getId(), $id);
917 $this->profile_completion_manager->writeCompletionEntryForRole($id, $this->profile->getId());
918 $success = true;
919 }
920 }
921 if ($success) {
922 $this->tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
923 }
924
925 $ilCtrl->redirect($this, "showUsers");
926 }
927
928 public function removeUsers(): void
929 {
930 $ilCtrl = $this->ctrl;
932
933 if (!$this->skill_tree_access_manager->hasManageProfilesPermission()) {
934 return;
935 }
936
937 if (!empty($this->requested_user_ids)) {
938 foreach ($this->requested_user_ids as $i) {
939 $type = ilObject::_lookupType($i);
940 switch ($type) {
941 case "usr":
942 $this->profile_manager->removeUserFromProfile($this->profile->getId(), $i);
943 break;
944
945 case "role":
946 $this->profile_manager->removeRoleFromProfile($this->profile->getId(), $i);
947 break;
948
949 default:
950 echo "not deleted";
951 }
952 }
953 $this->tpl->setOnScreenMessage("success", $lng->txt("msg_obj_modified"), true);
954 }
955 $ilCtrl->redirect($this, "showUsers");
956 }
957
958 public function showObjects(): void
959 {
961
962 $this->setTabs("objects");
963
964 $objects = $this->usage_manager->getAssignedObjectsForSkillProfile($this->profile->getId());
965
966 $table = $this->table_manager->getAssignedObjectsTable(
967 $this,
968 $objects,
969 0,
970 0,
971 $this->profile->getId()
972 )->getComponent();
973 $tpl->setContent($this->ui_ren->render($table));
974 }
975
976 public function exportProfiles(): void
977 {
978 $ilCtrl = $this->ctrl;
980
981 if (!$this->skill_tree_access_manager->hasManageProfilesPermission()) {
982 return;
983 }
984
985 $profiles_to_export = [];
986 if ($this->requested_table_profile_action === "exportProfiles"
987 && !empty($this->requested_table_profile_ids)
988 && $this->requested_table_profile_ids[0] === "ALL_OBJECTS"
989 ) {
990 $profiles = $this->skill_tree_id
991 ? $this->profile_manager->getProfilesForSkillTree($this->skill_tree_id)
992 : $this->profile_manager->getProfilesForAllSkillTrees();
993 foreach ($profiles as $profile) {
994 $profiles_to_export[] = $profile->getId();
995 }
996 } elseif ($this->requested_table_profile_action === "exportProfiles") {
997 $profiles_to_export = array_map("intval", $this->requested_table_profile_ids);
998 }
999
1000 if (empty($profiles_to_export)) {
1001 $this->tpl->setOnScreenMessage('info', $lng->txt("no_checkbox"), true);
1002 $ilCtrl->redirect($this, "");
1003 }
1004
1006 $configs = $this->export_factory->consumer()->exportConfig()->allExportConfigs();
1007 $config = $configs->getElementByComponent('components/ILIAS/Skill');
1008 $config->setMode(ilSkillExportConfig::MODE_PROFILES);
1009 $config->setSelectedProfiles($profiles_to_export);
1010 $config->setSkillTreeId($this->skill_tree_id);
1012 $obj = new ilObject();
1013 $obj->setRefId($this->requested_ref_id);
1014 $obj->setType('skee');
1015 $obj->read();
1016 $obj->setType('skmg');
1017 $this->export_factory->consumer()->handler()->createStandardExportByObject($this->usr->getId(), $obj, $configs);
1018
1019 //ilExport::_createExportDirectory(0, "xml", "");
1020 //$export_dir = ilExport::_getExportDirectory($a_id, "xml", $a_type);
1021 //$exp->exportEntity("skprof", $_POST["id"], "", "components/ILIAS/Skill", $a_title, $a_export_dir, "skprof");
1022
1023 $ilCtrl->redirectByClass(array("ilobjskilltreegui", "ilexportgui"), "");
1024 }
1025
1026 public function showImportForm(): void
1027 {
1028 $tpl = $this->tpl;
1029 $ilTabs = $this->tabs;
1030
1031 $tpl->setContent($this->initInputForm()->getHTML());
1032 }
1033
1035 {
1036 $lng = $this->lng;
1037 $ilCtrl = $this->ctrl;
1038
1039 $form = new ilPropertyFormGUI();
1040
1041 $fi = new ilFileInputGUI($lng->txt("skmg_input_file"), "import_file");
1042 $fi->setSuffixes(array("zip"));
1043 $fi->setRequired(true);
1044 $form->addItem($fi);
1045
1046 // save and cancel commands
1047 $form->addCommandButton("importProfiles", $lng->txt("import"));
1048 $form->addCommandButton("", $lng->txt("cancel"));
1049
1050 $form->setTitle($lng->txt("import"));
1051 $form->setFormAction($ilCtrl->getFormAction($this));
1052
1053 return $form;
1054 }
1055
1056 public function importProfiles(): void
1057 {
1058 $tpl = $this->tpl;
1059 $lng = $this->lng;
1060 $ilCtrl = $this->ctrl;
1061
1062 $form = $this->initInputForm();
1063 if ($form->checkInput()) {
1064 $imp = new ilImport();
1065 $conf = $imp->getConfig("components/ILIAS/Skill");
1066 $conf->setSkillTreeId($this->skill_tree_id);
1067 $imp->importEntity($_FILES["import_file"]["tmp_name"], $_FILES["import_file"]["name"], "skmg", "components/ILIAS/Skill");
1068
1069 $this->tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
1070 $ilCtrl->redirect($this, "");
1071 } else {
1072 $form->setValuesByPost();
1073 $tpl->setContent($form->getHTML());
1074 }
1075 }
1076}
Builds data types.
Definition: Factory.php:36
Mime type determination.
Definition: MimeType.php:30
Request wrapper for guis in skill administration.
Definition: UI.php:24
static stripSlashesArray(array $a_arr, bool $a_strip_html=true, string $a_allow="")
static lookupLevelTitle(int $a_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.
redirectByClass( $a_class, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false)
@inheritDoc
getLinkTarget(object $a_gui_obj, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
@inheritDoc
setParameter(object $a_gui_obj, string $a_parameter, $a_value)
@inheritDoc
getLinkTargetByClass( $a_class, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
@inheritDoc
This class represents a file property in a property form.
Help GUI class.
Import class.
language handling
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
User class.
static _lookupId(string|array $a_user_str)
Class ilObject Basic functions for all objects.
static _lookupType(int $id, bool $reference=false)
static getDefaultMemberRole(int $a_ref_id)
This class represents a property form user interface.
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...
Skill profile GUI class.
SkillAdminGUIRequest $admin_gui_request
Table TableManager $table_manager
ServerRequestInterface $request
ArrayBasedRequestWrapper $query
Profile SkillProfileCompletionManager $profile_completion_manager
Usage SkillUsageManager $usage_manager
SkillTreeAccess $skill_tree_access_manager
Profile SkillProfile $profile
SkillInternalFactoryService $skill_factory
initProfileForm(string $a_mode="edit")
__construct(SkillTreeAccess $skill_tree_access_manager, int $skill_tree_id=0)
assignLevelToProfile(?Profile\SkillProfileLevel $level=null)
ExportFactoryInterface $export_factory
ILIAS Data Factory $df
ilGlobalTemplateInterface $tpl
assignLevelSelectSkill(bool $update=false)
Output level table for profile assignment.
Profile SkillProfileManager $profile_manager
SkillTreeService $tree_service
TableGUI class for skill profile levels.
Class ilSkillProfileUploadHandlerGUI.
Explorer class that works on tree objects (Services/Tree)
static _lookupTitle(int $a_obj_id, int $a_tref_id=0)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setBackTarget(string $a_title, string $a_target, string $a_frame="")
clearTargets()
clear all targets
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')
setDescription(string $a_descr)
Sets description below title in standard template.
setTitle(string $a_title, bool $hidden=false)
Sets title in standard template.
setContent(string $a_html)
Sets content for standard template.
This describes commonalities between all forms.
Definition: Form.php:33
This describes commonalities between all inputs.
Definition: Input.php:47
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:61
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
global $DIC
Definition: shib_login.php:26