/**
  * Insert chapter from clipboard
  */
 function insertChapterClip()
 {
     global $ilCtrl, $ilUser;
     include_once "./Modules/Scorm2004/classes/class.ilSCORM2004Node.php";
     ilSCORM2004Node::insertChapterClip($this->object);
     $ilCtrl->redirect($this, "showOrganization", "node_" . ilSCORM2004OrganizationHFormGUI::getPostNodeId());
 }
 /**
  * Insert Chapter from clipboard
  */
 function insertChapterClip($a_slm_obj, $a_as_sub = false)
 {
     global $ilUser, $ilCtrl, $ilLog;
     // @todo: move this to a service since it can be used here, too
     include_once "./Modules/LearningModule/classes/class.ilEditClipboard.php";
     include_once "./Modules/Scorm2004/classes/class.ilSCORM2004OrganizationHFormGUI.php";
     $node_id = ilSCORM2004OrganizationHFormGUI::getPostNodeId();
     $first_child = ilSCORM2004OrganizationHFormGUI::getPostFirstChild();
     $tree = ilSCORM2004Node::getTree($a_slm_obj->getId());
     if ($a_as_sub) {
         if (!$first_child) {
             $parent_id = $node_id;
             $target = "";
         } else {
             return;
         }
     } else {
         if (!$first_child) {
             $parent_id = $tree->getParentId($node_id);
             $target = $node_id;
         } else {
             $parent_id = $node_id;
             $target = IL_FIRST_NODE;
             // do not move a chapter in front of a sco (maybe never needed)
             $childs = $tree->getChildsByType($parent_id, "sco");
             if (count($childs) != 0) {
                 $target = $childs[count($childs) - 1]["obj_id"];
             }
         }
     }
     // copy and paste
     $chapters = $ilUser->getClipboardObjects("chap", true);
     $copied_nodes = array();
     foreach ($chapters as $chap) {
         $cid = ilSCORM2004Node::pasteTree($a_slm_obj, $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("page");
         $ilUser->clipboardDeleteObjectsOfType("chap");
         $ilUser->clipboardDeleteObjectsOfType("sco");
         $ilUser->clipboardDeleteObjectsOfType("ass");
         ilEditClipboard::clear();
     }
 }
 /**
  * Insert assets from clipboard
  */
 function insertAssetClip()
 {
     global $ilCtrl, $ilUser;
     ilSCORM2004Node::insertAssetClip($this->slm_object);
     $ilCtrl->redirect($this, "showOrganization", "node_" . ilSCORM2004OrganizationHFormGUI::getPostNodeId());
 }