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