<?php use marsoltys\yii2user\Module; use yii\helpers\Html; use yii\widgets\ActiveForm; $this->title = Yii::$app->name . ' - ' . Module::t("Change password"); $this->params['breadcrumbs'] = [['label' => Module::t("Profile"), 'url' => ['/user/profile']], Module::t("Change password")]; $menu = [['label' => Module::t('List User'), 'url' => ['/user']], ['label' => Module::t('Profile'), 'url' => ['/user/profile']], ['label' => Module::t('Edit'), 'url' => ['/user/profile/edit']], ['label' => Module::t('Logout'), 'url' => ['/user/logout']]]; if (Module::isAdmin()) { array_unshift($menu, ['label' => Module::t('Manage Users'), 'url' => ['/user/admin']]); } Module::getInstance()->setMenu($menu); ?> <div class="change-password"> <h1><?php echo Module::t("Change password"); ?> </h1> <p class="note"><?php echo Module::t('Fields with <span class="required">*</span> are required.'); ?> </p> <div class="col-lg-4"> <?php $form = ActiveForm::begin(['id' => 'changepassword-form', 'enableAjaxValidation' => true, 'validateOnSubmit' => true, 'options' => ['class' => 'form-horizontal'], 'fieldConfig' => ['labelOptions' => ['class' => 'control-label']]]); ?>
/** * Checks if current user is an Administrator * @return boolean */ public function isAdmin() { return $this->module->isAdmin(); }
<?php use marsoltys\yii2user\Module; use yii\grid\GridView; use yii\helpers\Html; /* @var $this yii\web\View */ /* @var $dataProvider yii\data\ActiveDataProvider */ $this->params['breadcrumbs'] = [Module::t("Users")]; if (!Module::isAdmin()) { $this->context->layout = 'main'; } ?> <h1><?php echo Module::t("List User"); ?> </h1> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => [['format' => 'html', 'value' => function ($data) { return Html::a(Html::encode($data->username), ["user/view", "id" => $data->id]); }], 'create_at', 'lastvisit_at']]);
public function initMenu() { if (Module::isAdmin()) { $this->menu = [['label' => Module::t('Create User'), 'url' => ['/user/admin/create']], ['label' => Module::t('Manage Users'), 'url' => ['/user/admin/admin']], ['label' => Module::t('Manage Profile Field'), 'url' => ['/user/profile-field/admin']], ['label' => Module::t('List User'), 'url' => ['/user/user/index']]]; } }