<?php
/*
* 项目: iOrange(橘子)
* 作者: 离家出走(yzxh24)
* Email: yzxh24@gmail.com
* 主页: www.iorange.cc
*/
/* vim: set ts=4 sw=4: */
class LastAction extends BbsAction
{
    public function run()
    {
        $tid = $this->getTid();
        $thread = $this->getExistsThread($tid);
        $pageSize = Posts::$pageSize;
        
        $totalPage = $thread['replies'] > $pageSize ? ceil($thread['replies'] / $pageSize) : 0;
        $merge = array();
        $totalPage && $merge = array('page'=>$totalPage);
        $redirectUrl = url('system',array_merge(array('s'=>'bbs','a'=>'thread','tid'=>$tid), $merge)).'#lastpost';
        iforward($redirectUrl);
    }
}