5 include_once(
"./Services/Skill/classes/class.ilSkillTree.php");
43 $this->title = $a_title;
63 $this->type = $a_type;
103 $this->self_eval = $a_val;
113 return $this->self_eval;
123 $this->order_nr = $a_val;
133 return $this->order_nr;
143 if(!isset($this->data_record))
145 $query =
"SELECT * FROM skl_tree_node WHERE obj_id = ".
146 $ilDB->quote($this->
id,
"integer");
147 $obj_set = $ilDB->query(
$query);
148 $this->data_record = $ilDB->fetchAssoc($obj_set);
150 $this->
setType($this->data_record[
"type"]);
151 $this->
setTitle($this->data_record[
"title"]);
152 $this->
setOrderNr($this->data_record[
"order_nr"]);
154 $this->
setDraft($this->data_record[
"draft"]);
162 $this->data_record = $a_record;
171 protected static function _lookup($a_obj_id, $a_field)
175 $query =
"SELECT $a_field FROM skl_tree_node WHERE obj_id = ".
176 $ilDB->quote($a_obj_id,
"integer");
177 $obj_set = $ilDB->query(
$query);
178 $obj_rec = $ilDB->fetchAssoc($obj_set);
180 return $obj_rec[$a_field];
232 $query =
"SELECT * FROM skl_tree_node WHERE obj_id = ".
233 $ilDB->quote($a_obj_id,
"integer");
234 $obj_set = $ilDB->query(
$query);
235 $obj_rec = $ilDB->fetchAssoc($obj_set);
237 return $obj_rec[
"type"];
247 $this->draft = $a_val;
270 $query =
"UPDATE skl_tree_node SET ".
271 " title = ".$ilDB->quote($a_title,
"text").
272 " WHERE obj_id = ".$ilDB->quote($a_obj_id,
"integer");
274 $ilDB->manipulate(
$query);
287 $query =
"UPDATE skl_tree_node SET ".
288 " order_nr = ".$ilDB->quote($a_nr,
"integer").
289 " WHERE obj_id = ".$ilDB->quote($a_obj_id,
"integer");
290 $ilDB->manipulate(
$query);
303 $id = $ilDB->nextId(
"skl_tree_node");
304 $query =
"INSERT INTO skl_tree_node (obj_id, title, type, create_date, self_eval, order_nr, draft) ".
306 $ilDB->quote(
$id,
"integer").
",".
307 $ilDB->quote($this->
getTitle(),
"text").
",".
308 $ilDB->quote($this->
getType(),
"text").
", ".
311 $ilDB->quote((
int) $this->
getOrderNr(),
"integer").
", ".
312 $ilDB->quote((
int) $this->
getDraft(),
"integer").
314 $ilDB->manipulate(
$query);
325 $query =
"UPDATE skl_tree_node SET ".
326 " title = ".$ilDB->quote($this->
getTitle(),
"text").
328 " ,order_nr = ".$ilDB->quote((
int) $this->
getOrderNr(),
"integer").
329 " ,draft = ".$ilDB->quote((
int) $this->
getDraft(),
"integer").
330 " WHERE obj_id = ".$ilDB->quote($this->
getId(),
"integer");
332 $ilDB->manipulate(
$query);
342 $query =
"DELETE FROM skl_tree_node WHERE obj_id= ".
343 $ilDB->quote($this->
getId(),
"integer");
344 $ilDB->manipulate(
$query);
350 static function putInTree($a_obj, $a_parent_id =
"", $a_target_node_id =
"")
355 $parent_id = ($a_parent_id !=
"")
357 : $skill_tree->getRootId();
362 "skrt" => array(
"skll",
"scat",
"sktr",
"sktp",
"sctp"),
363 "scat" => array(
"skll",
"scat",
"sktr"),
364 "sctp" => array(
"sktp",
"sctp"));
366 if (!is_array($allowed[$par_type]) ||
367 !in_array($a_obj->getType(), $allowed[$par_type]))
373 if ($a_target_node_id !=
"")
375 $target = $a_target_node_id;
380 $childs = $skill_tree->getChilds($parent_id);
382 if (count($childs) == 0)
388 $target = $childs[count($childs) - 1][
"obj_id"];
392 if ($skill_tree->isInTree($parent_id) && !$skill_tree->isInTree($a_obj->getId()))
394 $skill_tree->insertNode($a_obj->getId(), $parent_id, $target);
418 if (is_array($a_items))
420 foreach($a_items as $item)
427 if (count($types) > 1)
440 include_once(
"./Services/Skill/classes/class.ilSkillTree.php");
443 if (!is_array($a_ids))
450 foreach($a_ids as
$id)
452 $path = $tree->getPathId($id);
454 foreach(
$path as $path_id)
456 if ($path_id != $id && in_array($path_id, $a_ids))
473 foreach ($cut_ids as
$id)
475 $curnode = $tree->getNodeData($id);
476 if ($tree->isInTree($id))
478 $tree->deleteTree($curnode);
493 include_once(
"./Services/Skill/classes/class.ilSkillTree.php");
497 $time = date(
"Y-m-d H:i:s", time());
498 foreach ($a_ids as
$id)
501 if ($tree->isInTree($id))
503 $curnode = $tree->getNodeData($id);
504 $subnodes = $tree->getSubTree($curnode);
505 foreach($subnodes as $subnode)
507 if ($subnode[
"child"] != $id)
509 $ilUser->addObjectToClipboard($subnode[
"child"],
510 $subnode[
"type"], $subnode[
"title"],
511 $subnode[
"parent"], $time, $subnode[
"lft"]);
515 $order = ($curnode[
"lft"] > 0)
517 : (
int) ($order + 1);
518 $ilUser->addObjectToClipboard($id,
533 include_once(
"./Modules/LearningModule/classes/class.ilEditClipboard.php");
535 include_once(
"./Services/Skill/classes/class.ilSkillTree.php");
538 $parent_id = $a_obj_id;
542 $skills = $ilUser->getClipboardObjects($a_type);
543 $copied_nodes = array();
544 foreach ($skills as $skill)
547 if(!in_array($skill[
"id"], array_keys($copied_nodes)))
550 $skill[
"insert_time"], $copied_nodes,
562 in_array($a_type, array(
"sktp",
"sctp")));
564 return $copied_nodes;
577 $ilUser->clipboardDeleteObjectsOfType(
"skll");
578 $ilUser->clipboardDeleteObjectsOfType(
"scat");
579 $ilUser->clipboardDeleteObjectsOfType(
"sktr");
580 $ilUser->clipboardDeleteObjectsOfType(
"sktp");
581 $ilUser->clipboardDeleteObjectsOfType(
"sctp");
582 include_once(
"./Modules/LearningModule/classes/class.ilEditClipboard.php");
590 static function pasteTree($a_item_id, $a_parent_id, $a_target, $a_insert_time,
591 &$a_copied_nodes, $a_as_copy =
false, $a_add_suffix =
false)
597 if ($item_type ==
"scat")
599 include_once(
"./Services/Skill/classes/class.ilSkillCategory.php");
602 else if ($item_type ==
"skll")
604 include_once(
"./Services/Skill/classes/class.ilBasicSkill.php");
607 else if ($item_type ==
"sktr")
609 include_once(
"./Services/Skill/classes/class.ilSkillTemplateReference.php");
612 else if ($item_type ==
"sktp")
614 include_once(
"./Services/Skill/classes/class.ilBasicSkillTemplate.php");
617 else if ($item_type ==
"sctp")
619 include_once(
"./Services/Skill/classes/class.ilSkillTemplateCategory.php");
623 $ilLog->write(
"Getting from clipboard type ".$item_type.
", ".
624 "Item ID: ".$a_item_id);
628 $target_item = $item->copy();
631 $target_item->setTitle($target_item->getTitle().
" ".$lng->txt(
"copy_of_suffix"));
632 $target_item->update();
634 $a_copied_nodes[$item->getId()] = $target_item->getId();
638 $target_item = $item;
641 $ilLog->write(
"Putting into skill tree type ".$target_item->getType().
642 "Item ID: ".$target_item->getId().
", Parent: ".$a_parent_id.
", ".
643 "Target: ".$a_target);
647 $childs = $ilUser->getClipboardChilds($item->getId(), $a_insert_time);
649 foreach($childs as $child)
652 IL_LAST_NODE, $a_insert_time, $a_copied_nodes, $a_as_copy);
655 return $target_item->getId();
667 if ($skill_tree->isInTree($a_id))
684 $set = $ilDB->query(
"SELECT obj_id, title FROM skl_tree_node WHERE ".
685 " self_eval = ".$ilDB->quote(
true,
"integer").
" ORDER BY TITLE "
688 while ($rec = $ilDB->fetchAssoc($set))
690 $nodes[$rec[
"obj_id"]] = $rec[
"title"];
704 $childs = $tr->getChildsByTypeFilter($tr->getRootId(), array(
"sktp",
"sctp"));
719 $set = $ilDB->query(
"SELECT * FROM skl_tree_node ".
720 " WHERE self_eval = ".$ilDB->quote(1,
"integer")
723 $sel_skills = array();
724 while ($rec = $ilDB->fetchAssoc($set))
726 $sel_skills[] = $rec;
744 include_once(
"./Services/Skill/classes/class.ilSkillTemplateReference.php");
745 include_once(
"./Services/Skill/classes/class.ilSkillTree.php");
748 if ($stree->isInTree($a_node_id))
750 $cnode = $stree->getNodeData($a_node_id);
753 if ($cnode[
"type"] ==
"skll" || !$a_only_basic)
755 $skills[] = array(
"id" => $a_node_id,
756 "type" => $cnode[
"type"],
"parent" => $cnode[
"parent"],
761 if ($cnode[
"type"] ==
"sktr")
764 if ($tr_ref->getSkillTemplateId() > 0)
766 $cnode2 = $stree->getNodeData($tr_ref->getSkillTemplateId());
767 if ($cnode2[
"child"] > 0)
769 $childs2 = $stree->getSubTree($cnode2);
770 foreach ($childs2 as $child2)
773 if ($child2[
"type"] ==
"sktp" || !$a_only_basic)
775 $par = ($tr_ref->getSkillTemplateId() == $child2[
"child"])
778 $skills[] = array(
"id" => $child2[
"child"],
779 "type" => $child2[
"type"],
"parent" => $par,
780 "tref" => $cnode[
"child"]);
788 $childs = $stree->getSubTree($cnode);
789 foreach ($childs as $child)
792 if($child[
"child"] == $cnode[
"child"])
798 if ($child[
"type"] ==
"skll" || !$a_only_basic)
800 $skills[] = array(
"id" => $child[
"child"],
801 "type" => $child[
"type"],
"parent" => $child[
"parent"],
806 if ($child[
"type"] ==
"sktr")
809 $cnode2 = $stree->getNodeData($tr_ref->getSkillTemplateId());
810 if ($tr_ref->getSkillTemplateId() > 0)
812 if ($cnode2[
"child"] > 0)
814 $childs2 = $stree->getSubTree($cnode2);
815 foreach ($childs2 as $child2)
817 $par = ($tr_ref->getSkillTemplateId() == $child2[
"child"])
821 if ($child2[
"type"] ==
"sktp" || !$a_only_basic)
823 $skills[] = array(
"id" => $child2[
"child"],
824 "type" => $child2[
"type"],
"parent" => $par,
825 "tref" => $child[
"child"]);
847 include_once(
"./Services/Skill/classes/class.ilSkillTree.php");
850 if ($a_par_id != $skill_tree->readRootId())
852 $childs = $skill_tree->getChilds($a_par_id);
858 $childs = $skill_tree->getChildsByTypeFilter($a_par_id,
859 array(
"skrt",
"sktp",
"sctp"));
863 $childs = $skill_tree->getChildsByTypeFilter($a_par_id,
864 array(
"skrt",
"skll",
"scat",
"sktr"));
868 foreach ($childs as $k => $c)
870 if (isset($a_childs_order[$c[
"child"]]))
872 $childs[$k][
"order_nr"] = (int) $a_childs_order[$c[
"child"]];
879 foreach ($childs as $c)
892 function getIconPath($a_obj_id, $a_type, $a_size =
"", $a_draft =
false)
898 $a_name =
"icon_".$a_type.$a_size.$off.
".gif";
899 if ($a_type ==
"sktr")
901 include_once(
"./Services/Skill/classes/class.ilSkillTemplateReference.php");
906 $a_name =
"icon_sctr".$a_size.$off.
".gif";
909 $vers =
"vers=".str_replace(array(
".",
" "),
"-",
ILIAS_VERSION);