public function getQuotationHTMLAsynchObject()
 {
     $oForumObjects = $this->getForumObjects();
     /**
      * @var $frm ilForum
      */
     $frm = $oForumObjects['frm'];
     require_once 'Modules/Forum/classes/class.ilForumAuthorInformation.php';
     $authorinfo = new ilForumAuthorInformation($this->objCurrentPost->getUserId(), $this->objCurrentPost->getUserAlias(), $this->objCurrentPost->getImportName());
     $html = ilRTE::_replaceMediaObjectImageSrc($frm->prepareText($this->objCurrentPost->getMessage(), 1, $authorinfo->getAuthorName()), 1);
     echo $html;
     exit;
 }
 /**
  * Print Posting.
  *
  */
 function printPost()
 {
     global $tpl, $lng, $ilAccess, $ilias;
     if (!$ilAccess->checkAccess('read,visible', '', $_GET['ref_id'])) {
         $ilias->raiseError($lng->txt('permission_denied'), $ilias->error_obj->MESSAGE);
     }
     $tplEx = new ilTemplate('tpl.forums_export_print.html', true, true, 'Modules/Forum');
     $tplEx->setVariable('CSSPATH', $tpl->tplPath);
     // get forum- and thread-data
     $this->frm->setMDB2WhereCondition('top_pk = %s ', array('integer'), array($_GET['top_pk']));
     if (is_array($frmData = $this->frm->getOneTopic())) {
         // post object
         $post = new ilForumPost((int) $_GET['print_post']);
         // headline
         $tplEx->setVariable('HEADLINE', $lng->txt('forum') . ': ' . $frmData['top_name'] . ' > ' . $lng->txt('forums_thread') . ': ' . $post->getThread()->getSubject());
         $tplEx->setCurrentBlock('posts_row');
         $tplEx->setVariable('ROWCOL', 'tblrow2');
         $authorinfo = new ilForumAuthorInformation($post->getUserId(), $post->getUserAlias(), $post->getImportName());
         $tplEx->setVariable('AUTHOR', $authorinfo->getAuthorName());
         if ($post->getUserId()) {
             // get create- and update-dates
             if ($post->getUpdateUserId()) {
                 $authorinfo = new ilForumAuthorInformation($post->getUpdateUserId(), '', '');
                 $tplEx->setVariable('POST_UPDATE', "<br />[" . $lng->txt('edited_on') . ": " . $this->frm->convertDate($post->getChangeDate()) . " - " . strtolower($lng->txt('from')) . " " . $authorinfo->getAuthorName() . "]");
             }
             if ($ilAccess->checkAccess('moderate_frm', '', $_GET['ref_id'])) {
                 $numPosts = $this->frm->countUserArticles($post->getUserId());
             } else {
                 $numPosts = $this->frm->countActiveUserArticles($post->getUserId());
             }
         }
         $tplEx->setVariable('SUBJECT', $post->getSubject());
         $tplEx->setVariable('TXT_CREATE_DATE', $lng->txt('forums_thread_create_date'));
         $tplEx->setVariable('POST_DATE', $this->frm->convertDate($post->getCreateDate()));
         $tplEx->setVariable('SPACER', "<hr noshade width=\"100%\" size=\"1\" align=\"center\" />");
         if ($post->isCensored()) {
             $tplEx->setVariable('POST', nl2br(stripslashes($post->getCensorshipComment())));
         } else {
             /** @todo mjansen: possible bugfix for mantis #8223 */
             if ($post->getMessage() == strip_tags($post->getMessage())) {
                 // We can be sure, that there are not html tags
                 $post->setMessage(nl2br($post->getMessage()));
             }
             $tplEx->setVariable('POST', ilRTE::_replaceMediaObjectImageSrc($this->frm->prepareText($post->getMessage(), 0, '', 'export'), 1));
         }
         $tplEx->parseCurrentBlock('posts_row');
         $tplEx->setCurrentBlock('posttable');
         $tplEx->setVariable('TXT_AUTHOR', $lng->txt('author'));
         $tplEx->setVariable('TXT_POST', $lng->txt('forums_thread') . ': ' . $post->getThread()->getSubject());
         $tplEx->parseCurrentBlock('posttable');
     }
     // if (is_array($frmData = $this->frm->getOneTopic()))
     $tplEx->show();
 }
    /**
     * Fetches and returns an array of posts from the post tree, starting with the node object passed by
     * the first paramter.
     * 
     * @param    ilForumPost	$a_post_node	node-object of a post
     * @return	array		array of post objects
     * @access	public
     */
    public function getPostTree(ilForumPost $a_post_node)
    {
        global $ilUser;
        $posts = array();
        $data = array();
        $data_types = array();
        $query = '
			SELECT 			pos_pk, fpt_date, rgt, pos_top_fk, pos_thr_fk, 
							pos_usr_id, pos_usr_alias, pos_subject,
							pos_status, pos_message, pos_date, pos_update,
							update_user, pos_cens, pos_cens_com, notify,
							import_name, fpt_pk, parent_pos, lft, depth,
							(CASE
							WHEN fur.post_id IS NULL ' . ($ilUser->getId() == ANONYMOUS_USER_ID ? ' AND 1 = 2 ' : '') . '
							THEN 0
							ELSE 1
							END) post_read,
							firstname, lastname, title, login
							 
			FROM 			frm_posts_tree
			 
			INNER JOIN 		frm_posts 
				ON 			pos_fk = pos_pk
				
			LEFT JOIN		usr_data
				ON			pos_usr_id  = usr_id
				
			LEFT JOIN		frm_user_read fur
				ON			fur.thread_id = pos_thr_fk
				AND			fur.post_id = pos_pk
				AND			fur.usr_id = %s
				 
			WHERE 			lft BETWEEN %s AND %s 
				AND 		thr_fk = %s';
        array_push($data_types, 'integer', 'integer', 'integer', 'integer');
        array_push($data, $ilUser->getId(), $a_post_node->getLft(), $a_post_node->getRgt(), $a_post_node->getThreadId());
        if ($this->orderField != "") {
            $query .= " ORDER BY " . $this->orderField . " " . $this->getOrderDirection();
        }
        $res = $this->db->queryf($query, $data_types, $data);
        $usr_ids = array();
        $deactivated = array();
        while ($row = $this->db->fetchAssoc($res)) {
            $tmp_object = new ilForumPost($row['pos_pk'], false, true);
            $tmp_object->assignData($row);
            if (!$this->is_moderator) {
                if (!$tmp_object->isActivated() && $tmp_object->getUserId() != $ilUser->getId()) {
                    $deactivated[] = $tmp_object;
                    unset($tmp_object);
                    continue;
                }
                foreach ($deactivated as $deactivated_node) {
                    if ($deactivated_node->getLft() < $tmp_object->getLft() && $deactivated_node->getRgt() > $tmp_object->getLft()) {
                        $deactivated[] = $tmp_object;
                        unset($tmp_object);
                        continue 2;
                    }
                }
            }
            if ((int) $row['pos_usr_id']) {
                $usr_ids[] = (int) $row['pos_usr_id'];
            }
            if ((int) $row['update_user']) {
                $usr_ids[] = (int) $row['update_user'];
            }
            $posts[] = $tmp_object;
            unset($tmp_object);
        }
        require_once 'Modules/Forum/classes/class.ilForumAuthorInformationCache.php';
        ilForumAuthorInformationCache::preloadUserObjects(array_unique($usr_ids));
        return $posts;
    }
    /**
     * generate new dataset in frm_posts
     * @param	integer	$topic
     * @param	integer	$thread
     * @param	integer	$user
     * @param	string	$message	
     * @param	integer	$parent_pos	
     * @param	integer	$notify	
     * @param	integer	$anonymize	
     * @param	string	$subject	
     * @param	datetime	$date	
     * @return	integer	$lastInsert: new post ID
     * @access	public
     */
    public function generatePost($forum_id, $thread_id, $user, $message, $parent_pos, $notify, $subject = '', $alias = '', $date = '', $status = 1, $send_activation_mail = 0)
    {
        global $ilUser, $ilDB;
        $objNewPost = new ilForumPost();
        $objNewPost->setForumId($forum_id);
        $objNewPost->setThreadId($thread_id);
        $objNewPost->setSubject($subject);
        $objNewPost->setMessage($message);
        $objNewPost->setUserId($user);
        $objNewPost->setUserAlias($alias);
        if ($date == "") {
            $objNewPost->setCreateDate(date("Y-m-d H:i:s"));
        } else {
            if (strpos($date, "-") > 0) {
                $objNewPost->setCreateDate($date);
            } else {
                $objNewPost->setCreateDate(date("Y-m-d H:i:s", $date));
            }
        }
        $objNewPost->setImportName($this->getImportName());
        $objNewPost->setNotification($notify);
        $objNewPost->setStatus($status);
        $objNewPost->insert();
        // entry in tree-table
        if ($parent_pos == 0) {
            $this->addPostTree($objNewPost->getThreadId(), $objNewPost->getId(), $objNewPost->getCreateDate());
        } else {
            $this->insertPostNode($objNewPost->getId(), $parent_pos, $objNewPost->getThreadId(), $objNewPost->getCreateDate());
        }
        //echo "<br>->".$objNewPost->getId()."-".$parent_pos."-".$objNewPost->getThreadId()."-".
        //	$objNewPost->getCreateDate()."-".$forum_id."-".$message."-".$user."-";
        // string last post
        $lastPost = $objNewPost->getForumId() . "#" . $objNewPost->getThreadId() . "#" . $objNewPost->getId();
        // update thread
        $result = $ilDB->manipulateF('
			UPDATE frm_threads 
			SET thr_num_posts = thr_num_posts + 1,
				thr_last_post = %s
			WHERE thr_pk = %s', array('text', 'integer'), array($lastPost, $objNewPost->getThreadId()));
        // update forum
        $result = $ilDB->manipulateF('
			UPDATE frm_data 
			SET top_num_posts = top_num_posts + 1,
			 	top_last_post = %s
			WHERE top_pk = %s', array('text', 'integer'), array($lastPost, $objNewPost->getForumId()));
        // MARK READ
        $forum_obj = ilObjectFactory::getInstanceByRefId($this->getForumRefId());
        $forum_obj->markPostRead($objNewPost->getUserId(), $objNewPost->getThreadId(), $objNewPost->getId());
        $pos_data = $objNewPost->getDataAsArray();
        $pos_data["ref_id"] = $this->getForumRefId();
        // Send notification to moderators if they have to enable a post
        if (!$status && $send_activation_mail) {
            $pos_data["top_name"] = $forum_obj->getTitle();
            $this->sendPostActivationNotification($pos_data);
        }
        // Add Notification to news
        if ($status) {
            require_once 'Services/RTE/classes/class.ilRTE.php';
            include_once "./Services/News/classes/class.ilNewsItem.php";
            $news_item = new ilNewsItem();
            $news_item->setContext($forum_obj->getId(), 'frm', $objNewPost->getId(), 'pos');
            $news_item->setPriority(NEWS_NOTICE);
            $news_item->setTitle($objNewPost->getSubject());
            $news_item->setContent(ilRTE::_replaceMediaObjectImageSrc($this->prepareText($objNewPost->getMessage(), 0), 1));
            $news_item->setUserId($user);
            $news_item->setVisibility(NEWS_USERS);
            $news_item->create();
        }
        return $objNewPost->getId();
    }