index.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 dektrium\user\models\UserSearch;
  11. use yii\data\ActiveDataProvider;
  12. use yii\grid\GridView;
  13. use yii\helpers\Html;
  14. use yii\jui\DatePicker;
  15. use yii\web\View;
  16. use yii\widgets\Pjax;
  17. /**
  18. * @var View $this
  19. * @var ActiveDataProvider $dataProvider
  20. * @var UserSearch $searchModel
  21. */
  22. $this->title = Yii::t('user', 'Manage users');
  23. $this->params['breadcrumbs'][] = $this->title;
  24. ?>
  25. <?= $this->render('/_alert', [
  26. 'module' => Yii::$app->getModule('user'),
  27. ]) ?>
  28. <?= $this->render('/admin/_menu') ?>
  29. <?php Pjax::begin() ?>
  30. <?= GridView::widget([
  31. 'dataProvider' => $dataProvider,
  32. 'filterModel' => $searchModel,
  33. 'layout' => "{items}\n{pager}",
  34. 'columns' => [
  35. //'username',
  36. 'email:email',
  37. 'at_org',
  38. [
  39. 'attribute' => 'registration_ip',
  40. 'value' => function ($model) {
  41. return $model->registration_ip == null
  42. ? '<span class="not-set">' . Yii::t('user', '(not set)') . '</span>'
  43. : $model->registration_ip;
  44. },
  45. 'format' => 'html',
  46. ],
  47. [
  48. 'attribute' => 'created_at',
  49. 'value' => function ($model) {
  50. if (extension_loaded('intl')) {
  51. return Yii::t('user', '{0, date, MMMM dd, YYYY HH:mm}', [$model->created_at]);
  52. } else {
  53. return date('Y-m-d G:i:s', $model->created_at);
  54. }
  55. },
  56. 'filter' => DatePicker::widget([
  57. 'model' => $searchModel,
  58. 'attribute' => 'created_at',
  59. 'dateFormat' => 'php:Y-m-d',
  60. 'options' => [
  61. 'class' => 'form-control',
  62. ],
  63. ]),
  64. ],
  65. [
  66. 'header' => Yii::t('user', 'Confirmation'),
  67. 'value' => function ($model) {
  68. if ($model->isConfirmed) {
  69. return '<div class="text-center"><span class="text-success">' . Yii::t('user', 'Confirmed') . '</span></div>';
  70. } else {
  71. return Html::a(Yii::t('user', 'Confirm'), ['confirm', 'id' => $model->id], [
  72. 'class' => 'btn btn-xs btn-success btn-block',
  73. 'data-method' => 'post',
  74. 'data-confirm' => Yii::t('user', 'Are you sure you want to confirm this user?'),
  75. ]);
  76. }
  77. },
  78. 'format' => 'raw',
  79. 'visible' => Yii::$app->getModule('user')->enableConfirmation,
  80. ],
  81. [
  82. 'header' => Yii::t('user', 'Block status'),
  83. 'value' => function ($model) {
  84. if ($model->isBlocked) {
  85. return Html::a(Yii::t('user', 'Unblock'), ['block', 'id' => $model->id], [
  86. 'class' => 'btn btn-xs btn-success btn-block',
  87. 'data-method' => 'post',
  88. 'data-confirm' => Yii::t('user', 'Are you sure you want to unblock this user?'),
  89. ]);
  90. } else {
  91. return Html::a(Yii::t('user', 'Block'), ['block', 'id' => $model->id], [
  92. 'class' => 'btn btn-xs btn-danger btn-block',
  93. 'data-method' => 'post',
  94. 'data-confirm' => Yii::t('user', 'Are you sure you want to block this user?'),
  95. ]);
  96. }
  97. },
  98. 'format' => 'raw',
  99. ],
  100. [
  101. 'class' => 'yii\grid\ActionColumn',
  102. 'template' => '{update} {delete}',
  103. ],
  104. ],
  105. ]); ?>
  106. <?php Pjax::end() ?>