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 UserController |
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 |
|
$user->find("name", $name); |
26
|
2 |
|
$user->setGravatar(); |
27
|
2 |
|
return $user; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Render profile page |
32
|
|
|
* |
33
|
|
|
* @return void |
34
|
|
|
*/ |
35
|
1 |
|
public function renderProfile() |
36
|
|
|
{ |
37
|
1 |
|
$this->checkIsLogin(); |
38
|
|
|
|
39
|
1 |
|
$name = $this->di->get('session')->get("user"); |
40
|
1 |
|
$user = $this->getUserDetails($name); |
41
|
|
|
|
42
|
|
|
|
43
|
|
|
$views = [ |
44
|
1 |
|
["user/profile/profile", ["user" => $user], "main"] |
45
|
1 |
|
]; |
46
|
|
|
|
47
|
1 |
|
if ($user->authority == "admin") { |
48
|
|
|
$views = [ |
49
|
|
|
["admin/navbar", [], "main"], |
50
|
|
|
["user/profile/profile", ["user" => $user], "main"] |
51
|
|
|
]; |
52
|
|
|
} |
53
|
|
|
|
54
|
1 |
|
$this->di->get("pageRenderComment")->renderPage([ |
55
|
1 |
|
"views" => $views, |
56
|
1 |
|
"title" => "$user->name" |
57
|
1 |
|
]); |
58
|
1 |
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Description. |
62
|
|
|
* |
63
|
|
|
* @param datatype $variable Description |
|
|
|
|
64
|
|
|
* |
65
|
|
|
* @throws Exception |
66
|
|
|
* |
67
|
|
|
* @return void |
68
|
|
|
*/ |
69
|
1 |
View Code Duplication |
public function getPostEditUser() |
|
|
|
|
70
|
|
|
{ |
71
|
1 |
|
$name = $this->di->get('session')->get("user"); |
72
|
1 |
|
$user = $this->getUserDetails($name); |
73
|
|
|
|
74
|
1 |
|
$form = new EditProfileForm($this->di, $name); |
75
|
1 |
|
$form->check(); |
76
|
|
|
|
77
|
|
|
$views = [ |
78
|
1 |
|
["user/profile/edit", ["form" => $form->getHTML(), "user" => $user], "main"] |
79
|
1 |
|
]; |
80
|
|
|
|
81
|
1 |
|
$this->di->get("pageRenderComment")->renderPage([ |
82
|
1 |
|
"views" => $views, |
83
|
|
|
"title" => "Edit Profile" |
84
|
1 |
|
]); |
85
|
1 |
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* Description. |
89
|
|
|
* |
90
|
|
|
* @param datatype $variable Description |
|
|
|
|
91
|
|
|
* |
92
|
|
|
* @throws Exception |
93
|
|
|
* |
94
|
|
|
* @return void |
95
|
|
|
*/ |
96
|
|
View Code Duplication |
public function getPostEditSecurity() |
|
|
|
|
97
|
|
|
{ |
98
|
|
|
$name = $this->di->get('session')->get("user"); |
99
|
|
|
$user = $this->getUserDetails($name); |
100
|
|
|
|
101
|
|
|
$form = new UpdateProfileSecurityForm($this->di); |
102
|
|
|
$form->check(); |
103
|
|
|
|
104
|
|
|
$views = [ |
105
|
|
|
["user/profile/edit", ["form" => $form->getHTML(), "user" => $user], "main"] |
106
|
|
|
]; |
107
|
|
|
|
108
|
|
|
$this->di->get("pageRenderComment")->renderPage([ |
109
|
|
|
"views" => $views, |
110
|
|
|
"title" => "Edit Profile" |
111
|
|
|
]); |
112
|
|
|
} |
113
|
|
|
} |
114
|
|
|
|
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.