| @@ 352-373 (lines=22) @@ | ||
| 349 | * |
|
| 350 | * @return void |
|
| 351 | */ |
|
| 352 | public function postAdminUpdateUser() |
|
| 353 | { |
|
| 354 | // Get POST-variables |
|
| 355 | $email = $this->request->getPost("email"); |
|
| 356 | $password = $this->request->getPost("password"); |
|
| 357 | $passwordagain = $this->request->getPost("passwordagain"); |
|
| 358 | $admin = $this->request->getPost("admin"); |
|
| 359 | $userId = $this->request->getPost("user_id"); |
|
| 360 | if ($password !== $passwordagain) { |
|
| 361 | $message = "<p>Passwords did not match!</p>"; |
|
| 362 | $this->getAdminUpdateUser($message, $userId); |
|
| 363 | } |
|
| 364 | // Update user |
|
| 365 | $update = (object) [ |
|
| 366 | "password" => $password, |
|
| 367 | "email" => $email, |
|
| 368 | "admin" => $admin, |
|
| 369 | ]; |
|
| 370 | $this->di->get("user")->updateUserInDatabase($userId, $update); |
|
| 371 | // Redirect back to admin page |
|
| 372 | $this->response->redirect("user/admin"); |
|
| 373 | } |
|
| 374 | ||
| 375 | ||
| 376 | /** |
|
| @@ 405-428 (lines=24) @@ | ||
| 402 | * |
|
| 403 | * @return void |
|
| 404 | */ |
|
| 405 | public function postAdminCreateUser() |
|
| 406 | { |
|
| 407 | // Get POST-variables |
|
| 408 | $acronym = $this->request->getPost("name"); |
|
| 409 | $email = $this->request->getPost("email"); |
|
| 410 | $admin = $this->request->getPost("admin"); |
|
| 411 | $password = $this->request->getPost("password"); |
|
| 412 | $passwordagain = $this->request->getPost("passwordagain"); |
|
| 413 | if ($password !== $passwordagain) { |
|
| 414 | $message = "<p>Passwords did not match!</p>"; |
|
| 415 | $this->getAdminCreateUser($message); |
|
| 416 | return; |
|
| 417 | } |
|
| 418 | // Create new user |
|
| 419 | $newUser = (object) [ |
|
| 420 | "acronym" => $acronym, |
|
| 421 | "password" => $password, |
|
| 422 | "email" => $email, |
|
| 423 | "admin" => $admin, |
|
| 424 | ]; |
|
| 425 | $this->di->get("user")->createUser($newUser); |
|
| 426 | // Redirect back to admin |
|
| 427 | $this->response->redirect("user/admin"); |
|
| 428 | } |
|
| 429 | ||
| 430 | ||
| 431 | /** |
|