Пример #1
0
?>

            <?php 
if ($type == Item::TYPE_ROLE) {
    //角色专用
    ?>
                <div class="page-header">子角色</div>
                <?php 
    echo Html::activeHiddenInput($authChildItemForm, 'child');
    ?>
                <?php 
    echo GridView::widget(['id' => 'childPermissions', 'showFooter' => true, 'dataProvider' => $rolesDataProvider, 'layout' => "<div class=\"grid-view-body table-responsive\">{items}</div>", 'columns' => [['options' => ['width' => 30], 'format' => 'raw', 'value' => function ($data) use($authChildItemForm, $childRoles) {
        return Html::checkbox(Html::getInputName($authChildItemForm, "child[{$data->type}][]"), isset($childRoles[$data->name]), ['value' => $data->name, 'data-key' => 'child-role-checkbox']);
    }], ['attribute' => 'description', 'options' => ['width' => 150], 'label' => $authItemForm->getAttributeLabel('description')], ['attribute' => 'name', 'options' => ['width' => 120], 'label' => $authItemForm->getAttributeLabel('name'), 'format' => 'html', 'value' => function ($data) {
        return Html::a($data->name, ['/admin/rbac/update-role', 'name' => $data->name]);
    }], ['label' => '权限', 'format' => 'raw', 'value' => function ($data) {
        return ListView::widget(['dataProvider' => new ArrayDataProvider(['models' => Yii::$app->getAuthManager()->getPermissionsByRole($data->name)]), 'itemOptions' => ['class' => 'col-sm-3'], 'itemView' => function ($model, $key, $index, $widget) {
            return Html::label(Html::checkbox($model->name, true, ['disabled' => true]) . ' ' . $model->description ?: $model->name);
        }, 'layout' => '<div class="row">{items}</div>']);
    }, 'footer' => '<div id="extendPermissions" class="row"></div>']]]);
    ?>
            <?php 
}
?>

            <div class="page-header">角色基本权限</div>
            <?php 
echo ListView::widget(['dataProvider' => $permissionsDataProvider, 'itemOptions' => ['class' => 'col-sm-3 col-xs-6'], 'itemView' => function ($model, $key, $index, $widget) use($authChildItemForm, $childPermissions) {
    $checkbox = Html::checkbox(Html::getInputName($authChildItemForm, "child[{$model->type}][]"), isset($childPermissions[$model->name]), ['value' => $model->name, 'data-key' => 'child-role-checkbox']);
    return Html::label($checkbox . ' ' . ($model->description ?: $model->name));
}, 'layout' => '<div class="row">{items}</div>']);
Пример #2
0
<?php

use yii\helpers\Html;
use app\modules\admin\widgets\GridView;
$this->title = '角色列表';
$this->params['breadcrumbs'] = [['url' => ['/admin/rbac'], 'label' => '角色与权限'], $this->title];
?>
<div class="box">
    <div class="box-body">
        <?php 
echo GridView::widget(['dataProvider' => $rolesProvider, 'button' => Html::a('添加角色', ['add-role'], ['class' => 'btn btn-primary pull-right']), 'columns' => [['attribute' => 'name', 'label' => $authItemForm->getAttributeLabel('name'), 'format' => 'html', 'value' => function ($data) {
    return Html::a($data->name, ['update-role', 'name' => $data->name]);
}], ['attribute' => 'description', 'label' => $authItemForm->getAttributeLabel('description')], ['attribute' => 'ruleName', 'label' => $authItemForm->getAttributeLabel('ruleName')], ['attribute' => 'data', 'label' => $authItemForm->getAttributeLabel('data')], ['attribute' => 'createdAt', 'label' => $authItemForm->getAttributeLabel('createdAt'), 'format' => ['date', 'Y-m-d H:i:s'], 'options' => ['width' => 140]], ['attribute' => 'updatedAt', 'label' => $authItemForm->getAttributeLabel('updatedAt'), 'format' => ['date', 'Y-m-d H:i:s'], 'options' => ['width' => 140]]]]);
?>
    </div>
</div>
Пример #3
0
<?php

use yii\helpers\Html;
use app\modules\admin\widgets\GridView;
$this->title = '用户管理';
$this->params['breadcrumbs'] = [$this->title];
?>
<div class="box">
    <div class="box-body">
        <?php 
echo GridView::widget(['dataProvider' => $userDataProvider, 'button' => Html::a('添加用户', ['/admin/user/add'], ['class' => 'btn btn-primary pull-right']), 'columns' => [['attribute' => 'id', 'options' => ['width' => 30]], ['attribute' => 'username'], ['attribute' => 'email'], ['attribute' => 'last_login_ip', 'options' => ['width' => 100]], ['attribute' => 'status', 'options' => ['width' => 60]], ['attribute' => 'last_visit_at', 'format' => ['date', 'Y-m-d H:i:s'], 'options' => ['width' => 140]], ['attribute' => 'created_at', 'format' => ['date', 'Y-m-d H:i:s'], 'options' => ['width' => 140]], ['attribute' => 'updated_at', 'format' => ['date', 'Y-m-d H:i:s'], 'options' => ['width' => 140]]]]);
?>
    </div>
</div>