protected function beforeAction($action) { parent::beforeAction($action); $roles = ['1']; $role = \Yii::app()->user->role; if (array_intersect($role, $roles)) { return true; } else { throw new CHttpException(403, 'Ошибка прав доступа.'); } }
/** * Отображает Расход по указанному идентификатору * * @param integer $id Идинтификатор Расход для отображения * * @return void */ protected function beforeAction($action) { parent::beforeAction($action); if ($action->id == 'create') { $roles = ['1', '2', '3', '4', '5']; $role = \Yii::app()->user->role; if (array_intersect($role, $roles)) { return true; } else { $this->redirect('/'); } } else { $this->redirect('/'); } }
protected function beforeAction($action) { $id = Yii::app()->getRequest()->getQuery('service'); $this->service = Yii::app()->getComponent('eauth')->getIdentity($id); return parent::beforeAction($action); }