Ejemplo n.º 1
0
 public function getExistsPermissions()
 {
     if (empty($this->existsRulesStorage)) {
         $this->existsRulesStorage = Permission::getByModuleIdentificator($this->getIdentificator());
     }
     return $this->existsRulesStorage;
 }
Ejemplo n.º 2
0
 public function addPermissionsToRole($event)
 {
     $this->owner->revokeAllPermissions();
     foreach ($this->owner->permissions as $permissionName) {
         $permission = Permission::getByName($permissionName);
         if ($permission) {
             $this->owner->addPermission($permission);
         }
     }
 }
Ejemplo n.º 3
0
 public function checkAccess($event)
 {
     $permissionName = Permission::getPermissionNameViaAction($event->action);
     if (\yii::$app->user->getIsGuest() && \Yii::$app->controller->action->id !== 'login') {
         return \Yii::$app->getResponse()->redirect(\Yii::$app->getUser()->loginUrl);
     }
     if (!Permission::isExists($permissionName) || \yii::$app->user->can($permissionName)) {
         return;
     }
     throw new ForbiddenHttpException(\Yii::t('yii', 'You are not allowed to perform this action.'), 403);
 }
Ejemplo n.º 4
0
?>

<div class="user-form">

    <?php 
$form = ActiveForm::begin();
?>
	
    <?php 
echo $form->field($model, 'description')->textInput();
?>
	<?php 
//var_dump($model->getPermitionsForDropdown()); die();
?>
	
	 <?php 
echo $form->field($model, 'permissions')->listBox(Permission::getAllAsAssoc(), ['multiple' => true, 'size' => 50]);
?>
	
    <div class="form-group">
        <?php 
echo Html::submitButton($newRecord ? 'Создать' : 'Обновить', ['class' => $newRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>
	
    <?php 
ActiveForm::end();
?>

</div>
Ejemplo n.º 5
0
 public function addPermission(Permission $permission)
 {
     self::getAuthManager()->addChild($this->getRbacItem(), $permission->getRbacItem());
 }