123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 |
- <?php
- /*
- * This file is part of the Dektrium project.
- *
- * (c) Dektrium project <http://github.com/dektrium>
- *
- * For the full copyright and license information, please view the LICENSE.md
- * file that was distributed with this source code.
- */
- use yii\grid\GridView;
- use yii\helpers\Html;
- use yii\helpers\Url;
- use yii\web\View;
- use yii\widgets\Pjax;
- use dektrium\user\models\Profile;
- use dektrium\user\models\User;
- /**
- * @var \yii\web\View $this
- * @var \yii\data\ActiveDataProvider $dataProvider
- * @var \dektrium\user\models\UserSearch $searchModel
- */
- $this->title = Yii::t('user', 'Manage users');
- $this->params['breadcrumbs'][] = $this->title;
- ?>
- <?= $this->render('/_alert', ['module' => Yii::$app->getModule('user')]) ?>
- <?= $this->render('/admin/_menu') ?>
- <?php Pjax::begin() ?>
- <?
- ?>
- <?= GridView::widget([
- 'dataProvider' => $dataProvider,
- 'filterModel' => $searchModel,
- 'layout' => "{items}\n{pager}",
- 'columns' => [
- [
- 'attribute' => 'id',
- 'headerOptions' => ['style' => 'width:90px;'], # 90px is sufficient for 5-digit user ids
- ],
- [
- 'attribute' => 'Фото',
- 'value' => function ($model) {
- if( file_exists(Yii::getAlias('@webroot').'/images/users/'.$model->id.'_sm.jpg') ){
- $s = Html::img('/images/users/'.$model->id.'_sm.jpg',['class' => "direct-chat-img"]);
- }else{
- $s = '';
- }
- return $s;
- },
- 'format' => 'html',
- ],
- 'username',
- [
- 'attribute' => 'Name',
- 'value' => function ($model) {
- $s='';
- //Yii::$app->profile->get($model->id);
- $profile = Profile::findOne($model->id);
- return $profile->name;
- },
- 'format' => 'html',
- ],
- 'email:email',
- [
- 'attribute' => 'registration_ip',
- 'value' => function ($model) {
- return $model->registration_ip == null
- ? '<span class="not-set">' . Yii::t('user', '(not set)') . '</span>'
- : $model->registration_ip;
- },
- 'format' => 'html',
- ],
- [
- 'attribute' => 'Роли',
- 'value' => function ($model) {
- $s='';
- foreach(Yii::$app->authManager->getRolesByUser($model->id) as $role=>$set){
- $s .= $set->name.' ';
- }
- return $s;
- },
- 'format' => 'html',
- ],
- [
- 'attribute' => 'created_at',
- 'value' => function ($model) {
- if (extension_loaded('intl')) {
- return Yii::t('user', '{0, date, MMMM dd, YYYY HH:mm}', [$model->created_at]);
- } else {
- return date('Y-m-d G:i:s', $model->created_at);
- }
- },
- ],
- [
- 'attribute' => 'last_login_at',
- 'value' => function ($model) {
- if (!$model->last_login_at || $model->last_login_at == 0) {
- return Yii::t('user', 'Never');
- } else if (extension_loaded('intl')) {
- return Yii::t('user', '{0, date, MMMM dd, YYYY HH:mm}', [$model->last_login_at]);
- } else {
- return date('Y-m-d G:i:s', $model->last_login_at);
- }
- },
- ],
- [
- 'header' => Yii::t('user', 'Confirmation'),
- 'value' => function ($model) {
- if ($model->isConfirmed) {
- return '<div class="text-center">
- <span class="text-success">' . Yii::t('user', 'Confirmed') . '</span>
- </div>';
- } else {
- return Html::a(Yii::t('user', 'Confirm'), ['confirm', 'id' => $model->id], [
- 'class' => 'btn btn-xs btn-success btn-block',
- 'data-method' => 'post',
- 'data-confirm' => Yii::t('user', 'Are you sure you want to confirm this user?'),
- ]);
- }
- },
- 'format' => 'raw',
- 'visible' => Yii::$app->getModule('user')->enableConfirmation,
- ],
- [
- 'header' => Yii::t('user', 'Block status'),
- 'value' => function ($model) {
- if ($model->isBlocked) {
- return Html::a(Yii::t('user', 'Unblock'), ['block', 'id' => $model->id], [
- 'class' => 'btn btn-xs btn-success btn-block',
- 'data-method' => 'post',
- 'data-confirm' => Yii::t('user', 'Are you sure you want to unblock this user?'),
- ]);
- } else {
- return Html::a(Yii::t('user', 'Block'), ['block', 'id' => $model->id], [
- 'class' => 'btn btn-xs btn-danger btn-block',
- 'data-method' => 'post',
- 'data-confirm' => Yii::t('user', 'Are you sure you want to block this user?'),
- ]);
- }
- },
- 'format' => 'raw',
- ],
- [
- 'class' => 'yii\grid\ActionColumn',
- 'template' => '{switch} {resend_password} {update} {avatar} {delete}',
- 'buttons' => [
- 'resend_password' => function ($url, $model, $key) {
- if (\Yii::$app->user->identity->isAdmin && !$model->isAdmin) {
- return '
- <a data-method="POST" data-confirm="' . Yii::t('user', 'Are you sure?') . '" href="' . Url::to(['resend-password', 'id' => $model->id]) . '">
- <span title="' . Yii::t('user', 'Generate and send new password to user') . '" class="glyphicon glyphicon-envelope">
- </span> </a>';
- }
- },
- 'switch' => function ($url, $model) {
- if(\Yii::$app->user->identity->isAdmin && $model->id != Yii::$app->user->id && Yii::$app->getModule('user')->enableImpersonateUser) {
- return Html::a('<span class="glyphicon glyphicon-user"></span>', ['/user/admin/switch', 'id' => $model->id], [
- 'title' => Yii::t('user', 'Become this user'),
- 'data-confirm' => Yii::t('user', 'Are you sure you want to switch to this user for the rest of this Session?'),
- 'data-method' => 'POST',
- ]);
- }
- },
- 'avatar' => function ($url, $model) {
- if(\Yii::$app->user->identity->isAdmin && Yii::$app->getModule('user')->enableImpersonateUser) {
- return Html::a('<span class="glyphicon glyphicon-picture"></span>', ['/manager/userex', 'id' => $model->id], [
- 'title' => Yii::t('user', 'Avatar this user')
- ]);
- }
- }
- ]
- ],
- ],
- ]); ?>
- <?php Pjax::end() ?>
|