/** * @return \yii\db\ActiveRecord */ public function getItemName() { return $this->hasOne(AuthItem::className(), ['name' => 'item_name']); }
/** * @return array */ public function getRolesItemsValues() { /** @var ActiveQuery $query */ $query = AuthItem::find()->asArray()->where(['type' => [Item::TYPE_ROLE]]); return ArrayHelper::map($query->all(), 'name', 'description'); }
public function actionDeletePermissions() { AuthItem::deleteAll('type in (:permissions)', [':permissions' => Item::TYPE_PERMISSION]); Yii::$app->session->setFlash(Yz::FLASH_SUCCESS, Yii::t('admin/t', 'Permissions were successfully deleted')); $this->redirect(['index']); }
public function afterSave($insert, $changedAttributes) { parent::afterSave($insert, $changedAttributes); if ($this->_childPermissions !== null || $this->_childRoles !== null) { if ($this->_childPermissions === null) { $this->getChildPermissions(); } if ($this->_childRoles === null) { $this->getChildRoles(); } $this->getAuthManager()->removeChildren($this->getAuthItem()); foreach ($this->_childPermissions as $name) { $permission = $this->getAuthManager()->getPermission($name); $this->getAuthManager()->addChild($this->getAuthItem(), $permission); } foreach ($this->_childRoles as $name) { $role = $this->getAuthManager()->getRole($name); $this->getAuthManager()->addChild($this->getAuthItem(), $role); } } }
/** * @return \yii\db\ActiveQuery */ public function getAdminAuthItems() { return $this->hasMany(AuthItem::className(), ['rule_name' => 'name']); }
/** * @return \yii\db\ActiveQueryInterface */ public function getParentRecord() { return $this->hasOne(AuthItem::className(), ['name' => 'parent']); }