<?php
/*
* 项目: iOrange(橘子)
* 作者: 离家出走(yzxh24)
* Email: yzxh24@gmail.com
* 主页: www.iorange.cc
*/
/* vim: set ts=4 sw=4: */
class MoveAction extends ForumAction
{
    public function run()
    {
        $this->isManager();
        
        $cid = S::gp('cid','G',2);
        $post = BookPost::single()->getOne($cid, $this->id());
        if (empty($post))
        {
            throw new iSystemException('不存在的书评');
        }
        if ($post['digest'])
        {
            throw new iSystemException('精华评论不能移除，必须先取消');
        }
    
        BookPost::single()->delete($cid, $this->id(), $this->uid(), $this->userName(), '移动评论');
        $data = array(
            'message' => $post['message'],
            'username' => $post['username'],
            'uid' => $post['uid'],
        );
        Chat::single($this->id())->create($data);
        
        iforward($this->getController()->url('system',array('s'=>'forum','id'=>$this->id())));
    }
}