added RBAC

This commit is contained in:
Antonio Ramirez
2016-12-14 02:26:02 +01:00
parent 9409da4c89
commit 9f1a60b542
43 changed files with 1625 additions and 245 deletions

View File

@ -0,0 +1,41 @@
<?php
/**
* @var $this yii\web\View
* @var $model \Da\User\Model\Role
*/
use Da\User\Helper\AuthHelper;
use kartik\select2\Select2;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
$unassignedItems = Yii::$container->get(AuthHelper::class)->getUnassignedItems($model);
?>
<?php $form = ActiveForm::begin(
[
'enableClientValidation' => false,
'enableAjaxValidation' => true,
]
) ?>
<?= $form->field($model, 'name') ?>
<?= $form->field($model, 'description') ?>
<?= $form->field($model, 'rule') ?>
<?= $form->field($model, 'children')->widget(
Select2::className(),
[
'data' => $unassignedItems,
'options' => [
'id' => 'children',
'multiple' => true
],
]
) ?>
<?= Html::submitButton(Yii::t('user', 'Save'), ['class' => 'btn btn-success btn-block']) ?>
<?php ActiveForm::end() ?>

View File

@ -0,0 +1,24 @@
<?php
/**
* @var $model \Da\User\Model\Role
* @var $this yii\web\View
* @var $unassignedItems string[]
*/
$this->title = Yii::t('user', 'Create new role');
$this->params['breadcrumbs'][] = $this->title;
?>
<?php $this->beginContent('@Da/User/resources/views/shared/admin_layout.php') ?>
<?= $this->render(
'_form',
[
'model' => $model,
'unassignedItems' => $unassignedItems
]
) ?>
<?php $this->endContent() ?>

View File

@ -0,0 +1,61 @@
<?php
use yii\grid\ActionColumn;
use yii\grid\GridView;
use yii\helpers\Url;
/**
* @var $dataProvider array
* @var $searchModel \Da\User\Search\RoleSearch
* @var $this yii\web\View
*/
$this->title = Yii::t('user', 'Roles');
$this->params['breadcrumbs'][] = $this->title;
?>
<?php $this->beginContent('@Da/User/resources/views/shared/admin_layout.php') ?>
<?= GridView::widget(
[
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'layout' => "{items}\n{pager}",
'columns' => [
[
'attribute' => 'name',
'header' => Yii::t('user', 'Name'),
'options' => [
'style' => 'width: 20%'
],
],
[
'attribute' => 'description',
'header' => Yii::t('user', 'Description'),
'options' => [
'style' => 'width: 55%'
],
],
[
'attribute' => 'rule_name',
'header' => Yii::t('user', 'Rule name'),
'options' => [
'style' => 'width: 20%'
],
],
[
'class' => ActionColumn::className(),
'template' => '{update} {delete}',
'urlCreator' => function ($action, $model) {
return Url::to(['/user/role/' . $action, 'name' => $model['name']]);
},
'options' => [
'style' => 'width: 5%'
],
]
],
]
) ?>
<?php $this->endContent() ?>

View File

@ -0,0 +1,24 @@
<?php
/**
* @var $model \Da\User\Model\Role
* @var $this yii\web\View
* @var $unassignedItems string[]
*/
$this->title = Yii::t('user', 'Update role');
$this->params['breadcrumbs'][] = $this->title;
?>
<?php $this->beginContent('@Da/User/resources/views/shared/admin_layout.php') ?>
<?= $this->render(
'_form',
[
'model' => $model,
'unassignedItems' => $unassignedItems
]
) ?>
<?php $this->endContent() ?>