/** * Fix container item group references after a container has been cloned * * @param * @return */ static function fixContainerItemGroupRefsAfterCloning($a_source_container, $a_copy_id) { global $ilLog; $ilLog->write(__METHOD__ . ': Fix item group references in ' . $a_source_container->getType()); include_once 'Services/CopyWizard/classes/class.ilCopyWizardOptions.php'; $cwo = ilCopyWizardOptions::_getInstance($a_copy_id); $mappings = $cwo->getMappings(); $new_container_ref_id = $mappings[$a_source_container->getRefId()]; $ilLog->write(__METHOD__ . ': 2-' . $new_container_ref_id . '-'); $new_container_obj_id = ilObject::_lookupObjId($new_container_ref_id); include_once "./Services/COPage/classes/class.ilPageObject.php"; include_once "./Services/Container/classes/class.ilContainerPage.php"; $ilLog->write(__METHOD__ . ': 3' . $new_container_obj_id . '-'); if (ilPageObject::_exists("cont", $new_container_obj_id)) { $ilLog->write(__METHOD__ . ': 4'); $new_page = new ilContainerPage($new_container_obj_id); $new_page->buildDom(); include_once "./Services/COPage/classes/class.ilPCResources.php"; ilPCResources::modifyItemGroupRefIdsByMapping($new_page, $mappings); $new_page->update(); } $ilLog->write(__METHOD__ . ': 5'); }
/** * Clone container settings * * @access public * @param int target ref_id * @param int copy id * @return object new object */ public function cloneObject($a_target_id, $a_copy_id = 0) { $new_obj = parent::cloneObject($a_target_id, $a_copy_id); include_once './Services/Container/classes/class.ilContainerSortingSettings.php'; $sorting = new ilContainerSortingSettings($new_obj->getId()); $sorting->setSortMode($this->getOrderType()); $sorting->update(); // copy content page include_once "./Services/Container/classes/class.ilContainerPage.php"; if (ilContainerPage::_exists("cont", $this->getId())) { $orig_page = new ilContainerPage($this->getId()); $new_page_object = new ilContainerPage(); $new_page_object->setParentId($new_obj->getId()); $new_page_object->setId($new_obj->getId()); $new_page_object->createFromXML(); $new_page_object->setXMLContent($orig_page->getXMLContent()); $new_page_object->buildDom(true); $new_page_object->update(); } return $new_obj; }