<?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);
        $member = $this->db()->select()->from(BookBan::table())->where(array('bookid'=>$this->id(),'uid'=>$uid))->find(true);
        if (empty($member))
        {
            throw new iSystemException('解禁的会员不存在');
        }
        if ($member['islock'])
        {
            throw new iSystemException('被锁定的用户，只能等到期后自动解禁');
        }
        
        $this->db()->delete(BookBan::table())->where(array('bookid'=>$this->id(),'uid'=>$uid))->q();
        $message[] = '解禁成功';
        $message[] = '返回' . ilink('管理',url('system',array('s'=>'forum','c'=>'manage','id'=>$this->id()))) . '.' . forumLink($this->id());
        
        $this->showMessage($message);
    }
}