<?php
class CompleteAction extends BaseAction
{
    public function run()
    {
        $id = Yii::app()->request->getQuery('id');
        $report = Oreport::model()->findByPk($id);
        
        if (!empty($report))
        {
            $report->status = 1;
            $report->save();
            
            $subject = '[系统消息]您举报的小说《'.$report->bookname.'》已经处理';
            $message = '您举报的小说《'.$report->bookname.'》已经处理，感谢您的支持！';
            if (setting('oreportaward'))
            {
                $message = '您举报的小说《'.$report->bookname.'》已经处理，奖励'.setting('oreportaward').setting('creditname').'，感谢您的支持！';
                Member::model()->updateCounters(array('extcredits1'=>setting('oreportaward')),'uid='.$report->uid);
            }
            Messages::model()->create($subject,$message,$report->uid);
        }
        
        $this->getController()->redirect(array('list'));
    }
}