<?php
class CompleteAction extends BaseAction
{
    public function run()
    {
        $id = Yii::app()->request->getQuery('id');
        $report = Reports::model()->findByPk($id);
        if (!empty($report))
        {
            $report->status = 1;
            $report->save();
            
            $subject = '[系统消息]您所报错的小说《'.$report->bookname.'》已经修复';
            $message = '您所报错的小说《'.$report->bookname.'》已经修复,给您带来的不便敬请见谅,感谢您的支持,书城有你更精彩!';
            if ($report->isfirst && setting('reportaward'))
            {
                $message = '您所报错的小说《'.$report->bookname.'》已经修复,给您带来的不便敬请见谅,由于您是第一个汇报错误的书友,为了感谢您对书城的支持,特奖励'.setting('reportaward').setting('creditname').'!';
                Member::model()->updateCounters(array('extcredits1'=>setting('reportaward')),'uid='.$report->uid);
            }

            Messages::model()->create($subject,$message,$report->uid);
        }
        
        $this->getController()->redirect(array('list'));
    }
}