ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
class.ilObjSkillTreeGUI.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
31 
39 {
40  public ?ilObject $object;
44  protected ilTabsGUI $tabs;
46  protected Tree\SkillTreeManager $skill_tree_manager;
47  protected Node\SkillTreeNodeManager $skill_tree_node_manager;
48  protected Access\SkillTreeAccess $skill_tree_access_manager;
49  protected Access\SkillManagementAccess $skill_management_access_manager;
50  protected Node\SkillDeletionManager $skill_deletion_manager;
51  protected Usage\SkillUsageManager $skill_usage_manager;
53  protected Tree\SkillTreeFactory $skill_tree_factory;
54  protected UIServices $ui;
57  protected Service\SkillAdminGUIRequest $admin_gui_request;
58  protected Service\SkillUIService $skill_ui_service;
59  protected int $requested_node_id = 0;
60  protected int $requested_tref_id = 0;
61  protected int $requested_templates_tree = 0;
62  protected string $requested_skexpand = "";
63  protected bool $requested_tmpmode = false;
64 
68  protected array $requested_titles = [];
69 
73  protected array $requested_node_ids = [];
74 
75  protected string $requested_table_action = "";
76 
80  protected array $requested_table_tree_ids = [];
81 
88  public function __construct(
89  $a_data,
90  int $a_id,
91  bool $a_call_by_reference = true,
92  bool $a_prepare_output = true
93  ) {
94  global $DIC;
95 
96  $this->ctrl = $DIC->ctrl();
97  $this->rbacsystem = $DIC->rbac()->system();
98  $this->error = $DIC["ilErr"];
99  $this->access = $DIC->access();
100  $this->tabs = $DIC->tabs();
101  $this->lng = $DIC->language();
102  $this->settings = $DIC->settings();
103  $this->tpl = $DIC["tpl"];
104  $this->toolbar = $DIC->toolbar();
105  $this->user = $DIC->user();
106  $ilCtrl = $DIC->ctrl();
107  $this->ui = $DIC->ui();
108  $this->main_tpl = $DIC->ui()->mainTemplate();
109  $this->locator = $DIC["ilLocator"];
110  $this->admin_gui_request = $DIC->skills()->internal()->gui()->admin_request();
111  $this->skill_ui_service = $DIC->skills()->ui();
112 
113  $this->type = "skee";
114  parent::__construct($a_data, $a_id, $a_call_by_reference, false);
115 
116  $this->lng->loadLanguageModule('skmg');
117 
118  $this->skill_tree_repo = $DIC->skills()->internal()->repo()->getTreeRepo();
119  $this->skill_tree_factory = $DIC->skills()->internal()->factory()->tree();
120  $this->skill_tree = $this->skill_tree_factory->getTreeById($this->object->getId());
121 
122  $ilCtrl->saveParameter($this, "node_id");
123 
124  $this->tool_context = $DIC->globalScreen()->tool()->context();
125 
126  $this->requested_node_id = $this->admin_gui_request->getNodeId();
127  $this->requested_tref_id = $this->admin_gui_request->getTrefId();
128  $this->requested_templates_tree = $this->admin_gui_request->getTemplatesTree();
129  $this->requested_skexpand = $this->admin_gui_request->getSkillExpand();
130  $this->requested_tmpmode = $this->admin_gui_request->getTemplateMode();
131  $this->requested_titles = $this->admin_gui_request->getTitles();
132  $this->requested_node_ids = $this->admin_gui_request->getNodeIds();
133  $this->requested_table_action = $this->admin_gui_request->getTableTreeAction();
134  $this->requested_table_tree_ids = $this->admin_gui_request->getTableTreeIds();
135  }
136 
137  public function init(Service\SkillInternalManagerService $skill_manager): void
138  {
139  $this->skill_tree_manager = $skill_manager->getTreeManager();
140  $this->skill_tree_node_manager = $skill_manager->getTreeNodeManager($this->object->getId());
141  $this->skill_tree_access_manager = $skill_manager->getTreeAccessManager($this->object->getRefId());
142  $this->skill_management_access_manager = $skill_manager->getManagementAccessManager(
143  $this->skill_tree_manager->getSkillManagementRefId()
144  );
145  $this->skill_deletion_manager = $skill_manager->getDeletionManager();
146  $this->skill_usage_manager = $skill_manager->getUsageManager();
147  }
148 
149  public function executeCommand(): void
150  {
151  $rbacsystem = $this->rbacsystem;
153  $ilTabs = $this->tabs;
154 
155  $next_class = $this->ctrl->getNextClass($this);
156  $cmd = $this->ctrl->getCmd();
157 
158  $this->prepareOutput();
159  $this->showLocator();
160 
161 
162  if (!$this->skill_tree_access_manager->hasReadTreePermission()) {
163  $ilErr->raiseError($this->lng->txt('no_permission'), $ilErr->WARNING);
164  }
165 
166  switch ($next_class) {
167  case 'ilskillrootgui':
168  if (!$this->skill_tree_access_manager->hasReadCompetencesPermission()) {
169  return;
170  }
171  $skrt_gui = new ilSkillRootGUI(
172  $this->skill_tree_node_manager,
173  $this->requested_node_id
174  );
175  $skrt_gui->setParentGUI($this);
176  $ret = $this->ctrl->forwardCommand($skrt_gui);
177  break;
178 
179  case 'ilskillcategorygui':
180  if (!$this->skill_tree_access_manager->hasReadCompetencesPermission()) {
181  return;
182  }
183  $this->tabs_gui->activateTab("skills");
184  $scat_gui = new ilSkillCategoryGUI(
185  $this->skill_tree_node_manager,
186  $this->requested_node_id
187  );
188  $scat_gui->setParentGUI($this);
189  $this->showTree(false, $scat_gui, "listItems");
190  $ret = $this->ctrl->forwardCommand($scat_gui);
191  break;
192 
193  case 'ilbasicskillgui':
194  if (!$this->skill_tree_access_manager->hasReadCompetencesPermission()) {
195  return;
196  }
197  $this->tabs_gui->activateTab("skills");
198  $skill_gui = new ilBasicSkillGUI(
199  $this->skill_tree_node_manager,
200  $this->requested_node_id
201  );
202  $skill_gui->setParentGUI($this);
203  $this->showTree(false, $skill_gui, "edit");
204  $ret = $this->ctrl->forwardCommand($skill_gui);
205  break;
206 
207  case 'ilskilltemplatecategorygui':
208  if (!$this->skill_tree_access_manager->hasReadCompetencesPermission()) {
209  return;
210  }
211  $this->tabs_gui->activateTab("skill_templates");
212  $sctp_gui = new ilSkillTemplateCategoryGUI(
213  $this->skill_tree_node_manager,
214  $this->requested_node_id,
215  $this->requested_tref_id
216  );
217  $sctp_gui->setParentGUI($this);
218  $this->showTree(($this->requested_tref_id == 0), $sctp_gui, "listItems");
219  $ret = $this->ctrl->forwardCommand($sctp_gui);
220  break;
221 
222  case 'ilbasicskilltemplategui':
223  if (!$this->skill_tree_access_manager->hasReadCompetencesPermission()) {
224  return;
225  }
226  $this->tabs_gui->activateTab("skill_templates");
227  $sktp_gui = new ilBasicSkillTemplateGUI(
228  $this->skill_tree_node_manager,
229  $this->requested_node_id,
230  $this->requested_tref_id
231  );
232  $sktp_gui->setParentGUI($this);
233  $this->showTree(($this->requested_tref_id == 0), $sktp_gui, "edit");
234  $ret = $this->ctrl->forwardCommand($sktp_gui);
235  break;
236 
237  case 'ilskilltemplatereferencegui':
238  if (!$this->skill_tree_access_manager->hasReadCompetencesPermission()) {
239  return;
240  }
241  $this->tabs_gui->activateTab("skills");
242  $sktr_gui = new ilSkillTemplateReferenceGUI(
243  $this->skill_tree_node_manager,
244  $this->requested_tref_id
245  );
246  $sktr_gui->setParentGUI($this);
247  $this->showTree(false, $sktr_gui, "listItems");
248  $ret = $this->ctrl->forwardCommand($sktr_gui);
249  break;
250 
251  case "ilskillprofilegui":
252  if (!$this->skill_tree_access_manager->hasReadProfilesPermission()) {
253  return;
254  }
255  $ilTabs->activateTab("profiles");
256  $skprof_gui = new ilSkillProfileGUI(
257  $this->skill_tree_access_manager,
258  $this->skill_tree->getTreeId()
259  );
260  $ret = $this->ctrl->forwardCommand($skprof_gui);
261  break;
262 
263  case "ilskillprofileuploadhandlergui":
264  $skprof_upl_gui = new ilSkillProfileUploadHandlerGUI();
265  $ret = $this->ctrl->forwardCommand($skprof_upl_gui);
266  break;
267 
268  case 'ilpermissiongui':
269  if (!$this->skill_tree_access_manager->hasEditTreePermissionsPermission()) {
270  return;
271  }
272  $this->tabs_gui->activateTab('permissions');
273  $perm_gui = new ilPermissionGUI($this);
274  $ret = $this->ctrl->forwardCommand($perm_gui);
275  break;
276 
277  case "ilexportgui":
278  if (!$this->skill_tree_access_manager->hasEditTreeSettingsPermission()) {
279  return;
280  }
281  $this->tabs_gui->activateTab('export');
282  $exp_gui = new ilExportGUI($this);
283  $exp_gui->addFormat("xml");
284  //$exp_gui->addFormat("html", "", $this, "exportHTML");
285  $this->object->setType("skmg");
286  $ret = $this->ctrl->forwardCommand($exp_gui);
287  $this->object->setType("skee");
288  break;
289 
290  default:
291  if (!$cmd || $cmd == 'view') {
292  $cmd = "editSkills";
293  }
294 
295  if ($cmd == "showTree") {
296  $this->showTree((bool) $this->requested_templates_tree);
297  } else {
298  $this->$cmd();
299  }
300  break;
301  }
302  }
303 
304  protected function showLocator(): void
305  {
306  $ctrl = $this->ctrl;
307  $locator = $this->locator;
308 
309  $locator->clearItems();
310 
312  "ilobjsystemfoldergui",
313  "ref_id",
315  );
316  $locator->addItem(
317  $this->lng->txt("administration"),
318  $this->ctrl->getLinkTargetByClass(array("iladministrationgui", "ilobjsystemfoldergui"), "")
319  );
320  $locator->addItem(
321  $this->lng->txt("obj_skmg"),
322  $this->getSkillManagementLink()
323  );
324 
325  /*
326  if ($this->object && ($this->object->getRefId() != SYSTEM_FOLDER_ID && !$a_do_not_add_object)) {
327  $ilLocator->addItem(
328  $this->object->getTitle(),
329  $this->ctrl->getLinkTarget($this, "view")
330  );
331  }*/
332  }
333 
334  protected function getSkillManagementLink(): string
335  {
336  $this->ctrl->clearParametersByClass("ilobjskillmanagementgui");
337  $this->ctrl->setParameterByClass(
338  "ilobjskillmanagementgui",
339  "ref_id",
340  $this->skill_tree_manager->getSkillManagementRefId()
341  );
342  return $this->ctrl->getLinkTargetByClass("ilobjskillmanagementgui", "");
343  }
344 
345  protected function create(): void
346  {
347  $lng = $this->lng;
348  $tabs = $this->tabs;
349  $mtpl = $this->main_tpl;
350  $ui = $this->ui;
351 
352  $tabs->clearTargets();
353  $tabs->setBackTarget(
354  $lng->txt("back"),
355  $this->getSkillManagementLink()
356  );
357 
358  $mtpl->setContent($ui->renderer()->render($this->initTreeForm()));
359  }
360 
361  protected function edit(): void
362  {
363  $tabs = $this->tabs;
364  $tabs->activateTab("settings");
365  $mtpl = $this->main_tpl;
366  $ui = $this->ui;
367 
368  if (!$this->skill_tree_access_manager->hasEditTreeSettingsPermission()) {
369  return;
370  }
371 
372  $mtpl->setContent($ui->renderer()->render($this->initTreeForm(true)));
373  }
374 
375  public function initTreeForm(bool $edit = false): Form\Standard
376  {
377  $ui = $this->ui;
378  $f = $ui->factory();
379  $ctrl = $this->ctrl;
380  $lng = $this->lng;
381 
382  $fields["title"] = $f->input()->field()->text($lng->txt("title"))->withRequired(true);
383  if ($edit) {
384  $fields["title"] = $fields["title"]->withValue($this->object->getTitle());
385  }
386 
387  $fields["description"] = $f->input()->field()->textarea($lng->txt("description"));
388  if ($edit) {
389  $fields["description"] = $fields["description"]->withValue($this->object->getDescription());
390  }
391 
392  // section
393  $section1 = $f->input()->field()->section($fields, $lng->txt("skmg_add_skill_tree"));
394 
395  if ($edit) {
396  $form_action = $ctrl->getLinkTarget($this, "update");
397  } else {
398  $form_action = $ctrl->getLinkTarget($this, "save");
399  }
400  return $f->input()->container()->form()->standard($form_action, ["props" => $section1]);
401  }
402 
403  public function save(): void
404  {
406  $form = $this->initTreeForm();
407  $lng = $this->lng;
408  $ctrl = $this->ctrl;
409  $tabs = $this->tabs;
410  $tpl = $this->tpl;
411  $ui = $this->ui;
412 
413  if ($request->getMethod() == "POST") {
414  $form = $form->withRequest($request);
415  $data = $form->getData();
416  if (isset($data["props"]) && is_array($data["props"])) {
417  $props = $data["props"];
418  $this->skill_tree_manager->createTree(
419  $props["title"],
420  $props["description"]
421  );
422  $this->main_tpl->setOnScreenMessage('info', $lng->txt("msg_obj_modified"), true);
423  } else {
424  $tpl->setContent($ui->renderer()->render($form));
425  $tabs->clearTargets();
426  $tabs->setBackTarget(
427  $lng->txt("back"),
428  $this->getSkillManagementLink()
429  );
430  return;
431  }
432  }
433  $ctrl->redirectByClass("ilskillrootgui", "listSkills");
434  }
435 
436  public function update(): void
437  {
439  $form = $this->initTreeForm();
440  $lng = $this->lng;
441  $ctrl = $this->ctrl;
442 
443  if ($request->getMethod() == "POST") {
444  $form = $form->withRequest($request);
445  $data = $form->getData();
446  if (isset($data["props"]) && is_array($data["props"])) {
447  $props = $data["props"];
449  $obj = $this->object;
450  $this->skill_tree_manager->updateTree(
451  $obj,
452  $props["title"],
453  $props["description"]
454  );
455  $this->main_tpl->setOnScreenMessage('info', $lng->txt("msg_obj_modified"), true);
456  }
457  }
458  $ctrl->redirect($this, "edit");
459  }
460 
461  public function delete(): void
462  {
463  $ctrl = $this->ctrl;
464 
465  if ($this->requested_table_action === "deleteTrees"
466  && !empty($this->requested_table_tree_ids)
467  && $this->requested_table_tree_ids[0] === "ALL_OBJECTS"
468  ) {
469  $all_trees = $this->skill_tree_manager->getTrees();
470  foreach ($all_trees as $tree_obj) {
471  $tree = $this->skill_tree_factory->getTreeById($tree_obj->getId());
472  $this->requested_node_ids[] = $tree->readRootId();
473  }
474  } elseif ($this->requested_table_action === "deleteTrees") {
475  $this->requested_node_ids = array_map("intval", $this->requested_table_tree_ids);
476  }
477 
478  $this->deleteNodes($this);
479  }
480 
481  public function getAdminTabs(): void
482  {
483  $rbacsystem = $this->rbacsystem;
484  $ilAccess = $this->access;
485  $lng = $this->lng;
486 
487 
488  $this->tabs_gui->setBackTarget(
489  $lng->txt("skmg_skill_trees"),
490  $this->getSkillManagementLink()
491  );
492 
493  if ($this->skill_tree_access_manager->hasReadTreePermission()) {
494  if ($this->skill_tree_access_manager->hasReadCompetencesPermission()) {
495  $this->tabs_gui->addTab(
496  "skills",
497  $lng->txt("skmg_skills"),
498  $this->ctrl->getLinkTarget($this, "editSkills")
499  );
500  $this->tabs_gui->addTab(
501  "skill_templates",
502  $lng->txt("skmg_skill_templates"),
503  $this->ctrl->getLinkTarget($this, "editSkillTemplates")
504  );
505  }
506 
507  if ($this->skill_tree_access_manager->hasReadProfilesPermission()) {
508  $this->tabs_gui->addTab(
509  "profiles",
510  $lng->txt("skmg_skill_profiles"),
511  $this->ctrl->getLinkTargetByClass("ilskillprofilegui")
512  );
513  }
514 
515  if ($this->skill_tree_access_manager->hasEditTreeSettingsPermission()) {
516  $this->tabs_gui->addTab(
517  "settings",
518  $lng->txt("settings"),
519  $this->ctrl->getLinkTarget($this, "edit")
520  );
521  }
522 
523  if ($this->skill_tree_access_manager->hasEditTreeSettingsPermission()) {
524  $this->tabs_gui->addTab(
525  "export",
526  $lng->txt("export"),
527  $this->ctrl->getLinkTargetByClass("ilexportgui", "")
528  );
529  }
530  }
531 
532  if ($this->skill_tree_access_manager->hasEditTreePermissionsPermission()) {
533  $this->tabs_gui->addTab(
534  "permissions",
535  $lng->txt("perm_settings"),
536  $this->ctrl->getLinkTargetByClass('ilpermissiongui', "perm")
537  );
538  }
539  }
540 
541  public function editSkills(): void
542  {
543  $tpl = $this->tpl;
544  $ilTabs = $this->tabs;
545  $lng = $this->lng;
546  $ilCtrl = $this->ctrl;
547 
548  $ilTabs->activateTab("skills");
549 
550  $ilCtrl->setParameterByClass(self::class, "node_id", $this->skill_tree->readRootId());
551  $ilCtrl->redirectByClass("ilskillrootgui", "listSkills");
552  }
553 
554  public function saveAllTitles(bool $a_succ_mess = true): void
555  {
556  $ilCtrl = $this->ctrl;
557  $lng = $this->lng;
558 
559  if (!count($this->requested_titles) == 0) {
560  foreach ($this->requested_titles as $id => $title) {
562  if (is_object($node_obj)) {
563  // update title
565  }
566  }
567  if ($a_succ_mess) {
568  $this->main_tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
569  }
570  }
571  $ilCtrl->redirect($this, "editSkills");
572  }
573 
574  public function saveAllTemplateTitles(bool $a_succ_mess = true): void
575  {
576  $ilCtrl = $this->ctrl;
577  $lng = $this->lng;
578 
579  if (!count($this->requested_titles) == 0) {
580  foreach ($this->requested_titles as $id => $title) {
582  if (is_object($node_obj)) {
583  // update title
585  }
586  }
587  if ($a_succ_mess) {
588  $this->main_tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
589  }
590  }
591  $ilCtrl->redirect($this, "editSkillTemplates");
592  }
593 
594  public function expandAll(bool $a_redirect = true): void
595  {
596  $this->requested_skexpand = "";
597  $n_id = ($this->requested_node_id > 0)
598  ? $this->requested_node_id
599  : $this->skill_tree->readRootId();
600  $stree = $this->skill_tree->getSubTree($this->skill_tree->getNodeData($n_id));
601  $n_arr = [];
602  foreach ($stree as $n) {
603  $n_arr[] = $n["child"];
604  ilSession::set("skexpand", $n_arr);
605  }
606  $this->saveAllTitles(false);
607  }
608 
609  public function collapseAll(bool $a_redirect = true): void
610  {
611  $this->requested_skexpand = "";
612  $n_id = ($this->requested_node_id > 0)
613  ? $this->requested_node_id
614  : $this->skill_tree->readRootId();
615  $stree = $this->skill_tree->getSubTree($this->skill_tree->getNodeData($n_id));
616  $old = ilSession::get("skexpand");
617  foreach ($stree as $n) {
618  if (in_array($n["child"], $old) && $n["child"] != $n_id) {
619  $k = array_search($n["child"], $old);
620  unset($old[$k]);
621  }
622  }
623  ilSession::set("skexpand", $old);
624  $this->saveAllTitles(false);
625  }
626 
627  public function deleteNodes(object $a_gui): void
628  {
629  $lng = $this->lng;
630  $tpl = $this->tpl;
631  $ilCtrl = $this->ctrl;
632  $ilTabs = $this->tabs;
633 
634  if (empty($this->requested_node_ids)) {
635  $tpl->setOnScreenMessage("info", $lng->txt("no_checkbox"), true);
636  $ilCtrl->redirectByClass("ilskilltreeadmingui", "listTrees");
637  }
638 
639  $ilTabs->clearTargets();
640 
641  // check usages
642  $mode = "";
643  $tree_ids = [];
644  $cskill_ids = [];
645  foreach ($this->requested_node_ids as $id) {
646  if (ilSkillTreeNode::_lookupType($id) == "skrt") {
647  if (!$this->skill_management_access_manager->hasCreateTreePermission()) {
648  return;
649  }
650  $mode = "tree";
651  $tree_node_id = $id;
652  $tree_ids[] = $tree_node_id;
653  }
654  if (in_array(ilSkillTreeNode::_lookupType($id), array("skll", "scat", "sktr"))) {
655  if ($mode == "templates") {
656  $tpl->setOnScreenMessage("failure", "Skill Deletion - type mismatch.", true);
657  $ilCtrl->redirectByClass("ilskilltreeadmingui", "listTrees");
658  }
659  $mode = "basic";
660  $skill_id = $id;
661  $tref_id = 0;
662  if (ilSkillTreeNode::_lookupType($id) == "sktr") {
664  $tref_id = $id;
665  }
666  $cskill_ids[] = array("skill_id" => $skill_id, "tref_id" => $tref_id);
667  }
668  if (in_array(ilSkillTreeNode::_lookupType($id), array("sktp", "sctp"))) {
669  if ($mode == "basic") {
670  $tpl->setOnScreenMessage("failure", "Skill Deletion - type mismatch.", true);
671  $ilCtrl->redirectByClass("ilskilltreeadmingui", "listTrees");
672  }
673  $mode = "templates";
674 
675  foreach (ilSkillTemplateReference::_lookupTrefIdsForTemplateId($id) as $tref_id) {
676  $cskill_ids[] = array("skill_id" => $id, "tref_id" => $tref_id);
677  }
678  }
679  // for cats, skills and template references, get "real" usages
680  // for skill and category templates check usage in references
681  }
682 
683  $usages = [];
684  if ($mode == "tree") {
685  $usages = $this->skill_usage_manager->getAllUsagesInfoOfTrees($tree_ids);
686  } elseif ($mode == "basic" || $mode == "templates") {
687  $usages = $this->skill_usage_manager->getAllUsagesInfoOfSubtrees($cskill_ids);
688  } else {
689  $tpl->setOnScreenMessage("failure", "Skill Deletion - type mismatch.", true);
690  $ilCtrl->redirectByClass("ilskilltreeadmingui", "listTrees");
691  }
692 
693  $usage_html = "";
694  if (count($usages) > 0) {
695  foreach ($usages as $k => $usage) {
696  $usages_ui = $this->skill_ui_service->getUsagesUI($k, $usage, $mode);
697  $usage_html .= $usages_ui->render() . "<br/><br/>";
698  }
699  $ilCtrl->saveParameter($a_gui, "tmpmode");
700  }
701 
702  // SAVE POST VALUES
703  ilSession::set("saved_post", $this->requested_node_ids);
704 
705  $confirmation_gui = new ilConfirmationGUI();
706 
707  $ilCtrl->setParameter($a_gui, "tmpmode", (int) $this->requested_tmpmode);
708  $a_form_action = $this->ctrl->getFormAction($a_gui);
709  $confirmation_gui->setFormAction($a_form_action);
710  if (count($usages) > 0) {
711  $confirmation_text = $this->lng->txt("skmg_delete_warning");
712  } else {
713  $confirmation_text = $this->lng->txt("info_delete_sure");
714  }
715  $confirmation_gui->setHeaderText($confirmation_text);
716 
717  // Add items to delete
718  foreach ($this->requested_node_ids as $id) {
719  if ($id != ilTree::POS_FIRST_NODE) {
720  $node_obj = ilSkillTreeNodeFactory::getInstance($id);
721  if ($mode == "tree") {
722  $tree_id = $this->skill_tree_repo->getTreeIdForNodeId($id);
723  $tree_obj = $this->skill_tree_manager->getTree($tree_id);
724  $obj_title = $tree_obj->getTitle();
725  } else {
726  $obj_title = (!in_array($node_obj->getType(), ["sktp", "sctp"]))
727  ? $node_obj->getTitle()
728  : $node_obj->getTitle() .
729  " (" .
730  $this->lng->txt("skmg_count_references") . " " .
732  ")";
733  }
734  $confirmation_gui->addItem(
735  "id[]",
736  (string) $node_obj->getId(),
737  $obj_title,
738  ilUtil::getImagePath("standard/icon_" . $node_obj->getType() . ".svg")
739  );
740  }
741  }
742 
743  $confirmation_gui->setCancel($lng->txt("cancel"), "cancelDelete");
744  if ($mode == "tree") {
745  $confirmation_gui->setConfirm($lng->txt("confirm"), "confirmedDeleteTrees");
746  } else {
747  $confirmation_gui->setConfirm($lng->txt("confirm"), "confirmedDelete");
748  }
749 
750  $tpl->setContent($confirmation_gui->getHTML() . $usage_html);
751  }
752 
753  public function cancelDelete(): void
754  {
755  $this->ctrl->redirectByClass("ilobjskillmanagementgui", "");
756  }
757 
758  public function confirmedDeleteTrees(): void
759  {
760  $ctrl = $this->ctrl;
761 
762  // delete all selected trees
763  foreach ($this->requested_node_ids as $id) {
764  $this->skill_deletion_manager->deleteTree($id);
765  }
766 
767  // feedback
768  $this->main_tpl->setOnScreenMessage('info', $this->lng->txt("info_deleted"), true);
769  $ctrl->redirectByClass("ilobjskillmanagementgui", "");
770  }
771 
772  public function confirmedDelete(): void
773  {
774  // delete all selected objects
775  foreach ($this->requested_node_ids as $id) {
776  $this->skill_deletion_manager->deleteNode($id, $this->skill_tree);
777  }
778  $this->skill_deletion_manager->updateProfileCompletions($this->skill_tree);
779 
780  // feedback
781  $this->main_tpl->setOnScreenMessage('info', $this->lng->txt("info_deleted"), true);
782  }
783 
784  //
785  // Skill Templates
786  //
787 
788  public function editSkillTemplates(): void
789  {
790  $tpl = $this->tpl;
791  $ilTabs = $this->tabs;
792  $lng = $this->lng;
793  $ilCtrl = $this->ctrl;
794 
795  $ilTabs->activateTab("skill_templates");
796  $ilCtrl->setParameter($this, "node_id", $this->skill_tree->readRootId());
797  $ilCtrl->redirectByClass("ilskillrootgui", "listTemplates");
798  }
799 
800  //
801  // Tree
802  //
803 
804  public function showTree(bool $a_templates, $a_gui = "", $a_gui_cmd = ""): void
805  {
806  $ilUser = $this->user;
807  $tpl = $this->tpl;
808  $ilCtrl = $this->ctrl;
809  $lng = $this->lng;
810 
811  if ($a_templates) {
812  if ($this->requested_node_id == 0 || $this->requested_node_id == $this->skill_tree->readRootId()) {
813  return;
814  }
815 
816  if ($this->requested_node_id != $this->skill_tree->readRootId()) {
817  $path = $this->skill_tree->getPathId($this->requested_node_id);
818  if (ilSkillTreeNode::_lookupType($path[1]) == "sktp") {
819  return;
820  }
821  }
822  }
823 
824  $ilCtrl->setParameter($this, "templates_tree", (int) $a_templates);
825 
826  if ($a_templates) {
827  $this->tool_context->current()->addAdditionalData(ilSkillGSToolProvider::SHOW_TEMPLATE_TREE, true);
828  $this->tool_context->current()->addAdditionalData(ilSkillGSToolProvider::SKILL_TREE_ID, $this->object->getId());
829  $exp = new ilSkillTemplateTreeExplorerGUI($this, "showTree", $this->object->getId());
830  } else {
831  $this->tool_context->current()->addAdditionalData(ilSkillGSToolProvider::SHOW_SKILL_TREE, true);
832  $this->tool_context->current()->addAdditionalData(ilSkillGSToolProvider::SKILL_TREE_ID, $this->object->getId());
833  $exp = new ilSkillTreeExplorerGUI($this, "showTree", $this->object->getId());
834  }
835  if (!$exp->handleCommand()) {
836  $tpl->setLeftNavContent($exp->getHTML());
837  }
838  }
839 }
Tree SkillTreeManager $skill_tree_manager
static get(string $a_var)
Access SkillManagementAccess $skill_management_access_manager
Node SkillTreeNodeManager $skill_tree_node_manager
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This describes commonalities between all forms.
Definition: Form.php:32
Skill category GUI class.
Skill tree gui class.
Skill root GUI class.
saveAllTemplateTitles(bool $a_succ_mess=true)
Skill profile GUI class.
redirectByClass( $a_class, string $a_cmd=null, string $a_anchor=null, bool $is_async=false)
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...
redirect(object $a_gui_obj, string $a_cmd=null, string $a_anchor=null, bool $is_async=false)
__construct( $a_data, int $a_id, bool $a_call_by_reference=true, bool $a_prepare_output=true)
setOnScreenMessage(string $type, string $a_txt, bool $a_keep=false)
Set a message to be displayed to the user.
Service SkillAdminGUIRequest $admin_gui_request
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
saveAllTitles(bool $a_succ_mess=true)
prepareOutput(bool $show_sub_objects=true)
Usage SkillUsageManager $skill_usage_manager
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
showTree(bool $a_templates, $a_gui="", $a_gui_cmd="")
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Factory.php:21
Explorer class that works on tree objects (Services/Tree)
setParameterByClass(string $a_class, string $a_parameter, $a_value)
expandAll(bool $a_redirect=true)
static _lookupType(int $a_obj_id)
initTreeForm(bool $edit=false)
const SYSTEM_FOLDER_ID
Definition: constants.php:35
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ilErr
Definition: raiseError.php:17
$path
Definition: ltiservices.php:30
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Access SkillTreeAccess $skill_tree_access_manager
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const POS_FIRST_NODE
ilLanguage $lng
Provides fluid interface to RBAC services.
Definition: UIServices.php:23
init(Service\SkillInternalManagerService $skill_manager)
static _lookupTrefIdsForTopTemplateId(int $a_template_id)
ilGlobalTemplateInterface $tpl
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setContent(string $a_html)
Sets content for standard template.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilGlobalTemplateInterface $main_tpl
ServerRequestInterface $request
renderer()
Get a renderer for UI components.
Definition: UIServices.php:43
Class ilObjectGUI Basic methods of all Output classes.
Skill template reference GUI class.
global $DIC
Definition: shib_login.php:25
setBackTarget(string $a_title, string $a_target, string $a_frame="")
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
ScreenContext ContextServices $tool_context
clearTargets()
clear all targets
Skill template category GUI class.
Node SkillDeletionManager $skill_deletion_manager
Service SkillUIService $skill_ui_service
activateTab(string $a_id)
getLinkTarget(object $a_gui_obj, string $a_cmd=null, string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
collapseAll(bool $a_redirect=true)
Tree SkillTreeFactory $skill_tree_factory
__construct(Container $dic, ilPlugin $plugin)
ilAccessHandler $access
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
factory()
Get the factory that crafts UI components.
Definition: UIServices.php:35
Explorer class that works on tree objects (Services/Tree)
setParameter(object $a_gui_obj, string $a_parameter, $a_value)
Basic skill GUI class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _writeTitle(int $a_obj_id, string $a_title)
ilSkillTreeRepository $skill_tree_repo
static set(string $a_var, $a_val)
Set a value.
Basic skill template GUI class.
setLeftNavContent(string $a_content)
Sets content of left navigation column.