Пример #1
0
 public function beforeAction(ActionEvent $event)
 {
     $controller = $event->action->controller->className();
     $action = $event->action->id;
     if (RoleChecker::isAuth($controller, $action)) {
         return true;
     } else {
         if (Yii::$app->user->isGuest) {
             Yii::$app->user->loginRequired();
         } else {
             if (Module::hasMultiLanguage()) {
                 throw new ForbiddenHttpException(RoleHelper::translate('forbidden'), 403);
             } else {
                 throw new ForbiddenHttpException(Yii::t('role', 'You are not allowed to perform this action.'), 403);
             }
         }
     }
 }
Пример #2
0
        echo Html::checkbox('checkall', false, ['class' => 'ace', 'id' => $id, 'title' => Yii::t('role', 'Toggle all')]);
        ?>
							<?php 
        echo Html::label($actions['name'], $id, ['style' => 'font-weight:bold;', 'class' => 'lbl']);
        ?>
						</div>
						<div class="col-sm-12 checkbox-list">
							<?php 
        foreach ($actions['actions'] as $action => $name) {
            ?>
								<div class="checkbox col-sm-2">
									<?php 
            echo Html::hiddenInput('Role[permissions][' . $controller . '][' . $action . ']', 0);
            ?>
									<?php 
            echo Html::checkbox('Role[permissions][' . $controller . '][' . $action . ']', RoleChecker::isAuth($controller, $action, $model->id), ['class' => 'ace', 'id' => 'Role_permissions_' . str_replace('\\', '_', $controller) . '_' . $action]);
            ?>
									<?php 
            echo Html::label($name, 'Role_permissions_' . str_replace('\\', '_', $controller) . '_' . $action, ['class' => 'lbl']);
            ?>
								</div>
							<?php 
        }
        ?>
						</div>
					</div>
				<?php 
    }
    ?>
			<?php 
}