示例#1
0
 public function getNotChildren()
 {
     $query = AuthItem::find()->where(['not in', 'name', ArrayHelper::getColumn($this->children, 'name')])->andWhere(['<>', 'name', $this->name]);
     if ($this->type == Item::TYPE_PERMISSION) {
         $query->andWhere(['type' => Item::TYPE_PERMISSION]);
     }
     return $query->all();
 }
 public function run()
 {
     if ($this->user) {
         $assignedPermissions = $this->user->assignedRules;
         $defaultPermissions = AuthItem::find()->where(['in', 'name', Yii::$app->authManager->defaultRoles])->all();
         $permissions = array_merge($assignedPermissions, $defaultPermissions);
     } else {
         $permissions = $this->item->children;
     }
     return $this->render('permissionsTreeWidget', ['permissions' => $permissions]);
 }
示例#3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = AuthItem::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params, $this->_formName);
     if ($this->_formName != 'AuthItemSearch') {
         $this->type = $this->_formName == 'RolesSearch' ? Item::TYPE_ROLE : Item::TYPE_PERMISSION;
     }
     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(['type' => $this->type])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
示例#4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getAuthItems()
 {
     return $this->hasMany(AuthItem::className(), ['rule_name' => 'name']);
 }
示例#5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getParent0()
 {
     return $this->hasOne(AuthItem::className(), ['name' => 'parent']);
 }
示例#6
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getItemName()
 {
     return $this->hasOne(AuthItem::className(), ['name' => 'item_name']);
 }
示例#7
0
 public function getNotAssignedRules()
 {
     return AuthItem::find()->where(['not in', 'name', ArrayHelper::getColumn($this->assignedRules, 'name')])->all();
 }