diff --git a/README.md b/README.md
index 9e364e6..b116917 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,4 @@
-
-
ZxCMS - Yii2 site management system
-
-
+# ZxCMS - Yii2 site management system
Yii 2 Advanced Project Template is a skeleton [Yii 2](http://www.yiiframework.com/) application best for
developing complex Web applications with multiple tiers.
diff --git a/backend/controllers/UserController.php b/backend/controllers/UserController.php
index ea4c4d4..b47b564 100644
--- a/backend/controllers/UserController.php
+++ b/backend/controllers/UserController.php
@@ -2,7 +2,9 @@
namespace backend\controllers;
+use core\forms\user\ProfileEditForm;
use core\forms\user\UserForm;
+use core\services\user\ProfileService;
use core\services\user\UserManageService;
use Yii;
use core\entities\user\User;
@@ -11,6 +13,7 @@ use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\filters\AccessControl;
+use yii\web\UploadedFile;
/**
* UserController implements the CRUD actions for User model.
@@ -18,11 +21,13 @@ use yii\filters\AccessControl;
class UserController extends Controller
{
private $service;
+ private $profile_service;
- public function __construct($id, $module, UserManageService $service, $config = [])
+ public function __construct($id, $module, UserManageService $service, ProfileService $profile_service, $config = [])
{
parent::__construct($id, $module, $config);
$this->service = $service;
+ $this->profile_service = $profile_service;
}
/**
@@ -39,6 +44,11 @@ class UserController extends Controller
'allow' => true,
'roles' => ['UserManagement'],
],
+ [
+ 'actions' => ['profile'],
+ 'allow' => true,
+ 'roles' => ['@'],
+ ],
[ // all the action are accessible to admin
'allow' => true,
'roles' => ['admin'],
@@ -142,6 +152,28 @@ class UserController extends Controller
return $this->redirect(['index']);
}
+ public function actionProfile()
+ {
+ $user = $this->findModel(Yii::$app->user->id);
+ $form = new ProfileEditForm($user);
+
+ if ($form->load(Yii::$app->request->post()) && $form->validate()) {
+ try {
+ $form->user_pic = UploadedFile::getInstance($form, 'user_pic');
+ $this->profile_service->edit(Yii::$app->user->id, $form);
+ Yii::$app->session->setFlash('success', Yii::t('user', 'Profile is saved.'));
+ } catch (\DomainException $e) {
+ Yii::$app->errorHandler->logException($e);
+ Yii::$app->session->setFlash('error', $e->getMessage());
+ }
+ }
+
+ return $this->render('profile', [
+ 'model' => $form,
+ 'user' => $user,
+ ]);
+ }
+
/**
* Finds the User model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
diff --git a/backend/messages/ru/main.php b/backend/messages/ru/main.php
index cfe0f46..27ec374 100644
--- a/backend/messages/ru/main.php
+++ b/backend/messages/ru/main.php
@@ -26,4 +26,5 @@ return [
'Change at your own risk' => 'Редактируйте на свой страх и риск',
'Online' => 'В сети',
'Search results' => 'Поиск',
+ 'Search...' => 'Поиск...',
];
\ No newline at end of file
diff --git a/backend/messages/ru/user.php b/backend/messages/ru/user.php
index 68241ed..08d9a29 100644
--- a/backend/messages/ru/user.php
+++ b/backend/messages/ru/user.php
@@ -32,4 +32,9 @@ return [
'Update Permission: {permission}' => 'Редактирование разрешения: {permission}',
'Administrator has full access rules' => 'Администратор обладает всеми правами доступа',
'Children roles and permissions for "{role}" is updated.' => 'Дочерние роли и разрешения для роли "{role}" обновлены.',
+ 'Profile' => 'Профиль',
+ 'Profile is saved.' => 'Профиль обновлен.',
+ 'Profile: {username}' => 'Профиль: {username}',
+ 'User Picture' => 'Аватар',
+ 'Registered: {date}' => 'Дата регистрации: {date}',
];
\ No newline at end of file
diff --git a/backend/views/layouts/header.php b/backend/views/layouts/header.php
index 50bc064..e0cf4e0 100644
--- a/backend/views/layouts/header.php
+++ b/backend/views/layouts/header.php
@@ -232,36 +232,28 @@ use core\components\avatar_generator\AvatarGenerator;