Exemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = AuthGroup::find()->where(['type' => self::TYPE_ROLE, 'level' => self::LEVEL_PERMISSION_GROUP]);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['type' => $this->type, 'level' => $this->level, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'rule_name', $this->rule_name])->andFilterWhere(['like', 'real_title', $this->real_title])->andFilterWhere(['like', 'data', $this->data]);
     return $dataProvider;
 }
Exemplo n.º 2
0
 /**
  * @name 角色分配权限组
  */
 public function actionPermission($id)
 {
     $role = $this->auth->getRole($id);
     $filter = ['type' => AuthGroup::TYPE_ROLE, 'level' => AuthGroup::LEVEL_PERMISSION_GROUP];
     $permissionGroup = AuthGroup::find()->where($filter)->orderBy('real_title asc')->asArray()->all();
     $childs = $this->auth->getChildren($role->name, AuthGroup::TYPE_ROLE, AuthGroup::LEVEL_PERMISSION_GROUP);
     $childrenNames = ArrayHelper::getColumn($childs, 'name');
     foreach ($permissionGroup as $k => &$v) {
         $v['is_sel'] = in_array($v['name'], $childrenNames) ? 1 : 0;
     }
     unset($v);
     return $this->render('permission', ['permission' => $permissionGroup, 'role' => $role]);
 }
Exemplo n.º 3
0
 /**
  * Finds the AuthGroup model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return AuthGroup the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = AuthGroup::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }