/** * Delete all posts */ public function dispose() { // Delete posts $posts = ForumPost::find('all', ['conditions' => ['theme_id = ?', $this->id]]); foreach ($posts as $post) { $post->delete(); } // Delete likes Like::table()->delete('post = "topic' . $this->id . '"'); }
/** * @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; }
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
/** * 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); }
<?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)); }
@section('forum-script') @stop @section('forum-content') <ul class="button-group breadcrumb-group"> <li><a href="/forums" class="button small secondary"><i class="icon-home"></i></a></li> <li><a href="#" class="button small secondary">Search Results for "{{$query}}"</a></li> </ul> <h3 class="topic-title">Search Results for "{{$query}}"</h3> <div class="topic-pagination search-pagination">{{$listing->links()}}</div> @foreach($listing as $result) <?php $post = ForumPost::find($result->id); ?> <div class="row search-result-row"> <div class="small-12 medium-3 columns post-user-column search-user-column"> <div class="user-card"> <div class="user-name"> {{$post->poster->username}} </div> </div> </div> <div class="small-12 medium-9 columns"> <div class="post-data"> <div class="post-title"> <a href="{{$post->topic->getLinkForPostById($user, $post->id)}}">{{$post->topic->title}}</a> <span class="right">Posted {{$post->created_at->diffForHumans()}}</span> </div>
public function show() { $this->forum_post = ForumPost::find($this->params()->id); $this->children = ForumPost::where("parent_id = ?", $this->params()->id)->order("id")->paginate($this->page_number(), 30); if (!$this->current_user->is_anonymous() && $this->current_user->last_forum_topic_read_at < $this->forum_post->updated_at && $this->forum_post->updated_at < time() - 3) { $this->current_user->updateAttribute('last_forum_topic_read_at', $this->forum_post->updated_at); } $this->respond_to_list("forum_post"); }
function deletePost() { $post = ForumPost::find(Input::get("id")); if ($post) { $user = Auth::user(); if ($post->poster->id == $user->id || $user->isStoryteller()) { $post_forum = $post->topic->forum; $post_topic = $post->topic; $post->delete(); //If this post is the first post in a thread, delete the thread. ForumTopic::where('first_post', $post->id)->delete(); //Redirect to the thread if it still exists. Otherwise, go back to the forum. if (ForumTopic::where('id', $post_topic->id)->count() > 0) { return Redirect::to("/forums/topic/" . $post_topic->id); } else { return Redirect::to("/forums/" . $post_forum->id); } } else { return Response::json(["success" => false, "message" => "Insufficient privileges."]); } } else { return Response::json(["success" => false, "message" => "No post found with that ID."]); } }