<?php
/*
* 项目: iOrange(橘子)
* 作者: 离家出走(yzxh24)
* Email: yzxh24@gmail.com
* 主页: www.iorange.cc
*/
/* vim: set ts=4 sw=4: */
class PushAction extends BbsAction
{
    public function run()
    {
        $tid = $this->getTid();
        $thread = $this->getExistsThread($tid);
        $allows = $this->getAllows($thread);
        !$allows['push'] && $this->NoPermission();

        $this->confirm('push', $thread);
        
        if (isset($_POST['time']))
        {
            $time = intval(S::getGP('time','P'));
            empty($time) && $this->showMessage('请输入提前时间');
            $time > $allows['push'] && $this->showMessage('您当前权限只能提升帖子'.$allows['push'].'小时');
            $time = $time * 3600;
            $this->db()->update(Threads::table())->value(array('lastpost'=>(CTIME+$time)))->where('id='.$tid)->q();
            iforward(url('system',array('s'=>'bbs','a'=>'thread','tid'=>$tid)));
        }
        
        $this->getController()->render('push',array(
                'tid' => $tid,
                'thread' => $thread,
                'allows' => $allows,
            )
        );
    }
}