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->getPosAuthorId(), $this->objCurrentPost->getDisplayUserId(), $this->objCurrentPost->getUserAlias(), $this->objCurrentPost->getImportName()); $html = ilRTE::_replaceMediaObjectImageSrc($frm->prepareText($this->objCurrentPost->getMessage(), 1, $authorinfo->getAuthorName()), 1); echo $html; exit; }
/** * generate new dataset in frm_posts * @param integer $topic * @param integer $thread * @param integer $author_id * @param integer $display_user_id * @param string $message * @param integer $parent_pos * @param integer $notify * @param integer $anonymize * @param string $subject * @param datetime $date * @return integer $last: new post ID * @access public */ public function generatePost($forum_id, $thread_id, $author_id, $display_user_id, $message, $parent_pos, $notify, $subject = '', $alias = '', $date = '', $status = 1, $send_activation_mail = 0) { global $ilDB; $objNewPost = new ilForumPost(); $objNewPost->setForumId($forum_id); $objNewPost->setThreadId($thread_id); $objNewPost->setSubject($subject); $objNewPost->setMessage($message); $objNewPost->setDisplayUserId($display_user_id); $objNewPost->setUserAlias($alias); $objNewPost->setPosAuthorId($author_id); $this->_isModerator($this->getForumRefId(), $author_id) ? $is_moderator = true : ($is_moderator = false); $objNewPost->setIsAuthorModerator($is_moderator); 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->getPosAuthorId(), $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($display_user_id); $news_item->setVisibility(NEWS_USERS); $news_item->create(); } return $objNewPost->getId(); }
/** * @param ilTemplate $tpl * @param ilForumPost $post * @param int $counter * @param int $mode */ protected function renderPostHtml(ilTemplate $tpl, ilForumPost $post, $counter, $mode) { /** * @var $lng ilLanguage * @var $rbacreview ilRbacReview * @var $ilUser ilObjUser * @var $ilObjDataCache ilObjectDataCache */ global $lng, $rbacreview, $ilUser, $ilObjDataCache; $tpl->setCurrentBlock('posts_row'); if (ilForumProperties::getInstance($ilObjDataCache->lookupObjId($_GET['ref_id']))->getMarkModeratorPosts() == 1) { if ($post->getIsAuthorModerator() === null && ($is_moderator = ilForum::_isModerator($_GET['ref_id'], $post->getPosAuthorId()))) { $rowCol = 'ilModeratorPosting'; } else { if ($post->getIsAuthorModerator()) { $rowCol = 'ilModeratorPosting'; } else { $rowCol = ilUtil::switchColor($counter, 'tblrow1', 'tblrow2'); } } } else { $rowCol = ilUtil::switchColor($counter, 'tblrow1', 'tblrow2'); } $tpl->setVariable('ROWCOL', ' ' . $rowCol); // post is censored if ($post->isCensored()) { // display censorship advice $tpl->setVariable('TXT_CENSORSHIP_ADVICE', $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 (!$post->isActivated() && $post->isOwner($ilUser->getId())) { $tpl->setVariable('POST_NOT_ACTIVATED_YET', $lng->txt('frm_post_not_activated_yet')); } $authorinfo = new ilForumAuthorInformation($post->getPosAuthorId(), $post->getDisplayUserId(), $post->getUserAlias(), $post->getImportName()); if ($authorinfo->hasSuffix()) { $tpl->setVariable('AUTHOR', $authorinfo->getSuffix()); $tpl->setVariable('USR_NAME', $post->getUserAlias()); } else { $tpl->setVariable('AUTHOR', $authorinfo->getAuthorShortName()); if ($authorinfo->getAuthorName(true)) { $tpl->setVariable('USR_NAME', $authorinfo->getAuthorName(true)); } } if (self::MODE_EXPORT_CLIENT == $mode) { if ($authorinfo->getAuthor()->getPref('public_profile') != 'n') { $tpl->setVariable('TXT_REGISTERED', $lng->txt('registered_since')); $tpl->setVariable('REGISTERED_SINCE', $this->frm->convertDate($authorinfo->getAuthor()->getCreateDate())); } if ($post->getDisplayUserId()) { if ($this->is_moderator) { $num_posts = $this->frm->countUserArticles($post->getDisplayUserId()); } else { $num_posts = $this->frm->countActiveUserArticles($post->getDisplayUserId()); } $tpl->setVariable('TXT_NUM_POSTS', $lng->txt('forums_posts')); $tpl->setVariable('NUM_POSTS', $num_posts); } } $tpl->setVariable('USR_IMAGE', $authorinfo->getProfilePicture()); if ($authorinfo->getAuthor()->getId() && ilForum::_isModerator((int) $_GET['ref_id'], $post->getPosAuthorId())) { if ($authorinfo->getAuthor()->getGender() == 'f') { $tpl->setVariable('ROLE', $lng->txt('frm_moderator_f')); } else { if ($authorinfo->getAuthor()->getGender() == 'm') { $tpl->setVariable('ROLE', $lng->txt('frm_moderator_m')); } } } // get create- and update-dates if ($post->getUpdateUserId() > 0) { $spanClass = ''; // last update from moderator? $posMod = $this->frm->getModeratorFromPost($post->getId()); if (is_array($posMod) && $posMod['top_mods'] > 0) { $MODS = $rbacreview->assignedUsers($posMod['top_mods']); if (is_array($MODS)) { if (in_array($post->getUpdateUserId(), $MODS)) { $spanClass = 'moderator_small'; } } } $post->setChangeDate($post->getChangeDate()); if ($spanClass == '') { $spanClass = 'small'; } require_once 'Modules/Forum/classes/class.ilForumAuthorInformation.php'; $authorinfo = new ilForumAuthorInformation($post->getPosAuthorId(), $post->getUpdateUserId(), '', ''); $tpl->setVariable('POST_UPDATE_TXT', $lng->txt('edited_on') . ': ' . $this->frm->convertDate($post->getChangeDate()) . ' - ' . strtolower($lng->txt('by'))); $tpl->setVariable('UPDATE_AUTHOR', $authorinfo->getLinkedAuthorShortName()); if ($authorinfo->getAuthorName(true)) { $tpl->setVariable('UPDATE_USR_NAME', $authorinfo->getAuthorName(true)); } } // prepare post $post->setMessage($this->frm->prepareText($post->getMessage())); $tpl->setVariable('POST_DATE', $this->frm->convertDate($post->getCreateDate())); $tpl->setVariable('SUBJECT', $post->getSubject()); if (!$post->isCensored()) { // post from moderator? $modAuthor = $this->frm->getModeratorFromPost($post->getId()); $spanClass = ""; if (is_array($modAuthor) && $modAuthor['top_mods'] > 0) { $MODS = $rbacreview->assignedUsers($modAuthor['top_mods']); if (is_array($MODS) && in_array($post->getDisplayUserId(), $MODS)) { $spanClass = 'moderator'; } } // 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())); } if ($spanClass != "") { $tpl->setVariable('POST', "<span class=\"" . $spanClass . "\">" . ilRTE::_replaceMediaObjectImageSrc($post->getMessage(), 1) . "</span>"); } else { $tpl->setVariable('POST', ilRTE::_replaceMediaObjectImageSrc($post->getMessage(), 1)); } } else { $tpl->setVariable('POST', "<span class=\"moderator\">" . nl2br($post->getCensorshipComment()) . "</span>"); } $tpl->parseCurrentBlock('posts_row'); }