/** * @access public * @return void * @param int[] $a_ids * @desc Read from the db the comments for the supplied review item */ public function ReadCommentsForReviewItem(ReviewItem $review_item) { $s_person = $this->GetSettings()->GetTable('User'); $s_message = $this->GetSettings()->GetTable('ForumMessage'); # prepare command $s_sql = 'SELECT ' . $s_person . '.user_id, ' . $s_person . '.known_as, ' . 'location, ' . $s_person . ".date_added AS sign_up_date, " . $s_person . '.total_messages, ' . $s_message . '.id, ' . $s_message . '.message, ' . $s_message . ".date_added AS message_date " . 'FROM ' . $s_message . ' INNER JOIN ' . $s_person . ' ON ' . $s_message . '.user_id = ' . $s_person . '.user_id ' . 'WHERE ' . $s_message . '.item_id = ' . Sql::ProtectNumeric($review_item->GetId(), false, false) . ' AND item_type = ' . Sql::ProtectNumeric($review_item->GetType(), false, false); if ($this->GetReverseOrder()) { $s_sql .= ' ORDER BY sort_override DESC, ' . $s_message . '.date_added DESC'; } else { $s_sql .= ' ORDER BY sort_override, ' . $s_message . '.date_added ASC'; } # get data $result = $this->GetDataConnection()->query($s_sql); $this->Clear(); $o_topic = new ForumTopic($this->GetSettings()); while ($o_row = $result->fetch()) { $o_person = new User(); $o_person->SetId($o_row->user_id); $o_person->SetName($o_row->known_as); $o_person->SetSignUpdate($o_row->sign_up_date); $o_person->SetLocation($o_row->location); $o_person->SetTotalMessages($o_row->total_messages); $o_message = new ForumMessage($this->GetSettings(), AuthenticationManager::GetUser()); $o_message->SetId($o_row->id); $o_message->SetDate($o_row->message_date); $o_message->SetBody($o_row->message); $o_message->SetUser($o_person); $o_message->SetReviewItem($review_item); $o_topic->Add($o_message); } $this->Add($o_topic); $result->closeCursor(); }
function OnPreRender() { /* @var $o_top_level Category */ $review_item = $this->o_topic->GetReviewItem(); $s_suggested_title = urlencode(StringFormatter::PlainText(trim($review_item->GetTitle()))); $s_page = urlencode($_SERVER['REQUEST_URI']); $s_subscribe_link = '/play/subscribe.php?type=' . $review_item->GetType() . '&item=' . $review_item->GetId() . '&title=' . $s_suggested_title . '&page=' . $s_page; $s_subscribe_title = 'Get an email alert every time there are new comments on this page'; $this->AddControl('<div class="forumSubscribe"><a href="' . $s_subscribe_link . '" title="' . $s_subscribe_title . '">Subscribe to comments</a></div>'); if (!$this->authentication_manager->GetUser()->Permissions()->HasPermission(PermissionType::ForumAddMessage())) { $add = $this->o_topic->GetCount() ? 'Add your comments' : 'Be the first to add your comments!'; $this->AddControl('<div class="forumPost"><a href="' . Html::Encode($this->authentication_manager->GetPermissionUrl()) . urlencode('#forumMessageForm') . '">' . $add . '</a></div>'); } }
public function GetTopics($max = null) { $query = "SELECT * FROM " . System::$Configuration["Database.TablePrefix"] . "forum_topics WHERE forum_id = " . $this->ID . ($max == null ? "" : " LIMIT " . $max); $result = mysql_query($query); $count = mysql_num_rows($result); $retval = array(); for ($i = 0; $i < $count; $i++) { $values = mysql_fetch_assoc($result); $retval[] = ForumTopic::GetByAssoc($values); } return $retval; }
/** * Отобразить карточку темы * * @param string $alias - url темы * @throws CHttpException * * @return void */ public function actionShow($alias = null) { $topic = ForumTopic::model()->findByAttributes(array('alias' => $alias)); if ($topic === null) { throw new CHttpException(404, Yii::t('ForumModule.forum', 'Page was not found!')); } if (($data = Yii::app()->getRequest()->getPost('ForumMessage')) !== null) { $model = new ForumMessage(); $model->setAttributes($data); $model->topic_id = $topic->id; $model->user_id = Yii::app()->user->id; if ($model->save()) { Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, 'Сообщение добавлено'); $this->redirect(Yii::app()->createUrl($this->getRoute(), array('alias' => $topic->alias))); } } $this->render('show', array('topic' => $topic)); }
private function DisplayComments() { # Display review topic listing require_once 'forums/forum-topic-listing.class.php'; require_once 'forums/forum-comments-topic-navbar.class.php'; if (!isset($this->topic)) { $this->topic = new ForumTopic($this->GetSettings()); } $this->topic->SetReviewItem($this->review_item); $signed_in = AuthenticationManager::GetUser()->IsSignedIn(); echo '<div id="comments-topic"'; if ($signed_in) { echo ' class="signed-in"'; } echo '>'; if ($this->topic->GetCount() or !$signed_in) { echo '<h2>Comments</h2>'; } $navbar = new ForumCommentsTopicNavbar($this->topic, $this->GetAuthenticationManager()); echo $navbar; $o_review_topic = new ForumTopicListing($this->GetSettings(), AuthenticationManager::GetUser(), $this->topic); echo $o_review_topic; if ($this->topic->GetCount() and !$signed_in) { echo $navbar; } # Add comment if (AuthenticationManager::GetUser()->Permissions()->HasPermission(PermissionType::ForumAddMessage())) { # create form $this->LoadClientScript("/scripts/tiny_mce/jquery.tinymce.js"); $this->LoadClientScript("/scripts/tinymce.js"); require_once 'forums/forum-message-form.class.php'; $o_form = new ForumMessageForm(); echo $o_form->GetForm(); } echo '</div>'; }
$bool_str = $isBlocked ? "true" : "false"; printf("Comment %d is blocked: %s\n", 255494673, $bool_str); //////////////////////////// //ForumTopic UNIT TESTS //////////////////////////// printf("/////////////////////////////////\n"); printf("STARTING ForumTopic UNIT TESTS\n"); printf("/////////////////////////////////\n"); //construct empty forum topic $forumTopic = new ForumTopic(); //add topic $forumTopic->createForum("kmassey", "Dummy Topic", "Dummy question"); //delete topic $forumTopic->deleteForum(); //fetch existing forumTopic $forumTopic2 = new ForumTopic(1895578464); //fetch description of existing forum Topic $topic_description = $forumTopic2->getTopicDescription(); printf("Fetched Topic description: %s\n", $topic_description); //block forum topic printf("Blocking topic %d\n", 1895578464); $forumTopic2->block(); $isBlocked = $forumTopic2->isBlocked(); $bool_str = $isBlocked ? "true" : "false"; printf("Forum Topic %d is blocked: %s\n", 1895578464, $bool_str); //unblock forum topic printf("Unblocking topic %d\n", 1895578464); $forumTopic2->unblock(); $isBlocked = $forumTopic2->isBlocked(); $bool_str = $isBlocked ? "true" : "false"; printf("Forum Topic %d is blocked: %s\n", 1895578464, $bool_str);
echo Yii::t('ForumModule.forum', 'Fields with'); ?> <span class="required">*</span> <?php echo Yii::t('ForumModule.forum', 'are required.'); ?> </div> <?php echo $form->errorSummary($model); ?> <div class="row"> <div class="col-sm-3"> <?php echo $form->dropDownListGroup($model, 'topic_id', ['widgetOptions' => ['data' => ForumTopic::model()->getFormattedList(), 'htmlOptions' => ['class' => 'popover-help', 'data-original-title' => $model->getAttributeLabel('topic_id'), 'data-content' => $model->getAttributeDescription('topic_id'), 'empty' => Yii::t('ForumModule.forum', '--no--')]]]); ?> </div> <div class="col-sm-4"> <?php echo $form->dropDownListGroup($model, 'user_id', ['widgetOptions' => ['data' => $model->getUserList(), 'htmlOptions' => ['class' => 'popover-help', 'data-original-title' => $model->getAttributeLabel('user_id'), 'data-content' => $model->getAttributeDescription('user_id'), 'empty' => Yii::t('ForumModule.forum', '--no--')]]]); ?> </div> </div> <div class="row"> <div class="col-sm-12 form-group popover-help" data-original-title='<?php echo $model->getAttributeLabel('message'); ?> '
function OnPreRender() { if ($this->topic->GetCount()) { $this->AddControl($this->GetFormattedMessages()); } }
<?php $this->breadcrumbs = [Yii::t('ForumModule.forum', 'Forums') => ['/forum/forumBackend/index'], Yii::t('ForumModule.forum', 'Topics') => ['/forum/messageBackend/index'], Yii::t('ForumModule.forum', 'Manage')]; $this->pageTitle = Yii::t('ForumModule.forum', 'Messages - manage'); $this->menu = Yii::app()->getModule('forum')->getNavigation(); ?> <div class="page-header"> <h1> <?php echo Yii::t('ForumModule.forum', 'Messages'); ?> <small><?php echo Yii::t('ForumModule.forum', 'manage'); ?> </small> </h1> </div> <p><?php echo Yii::t('ForumModule.forum', 'This section describes forum management'); ?> </p> <?php $this->widget('yupe\\widgets\\CustomGridView', ['id' => 'forum-message-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => [['name' => 'id', 'htmlOptions' => ['style' => 'width:20px'], 'type' => 'raw', 'value' => 'CHtml::link($data->id, ["/forum/forumBackend/update", "id" => $data->id])', 'filter' => CHtml::activeTextField($model, 'id', ['class' => 'form-control', 'style' => 'width:20px'])], ['name' => 'topic_id', 'value' => '$data->getTopicTitle()', 'filter' => CHtml::activeDropDownList($model, 'topic_id', ForumTopic::model()->getFormattedList(), ['empty' => '', 'class' => 'form-control'])], ['name' => 'user_id', 'value' => '$data->getUserNickname()', 'filter' => CHtml::activeDropDownList($model, 'user_id', ForumMessage::model()->getUserList(), ['empty' => '', 'class' => 'form-control'])], ['name' => 'message', 'type' => 'ntext'], ['name' => 'date', 'htmlOptions' => ['style' => 'width:150px'], 'filter' => false], ['class' => 'bootstrap.widgets.TbButtonColumn']]]);
</td> <td> <a href="/forums/{{$topic->forum->id}}">{{$topic->forum->name}}</a> </td> <td> {{$topic->firstPost->poster->username}} </td> </tr> @endforeach </tbody> </table> </div> <div class="small-12 medium-5 columns"> <h4>Unresolved Forum Issues</h4> <?php $topics = ForumTopic::where('is_complete', 0)->where(['forum_id' => 35, 'is_complete' => false, 'is_sticky' => false])->orderBy('created_at')->get(); ?> <p> There are currently <b>{{$topics->count()}}</b> unresolved issues. @if($topics->count() > 0) The oldest issue was created <b>{{$topics[0]->created_at->diffForHumans()}}</b>. @endif </p> <table class="responsive"> <thead> <th></th> <th>Title</th> <th style="width: 20%">Age</th> </thead> <tbody> @foreach($topics as $topic)
public function getTopic() { if (!$this->topic instanceof ForumTopic) { $this->topic = ForumTopic::fromID($this->topicID, $this->getForum()); } return $this->topic; }
$pageSize = $user->getSettingValue("Threads Per Page"); $pagination = $topics->paginate($pageSize ? $pageSize : 15); ?> <div class="topic-pagination">{{$pagination->links()}}</div> @if($pagination->count() == 0) <p style="clear: both;">There are no topics here. Be the first to post!</p> @else @if(strlen($forum->list_header) > 0) <div class="list-header">{{ForumPost::render($forum->list_header)}}</div> @endif <div class="forum-title">Topics</div> <div class="topics-list"> @foreach($pagination as $tp_data) <?php $topic = ForumTopic::find($tp_data->topic_id); if (!$topic) { continue; } ?> <div class="topic-row {{$topic->is_complete && $user->isStoryteller() ? 'completed' : ''}}"> <div class="unread-topic-container"><div class="unread-topics {{$topic->hasUnreadPosts($user->id) ? 'unread' : ''}}"></div></div> <div class="topic-row-title"> <a class="topic-name" href="/forums/topic/{{$topic->id}}"> @if($topic->is_complete && ($forum->id == 35 || $user->isStoryteller()))<label class="label success">Complete</label> @endif @if($topic->is_sticky) <label class="label success">Stickied</label>@endif {{$topic->title}} </a> <a href="{{$topic->getLinkForLastPost($user)}}"> <i class="to-page-link icon-right-open"></i> <i class="to-page-link icon-right-open"></i>
public static function updateForumOfTopic(ForumTopic $t) { global $db; $db->query("\n\t\t\t\tUPDATE " . TABLE_TOPICS . "\n\t\t\t\tSET forum_id = :fid\n\t\t\t\tWHERE id = :pid\n\t\t\t", array($t->getForumID(), $t->getID())); $db->query("\n\t\t\t\tUPDATE " . TABLE_POSTS . "\n\t\t\t\tSET forum_id = :fid\n\t\t\t\tWHERE topic_id = :tid\n\t\t\t", array($t->getForumID(), $t->getID())); }
/** * Get $pageLimit topics. * * @param int $pageLimit How many pages per page? * @param int $currentPage On what page are we currently? (you should not set this manually!) * * @return array Array containing topics and pages. */ public function getTopics($pageLimit = 20, $currentPage = 1) { global $db, $user, $userManager; $resMeta = $db->query("SELECT * FROM " . TABLE_TOPICS . " WHERE forum_id = ?", array($this->id)); $page = isset($currentPage) ? max($currentPage, 1) : 1; $pages = ceil($db->numRows($resMeta) / $pageLimit); if ($userManager->loggedIn()) { $res = $db->query("\n\t\t\t\t\tSELECT *\n\t\t\t\t\tFROM " . TABLE_TOPICS . " AS topics\n\t\t\t\t\tLEFT JOIN " . TABLE_TOPICS_TRACK . " AS t\n\t\t\t\t\t\tON t.topic_id = topics.id AND t.user_id = :uid\n\t\t\t\t\tWHERE topics.forum_id = :id\n\t\t\t\t\tORDER BY topics.topic_important DESC, last_post_time DESC\n\t\t\t\t\tLIMIT :pageCalc,:pageLimit\n\t\t\t\t", array($user->getID(), $this->id, $page * $pageLimit - $pageLimit, $pageLimit)); } else { $res = $db->query("\n\t\t\t\t\tSELECT *\n\t\t\t\t\tFROM " . TABLE_TOPICS . " AS topics\n\t\t\t\t\tWHERE forum_id = :id\n\t\t\t\t\tORDER BY topics.topic_important DESC, last_post_time DESC\n\t\t\t\t\tLIMIT :pageCalc,:pageLimit\n\t\t\t\t", array($this->id, $page * $pageLimit - $pageLimit, $pageLimit)); } $topics = array(); while ($row = $db->fetchObject($res)) { $topics[] = ForumTopic::fromRow($row, $this); } return array('topics' => $topics, 'pages' => $pages); }
<?php require 'base.php'; require LANGS . 'ForumT.php'; ForumT::init(); $topic = ForumTopic::fromID((int) $_GET['id']); if (!$topic instanceof ForumTopic) { echo ErrorMessage::setText(ForumT::get('topic_doesnt_exist'), true); } $forum = $topic->getForum(); $posts = $topic->getPosts(Config::get('max_posts_perpage'), max((int) $_GET['page'], 1)); Templates::assignVars(array('forum' => $forum, 'topic' => $topic, 'posts' => $posts['posts'], 'pages' => $posts['pages'])); PluginHelper::delegate('__onPageDisplay', array($page)); Templates::display('viewtopic');
private static function getTopicURL(ForumTopic $t) { return './viewtopic.php?id=' . $t->getID(); }
<span class="required">*</span> <?php echo Yii::t('ForumModule.forum', 'are required.'); ?> </div> <?php echo $form->errorSummary($model); ?> <div class='control-group <?php echo $model->hasErrors("topic_id") ? "error" : ""; ?> '> <?php echo $form->dropDownListRow($model, 'topic_id', ForumTopic::model()->getFormattedList(), array('class' => 'span7', 'encode' => false)); ?> </div> <div class='control-group <?php echo $model->hasErrors("user_id") ? "error" : ""; ?> '> <?php echo $form->dropDownListRow($model, 'user_id', $model->getUserList(), array('class' => 'span7')); ?> </div> <div class="row-fluid control-group <?php echo $model->hasErrors('message') ? 'error' : ''; ?>
public function canAccessTopic($topic_id) { $topic = ForumTopic::find($topic_id); $forum = $topic->forum; if ($this->canAccessForum($topic->forum_id)) { $topicsForUser = $forum->rawTopicsForUser($this->id)->get(); foreach ($topicsForUser as $tp) { if ($tp->topic_id == $topic_id) { return true; } } } return false; }
/** * Возвращает модель по указанному идентификатору * Если модель не будет найдена - возникнет HTTP-исключение. * * @param integer идентификатор нужной модели * @return ForumTopic $model * @throws CHttpException */ public function loadModel($id) { $model = ForumTopic::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, Yii::t('ForumModule.forum', 'Page was not found!')); } return $model; }
public function getTopics($limit = -1) { $criteria = new CDbCriteria(); $criteria->compare('forum_id', $this->id); $criteria->join = 'LEFT JOIN ' . ForumMessage::model()->tableName() . ' AS fm ON fm.topic_id=t.id'; $criteria->order = 'fm.topic_id DESC'; $criteria->group = 't.id'; $criteria->limit = $limit; return ForumTopic::model()->findAll($criteria); }
public function getFormattedList() { $topics = ForumTopic::model()->findAll(); $list = array(); foreach ($topics as $topic) { $list[$topic->id] = $topic->title; } return $list; }
public function markForumRead($user_id) { $user = User::find($user_id); foreach ($this->rawTopicsForUser($user_id)->get() as $topic) { $realTopic = ForumTopic::find($topic->id); if ($realTopic->hasUnreadPosts($user_id)) { $realTopic->markAsRead($user); } } }
<?php $this->breadcrumbs = array(Yii::t('ForumModule.forum', 'Forums') => array('/forum/forumBackend/index'), Yii::t('ForumModule.forum', 'Topics') => array('/forum/messageBackend/index'), Yii::t('ForumModule.forum', 'Manage')); $this->pageTitle = Yii::t('ForumModule.forum', 'Messages - manage'); $this->menu = Yii::app()->getModule('forum')->getNavigation(); ?> <div class="page-header"> <h1> <?php echo Yii::t('ForumModule.forum', 'Messages'); ?> <small><?php echo Yii::t('ForumModule.forum', 'manage'); ?> </small> </h1> </div> <p><?php echo Yii::t('ForumModule.forum', 'This section describes forum management'); ?> </p> <?php $this->widget('yupe\\widgets\\CustomGridView', array('id' => 'forum-message-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array(array('name' => 'id', 'htmlOptions' => array('style' => 'width:20px'), 'type' => 'raw', 'value' => 'CHtml::link($data->id, array("/forum/forumBackend/update", "id" => $data->id))'), array('name' => 'topic_id', 'value' => '$data->getTopicTitle()', 'filter' => CHtml::activeDropDownList($model, 'topic_id', ForumTopic::model()->getFormattedList(), array('encode' => false, 'empty' => ''))), array('name' => 'user_id', 'value' => '$data->getUserNickname()', 'filter' => CHtml::activeDropDownList($model, 'user_id', ForumMessage::model()->getUserList(), array('encode' => false, 'empty' => ''))), array('name' => 'message', 'type' => 'ntext'), 'date', array('class' => 'bootstrap.widgets.TbButtonColumn'))));
public function alertSTs() { $topic = ForumTopic::find(Input::get("topic")); $user = Auth::user(); if ($user->isStoryteller()) { $sendTo = []; $message = Input::get("alert-comment"); foreach (User::listStorytellers() as $st) { $response = Input::get("st-alert-" . $st->id); if ($response == "on") { $sendTo[] = $st; } } foreach ($sendTo as $st) { $st->sendMessage(null, "Carpe Noctem Topic Alert", "Hello, {$st->username},<br><br>This message has been sent to you by {$user->username} to" . " your bring attention to the topic <a href='http://larp.illini-rp.net/forums/topic/{$topic->id}'>" . "{$topic->title}</a>." . ($message ? " {$user->username} had this to say about the topic:<br><br>" . "<blockquote>{$message}</blockquote>" : "")); } return Redirect::to('/forums/topic/' . $topic->id); } else { return Response::json(["success" => false, "message" => "Insufficient priviledges."]); } }