コード例 #1
0
 protected function deleteAllPages()
 {
     // delete pages
     include_once "Modules/Portfolio/classes/class.ilPortfolioPage.php";
     $pages = ilPortfolioPage::getAllPages($this->id);
     foreach ($pages as $page) {
         $page_obj = new ilPortfolioPage($page["id"]);
         $page_obj->setPortfolioId($this->id);
         $page_obj->delete();
     }
 }
コード例 #2
0
 public static function isInPortfolioPage(ilPortfolioPage $a_page, $a_type, $a_id)
 {
     // try to find verification in portfolio page
     $a_page->buildDom();
     $dom = $a_page->getDom();
     if ($dom instanceof php4DOMDocument) {
         $dom = $dom->myDOMDocument;
     }
     $xpath_temp = new DOMXPath($dom);
     $nodes = $xpath_temp->query("//PageContent/Verification");
     foreach ($nodes as $node) {
         if ($node->getAttribute("Type") == $a_type && $node->getAttribute("Id") == $a_id) {
             return true;
         }
     }
     return false;
 }
コード例 #3
0
 protected function doCloneObject($new_obj, $a_target_id, $a_copy_id = null)
 {
     self::cloneBasics($this, $new_obj);
     // copy pages
     include_once "Modules/Portfolio/classes/class.ilPortfolioTemplatePage.php";
     foreach (ilPortfolioPage::getAllPages($this->getId()) as $page) {
         // see ilObjWiki::cloneObject();
         $page = new ilPortfolioTemplatePage($page["id"]);
         $new_page = new ilPortfolioTemplatePage();
         $new_page->setPortfolioId($new_obj->getId());
         $new_page->setTitle($page->getTitle());
         $new_page->setType($page->getType());
         $new_page->setOrderNr($page->getOrderNr());
         $new_page->create();
         $page->copy($new_page->getId(), "", 0, true);
     }
 }
コード例 #4
0
 function getItems()
 {
     global $ilUser;
     include_once "./Services/Portfolio/classes/class.ilPortfolioPage.php";
     $data = ilPortfolioPage::getAllPages($this->portfolio->getId());
     $this->setData($data);
     $this->blogs = array();
     include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
     $tree = new ilWorkspaceTree($ilUser->getId());
     $root = $tree->readRootId();
     if ($root) {
         $root = $tree->getNodeData($root);
         foreach ($tree->getSubTree($root) as $node) {
             if ($node["type"] == "blog") {
                 $this->blogs[$node["obj_id"]] = $node["wsp_id"];
             }
         }
     }
     include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
 }
コード例 #5
0
 /**
  * Export all pages
  */
 function exportHTMLPages()
 {
     global $tpl, $ilBench, $ilLocator;
     require_once "Services/Portfolio/classes/class.ilPortfolioPage.php";
     $pages = ilPortfolioPage::getAllPages($this->object->getId());
     $this->tabs = array();
     foreach ($pages as $page) {
         // substitute blog id with title
         if ($page["type"] == ilPortfolioPage::TYPE_BLOG) {
             include_once "Modules/Blog/classes/class.ilObjBlog.php";
             $page["title"] = ilObjBlog::_lookupTitle((int) $page["title"]);
         }
         $this->tabs[$page["id"]] = $page["title"];
     }
     // for sub-pages, e.g. blog postings
     $tpl_callback = array($this, "buildExportTemplate");
     include_once "./Services/COPage/classes/class.ilPageContentUsage.php";
     include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
     $has_index = false;
     foreach ($pages as $page) {
         if (ilPageObject::_exists("prtf", $page["id"])) {
             $this->active_tab = "user_page_" . $page["id"];
             if ($page["type"] == ilPortfolioPage::TYPE_BLOG) {
                 $link_template = "prtf_" . $page["id"] . "_bl{TYPE}_{ID}.html";
                 include_once "Modules/Blog/classes/class.ilObjBlogGUI.php";
                 $blog = new ilObjBlogGUI((int) $page["title"], ilObject2GUI::WORKSPACE_OBJECT_ID);
                 $blog->exportHTMLPages($this->export_dir . "/", $link_template, $tpl_callback, $this->co_page_html_export, "prtf_" . $page["id"] . ".html");
             } else {
                 $this->exportPageHTML($page["id"]);
                 $this->co_page_html_export->collectPageElements("prtf:pg", $page["id"]);
             }
             if (!$has_index) {
                 copy($this->export_dir . "/prtf_" . $page["id"] . ".html", $this->export_dir . "/index.html");
                 $has_index = true;
             }
         }
     }
     $this->co_page_html_export->exportPageElements();
 }
コード例 #6
0
 /**
  * Get's the repository object ID of a parent object, if possible
  * 
  * see ilWebAccessChecker 
  */
 function getParentObjectIdForUsage($a_usage, $a_include_all_access_obj_ids = false)
 {
     if (is_int(strpos($a_usage["type"], ":"))) {
         $us_arr = explode(":", $a_usage["type"]);
         $type = $us_arr[1];
         $cont_type = $us_arr[0];
     } else {
         $type = $a_usage["type"];
     }
     $id = $a_usage["id"];
     $obj_id = false;
     switch ($type) {
         // RTE / tiny mce
         case "html":
             switch ($cont_type) {
                 case "qpl":
                     // Question Pool *Question* Text (Test)
                     include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
                     $qinfo = assQuestion::_getQuestionInfo($id);
                     if ($qinfo["original_id"] > 0) {
                         include_once "./Modules/Test/classes/class.ilObjTest.php";
                         $obj_id = ilObjTest::_lookupTestObjIdForQuestionId($id);
                         // usage in test
                     } else {
                         $obj_id = $qinfo["obj_fi"];
                         // usage in pool
                     }
                     break;
                 case "spl":
                     // Question Pool *Question* Text (Survey)
                     include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
                     $quest = SurveyQuestion::_instanciateQuestion($id);
                     if ($quest) {
                         if ($quest->getOriginalId() > 0) {
                             $obj_id = $quest->getSurveyId();
                         } else {
                             $obj_id = $quest->getObjId();
                             // usage in pool
                         }
                         unset($quest);
                     }
                     break;
                 case "exca":
                     // Exercise assignment
                     $returned_pk = $a_usage['id'];
                     // we are just checking against exercise object
                     include_once 'Modules/Exercise/classes/class.ilObjExercise.php';
                     $obj_id = ilObjExercise::lookupExerciseIdForReturnedId($returned_pk);
                     break;
                 case "frm":
                     // Forum
                     $post_pk = $a_usage['id'];
                     include_once 'Modules/Forum/classes/class.ilForumPost.php';
                     include_once 'Modules/Forum/classes/class.ilForum.php';
                     $oPost = new ilForumPost($post_pk);
                     $frm_pk = $oPost->getForumId();
                     $obj_id = ilForum::_lookupObjIdForForumId($frm_pk);
                     break;
                     // temporary items (per user)
                 // temporary items (per user)
                 case "frm~":
                 case "exca~":
                     $obj_id = $a_usage['id'];
                     break;
                     // "old" category pages
                 // "old" category pages
                 case "cat":
                     // InfoScreen Text
                 // InfoScreen Text
                 case "tst":
                 case "svy":
                     // data collection
                 // data collection
                 case "dcl":
                     $obj_id = $id;
                     break;
             }
             break;
             // page editor
         // page editor
         case "pg":
             switch ($cont_type) {
                 case "qpl":
                     // Question Pool Question Pages
                     include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
                     $qinfo = assQuestion::_getQuestionInfo($id);
                     if ($qinfo["original_id"] > 0) {
                         include_once "./Modules/Test/classes/class.ilObjTest.php";
                         $obj_id = ilObjTest::_lookupTestObjIdForQuestionId($id);
                         // usage in test
                     } else {
                         $obj_id = $qinfo["obj_fi"];
                         // usage in pool
                     }
                     break;
                 case "lm":
                 case "dbk":
                     // learning modules
                     include_once "./Modules/LearningModule/classes/class.ilLMObject.php";
                     $obj_id = ilLMObject::_lookupContObjID($id);
                     break;
                 case "gdf":
                     // glossary definition
                     include_once "./Modules/Glossary/classes/class.ilGlossaryDefinition.php";
                     include_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php";
                     $term_id = ilGlossaryDefinition::_lookupTermId($id);
                     $obj_id = ilGlossaryTerm::_lookGlossaryID($term_id);
                     break;
                 case "wpg":
                     // wiki page
                     include_once 'Modules/Wiki/classes/class.ilWikiPage.php';
                     $obj_id = ilWikiPage::lookupObjIdByPage($id);
                     break;
                 case "sahs":
                     // sahs page
                     // can this implementation be used for other content types, too?
                     include_once './Services/COPage/classes/class.ilPageObject.php';
                     $obj_id = ilPageObject::lookupParentId($id, 'sahs');
                     break;
                 case "prtf":
                     // portfolio
                     include_once "Modules/Portfolio/classes/class.ilPortfolioPage.php";
                     $obj_id = ilPortfolioPage::findPortfolioForPage($id);
                     break;
                 case "prtt":
                     // portfolio template
                     include_once "Modules/Portfolio/classes/class.ilPortfolioTemplatePage.php";
                     $obj_id = ilPortfolioTemplatePage::findPortfolioForPage($id);
                     break;
                 case "blp":
                     // blog
                     include_once './Services/COPage/classes/class.ilPageObject.php';
                     $obj_id = ilPageObject::lookupParentId($id, 'blp');
                     break;
                 case "crs":
                 case "grp":
                 case "cat":
                 case "fold":
                 case "root":
                     // repository pages
                     $obj_id = $id;
                     break;
             }
             break;
             // Media Pool
         // Media Pool
         case "mep":
             $obj_id = $id;
             break;
             // News Context Object (e.g. MediaCast)
         // News Context Object (e.g. MediaCast)
         case "news":
             include_once "./Services/News/classes/class.ilNewsItem.php";
             $obj_id = ilNewsItem::_lookupContextObjId($id);
             break;
     }
     return $obj_id;
 }
コード例 #7
0
 /**
  * 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!
             }
         }
     }
 }
コード例 #8
0
 /**
  * Get's the repository object ID of a parent object, if possible
  */
 function getParentObjectIdForUsage($a_usage, $a_include_all_access_obj_ids = false)
 {
     if (is_int(strpos($a_usage["type"], ":"))) {
         $us_arr = explode(":", $a_usage["type"]);
         $type = $us_arr[1];
         $cont_type = $us_arr[0];
     } else {
         $type = $a_usage["type"];
     }
     $id = $a_usage["id"];
     $obj_id = false;
     switch ($type) {
         case "html":
             // "old" category pages
             if ($cont_type == "cat") {
                 $obj_id = $id;
             }
             // Test InfoScreen Text
             if ($cont_type == "tst" || $cont_type == "svy") {
                 $obj_id = $id;
                 //var_dump($qinfo);
             }
             // Question Pool *Question* Text (Test)
             if ($cont_type == "qpl") {
                 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
                 $qinfo = assQuestion::_getQuestionInfo($id);
                 if ($qinfo["original_id"] > 0) {
                     include_once "./Modules/Test/classes/class.ilObjTest.php";
                     $obj_id = ilObjTest::_lookupTestObjIdForQuestionId($id);
                     // usage in test
                 } else {
                     $obj_id = $qinfo["obj_fi"];
                     // usage in pool
                 }
             }
             // Question Pool *Question* Text (Survey)
             if ($cont_type == "spl") {
                 include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
                 $quest = SurveyQuestion::_instanciateQuestion($id);
                 if ($quest) {
                     if ($quest->getOriginalId() > 0) {
                         $obj_id = $quest->getSurveyId();
                     } else {
                         $obj_id = $quest->getObjId();
                         // usage in pool
                     }
                     unset($quest);
                 }
             }
             // Forum
             if ($cont_type == "frm") {
                 $post_pk = $a_usage['id'];
                 include_once 'Modules/Forum/classes/class.ilForumPost.php';
                 include_once 'Modules/Forum/classes/class.ilForum.php';
                 $oPost = new ilForumPost($post_pk);
                 $frm_pk = $oPost->getForumId();
                 $obj_id = ilForum::_lookupObjIdForForumId($frm_pk);
             }
             if ($cont_type == 'frm~') {
                 $obj_id = $a_usage['id'];
             }
             if ($cont_type == "dcl") {
                 $obj_id = $id;
             }
             break;
         case "pg":
             // Question Pool Question Pages
             if ($cont_type == "qpl") {
                 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
                 $qinfo = assQuestion::_getQuestionInfo($id);
                 if ($qinfo["original_id"] > 0) {
                     include_once "./Modules/Test/classes/class.ilObjTest.php";
                     $obj_id = ilObjTest::_lookupTestObjIdForQuestionId($id);
                     // usage in test
                 } else {
                     $obj_id = $qinfo["obj_fi"];
                     // usage in pool
                 }
             }
             // learning modules
             if ($cont_type == "lm" || $cont_type == "dbk") {
                 include_once "./Modules/LearningModule/classes/class.ilLMObject.php";
                 $obj_id = ilLMObject::_lookupContObjID($id);
             }
             // glossary definition
             if ($cont_type == "gdf") {
                 include_once "./Modules/Glossary/classes/class.ilGlossaryDefinition.php";
                 include_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php";
                 $term_id = ilGlossaryDefinition::_lookupTermId($id);
                 $obj_id = ilGlossaryTerm::_lookGlossaryID($term_id);
             }
             // wiki page
             if ($cont_type == 'wpg') {
                 include_once 'Modules/Wiki/classes/class.ilWikiPage.php';
                 $obj_id = ilWikiPage::lookupObjIdByPage($id);
             }
             // sahs page
             if ($cont_type == 'sahs') {
                 // can this implementation be used for other content types, too?
                 include_once './Services/COPage/classes/class.ilPageObject.php';
                 $obj_id = ilPageObject::lookupParentId($id, 'sahs');
             }
             // repository pages
             if (in_array($cont_type, array("crs", "grp", "cat", "fold", "root"))) {
                 $obj_id = $id;
             }
             if ($cont_type == 'prtf') {
                 include_once "Services/Portfolio/classes/class.ilPortfolioPage.php";
                 $obj_id = ilPortfolioPage::findPortfolioForPage($id);
             }
             if ($cont_type == 'blp') {
                 include_once './Services/COPage/classes/class.ilPageObject.php';
                 $obj_id = ilPageObject::lookupParentId($id, 'blp');
             }
             break;
             // Media Pool
         // Media Pool
         case "mep":
             $obj_id = $id;
             break;
             // News Context Object (e.g. MediaCast)
         // News Context Object (e.g. MediaCast)
         case "news":
             include_once "./Services/News/classes/class.ilNewsItem.php";
             $obj_id = ilNewsItem::_lookupContextObjId($id);
             break;
     }
     return $obj_id;
 }
コード例 #9
0
 /**
  * Get portfolio template page instance
  * 
  * @param int $a_page_id
  * @param int $a_portfolio_id
  * @return ilPortfolioPage
  */
 protected function getPageInstance($a_page_id = null, $a_portfolio_id = null)
 {
     // #11531
     if (!$a_portfolio_id && $this->object) {
         $a_portfolio_id = $this->object->getId();
     }
     include_once "Modules/Portfolio/classes/class.ilPortfolioPage.php";
     $page = new ilPortfolioPage($a_page_id);
     $page->setPortfolioId($a_portfolio_id);
     return $page;
 }
コード例 #10
0
 /**
  * Show user page
  */
 function preview($a_return = false, $a_content = false, $a_show_notes = true)
 {
     global $ilSetting;
     $portfolio_id = $this->object->getId();
     $user_id = $this->object->getOwner();
     $this->tabs_gui->clearTargets();
     $pages = ilPortfolioPage::getAllPages($portfolio_id);
     $current_page = (int) $_GET["user_page"];
     // validate current page
     if ($pages && $current_page) {
         $found = false;
         foreach ($pages as $page) {
             if ($page["id"] == $current_page) {
                 $found = true;
                 break;
             }
         }
         if (!$found) {
             $current_page = null;
         }
     }
     // display first page of portfolio if none given
     if (!$current_page && $pages) {
         $current_page = $pages;
         $current_page = array_shift($current_page);
         $current_page = $current_page["id"];
     }
     // #13788 - keep page after login
     if ($this->user_id == ANONYMOUS_USER_ID && $this->getType() == "prtf") {
         $this->tpl->setLoginTargetPar("prtf_" . $this->object->getId() . "_" . $current_page);
     }
     // public profile
     if ($_REQUEST["back_url"]) {
         $back = $_REQUEST["back_url"];
     } else {
         if ($_GET["baseClass"] != "ilPublicUserProfileGUI" && $this->user_id && $this->user_id != ANONYMOUS_USER_ID) {
             if (!$this->checkPermissionBool("write")) {
                 // shared
                 if ($this->getType() == "prtf") {
                     $this->ctrl->setParameterByClass("ilportfoliorepositorygui", "shr_id", $this->object->getOwner());
                     $back = $this->ctrl->getLinkTargetByClass(array("ilpersonaldesktopgui", "ilportfoliorepositorygui"), "showOther");
                     $this->ctrl->setParameterByClass("ilportfoliorepositorygui", "shr_id", "");
                 } else {
                     // #12819
                     global $tree;
                     $parent_id = $tree->getParentId($this->node_id);
                     include_once "Services/Link/classes/class.ilLink.php";
                     $back = ilLink::_getStaticLink($parent_id);
                 }
             } else {
                 $back = $this->ctrl->getLinkTarget($this, "view");
             }
         }
     }
     global $ilMainMenu;
     $ilMainMenu->setMode(ilMainMenuGUI::MODE_TOPBAR_ONLY);
     if ($back) {
         // might already be set in ilPublicUserProfileGUI
         $ilMainMenu->setTopBarBack($back);
     }
     // render tabs
     $current_blog = null;
     if (count($pages) > 1) {
         foreach ($pages as $p) {
             if ($p["type"] == ilPortfolioPage::TYPE_BLOG) {
                 // needed for blog comments (see below)
                 if ($p["id"] == $current_page) {
                     $current_blog = (int) $p["title"];
                 }
                 include_once "Modules/Blog/classes/class.ilObjBlog.php";
                 $p["title"] = ilObjBlog::_lookupTitle($p["title"]);
             }
             $this->ctrl->setParameter($this, "user_page", $p["id"]);
             $this->tabs_gui->addTab("user_page_" . $p["id"], $p["title"], $this->ctrl->getLinkTarget($this, "preview"));
         }
         $this->tabs_gui->activateTab("user_page_" . $current_page);
     }
     $this->ctrl->setParameter($this, "user_page", $current_page);
     if (!$a_content) {
         // get current page content
         $page_gui = $this->getPageGUIInstance($current_page);
         $page_gui->setEmbedded(true);
         $content = $this->ctrl->getHTML($page_gui);
     } else {
         $content = $a_content;
     }
     if ($a_return && $this->checkPermissionBool("write")) {
         return $content;
     }
     // blog posting comments are handled within the blog
     $notes = "";
     if ($a_show_notes && $this->object->hasPublicComments() && !$current_blog) {
         include_once "./Services/Notes/classes/class.ilNoteGUI.php";
         $note_gui = new ilNoteGUI($portfolio_id, $current_page, "pfpg");
         $note_gui->setRepositoryMode(false);
         $note_gui->enablePublicNotes(true);
         $note_gui->enablePrivateNotes(false);
         $note_gui->enablePublicNotesDeletion($this->user_id == $user_id && $ilSetting->get("comments_del_tutor", 1));
         $next_class = $this->ctrl->getNextClass($this);
         if ($next_class == "ilnotegui") {
             $notes = $this->ctrl->forwardCommand($note_gui);
         } else {
             $notes = $note_gui->getNotesHTML();
         }
     }
     if ($this->perma_link === null) {
         if ($this->getType() == "prtf") {
             $this->tpl->setPermanentLink($this->getType(), $this->object->getId(), "_" . $current_page);
         } else {
             $this->tpl->setPermanentLink($this->getType(), $this->object->getRefId());
         }
     } else {
         $this->tpl->setPermanentLink($this->perma_link["type"], $this->perma_link["obj_id"]);
     }
     self::renderFullscreenHeader($this->object, $this->tpl, $user_id);
     // #13564
     $this->ctrl->setParameter($this, "user_page", "");
     $this->tpl->setTitleUrl($this->ctrl->getLinkTarget($this, "preview"));
     $this->ctrl->setParameter($this, "user_page", $this->page_id);
     // blog pages do their own (page) style handling
     if (!$current_blog) {
         $content = '<div id="ilCOPageContent" class="ilc_page_cont_PageContainer">' . '<div class="ilc_page_Page">' . $content . '</div></div>';
         $this->setContentStyleSheet($this->tpl);
     }
     // #10717
     $this->tpl->setContent($content . '<div class="ilClearFloat">' . $notes . '</div>');
 }
コード例 #11
0
 /**
  * Show user page
  */
 function preview($a_return = false, $a_content = false, $a_show_notes = true)
 {
     // public profile
     if ($_REQUEST["back_url"]) {
         $back = $_REQUEST["back_url"];
     } else {
         if ($_GET["baseClass"] != "ilPublicUserProfileGUI" && $this->user_id && $this->user_id != ANONYMOUS_USER_ID) {
             if (!$this->checkPermissionBool("write")) {
                 $this->ctrl->setParameterByClass("ilportfoliorepositorygui", "shr_id", $this->object->getOwner());
                 $back = $this->ctrl->getLinkTargetByClass(array("ilpersonaldesktopgui", "ilportfoliorepositorygui"), "showOther");
                 $this->ctrl->setParameterByClass("ilportfoliorepositorygui", "shr_id", "");
             } else {
                 $back = $this->ctrl->getLinkTarget($this, "view");
             }
         }
     }
     $this->tpl->setTopBar($back);
     $portfolio_id = $this->object->getId();
     $user_id = $this->object->getOwner();
     $this->tabs_gui->clearTargets();
     $pages = ilPortfolioPage::getAllPages($portfolio_id);
     $current_page = (int) $_GET["user_page"];
     // validate current page
     if ($pages && $current_page) {
         $found = false;
         foreach ($pages as $page) {
             if ($page["id"] == $current_page) {
                 $found = true;
                 break;
             }
         }
         if (!$found) {
             $current_page = null;
         }
     }
     // display first page of portfolio if none given
     if (!$current_page && $pages) {
         $current_page = $pages;
         $current_page = array_shift($current_page);
         $current_page = $current_page["id"];
     }
     // render tabs
     $current_blog = null;
     if (count($pages) > 1) {
         foreach ($pages as $p) {
             if ($p["type"] == ilPortfolioPage::TYPE_BLOG) {
                 // needed for blog comments (see below)
                 if ($p["id"] == $current_page) {
                     $current_blog = (int) $p["title"];
                 }
                 include_once "Modules/Blog/classes/class.ilObjBlog.php";
                 $p["title"] = ilObjBlog::_lookupTitle($p["title"]);
             }
             $this->ctrl->setParameter($this, "user_page", $p["id"]);
             $this->tabs_gui->addTab("user_page_" . $p["id"], $p["title"], $this->ctrl->getLinkTarget($this, "preview"));
         }
         $this->tabs_gui->activateTab("user_page_" . $current_page);
     }
     $this->ctrl->setParameter($this, "user_page", $current_page);
     if (!$a_content) {
         // get current page content
         $page_gui = $this->getPageGUIInstance($current_page);
         $page_gui->setEmbedded(true);
         $content = $this->ctrl->getHTML($page_gui);
     } else {
         $content = $a_content;
     }
     if ($a_return && $this->checkPermissionBool("write")) {
         return $content;
     }
     // blog posting comments are handled within the blog
     $notes = "";
     if ($a_show_notes && $this->object->hasPublicComments() && !$current_blog) {
         include_once "./Services/Notes/classes/class.ilNoteGUI.php";
         $note_gui = new ilNoteGUI($portfolio_id, $current_page, "pfpg");
         $note_gui->setRepositoryMode(false);
         $note_gui->enablePublicNotes(true);
         $note_gui->enablePrivateNotes(false);
         $note_gui->enablePublicNotesDeletion($this->user_id == $user_id);
         $next_class = $this->ctrl->getNextClass($this);
         if ($next_class == "ilnotegui") {
             $notes = $this->ctrl->forwardCommand($note_gui);
         } else {
             $notes = $note_gui->getNotesHTML();
         }
     }
     if ($this->perma_link === null) {
         include_once 'Services/PermanentLink/classes/class.ilPermanentLinkGUI.php';
         if ($this->getType() == "prtf") {
             $plink = new ilPermanentLinkGUI($this->getType(), $this->object->getId(), "_" . $current_page);
         } else {
             $plink = new ilPermanentLinkGUI($this->getType(), $this->object->getRefId());
         }
         $plink = $plink->getHTML();
     } else {
         $plink = $this->perma_link;
     }
     self::renderFullscreenHeader($this->object, $this->tpl, $user_id);
     // wiki/forum will set locator items
     $this->tpl->setVariable("LOCATOR", "");
     // blog pages do their own (page) style handling
     if (!$current_blog) {
         $content = '<div id="ilCOPageContent" class="ilc_page_cont_PageContainer">' . '<div class="ilc_page_Page">' . $content . '</div></div>';
         $this->setContentStyleSheet($this->tpl);
     }
     // #10717
     $this->tpl->setContent($content . '<div class="ilClearFloat">' . $notes . $plink . '</div>');
     $this->tpl->setFrameFixedWidth(true);
     echo $this->tpl->show("DEFAULT", true, true);
     exit;
 }
コード例 #12
0
 protected function doDelete()
 {
     global $ilDB;
     // delete pages
     include_once "Services/Portfolio/classes/class.ilPortfolioPage.php";
     $pages = ilPortfolioPage::getAllPages($this->id);
     foreach ($pages as $page) {
         $page = new ilPortfolioPage($this->id, $page["id"]);
         $page->delete();
     }
     $this->deleteImage();
     $ilDB->manipulate("DELETE FROM usr_portfolio" . " WHERE id = " . $ilDB->quote($this->id, "integer"));
 }
コード例 #13
0
 /**
  * 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;
         }
     }
     self::cloneBasics($a_source, $a_target);
     // personal skills
     include_once "Services/Skill/classes/class.ilPersonalSkill.php";
     $pskills = array_keys(ilPersonalSkill::getSelectedUserSkills($ilUser->getId()));
     // 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
                 if ($direction == "t2p") {
                     $dom = $target_page->getDom();
                     if ($dom instanceof php4DOMDocument) {
                         $dom = $dom->myDOMDocument;
                     }
                     // update profile/consultation hours user id
                     self::updateDomNodes($dom, "//PageContent/Profile", "User", $ilUser->getId());
                     self::updateDomNodes($dom, "//PageContent/ConsultationHours", "User", $ilUser->getId());
                     self::updateDomNodes($dom, "//PageContent/MyCourses", "User", $ilUser->getId());
                     // skills
                     $xpath = new DOMXPath($dom);
                     $nodes = $xpath->query("//PageContent/Skills");
                     foreach ($nodes as $node) {
                         $skill_id = $node->getAttribute("Id");
                         // existing personal skills
                         if (in_array($skill_id, $pskills)) {
                             $node->setAttribute("User", $ilUser->getId());
                         } else {
                             if (in_array($skill_id, $a_recipe["skills"])) {
                                 include_once "Services/Skill/classes/class.ilPersonalSkill.php";
                                 ilPersonalSkill::addPersonalSkill($ilUser->getId(), $skill_id);
                                 $node->setAttribute("User", $ilUser->getId());
                             } else {
                                 $page_element = $node->parentNode;
                                 $page_element->parentNode->removeChild($page_element);
                             }
                         }
                     }
                 }
                 $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!
             }
         }
     }
 }
コード例 #14
0
 function copyPage()
 {
     global $ilCtrl, $lng;
     $form = $this->initCopyPageForm();
     if ($form->checkInput()) {
         // existing
         if ($form->getInput("target") == "old") {
             $portfolio_id = $form->getInput("prtf");
             $portfolio = new ilObjPortfolio($portfolio_id, false);
         } else {
             $portfolio = new ilObjPortfolio();
             $portfolio->setTitle($form->getInput("title"));
             $portfolio->create();
             $portfolio_id = $portfolio->getId();
         }
         // copy page(s)
         include_once "Services/Portfolio/classes/class.ilPortfolioPage.php";
         foreach ($_POST["prtf_pages"] as $page_id) {
             $source = new ilPortfolioPage($portfolio_id, $page_id);
             $target = new ilPortfolioPage($portfolio_id);
             $target->setXMLContent($source->copyXmlContent());
             $target->setType($source->getType());
             $target->setTitle($source->getTitle());
             $target->create();
         }
         ilUtil::sendSuccess($lng->txt("prtf_pages_copied"), true);
         $ilCtrl->redirect($this, "pages");
     }
     $form->setValuesByPost();
     $this->copyPageForm($form);
 }