/**
  * Clone object permissions, put in tree ...
  *
  * @access public
  * @param int target id
  * @param int copy id for class.ilCopyWizardOptions()
  * @return object new object
  *  
  */
 public function cloneObject($a_target_id, $a_copy_id = 0, $a_omit_tree = false)
 {
     global $objDefinition, $ilUser, $rbacadmin, $ilDB;
     $location = $objDefinition->getLocation($this->getType());
     $class_name = 'ilObj' . $objDefinition->getClassName($this->getType());
     if (!$a_omit_tree) {
         $title = $this->appendCopyInfo($a_target_id, $a_copy_id);
     } else {
         $title = $this->getTitle();
     }
     // create instance
     include_once $location . "/class." . $class_name . ".php";
     $new_obj = new $class_name(0, false);
     $new_obj->setOwner($ilUser->getId());
     $new_obj->setTitle($title);
     $new_obj->setDescription($this->getLongDescription());
     $new_obj->setType($this->getType());
     // Choose upload mode to avoid creation of additional settings, db entries ...
     $new_obj->create(true);
     if (!$a_omit_tree) {
         $new_obj->createReference();
         $new_obj->putInTree($a_target_id);
         $new_obj->setPermissions($a_target_id);
         // when copying from personal workspace we have no current ref id
         if ($this->getRefId()) {
             // copy local roles
             $rbacadmin->copyLocalRoles($this->getRefId(), $new_obj->getRefId());
         }
     }
     include_once './Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php';
     ilAdvancedMDValues::_cloneValues($this->getId(), $new_obj->getId());
     // BEGIN WebDAV: Clone WebDAV properties
     $query = "INSERT INTO dav_property (obj_id,node_id,ns,name,value) " . "SELECT " . $ilDB->quote($new_obj->getId(), 'integer') . ",node_id,ns,name,value " . "FROM dav_property " . "WHERE obj_id = " . $ilDB->quote($this->getId(), 'integer');
     $res = $ilDB->manipulate($query);
     // END WebDAV: Clone WebDAV properties
     return $new_obj;
 }
Example #2
0
 /**
  * Create new wiki page
  *
  * @param string $a_page_title page title
  * @param int $a_template_page template page id
  * @return ilWikiPage new wiki page
  */
 function createWikiPage($a_page_title, $a_template_page = 0)
 {
     // check if template has to be used
     if ($a_template_page == 0) {
         if (!$this->getEmptyPageTemplate()) {
             include_once "./Modules/Wiki/classes/class.ilWikiPageTemplate.php";
             $wt = new ilWikiPageTemplate($this->getId());
             $ts = $wt->getAllInfo(ilWikiPageTemplate::TYPE_NEW_PAGES);
             if (count($ts) == 1) {
                 $t = current($ts);
                 $a_template_page = $t["wpage_id"];
             }
         }
     }
     // create the page
     $page = new ilWikiPage();
     $page->setWikiId($this->getId());
     $page->setTitle(ilWikiUtil::makeDbTitle($a_page_title));
     if ($this->getRating() && $this->getRatingForNewPages()) {
         $page->setRating(true);
     }
     // needed for notification
     $page->setWikiRefId($this->getRefId());
     $page->create();
     // copy template into new page
     if ($a_template_page > 0) {
         $orig = new ilWikiPage($a_template_page);
         $orig->copy($page->getId());
         // #15718
         include_once "Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php";
         ilAdvancedMDValues::_cloneValues($this->getId(), $this->getId(), "wpg", $a_template_page, $page->getId());
     }
     return $page;
 }