Beispiel #1
0
 protected function checkControllerRules($controller, $module = null, $application)
 {
     $accessArray = array();
     //user roles
     $user_actions = UsersActions::model()->findAll("controller like '{$controller}' and module like '{$module}'");
     if ($user_actions) {
         foreach ($user_actions as $key => $user_action) {
             $array_action = array_map('trim', explode(",", trim($user_action->actions)));
             $accessArray[] = array($user_action->type, 'actions' => $array_action, 'users' => array($user_action->user->username));
         }
     }
     //menu roles
     $menu = Menus::model()->find(array('condition' => "controller_name like '{$controller}' and module_name like '{$module}' and application_id = {$application}", 'order' => 'desc'));
     if ($menu) {
         $roles_menu = RolesMenus::model()->findAll("menu_id = {$menu->id}");
         foreach ($roles_menu as $key => $role_menu) {
             $array_action = array_map('trim', explode(",", trim($role_menu->actions)));
             $accessArray[] = array('allow', 'actions' => $array_action, 'users' => array('@'), 'expression' => 'Yii::app()->user->role_id == ' . $role_menu->role_id);
         }
     }
     $accessArray[] = array('deny');
     return $accessArray;
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = UsersActions::model()->findByPk($id);
     if ($model === null) {
         Yii::log("The requested page does not exist.");
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }