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