/** * confirm deletion screen of skill tree nodes */ function deleteNodes($a_gui) { global $lng, $tpl, $ilCtrl, $ilTabs, $ilToolbar; if (!isset($_POST["id"])) { $this->ilias->raiseError($this->lng->txt("no_checkbox"), $this->ilias->error_obj->MESSAGE); } $ilTabs->clearTargets(); // check usages $mode = ""; $cskill_ids = array(); foreach ($_POST["id"] as $id) { if (in_array(ilSkillTreeNode::_lookupType($id), array("skll", "scat", "sktr"))) { if ($mode == "templates") { $this->ilias->raiseError("Skill Deletion - type mismatch.", $this->ilias->error_obj->MESSAGE); } $mode = "basic"; $skill_id = $id; $tref_id = 0; if (ilSkillTreeNode::_lookupType($id) == "sktr") { include_once "./Services/Skill/classes/class.ilSkillTemplateReference.php"; $skill_id = ilSkillTemplateReference::_lookupTemplateId($id); $tref_id = $id; } $cskill_ids[] = array("skill_id" => $skill_id, "tref_id" => $tref_id); } if (in_array(ilSkillTreeNode::_lookupType($id), array("sktp", "sctp"))) { if ($mode == "basic") { $this->ilias->raiseError("Skill Deletion - type mismatch.", $this->ilias->error_obj->MESSAGE); } $mode = "templates"; foreach (ilSkillTemplateReference::_lookupTrefIdsForTemplateId($id) as $tref_id) { $cskill_ids[] = array("skill_id" => $id, "tref_id" => $tref_id); } } // for cats, skills and template references, get "real" usages // for skill and category templates check usage in references } if ($mode == "basic" || $mode == "templates") { include_once "./Services/Skill/classes/class.ilSkillUsage.php"; $u = new ilSkillUsage(); $usages = $u->getAllUsagesInfoOfSubtrees($cskill_ids); if (count($usages) > 0) { $html = ""; foreach ($usages as $k => $usage) { include_once "./Services/Skill/classes/class.ilSkillUsageTableGUI.php"; $tab = new ilSkillUsageTableGUI($this, "showUsage", $k, $usage); $html .= $tab->getHTML() . "<br/><br/>"; } $tpl->setContent($html); $ilToolbar->addButton($lng->txt("back"), $ilCtrl->getLinkTarget($a_gui, "cancelDelete")); ilUtil::sendFailure($lng->txt("skmg_cannot_delete_nodes_in_use")); return; } } else { $this->ilias->raiseError("Skill Deletion - type mismatch.", $this->ilias->error_obj->MESSAGE); } // SAVE POST VALUES $_SESSION["saved_post"] = $_POST["id"]; include_once "./Services/Utilities/classes/class.ilConfirmationGUI.php"; $confirmation_gui = new ilConfirmationGUI(); $ilCtrl->setParameter($a_gui, "tmpmode", $_GET["tmpmode"]); $a_form_action = $this->ctrl->getFormAction($a_gui); $confirmation_gui->setFormAction($a_form_action); $confirmation_gui->setHeaderText($this->lng->txt("info_delete_sure")); // Add items to delete include_once "./Services/Skill/classes/class.ilSkillTreeNodeFactory.php"; foreach ($_POST["id"] as $id) { if ($id != IL_FIRST_NODE) { $node_obj = ilSkillTreeNodeFactory::getInstance($id); $confirmation_gui->addItem("id[]", $node_obj->getId(), $node_obj->getTitle(), ilUtil::getImagePath("icon_" . $node_obj->getType() . ".svg")); } } $confirmation_gui->setCancel($lng->txt("cancel"), "cancelDelete"); $confirmation_gui->setConfirm($lng->txt("confirm"), "confirmedDelete"); $tpl->setContent($confirmation_gui->getHTML()); }
/** * Show skill usage */ function showUsage() { global $tpl; $this->setTabs("usage"); include_once "./Services/Skill/classes/class.ilSkillUsage.php"; $usage_info = new ilSkillUsage(); $base_skill_id = $this->base_skill_id > 0 ? $this->base_skill_id : $this->node_object->getId(); $usages = $usage_info->getAllUsagesInfoOfSubtree($base_skill_id . ":" . $this->tref_id); $html = ""; include_once "./Services/Skill/classes/class.ilSkillUsageTableGUI.php"; foreach ($usages as $k => $usage) { $tab = new ilSkillUsageTableGUI($this, "showUsage", $k, $usage); $html .= $tab->getHTML() . "<br/><br/>"; } $tpl->setContent($html); }