diff options
Diffstat (limited to 'src/view/UserEditBuilder.php')
-rw-r--r-- | src/view/UserEditBuilder.php | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/view/UserEditBuilder.php b/src/view/UserEditBuilder.php new file mode 100644 index 0000000..63bbfad --- /dev/null +++ b/src/view/UserEditBuilder.php | |||
@@ -0,0 +1,58 @@ | |||
1 | <?php | ||
2 | // src/view/UserEditBuilder.php | ||
3 | // | ||
4 | // fonctionne avec UserController | ||
5 | |||
6 | declare(strict_types=1); | ||
7 | |||
8 | use App\Entity\Node; | ||
9 | |||
10 | class UserEditBuilder extends AbstractBuilder | ||
11 | { | ||
12 | public function __construct(Node $node) | ||
13 | { | ||
14 | // pour éviter les arnaques | ||
15 | if(!$_SESSION['admin']) | ||
16 | { | ||
17 | header('Location: ' . new URL); | ||
18 | die; | ||
19 | } | ||
20 | |||
21 | $viewFile = self::VIEWS_PATH . $node->getName() . '.php'; | ||
22 | |||
23 | $error_messages = [ | ||
24 | 'error_non_valid_captcha' => 'Erreur au test anti-robot, veuillez saisir un nombre entier.', | ||
25 | 'captcha_server_error' => 'captcha_server_error', | ||
26 | |||
27 | 'bad_login_or_password' => 'Mauvais identifiant ou mot de passe, veuillez réessayer.', // ne pas indiquer où est l'erreur | ||
28 | 'bad_solution_captcha' => 'Erreur au test anti-robot, veuillez réessayer.', | ||
29 | 'forbidden_characters' => 'Caractères interdits: espaces, tabulations, sauts CR/LF.', | ||
30 | 'same_username_as_before' => 'Nouveau nom identique au précédent.', | ||
31 | 'same_password_as_before' => 'Nouveau mot de passe identique au précédent.' | ||
32 | ]; | ||
33 | |||
34 | $error_username = isset($_GET['error_login']) ? $error_messages[$_GET['error_login']] : ''; | ||
35 | $success_username = (isset($_GET['success_login']) && $_GET['success_login']) ? 'Identifiant modifié avec succès.' : ''; | ||
36 | $error_password = isset($_GET['error_password']) ? $error_messages[$_GET['error_password']] : ''; | ||
37 | $success_password = (isset($_GET['success_password']) && $_GET['success_password']) ? 'Mot de passe modifié avec succès.' : ''; | ||
38 | |||
39 | $captcha = new Captcha; | ||
40 | $_SESSION['captcha'] = $captcha->getSolution(); // enregistrement de la réponse du captcha pour vérification | ||
41 | |||
42 | $link_user_form = new URL(['action' => 'update_username']); | ||
43 | isset($_GET['from']) ? $link_user_form->addParams(['from' => $_GET['from']]) : ''; | ||
44 | isset($_GET['id']) ? $link_user_form->addParams(['id' => $_GET['id']]) : ''; | ||
45 | |||
46 | $link_password_form = new URL(['action' => 'update_password']); | ||
47 | isset($_GET['from']) ? $link_password_form->addParams(['from' => $_GET['from']]) : ''; | ||
48 | isset($_GET['id']) ? $link_password_form->addParams(['id' => $_GET['id']]) : ''; | ||
49 | |||
50 | $link_exit = new URL; | ||
51 | isset($_GET['from']) ? $link_exit->addParams(['page' => $_GET['from'] ]) : ''; | ||
52 | isset($_GET['id']) ? $link_exit->addParams(['id' => $_GET['id']]) : ''; | ||
53 | |||
54 | ob_start(); | ||
55 | require $viewFile; | ||
56 | $this->html = ob_get_clean(); // nouveau contenu | ||
57 | } | ||
58 | } \ No newline at end of file | ||