/**
  * Copy tree content
  *
  * @param
  * @return
  */
 function copyTreeContent($a_new_obj, $a_target_parent, $a_source_parent)
 {
     include_once "./Modules/MediaPool/classes/class.ilMediaPoolItem.php";
     include_once "./Modules/MediaPool/classes/class.ilMediaPoolPage.php";
     include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
     // get all chapters of root lm
     $nodes = $this->getTree()->getChilds($a_source_parent);
     foreach ($nodes as $node) {
         $item = new ilMediaPoolItem();
         $item->setType($node["type"]);
         switch ($node["type"]) {
             case "mob":
                 $mob_id = ilMediaPoolItem::lookupForeignId($node["child"]);
                 $mob = new ilObjMediaObject($mob_id);
                 $new_mob = $mob->duplicate();
                 $item->setForeignId($new_mob->getId());
                 $item->setTitle($new_mob->getTitle());
                 $item->create();
                 break;
             case "pg":
                 $item->setTitle($node["title"]);
                 $item->create();
                 $page = new ilMediaPoolPage($node["child"]);
                 $new_page = new ilMediaPoolPage();
                 $new_page->setId($item->getId());
                 $new_page->create();
                 // todo: make mobs being copied
                 $new_page->setXMLContent($page->copyXMLContent(true));
                 $new_page->buildDom();
                 $new_page->update();
                 break;
             case "fold":
                 $item->setTitle($node["title"]);
                 $item->create();
                 break;
         }
         // insert item into tree
         $a_new_obj->insertInTree($item->getId(), $a_target_parent);
         // handle childs
         $this->copyTreeContent($a_new_obj, $item->getId(), $node["child"]);
     }
 }
 /**
  * insert media object from clipboard
  */
 function insertFromClipboard()
 {
     global $ilAccess;
     if (!$ilAccess->checkAccess("write", "", $this->object->getRefId())) {
         $this->ilias->raiseError($this->lng->txt("permission_denied"), $this->ilias->error_obj->MESSAGE);
     }
     include_once "./Services/Clipboard/classes/class.ilEditClipboardGUI.php";
     $ids = ilEditClipboardGUI::_getSelectedIDs();
     $not_inserted = array();
     if (is_array($ids)) {
         foreach ($ids as $id2) {
             $id = explode(":", $id2);
             $type = $id[0];
             $id = $id[1];
             if ($type == "mob") {
                 if (ilObjMEdiaPool::isForeignIdInTree($this->object->getId(), $id)) {
                     $not_inserted[] = ilObject::_lookupTitle($id) . " [" . $id . "]";
                 } else {
                     $item = new ilMediaPoolItem();
                     $item->setType("mob");
                     $item->setForeignId($id);
                     $item->setTitle(ilObject::_lookupTitle($id));
                     $item->create();
                     if ($item->getId() > 0) {
                         $this->object->insertInTree($item->getId(), $_GET["mepitem_id"]);
                     }
                 }
             }
             if ($type == "incl") {
                 include_once "./Modules/MediaPool/classes/class.ilMediaPoolPage.php";
                 include_once "./Modules/MediaPool/classes/class.ilMediaPoolItem.php";
                 if (ilObjMEdiaPool::isItemIdInTree($this->object->getId(), $id)) {
                     $not_inserted[] = ilMediaPoolPage::lookupTitle($id) . " [" . $id . "]";
                 } else {
                     $original = new ilMediaPoolPage($id);
                     // copy the page into the pool
                     $item = new ilMediaPoolItem();
                     $item->setType("pg");
                     $item->setTitle(ilMediaPoolItem::lookupTitle($id));
                     $item->create();
                     if ($item->getId() > 0) {
                         $this->object->insertInTree($item->getId(), $_GET["mepitem_id"]);
                         // create page
                         include_once "./Modules/MediaPool/classes/class.ilMediaPoolPage.php";
                         $page = new ilMediaPoolPage();
                         $page->setId($item->getId());
                         $page->create();
                         // copy content
                         $page->setXMLContent($original->copyXMLContent());
                         $page->buildDom();
                         $page->update();
                     }
                 }
             }
         }
     }
     if (count($not_inserted) > 0) {
         ilUtil::sendInfo($this->lng->txt("mep_not_insert_already_exist") . "<br>" . implode($not_inserted, "<br>"), true);
     }
     $this->ctrl->redirect($this, $_GET["mep_mode"] ? $_GET["mep_mode"] : "listMedia");
 }