Skip to content

Commit be25bb4

Browse files
changed user editing
1 parent 2cc3ae0 commit be25bb4

File tree

4 files changed

+24
-23
lines changed

4 files changed

+24
-23
lines changed

src/controllers/UserController.php

+7-2
Original file line numberDiff line numberDiff line change
@@ -325,9 +325,14 @@ public function actionProfile($id = null)
325325
]);
326326
}
327327

328-
public function actionEditProfile()
328+
public function actionEditProfile($id = null)
329329
{
330-
$model = Yii::$app->user->identity;
330+
// if the current user's profile
331+
if (empty($id)) {
332+
$model = Yii::$app->user->identity;
333+
} else {
334+
$model = $this->findModel($id);
335+
}
331336

332337
$settings = UserSettingsConfig::find()->where([
333338
'access_level' => [1, 2]

src/views/user/editProfile.php

+14
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,20 @@
2929
<div class="white-block">
3030
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
3131

32+
<?php if (Yii::$app->user->identity->hasRole('admin')) {?>
33+
<div class="row">
34+
<div class="col-md-4">
35+
<?= $form->field($model, 'username')->textInput(['maxlength' => true]) ?>
36+
</div>
37+
<div class="col-md-4">
38+
<?= $form->field($model, 'email')->textInput(['maxlength' => true]) ?>
39+
</div>
40+
<div class="col-md-4">
41+
<?= $form->field($model, 'status')->dropDownList(User::getStatusList()) ?>
42+
</div>
43+
</div>
44+
<?php } ?>
45+
3246
<div class="row">
3347
<div class="col-md-3">
3448
<?= $form->field($model, 'city')->textInput(['maxlength' => true]) ?>

src/views/user/index.php

+3
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,9 @@
281281
if ($action == 'view') {
282282
return Url::toRoute(['profile', 'id' => $model->id]);
283283
}
284+
if ($action == 'update') {
285+
return Url::toRoute(['edit-profile', 'id' => $model->id]);
286+
}
284287
return Url::toRoute([$action, 'id' => $model->id]);
285288
}
286289
],

src/views/user/update.php

-21
This file was deleted.

0 commit comments

Comments
 (0)