public function redirectToPost($post_id)
    {
        $post_id = Container::get('hooks')->fire('model.topic.redirect_to_post', $post_id);

        $result['select'] = ['topic_id', 'posted'];

        $result = DB::forTable('posts')
                      ->select_many($result['select'])
                      ->where('id', $post_id);
        $result = Container::get('hooks')->fireDB('model.topic.redirect_to_post_query', $result);
        $result = $result->find_one();

        if (!$result) {
            throw new  RunBBException(__('Bad request'), 404);
        }

        $post['topic_id'] = $result['topic_id'];
        $posted = $result['posted'];

        // Determine on which page the post is located (depending on $forum_user['disp_posts'])
        $num_posts = DB::forTable('posts')
                        ->where('topic_id', $post['topic_id'])
                        ->where_lt('posted', $posted)
                        ->count('id');

        $num_posts = Container::get('hooks')->fire('model.topic.redirect_to_post_num', $num_posts);

        $post['get_p'] = ceil(($num_posts + 1) / User::get()->disp_posts);

        $post = Container::get('hooks')->fire('model.topic.redirect_to_post', $post);

        return $post;
    }
public function redirectToPost($post_id)
    {
        $post_id = Container::get('hooks')->fire('model.topic.redirect_to_post', $post_id);

        $result['select'] = ['topic_id', 'posted'];

        $result = DB::forTable('posts')
                      ->select_many($result['select'])
                      ->where('id', $post_id);
        $result = Container::get('hooks')->fireDB('model.topic.redirect_to_post_query', $result);
        $result = $result->find_one();

        if (!$result) {
            throw new  RunBBException(__('Bad request'), 404);
        }

        $post['topic_id'] = $result['topic_id'];
        $posted = $result['posted'];

        // Determine on which page the post is located (depending on $forum_user['disp_posts'])
        $num_posts = DB::forTable('posts')
                        ->where('topic_id', $post['topic_id'])
                        ->where_lt('posted', $posted)
                        ->count('id');

        $num_posts = Container::get('hooks')->fire('model.topic.redirect_to_post_num', $num_posts);

        $post['get_p'] = ceil(($num_posts + 1) / User::get()->disp_posts);

        $post = Container::get('hooks')->fire('model.topic.redirect_to_post', $post);

        return $post;
    }
public function redirectToPost ( $ post_id ) { $ post_id = Container :: get ( 'hooks' ) -> fire ( 'model.topic.redirect_to_post' , $ post_id ) ; $ result [ 'select' ] = [ 'topic_id' , 'posted' ] ; $ result = DB :: forTable ( 'posts' ) -> select_many ( $ result [ 'select' ] ) -> where ( 'id' , $ post_id ) ; $ result = Container :: get ( 'hooks' ) -> fireDB ( 'model.topic.redirect_to_post_query' , $ result ) ; $ result = $ result -> find_one ( ) ; if ( ! $ result ) { throw new RunBBException ( __ ( 'Bad request' ) , 404 ) ; } $ post [ 'topic_id' ] = $ result [ 'topic_id' ] ; $ posted = $ result [ 'posted' ] ; // Determine on which page the post is located (depending on $forum_user['disp_posts']) $ num_posts = DB :: forTable ( 'posts' ) -> where ( 'topic_id' , $ post [ 'topic_id' ] ) -> where_lt ( 'posted' , $ posted ) -> count ( 'id' ) ; $ num_posts = Container :: get ( 'hooks' ) -> fire ( 'model.topic.redirect_to_post_num' , $ num_posts ) ; $ post [ 'get_p' ] = ceil ( ( $ num_posts + 1 ) / User :: get ( ) -> disp_posts ) ; $ post = Container :: get ( 'hooks' ) -> fire ( 'model.topic.redirect_to_post' , $ post ) ; return $ post ; }
Redirect to a post in particular
@param $post_id
@return mixed
@throws RunBBException
Redirect to a post in particular