1 | <?php |
||
15 | class UserController implements InjectionAwareInterface |
||
16 | { |
||
17 | use InjectionAwareTrait; |
||
18 | |||
19 | private $session; |
||
20 | private $userService; |
||
21 | private $response; |
||
22 | private $view; |
||
23 | private $pageRender; |
||
24 | |||
25 | |||
26 | |||
27 | /** |
||
28 | * Initiate the controller. |
||
29 | * @return void |
||
30 | */ |
||
31 | 8 | public function init() |
|
39 | |||
40 | |||
41 | |||
42 | /** |
||
43 | * Login-page |
||
44 | * |
||
45 | * @throws Exception |
||
46 | * |
||
47 | * @return void |
||
48 | */ |
||
49 | 1 | public function getPostLogin() |
|
68 | |||
69 | |||
70 | |||
71 | /** |
||
72 | * Create user page. |
||
73 | * |
||
74 | * @throws Exception |
||
75 | * |
||
76 | * @return void |
||
77 | */ |
||
78 | 1 | public function getPostCreateUser() |
|
93 | |||
94 | |||
95 | |||
96 | /** |
||
97 | * Uppdatera användare. |
||
98 | * |
||
99 | * @param integer $id User id. |
||
100 | * |
||
101 | * @throws Exception |
||
102 | * |
||
103 | * @return void |
||
104 | */ |
||
105 | 1 | public function getPostUpdateUser($id) |
|
133 | |||
134 | |||
135 | |||
136 | /** |
||
137 | * Handler with form to delete an item. |
||
138 | * |
||
139 | * @return void |
||
140 | */ |
||
141 | 1 | public function getPostDeleteUser($id) |
|
142 | { |
||
143 | 1 | $loggedInUser = $this->userService->getCurrentLoggedInUser(); |
|
144 | |||
145 | 1 | if ($loggedInUser === null) { |
|
146 | 1 | $this->response->redirect("user/login"); |
|
147 | 1 | } |
|
148 | 1 | if ($loggedInUser !== null && !$loggedInUser->administrator) { |
|
149 | 1 | $this->response->redirect("user/login"); |
|
150 | 1 | } |
|
151 | |||
152 | 1 | $title = "Radera en användare"; |
|
153 | 1 | $form = new DeleteUserForm($this->di, $id); |
|
154 | |||
155 | 1 | $form->check(); |
|
156 | |||
157 | $data = [ |
||
158 | 1 | "content" => $form->getHTML(), |
|
159 | 1 | ]; |
|
160 | |||
161 | 1 | $this->view->add("default2/article", $data); |
|
162 | |||
163 | 1 | $this->pageRender->renderPage(["title" => $title]); |
|
164 | 1 | } |
|
165 | |||
166 | |||
167 | |||
168 | /** |
||
169 | * Logout user. |
||
170 | * |
||
171 | * @return void |
||
172 | */ |
||
173 | 1 | public function logout() |
|
178 | } |
||
179 |