static function getInstance($a_id = 0)
 {
     global $ilias, $ilDB;
     $query = "SELECT * FROM skl_tree_node WHERE obj_id = " . $ilDB->quote($a_id, "integer");
     $obj_set = $ilDB->query($query);
     $obj_rec = $ilDB->fetchAssoc($obj_set);
     $obj = null;
     switch ($obj_rec["type"]) {
         case "skll":
             $obj = new ilBasicSkill();
             $obj->setId($obj_rec["obj_id"]);
             $obj->setDataRecord($obj_rec);
             $obj->read();
             break;
         case "scat":
             $obj = new ilSkillCategory();
             $obj->setId($obj_rec["obj_id"]);
             $obj->setDataRecord($obj_rec);
             $obj->read();
             break;
         case "sktp":
             $obj = new ilBasicSkillTemplate();
             $obj->setId($obj_rec["obj_id"]);
             $obj->setDataRecord($obj_rec);
             $obj->read();
             break;
         case "sctp":
             $obj = new ilSkillTemplateCategory();
             $obj->setId($obj_rec["obj_id"]);
             $obj->setDataRecord($obj_rec);
             $obj->read();
             break;
         case "skrt":
             $obj = new ilSkillRoot();
             $obj->setId($obj_rec["obj_id"]);
             $obj->setDataRecord($obj_rec);
             $obj->read();
             break;
         case "sktr":
             $obj = new ilSkillTemplateReference();
             $obj->setId($obj_rec["obj_id"]);
             $obj->setDataRecord($obj_rec);
             $obj->read();
             break;
     }
     return $obj;
 }
 /**
  * Copy basic skill template
  */
 function copy()
 {
     $skill = new ilBasicSkillTemplate();
     $skill->setTitle($this->getTitle());
     $skill->setType($this->getType());
     $skill->setOrderNr($this->getOrderNr());
     $skill->create();
     $levels = $this->getLevelData();
     if (sizeof($levels)) {
         foreach ($levels as $item) {
             $skill->addLevel($item["title"], $item["description"]);
         }
     }
     $skill->update();
     return $skill;
 }
 /**
  * Insert one or multiple basic skill templates
  *
  * @param
  * @return
  */
 function insertBasicSkillTemplate()
 {
     global $ilCtrl, $lng;
     include_once "./Services/Skill/classes/class.ilSkillHFormGUI.php";
     include_once "./Services/Skill/classes/class.ilSkillTreeNode.php";
     $num = ilSkillHFormGUI::getPostMulti();
     $node_id = ilSkillHFormGUI::getPostNodeId();
     if (!ilSkillHFormGUI::getPostFirstChild()) {
         $parent_id = $this->skill_tree->getParentId($node_id);
         $target = $node_id;
     } else {
         $parent_id = $node_id;
         $target = IL_FIRST_NODE;
     }
     include_once "./Services/Skill/classes/class.ilBasicSkillTemplate.php";
     $skill_ids = array();
     for ($i = 1; $i <= $num; $i++) {
         $skill = new ilBasicSkillTemplate();
         $skill->setTitle($lng->txt("skmg_new_skill_template"));
         $skill->create();
         ilSkillTreeNode::putInTree($skill, $parent_id, $target);
         $skill_ids[] = $skill->getId();
     }
     $skill_ids = array_reverse($skill_ids);
     $skill_ids = implode($skill_ids, ":");
     $ilCtrl->setParameter($this, "highlight", $skill_ids);
     $ilCtrl->redirect($this, "editSkillTemplates", "node_" . $node_id);
 }
 /**
  * Save item
  */
 function saveItem()
 {
     $it = new ilBasicSkillTemplate();
     $it->setTitle($this->form->getInput("title"));
     $it->setOrderNr($this->form->getInput("order_nr"));
     $it->create();
     ilSkillTreeNode::putInTree($it, (int) $_GET["obj_id"], IL_LAST_NODE);
     $this->node_object = $it;
 }