5include_once(
"./Services/Skill/classes/class.ilSkillTree.php");
 
   37        $this->db = 
$DIC->database();
 
   54        $this->title = $a_title;
 
   74        $this->description = $a_description;
 
  134        $this->self_eval = $a_val;
 
  144        return $this->self_eval;
 
  154        $this->order_nr = $a_val;
 
  164        return $this->order_nr;
 
  174        $this->import_id = $a_val;
 
  184        return $this->import_id;
 
  194        $this->creation_date = $a_val;
 
  204        return $this->creation_date;
 
  219            self::STATUS_DRAFT => 
$lng->txt(
"skmg_status_draft"),
 
  220            self::STATUS_PUBLISH => 
$lng->txt(
"skmg_status_publish"),
 
  221            self::STATUS_OUTDATED => 
$lng->txt(
"skmg_status_outdated")
 
  252        if (!isset($this->data_record)) {
 
  253            $query = 
"SELECT * FROM skl_tree_node WHERE obj_id = " .
 
  254                $ilDB->quote($this->
id, 
"integer");
 
  256            $this->data_record = 
$ilDB->fetchAssoc($obj_set);
 
  258        $this->
setType($this->data_record[
"type"]);
 
  259        $this->
setTitle($this->data_record[
"title"]);
 
  261        $this->
setOrderNr($this->data_record[
"order_nr"]);
 
  263        $this->
setStatus($this->data_record[
"status"]);
 
  264        $this->
setImportId($this->data_record[
"import_id"]);
 
  273        $this->data_record = $a_record;
 
  282    protected static function _lookup($a_obj_id, $a_field)
 
  288        $query = 
"SELECT $a_field FROM skl_tree_node WHERE obj_id = " .
 
  289            $ilDB->quote($a_obj_id, 
"integer");
 
  291        $obj_rec = 
$ilDB->fetchAssoc($obj_set);
 
  293        return $obj_rec[$a_field];
 
  308        include_once(
"./Services/Skill/classes/class.ilSkillTemplateReference.php");
 
  372        $query = 
"SELECT * FROM skl_tree_node WHERE obj_id = " .
 
  373            $ilDB->quote($a_obj_id, 
"integer");
 
  375        $obj_rec = 
$ilDB->fetchAssoc($obj_set);
 
  377        return $obj_rec[
"type"];
 
  387        $this->status = $a_val;
 
  397        return $this->status;
 
  412        $query = 
"UPDATE skl_tree_node SET " .
 
  413            " title = " . 
$ilDB->quote($a_title, 
"text") .
 
  414            " WHERE obj_id = " . 
$ilDB->quote($a_obj_id, 
"integer");
 
  431        $query = 
"UPDATE skl_tree_node SET " .
 
  432            " description = " . 
$ilDB->quote($a_description, 
"clob") .
 
  433            " WHERE obj_id = " . 
$ilDB->quote($a_obj_id, 
"integer");
 
  450        $query = 
"UPDATE skl_tree_node SET " .
 
  451            " order_nr = " . 
$ilDB->quote($a_nr, 
"integer") .
 
  452            " WHERE obj_id = " . 
$ilDB->quote($a_obj_id, 
"integer");
 
  466        $id = 
$ilDB->nextId(
"skl_tree_node");
 
  467        $query = 
"INSERT INTO skl_tree_node (obj_id, title, description, type, create_date, self_eval, order_nr, status, creation_date, import_id) " .
 
  469            $ilDB->quote(
$id, 
"integer") . 
"," .
 
  473            $ilDB->now() . 
", " .
 
  477            $ilDB->now() . 
", " .
 
  491        $query = 
"UPDATE skl_tree_node SET " .
 
  496            " ,status = " . 
$ilDB->quote((
int) $this->
getStatus(), 
"integer") .
 
  498            " WHERE obj_id = " . 
$ilDB->quote($this->
getId(), 
"integer");
 
  506    public function delete()
 
  510        $query = 
"DELETE FROM skl_tree_node WHERE obj_id= " .
 
  518    public static function putInTree($a_obj, $a_parent_id = 
"", $a_target_node_id = 
"")
 
  523        $parent_id = ($a_parent_id != 
"")
 
  525            : $skill_tree->getRootId();
 
  530            "skrt" => array(
"skll", 
"scat", 
"sktr", 
"sktp", 
"sctp"),
 
  531            "scat" => array(
"skll", 
"scat", 
"sktr"),
 
  532            "sctp" => array(
"sktp", 
"sctp"));
 
  534        if (!is_array($allowed[$par_type]) ||
 
  535            !in_array($a_obj->getType(), $allowed[$par_type])) {
 
  540        if ($a_target_node_id != 
"") {
 
  541            $target = $a_target_node_id;
 
  544            $childs = $skill_tree->getChilds($parent_id);
 
  546            if (count($childs) == 0) {
 
  549                $target = $childs[count($childs) - 1][
"obj_id"];
 
  553        if ($skill_tree->isInTree($parent_id) && !$skill_tree->isInTree($a_obj->getId())) {
 
  554            $skill_tree->insertNode($a_obj->getId(), $parent_id, $target);
 
  578        if (is_array($a_items)) {
 
  579            foreach ($a_items as $item) {
 
  585        if (count($types) > 1) {
 
  597        include_once(
"./Services/Skill/classes/class.ilSkillTree.php");
 
  600        if (!is_array($a_ids)) {
 
  604            foreach ($a_ids as 
$id) {
 
  605                $path = $tree->getPathId(
$id);
 
  607                foreach ($path as $path_id) {
 
  608                    if ($path_id != 
$id && in_array($path_id, $a_ids)) {
 
  623        foreach ($cut_ids as 
$id) {
 
  624            $curnode = $tree->getNodeData(
$id);
 
  625            if ($tree->isInTree(
$id)) {
 
  626                $tree->deleteTree($curnode);
 
  642        include_once(
"./Services/Skill/classes/class.ilSkillTree.php");
 
  646        $time = date(
"Y-m-d H:i:s", time());
 
  647        foreach ($a_ids as 
$id) {
 
  649            if ($tree->isInTree(
$id)) {
 
  650                $curnode = $tree->getNodeData(
$id);
 
  651                $subnodes = $tree->getSubTree($curnode);
 
  652                foreach ($subnodes as $subnode) {
 
  653                    if ($subnode[
"child"] != 
$id) {
 
  665            $order = ($curnode[
"lft"] > 0)
 
  667                : (
int) ($order + 1);
 
  691        include_once(
"./Modules/LearningModule/classes/class.ilEditClipboard.php");
 
  693        include_once(
"./Services/Skill/classes/class.ilSkillTree.php");
 
  696        $parent_id = $a_obj_id;
 
  701        $copied_nodes = array();
 
  702        foreach ($skills as $skill) {
 
  704            if (!in_array($skill[
"id"], array_keys($copied_nodes))) {
 
  709                    $skill[
"insert_time"],
 
  726            in_array(
$a_type, array(
"sktp", 
"sctp"))
 
  729        return $copied_nodes;
 
  744        $ilUser->clipboardDeleteObjectsOfType(
"skll");
 
  745        $ilUser->clipboardDeleteObjectsOfType(
"scat");
 
  746        $ilUser->clipboardDeleteObjectsOfType(
"sktr");
 
  747        $ilUser->clipboardDeleteObjectsOfType(
"sktp");
 
  748        $ilUser->clipboardDeleteObjectsOfType(
"sctp");
 
  749        include_once(
"./Modules/LearningModule/classes/class.ilEditClipboard.php");
 
  764        $a_add_suffix = 
false 
  774        if ($item_type == 
"scat") {
 
  775            include_once(
"./Services/Skill/classes/class.ilSkillCategory.php");
 
  777        } elseif ($item_type == 
"skll") {
 
  778            include_once(
"./Services/Skill/classes/class.ilBasicSkill.php");
 
  780        } elseif ($item_type == 
"sktr") {
 
  781            include_once(
"./Services/Skill/classes/class.ilSkillTemplateReference.php");
 
  783        } elseif ($item_type == 
"sktp") {
 
  784            include_once(
"./Services/Skill/classes/class.ilBasicSkillTemplate.php");
 
  786        } elseif ($item_type == 
"sctp") {
 
  787            include_once(
"./Services/Skill/classes/class.ilSkillTemplateCategory.php");
 
  791        $ilLog->write(
"Getting from clipboard type " . $item_type . 
", " .
 
  792            "Item ID: " . $a_item_id);
 
  795            $target_item = $item->copy();
 
  797                $target_item->setTitle($target_item->getTitle() . 
" " . 
$lng->txt(
"copy_of_suffix"));
 
  798                $target_item->update();
 
  800            $a_copied_nodes[$item->getId()] = $target_item->getId();
 
  802            $target_item = $item;
 
  805        $ilLog->write(
"Putting into skill tree type " . $target_item->getType() .
 
  806            "Item ID: " . $target_item->getId() . 
", Parent: " . $a_parent_id . 
", " .
 
  807            "Target: " . $a_target);
 
  811        $childs = 
$ilUser->getClipboardChilds($item->getId(), $a_insert_time);
 
  813        foreach ($childs as $child) {
 
  816                $target_item->getId(),
 
  824        return $target_item->getId();
 
  836        if ($skill_tree->isInTree($a_id)) {
 
  855            "SELECT obj_id, title FROM skl_tree_node WHERE " .
 
  856            " self_eval = " . 
$ilDB->quote(
true, 
"integer") . 
" ORDER BY TITLE " 
  859        while ($rec = 
$ilDB->fetchAssoc($set)) {
 
  860            $nodes[$rec[
"obj_id"]] = $rec[
"title"];
 
  874        $childs = $tr->getChildsByTypeFilter($tr->getRootId(), array(
"sktp", 
"sctp"));
 
  892            "SELECT * FROM skl_tree_node " .
 
  893            " WHERE self_eval = " . 
$ilDB->quote(1, 
"integer")
 
  896        $sel_skills = array();
 
  897        while ($rec = 
$ilDB->fetchAssoc($set)) {
 
  898            $sel_skills[] = $rec;
 
  910    public static function saveChildsOrder($a_par_id, $a_childs_order, $a_templates = 
false)
 
  912        include_once(
"./Services/Skill/classes/class.ilSkillTree.php");
 
  915        if ($a_par_id != $skill_tree->readRootId()) {
 
  916            $childs = $skill_tree->getChilds($a_par_id);
 
  919                $childs = $skill_tree->getChildsByTypeFilter(
 
  921                    array(
"skrt", 
"sktp", 
"sctp")
 
  924                $childs = $skill_tree->getChildsByTypeFilter(
 
  926                    array(
"skrt", 
"skll", 
"scat", 
"sktr")
 
  931        foreach ($childs as $k => 
$c) {
 
  932            if (isset($a_childs_order[
$c[
"child"]])) {
 
  933                $childs[$k][
"order_nr"] = (int) $a_childs_order[
$c[
"child"]];
 
  940        foreach ($childs as 
$c) {
 
  957        if ($a_status == self::STATUS_DRAFT && 
$a_type == 
"sctp") {
 
  960        if ($a_status == self::STATUS_DRAFT && 
$a_type == 
"sktp") {
 
  968        $a_name = 
"icon_" . 
$a_type . $a_size . $off . 
".svg";
 
  970            include_once(
"./Services/Skill/classes/class.ilSkillTemplateReference.php");
 
  973            if (
$type == 
"sctp") {
 
  974                $a_name = 
"icon_sctr" . $a_size . $off . 
".svg";
 
  977        $vers = 
"vers=" . str_replace(array(
".", 
" "), 
"-", 
ILIAS_VERSION);
 
  994        $candidates = array();
 
  999            " FROM skl_tree_node" .
 
 1000            " WHERE " . 
$ilDB->like(
"title", 
"text", 
"%" . $a_term . 
"%");
 
 1001        $sql .= 
" ORDER BY title";
 
 1002        $set = 
$ilDB->query($sql);
 
 1003        include_once(
"./Services/Skill/classes/class.ilSkillTemplateReference.php");
 
 1004        while ($row = 
$ilDB->fetchAssoc($set)) {
 
 1005            if (in_array($row[
"type"], array(
"sctp", 
"sktp"))) {
 
 1007                $path = $skill_tree->getSkillTreePath($row[
"obj_id"]);
 
 1008                if ($path[1][
"child"] != $row[
"obj_id"]) {
 
 1010                    foreach ($trefs as $tref) {
 
 1011                        $candidates[] = array(
"tref_id" => $tref, 
"skill_id" => $row[
"obj_id"], 
"title" => $row[
"title"]);
 
 1014            } elseif ($row[
"type"] == 
"sktr") {
 
 1019                $candidates[] = array(
"tref_id" => 0, 
"skill_id" => $row[
"obj_id"], 
"title" => $row[
"title"]);
 
 1023        foreach ($candidates as 
$c) {
 
 1025            $path = $skill_tree->getSkillTreePath(
$c[
"skill_id"], 
$c[
"tref_id"]);
 
 1027            if (is_array($path) && count($path) > 0) {
 
 1032            if (is_array($path)) {
 
 1033                foreach ($path as $p) {
 
 1034                    if ($p[
"status"] > 0) {
 
 1040                if (!in_array(
$c[
"title"], 
$res)) {
 
 1058        include_once(
"./Services/Skill/classes/class.ilSkillTemplateReference.php");
 
 1059        $cskill_ids = array();
 
 1060        foreach ($a_node_ids as 
$id) {
 
 1061            if (in_array(self::_lookupType(
$id), array(
"skll", 
"scat", 
"sktr"))) {
 
 1068                $cskill_ids[] = array(
"skill_id" => $skill_id, 
"tref_id" => $tref_id);
 
 1072                    $cskill_ids[] = array(
"skill_id" => 
$id, 
"tref_id" => $tref_id);
 
An exception for terminatinating execution or to throw for unit testing.
Skill Template Reference.
static _lookupTrefIdsForTemplateId($a_tid)
Get all tref ids for a template id.
static _lookupTrefIdsForTopTemplateId($a_template_id)
Lookup tref ids for template id.
static _lookupTemplateId($a_obj_id)
Lookup template ID.
A node in the skill tree.
static isInTree($a_id)
Is id in tree?
static _writeTitle($a_obj_id, $a_title)
Write Title.
static getIconPath($a_obj_id, $a_type, $a_size="", $a_status=0)
Get icon path.
static putInTree($a_obj, $a_parent_id="", $a_target_node_id="")
Put this object into the skill tree.
static uniqueTypesCheck($a_items)
Check for unique types.
setTitle($a_title)
Set title.
getDescription()
Get description.
static getStatusInfo($a_status)
Get status info.
static _lookupStatus($a_obj_id)
Lookup Status.
static saveChildsOrder($a_par_id, $a_childs_order, $a_templates=false)
Save childs order.
static insertItemsFromClip($a_type, $a_obj_id)
Insert basic skills from clipboard.
static getAllStatus()
Get all status.
static findSkills($a_term)
Find skills.
static getTopTemplates()
Get top skill templates and template categories.
static clipboardCopy($a_tree_id, $a_ids)
Copy a set of skills/skill categories into the clipboard.
setCreationDate($a_val)
Set creation date.
setOrderNr($a_val)
Set order nr.
static _lookupSelfEvaluation($a_obj_id)
Lookup self evaluation.
static _lookupTitle($a_obj_id, $a_tref_id=0)
Lookup Title.
static _writeDescription($a_obj_id, $a_description)
Write Description.
setDescription($a_description)
Set description.
static clearClipboard()
Remove all skill items from clipboard.
static pasteTree( $a_item_id, $a_parent_id, $a_target, $a_insert_time, &$a_copied_nodes, $a_as_copy=false, $a_add_suffix=false)
Paste item (tree) from clipboard to skill tree.
getCreationDate()
Get creation date.
setType($a_type)
Set type.
static _lookup($a_obj_id, $a_field)
Lookup Title.
static getTree($a_slm_obj_id)
Get scorm module editing tree.
static clipboardCut($a_tree_id, $a_ids)
Cut and copy a set of skills/skill categories into the clipboard.
static getAllSelfEvaluationNodes()
Get all self evaluation nodes.
getOrderNr()
Get order nr.
static getSelectableSkills()
Get selectable skills.
static _writeOrderNr($a_obj_id, $a_nr)
Write Order Nr.
setDataRecord($a_record)
this method should only be called by class ilSCORM2004NodeFactory
setStatus($a_val)
Set status.
setSelfEvaluation($a_val)
Set self evaluation.
static _lookupDescription($a_obj_id)
Lookup Description.
getImportId()
Get import id.
static getAllCSkillIdsForNodeIds(array $a_node_ids)
Get all possible common skill IDs for node IDs.
static _lookupType($a_obj_id)
Lookup Type.
getSelfEvaluation()
Get self evaluation.
setImportId($a_val)
Set import id.
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
foreach($_POST as $key=> $value) $res