Esempio n. 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = RoleMaster::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'role_action_id' => $this->role_action_id, 'user_type_id' => $this->user_type_id]);
     return $dataProvider;
 }
Esempio n. 2
0
 /**
  * @inheritdoc
  */
 static function accessRule($controller = '', $action = '')
 {
     $userid = Yii::$app->user->id;
     $user = User::find()->select('user_type_id')->where(['id' => $userid])->one();
     if ($user->user_type_id == 1) {
         return true;
     }
     $roleAction = RoleAction::find()->where(['action_name' => strtolower($action), 'controller_name' => strtolower($controller)])->one();
     if (!empty($roleAction)) {
         $actionPermission = RoleMaster::find()->where(['role_action_id' => $roleAction->id, 'user_type_id' => $user->user_type_id])->one();
         if (!empty($actionPermission)) {
             return true;
         } else {
             return false;
         }
     } else {
         return true;
     }
 }
Esempio n. 3
0
 public function getTreeModuleView($user_type_id = '')
 {
     $html_tree_view = "";
     $m = 1;
     $c = 1;
     $a = 1;
     $roleModule = RoleAction::find()->select('module_name')->groupBy('module_name')->all();
     if (!empty($roleModule)) {
         $html_tree_view .= '<div class="row">';
         foreach ($roleModule as $key => $module) {
             $module_name = $module->module_name;
             $html_tree_view .= '<div class="col-md-12">';
             $html_tree_view .= '<li id="module_' . $module_name . '">';
             $html_tree_view .= '<input type="checkbox" id="' . $module_name . $m . '" class="module_group" name="RoleMaster[module][]" value="' . $module_name . '"/> ';
             $html_tree_view .= '<label for="' . $module_name . $m . '">' . ucfirst($module_name) . '</label>';
             $roleController = RoleAction::find()->select('controller_name')->where(['module_name' => $module_name])->groupBy('controller_name')->all();
             if (!empty($roleController)) {
                 $html_tree_view .= '<ul>';
                 $html_tree_view .= '<div class="row">';
                 $ca = 1;
                 foreach ($roleController as $key => $controller) {
                     $controller_name = $controller->controller_name;
                     if ($ca == 4) {
                         $ca = 1;
                         $html_tree_view .= '</div><div class="row"><div class="col-md-4">';
                     } else {
                         $html_tree_view .= '<div class="col-md-4">';
                     }
                     $html_tree_view .= '<li>';
                     $html_tree_view .= '<i class="icon-file"></i>';
                     $html_tree_view .= '<input id="' . $controller_name . $m . $c . '" type="checkbox" class="controller_group" ref="main_grp' . $controller_name . '" name="RoleMaster[controller][]" value="' . $controller_name . '"/> ';
                     $html_tree_view .= '<label for="' . $controller_name . $m . $c . '">' . ucfirst($controller_name) . '</label>';
                     $roleAction = RoleAction::find()->select('id,action_name')->where(['controller_name' => $controller_name, 'module_name' => $module_name])->groupBy('action_name')->all();
                     if (!empty($roleAction)) {
                         $html_tree_view .= '<ul>';
                         foreach ($roleAction as $key => $action) {
                             $action_name = $action->action_name;
                             $actionPermission = RoleMaster::find()->where(['role_action_id' => $action->id, 'user_type_id' => $user_type_id])->one();
                             $html_tree_view .= '<li>';
                             $html_tree_view .= '<i class="icon-file"></i>';
                             //if(empty($actionPermission)){echo 1; die;}
                             $action_check = !empty($actionPermission) ? 'checked="checked"' : '';
                             $html_tree_view .= '<input id="' . $action_name . $m . $c . $a . '" type="checkbox" class="action_group" ref="main_grp' . $action_name . '" name="RoleMaster[action][]" value="' . $action->id . '" ' . $action_check . '/> ';
                             $html_tree_view .= '<label for="' . $action_name . $m . $c . $a . '">' . ucfirst($action_name) . '</label>';
                             $html_tree_view .= '</li>';
                             $a++;
                         }
                         $html_tree_view .= '</ul>';
                     }
                     $html_tree_view .= '</li>';
                     $html_tree_view .= '</div>';
                     $c++;
                     $ca++;
                 }
                 $html_tree_view .= '</ul>';
             }
             $html_tree_view .= '</li>';
             $html_tree_view .= '</div>';
             $m++;
         }
     }
     $html_tree_view .= '</div></div>';
     return $html_tree_view;
 }
Esempio n. 4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getRoleMasters()
 {
     return $this->hasMany(RoleMaster::className(), ['role_action_id' => 'id']);
 }
Esempio n. 5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getRoleMasters()
 {
     return $this->hasMany(RoleMaster::className(), ['user_type_id' => 'id']);
 }