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]); }
/** * 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; }
/** * @return \yii\db\ActiveQuery */ public function getAuthItems() { return $this->hasMany(AuthItem::className(), ['rule_name' => 'name']); }
/** * @return \yii\db\ActiveQuery */ public function getParent0() { return $this->hasOne(AuthItem::className(), ['name' => 'parent']); }
/** * @return \yii\db\ActiveQuery */ public function getItemName() { return $this->hasOne(AuthItem::className(), ['name' => 'item_name']); }
public function getNotAssignedRules() { return AuthItem::find()->where(['not in', 'name', ArrayHelper::getColumn($this->assignedRules, 'name')])->all(); }