6 require_once(
"./Services/MetaData/classes/class.ilMDLanguageItem.php");
32 $this->
setSLMId($a_slm_object->getId());
34 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Tree.php");
53 $this->title = $a_title;
73 $this->description = $a_description;
83 return $this->description;
93 $this->type = $a_type;
113 $this->slm_id = $a_slm_id;
134 $this->slm_object = $a_slm_obj;
184 return $this->import_id;
194 $this->import_id = $a_id;
204 if(!isset($this->data_record))
206 $query =
"SELECT * FROM sahs_sc13_tree_node WHERE obj_id = ".
207 $ilDB->quote($this->
id,
"integer");
208 $obj_set = $ilDB->query(
$query);
209 $this->data_record = $ilDB->fetchAssoc($obj_set);
212 $this->type = $this->data_record[
"type"];
213 $this->
setImportId($this->data_record[
"import_id"]);
214 $this->
setTitle($this->data_record[
"title"]);
230 include_once
'Services/MetaData/classes/class.ilMD.php';
238 $md_gen = $md->getGeneral();
242 foreach($md_gen->getDescriptionIds() as
$id)
244 $md_des = $md_gen->getDescription(
$id);
264 include_once
'Services/MetaData/classes/class.ilMDCreator.php';
266 $md_creator->setTitle($this->
getTitle());
267 $md_creator->setTitleLanguage($ilUser->getPref(
'language'));
269 $md_creator->setDescriptionLanguage($ilUser->getPref(
'language'));
270 $md_creator->setKeywordLanguage($ilUser->getPref(
'language'));
271 $md_creator->setLanguage($ilUser->getPref(
'language'));
272 $md_creator->create();
282 include_once(
"Services/MetaData/classes/class.ilMD.php");
283 include_once(
"Services/MetaData/classes/class.ilMDGeneral.php");
284 include_once(
"Services/MetaData/classes/class.ilMDDescription.php");
287 $md_gen = $md->getGeneral();
288 $md_gen->setTitle($this->
getTitle());
291 $md_des_ids = $md_gen->getDescriptionIds();
292 if (count($md_des_ids) > 0)
294 $md_des =& $md_gen->getDescription($md_des_ids[0]);
308 include_once(
'Services/MetaData/classes/class.ilMD.php');
318 $this->data_record = $a_record;
331 $query =
"SELECT * FROM sahs_sc13_tree_node WHERE obj_id = ".
332 $ilDB->quote($a_obj_id,
"integer");
333 $obj_set = $ilDB->query(
$query);
334 $obj_rec = $ilDB->fetchAssoc($obj_set);
336 return $obj_rec[
"title"];
349 $query =
"SELECT * FROM sahs_sc13_tree_node WHERE obj_id = ".
350 $ilDB->quote($a_obj_id,
"integer");
351 $obj_set = $ilDB->query(
$query);
352 $obj_rec = $ilDB->fetchAssoc($obj_set);
354 return $obj_rec[
"type"];
367 $query =
"UPDATE sahs_sc13_tree_node SET ".
368 " title = ".$ilDB->quote($a_title,
"text").
369 " WHERE obj_id = ".$ilDB->quote($a_obj_id,
"integer");
370 $ilDB->manipulate(
$query);
383 $q =
"UPDATE sahs_sc13_tree_node ".
385 "import_id = ".$ilDB->quote($a_import_id,
"text").
",".
386 "last_update = ".$ilDB->now().
387 "WHERE obj_id = ".$ilDB->quote($a_id,
"integer");
389 $ilDB->manipulate($q);
402 $id = $ilDB->nextId(
"sahs_sc13_tree_node");
403 $query =
"INSERT INTO sahs_sc13_tree_node (obj_id, title, type, slm_id, import_id, create_date) ".
405 $ilDB->quote(
$id,
"integer").
",".
406 $ilDB->quote($this->
getTitle(),
"text").
",".
407 $ilDB->quote($this->
getType(),
"text").
", ".
408 $ilDB->quote($this->
getSLMId(),
"integer").
",".
410 ", ".$ilDB->now().
")";
411 $ilDB->manipulate(
$query);
429 $query =
"UPDATE sahs_sc13_tree_node SET ".
430 " slm_id = ".$ilDB->quote($this->
getSLMId(),
"integer").
431 " ,title = ".$ilDB->quote($this->
getTitle(),
"text").
432 " WHERE obj_id = ".$ilDB->quote($this->
getId(),
"integer");
434 $ilDB->manipulate(
$query);
444 $query =
"DELETE FROM sahs_sc13_tree_node WHERE obj_id= ".
445 $ilDB->quote($this->
getId(),
"integer");
446 $ilDB->manipulate(
$query);
467 $q =
"SELECT * FROM sahs_sc13_tree_node WHERE import_id = ".
468 $ilDB->quote($a_import_id,
"text").
" ".
469 " ORDER BY create_date DESC";
470 $obj_set = $ilDB->query($q);
471 while ($obj_rec = $ilDB->fetchAssoc($obj_set))
478 return $obj_rec[
"obj_id"];
496 include_once(
"./Services/COPage/classes/class.ilInternalLink.php");
497 if (is_int(strpos($a_id,
"_")))
502 $q =
"SELECT * FROM sahs_sc13_tree_node WHERE obj_id = ".
503 $ilDB->quote($a_id,
"integer");
504 $obj_set = $ilDB->query($q);
505 if ($obj_rec = $ilDB->fetchAssoc($obj_set))
526 $query =
"SELECT * FROM sahs_sc13_tree_node ".
527 "WHERE slm_id = ".$ilDB->quote($a_slm_object->getId(),
"integer").
" ";
528 $obj_set = $ilDB->query(
$query);
530 require_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004NodeFactory.php");
531 while($obj_rec = $ilDB->fetchAssoc($obj_set))
535 if (is_object($node_obj))
551 $query =
"SELECT * FROM sahs_sc13_tree_node WHERE obj_id = ".
552 $ilDB->quote($a_id,
"integer").
"";
553 $obj_set = $ilDB->query(
$query);
554 $obj_rec = $ilDB->fetchAssoc($obj_set);
556 return $obj_rec[
"slm_id"];
562 static function putInTree($a_obj, $a_parent_id =
"", $a_target_node_id =
"")
564 $tree =&
new ilTree($a_obj->getSLMId());
566 $tree->setTableNames(
'sahs_sc13_tree',
'sahs_sc13_tree_node');
569 $parent_id = ($a_parent_id !=
"")
571 : $tree->getRootId();
574 if ($a_target_node_id !=
"")
576 $target = $a_target_node_id;
581 $childs =& $tree->getChilds($parent_id);
583 if (count($childs) == 0)
589 $target = $childs[count($childs) - 1][
"obj_id"];
593 if ($tree->isInTree($parent_id) && !$tree->isInTree($a_obj->getId()))
595 $tree->insertNode($a_obj->getId(), $parent_id, $target);
608 $tree =
new ilTree($a_slm_obj_id);
609 $tree->setTableNames(
'sahs_sc13_tree',
'sahs_sc13_tree_node');
610 $tree->setTreeTablePK(
"slm_id");
625 $ilUser->clipboardDeleteObjectsOfType(
"page");
626 $ilUser->clipboardDeleteObjectsOfType(
"chap");
627 $ilUser->clipboardDeleteObjectsOfType(
"sco");
628 $ilUser->clipboardDeleteObjectsOfType(
"ass");
631 $time = date(
"Y-m-d H:i:s", time());
632 foreach ($a_ids as
$id)
635 if ($tree->isInTree($id))
637 $curnode = $tree->getNodeData($id);
638 $subnodes = $tree->getSubTree($curnode);
639 foreach($subnodes as $subnode)
641 if ($subnode[
"child"] != $id)
643 $ilUser->addObjectToClipboard($subnode[
"child"],
644 $subnode[
"type"], $subnode[
"title"],
645 $subnode[
"parent"], $time, $subnode[
"lft"]);
649 $order = ($curnode[
"lft"] > 0)
651 : (
int) ($order + 1);
652 $ilUser->addObjectToClipboard($id,
665 if (!is_array($a_ids))
672 foreach($a_ids as
$id)
674 $path = $tree->getPathId($id);
676 foreach(
$path as $path_id)
678 if ($path_id != $id && in_array($path_id, $a_ids))
695 foreach ($cut_ids as
$id)
697 $curnode = $tree->getNodeData($id);
698 if ($tree->isInTree($id))
700 $tree->deleteTree($curnode);
712 if (is_array($a_items))
714 foreach($a_items as $item)
721 if (count($types) > 1)
736 include_once(
"./Modules/LearningModule/classes/class.ilEditClipboard.php");
738 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004OrganizationHFormGUI.php");
746 $parent_id = $tree->getParentId($node_id);
751 $parent_id = $node_id;
756 $pages = $ilUser->getClipboardObjects(
"page");
757 $copied_nodes = array();
758 foreach ($pages as $pg)
761 $pg[
"insert_time"], $copied_nodes,
769 $ilUser->clipboardDeleteObjectsOfType(
"page");
770 $ilUser->clipboardDeleteObjectsOfType(
"chap");
771 $ilUser->clipboardDeleteObjectsOfType(
"sco");
772 $ilUser->clipboardDeleteObjectsOfType(
"ass");
785 include_once(
"./Modules/LearningModule/classes/class.ilEditClipboard.php");
787 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004OrganizationHFormGUI.php");
795 $parent_id = $tree->getParentId($node_id);
800 $parent_id = $node_id;
805 $scos = $ilUser->getClipboardObjects($a_type);
806 $copied_nodes = array();
807 foreach ($scos as $sco)
810 $sco[
"insert_time"], $copied_nodes,
818 $ilUser->clipboardDeleteObjectsOfType(
"page");
819 $ilUser->clipboardDeleteObjectsOfType(
"chap");
820 $ilUser->clipboardDeleteObjectsOfType(
"sco");
821 $ilUser->clipboardDeleteObjectsOfType(
"ass");
843 include_once(
"./Modules/LearningModule/classes/class.ilEditClipboard.php");
845 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004OrganizationHFormGUI.php");
855 $parent_id = $node_id;
867 $parent_id = $tree->getParentId($node_id);
872 $parent_id = $node_id;
876 $childs = $tree->getChildsByType($parent_id,
"sco");
877 if (count($childs) != 0)
879 $target = $childs[count($childs) - 1][
"obj_id"];
885 $chapters = $ilUser->getClipboardObjects(
"chap",
true);
886 $copied_nodes = array();
887 foreach ($chapters as $chap)
890 $target, $chap[
"insert_time"], $copied_nodes,
898 $ilUser->clipboardDeleteObjectsOfType(
"page");
899 $ilUser->clipboardDeleteObjectsOfType(
"chap");
900 $ilUser->clipboardDeleteObjectsOfType(
"sco");
901 $ilUser->clipboardDeleteObjectsOfType(
"ass");
918 static function pasteTree($a_target_slm, $a_item_id, $a_parent_id, $a_target, $a_insert_time,
919 &$a_copied_nodes, $a_as_copy =
false, $a_from_clipboard =
true)
927 include_once(
"./Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModule.php");
930 if ($item_type ==
"chap")
932 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Chapter.php");
935 else if ($item_type ==
"page")
937 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004PageNode.php");
940 else if ($item_type ==
"sco")
942 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Sco.php");
945 else if ($item_type ==
"ass")
947 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Asset.php");
951 $ilLog->write(
"Getting from clipboard type ".$item_type.
", ".
952 "Item ID: ".$a_item_id.
", of original SLM: ".$item_slm_id);
954 if ($item_slm_id != $a_target_slm->getId() && !$a_as_copy)
959 include_once(
"Services/MetaData/classes/class.ilMD.php");
960 $md =
new ilMD($item_slm_id, $item->getId(), $item->getType());
961 $new_md = $md->
cloneMD($a_target_slm->getId(), $item->getId(), $item->getType());
964 $item->setSLMId($a_target_slm->getId());
965 $item->setSLMObject($a_target_slm);
971 if ($item_type ==
"page")
973 $page = $item->getPageObject();
974 $page->buildDom($a_from_clipboard);
975 $page->setParentId($a_target_slm->getId());
982 $target_item = $item->copy($a_target_slm);
983 $a_copied_nodes[$item->getId()] = $target_item->getId();
987 $target_item = $item;
990 $ilLog->write(
"Putting into tree type ".$target_item->getType().
991 "Item ID: ".$target_item->getId().
", Parent: ".$a_parent_id.
", ".
992 "Target: ".$a_target.
", Item LM:".$target_item->getContentObject()->getId());
996 if ($a_from_clipboard)
998 $childs = $ilUser->getClipboardChilds($item->getId(), $a_insert_time);
1003 $source_tree = $slm_obj->getTree();
1004 $childs = $source_tree->getChilds($a_item_id);
1007 foreach($childs as $child)
1009 $child_id = ($a_from_clipboard)
1013 IL_LAST_NODE, $a_insert_time, $a_copied_nodes, $a_as_copy, $a_from_clipboard);
1016 return $target_item->getId();
1024 include_once(
"./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004Objective.php");
1030 include_once(
"./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004Item.php");
1032 $seq_item ->
delete();
1037 include_once(
"./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004Utilities.php");