/**
  * 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;
 }
 /**
  * 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>');
 }
 /**
  * Show user page
  */
 function preview($a_return = false, $a_content = false, $a_show_notes = true)
 {
     global $ilUser, $tpl, $ilCtrl, $ilTabs, $lng;
     // public profile
     if ($_REQUEST["back_url"]) {
         $back = $_REQUEST["back_url"];
     } else {
         if ($_GET["baseClass"] != "ilPublicUserProfileGUI" && $ilUser->getId() && $ilUser->getId() != ANONYMOUS_USER_ID) {
             if (!$this->checkAccess("write")) {
                 $ilCtrl->setParameter($this, "user", $this->portfolio->getOwner());
                 $back = $ilCtrl->getLinkTarget($this, "showOther");
                 $ilCtrl->setParameter($this, "user", "");
             } else {
                 $back = $ilCtrl->getLinkTarget($this, "pages");
             }
         }
     }
     $tpl->setTopBar($back);
     $portfolio_id = $this->portfolio->getId();
     $user_id = $this->portfolio->getOwner();
     $ilTabs->clearTargets();
     include_once "./Services/Portfolio/classes/class.ilPortfolioPage.php";
     $pages = ilPortfolioPage::getAllPages($portfolio_id);
     $current_page = $_GET["user_page"];
     // 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"]);
             }
             $ilCtrl->setParameter($this, "user_page", $p["id"]);
             $ilTabs->addTab("user_page_" . $p["id"], $p["title"], $ilCtrl->getLinkTarget($this, "preview"));
         }
         $ilTabs->activateTab("user_page_" . $current_page);
     }
     $ilCtrl->setParameter($this, "user_page", $current_page);
     if (!$a_content) {
         // get current page content
         include_once "./Services/Portfolio/classes/class.ilPortfolioPageGUI.php";
         $page_gui = new ilPortfolioPageGUI($portfolio_id, $current_page, 0, $this->portfolio->hasPublicComments());
         $page_gui->setEmbedded(true);
         $page_gui->setAdditional($this->getAdditional());
         $content = $ilCtrl->getHTML($page_gui);
     } else {
         $content = $a_content;
     }
     if ($a_return && $this->checkAccess("write")) {
         return $content;
     }
     // blog posting comments are handled within the blog
     $notes = "";
     if ($a_show_notes && $this->portfolio->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($ilUser->getId() == $user_id);
         $next_class = $ilCtrl->getNextClass($this);
         if ($next_class == "ilnotegui") {
             $notes = $ilCtrl->forwardCommand($note_gui);
         } else {
             $notes = $note_gui->getNotesHTML();
         }
     }
     if ($this->perma_link === null) {
         include_once 'Services/PermanentLink/classes/class.ilPermanentLinkGUI.php';
         $plink = new ilPermanentLinkGUI("prtf", $this->portfolio->getId());
         $plink = $plink->getHTML();
     } else {
         $plink = $this->perma_link;
     }
     self::renderFullscreenHeader($this->portfolio, $tpl, $user_id);
     // wiki/forum will set locator items
     $tpl->setVariable("LOCATOR", "");
     // #10717
     $tpl->setContent($content . '<div class="ilClearFloat">' . $notes . $plink . '</div>');
     $tpl->setFrameFixedWidth(true);
     echo $tpl->show("DEFAULT", true, true);
     exit;
 }