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

        if ($thread['uid'] != $this->uid() && isGM($this->uid()))
        {
            $this->NoPermission();
        }
        if (!$robfloor['robstatus'])
        {
            throw new iSystemException('当前的踢楼活动不能停止');
        }

        if (!$_GET['confirm'])
        {
            $message[] = '确定要终止踢楼活动吗？';
            $message[] = ilink('确定', url('system', array('s'=>'bbs','a'=>'efloor','tid'=>$tid,'confirm'=>1))).'|'.ilink('取消', url('system', array('s'=>'bbs','a'=>'thread','tid'=>$tid)));
            $this->showMessage($message);
        }
        $this->db()->update(Robbuild::table())->value(array('status'=>1))->where(array('tid'=>$tid))->q();

        iforward(url('system', array('s'=>'bbs','a'=>'thread','tid'=>$tid)));
    }
}