<?php
/*
* 项目: iOrange(橘子)
* 作者: 离家出走(yzxh24)
* Email: yzxh24@gmail.com
* 主页: www.iorange.cc
*/
/* vim: set ts=4 sw=4: */
class DeleteAction extends AuthorAction
{
    public function run()
    {
        throw new iSystemException('禁止删除');
        $bookId = S::gp('bid','G',2);
        $chapterId = S::gp('cid','G',2);
        
        $book = $this->isBookOwner($bookId);
        $chapter = Chapter::single()->getOne($chapterId);
        if ($chapter['bookid'] != $book['bookid'])
        {
            $this->_showMessage('非法操作');
        }
        
        if (!$_GET['confirm'])
        {
            $message[] = '确定要删除吗？删除后将不可再恢复！';
            $message[] = ilink('确定删除',$this->getController()->url('system',array('s'=>'author','c'=>'chapter','a'=>'delete','confirm'=>1,'bid'=>$bookId,'cid'=>$chapterId))).'.'.ilink('返回章节', $this->getController()->url('system',array('s'=>'author','c'=>'chapter','bid'=>$bookId)));
            $this->showMessage($message);
        }
        Chapter::single()->delete($chapterId, $bookId);

        $this->db()->insert(ChapterDelete::table())->value(array('bid'=>$bookId,'name'=>$chapter['chaptername'],'date'=>CDATE,'createdate'=>CDATETIME,'uid'=>$this->uid(),'username'=>$this->userName(),'size'=>$chapter['size']))->q();
        if ($this->getController()->isWebRequest())
        {
            $this->_showMessage('删除成功！', 1);
        }
        
        $message[] = '删除成功';
        $message[] = '返回'.ilink('章节列表',$this->getController()->url('system',array('s'=>'author','c'=>'chapter','bid'=>$bookId))).'.'.ilink('作者中心',$this->getController()->url('system',array('s'=>'author')));
        $this->showMessage($message);
    }
}