1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Nicklas\Comment; |
4
|
|
|
|
5
|
|
|
use \Nicklas\Comment\HTMLForm\Profile\EditProfileForm; |
6
|
|
|
use \Nicklas\Comment\HTMLForm\Profile\UpdateProfileSecurityForm; |
7
|
|
|
use \Nicklas\Comment\Modules\User; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* A controller class. |
11
|
|
|
*/ |
12
|
|
|
class ProfileController extends LoginController |
13
|
|
|
{ |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Get details on item to load form with. |
17
|
|
|
* |
18
|
|
|
* @param integer $id get details on item with id. |
|
|
|
|
19
|
|
|
* |
20
|
|
|
* @return object true if okey, false if something went wrong. |
21
|
|
|
*/ |
22
|
2 |
|
public function getUserDetails($name) |
23
|
|
|
{ |
24
|
2 |
|
$user = new User($this->di->get("db")); |
25
|
2 |
|
return $user->getUser($name); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Render profile page |
30
|
|
|
* |
31
|
|
|
* @return void |
32
|
|
|
*/ |
33
|
1 |
|
public function renderProfile() |
34
|
|
|
{ |
35
|
1 |
|
$this->checkIsLogin(); |
36
|
|
|
|
37
|
1 |
|
$name = $this->di->get('session')->get("user"); |
38
|
1 |
|
$user = $this->getUserDetails($name); |
39
|
|
|
|
40
|
|
|
|
41
|
|
|
$views = [ |
42
|
1 |
|
["comment/user/profile/profile", ["user" => $user], "main"] |
43
|
1 |
|
]; |
44
|
|
|
|
45
|
1 |
|
if ($user->authority == "admin") { |
46
|
|
|
$views = [ |
47
|
1 |
|
["comment/admin/navbar", [], "main"], |
48
|
1 |
|
["comment/user/profile/profile", ["user" => $user], "main"] |
49
|
1 |
|
]; |
50
|
1 |
|
} |
51
|
|
|
|
52
|
1 |
|
$this->di->get("pageRenderComment")->renderPage([ |
53
|
1 |
|
"views" => $views, |
54
|
1 |
|
"title" => "$user->name" |
55
|
1 |
|
]); |
56
|
1 |
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Description. |
60
|
|
|
* |
61
|
|
|
* |
62
|
|
|
* @return void |
63
|
|
|
*/ |
64
|
1 |
View Code Duplication |
public function getPostEditUser() |
|
|
|
|
65
|
|
|
{ |
66
|
1 |
|
$this->checkIsLogin(); |
67
|
1 |
|
$name = $this->di->get('session')->get("user"); |
68
|
1 |
|
$user = $this->getUserDetails($name); |
69
|
|
|
|
70
|
1 |
|
$form = new EditProfileForm($this->di, $name); |
71
|
1 |
|
$form->check(); |
72
|
|
|
|
73
|
|
|
$views = [ |
74
|
1 |
|
["comment/user/profile/edit", ["form" => $form->getHTML(), "user" => $user], "main"] |
75
|
1 |
|
]; |
76
|
|
|
|
77
|
1 |
|
$this->di->get("pageRenderComment")->renderPage([ |
78
|
1 |
|
"views" => $views, |
79
|
|
|
"title" => "Edit Profile" |
80
|
1 |
|
]); |
81
|
1 |
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* Description. |
85
|
|
|
* |
86
|
|
|
* |
87
|
|
|
* @return void |
88
|
|
|
*/ |
89
|
|
View Code Duplication |
public function getPostEditSecurity() |
|
|
|
|
90
|
|
|
{ |
91
|
|
|
$name = $this->di->get('session')->get("user"); |
92
|
|
|
$user = $this->getUserDetails($name); |
93
|
|
|
|
94
|
|
|
$form = new UpdateProfileSecurityForm($this->di); |
95
|
|
|
$form->check(); |
96
|
|
|
|
97
|
|
|
$views = [ |
98
|
|
|
["comment/user/profile/edit", ["form" => $form->getHTML(), "user" => $user], "main"] |
99
|
|
|
]; |
100
|
|
|
|
101
|
|
|
$this->di->get("pageRenderComment")->renderPage([ |
102
|
|
|
"views" => $views, |
103
|
|
|
"title" => "Edit Profile" |
104
|
|
|
]); |
105
|
|
|
} |
106
|
|
|
} |
107
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.