<?php
/**
 * 删除用户
 * @author yzxh24
 */
class DeleteAction extends BaseAction
{
    public function run()
    {
        if(Yii::app()->request->isPostRequest)
        {
            $model = Manager::model()->find('id=:id',array(':id'=>intval($_GET['id'])));
            if (empty($model))
            {
                throw new CHttpException(400,'不存在的用户');
            }
            
            $model->deleted = 1;
            $model->save();

            if(!isset($_GET['ajax']))
            {
                $this->getController()->redirect(array('list'));
            }
        }
        else
        {
            throw new CHttpException(400,'Invalid request. Please do not repeat this request again.');
        }
    }
}