예제 #1
0
 /**
  * Родительская роль или допуск
  * @return \yii\db\ActiveQuery
  */
 public function getParent0()
 {
     return $this->hasOne(AuthItem::className(), ['name' => 'parent']);
 }
예제 #2
0
파일: index.php 프로젝트: lowbase/yii2-user
$assets = UserAsset::register($this);
?>
<div class="auth-item-index">

    <?php 
$gridColumns = [['class' => 'kartik\\grid\\SerialColumn', 'contentOptions' => ['class' => 'kartik-sheet-style'], 'width' => '30px', 'header' => '', 'headerOptions' => ['class' => 'kartik-sheet-style']], 'name', ['attribute' => 'type', 'vAlign' => 'middle', 'format' => 'raw', 'value' => function ($model) {
    switch ($model->type) {
        case 1:
            return '<span class="label label-primary">' . AuthItem::getTypes()[$model->type] . '</span>';
            break;
        case 2:
            return '<span class="label label-success">' . AuthItem::getTypes()[$model->type] . '</span>';
            break;
    }
    return false;
}, 'filter' => AuthItem::getTypes()], 'description:ntext', 'rule_name', 'data:ntext', ['template' => '{view} {update} {delete}', 'class' => 'kartik\\grid\\ActionColumn'], ['class' => 'kartik\\grid\\CheckboxColumn', 'headerOptions' => ['class' => 'kartik-sheet-style']]];
echo GridView::widget(['layout' => "{items}\n{summary}\n{pager}", 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => $gridColumns, 'containerOptions' => ['style' => 'overflow: auto'], 'headerRowOptions' => ['class' => 'kartik-sheet-style'], 'filterRowOptions' => ['class' => 'kartik-sheet-style'], 'pjax' => false, 'panel' => ['heading' => '<i class="glyphicon glyphicon-eye-close"></i> ' . Yii::t('user', 'Роли и допуски'), 'type' => GridView::TYPE_PRIMARY, 'before' => Html::a('<span class="glyphicon glyphicon-plus"></span> ' . Yii::t('user', 'Добавить'), ['auth-item/create'], ['class' => 'btn btn-success']), 'after' => "<div class='text-right'><b>" . Yii::t('user', 'Выбранные') . ":</b> " . Html::button('<span class="glyphicon glyphicon-trash"></span> ' . Yii::t('user', 'Удалить'), ['class' => 'btn btn-danger delete-all']) . "</div>"], 'export' => ['fontAwesome' => true], 'bordered' => true, 'striped' => true, 'condensed' => true, 'persistResize' => false, 'hover' => true, 'responsive' => true]);
?>

</div>

<?php 
$this->registerJs('
        $(".delete-all").click(function(){
        var keys = $(".grid-view").yiiGridView("getSelectedRows");
        $.ajax({
            url: "' . Url::to(['auth-item/multidelete']) . '",
            type:"POST",
            data:{keys: keys},
            success: function(data){
                location.reload();
예제 #3
0
파일: _form.php 프로젝트: lowbase/yii2-user
        <div class="col-lg-6">
            <?php 
echo $form->field($model, 'rule_name')->widget(Select2::classname(), ['data' => AuthRule::getAll(), 'options' => ['placeholder' => ''], 'pluginOptions' => ['allowClear' => true]]);
?>
        </div>
        <div class="col-lg-6">
        </div>
    </div>

    <div class="row">
        <div class="col-lg-6">
            <?php 
echo '<label class="control-label">' . Yii::t('user', 'Обладает допусками') . '</label>';
?>
            <?php 
echo Select2::widget(['name' => 'AuthItem[children_array]', 'value' => array_keys($model->children_array), 'data' => AuthItem::getAll(), 'options' => ['multiple' => true], 'pluginOptions' => ['tags' => true]]);
?>
        </div>
        <div class="col-lg-6">
            <?php 
echo '<label class="control-label">' . Yii::t('user', 'Обладают пользователи') . '</label>';
?>
            <?php 
echo Select2::widget(['name' => 'AuthItem[user_array]', 'value' => array_keys($model->user_array), 'data' => User::getAll(), 'options' => ['multiple' => true], 'pluginOptions' => ['tags' => true]]);
?>
        </div>
    </div>


    <?php 
ActiveForm::end();
예제 #4
0
 /**
  * Дочерние роли или допуски
  * @return \yii\db\ActiveQuery
  */
 public function getChildren()
 {
     return $this->hasMany(AuthItem::className(), ['name' => 'child'])->viaTable('lb_auth_item_child', ['parent' => 'name']);
 }
예제 #5
0
 /**
  * Допуски, имеющие текущее правило
  * @return \yii\db\ActiveQuery
  */
 public function getAuthItems()
 {
     return $this->hasMany(AuthItem::className(), ['rule_name' => 'name']);
 }
예제 #6
0
 /**
  * Поиск модели (роль / допуск) по ID
  * @param string $id
  * @return AuthItem the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = AuthItem::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException(Yii::t('user', 'Запрашиваемая страница не найдена.'));
     }
 }
예제 #7
0
 /**
  * Роль или допуск
  * @return \yii\db\ActiveQuery
  */
 public function getItemName()
 {
     return $this->hasOne(AuthItem::className(), ['name' => 'item_name']);
 }
예제 #8
0
파일: User.php 프로젝트: lowbase/yii2-user
 /**
  * Роли и допуски (разрешения)
  * @return \yii\db\ActiveQuery
  */
 public function getItemNames()
 {
     return $this->hasMany(AuthItem::className(), ['name' => 'item_name'])->viaTable('lb_auth_assignment', ['user_id' => 'id']);
 }