Пример #1
0
 /**
  * @return \yii\db\ActiveRecord
  */
 public function getItemName()
 {
     return $this->hasOne(AuthItem::className(), ['name' => 'item_name']);
 }
Пример #2
0
 /**
  * @return array
  */
 public function getRolesItemsValues()
 {
     /** @var ActiveQuery $query */
     $query = AuthItem::find()->asArray()->where(['type' => [Item::TYPE_ROLE]]);
     return ArrayHelper::map($query->all(), 'name', 'description');
 }
Пример #3
0
 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']);
 }
Пример #4
0
 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);
         }
     }
 }
Пример #5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getAdminAuthItems()
 {
     return $this->hasMany(AuthItem::className(), ['rule_name' => 'name']);
 }
Пример #6
0
 /**
  * @return \yii\db\ActiveQueryInterface
  */
 public function getParentRecord()
 {
     return $this->hasOne(AuthItem::className(), ['name' => 'parent']);
 }