<?php
/*
* 项目: iOrange(橘子)
* 作者: 离家出走(yzxh24)
* Email: yzxh24@gmail.com
* 主页: www.iorange.cc
*/
/* vim: set ts=4 sw=4: */
class ToAction extends BcartAction
{
    public function run()
    {
        $this->getController()->isLogin();

        $redirect = S::gp('redirect', 'G');
        $bookId = S::gp('bid', 'G', 2);
        $book = fetchBookInfo($bookId);
        if (empty($book))
        {
            throw new iSystemException('不存在的小说');
        }

        $message = '';
        $myBcarts = $this->db()->select(array('id', 'subject'))->from(Bcarts::table())->where(array('uid'=>$this->uid(),'isdelete'=>0))->find();
        if (empty($myBcarts))
        {
            $message[] = '您当前还没有书单,是否现在'.ilink('创建', url('system', array('s'=>'bcart','c'=>'member','a'=>'create'))).'?';
            $message[] = '不知道什么是书单?'.ilink('马上点击查看&gt;&gt;', url('help/index', array('action'=>'bcart_1')));
            $message[] = ilink('返回继续阅读', url('bookshow', array('bid'=>$bookId)));
            $this->showMessage($message);
        }

        $this->getController()->render('to', array('book' => $book, 'myBcarts' => $myBcarts, 'redirect' => $redirect));
    }
}
