Exemplo n.º 1
0
 protected function handleRequest(Request $request)
 {
     $tid = \Route::input('id');
     // Fetch some info about the topic
     $topic = Topic::with('forum.perms')->findOrFail($tid);
     $this->data['topic'] = $topic;
     $this->data['action'] = trans('fluxbb::post.post_a_reply');
 }
Exemplo n.º 2
0
 public function put_reply($tid)
 {
     $topic = Topic::with(array('forum', 'forum.perms'))->where('id', '=', $tid)->first();
     if ($topic === NULL) {
         return \Event::first('404');
     }
     // TODO: Flood protection
     $rules = array('req_message' => 'required');
     // TODO: More validation
     if (\Auth::isGuest()) {
         if (Config::enabled('p_force_guest_email') || \Input::get('email') != '') {
             $rules['req_email'] = 'required|email';
         }
         // TODO: banned email
     }
     $validation = $this->make_validator(\Input::all(), $rules);
     if ($validation->fails()) {
         return \Redirect::to_action('fluxbb::posting@reply', array($tid))->with_input()->with_errors($validation);
     }
     $post_data = array('poster' => User::current()->username, 'poster_id' => User::current()->id, 'poster_ip' => \Request::ip(), 'message' => \Input::get('req_message'), 'hide_smilies' => \Input::get('hide_smilies') ? '1' : '0', 'posted' => \Request::time(), 'topic_id' => $tid);
     if (\Auth::isGuest()) {
         $post_data['poster'] = \Input::get('req_username');
         $post_data['poster_email'] = Config::enabled('p_force_guest_email') ? \Input::get('req_email') : \Input::get('email');
     }
     // Insert the new post
     $post = Post::create($post_data);
     // To subscribe or not to subscribe
     $topic->subscribe(\Input::get('subscribe'));
     // Update topic
     $topic->num_replies += 1;
     $topic->last_post = \Request::time();
     $topic->last_post_id = $post->id;
     $topic->last_poster = $post_data['poster'];
     $topic->save();
     // Update forum (maybe $forum->update_forum() ?)
     $forum = $topic->forum;
     $forum->num_posts += 1;
     $forum->last_post = $topic->last_post;
     $forum->last_post_id = $topic->last_post_id;
     $forum->last_poster = $topic->last_poster;
     $forum->save();
     // TODO: update_search_index();
     // If the posting user is logged in, increment his/her post count
     $user = User::current();
     if (\Auth::isAuthed()) {
         $user->num_posts += 1;
         $user->last_post = \Request::time();
         $user->save();
         // TODO: Promote this user to a new group if enabled
     } else {
         $user->online()->update(array('last_post' => \Request::time()));
     }
     return \Redirect::to_action('fluxbb::post', array($post->id))->with('message', trans('fluxbb::post.post_added'));
 }
Exemplo n.º 3
0
 public function get_topic($tid, $page = 1)
 {
     // Fetch some info about the topic
     $topic = Topic::with(array('forum', 'forum.perms'))->where('id', '=', $tid)->whereNull('moved_to')->first();
     if ($topic === NULL) {
         return \Event::first('404');
     }
     $disp_posts = $this->user()->dispPosts();
     $num_pages = ceil(($topic->num_replies + 1) / $disp_posts);
     $page = $page <= 1 || $page > $num_pages ? 1 : intval($page);
     $start_from = $disp_posts * ($page - 1);
     // TODO: Use paginate?
     // Fetch post data
     // TODO: Can we enforce the INNER JOIN here somehow?
     $posts = Post::with(array('poster', 'poster.group'))->where('topic_id', '=', $tid)->orderBy('id')->skip($start_from)->take($disp_posts)->get();
     // TODO: Or do I need to fetch the IDs here first, since those big results will otherwise have to be filtered after fetching by LIMIT / OFFSET?
     return \View::make('fluxbb::viewtopic')->with('topic', $topic)->with('posts', $posts)->with('start_from', $start_from);
 }
Exemplo n.º 4
0
 protected function handleRequest(Request $request)
 {
     $tid = \Route::input('id');
     $this->topic = Topic::with('forum.perms')->findOrFail($tid);
     $this->message = $request->input('req_message');
 }