|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @package Cadmium\System\Modules\Profile |
|
5
|
|
|
* @author Anton Romanov |
|
6
|
|
|
* @copyright Copyright (c) 2015-2017, Anton Romanov |
|
7
|
|
|
* @link http://cadmium-cms.com |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
namespace Modules\Profile\Handler { |
|
11
|
|
|
|
|
12
|
|
|
use Frames, Modules\Profile, Utils\Messages, Utils\View, Language, Request, Template; |
|
13
|
|
|
|
|
14
|
|
|
class Edit extends Frames\Site\Area\Authorized { |
|
15
|
|
|
|
|
16
|
|
|
protected $_title = 'TITLE_PROFILE'; |
|
17
|
|
|
|
|
18
|
|
|
private $form_personal = null, $form_password = null; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Get the contents block |
|
22
|
|
|
*/ |
|
23
|
|
|
|
|
24
|
|
|
private function getContents() : Template\Block { |
|
25
|
|
|
|
|
26
|
|
|
$contents = View::get('Blocks/Profile/Edit'); |
|
27
|
|
|
|
|
28
|
|
|
# Implement forms |
|
29
|
|
|
|
|
30
|
|
|
$this->form_personal->implement($contents); |
|
31
|
|
|
|
|
32
|
|
|
$this->form_password->implement($contents); |
|
33
|
|
|
|
|
34
|
|
|
# ------------------------ |
|
35
|
|
|
|
|
36
|
|
|
return $contents; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Handle the request |
|
41
|
|
|
*/ |
|
42
|
|
|
|
|
43
|
|
|
protected function handle() : Template\Block { |
|
44
|
|
|
|
|
45
|
|
|
# Create forms |
|
46
|
|
|
|
|
47
|
|
|
$this->form_personal = new Profile\Form\Personal; |
|
48
|
|
|
|
|
49
|
|
|
$this->form_password = new Profile\Form\Password; |
|
50
|
|
|
|
|
51
|
|
|
# Create controllers |
|
52
|
|
|
|
|
53
|
|
|
$controller_personal = new Profile\Controller\Personal; |
|
54
|
|
|
|
|
55
|
|
|
$controller_password = new Profile\Controller\Password; |
|
56
|
|
|
|
|
57
|
|
|
# Handle forms |
|
58
|
|
|
|
|
59
|
|
|
if ($this->form_personal->handle($controller_personal) || $this->form_password->handle($controller_password)) { |
|
60
|
|
|
|
|
61
|
|
|
Request::redirect(INSTALL_PATH . '/profile/edit?submitted'); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
# Display success message |
|
65
|
|
|
|
|
66
|
|
|
if (false !== Request::get('submitted')) Messages::set('success', Language::get('USER_SUCCESS_EDIT')); |
|
67
|
|
|
|
|
68
|
|
|
# ------------------------ |
|
69
|
|
|
|
|
70
|
|
|
return $this->getContents(); |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|