public function post($title, $body, $user = null) { if (!Auth::check()) { return false; } if (!$user) { $user = Auth::user(); } if ($user->canAccessForum($this->id)) { $topic = new ForumTopic(); $topic->forum_id = $this->id; $topic->title = $title; $topic->save(); $post = new ForumPost(); $post->topic_id = $topic->id; $post->body = $body; $post->posted_by = $user->id; $post->save(); $topic->first_post = $post->id; $topic->save(); return $topic; } else { return false; } }
public function postReply($user_id, $body) { $post = new ForumPost(); $post->topic_id = $this->id; $post->body = $body; $post->posted_by = $user_id; $post->save(); return $post; }
public static function AddReplyNotifications($post_id) { global $currentUser; $post = new ForumPost($post_id); // Lista di utenti che hanno risposto al topic, ma che non // sono all'interno della skip list $q = exequery("SELECT p.user_id as user_id, s.user_id as skip_user_id FROM forum_posts p \n\t\t\t\t\t\t\tLEFT OUTER JOIN forum_notifications_skip_list s ON (s.user_id = p.user_id AND s.topic_id = {$post['root_topic']}) \n\t\t\t\t\t\t\tWHERE p.root_topic = {$post['root_topic']} OR p.id = {$post['root_topic']} GROUP BY user_id\n\t\t\t\t\t\t\tUNION SELECT a.user_id AS user_id, NULL AS skip_user_id\n\t\t\t\t\t\t\tFROM forum_notifications_add_list a WHERE a.topic_id = {$post['root_topic']}\n\t\t\t"); // Una notifica a ciascuno, non fa male a nessuno while ($values = mysqli_fetch_array($q)) { if ($values['user_id'] == $currentUser['id']) { continue; } //Skip noi stessi if ($values['skip_user_id'] != null) { continue; } //Skippa se richiesto exequery("INSERT INTO forum_notifications (topic_id, user_id, notify_tm, post_id, page_num) \n\t\t\t \tVALUES ('{$post['root_topic']}','{$values['user_id']}'," . time() . ", {$post_id}, " . $post->getPageNumber() . ")"); } //Rimuovi dalla lista di skip_notifications l'user che ha postato exequery("DELETE FROM forum_notifications_skip_list \n\t\t\t \t\t\tWHERE user_id = {$currentUser['id']} AND topic_id = {$post['root_topic']}"); }
/** * @param $postId * @param \User $author * @return bool|void */ public static function minus($postId, \User $author) { $forum = \ForumPost::find(intval($postId)); if (!$forum) { return false; } if ($forum->author_id == $author->id) { return $forum->author_id; } if ($forum->author->rate(-1)) { return $forum->author_id; } return false; }
/** * Get last post of newest topic in this forum. * * @return ForumPost */ public function getLastPost() { global $db; $res = $db->query("SELECT * FROM " . TABLE_POSTS . " WHERE forum_id = ? ORDER BY post_time DESC LIMIT 1", array($this->id)); $row = $db->fetchObject($res); if ($row) { return ForumPost::fromRow($row, null, $this); } return null; }
<?php render(false); if (!empty(Request::$params->forum_post)) { $preview = true; $forum_post = ForumPost::blank(array_merge(request::$params->forum_post, array('creator_id' => User::$current->id))); $forum_post->created_at = gmd(); render_partial("post", array('post' => $forum_post)); }
/** * @return array */ public function to_array() { return array_merge(['author' => $this->author->to_array(), 'forum' => $this->forum->to_array(), 'close' => $this->close_id ? $this->close->to_array() : [], 'posts' => intval(ForumPost::count(['conditions' => ['theme_id = ?', $this->id]]))], parent::to_array()); }
Fields with checkmarks have already been awarded. To view a character's backstory, press the book icon.<br> <b>Awarding character biography experience cannot be undone.</b> </p> <table class="journal-grid responsive"> <thead> <th>Character</th> <th></th> <th></th> <th>Question XP</th> <th>Backstory XP</th> </thead> <tbody> @foreach(Character::activeCharacters()->orderBy('name')->get() as $c) <?php //Find the relevant thread $topic = ForumPost::where('body', "[[questionnaire/{$c->id}]]")->first(); ?> <tr> <td> @if($topic) <a href="/forums/topic/{{$topic->topic->id}}">{{$c->name}}</a> @else {{$c->name}} @endif </td> <?php $biographies = CharacterQuestionnaire::where('character_id', $c->id)->where('response', '!=', '')->get(); $experience = CharacterBiographyExperience::where('character_id', $c->id)->first(); ?> <td> {{$biographies->count()}}
<?php create_page_params(); if (request::$params->query) { $query = '%' . str_replace(' ', '%', request::$params->query) . '%'; $forum_posts = ForumPost::find_all(array('order' => "id desc", 'per_page' => 30, 'conditions' => array('title LIKE ? OR body LIKE ?', $query, $query), 'page' => request::$params->page)); } else { $forum_posts = ForumPost::find_all(array('order' => "id desc", 'per_page' => 30, 'page' => request::$params->page)); } calc_pages(); respond_to_list("forum_posts");
$bool_str = $isBlocked ? "true" : "false"; printf("Forum Topic %d is blocked: %s\n", 1895578464, $bool_str); //////////////////////////// //ForumPost UNIT TESTS //////////////////////////// printf("/////////////////////////////////\n"); printf("STARTING ForumPost UNIT TESTS\n"); printf("/////////////////////////////////\n"); //construct empty forum post $forumPost = new ForumPost(); //add post $forumPost->createPost(1895578464, "kmassey", "This is a forum post."); //delete post $forumPost->deletePost(); //fetch existing forumPost $forumPost2 = new ForumPost(1667447439); //fetch content of existing forum post $post_content = $forumPost2->getPostContent(); printf("Fetched Post: %s\n", $post_content); //block forum post printf("Blocking post %d\n", 1667447439); $forumPost2->block(); $isBlocked = $forumPost2->isBlocked(); $bool_str = $isBlocked ? "true" : "false"; printf("Forum Post %d is blocked: %s\n", 1667447439, $bool_str); //unblock forum post printf("Unblocking post %d\n", 1667447439); $forumPost2->unblock(); $isBlocked = $forumPost2->isBlocked(); $bool_str = $isBlocked ? "true" : "false"; printf("Forum Post %d is blocked: %s\n", 1667447439, $bool_str);
/** * Exclude object from result * * @param ForumPost $forumPost Object to remove from the list of results * * @return ForumPostQuery The current query, for fluid interface */ public function prune($forumPost = null) { if ($forumPost) { $this->addUsingAlias(ForumPostPeer::POST_ID, $forumPost->getPostId(), Criteria::NOT_EQUAL); } return $this; }
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ /** Ricava il contenuto raw di un post (o topic) del forum La richiesta dev'essere effettuata da un utente che ha i permessi per editare il post/topic method: GET e POST combinato params: id (GET): id del post/topic value (POST): nuovo contenuto returns: success => true|false value => HTML contenente il nuovo post */ require_once "__inc__.php"; $response = new RestfulResponse("json"); validate_num($_GET['id']); if ($currentUser->isLogged()) { $q = exequery("SELECT argument, user_id FROM forum_posts WHERE id = {$_GET['id']}"); $values = mysqli_fetch_array($q); // Puo' editare? if ($currentUser->isModOfForum($values['argument']) || $currentUser["id"] == $values['user_id']) { $message = db_escape(Charset::Utf8ToDB($_POST['value'])); exequery("UPDATE forum_posts SET message = '{$message}', edit_date = " . time() . ", edit_by = {$currentUser['id']}\n WHERE id = {$_GET['id']}"); $post = new ForumPost($_GET['id']); $response->set("value", $post->getParsedMessage()); $response->setSuccess(true); } else { $response->setError("Non hai i permessi per modificare questo post"); } } else { $response->setError("Non loggato"); } echo $response->send();
if ($_SERVER["REQUEST_METHOD"] == "POST") { if (isset($_POST['description'])) { $topic = test_input($_POST["topic"]); $description = test_input($_POST["description"]); } } function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } //update forum_post table if (isset($_POST['submit'])) { $new_forum_topic = new ForumPost(); $new_forum_topic->createNew(array('post_title' => $topic, 'post_description' => $description, 'posted_user' => $name, 'posted_date' => $date)); $new_forum_topic->register(); header('Location: forum_p.php'); exit; } ob_flush(); //Get details from forum_post table echo "<div class='datagrid'><table>\n <thead><tr><th>Discussion</th><th>Posted by</th><th>Date</th></tr></thead>"; $allposts = ForumPost::getallForum(); foreach ($allposts as $key => $value) { $id = $value->get_id(); $title = $value->get_Title(); #$des=$value->get_Description(); $pst_usr = $value->get_Posteduser(); $pst_date = $value->get_Postdate();
public function saveBiography($character) { $question_ids = Input::get('ids'); $replies = Input::get('replies'); if ($character) { foreach ($question_ids as $index => $q) { $response = CharacterQuestionnaire::firstOrNew(['character_id' => $character->id, 'questionnaire_id' => $q]); $response->response = $replies[$index]; $response->save(); } if (Input::hasFile('backstory')) { $file = Input::file('backstory'); $fileName = preg_replace("([^\\w\\d\\-_~,;:\\[\\]\\(\\).])", '', $character->name . "Backstory." . $file->getClientOriginalExtension()); $file->move(public_path() . '/content/backstories/', $fileName); $character->backstory_file = $fileName; $character->save(); } if ($character->active || $character->in_review) { //Find the relevant forum post and bump it (or create it if it doesn't exist) $post = ForumPost::where('body', "[[questionnaire/{$character->id}]]")->first(); if ($post) { $topic = $post->topic; $topic->postReply($character->owner->id, "Questionnaire responses updated. (Automatic system post)"); } else { //42 = Character Backgrounds $topic = Forum::find(42)->post("Character Biography for " . $character->name, "[[questionnaire/{$character->id}]]"); $topic->markAsRead(Auth::user()); } return Redirect::to("/forums/topic/" . $topic->id); } else { return Redirect::to("/dashboard/characters"); } } else { return Response::json(["success" => false, "message" => "Character could not be found."]); } }
<?php ForumPost::lock(request::$params->id); notice("Topic locked"); redirect_to("#show", array('id' => request::$params->id));
<?php set_title(CONFIG::app_name . " Forum"); create_page_params(); auto_set_params(array('query', 'parent_id')); if (isset(request::$params->parent_id)) { $forum_posts = ForumPost::find_all(array('order' => "is_sticky desc, updated_at DESC", 'per_page' => 100, 'conditions' => array("parent_id = ?", request::$params->parent_id), 'page' => request::$params->page)); } else { $forum_posts = ForumPost::find_all(array('order' => "is_sticky desc, updated_at DESC", 'per_page' => 30, 'conditions' => array("parent_id IS NULL"), 'page' => request::$params->page)); } calc_pages(); respond_to_list($forum_posts);
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param ForumPost $value A ForumPost object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(ForumPost $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getPostId(); } // if key === null self::$instances[$key] = $obj; } }
<?php /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ /** Ricava il contenuto raw di un post (o topic) del forum La richiesta dev'essere effettuata da un utente che ha i permessi per editare il post/topic method: GET params: id: id del post/topic returns: informazioni del post/topic, inclusi: - messaggio, username del postatore */ require_once "__inc__.php"; $response = new RestfulResponse("json"); validate_num($_GET['id']); if ($currentUser->isLogged()) { $post = new ForumPost($_GET['id']); if ($post->isViewableBy($currentUser)) { $response->set('message', $post['message']); $response->set('username', $post['user']); } else { $response->setError("Non hai i permessi per leggere queste informazioni."); } } else { $response->setError("Non loggato"); } echo $response->send();
public function getPosts($pageLimit = 0, $currentPage = 1) { global $db, $user, $userManager; if ($pageLimit == 0) { $pageLimit = Config::get('max_posts_perpage'); } $resMeta = $db->query("SELECT * FROM " . TABLE_POSTS . " WHERE topic_id = '" . $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 posts.*, track.mark_time\n\t\t\t\t\tFROM " . TABLE_POSTS . " AS posts\n\t\t\t\t\tLEFT JOIN " . TABLE_TOPICS_TRACK . " AS track\n\t\t\t\t\t\tON posts.topic_id = track.topic_id AND track.user_id = :uid\n\t\t\t\t\tWHERE posts.topic_id = :tid\n\t\t\t\t\tORDER BY posts.id ASC\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 posts.*\n\t\t\t\t\tFROM " . TABLE_POSTS . " AS posts\n\t\t\t\t\tWHERE posts.topic_id = :tid\n\t\t\t\t\tORDER BY posts.id ASC\n\t\t\t\t\tLIMIT :pageCalc,:pageLimit\n\t\t\t\t", array($this->id, $page * $pageLimit - $pageLimit, $pageLimit)); } $posts = array(); while ($row = $db->fetchObject($res)) { $posts[] = ForumPost::fromRow($row, $this); } return array('posts' => $posts, 'pages' => $pages); }
static function updated($user) { $conds = array(); if (!$user->is_anonymous) { $conds[] = "creator_id <> " . $user->id; } if (!($newest_topic = ForumPost::find_first(array('order' => "id desc", 'limit' => 1, 'select' => "created_at", 'conditions' => $conds)))) { return false; } return $newest_topic->created_at > $user->last_forum_topic_read_at; }
<?php ForumPost::unstick(request::$params->id); notice("Topic unstickied"); redirect_to("#show", array('id' => request::$params->id));
$response = new RestfulResponse("json"); $av = new AutoValidator("frm-forum-reply", $_POST); if ($av->validate()) { if ($currentUser->isLogged()) { // Valida i campi di input validate_num($_POST['topic_id']); $topic = new Topic($_POST['topic_id']); $message = db_escape(Charset::Utf8ToDB($_POST['message'])); if (!Forum::IsUserFlooding($currentUser)) { if (!$topic['locked']) { // Trova il forum_id $values = DB::FindOne("SELECT argument FROM forum_posts WHERE id = {$_POST['topic_id']}"); $forum_id = $values['argument']; exequery(sprintf("INSERT INTO forum_posts (user_id, root_topic, argument, message, type, post_date, last_post_date, ip) \n VALUES(%d, %d, %d, '%s', %d, %d, %d, '%s')", $currentUser['id'], $_POST['topic_id'], $forum_id, $message, Forum::TYPE_POST, time(), time(), get_ip())); $id = DB::LastId(); $post = new ForumPost($id); Forum::UpdateTopicAfterReply($_POST['topic_id']); Forum::IncPostCountForUser($currentUser); Forum::AddReplyNotifications($post['id']); $response->set("post_html", $post->render("forum/post.html")); $response->setSuccess(true); } else { $response->setError("Il topic e' stato chiuso dal moderatore."); } } else { $response->setError("Attendi almeno " . Forum::FLOOD_SECONDS_LIMIT . " secondi tra un post e l'altro."); } } else { $response->setError("Non sei loggato."); } } else {
public static function deletePost(ForumPost $p) { global $db; $db->query("\n\t\t\t\tDELETE FROM " . TABLE_POSTS . "\n\t\t\t\tWHERE id = ?\n\t\t\t", array($p->getID())); }
protected function init_cookies() { if ($this->request()->format() == "xml" || $this->request()->format() == "json") { return; } $forum_posts = ForumPost::where("parent_id IS NULL")->order("updated_at DESC")->limit(10)->take(); $this->cookies()->current_forum_posts = json_encode(array_map(function ($fp) { if (current_user()->is_anonymous()) { $updated = false; } else { $updated = $fp->updated_at > current_user()->last_forum_topic_read_at; } return [$fp->title, $fp->id, $updated, ceil($fp->response_count / 30.0)]; }, $forum_posts->members())); $this->cookies()->country = current_user()->country; if (!current_user()->is_anonymous()) { $this->cookies()->user_id = (string) current_user()->id; $this->cookies()->user_info = current_user()->user_info_cookie(); $this->cookies()->has_mail = current_user()->has_mail ? "1" : "0"; $this->cookies()->forum_updated = current_user()->is_privileged_or_higher() && ForumPost::updated(current_user()) ? "1" : "0"; $this->cookies()->comments_updated = current_user()->is_privileged_or_higher() && Comment::updated(current_user()) ? "1" : "0"; if (current_user()->is_janitor_or_higher()) { $mod_pending = Post::where("status = 'flagged' OR status = 'pending'")->count(); $this->cookies()->mod_pending = (string) $mod_pending; } if (current_user()->is_blocked()) { if (current_user()->ban) { $this->cookies()->block_reason = "You have been blocked. Reason: " . current_user()->ban->reason . ". Expires: " . substr(current_user()->ban->expires_at, 0, 10); } else { $this->cookies()->block_reason = "You have been blocked."; } } else { $this->cookies()->block_reason = ""; } $this->cookies()->resize_image = current_user()->always_resize_images ? "1" : "0"; $this->cookies()->show_advanced_editing = current_user()->show_advanced_editing ? "1" : "0"; $this->cookies()->my_tags = current_user()->my_tags; $this->cookies()->blacklisted_tags = json_encode(current_user()->blacklisted_tags_array()); $this->cookies()->held_post_count = (string) current_user()->held_post_count(); } else { $this->cookies()->delete('user_info'); $this->cookies()->delete('login'); $this->cookies()->blacklisted_tags = json_encode(CONFIG()->default_blacklists); } if ($this->session()->notice) { $this->cookies()->notice = $this->session()->notice; $this->session()->delete('notice'); } }
selector: "#post", plugins: "textcolor link hr image emoticons table preview fullscreen print searchreplace visualblocks code", toolbar1: "undo redo | styleselect | bold italic underline | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image", toolbar2: "forecolor backcolor emoticons", image_advtab: true, forced_root_block : '' }); @stop @section('forum-content') <?php $user = Auth::user(); $quote = Input::get('quote'); $quoteValue = ""; if (isset($quote)) { $postToQuote = ForumPost::find($quote); if ($postToQuote) { $quoteValue = "<blockquote><cite>" . $postToQuote->poster->username . " wrote:</cite>" . $postToQuote->body . "</blockquote><br>"; } } if (isset($post)) { $topic = $post->topic; } ?> <ul class="button-group breadcrumb-group"> <li><a href="/forums" class="button small secondary"><i class="icon-home"></i></a></li> <li><a href="/forums/{{$topic->forum->id}}" class="button small secondary">{{$topic->forum->name}}</a></li> <li><a href="/forums/topic/{{$topic->id}}" class="button small secondary">{{$topic->title}}</a></li> @if($topic->forum->reply_permission == null || $user->hasPermissionById($topic->forum->reply_permission)) <li><a href="#" class="button small secondary">Post Reply</a></li> @endif
<?php if (!($forum_post = ForumPost::find(request::$params->id))) { return 404; } if (User::$current->has_permission($forum_post, 'creator_id')) { $forum_post->destroy(); notice("Post destroyed"); if ($forum_post->is_parent) { redirect_to("#index"); } else { redirect_to("#show", array('id' => $forum_post->root_id)); } } else { notice("Access denied"); redirect_to("#show", array('id' => $forum_post->root_id)); }
function init_cookies() { if (Request::$format != 'html' || Request::$format == 'json') { return; } // $forum_posts = ForumPost::find('all', array('order' => "updated_at DESC", 'limit' => 10, 'conditions' => "parent_id IS NULL")); // foreach($forum_posts as $fp) { // $updated = User::$current->is_anonymous ? false : $fp->updated_at > User::$current->last_forum_topic_read_at; // $fp_cookies[] = array($fp->updated_at, $fp->id, $updated, ceil($fp->response_count/30)); // } // Cookies::$list["current_forum_posts"] = to_json($fp_cookies); // Cookies::$list["country"] = $current_user_country; // vde(User::$current->is_anonymous); if (!User::$current->is_anonymous) { cookie_put("user_id", (string) User::$current->id); cookie_put("user_info", User::$current->user_info_cookie()); // Cookies::$list["has_mail"] = User::$current->has_mail() ? "1" : "0"; cookie_put("forum_updated", User::$current->is(">=30") && ForumPost::updated(User::$current) ? "1" : "0"); // Cookies::$list["comments_updated"] = User::$current->is(">=30") && Comment::updated(User::$current) ? "1" : "0"; // if(User::$current->is(">=35")) { // $mod_pending = Post::count(array('conditions' => array("status = 'flagged' OR status = 'pending'"))); // cookies["mod_pending"] = $mod_pending; // } // if(User::$current->is_blocked()) { // if(User::$current->ban) // Cookies::$list["block_reason"] = "You have been blocked. Reason: ".User::$current->ban->reason.". Expires: ".substr(User::$current->ban->expires_at, 0, 10); // else // Cookies::$list["block_reason"] = "You have been blocked."; // } else // Cookies::$list["block_reason"] = ""; cookie_put("resize_image", User::$current->always_resize_images ? "1" : "0"); cookie_put('show_advanced_editing', User::$current->show_advanced_editing ? "1" : "0"); // Cookies::$list["my_tags"] = User::$current->my_tags; // $a = explode("\r\n", User::$current->blacklisted_tags()); // vde($a); cookie_rawput('blacklisted_tags', str_replace('%0D%0A', '&', urlencode(User::$current->blacklisted_tags()))); // ["blacklisted_tags"] = User::$current->blacklisted_tags_array; cookie_put("held_post_count", User::$current->held_post_count()); } else { cookie_remove('user_info'); cookie_remove('login'); // Cookies::$list["blacklisted_tags"] = str_replace('%0D%0A', '&', urlencode(implode("\r\n", CONFIG::$default_blacklists))); // Cookies::rawput cookie_rawput('blacklisted_tags', str_replace('%0D%0A', '&', urlencode(implode("\r\n", CONFIG::$default_blacklists)))); } // if flash[:notice] then // cookies["notice"] = flash[:notice] }
<td><strong><?php echo $this->t('user_wiki_edits'); ?> </strong></td> <td><?php echo $this->linkTo(WikiPageVersion::where(['user_id' => $this->user->id])->count(), array('wiki#recent_changes', 'user_id' => $this->user->id)); ?> </td> </tr> <tr> <td><strong><?php echo $this->t('user_forum_post'); ?> </strong></td> <td><?php echo ForumPost::where(['creator_id' => $this->user->id])->count(); ?> </td> </tr> <?php if ($this->user->invited_by) { ?> <tr> <td><strong><?php echo $this->t('user_invited_by'); ?> </strong></td> <td><?php echo $this->linkTo($this->h(User::find($this->user->invited_by)->name), array('action' => 'show', 'id' => $this->user->invited_by)); ?> </td>
<?php require_once 'core/init.php'; // define variables and set to empty values $topic = $description = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { $topic = test_input($_POST["topic"]); $description = test_input($_POST["description"]); } function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } $new_forum_topic = new ForumPost(); $new_forum_topic->createNew(array('category_title' => $topic, 'category_description' => $description)); $new_forum_topic->register(); $allposts = forumPost::getallForum(); foreach ($allposts as $key => $value) { $title = $value->get_Title(); $des = $value->get_Description(); echo "<a href='#' class='cat_links'> <b>{$title}</b> : <hr> <br><i>{$des}</i></a><br> "; } ?> </div> </div>
/** * Comments list * * @param $request * @param $matches * @return mixed */ public function posts_list($request, $matches) { $topic = $this->view->get('topic', $matches->get('topic')); $topic = $topic instanceof \ForumTheme ? $topic : \ForumTheme::find($topic); $filter = ['conditions' => ['theme_id = ?', $topic->id], 'order' => 'created_at DESC']; /** @var Listing $paginator */ $paginator = NCService::load('Paginator.Listing', [$request->page, \ForumPost::count($filter)]); $filter = array_merge($filter, $paginator->limit()); // Comments $comments = \ForumPost::find('all', $filter); $comments = \ForumPost::as_array($comments); // Context $context = ['topic' => $topic, 'posts_list' => $comments, 'page' => $paginator->cur_page, 'listing' => $paginator->pages()]; // Add comment status if ($status = $this->view->get('status', false)) { $context['status'] = $status; } // Build response if ($request->get('type', 'html') == 'json') { unset($context['listing']); $context['pages'] = $paginator->pages; $context['rows'] = $paginator->num_rows; return static::json_response($context); } return $this->view->render('forum/posts.twig', $context); }