<?php
class CompleteAction extends BaseAction
{
    public function run()
    {
        $id = Yii::app()->request->getQuery('id');
        $demand = Demands::model()->findByPk($id);
        if (!empty($demand))
        {
            $demand->status = 1;
            $demand->save();
            
            $subject = '[系统消息]您所求的小说《'.$demand->bookname.'》已经上架';
            $message = '您所求的小说《'.$demand->bookname.'》已经上架,欢迎阅读,感谢您的支持.';
            Messages::model()->create($subject,$message,$demand->uid);
        }
        
        $this->getController()->redirect(array('list'));
    }
}