Completed
Push — master ( 008d1c...59e294 )
by vistart
03:42
created

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

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 yii\data\ActiveDataProvider;
15
use yii\grid\ActionColumn;
16
use yii\grid\DataColumn;
17
use yii\grid\GridView;
18
use yii\helpers\Html;
19
use yii\helpers\Url;
20
use yii\widgets\Pjax;
21
22
/* @var $this yii\web\View */
23
/* @var $searchModel UserProfileView */
24
/* @var $dataProvider ActiveDataProvider */
25
$this->title = Yii::t('user', 'User List');
26
$this->params['breadcrumbs'][] = $this->title;
27
$formId = 'user-search-form';
28
Pjax::begin([
29
    'id' => 'user-pjax',
30
    'formSelector' => "#$formId",
31
]);
32
echo $this->render('_search', ['model' => $searchModel, 'formId' => $formId]);
33
echo empty($dataProvider) ? '' : GridView::widget([
34
    'dataProvider' => $dataProvider,
35
    'columns' => [
36
        ['class' => 'yii\grid\SerialColumn'],
37
        /* The GUID is not displayed by default.
38
        'guid' => [
39
            'class' => DataColumn::class,
40
            'header' => Yii::t('user', 'GUID'),
41
            'content' => function ($model, $key, $index, $column) {
42
                return $model->getReadableGUID();
43
            },
44
            'format' => 'text',
45
        ],*/
46
        'id',
47
        'nickname',
48
        'name' => [
49
            'class' => DataColumn::class,
50
            'header' => Yii::t('user', 'Name'),
51
            '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...
52
                return $model->last_name . $model->first_name;
53
            }
54
        ],
55
        'createdAt' => [
56
            'class' => DataColumn::class,
57
            'header' => Yii::t('user', 'Creation Time'),
58
            'content' => function ($model, $key, $index, $column) {
59
                /* @var $model User */
60
                return $column->grid->formatter->format($model->created_at, 'datetime');
0 ignored issues
show
The property created_at does not exist on object<rhosocial\user\User>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
61
            },
62
        ],
63
        'updatedAt' => [
64
            'class' => DataColumn::class,
65
            'header' => Yii::t('user', 'Last Updated Time'),
66
            'content' => function ($model, $key, $index, $column) {
67
                /* @var $model User */
68
                return $column->grid->formatter->format($model->updated_at, 'datetime');
0 ignored issues
show
The property updated_at does not exist on object<rhosocial\user\User>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
69
            },
70
        ],
71
        [
72
            'class' => ActionColumn::class,
73
            'header' => Yii::t('user', 'Action'),
74
            'urlCreator' => function (string $action, $model, $key, $index, ActionColumn $column) {
75
                /* @var $model User */
76
                if ($action == 'view') {
77
                    return Url::to(['view', 'id' => $model->id]);
78
                } elseif ($action == 'update') {
79
                    return Url::to(['update', 'id' => $model->id]);
80
                } elseif ($action == 'delete') {
81
                    return Url::to(['deregister', 'id' => $model->id]);
82
                }
83
                return '#';
84
            },
85
            'visibleButtons' => [
86
                'view' => Yii::$app->user->can('viewUser'),
87
                'update' => Yii::$app->user->can('updateUser'),
88
                'delete' => Yii::$app->user->can('deleteUser'),
89
            ],
90
        ],
91
    ],
92
]);
93
Pjax::end();
94
?>
95
<div class="row">
96
    <div class="col-md-3">
97
        <?= Html::a(Yii::t('user', 'Register New User'), ['register-new-user'], ['class' => 'btn btn-primary']) ?>
98
    </div>
99
</div>
100