<?php
/*
* 项目: iOrange(橘子)
* 作者: 离家出走(yzxh24)
* Email: yzxh24@gmail.com
* 主页: www.iorange.cc
*/
/* vim: set ts=4 sw=4: */
class DeleteAction extends ForumAction
{
    public function run()
    {
        $this->isManager();
        $uid = S::gp('uid', 'G', 2);
        try
        {
            $member = Members::single()->getOne($uid);
        }
        catch (Exception $exce)
        {
            throw new iSystemException($exce->getMessage());
        }

        $check = $this->db()->getValue('SELECT COUNT(*) FROM '.BookManageDeputy::table().' WHERE uid='.$uid.' AND bookid='.$this->id());
        if (!$check)
        {
            throw new iSystemException('不存在的书会副管');
        }
        $this->db()->delete(BookManageDeputy::table())->where(array('bookid'=>$this->id(),'uid'=>$uid))->q();
        BookManageDeputy::single()->updateAllCache($this->id());
        
        iforward(url('system', array('s'=>'forum','c'=>'deputy','id'=>$this->id())));
    }
}