Issues (1256)

views/admin/users/index.php (7 issues)

1
<?php
2
3
use yii\grid\GridView;
4
use yii\helpers\{Html, Url};
5
use Itstructure\RbacModule\interfaces\RbacIdentityInterface;
6
7
/* @var $this yii\web\View */
8
/* @var $dataProvider yii\data\ActiveDataProvider */
9
/* @var $searchModel app\models\UserSearch */
10
/* @var $administrateAccess bool */
11
12
$this->title = Yii::t('users', 'Users');
13
$this->params['breadcrumbs'][] = $this->title;
14
?>
15
<div class="users-index">
16
17
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>
18
19
    <p>
20
        <?php echo Html::a(Yii::t('users', 'Create user'), [
21
            $this->params['urlPrefix'].'create'
22
        ], [
23
            'class' => 'btn btn-success'
24
        ]) ?>
25
    </p>
26
27
    <?php echo GridView::widget([
28
        'dataProvider' => $dataProvider,
29
        //'filterModel' => $searchModel,
30
        'columns' => [
31
            'id' => [
32
                'label' => Yii::t('app', 'ID'),
33
                'value' => function($searchModel) {
34
                    return Html::a(
35
                        Html::encode($searchModel->id),
36
                        Url::to([
37
                            $this->params['urlPrefix'].'view',
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $this seems to be never defined.
Loading history...
38
                            'id' => $searchModel->id
39
                        ])
40
                    );
41
                },
42
                'format' => 'raw',
43
            ],
44
            'avatar' => [
45
                'label' => Yii::t('users', 'Avatar'),
46
                'value' => function ($searchModel) {
47
                    /* @var $searchModel \app\models\UserSearch */
48
                    $thumbnailModel = $searchModel->getThumbnailModel();
49
                    return $thumbnailModel == null ? '' : Html::a(Html::img($searchModel->getAvatar(), [
50
                            'width' => 75,
51
                            'height' => 75,
52
                        ]), Url::to([
53
                            $this->params['urlPrefix'].'view',
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $this seems to be never defined.
Loading history...
54
                            'id' => $searchModel->id
55
                        ])
56
                    );
57
                },
58
                'format' => 'raw',
59
            ],
60
            'first_name' => [
61
                'label' => Yii::t('users', 'First Name'),
62
                'value' => function($searchModel) {
63
                    return Html::a(
64
                        Html::encode($searchModel->first_name),
65
                        Url::to([
66
                            $this->params['urlPrefix'].'view',
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $this seems to be never defined.
Loading history...
67
                            'id' => $searchModel->id
68
                        ])
69
                    );
70
                },
71
                'format' => 'raw',
72
            ],
73
            'last_name' => [
74
                'label' => Yii::t('users', 'Last Name'),
75
                'value' => function($searchModel) {
76
                    return Html::a(
77
                        Html::encode($searchModel->last_name),
78
                        Url::to([
79
                            $this->params['urlPrefix'].'view',
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $this seems to be never defined.
Loading history...
80
                            'id' => $searchModel->id
81
                        ])
82
                    );
83
                },
84
                'format' => 'raw',
85
            ],
86
            'status' => [
87
                'label' => Yii::t('users', 'Status'),
88
                'value' => function($searchModel) {
89
                    if (!isset($searchModel->status) || empty($searchModel->status)) {
90
                        return '<i class="fa fa-minus-circle text-warning"> ' . Yii::t('users', 'No status');
91
                    }
92
                    if ($searchModel->status == 1){
93
                        return '<i class="fa fa-check-circle text-success"> ' . Yii::t('app', 'Active') . '</i>';
94
                    } else {
95
                        return '<i class="fa fa-times text-danger"> ' . Yii::t('app', 'Blocked') . '</i>';
96
                    }
97
                },
98
                'format' => 'raw',
99
            ],
100
            'public' => [
101
                'label' => Yii::t('users', 'Publicity'),
102
                'value' => function($searchModel) {
103
                    if (!isset($searchModel->public) || empty($searchModel->public)) {
104
                        return '<i class="fa fa-minus-circle text-warning"> ' . Yii::t('app', 'Private');
105
                    }
106
                    if ($searchModel->public == 1){
107
                        return '<i class="fa fa-folder-open-o text-primary"> ' . Yii::t('app', 'Public') . '</i>';
108
                    } else {
109
                        return '<i class="fa fa-minus-circle text-warning"> ' . Yii::t('app', 'Private') . '</i>';
110
                    }
111
                },
112
                'format' => 'raw',
113
            ],
114
            'email' => [
115
                'label' =>  Yii::t('users', 'Email'),
116
                'value' => function ($model) {
117
                    return '<a href="mailto:'.$model->email.'">'.$model->email.'</a>';
118
                },
119
                'format' => 'raw',
120
            ],
121
            'roles' => [
122
                'label' => Yii::t('users', 'Roles'),
123
                'value' => function($searchModel) {
124
                    /* @var $searchModel RbacIdentityInterface */
125
                    $roles = $searchModel->getRoles();
126
127
                    if (empty($roles)) {return Yii::t('users', 'No roles');}
128
129
                    return implode('<br>', array_map(function ($data) {
130
131
                        return Html::a($data, Url::to([
132
                            '/rbac/roles/view',
133
                            'id' => $data
134
                        ]),
135
                            [
136
                                'target' => '_blank'
137
                            ]);
138
139
                    }, array_keys($roles)));
140
                },
141
                'format' => 'raw',
142
            ],
143
            'position' => [
144
                'attribute' => 'position',
145
                'label' =>  Yii::t('users', 'Position'),
146
                'value' => function ($searchModel) {
147
                    /* @var $searchModel \app\models\UserSearch */
148
                    return empty($searchModel->position) ? '' : $searchModel->position->name;
149
                }
150
            ],
151
            'sort' => [
152
                'label' => Yii::t('users', 'Order'),
153
                'value' => function($searchModel) {
154
                    return
155
                        Html::tag('div',
156
                            $searchModel->order > $searchModel->minOrder ?
157
                                Html::a(Html::tag('i', '', ['class' => 'fa fa-sort-asc fa-lg', 'aria-hidden' => true]),
158
                                    Url::to(['/admin/users', 'id' => $searchModel->id, 'order' => $searchModel->order - 1])
159
                                ) : ''
160
                            ,
161
                            [
162
                                'style' => 'clear:both;'
163
                            ]
164
                        )
165
                        .
166
                        Html::tag('div',
167
                            $searchModel->order < $searchModel->maxOrder ?
168
                                Html::a(Html::tag('i', '', ['class' => 'fa fa-sort-desc fa-lg', 'aria-hidden' => true]),
169
                                    Url::to(['/admin/users', 'id' => $searchModel->id, 'order' => $searchModel->order + 1])
170
                                ) : ''
171
                            ,
172
                            [
173
                                'style' => 'clear:both;'
174
                            ]
175
                        )
176
                        .
177
                        ($searchModel->minOrder == $searchModel->maxOrder ?
178
                            '-' : ''
179
                        );
180
                },
181
                'format' => 'raw',
182
                'visible' => $administrateAccess
183
            ],
184
            'created_at' => [
185
                'attribute' => 'created_at',
186
                'label' => Yii::t('app', 'Created date'),
187
                'format' =>  ['date', 'dd.MM.YY HH:mm:ss'],
188
            ],
189
            'updated_at' => [
190
                'attribute' => 'updated_at',
191
                'label' => Yii::t('app', 'Updated date'),
192
                'format' =>  ['date', 'dd.MM.Y HH:mm:ss'],
193
            ],
194
            'ActionColumn' => [
195
                'class' => 'yii\grid\ActionColumn',
196
                'header' => Yii::t('app', 'Actions'),
197
                'template' => '{view} {update} {delete}',
198
                'urlCreator'=>function($action, $model, $key, $index){
0 ignored issues
show
The parameter $key is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

198
                'urlCreator'=>function($action, $model, /** @scrutinizer ignore-unused */ $key, $index){

This check looks for 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. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

198
                'urlCreator'=>function($action, $model, $key, /** @scrutinizer ignore-unused */ $index){

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

Loading history...
199
                    return Url::to([
200
                        $this->params['urlPrefix'].$action,
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $this seems to be never defined.
Loading history...
201
                        'id' => $model->id
202
                    ]);
203
                }
204
            ],
205
        ]
206
    ]); ?>
207
</div>
208