This commit is contained in:
2020-02-01 16:47:12 +07:00
commit 4c619ad6e6
16739 changed files with 3329179 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
<?php
use yii\helpers\Html;
use yii\web\View;
/* @var $this yii\web\View */
/* @var $assignUrl array */
/* @var $removeUrl array */
/* @var $opts string */
$this->registerJs("var _opts = {$opts};", View::POS_BEGIN);
?>
<div class="row">
<div class="col-lg-5">
<input class="form-control search" data-target="available"
placeholder="<?php echo Yii::t('yii2mod.rbac', 'Search for available'); ?>">
<br/>
<select multiple size="20" class="form-control list" data-target="available"></select>
</div>
<div class="col-lg-2">
<div class="move-buttons">
<br><br>
<?php echo Html::a('&gt;&gt;', $assignUrl, [
'class' => 'btn btn-success btn-assign',
'data-target' => 'available',
'title' => Yii::t('yii2mod.rbac', 'Assign'),
]); ?>
<br/><br/>
<?php echo Html::a('&lt;&lt;', $removeUrl, [
'class' => 'btn btn-danger btn-assign',
'data-target' => 'assigned',
'title' => Yii::t('yii2mod.rbac', 'Remove'),
]); ?>
</div>
</div>
<div class="col-lg-5">
<input class="form-control search" data-target="assigned"
placeholder="<?php echo Yii::t('yii2mod.rbac', 'Search for assigned'); ?>">
<br/>
<select multiple size="20" class="form-control list" data-target="assigned"></select>
</div>
</div>

View File

@@ -0,0 +1,35 @@
<?php
use yii\grid\GridView;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\widgets\Pjax;
/* @var $this \yii\web\View */
/* @var $gridViewColumns array */
/* @var $dataProvider \yii\data\ArrayDataProvider */
/* @var $searchModel \yii2mod\rbac\models\search\AssignmentSearch */
$this->title = Yii::t('yii2mod.rbac', 'Assignments');
$this->params['breadcrumbs'][] = $this->title;
$this->render('/layouts/_sidebar');
?>
<div class="assignment-index">
<h1><?php echo Html::encode($this->title); ?></h1>
<?php Pjax::begin(['timeout' => 5000]); ?>
<?php echo GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => ArrayHelper::merge($gridViewColumns, [
[
'class' => 'yii\grid\ActionColumn',
'template' => '{view}',
],
]),
]); ?>
<?php Pjax::end(); ?>
</div>

View File

@@ -0,0 +1,31 @@
<?php
use yii\helpers\Html;
use yii\helpers\Json;
use yii2mod\rbac\RbacAsset;
RbacAsset::register($this);
/* @var $this yii\web\View */
/* @var $model \yii2mod\rbac\models\AssignmentModel */
/* @var $usernameField string */
$userName = $model->user->{$usernameField};
$this->title = Yii::t('yii2mod.rbac', 'Assignment : {0}', $userName);
$this->params['breadcrumbs'][] = ['label' => Yii::t('yii2mod.rbac', 'Assignments'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $userName;
$this->render('/layouts/_sidebar');
?>
<div class="assignment-index">
<h1><?php echo Html::encode($this->title); ?></h1>
<?php echo $this->render('../_dualListBox', [
'opts' => Json::htmlEncode([
'items' => $model->getItems(),
]),
'assignUrl' => ['assign', 'id' => $model->userId],
'removeUrl' => ['remove', 'id' => $model->userId],
]); ?>
</div>

View File

@@ -0,0 +1,34 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model yii2mod\rbac\models\AuthItemModel */
?>
<div class="auth-item-form">
<?php $form = ActiveForm::begin(); ?>
<?php echo $form->field($model, 'name')->textInput(['maxlength' => 64]); ?>
<?php echo $form->field($model, 'description')->textarea(['rows' => 2]); ?>
<?php echo $form->field($model, 'ruleName')->widget('yii\jui\AutoComplete', [
'options' => [
'class' => 'form-control',
],
'clientOptions' => [
'source' => array_keys(Yii::$app->authManager->getRules()),
],
]);
?>
<?php echo $form->field($model, 'data')->textarea(['rows' => 6]); ?>
<div class="form-group">
<?php echo Html::submitButton($model->getIsNewRecord() ? Yii::t('yii2mod.rbac', 'Create') : Yii::t('yii2mod.rbac', 'Update'), ['class' => $model->getIsNewRecord() ? 'btn btn-success' : 'btn btn-primary']); ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@@ -0,0 +1,19 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model \yii2mod\rbac\models\AuthItemModel */
$labels = $this->context->getLabels();
$this->title = Yii::t('yii2mod.rbac', 'Create ' . $labels['Item']);
$this->params['breadcrumbs'][] = ['label' => Yii::t('yii2mod.rbac', $labels['Items']), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
$this->render('/layouts/_sidebar');
?>
<div class="auth-item-create">
<h1><?php echo Html::encode($this->title); ?></h1>
<?php echo $this->render('_form', [
'model' => $model,
]); ?>
</div>

View File

@@ -0,0 +1,52 @@
<?php
use yii\grid\GridView;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\widgets\Pjax;
/* @var $this yii\web\View */
/* @var $dataProvider \yii\data\ArrayDataProvider */
/* @var $searchModel \yii2mod\rbac\models\search\AuthItemSearch */
$labels = $this->context->getLabels();
$this->title = Yii::t('yii2mod.rbac', $labels['Items']);
$this->params['breadcrumbs'][] = $this->title;
$this->render('/layouts/_sidebar');
?>
<div class="item-index">
<h1><?php echo Html::encode($this->title); ?></h1>
<p>
<?php echo Html::a(Yii::t('yii2mod.rbac', 'Create ' . $labels['Item']), ['create'], ['class' => 'btn btn-success']); ?>
</p>
<?php Pjax::begin(['timeout' => 5000, 'enablePushState' => false]); ?>
<?php echo GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
[
'attribute' => 'name',
'label' => Yii::t('yii2mod.rbac', 'Name'),
],
[
'attribute' => 'ruleName',
'label' => Yii::t('yii2mod.rbac', 'Rule Name'),
'filter' => ArrayHelper::map(Yii::$app->getAuthManager()->getRules(), 'name', 'name'),
'filterInputOptions' => ['class' => 'form-control', 'prompt' => Yii::t('yii2mod.rbac', 'Select Rule')],
],
[
'attribute' => 'description',
'format' => 'ntext',
'label' => Yii::t('yii2mod.rbac', 'Description'),
],
[
'header' => Yii::t('yii2mod.rbac', 'Action'),
'class' => 'yii\grid\ActionColumn',
],
],
]); ?>
<?php Pjax::end(); ?>
</div>

View File

@@ -0,0 +1,21 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model \yii2mod\rbac\models\AuthItemModel */
$context = $this->context;
$labels = $this->context->getLabels();
$this->title = Yii::t('yii2mod.rbac', 'Update ' . $labels['Item'] . ' : {0}', $model->name);
$this->params['breadcrumbs'][] = ['label' => Yii::t('yii2mod.rbac', $labels['Items']), 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->name]];
$this->params['breadcrumbs'][] = Yii::t('yii2mod.rbac', 'Update');
$this->render('/layouts/_sidebar');
?>
<div class="auth-item-update">
<h1><?php echo Html::encode($this->title); ?></h1>
<?php echo $this->render('_form', [
'model' => $model,
]); ?>
</div>

View File

@@ -0,0 +1,50 @@
<?php
use yii\helpers\Html;
use yii\helpers\Json;
use yii\widgets\DetailView;
use yii2mod\rbac\RbacAsset;
RbacAsset::register($this);
/* @var $this yii\web\View */
/* @var $model \yii2mod\rbac\models\AuthItemModel */
$labels = $this->context->getLabels();
$this->title = Yii::t('yii2mod.rbac', $labels['Item'] . ' : {0}', $model->name);
$this->params['breadcrumbs'][] = ['label' => Yii::t('yii2mod.rbac', $labels['Items']), 'url' => ['index']];
$this->params['breadcrumbs'][] = $model->name;
$this->render('/layouts/_sidebar');
?>
<div class="auth-item-view">
<h1><?php echo Html::encode($this->title); ?></h1>
<p>
<?php echo Html::a(Yii::t('yii2mod.rbac', 'Update'), ['update', 'id' => $model->name], ['class' => 'btn btn-primary']); ?>
<?php echo Html::a(Yii::t('yii2mod.rbac', 'Delete'), ['delete', 'id' => $model->name], [
'class' => 'btn btn-danger',
'data-confirm' => Yii::t('yii2mod.rbac', 'Are you sure to delete this item?'),
'data-method' => 'post',
]); ?>
<?php echo Html::a(Yii::t('yii2mod.rbac', 'Create'), ['create'], ['class' => 'btn btn-success']); ?>
</p>
<div class="row">
<div class="col-sm-12">
<?php echo DetailView::widget([
'model' => $model,
'attributes' => [
'name',
'description:ntext',
'ruleName',
'data:ntext',
],
]); ?>
</div>
</div>
<?php echo $this->render('../_dualListBox', [
'opts' => Json::htmlEncode([
'items' => $model->getItems(),
]),
'assignUrl' => ['assign', 'id' => $model->name],
'removeUrl' => ['remove', 'id' => $model->name],
]); ?>
</div>

View File

@@ -0,0 +1,26 @@
<?php
/* @var $this \yii\web\View */
$this->params['sidebar'] = [
[
'label' => Yii::t('yii2mod.rbac', 'Assignments'),
'url' => ['assignment/index'],
],
[
'label' => Yii::t('yii2mod.rbac', 'Roles'),
'url' => ['role/index'],
],
[
'label' => Yii::t('yii2mod.rbac', 'Permissions'),
'url' => ['permission/index'],
],
[
'label' => Yii::t('yii2mod.rbac', 'Routes'),
'url' => ['route/index'],
],
[
'label' => Yii::t('yii2mod.rbac', 'Rules'),
'url' => ['rule/index'],
],
];

View File

@@ -0,0 +1,23 @@
<?php
/**
* @var string the new migration class name
*/
echo "<?php\n";
?>
use yii2mod\rbac\migrations\Migration;
class <?= $className; ?> extends Migration
{
public function safeUp()
{
}
public function safeDown()
{
echo "<?= $className; ?> cannot be reverted.\n";
return false;
}
}

View File

@@ -0,0 +1,27 @@
<?php
use yii\helpers\Html;
use yii\helpers\Json;
use yii2mod\rbac\RbacRouteAsset;
RbacRouteAsset::register($this);
/* @var $this yii\web\View */
/* @var $routes array */
$this->title = Yii::t('yii2mod.rbac', 'Routes');
$this->params['breadcrumbs'][] = $this->title;
$this->render('/layouts/_sidebar');
?>
<h1><?php echo Html::encode($this->title); ?></h1>
<?php echo Html::a(Yii::t('yii2mod.rbac', 'Refresh'), ['refresh'], [
'class' => 'btn btn-primary',
'id' => 'btn-refresh',
]); ?>
<?php echo $this->render('../_dualListBox', [
'opts' => Json::htmlEncode([
'items' => $routes,
]),
'assignUrl' => ['assign'],
'removeUrl' => ['remove'],
]); ?>

View File

@@ -0,0 +1,29 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model \yii2mod\rbac\models\BizRuleModel */
/* @var $form ActiveForm */
?>
<div class="rule-item-form">
<?php $form = ActiveForm::begin(); ?>
<?php echo $form->field($model, 'name')->textInput(['maxlength' => 64]); ?>
<?php echo $form->field($model, 'className')->textInput(); ?>
<div class="form-group">
<?php echo Html::submitButton(
$model->getIsNewRecord() ? Yii::t('yii2mod.rbac', 'Create') : Yii::t('yii2mod.rbac', 'Update'),
[
'class' => $model->getIsNewRecord() ? 'btn btn-success' : 'btn btn-primary',
]
); ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@@ -0,0 +1,21 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model \yii2mod\rbac\models\BizRuleModel */
$this->title = Yii::t('yii2mod.rbac', 'Create Rule');
$this->params['breadcrumbs'][] = ['label' => Yii::t('yii2mod.rbac', 'Rules'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
$this->render('/layouts/_sidebar');
?>
<div class="rule-item-create">
<h1><?php echo Html::encode($this->title); ?></h1>
<?php echo $this->render('_form', [
'model' => $model,
]); ?>
</div>

View File

@@ -0,0 +1,43 @@
<?php
use yii\grid\GridView;
use yii\helpers\Html;
use yii\widgets\Pjax;
/* @var $this yii\web\View */
/* @var $dataProvider \yii\data\ArrayDataProvider */
/* @var $searchModel yii2mod\rbac\models\search\BizRuleSearch */
$this->title = Yii::t('yii2mod.rbac', 'Rules');
$this->params['breadcrumbs'][] = $this->title;
$this->render('/layouts/_sidebar');
?>
<div class="role-index">
<h1><?php echo Html::encode($this->title); ?></h1>
<p>
<?php echo Html::a(Yii::t('yii2mod.rbac', 'Create Rule'), ['create'], ['class' => 'btn btn-success']); ?>
</p>
<?php Pjax::begin(['timeout' => 5000]); ?>
<?php echo GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
[
'attribute' => 'name',
'label' => Yii::t('yii2mod.rbac', 'Name'),
],
[
'header' => Yii::t('yii2mod.rbac', 'Action'),
'class' => 'yii\grid\ActionColumn',
],
],
]);
?>
<?php Pjax::end(); ?>
</div>

View File

@@ -0,0 +1,21 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model \yii2mod\rbac\models\BizRuleModel */
$this->title = Yii::t('yii2mod.rbac', 'Update Rule : {0}', $model->name);
$this->params['breadcrumbs'][] = ['label' => Yii::t('yii2mod.rbac', 'Rules'), 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->name]];
$this->params['breadcrumbs'][] = Yii::t('yii2mod.rbac', 'Update');
$this->render('/layouts/_sidebar');
?>
<div class="rule-item-update">
<h1><?php echo Html::encode($this->title); ?></h1>
<?php echo $this->render('_form', [
'model' => $model,
]); ?>
</div>

View File

@@ -0,0 +1,35 @@
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model \yii2mod\rbac\models\BizRuleModel */
$this->title = Yii::t('yii2mod.rbac', 'Rule : {0}', $model->name);
$this->params['breadcrumbs'][] = ['label' => Yii::t('yii2mod.rbac', 'Rules'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $model->name;
$this->render('/layouts/_sidebar');
?>
<div class="rule-item-view">
<h1><?php echo Html::encode($this->title); ?></h1>
<p>
<?php echo Html::a(Yii::t('yii2mod.rbac', 'Update'), ['update', 'id' => $model->name], ['class' => 'btn btn-primary']); ?>
<?php echo Html::a(Yii::t('yii2mod.rbac', 'Delete'), ['delete', 'id' => $model->name], [
'class' => 'btn btn-danger',
'data-confirm' => Yii::t('yii2mod.rbac', 'Are you sure to delete this item?'),
'data-method' => 'post',
]); ?>
</p>
<?php echo DetailView::widget([
'model' => $model,
'attributes' => [
'name',
'className',
],
]); ?>
</div>