24 require_once(
"./Services/MetaData/classes/class.ilMDLanguageItem.php");
50 $this->
setSLMId($a_slm_object->getId());
52 $this->tree =
new ilTree($a_slm_object->getId());
53 $this->tree->
setTableNames(
'sahs_sc13_tree',
'sahs_sc13_tree_node');
54 $this->tree->setTreeTablePK(
"slm_id");
69 $this->title = $a_title;
89 $this->description = $a_description;
99 return $this->description;
109 $this->type = $a_type;
129 $this->slm_id = $a_slm_id;
150 $this->slm_object = $a_slm_obj;
200 return $this->import_id;
210 $this->import_id = $a_id;
220 if(!isset($this->data_record))
222 $query =
"SELECT * FROM sahs_sc13_tree_node WHERE obj_id = ".
223 $ilDB->quote($this->
id,
"integer");
224 $obj_set = $ilDB->query(
$query);
225 $this->data_record = $ilDB->fetchAssoc($obj_set);
228 $this->type = $this->data_record[
"type"];
229 $this->
setImportId($this->data_record[
"import_id"]);
230 $this->
setTitle($this->data_record[
"title"]);
246 include_once
'Services/MetaData/classes/class.ilMD.php';
254 $md_gen = $md->getGeneral();
258 foreach($md_gen->getDescriptionIds() as
$id)
260 $md_des = $md_gen->getDescription(
$id);
280 include_once
'Services/MetaData/classes/class.ilMDCreator.php';
282 $md_creator->setTitle($this->
getTitle());
283 $md_creator->setTitleLanguage($ilUser->getPref(
'language'));
285 $md_creator->setDescriptionLanguage($ilUser->getPref(
'language'));
286 $md_creator->setKeywordLanguage($ilUser->getPref(
'language'));
287 $md_creator->setLanguage($ilUser->getPref(
'language'));
288 $md_creator->create();
298 include_once(
"Services/MetaData/classes/class.ilMD.php");
299 include_once(
"Services/MetaData/classes/class.ilMDGeneral.php");
300 include_once(
"Services/MetaData/classes/class.ilMDDescription.php");
303 $md_gen = $md->getGeneral();
304 $md_gen->setTitle($this->
getTitle());
307 $md_des_ids = $md_gen->getDescriptionIds();
308 if (count($md_des_ids) > 0)
310 $md_des =& $md_gen->getDescription($md_des_ids[0]);
324 include_once(
'Services/MetaData/classes/class.ilMD.php');
334 $this->data_record = $a_record;
347 $query =
"SELECT * FROM sahs_sc13_tree_node WHERE obj_id = ".
348 $ilDB->quote($a_obj_id,
"integer");
349 $obj_set = $ilDB->query(
$query);
350 $obj_rec = $ilDB->fetchAssoc($obj_set);
352 return $obj_rec[
"title"];
365 $query =
"SELECT * FROM sahs_sc13_tree_node WHERE obj_id = ".
366 $ilDB->quote($a_obj_id,
"integer");
367 $obj_set = $ilDB->query(
$query);
368 $obj_rec = $ilDB->fetchAssoc($obj_set);
370 return $obj_rec[
"type"];
383 $query =
"UPDATE sahs_sc13_tree_node SET ".
384 " title = ".$ilDB->quote($a_title,
"text").
385 " WHERE obj_id = ".$ilDB->quote($a_obj_id,
"integer");
386 $ilDB->manipulate(
$query);
399 $q =
"UPDATE sahs_sc13_tree_node ".
401 "import_id = ".$ilDB->quote($a_import_id,
"text").
",".
402 "last_update = ".$ilDB->now().
403 "WHERE obj_id = ".$ilDB->quote($a_id,
"integer");
405 $ilDB->manipulate($q);
418 $id = $ilDB->nextId(
"sahs_sc13_tree_node");
419 $query =
"INSERT INTO sahs_sc13_tree_node (obj_id, title, type, slm_id, import_id, create_date) ".
421 $ilDB->quote(
$id,
"integer").
",".
422 $ilDB->quote($this->
getTitle(),
"text").
",".
423 $ilDB->quote($this->
getType(),
"text").
", ".
424 $ilDB->quote($this->
getSLMId(),
"integer").
",".
426 ", ".$ilDB->now().
")";
427 $ilDB->manipulate(
$query);
445 $query =
"UPDATE sahs_sc13_tree_node SET ".
446 " slm_id = ".$ilDB->quote($this->
getSLMId(),
"integer").
447 " ,title = ".$ilDB->quote($this->
getTitle(),
"text").
448 " WHERE obj_id = ".$ilDB->quote($this->
getId(),
"integer");
450 $ilDB->manipulate(
$query);
460 $query =
"DELETE FROM sahs_sc13_tree_node WHERE obj_id= ".
461 $ilDB->quote($this->
getId(),
"integer");
462 $ilDB->manipulate(
$query);
483 $q =
"SELECT * FROM sahs_sc13_tree_node WHERE import_id = ".
484 $ilDB->quote($a_import_id,
"text").
" ".
485 " ORDER BY create_date DESC";
486 $obj_set = $ilDB->query($q);
487 while ($obj_rec = $ilDB->fetchAssoc($obj_set))
494 return $obj_rec[
"obj_id"];
512 include_once(
"./Services/COPage/classes/class.ilInternalLink.php");
513 if (is_int(strpos($a_id,
"_")))
518 $q =
"SELECT * FROM sahs_sc13_tree_node WHERE obj_id = ".
519 $ilDB->quote($a_id,
"integer");
520 $obj_set = $ilDB->query($q);
521 if ($obj_rec = $ilDB->fetchAssoc($obj_set))
542 $query =
"SELECT * FROM sahs_sc13_tree_node ".
543 "WHERE slm_id = ".$ilDB->quote($a_slm_object->getId(),
"integer").
" ";
544 $obj_set = $ilDB->query(
$query);
546 require_once(
"./Modules/LearningModule/classes/class.ilScorm2004NodeFactory.php");
547 while($obj_rec = $ilDB->fetchAssoc($obj_set))
551 if (is_object($node_obj))
567 $query =
"SELECT * FROM sahs_sc13_tree_node WHERE obj_id = ".
568 $ilDB->quote($a_id,
"integer").
"";
569 $obj_set = $ilDB->query(
$query);
570 $obj_rec = $ilDB->fetchAssoc($obj_set);
572 return $obj_rec[
"slm_id"];
578 static function putInTree($a_obj, $a_parent_id =
"", $a_target_node_id =
"")
580 $tree =&
new ilTree($a_obj->getSLMId());
582 $tree->setTableNames(
'sahs_sc13_tree',
'sahs_sc13_tree_node');
585 $parent_id = ($a_parent_id !=
"")
587 : $tree->getRootId();
590 if ($a_target_node_id !=
"")
592 $target = $a_target_node_id;
597 $childs =& $tree->getChilds($parent_id);
599 if (count($childs) == 0)
605 $target = $childs[count($childs) - 1][
"obj_id"];
609 if ($tree->isInTree($parent_id) && !$tree->isInTree($a_obj->getId()))
611 $tree->insertNode($a_obj->getId(), $parent_id, $target);
624 $tree =
new ilTree($a_slm_obj_id);
625 $tree->setTableNames(
'sahs_sc13_tree',
'sahs_sc13_tree_node');
626 $tree->setTreeTablePK(
"slm_id");
641 $ilUser->clipboardDeleteObjectsOfType(
"page");
642 $ilUser->clipboardDeleteObjectsOfType(
"chap");
643 $ilUser->clipboardDeleteObjectsOfType(
"sco");
646 $time = date(
"Y-m-d H:i:s", time());
647 foreach ($a_ids as
$id)
650 if ($tree->isInTree($id))
652 $curnode = $tree->getNodeData($id);
653 $subnodes = $tree->getSubTree($curnode);
654 foreach($subnodes as $subnode)
656 if ($subnode[
"child"] != $id)
658 $ilUser->addObjectToClipboard($subnode[
"child"],
659 $subnode[
"type"], $subnode[
"title"],
660 $subnode[
"parent"], $time, $subnode[
"lft"]);
664 $order = ($curnode[
"lft"] > 0)
666 : (
int) ($order + 1);
667 $ilUser->addObjectToClipboard($id,
680 if (!is_array($a_ids))
687 foreach($a_ids as
$id)
689 $path = $tree->getPathId($id);
691 foreach(
$path as $path_id)
693 if ($path_id != $id && in_array($path_id, $a_ids))
710 foreach ($cut_ids as
$id)
712 $curnode = $tree->getNodeData($id);
713 if ($tree->isInTree($id))
715 $tree->deleteTree($curnode);
727 if (is_array($a_items))
729 foreach($a_items as $item)
736 if (count($types) > 1)
751 include_once(
"./Modules/LearningModule/classes/class.ilEditClipboard.php");
753 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004OrganizationHFormGUI.php");
761 $parent_id = $tree->getParentId($node_id);
766 $parent_id = $node_id;
771 $pages = $ilUser->getClipboardObjects(
"page");
772 $copied_nodes = array();
773 foreach ($pages as $pg)
776 $pg[
"insert_time"], $copied_nodes,
784 $ilUser->clipboardDeleteObjectsOfType(
"page");
785 $ilUser->clipboardDeleteObjectsOfType(
"chap");
786 $ilUser->clipboardDeleteObjectsOfType(
"sco");
799 include_once(
"./Modules/LearningModule/classes/class.ilEditClipboard.php");
801 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004OrganizationHFormGUI.php");
809 $parent_id = $tree->getParentId($node_id);
814 $parent_id = $node_id;
819 $scos = $ilUser->getClipboardObjects(
"sco");
820 $copied_nodes = array();
821 foreach ($scos as $sco)
824 $sco[
"insert_time"], $copied_nodes,
832 $ilUser->clipboardDeleteObjectsOfType(
"page");
833 $ilUser->clipboardDeleteObjectsOfType(
"chap");
834 $ilUser->clipboardDeleteObjectsOfType(
"sco");
847 include_once(
"./Modules/LearningModule/classes/class.ilEditClipboard.php");
849 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004OrganizationHFormGUI.php");
859 $parent_id = $node_id;
871 $parent_id = $tree->getParentId($node_id);
876 $parent_id = $node_id;
880 $childs = $tree->getChildsByType($parent_id,
"sco");
881 if (count($childs) != 0)
883 $target = $childs[count($childs) - 1][
"obj_id"];
889 $chapters = $ilUser->getClipboardObjects(
"chap",
true);
890 $copied_nodes = array();
891 foreach ($chapters as $chap)
894 $target, $chap[
"insert_time"], $copied_nodes,
902 $ilUser->clipboardDeleteObjectsOfType(
"page");
903 $ilUser->clipboardDeleteObjectsOfType(
"chap");
904 $ilUser->clipboardDeleteObjectsOfType(
"sco");
912 static function pasteTree($a_target_slm, $a_item_id, $a_parent_id, $a_target, $a_insert_time,
913 &$a_copied_nodes, $a_as_copy =
false)
915 global $ilUser, $ilias,
$ilLog;
919 $slm_obj = $ilias->obj_factory->getInstanceByObjId($item_slm_id);
920 if ($item_type ==
"chap")
922 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Chapter.php");
925 else if ($item_type ==
"page")
927 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004PageNode.php");
930 else if ($item_type ==
"sco")
932 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Sco.php");
936 $ilLog->write(
"Getting from clipboard type ".$item_type.
", ".
937 "Item ID: ".$a_item_id.
", of original SLM: ".$item_slm_id);
939 if ($item_slm_id != $a_target_slm->getId() && !$a_as_copy)
944 include_once(
"Services/MetaData/classes/class.ilMD.php");
945 $md =
new ilMD($item_slm_id, $item->getId(), $item->getType());
946 $new_md = $md->
cloneMD($a_target_slm->getId(), $item->getId(), $item->getType());
949 $item->setSLMId($a_target_slm->getId());
950 $item->setSLMObject($a_target_slm);
956 if ($item_type ==
"page")
958 $page = $item->getPageObject();
960 $page->setParentId($a_target_slm->getId());
967 $target_item = $item->copy($a_target_slm);
968 $a_copied_nodes[$item->getId()] = $target_item->getId();
972 $target_item = $item;
975 $ilLog->write(
"Putting into tree type ".$target_item->getType().
976 "Item ID: ".$target_item->getId().
", Parent: ".$a_parent_id.
", ".
977 "Target: ".$a_target.
", Item LM:".$target_item->getContentObject()->getId());
981 $childs = $ilUser->getClipboardChilds($item->getId(), $a_insert_time);
983 foreach($childs as $child)
986 IL_LAST_NODE, $a_insert_time, $a_copied_nodes, $a_as_copy);
989 return $target_item->getId();
997 include_once(
"./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004Objective.php");
1003 include_once(
"./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004Item.php");
1005 $seq_item ->
delete();
1010 include_once(
"./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004Utilities.php");