Completed
Push — master ( 22896e...75e918 )
by vistart
03:54
created

web/admin/views/user/index.php (3 issues)

Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
/**
4
 *  _   __ __ _____ _____ ___  ____  _____
5
 * | | / // // ___//_  _//   ||  __||_   _|
6
 * | |/ // /(__  )  / / / /| || |     | |
7
 * |___//_//____/  /_/ /_/ |_||_|     |_|
8
 * @link https://vistart.me/
9
 * @copyright Copyright (c) 2016 - 2017 vistart
10
 * @license https://vistart.me/license/
11
 */
12
13
use rhosocial\user\UserProfileView;
14
use rhosocial\user\widgets\UserProfileSearchWidget;
15
use yii\data\ActiveDataProvider;
16
use yii\grid\ActionColumn;
17
use yii\grid\DataColumn;
18
use yii\grid\GridView;
19
use yii\helpers\Html;
20
use yii\helpers\Url;
21
use yii\widgets\Pjax;
22
23
/* @var $this yii\web\View */
24
/* @var $searchModel UserProfileView */
25
/* @var $dataProvider ActiveDataProvider */
26
$this->title = Yii::t('user', 'User List');
27
$this->params['breadcrumbs'][] = $this->title;
28
$formId = 'user-search-form';
29
echo UserProfileSearchWidget::widget([
30
    'model' => $searchModel,
31
    'formId' => $formId,
32
]);
33
Pjax::begin([
34
    'id' => 'user-pjax',
35
    'formSelector' => "#$formId",
36
]);
37
echo empty($dataProvider) ? '' : GridView::widget([
38
    'id' => 'user-grid-view',
39
    'caption' => Yii::t('user', 'Here are all the users who meet the search criteria:'),
40
    'dataProvider' => $dataProvider,
41
    'layout' => "{summary}\n<div class=\"table-responsive\">{items}</div>\n{pager}",
42
    'columns' => [
43
        ['class' => 'yii\grid\SerialColumn'],
44
        /* The GUID is not displayed by default.
45
        'guid' => [
46
            'class' => DataColumn::class,
47
            'header' => Yii::t('user', 'GUID'),
48
            'content' => function ($model, $key, $index, $column) {
49
                return $model->getReadableGUID();
50
            },
51
            'format' => 'text',
52
        ],*/
53
        'id',
54
        'nickname',
55
        'name' => [
56
            'class' => DataColumn::class,
57
            'header' => Yii::t('user', 'Name'),
58
            'content' => function ($model, $key, $index, $column) {
0 ignored issues
show
The parameter $key is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
The parameter $index is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
The parameter $column is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
59
                return $model->last_name . $model->first_name;
60
            }
61
        ],
62
        'createdAt' => [
63
            'class' => DataColumn::class,
64
            'header' => Yii::t('user', 'Creation Time'),
65
            'content' => function ($model, $key, $index, $column) {
66
                /* @var $model User */
67
                return $column->grid->formatter->format($model->created_at, 'datetime');
68
            },
69
        ],
70
        'updatedAt' => [
71
            'class' => DataColumn::class,
72
            'header' => Yii::t('user', 'Last Updated Time'),
73
            'content' => function ($model, $key, $index, $column) {
74
                /* @var $model User */
75
                return $column->grid->formatter->format($model->updated_at, 'datetime');
76
            },
77
        ],
78
        [
79
            'class' => ActionColumn::class,
80
            'header' => Yii::t('user', 'Action'),
81
            'urlCreator' => function (string $action, $model, $key, $index, ActionColumn $column) {
82
                /* @var $model User */
83
                if ($action == 'view') {
84
                    return Url::to(['view', 'id' => $model->id]);
85
                } elseif ($action == 'update') {
86
                    return Url::to(['update', 'id' => $model->id]);
87
                } elseif ($action == 'delete') {
88
                    return Url::to(['deregister', 'id' => $model->id]);
89
                }
90
                return '#';
91
            },
92
            'visibleButtons' => [
93
                'view' => Yii::$app->user->can('viewUser'),
94
                'update' => Yii::$app->user->can('updateUser'),
95
                'delete' => Yii::$app->user->can('deleteUser'),
96
            ],
97
        ],
98
    ],
99
    'tableOptions' => [
100
        'class' => 'table table-striped'
101
    ]
102
]);
103
Pjax::end();
104
?>
105
<div class="well well-sm">
106
    <?= Yii::t('user', 'Directions:') ?>
107
    <ol>
108
        <li><?= Yii::t('user', 'If no search criteria are specified, all users are displayed.') ?></li>
109
        <li><?= Yii::t('user', 'If the creation time is the same as the last update time, there is no change.') ?></li>
110
    </ol>
111
</div>
112
<div class="row">
113
    <div class="col-md-3">
114
        <?= Html::a(Yii::t('user', 'Register New User'), ['register-new-user'], ['class' => 'btn btn-primary']) ?>
115
    </div>
116
</div>
117