Example #1
0
 public function viewThreadObject()
 {
     /**
      * @var $tpl ilTemplate
      * @var $lng ilLanguage
      * @var $ilUser ilObjUser
      * @var $ilAccess ilAccessHandler
      * @var $rbacreview ilRbacReview
      * @var $ilNavigationHistory ilNavigationHistory
      * @var $ilCtrl ilCtrl
      * @var $ilToolbar ilToolbarGUI
      */
     global $tpl, $lng, $ilUser, $ilAccess, $rbacreview, $ilNavigationHistory, $ilCtrl, $frm, $ilToolbar, $ilLocator;
     $tpl->addCss('./Modules/Forum/css/forum_tree.css');
     if (!isset($_SESSION['viewmode'])) {
         $_SESSION['viewmode'] = $this->objProperties->getDefaultView();
     }
     // quick and dirty: check for treeview
     if (!isset($_SESSION['thread_control']['old'])) {
         $_SESSION['thread_control']['old'] = $_GET['thr_pk'];
         $_SESSION['thread_control']['new'] = $_GET['thr_pk'];
     } else {
         if (isset($_SESSION['thread_control']['old']) && $_GET['thr_pk'] != $_SESSION['thread_control']['old']) {
             $_SESSION['thread_control']['new'] = $_GET['thr_pk'];
         }
     }
     if (isset($_GET['viewmode']) && $_GET['viewmode'] != $_SESSION['viewmode']) {
         $_SESSION['viewmode'] = $_GET['viewmode'];
     }
     if (isset($_GET['action']) && $_SESSION['viewmode'] != ilForumProperties::VIEW_DATE || $_SESSION['viewmode'] == ilForumProperties::VIEW_TREE) {
         $_SESSION['viewmode'] = ilForumProperties::VIEW_TREE;
     } else {
         $_SESSION['viewmode'] = ilForumProperties::VIEW_DATE;
     }
     if (!$ilAccess->checkAccess('read', '', $this->object->getRefId())) {
         $this->ilias->raiseError($lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
     }
     // init objects
     $oForumObjects = $this->getForumObjects();
     /**
      * @var $forumObj ilObjForum
      */
     $forumObj = $oForumObjects['forumObj'];
     /**
      * @var $frm ilForum
      */
     $frm = $oForumObjects['frm'];
     /**
      * @var $file_obj ilFileDataForum
      */
     $file_obj = $oForumObjects['file_obj'];
     // download file
     if ($_GET['file']) {
         if (!($path = $file_obj->getFileDataByMD5Filename($_GET['file']))) {
             ilUtil::sendFailure($this->lng->txt('error_reading_file'));
         } else {
             ilUtil::deliverFile($path['path'], $path['clean_filename']);
         }
     }
     if (!$this->objCurrentTopic->getId()) {
         $ilCtrl->redirect($this, 'showThreads');
     }
     // Set context for login
     $append = '_' . $this->objCurrentTopic->getId() . ($this->objCurrentPost->getId() ? '_' . $this->objCurrentPost->getId() : '');
     $tpl->setLoginTargetPar('frm_' . $_GET['ref_id'] . $append);
     // delete temporary media object (not in case a user adds media objects and wants to save an invalid form)
     if ($_GET['action'] != 'showreply' && $_GET['action'] != 'showedit') {
         try {
             include_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
             $mobs = ilObjMediaObject::_getMobsOfObject('frm~:html', $ilUser->getId());
             foreach ($mobs as $mob) {
                 if (ilObjMediaObject::_exists($mob)) {
                     ilObjMediaObject::_removeUsage($mob, 'frm~:html', $ilUser->getId());
                     $mob_obj = new ilObjMediaObject($mob);
                     $mob_obj->delete();
                 }
             }
         } catch (Exception $e) {
         }
     }
     require_once './Modules/Forum/classes/class.ilObjForum.php';
     require_once './Modules/Forum/classes/class.ilFileDataForum.php';
     $lng->loadLanguageModule('forum');
     // add entry to navigation history
     if (!$this->getCreationMode() && $ilAccess->checkAccess('read', '', $this->object->getRefId())) {
         $ilCtrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
         $ilNavigationHistory->addItem($this->object->getRefId(), $ilCtrl->getLinkTarget($this, 'showThreads'), 'frm');
     }
     // save last access
     $forumObj->updateLastAccess($ilUser->getId(), (int) $this->objCurrentTopic->getId());
     $this->prepareThreadScreen($forumObj);
     $tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.forums_threads_view.html', 'Modules/Forum');
     if (isset($_GET['anchor'])) {
         $tpl->setVariable('JUMP2ANCHOR_ID', (int) $_GET['anchor']);
     }
     if ($_SESSION['viewmode'] == 'date' || $_SESSION['viewmode'] == ilForumProperties::VIEW_DATE) {
         $orderField = 'frm_posts_tree.fpt_date';
         $this->objCurrentTopic->setOrderDirection(in_array($this->objProperties->getDefaultView(), array(ilForumProperties::VIEW_DATE_ASC, ilForumProperties::VIEW_TREE)) ? 'ASC' : 'DESC');
     } else {
         $orderField = 'frm_posts_tree.rgt';
         $this->objCurrentTopic->setOrderDirection('DESC');
     }
     // get forum- and thread-data
     $frm->setMDB2WhereCondition('top_frm_fk = %s ', array('integer'), array($frm->getForumId()));
     if (is_array($topicData = $frm->getOneTopic())) {
         // Visit-Counter for topic
         $this->objCurrentTopic->updateVisits();
         $tpl->setTitle($lng->txt('forums_thread') . " \"" . $this->objCurrentTopic->getSubject() . "\"");
         // ********************************************************************************
         // build location-links
         $ilLocator->addRepositoryItems();
         $ilLocator->addItem($this->object->getTitle(), $ilCtrl->getLinkTarget($this, ""), "_top");
         $tpl->setLocator();
         // set tabs
         // menu template (contains linkbar)
         /** @var $menutpl ilTemplate */
         $menutpl = new ilTemplate('tpl.forums_threads_menu.html', true, true, 'Modules/Forum');
         include_once "./Services/Accessibility/classes/class.ilAccessKeyGUI.php";
         // mark all as read
         if ($ilUser->getId() != ANONYMOUS_USER_ID && $forumObj->getCountUnread($ilUser->getId(), (int) $this->objCurrentTopic->getId())) {
             $this->ctrl->setParameter($this, 'mark_read', '1');
             $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
             $ilToolbar->addButton($this->lng->txt('forums_mark_read'), $this->ctrl->getLinkTarget($this, 'viewThread'), '', ilAccessKey::MARK_ALL_READ);
             $this->ctrl->clearParameters($this);
         }
         // print thread
         $this->ctrl->setParameterByClass('ilforumexportgui', 'print_thread', $this->objCurrentTopic->getId());
         $this->ctrl->setParameterByClass('ilforumexportgui', 'thr_top_fk', $this->objCurrentTopic->getForumId());
         $ilToolbar->addButton($this->lng->txt('forums_print_thread'), $this->ctrl->getLinkTargetByClass('ilforumexportgui', 'printThread'));
         $this->ctrl->clearParametersByClass('ilforumexportgui');
         $this->addHeaderAction();
         if ($_GET['mark_read']) {
             $forumObj->markThreadRead($ilUser->getId(), (int) $this->objCurrentTopic->getId());
             ilUtil::sendInfo($lng->txt('forums_thread_marked'), true);
         }
         // delete post and its sub-posts
         require_once './Modules/Forum/classes/class.ilForum.php';
         if ($_GET['action'] == 'ready_delete' && $_POST['confirm'] != '') {
             if (!$this->objCurrentTopic->isClosed() && ($this->is_moderator || $this->objCurrentPost->isOwner($ilUser->getId()) && !$this->objCurrentPost->hasReplies()) && $ilUser->getId() != ANONYMOUS_USER_ID) {
                 $frm = new ilForum();
                 $frm->setForumId($forumObj->getId());
                 $frm->setForumRefId($forumObj->getRefId());
                 $dead_thr = $frm->deletePost($this->objCurrentPost->getId());
                 // if complete thread was deleted ...
                 if ($dead_thr == $this->objCurrentTopic->getId()) {
                     $frm->setMDB2WhereCondition('top_frm_fk = %s ', array('integer'), array($forumObj->getId()));
                     $topicData = $frm->getOneTopic();
                     ilUtil::sendInfo($lng->txt('forums_post_deleted'), true);
                     if ($topicData['top_num_threads'] > 0) {
                         $this->ctrl->redirect($this, 'showThreads');
                     } else {
                         $this->ctrl->redirect($this, 'createThread');
                     }
                 }
                 ilUtil::sendInfo($lng->txt('forums_post_deleted'));
             }
         }
         // form processing (censor)
         if (!$this->objCurrentTopic->isClosed() && $_GET['action'] == 'ready_censor') {
             if (($_POST['confirm'] != '' || $_POST['no_cs_change'] != '') && $_GET['action'] == 'ready_censor') {
                 $frm->postCensorship($this->handleFormInput($_POST['formData']['cens_message']), $this->objCurrentPost->getId(), 1);
             } else {
                 if (($_POST['cancel'] != '' || $_POST['yes_cs_change'] != '') && $_GET['action'] == 'ready_censor') {
                     $frm->postCensorship($this->handleFormInput($_POST['formData']['cens_message']), $this->objCurrentPost->getId());
                 }
             }
         }
         // get complete tree of thread
         $first_node = $this->objCurrentTopic->getFirstPostNode();
         $this->objCurrentTopic->setOrderField($orderField);
         $subtree_nodes = $this->objCurrentTopic->getPostTree($first_node);
         // no posts
         if (!($posNum = count($subtree_nodes))) {
             ilUtil::sendInfo($this->lng->txt('forums_no_posts_available'));
         }
         $pageHits = $frm->getPageHits();
         $z = 0;
         // navigation to browse
         if ($posNum > $pageHits) {
             $params = array('ref_id' => $_GET['ref_id'], 'thr_pk' => $this->objCurrentTopic->getId(), 'orderby' => $_GET['orderby']);
             if (!$_GET['offset']) {
                 $Start = 0;
             } else {
                 $Start = $_GET['offset'];
             }
             $linkbar = ilUtil::Linkbar($ilCtrl->getLinkTarget($this, 'viewThread'), $posNum, $pageHits, $Start, $params);
             if ($linkbar != '') {
                 $menutpl->setCurrentBlock('linkbar');
                 $menutpl->setVariable('LINKBAR', $linkbar);
                 $menutpl->parseCurrentBlock();
             }
         }
         $tpl->setVariable('THREAD_MENU', $menutpl->get());
         // assistance val for anchor-links
         $jump = 0;
         // generate post-dates
         foreach ($subtree_nodes as $node) {
             /**
              * @var $node ilForumPost 
              */
             $this->ctrl->clearParameters($this);
             if ($this->objCurrentPost->getId() && $this->objCurrentPost->getId() == $node->getId()) {
                 $jump++;
             }
             if ($posNum > $pageHits && $z >= $Start + $pageHits) {
                 // if anchor-link was not found ...
                 if ($this->objCurrentPost->getId() && $jump < 1) {
                     $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
                     $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
                     $this->ctrl->setParameter($this, 'offset', $Start + $pageHits);
                     $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
                     $this->ctrl->redirect($this, 'viewThread', $this->objCurrentPost->getId());
                     exit;
                 } else {
                     break;
                 }
             }
             if ($posNum > $pageHits && $z >= $Start || $posNum <= $pageHits) {
                 if ($this->objCurrentPost->getId() == $node->getId()) {
                     # actions for "active" post
                     if ($this->is_moderator || $node->isActivated()) {
                         // reply/edit
                         if (!$this->objCurrentTopic->isClosed() && ($_GET['action'] == 'showreply' || $_GET['action'] == 'showedit')) {
                             if ($_GET['action'] == 'showedit' && (!$this->is_moderator && !$node->isOwner($ilUser->getId()) || $ilUser->getId() == ANONYMOUS_USER_ID || $node->isCensored())) {
                                 $this->ilias->raiseError($lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
                             } else {
                                 if ($_GET['action'] == 'showreply' && !$ilAccess->checkAccess('add_reply', '', (int) $_GET['ref_id'])) {
                                     $this->ilias->raiseError($lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
                                 }
                             }
                             $tpl->setVariable('REPLY_ANKER', $this->objCurrentPost->getId());
                             $oEditReplyForm = $this->getReplyEditForm();
                             switch ($this->objProperties->getSubjectSetting()) {
                                 case 'add_re_to_subject':
                                     $subject = $this->getModifiedReOnSubject(true);
                                     break;
                                 case 'preset_subject':
                                     $subject = $this->objCurrentPost->getSubject();
                                     break;
                                 case 'empty_subject':
                                 default:
                                     $subject = NULL;
                                     break;
                             }
                             switch ($_GET['action']) {
                                 case 'showreply':
                                     if ($this->ctrl->getCmd() == 'savePost') {
                                         $oEditReplyForm->setValuesByPost();
                                     } else {
                                         if ($this->ctrl->getCmd() == 'quotePost') {
                                             require_once 'Modules/Forum/classes/class.ilForumAuthorInformation.php';
                                             $authorinfo = new ilForumAuthorInformation($node->getPosAuthorId(), $node->getDisplayUserId(), $node->getUserAlias(), $node->getImportName());
                                             $oEditReplyForm->setValuesByPost();
                                             $oEditReplyForm->getItemByPostVar('message')->setValue(ilRTE::_replaceMediaObjectImageSrc($frm->prepareText($node->getMessage(), 1, $authorinfo->getAuthorName()) . "\n" . $oEditReplyForm->getInput('message'), 1));
                                         } else {
                                             $oEditReplyForm->setValuesByArray(array('alias' => '', 'subject' => $subject, 'message' => '', 'notify' => 0, 'userfile' => '', 'del_file' => array()));
                                         }
                                     }
                                     $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
                                     $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
                                     $jsTpl = new ilTemplate('tpl.forum_post_quoation_ajax_handler.html', true, true, 'Modules/Forum/');
                                     $jsTpl->setVariable('IL_FRM_QUOTE_CALLBACK_SRC', $this->ctrl->getLinkTarget($this, 'getQuotationHTMLAsynch', '', true));
                                     $this->ctrl->clearParameters($this);
                                     $this->tpl->setVariable('FORM_ADDITIONAL_JS', $jsTpl->get());
                                     break;
                                 case 'showedit':
                                     if ($this->ctrl->getCmd() == 'savePost') {
                                         $oEditReplyForm->setValuesByPost();
                                     } else {
                                         $oEditReplyForm->setValuesByArray(array('alias' => '', 'subject' => $this->objCurrentPost->getSubject(), 'message' => ilRTE::_replaceMediaObjectImageSrc($frm->prepareText($this->objCurrentPost->getMessage(), 2), 1), 'notify' => $this->objCurrentPost->isNotificationEnabled() ? true : false, 'userfile' => '', 'del_file' => array()));
                                     }
                                     break;
                             }
                             $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
                             $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
                             $this->ctrl->setParameter($this, 'offset', (int) $_GET['offset']);
                             $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
                             $this->ctrl->setParameter($this, 'action', $_GET['action']);
                             $tpl->setVariable('FORM', $oEditReplyForm->getHTML());
                             $this->ctrl->clearParameters($this);
                         } else {
                             if (!$this->objCurrentTopic->isClosed() && $_GET['action'] == 'delete') {
                                 if ($this->is_moderator || $node->isOwner($ilUser->getId()) && !$node->hasReplies() && $ilUser->getId() != ANONYMOUS_USER_ID) {
                                     // confirmation: delete
                                     $tpl->setVariable('FORM', $this->getDeleteFormHTML());
                                 }
                             } else {
                                 if (!$this->objCurrentTopic->isClosed() && $_GET['action'] == 'censor') {
                                     if ($this->is_moderator) {
                                         // confirmation: censor / remove censorship
                                         $tpl->setVariable('FORM', $this->getCensorshipFormHTML());
                                     }
                                 } else {
                                     if (!$this->objCurrentTopic->isClosed() && $this->displayConfirmPostActivation()) {
                                         if ($this->is_moderator) {
                                             // confirmation: activate
                                             $tpl->setVariable('FORM', $this->getActivationFormHTML());
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
                 // if ($this->objCurrentPost->getId() == $node->getId())
                 if ($this->objCurrentPost->getId() != $node->getId() || $_GET['action'] != 'showreply' && $_GET['action'] != 'showedit' && $_GET['action'] != 'censor' && $_GET['action'] != 'delete' && !$this->displayConfirmPostActivation()) {
                     if ($this->is_moderator || $node->isActivated()) {
                         // button: reply
                         if (!$this->objCurrentTopic->isClosed() && $ilAccess->checkAccess('add_reply', '', (int) $_GET['ref_id']) && !$node->isCensored()) {
                             $tpl->setCurrentBlock('commands');
                             $this->ctrl->setParameter($this, 'action', 'showreply');
                             $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
                             $this->ctrl->setParameter($this, 'offset', $Start);
                             $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
                             $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
                             $tpl->setVariable('COMMANDS_COMMAND', $this->ctrl->getLinkTarget($this, 'viewThread', $node->getId()));
                             $tpl->setVariable('COMMANDS_TXT', $lng->txt('reply'));
                             $this->ctrl->clearParameters($this);
                             $tpl->parseCurrentBlock();
                         }
                         // button: edit article
                         if (!$this->objCurrentTopic->isClosed() && ($node->isOwner($ilUser->getId()) || $this->is_moderator) && !$node->isCensored() && $ilUser->getId() != ANONYMOUS_USER_ID) {
                             $tpl->setCurrentBlock('commands');
                             $this->ctrl->setParameter($this, 'action', 'showedit');
                             $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
                             $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
                             $this->ctrl->setParameter($this, 'offset', $Start);
                             $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
                             $tpl->setVariable('COMMANDS_COMMAND', $this->ctrl->getLinkTarget($this, 'viewThread', $node->getId()));
                             $tpl->setVariable('COMMANDS_TXT', $lng->txt('edit'));
                             $this->ctrl->clearParameters($this);
                             $tpl->parseCurrentBlock();
                         }
                         // button: print
                         if (!$node->isCensored()) {
                             $tpl->setCurrentBlock('commands');
                             $this->ctrl->setParameterByClass('ilforumexportgui', 'print_post', $node->getId());
                             $this->ctrl->setParameterByClass('ilforumexportgui', 'top_pk', $node->getForumId());
                             $this->ctrl->setParameterByClass('ilforumexportgui', 'thr_pk', $node->getThreadId());
                             $tpl->setVariable('COMMANDS_COMMAND', $this->ctrl->getLinkTargetByClass('ilforumexportgui', 'printPost'));
                             $tpl->setVariable('COMMANDS_TXT', $lng->txt('print'));
                             $this->ctrl->clearParameters($this);
                             $tpl->parseCurrentBlock();
                         }
                         # buttons for every post except the "active"
                         if (!$this->objCurrentTopic->isClosed() && ($this->is_moderator || $node->isOwner($ilUser->getId()) && !$node->hasReplies()) && $ilUser->getId() != ANONYMOUS_USER_ID) {
                             // button: delete
                             $tpl->setCurrentBlock('commands');
                             $this->ctrl->setParameter($this, 'action', 'delete');
                             $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
                             $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
                             $this->ctrl->setParameter($this, 'offset', $Start);
                             $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
                             $tpl->setVariable('COMMANDS_COMMAND', $this->ctrl->getLinkTarget($this, 'viewThread', $node->getId()));
                             $tpl->setVariable('COMMANDS_TXT', $lng->txt('delete'));
                             $this->ctrl->clearParameters($this);
                             $tpl->parseCurrentBlock();
                         }
                         if (!$this->objCurrentTopic->isClosed() && $this->is_moderator) {
                             // button: censor
                             $tpl->setCurrentBlock('commands');
                             $this->ctrl->setParameter($this, 'action', 'censor');
                             $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
                             $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
                             $this->ctrl->setParameter($this, 'offset', $Start);
                             $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
                             $tpl->setVariable('COMMANDS_COMMAND', $this->ctrl->getLinkTarget($this, 'viewThread', $node->getId()));
                             $tpl->setVariable('COMMANDS_TXT', $lng->txt('censorship'));
                             $this->ctrl->clearParameters($this);
                             $tpl->parseCurrentBlock();
                             // button: activation/deactivation
                             $tpl->setCurrentBlock('commands');
                             $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
                             $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
                             $this->ctrl->setParameter($this, 'offset', $Start);
                             $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
                             if (!$node->isActivated()) {
                                 $tpl->setVariable('COMMANDS_COMMAND', $this->ctrl->getLinkTarget($this, 'askForPostActivation', $node->getId()));
                                 $tpl->setVariable('COMMANDS_TXT', $lng->txt('activate_post'));
                             }
                             $this->ctrl->clearParameters($this);
                             $tpl->parseCurrentBlock();
                         }
                         // button: mark read
                         if ($ilUser->getId() != ANONYMOUS_USER_ID && !$node->isPostRead()) {
                             $tpl->setCurrentBlock('commands');
                             $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
                             $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
                             $this->ctrl->setParameter($this, 'offset', $Start);
                             $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
                             $this->ctrl->setParameter($this, 'viewmode', $_SESSION['viewmode']);
                             $tpl->setVariable('COMMANDS_COMMAND', $this->ctrl->getLinkTarget($this, 'markPostRead', $node->getId()));
                             $tpl->setVariable('COMMANDS_TXT', $lng->txt('is_read'));
                             $this->ctrl->clearParameters($this);
                             $tpl->parseCurrentBlock();
                         }
                         // button: mark unread
                         if ($ilUser->getId() != ANONYMOUS_USER_ID && $node->isPostRead()) {
                             $tpl->setCurrentBlock('commands');
                             $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
                             $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
                             $this->ctrl->setParameter($this, 'offset', $Start);
                             $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
                             $this->ctrl->setParameter($this, 'viewmode', $_SESSION['viewmode']);
                             $tpl->setVariable('COMMANDS_COMMAND', $this->ctrl->getLinkTarget($this, 'markPostUnread', $node->getId()));
                             $tpl->setVariable('COMMANDS_TXT', $lng->txt('unread'));
                             $this->ctrl->clearParameters($this);
                             $tpl->parseCurrentBlock();
                         }
                     }
                 }
                 // if ($this->objCurrentPost->getId() != $node->getId())
                 // download post attachments
                 $tmp_file_obj = new ilFileDataForum($forumObj->getId(), $node->getId());
                 if (count($tmp_file_obj->getFilesOfPost())) {
                     if ($node->getId() != $this->objCurrentPost->getId() || $_GET['action'] != 'showedit') {
                         foreach ($tmp_file_obj->getFilesOfPost() as $file) {
                             $tpl->setCurrentBlock('attachment_download_row');
                             $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
                             $this->ctrl->setParameter($this, 'file', $file['md5']);
                             $tpl->setVariable('HREF_DOWNLOAD', $this->ctrl->getLinkTarget($this, 'viewThread'));
                             $tpl->setVariable('TXT_FILENAME', $file['name']);
                             $this->ctrl->clearParameters($this);
                             $tpl->parseCurrentBlock();
                         }
                         $tpl->setCurrentBlock('attachments');
                         $tpl->setVariable('TXT_ATTACHMENTS_DOWNLOAD', $lng->txt('forums_attachments'));
                         include_once "./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php";
                         $tpl->setVariable('DOWNLOAD_IMG', ilGlyphGUI::get(ilGlyphGUI::ATTACHMENT, $lng->txt('forums_download_attachment')));
                         $tpl->parseCurrentBlock();
                     }
                 }
                 $tpl->setCurrentBlock('posts_row');
                 // anker for every post
                 $tpl->setVariable('POST_ANKER', $node->getId());
                 //permanent link for every post
                 //	$tpl->setVariable('PERMA_LINK', ILIAS_HTTP_PATH."/goto.php?target="."frm"."_".$this->object->getRefId()."_".$node->getThreadId()."_".$node->getId()."&client_id=".CLIENT_ID);
                 $tpl->setVariable('TXT_PERMA_LINK', $lng->txt('perma_link'));
                 $tpl->setVariable('PERMA_TARGET', '_top');
                 if ($this->objProperties->getMarkModeratorPosts() == 1) {
                     if ($node->getIsAuthorModerator() === null && ($is_moderator = ilForum::_isModerator($_GET['ref_id'], $node->getPosAuthorId()))) {
                         $rowCol = 'ilModeratorPosting';
                     } elseif ($node->getIsAuthorModerator()) {
                         $rowCol = 'ilModeratorPosting';
                     } else {
                         $rowCol = ilUtil::switchColor($z, 'tblrow1', 'tblrow2');
                     }
                 } else {
                     $rowCol = ilUtil::switchColor($z, 'tblrow1', 'tblrow2');
                 }
                 if ($_GET['action'] != 'delete' && $_GET['action'] != 'censor' && !$this->displayConfirmPostActivation() || $this->objCurrentPost->getId() != $node->getId()) {
                     $tpl->setVariable('ROWCOL', ' ' . $rowCol);
                 } else {
                     // highlight censored posts
                     $rowCol = 'tblrowmarked';
                 }
                 // post is censored
                 if ($node->isCensored()) {
                     // display censorship advice
                     if ($_GET['action'] != 'censor') {
                         $tpl->setVariable('TXT_CENSORSHIP_ADVICE', $this->lng->txt('post_censored_comment_by_moderator'));
                     }
                     // highlight censored posts
                     $rowCol = 'tblrowmarked';
                 }
                 // set row color
                 $tpl->setVariable('ROWCOL', ' ' . $rowCol);
                 // if post is not activated display message for the owner
                 if (!$node->isActivated() && $node->isOwner($ilUser->getId())) {
                     $tpl->setVariable('POST_NOT_ACTIVATED_YET', $this->lng->txt('frm_post_not_activated_yet'));
                 }
                 // Author
                 $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
                 $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
                 $backurl = urlencode($this->ctrl->getLinkTarget($this, 'viewThread', $node->getId()));
                 $this->ctrl->clearParameters($this);
                 $this->ctrl->setParameter($this, 'backurl', $backurl);
                 $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
                 $this->ctrl->setParameter($this, 'user', $node->getDisplayUserId());
                 require_once 'Modules/Forum/classes/class.ilForumAuthorInformation.php';
                 $authorinfo = new ilForumAuthorInformation($node->getPosAuthorId(), $node->getDisplayUserId(), $node->getUserAlias(), $node->getImportName(), array('href' => $this->ctrl->getLinkTarget($this, 'showUser')));
                 $this->ctrl->clearParameters($this);
                 if ($authorinfo->hasSuffix()) {
                     $tpl->setVariable('AUTHOR', $authorinfo->getSuffix());
                     $tpl->setVariable('USR_NAME', $node->getUserAlias());
                 } else {
                     $tpl->setVariable('AUTHOR', $authorinfo->getLinkedAuthorShortName());
                     if ($authorinfo->getAuthorName(true)) {
                         $tpl->setVariable('USR_NAME', $authorinfo->getAuthorName(true));
                     }
                 }
                 $tpl->setVariable('USR_IMAGE', $authorinfo->getProfilePicture());
                 if ($authorinfo->getAuthor()->getId() && ilForum::_isModerator((int) $_GET['ref_id'], $node->getPosAuthorId())) {
                     if ($authorinfo->getAuthor()->getGender() == 'f') {
                         $tpl->setVariable('ROLE', $this->lng->txt('frm_moderator_f'));
                     } else {
                         if ($authorinfo->getAuthor()->getGender() == 'm') {
                             $tpl->setVariable('ROLE', $this->lng->txt('frm_moderator_m'));
                         }
                     }
                 }
                 // get create- and update-dates
                 if ($node->getUpdateUserId() > 0) {
                     $spanClass = '';
                     // last update from moderator?
                     $posMod = $frm->getModeratorFromPost($node->getId());
                     if (is_array($posMod) && $posMod['top_mods'] > 0) {
                         $MODS = $rbacreview->assignedUsers($posMod['top_mods']);
                         if (is_array($MODS)) {
                             if (in_array($node->getUpdateUserId(), $MODS)) {
                                 $spanClass = 'moderator_small';
                             }
                         }
                     }
                     $node->setChangeDate($node->getChangeDate());
                     if ($spanClass == '') {
                         $spanClass = 'small';
                     }
                     $this->ctrl->setParameter($this, 'backurl', $backurl);
                     $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
                     $this->ctrl->setParameter($this, 'user', $node->getUpdateUserId());
                     require_once 'Modules/Forum/classes/class.ilForumAuthorInformation.php';
                     $authorinfo = new ilForumAuthorInformation($node->getPosAuthorId(), $node->getUpdateUserId(), '', '', array('href' => $this->ctrl->getLinkTarget($this, 'showUser')));
                     $this->ctrl->clearParameters($this);
                     $tpl->setVariable('POST_UPDATE_TXT', $lng->txt('edited_on') . ': ' . $frm->convertDate($node->getChangeDate()) . ' - ' . strtolower($lng->txt('by')));
                     $tpl->setVariable('UPDATE_AUTHOR', $authorinfo->getLinkedAuthorShortName());
                     if ($authorinfo->getAuthorName(true)) {
                         $tpl->setVariable('UPDATE_USR_NAME', $authorinfo->getAuthorName(true));
                     }
                 }
                 // if ($node->getUpdateUserId() > 0)*/
                 // Author end
                 // prepare post
                 $node->setMessage($frm->prepareText($node->getMessage()));
                 if ($ilUser->getId() == ANONYMOUS_USER_ID || $node->isPostRead()) {
                     $tpl->setVariable('SUBJECT', $node->getSubject());
                 } else {
                     $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
                     $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
                     $this->ctrl->setParameter($this, 'offset', $Start);
                     $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
                     $this->ctrl->setParameter($this, 'viewmode', $_SESSION['viewmode']);
                     $mark_post_target = $this->ctrl->getLinkTarget($this, 'markPostRead', $node->getId());
                     $tpl->setVariable('SUBJECT', "<a href=\"" . $mark_post_target . "\"><b>" . $node->getSubject() . "</b></a>");
                 }
                 $tpl->setVariable('POST_DATE', $frm->convertDate($node->getCreateDate()));
                 if (!$node->isCensored() || $this->objCurrentPost->getId() == $node->getId() && $_GET['action'] == 'censor') {
                     // post from moderator?
                     $modAuthor = $frm->getModeratorFromPost($node->getId());
                     $spanClass = "";
                     if (is_array($modAuthor) && $modAuthor['top_mods'] > 0) {
                         unset($MODS);
                         $MODS = $rbacreview->assignedUsers($modAuthor['top_mods']);
                         if (is_array($MODS)) {
                             if (in_array($node->getDisplayUserId(), $MODS)) {
                                 $spanClass = 'moderator';
                             }
                         }
                     }
                     // possible bugfix for mantis #8223
                     if ($node->getMessage() == strip_tags($node->getMessage())) {
                         // We can be sure, that there are not html tags
                         $node->setMessage(nl2br($node->getMessage()));
                     }
                     if ($spanClass != "") {
                         $tpl->setVariable('POST', "<span class=\"" . $spanClass . "\">" . ilRTE::_replaceMediaObjectImageSrc($node->getMessage(), 1) . "</span>");
                     } else {
                         $tpl->setVariable('POST', ilRTE::_replaceMediaObjectImageSrc($node->getMessage(), 1));
                     }
                 } else {
                     $tpl->setVariable('POST', "<span class=\"moderator\">" . nl2br($node->getCensorshipComment()) . "</span>");
                 }
                 $tpl->parseCurrentBlock();
             }
             $z++;
         }
     } else {
         $tpl->setCurrentBlock('posts_no');
         $tpl->setVariable('TXT_MSG_NO_POSTS_AVAILABLE', $lng->txt('forums_posts_not_available'));
         $tpl->parseCurrentBlock();
     }
     $oThreadToolbar = clone $ilToolbar;
     $oThreadToolbar->addSeparator();
     $oThreadToolbar->addButton($this->lng->txt('top_of_page'), '#frm_page_top');
     $tpl->setVariable('THREAD_TOOLBAR', $oThreadToolbar->getHTML());
     $tpl->setVariable('TPLPATH', $tpl->vars['TPLPATH']);
     // permanent link
     include_once 'Services/PermanentLink/classes/class.ilPermanentLinkGUI.php';
     $permalink = new ilPermanentLinkGUI('frm', $this->object->getRefId(), '_' . $this->objCurrentTopic->getId());
     $this->tpl->setVariable('PRMLINK', $permalink->getHTML());
     // Render tree
     if ($_SESSION['viewmode'] == 'answers' || $_SESSION['viewmode'] == ilForumProperties::VIEW_TREE) {
         $tpl->setLeftNavContent($this->getForumExplorer());
     }
     return true;
 }