/**
  * Clone learning module
  *
  * @access public
  * @param int target ref_id
  * @param int copy id
  *
  */
 public function cloneObject($a_target_id, $a_copy_id = 0)
 {
     global $ilDB, $ilUser, $ilias;
     $new_obj = parent::cloneObject($a_target_id, $a_copy_id);
     $this->cloneMetaData($new_obj);
     //$new_obj->createProperties();
     $new_obj->setTitle($this->getTitle());
     $new_obj->setDescription($this->getDescription());
     $new_obj->setLayoutPerPage($this->getLayoutPerPage());
     $new_obj->setLayout($this->getLayout());
     $new_obj->setTOCMode($this->getTOCMode());
     $new_obj->setActiveLMMenu($this->isActiveLMMenu());
     $new_obj->setActiveTOC($this->isActiveTOC());
     $new_obj->setActiveNumbering($this->isActiveNumbering());
     $new_obj->setActivePrintView($this->isActivePrintView());
     $new_obj->setActivePreventGlossaryAppendix($this->isActivePreventGlossaryAppendix());
     $new_obj->setActiveDownloads($this->isActiveDownloads());
     $new_obj->setActiveDownloadsPublic($this->isActiveDownloadsPublic());
     $new_obj->setPublicNotes($this->publicNotes());
     $new_obj->setCleanFrames($this->cleanFrames());
     $new_obj->setHistoryUserComments($this->isActiveHistoryUserComments());
     $new_obj->setPublicAccessMode($this->getPublicAccessMode());
     $new_obj->setPageHeader($this->getPageHeader());
     $new_obj->setRating($this->hasRating());
     $new_obj->update();
     $new_obj->createLMTree();
     // copy style
     include_once "./Services/Style/classes/class.ilObjStyleSheet.php";
     $style_id = $this->getStyleSheetId();
     if ($style_id > 0 && !ilObjStyleSheet::_lookupStandard($style_id)) {
         $style_obj = $ilias->obj_factory->getInstanceByObjId($style_id);
         $new_id = $style_obj->ilClone();
         $new_obj->setStyleSheetId($new_id);
         $new_obj->update();
     }
     // copy content
     $this->copyAllPagesAndChapters($new_obj);
     // Copy learning progress settings
     include_once 'Services/Tracking/classes/class.ilLPObjSettings.php';
     $obj_settings = new ilLPObjSettings($this->getId());
     $obj_settings->cloneSettings($new_obj->getId());
     unset($obj_settings);
     return $new_obj;
 }
Ejemplo n.º 2
0
 function saveStyleSettings()
 {
     global $ilSetting;
     include_once "./Services/Style/classes/class.ilObjStyleSheet.php";
     if ($ilSetting->get("fixed_content_style_id") <= 0 && (ilObjStyleSheet::_lookupStandard($this->object->getStyleSheetId()) || $this->object->getStyleSheetId() == 0)) {
         $this->object->setStyleSheetId(ilUtil::stripSlashes($_POST["style_id"]));
         $this->object->update();
         ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
     }
     $this->ctrl->redirect($this, "editStyleProperties");
 }
 /**
  * Copy authored content (everything done with the editor
  *
  * @param
  * @return
  */
 function copyAuthoredContent($a_new_obj)
 {
     global $ilias;
     // set/copy stylesheet
     include_once "./Services/Style/classes/class.ilObjStyleSheet.php";
     $style_id = $this->getStyleSheetId();
     if ($style_id > 0 && !ilObjStyleSheet::_lookupStandard($style_id)) {
         $style_obj = $ilias->obj_factory->getInstanceByObjId($style_id);
         $new_id = $style_obj->ilClone();
         $a_new_obj->setStyleSheetId($new_id);
         $a_new_obj->update();
     }
     $a_new_obj->createScorm2004Tree();
     $source_tree = $this->getTree();
     $target_tree_root_id = $a_new_obj->getTree()->readRootId();
     $childs = $source_tree->getChilds($source_tree->readRootId());
     $a_copied_nodes = array();
     include_once "./Modules/Scorm2004/classes/class.ilSCORM2004Node.php";
     foreach ($childs as $c) {
         ilSCORM2004Node::pasteTree($a_new_obj, $c["child"], $target_tree_root_id, IL_LAST_NODE, "", $a_copied_nodes, true, false);
     }
 }
Ejemplo n.º 4
0
 protected function doCloneObject(ilObjBlog $new_obj, $a_target_id, $a_copy_id = null)
 {
     // banner?
     $img = $this->getImage();
     if ($img) {
         $new_obj->setImage($img);
         $source = $this->initStorage($this->getId());
         $target = $new_obj->initStorage($new_obj->getId());
         copy($source . $img, $target . $img);
     }
     $new_obj->setNotesStatus($this->getNotesStatus());
     $new_obj->setProfilePicture($this->hasProfilePicture());
     $new_obj->setBackgroundColor($this->getBackgroundColor());
     $new_obj->setFontColor($this->getFontColor());
     $new_obj->setRSS($this->hasRSS());
     $new_obj->setApproval($this->hasApproval());
     $new_obj->update();
     // set/copy stylesheet
     include_once "./Services/Style/classes/class.ilObjStyleSheet.php";
     $style_id = $this->getStyleSheetId();
     if ($style_id > 0 && !ilObjStyleSheet::_lookupStandard($style_id)) {
         $style_obj = ilObjectFactory::getInstanceByObjId($style_id);
         $new_id = $style_obj->ilClone();
         $new_obj->setStyleSheetId($new_id);
         $new_obj->update();
     }
 }
 /**
  * Build template from portfolio and vice versa
  * 
  * @param ilObjPortfolioBase $a_source
  * @param ilObjPortfolioBase $a_target
  * @param array $a_recipe
  */
 public static function clonePagesAndSettings(ilObjPortfolioBase $a_source, ilObjPortfolioBase $a_target, array $a_recipe = null)
 {
     global $lng, $ilUser;
     $source_id = $a_source->getId();
     $target_id = $a_target->getId();
     if ($a_source instanceof ilObjPortfolioTemplate && $a_target instanceof ilObjPortfolio) {
         $direction = "t2p";
     } else {
         if ($a_source instanceof ilObjPortfolio && $a_target instanceof ilObjPortfolioTemplate) {
             $direction = "p2t";
         } else {
             return;
         }
     }
     // copy portfolio properties
     $a_target->setPublicComments($a_source->hasPublicComments());
     $a_target->setProfilePicture($a_source->hasProfilePicture());
     $a_target->setFontColor($a_source->getFontColor());
     $a_target->setBackgroundColor($a_source->getBackgroundColor());
     $a_target->setImage($a_source->getImage());
     $a_target->update();
     // banner/images
     $source_dir = $a_source->initStorage($source_id);
     $target_dir = $a_target->initStorage($target_id);
     ilFSStoragePortfolio::_copyDirectory($source_dir, $target_dir);
     // set/copy stylesheet
     include_once "./Services/Style/classes/class.ilObjStyleSheet.php";
     $style_id = $a_source->getStyleSheetId();
     if ($style_id > 0 && !ilObjStyleSheet::_lookupStandard($style_id)) {
         $style_obj = ilObjectFactory::getInstanceByObjId($style_id);
         $new_id = $style_obj->ilClone();
         $a_target->setStyleSheetId($new_id);
         $a_target->update();
     }
     // copy pages
     $blog_count = 0;
     include_once "Modules/Portfolio/classes/class.ilPortfolioTemplatePage.php";
     foreach (ilPortfolioPage::getAllPages($source_id) as $page) {
         $page_id = $page["id"];
         if ($direction == "t2p") {
             $source_page = new ilPortfolioTemplatePage($page_id);
             $target_page = new ilPortfolioPage();
         } else {
             $source_page = new ilPortfolioPage($page_id);
             $target_page = new ilPortfolioTemplatePage();
         }
         $source_page->setPortfolioId($source_id);
         $target_page->setPortfolioId($target_id);
         $page_type = $source_page->getType();
         $page_title = $source_page->getTitle();
         $page_recipe = null;
         if (is_array($a_recipe)) {
             $page_recipe = $a_recipe[$page_id];
         }
         $valid = false;
         switch ($page_type) {
             // blog => blog template
             case ilPortfolioTemplatePage::TYPE_BLOG:
                 if ($direction == "p2t") {
                     $page_type = ilPortfolioTemplatePage::TYPE_BLOG_TEMPLATE;
                     $page_title = $lng->txt("obj_blog") . " " . ++$blog_count;
                     $valid = true;
                 }
                 break;
                 // blog template => blog (needs recipe)
             // blog template => blog (needs recipe)
             case ilPortfolioTemplatePage::TYPE_BLOG_TEMPLATE:
                 if ($direction == "t2p" && is_array($page_recipe)) {
                     $page_type = ilPortfolioPage::TYPE_BLOG;
                     if ($page_recipe[0] == "blog") {
                         switch ($page_recipe[1]) {
                             case "create":
                                 $page_title = self::createBlogInPersonalWorkspace($page_recipe[2]);
                                 $valid = true;
                                 break;
                             case "reuse":
                                 $page_title = $page_recipe[2];
                                 $valid = true;
                                 break;
                             case "ignore":
                                 // do nothing
                                 break;
                         }
                     }
                 }
                 break;
                 // page editor
             // page editor
             default:
                 $target_page->setXMLContent($source_page->copyXmlContent(true));
                 // copy mobs
                 $target_page->buildDom(true);
                 // parse content / blocks
                 $dom = $target_page->getDom();
                 if ($dom instanceof php4DOMDocument) {
                     $dom = $dom->myDOMDocument;
                 }
                 if ($direction == "t2p") {
                     // update profile/consultation hours user id
                     self::updateDomNodes($dom, "//PageContent/Profile", "User", $ilUser->getId());
                     self::updateDomNodes($dom, "//PageContent/ConsultationHours", "User", $ilUser->getId());
                 }
                 // :TODO: skills
                 $valid = true;
                 break;
         }
         if ($valid) {
             // #12038 - update xml from dom
             $target_page->setXMLContent($target_page->getXMLFromDom());
             $target_page->setType($page_type);
             $target_page->setTitle($page_title);
             $target_page->create();
             if ($page_type == ilPortfolioPage::TYPE_PAGE) {
                 $target_page->update();
                 // handle mob usages!
             }
         }
     }
 }
 protected function afterSave(ilObject $a_new_object)
 {
     global $ilUser, $tree;
     // add default translation
     $a_new_object->addTranslation($a_new_object->getTitle(), $a_new_object->getDescription(), $ilUser->getPref("language"), true);
     // default: sort by title
     include_once 'Services/Container/classes/class.ilContainerSortingSettings.php';
     $settings = new ilContainerSortingSettings($a_new_object->getId());
     $settings->setSortMode(ilContainer::SORT_TITLE);
     $settings->save();
     // inherit parents content style, if not individual
     $parent_ref_id = $tree->getParentId($a_new_object->getRefId());
     $parent_id = ilObject::_lookupObjId($parent_ref_id);
     include_once "./Services/Style/classes/class.ilObjStyleSheet.php";
     $style_id = ilObjStyleSheet::lookupObjectStyle($parent_id);
     if ($style_id > 0) {
         if (ilObjStyleSheet::_lookupStandard($style_id)) {
             ilObjStyleSheet::writeStyleUsage($a_new_object->getId(), $style_id);
         }
     }
     // always send a message
     ilUtil::sendSuccess($this->lng->txt("cat_added"), true);
     $this->ctrl->setParameter($this, "ref_id", $a_new_object->getRefId());
     $this->redirectToRefId($a_new_object->getRefId(), "");
 }
Ejemplo n.º 7
0
 /**
  * Clone glossary
  *
  * @param int target ref_id
  * @param int copy id
  */
 public function cloneObject($a_target_id, $a_copy_id = 0)
 {
     global $ilDB, $ilUser, $ilias;
     $new_obj = parent::cloneObject($a_target_id, $a_copy_id);
     $this->cloneMetaData($new_obj);
     //copy online status if object is not the root copy object
     $cp_options = ilCopyWizardOptions::_getInstance($a_copy_id);
     if (!$cp_options->isRootNode($this->getRefId())) {
         $new_obj->setOnline($this->getOnline());
     }
     //		$new_obj->setTitle($this->getTitle());
     $new_obj->setDescription($this->getDescription());
     $new_obj->setVirtualMode($this->getVirtualMode());
     $new_obj->setPresentationMode($this->getPresentationMode());
     $new_obj->setSnippetLength($this->getSnippetLength());
     $new_obj->update();
     // set/copy stylesheet
     include_once "./Services/Style/classes/class.ilObjStyleSheet.php";
     $style_id = $this->getStyleSheetId();
     if ($style_id > 0 && !ilObjStyleSheet::_lookupStandard($style_id)) {
         $style_obj = $ilias->obj_factory->getInstanceByObjId($style_id);
         $new_id = $style_obj->ilClone();
         $new_obj->setStyleSheetId($new_id);
         $new_obj->update();
     }
     // copy taxonomy
     if (($tax_id = $this->getTaxonomyId()) > 0) {
         // clone it
         include_once "./Services/Taxonomy/classes/class.ilObjTaxonomy.php";
         $tax = new ilObjTaxonomy($tax_id);
         $new_tax = $tax->cloneObject(0, 0, true);
         $map = $tax->getNodeMapping();
         // assign new taxonomy to new glossary
         ilObjTaxonomy::saveUsage($new_tax->getId(), $new_obj->getId());
     }
     // assign new tax/new glossary
     // handle mapping
     // prepare tax node assignments objects
     include_once "./Services/Taxonomy/classes/class.ilTaxNodeAssignment.php";
     if ($tax_id > 0) {
         $tax_ass = new ilTaxNodeAssignment("glo", $this->getId(), "term", $tax_id);
         $new_tax_ass = new ilTaxNodeAssignment("glo", $new_obj->getId(), "term", $new_tax->getId());
     }
     // copy terms
     foreach (ilGlossaryTerm::getTermList($this->getId()) as $term) {
         $new_term_id = ilGlossaryTerm::_copyTerm($term["id"], $new_obj->getId());
         // copy tax node assignments
         if ($tax_id > 0) {
             $assignmts = $tax_ass->getAssignmentsOfItem($term["id"]);
             foreach ($assignmts as $a) {
                 if ($map[$a["node_id"]] > 0) {
                     $new_tax_ass->addAssignment($map[$a["node_id"]], $new_term_id);
                 }
             }
         }
     }
     return $new_obj;
 }
Ejemplo n.º 8
0
 /**
  * Clone wiki
  *
  * @param int target ref_id
  * @param int copy id
  */
 public function cloneObject($a_target_id, $a_copy_id = 0)
 {
     global $ilDB, $ilUser, $ilias;
     $new_obj = parent::cloneObject($a_target_id, $a_copy_id);
     $new_obj->setTitle($this->getTitle());
     $new_obj->setStartPage($this->getStartPage());
     $new_obj->setShortTitle($this->getShortTitle());
     $new_obj->setRatingOverall($this->getRatingOverall());
     $new_obj->setRating($this->getRating());
     $new_obj->setRatingAsBlock($this->getRatingAsBlock());
     $new_obj->setRatingForNewPages($this->getRatingForNewPages());
     $new_obj->setRatingCategories($this->getRatingCategories());
     $new_obj->setPublicNotes($this->getPublicNotes());
     $new_obj->setIntroduction($this->getIntroduction());
     $new_obj->setImportantPages($this->getImportantPages());
     $new_obj->setPageToc($this->getPageToc());
     $new_obj->update();
     // set/copy stylesheet
     include_once "./Services/Style/classes/class.ilObjStyleSheet.php";
     $style_id = $this->getStyleSheetId();
     if ($style_id > 0 && !ilObjStyleSheet::_lookupStandard($style_id)) {
         $style_obj = $ilias->obj_factory->getInstanceByObjId($style_id);
         $new_id = $style_obj->ilClone();
         $new_obj->setStyleSheetId($new_id);
         $new_obj->update();
     }
     // copy content
     include_once "./Modules/Wiki/classes/class.ilWikiPage.php";
     $pages = ilWikiPage::getAllPages($this->getId());
     if (count($pages) > 0) {
         // if we have any pages, delete the start page first
         $pg_id = ilWikiPage::getPageIdForTitle($new_obj->getId(), $new_obj->getStartPage());
         $start_page = new ilWikiPage($pg_id);
         $start_page->delete();
     }
     $map = array();
     foreach ($pages as $p) {
         $page = new ilWikiPage($p["id"]);
         $new_page = new ilWikiPage();
         $new_page->setTitle($page->getTitle());
         $new_page->setWikiId($new_obj->getId());
         $new_page->setTitle($page->getTitle());
         $new_page->setBlocked($page->getBlocked());
         $new_page->setRating($page->getRating());
         $new_page->hideAdvancedMetadata($page->isAdvancedMetadataHidden());
         $new_page->create();
         $page->copy($new_page->getId(), "", 0, true);
         //$new_page->setXMLContent($page->copyXMLContent(true));
         //$new_page->buildDom(true);
         //$new_page->update();
         $map[$p["id"]] = $new_page->getId();
     }
     // copy important pages
     foreach (ilObjWiki::_lookupImportantPagesList($this->getId()) as $ip) {
         $new_obj->addImportantPage($map[$ip["page_id"]], $ip["ord"], $ip["indent"]);
     }
     // copy rating categories
     include_once "./Services/Rating/classes/class.ilRatingCategory.php";
     foreach (ilRatingCategory::getAllForObject($this->getId()) as $rc) {
         $new_rc = new ilRatingCategory();
         $new_rc->setParentId($new_obj->getId());
         $new_rc->setTitle($rc["title"]);
         $new_rc->setDescription($rc["description"]);
         $new_rc->save();
     }
     return $new_obj;
 }
Ejemplo n.º 9
0
 /**
  * Clone basic settings 
  * 
  * @param ilObjPortfolioBase $a_source
  * @param ilObjPortfolioBase $a_target
  */
 protected static function cloneBasics(ilObjPortfolioBase $a_source, ilObjPortfolioBase $a_target)
 {
     // copy portfolio properties
     $a_target->setPublicComments($a_source->hasPublicComments());
     $a_target->setProfilePicture($a_source->hasProfilePicture());
     $a_target->setFontColor($a_source->getFontColor());
     $a_target->setBackgroundColor($a_source->getBackgroundColor());
     $a_target->setImage($a_source->getImage());
     $a_target->update();
     // banner/images
     $source_dir = $a_source->initStorage($a_source->getId());
     $target_dir = $a_target->initStorage($a_target->getId());
     ilFSStoragePortfolio::_copyDirectory($source_dir, $target_dir);
     // set/copy stylesheet
     include_once "./Services/Style/classes/class.ilObjStyleSheet.php";
     $style_id = $a_source->getStyleSheetId();
     if ($style_id > 0 && !ilObjStyleSheet::_lookupStandard($style_id)) {
         $style_obj = ilObjectFactory::getInstanceByObjId($style_id);
         $new_id = $style_obj->ilClone();
         $a_target->setStyleSheetId($new_id);
         $a_target->update();
     }
 }