Exemplo n.º 1
0
 protected function saveBlogObject()
 {
     global $ilUser;
     if (!$_POST["node"]) {
         ilUtil::sendFailure($this->lng->txt("select_one"));
         return $this->createBlogObject();
     }
     $parent_node = $_POST["node"];
     include_once "Modules/Blog/classes/class.ilObjBlog.php";
     include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
     include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
     $blog = new ilObjBlog();
     $blog->setTitle($this->object->getTitle() . " - " . $this->ass->getTitle());
     $blog->create();
     $tree = new ilWorkspaceTree($ilUser->getId());
     $node_id = $tree->insertObject($parent_node, $blog->getId());
     $access_handler = new ilWorkspaceAccessHandler($tree);
     $access_handler->setPermissions($parent_node, $node_id);
     $this->object->addResourceObject($node_id, $this->ass->getId(), $ilUser->getId());
     ilUtil::sendSuccess($this->lng->txt("exc_blog_created"), true);
     $this->ctrl->redirect($this, "showOverview");
 }
Exemplo n.º 2
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();
     }
 }
Exemplo n.º 3
0
 /**
  * Import record
  *
  * @param
  * @return
  */
 function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
 {
     switch ($a_entity) {
         case "blog":
             include_once "./Modules/Blog/classes/class.ilObjBlog.php";
             // container copy
             if ($new_id = $a_mapping->getMapping("Services/Container", "objs", $a_rec["Id"])) {
                 $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
             } else {
                 $newObj = new ilObjBlog();
                 $newObj->create();
             }
             $newObj->setTitle($a_rec["Title"]);
             $newObj->setDescription($a_rec["Description"]);
             $newObj->setNotesStatus($a_rec["Notes"]);
             $newObj->setBackgroundColor($a_rec["BgColor"]);
             $newObj->setFontColor($a_rec["FontColor"]);
             $newObj->setProfilePicture($a_rec["Ppic"]);
             $newObj->setRSS($a_rec["RssActive"]);
             $newObj->setApproval($a_rec["Approval"]);
             $newObj->setImage($a_rec["Img"]);
             $newObj->setAbstractShorten($a_rec["AbsShorten"]);
             $newObj->setAbstractShortenLength($a_rec["AbsShortenLen"]);
             $newObj->setAbstractImage($a_rec["AbsImage"]);
             $newObj->setAbstractImageWidth($a_rec["AbsImgWidth"]);
             $newObj->setAbstractImageHeight($a_rec["AbsImgHeight"]);
             $newObj->setNavMode($a_rec["NavMode"]);
             $newObj->setNavModeListPostings($a_rec["NavListPost"]);
             $newObj->setNavModeListMonths($a_rec["NavListMon"]);
             $newObj->setKeywords($a_rec["Keywords"]);
             $newObj->setAuthors($a_rec["Authors"]);
             $newObj->setOrder(trim($a_rec["NavOrder"]) ? explode(";", $a_rec["NavOrder"]) : null);
             $newObj->setOverviewPostings($a_rec["OvPost"]);
             $newObj->update();
             // handle image(s)
             if ($a_rec["Img"]) {
                 $dir = str_replace("..", "", $a_rec["Dir"]);
                 if ($dir != "" && $this->getImportDirectory() != "") {
                     $source_dir = $this->getImportDirectory() . "/" . $dir;
                     $target_dir = ilObjBlog::initStorage($newObj->getId());
                     ilUtil::rCopy($source_dir, $target_dir);
                 }
             }
             if ($a_rec["Style"]) {
                 self::$style_map[$a_rec["Style"]][] = $newObj->getId();
             }
             $a_mapping->addMapping("Modules/Blog", "blog", $a_rec["Id"], $newObj->getId());
             break;
         case "blog_posting":
             $blog_id = (int) $a_mapping->getMapping("Modules/Blog", "blog", $a_rec["BlogId"]);
             if ($blog_id) {
                 include_once "./Modules/Blog/classes/class.ilBlogPosting.php";
                 $newObj = new ilBlogPosting();
                 $newObj->setBlogId($blog_id);
                 $newObj->setTitle($a_rec["Title"]);
                 $newObj->setCreated(new ilDateTime($a_rec["Created"], IL_CAL_DATETIME));
                 $newObj->setApproved($a_rec["Approved"]);
                 // parse export id into local id (if possible)
                 $author = $this->parseObjectExportId($a_rec["Author"], -1);
                 $newObj->setAuthor($author["id"]);
                 $newObj->create(true);
                 // keywords
                 $keywords = array();
                 for ($loop = 0; $loop < 1000; $loop++) {
                     if (isset($a_rec["Keyword" . $loop])) {
                         $keyword = trim($a_rec["Keyword" . $loop]);
                         if (strlen($keyword)) {
                             $keywords[] = $keyword;
                         }
                     }
                 }
                 if (sizeof($keywords)) {
                     $newObj->updateKeywords($keywords);
                 }
                 $a_mapping->addMapping("Services/COPage", "pg", "blp:" . $a_rec["Id"], "blp:" . $newObj->getId());
             }
             break;
     }
 }
 protected static function createBlogInPersonalWorkspace($a_title)
 {
     global $ilUser;
     static $ws_access = null;
     include_once "Modules/Blog/classes/class.ilObjBlog.php";
     $blog = new ilObjBlog();
     $blog->setType("blog");
     $blog->setTitle($a_title);
     $blog->create();
     if (!$ws_access) {
         include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
         include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
         $tree = new ilWorkspaceTree($ilUser->getId());
         $ws_access = new ilWorkspaceAccessHandler($tree);
     }
     $tree = $ws_access->getTree();
     $node_id = $tree->insertObject($tree->getRootId(), $blog->getId());
     $ws_access->setPermissions($tree->getRootId(), $node_id);
     return $blog->getId();
 }
Exemplo n.º 5
0
 /**
  * Import record
  *
  * @param
  * @return
  */
 function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
 {
     switch ($a_entity) {
         case "blog":
             include_once "./Modules/Blog/classes/class.ilObjBlog.php";
             $newObj = new ilObjBlog();
             $newObj->setTitle($a_rec["Title"]);
             $newObj->setDescription($a_rec["Description"]);
             $newObj->create();
             $newObj->setNotesStatus($a_rec["Notes"]);
             $newObj->setBackgroundColor($a_rec["BgColor"]);
             $newObj->setFontColor($a_rec["FontColor"]);
             $newObj->setProfilePicture($a_rec["Ppic"]);
             $newObj->setRSS($a_rec["RssActive"]);
             $newObj->setApproval($a_rec["Approval"]);
             $newObj->setImage($a_rec["Img"]);
             $newObj->update();
             // handle image(s)
             if ($a_rec["Img"]) {
                 $dir = str_replace("..", "", $a_rec["Dir"]);
                 if ($dir != "" && $this->getImportDirectory() != "") {
                     $source_dir = $this->getImportDirectory() . "/" . $dir;
                     $target_dir = ilObjBlog::initStorage($newObj->getId());
                     ilUtil::rCopy($source_dir, $target_dir);
                 }
             }
             $a_mapping->addMapping("Modules/Blog", "blog", $a_rec["Id"], $newObj->getId());
             break;
         case "blog_posting":
             $blog_id = (int) $a_mapping->getMapping("Modules/Blog", "blog", $a_rec["BlogId"]);
             if ($blog_id) {
                 include_once "./Modules/Blog/classes/class.ilBlogPosting.php";
                 $newObj = new ilBlogPosting();
                 $newObj->setBlogId($blog_id);
                 $newObj->setTitle($a_rec["Title"]);
                 $newObj->setCreated(new ilDateTime($a_rec["Created"], IL_CAL_DATETIME));
                 $newObj->setApproved($a_rec["Approved"]);
                 // parse export id into local id (if possible)
                 $author = $this->parseObjectExportId($a_rec["Author"], -1);
                 $newObj->setAuthor($author["id"]);
                 $newObj->create(true);
                 $a_mapping->addMapping("Services/COPage", "pg", "blp:" . $a_rec["Id"], "blp:" . $newObj->getId());
             }
             break;
     }
 }