/** * Insert Chapter from clipboard */ function insertChapterClip() { global $ilUser, $ilCtrl, $ilLog; include_once "./Modules/LearningModule/classes/class.ilChapterHierarchyFormGUI.php"; $node_id = ilChapterHierarchyFormGUI::getPostNodeId(); $first_child = ilChapterHierarchyFormGUI::getPostFirstChild(); $ilLog->write("InsertChapterClip, num: {$num}, node_id: {$node_id}, " . " getPostFirstChild " . ilChapterHierarchyFormGUI::getPostFirstChild()); if (!$first_child) { $parent_id = $this->lm_tree->getParentId($node_id); $target = $node_id; } else { $parent_id = $node_id; $target = IL_FIRST_NODE; } // copy and paste $chapters = $ilUser->getClipboardObjects("st", true); $copied_nodes = array(); foreach ($chapters as $chap) { $ilLog->write("Call pasteTree, Target LM: " . $this->object->getId() . ", Chapter ID: " . $chap["id"] . ", Parent ID: " . $parent_id . ", Target: " . $target); $cid = ilLMObject::pasteTree($this->object, $chap["id"], $parent_id, $target, $chap["insert_time"], $copied_nodes, ilEditClipboard::getAction() == "copy"); $target = $cid; } ilLMObject::updateInternalLinks($copied_nodes); if (ilEditClipboard::getAction() == "cut") { $ilUser->clipboardDeleteObjectsOfType("pg"); $ilUser->clipboardDeleteObjectsOfType("st"); ilEditClipboard::clear(); } $this->object->checkTree(); $ilCtrl->redirect($this, "chapters"); }
/** * Copy all pages and chapters * * @param object $a_target_obj target learning module */ function copyAllPagesAndChapters($a_target_obj) { $parent_id = $a_target_obj->lm_tree->readRootId(); include_once "./Modules/LearningModule/classes/class.ilLMObject.php"; include_once "./Modules/LearningModule/classes/class.ilLMPageObject.php"; // get all chapters of root lm $chapters = $this->lm_tree->getChildsByType($this->lm_tree->readRootId(), "st"); $copied_nodes = array(); //$time = time(); foreach ($chapters as $chap) { $cid = ilLMObject::pasteTree($a_target_obj, $chap["child"], $parent_id, IL_LAST_NODE, $time, $copied_nodes, true, $this); $target = $cid; } // copy free pages $pages = ilLMPageObject::getPageList($this->getId()); foreach ($pages as $p) { if (!$this->lm_tree->isInTree($p["obj_id"])) { $item = new ilLMPageObject($this, $p["obj_id"]); $target_item = $item->copy($a_target_obj); $copied_nodes[$item->getId()] = $target_item->getId(); } } ilLMObject::updateInternalLinks($copied_nodes); $a_target_obj->checkTree(); }
/** * Insert pages from clipboard */ function insertPageClip() { global $ilCtrl, $ilUser; include_once "./Modules/LearningModule/classes/class.ilChapterHierarchyFormGUI.php"; $node_id = ilChapterHierarchyFormGUI::getPostNodeId(); $first_child = ilChapterHierarchyFormGUI::getPostFirstChild(); if (!$first_child) { $parent_id = $this->tree->getParentId($node_id); $target = $node_id; } else { $parent_id = $node_id; $target = IL_FIRST_NODE; } // cut and paste $pages = $ilUser->getClipboardObjects("pg"); $copied_nodes = array(); foreach ($pages as $pg) { $cid = ilLMObject::pasteTree($this->content_object, $pg["id"], $parent_id, $target, $pg["insert_time"], $copied_nodes, ilEditClipboard::getAction() == "copy"); $target = $cid; } ilLMObject::updateInternalLinks($copied_nodes); if (ilEditClipboard::getAction() == "cut") { $ilUser->clipboardDeleteObjectsOfType("pg"); $ilUser->clipboardDeleteObjectsOfType("st"); ilEditClipboard::clear(); } $ilCtrl->redirect($this, "view"); }
/** * Copy all pages and chapters * * @param object $a_target_obj target learning module */ function copyAllPagesAndChapters($a_target_obj, $a_copy_id = 0) { $parent_id = $a_target_obj->lm_tree->readRootId(); include_once "./Modules/LearningModule/classes/class.ilLMObject.php"; include_once "./Modules/LearningModule/classes/class.ilLMPageObject.php"; // get all chapters of root lm $chapters = $this->lm_tree->getChildsByType($this->lm_tree->readRootId(), "st"); $copied_nodes = array(); //$time = time(); foreach ($chapters as $chap) { $cid = ilLMObject::pasteTree($a_target_obj, $chap["child"], $parent_id, IL_LAST_NODE, $time, $copied_nodes, true, $this); $target = $cid; } // copy free pages $pages = ilLMPageObject::getPageList($this->getId()); foreach ($pages as $p) { if (!$this->lm_tree->isInTree($p["obj_id"])) { $item = new ilLMPageObject($this, $p["obj_id"]); $target_item = $item->copy($a_target_obj); $copied_nodes[$item->getId()] = $target_item->getId(); } } // Add mapping for pages and chapters include_once './Services/CopyWizard/classes/class.ilCopyWizardOptions.php'; $options = ilCopyWizardOptions::_getInstance($a_copy_id); foreach ($copied_nodes as $old_id => $new_id) { $options->appendMapping($this->getRefId() . '_' . $old_id, $a_target_obj->getRefId() . '_' . $new_id); } ilLMObject::updateInternalLinks($copied_nodes); $a_target_obj->checkTree(); }