public function actionActivate() { $field = isset($_GET['field']) ? $_GET['field'] : 'active'; $action = $_GET['action']; $id = $_GET['id']; if (!(!$id && $action === null)) { $model = $this->loadModel($id); if ($this->scenario) { $model->scenario = $this->scenario; } if ($model) { $model->{$field} = $action == 'activate' ? 1 : 0; $model->update(array($field)); User::destroyUserSession($model->id); } } if (!Yii::app()->request->isAjaxRequest) { $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin')); } }