/**
  * copy chapter
  */
 function copy($a_target_lm)
 {
     $chap = new ilStructureObject($a_target_lm);
     $chap->setTitle($this->getTitle());
     if ($this->getLMId() != $a_target_lm->getId()) {
         $chap->setImportId("il__st_" . $this->getId());
     }
     $chap->setLMId($a_target_lm->getId());
     $chap->setType($this->getType());
     $chap->setDescription($this->getDescription());
     $chap->create(true);
     $a_copied_nodes[$this->getId()] = $chap->getId();
     // copy meta data
     include_once "Services/MetaData/classes/class.ilMD.php";
     $md = new ilMD($this->getLMId(), $this->getId(), $this->getType());
     $new_md =& $md->cloneMD($a_target_lm->getId(), $chap->getId(), $this->getType());
     return $chap;
 }
 /**
  * Insert (multiple) chapters at node
  */
 function insertChapter()
 {
     global $ilCtrl, $lng;
     include_once "./Modules/LearningModule/classes/class.ilChapterHierarchyFormGUI.php";
     $num = ilChapterHierarchyFormGUI::getPostMulti();
     $node_id = ilChapterHierarchyFormGUI::getPostNodeId();
     if (!ilChapterHierarchyFormGUI::getPostFirstChild()) {
         $parent_id = $this->lm_tree->getParentId($node_id);
         $target = $node_id;
     } else {
         $parent_id = $node_id;
         $target = IL_FIRST_NODE;
     }
     for ($i = 1; $i <= $num; $i++) {
         $chap = new ilStructureObject($this->object);
         $chap->setType("st");
         $chap->setTitle($lng->txt("cont_new_chap"));
         $chap->setLMId($this->object->getId());
         $chap->create();
         ilLMObject::putInTree($chap, $parent_id, $target);
     }
     $ilCtrl->redirect($this, "chapters");
 }
 /**
  * Add first chapter and page
  */
 function addFirstChapterAndPage()
 {
     global $lng;
     include_once "./Modules/LearningModule/classes/class.ilLMObject.php";
     include_once "./Modules/LearningModule/classes/class.ilStructureObject.php";
     include_once "./Modules/LearningModule/classes/class.ilLMPageObject.php";
     $root_id = $this->lm_tree->getRootId();
     // chapter
     $chap = new ilStructureObject($this);
     $chap->setType("st");
     $chap->setTitle($lng->txt("cont_new_chap"));
     $chap->setLMId($this->getId());
     $chap->create();
     ilLMObject::putInTree($chap, $root_id, IL_FIRST_NODE);
     // page
     $page = new ilLMPageObject($this);
     $page->setType("pg");
     $page->setTitle($lng->txt("cont_new_page"));
     $page->setLMId($this->getId());
     $page->create();
     ilLMObject::putInTree($page, $chap->getId(), IL_FIRST_NODE);
 }