index.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <?php
  2. /*
  3. * This file is part of the Dektrium project.
  4. *
  5. * (c) Dektrium project <http://github.com/dektrium>
  6. *
  7. * For the full copyright and license information, please view the LICENSE.md
  8. * file that was distributed with this source code.
  9. */
  10. use yii\grid\GridView;
  11. use yii\helpers\Html;
  12. use yii\helpers\Url;
  13. use yii\web\View;
  14. use yii\widgets\Pjax;
  15. /**
  16. * @var \yii\web\View $this
  17. * @var \yii\data\ActiveDataProvider $dataProvider
  18. * @var \dektrium\user\models\UserSearch $searchModel
  19. */
  20. $this->title = Yii::t('user', 'Manage users');
  21. $this->params['breadcrumbs'][] = $this->title;
  22. ?>
  23. <?= $this->render('/_alert', ['module' => Yii::$app->getModule('user')]) ?>
  24. <?= $this->render('/admin/_menu') ?>
  25. <?php Pjax::begin() ?>
  26. <?= GridView::widget([
  27. 'dataProvider' => $dataProvider,
  28. 'filterModel' => $searchModel,
  29. 'layout' => "{items}\n{pager}",
  30. 'columns' => [
  31. /*[
  32. 'attribute' => 'id',
  33. 'headerOptions' => ['style' => 'width:90px;'], # 90px is sufficient for 5-digit user ids
  34. ],*/
  35. 'uuid',
  36. 'fio',
  37. 'cname',
  38. 'phone',
  39. 'email:email',
  40. /*[
  41. 'attribute' => 'registration_ip',
  42. 'value' => function ($model) {
  43. return $model->registration_ip == null
  44. ? '<span class="not-set">' . Yii::t('user', '(not set)') . '</span>'
  45. : $model->registration_ip;
  46. },
  47. 'format' => 'html',
  48. ],*/
  49. /*[
  50. 'attribute' => 'created_at',
  51. 'value' => function ($model) {
  52. if (extension_loaded('intl')) {
  53. return Yii::t('user', '{0, date, MMMM dd, YYYY HH:mm}', [$model->created_at]);
  54. } else {
  55. return date('Y-m-d G:i:s', $model->created_at);
  56. }
  57. },
  58. ],*/
  59. /*[
  60. 'attribute' => 'last_login_at',
  61. 'value' => function ($model) {
  62. if (!$model->last_login_at || $model->last_login_at == 0) {
  63. return Yii::t('user', 'Never');
  64. } else if (extension_loaded('intl')) {
  65. return Yii::t('user', '{0, date, MMMM dd, YYYY HH:mm}', [$model->last_login_at]);
  66. } else {
  67. return date('Y-m-d G:i:s', $model->last_login_at);
  68. }
  69. },
  70. ],*/
  71. /*[
  72. 'header' => Yii::t('user', 'Confirmation'),
  73. 'value' => function ($model) {
  74. if ($model->isConfirmed) {
  75. return '<div class="text-center">
  76. <span class="text-success">' . Yii::t('user', 'Confirmed') . '</span>
  77. </div>';
  78. } else {
  79. return Html::a(Yii::t('user', 'Confirm'), ['confirm', 'id' => $model->id], [
  80. 'class' => 'btn btn-xs btn-success btn-block',
  81. 'data-method' => 'post',
  82. 'data-confirm' => Yii::t('user', 'Are you sure you want to confirm this user?'),
  83. ]);
  84. }
  85. },
  86. 'format' => 'raw',
  87. 'visible' => Yii::$app->getModule('user')->enableConfirmation,
  88. ],*/
  89. [
  90. 'header' => Yii::t('user', 'Block status'),
  91. 'value' => function ($model) {
  92. if ($model->isBlocked) {
  93. return Html::a(Yii::t('user', 'Unblock'), ['block', 'id' => $model->id], [
  94. 'class' => 'btn btn-xs btn-success btn-block',
  95. 'data-method' => 'post',
  96. 'data-confirm' => Yii::t('user', 'Are you sure you want to unblock this user?'),
  97. ]);
  98. } else {
  99. return Html::a(Yii::t('user', 'Block'), ['block', 'id' => $model->id], [
  100. 'class' => 'btn btn-xs btn-danger btn-block',
  101. 'data-method' => 'post',
  102. 'data-confirm' => Yii::t('user', 'Are you sure you want to block this user?'),
  103. ]);
  104. }
  105. },
  106. 'format' => 'raw',
  107. ],
  108. [
  109. 'class' => 'yii\grid\ActionColumn',
  110. 'contentOptions' => ['style'=>'white-space:nowrap;'],
  111. 'template' => '{switch} {resend_password} {update} {delete}',
  112. 'buttons' => [
  113. 'resend_password' => function ($url, $model, $key) {
  114. if (\Yii::$app->user->identity->isAdmin && !$model->isAdmin) {
  115. return '
  116. <a data-method="POST" data-confirm="' . Yii::t('user', 'Are you sure?') . '" href="' . Url::to(['resend-password', 'id' => $model->id]) . '">
  117. <span title="' . Yii::t('user', 'Generate and send new password to user') . '" class="glyphicon glyphicon-envelope">
  118. </span> </a>';
  119. }
  120. },
  121. 'switch' => function ($url, $model) {
  122. if(\Yii::$app->user->identity->isAdmin && $model->id != Yii::$app->user->id && Yii::$app->getModule('user')->enableImpersonateUser) {
  123. return Html::a('<span class="glyphicon glyphicon-user"></span>', ['/user/admin/switch', 'id' => $model->id], [
  124. 'title' => Yii::t('user', 'Become this user'),
  125. 'data-confirm' => Yii::t('user', 'Are you sure you want to switch to this user for the rest of this Session?'),
  126. 'data-method' => 'POST',
  127. ]);
  128. }
  129. }
  130. ]
  131. ],
  132. ],
  133. ]); ?>
  134. <?php Pjax::end() ?>