Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 36
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
OlzEmailReaktionParams
n/a
0 / 0
n/a
0 / 0
0
n/a
0 / 0
OlzEmailReaktion
0.00% covered (danger)
0.00%
0 / 36
0.00% covered (danger)
0.00%
0 / 1
110
0.00% covered (danger)
0.00%
0 / 1
 getHtml
0.00% covered (danger)
0.00%
0 / 36
0.00% covered (danger)
0.00%
0 / 1
110
1<?php
2
3namespace Olz\Components\Auth\OlzEmailReaktion;
4
5use Olz\Components\Common\OlzComponent;
6use Olz\Components\Page\OlzFooter\OlzFooter;
7use Olz\Components\Page\OlzHeader\OlzHeader;
8use Olz\Utils\EmailUtils;
9use Olz\Utils\HttpParams;
10
11/** @extends HttpParams<array{token?: ?string}> */
12class OlzEmailReaktionParams extends HttpParams {
13}
14
15/** @extends OlzComponent<array<string, mixed>> */
16class OlzEmailReaktion extends OlzComponent {
17    public function getHtml(mixed $args): string {
18        $params = $this->httpUtils()->validateGetParams(OlzEmailReaktionParams::class);
19        $code_href = $this->envUtils()->getCodeHref();
20        $token = $params['token'] ?? '';
21        $js_token = htmlentities(json_encode($token) ?: '');
22        $reaction_data = EmailUtils::fromEnv()->decryptEmailReactionToken($token);
23
24        $out = OlzHeader::render([
25            'title' => "Reaktion auf E-Mail",
26            'description' => "Reaktion auf E-Mail.",
27            'norobots' => true,
28        ]);
29
30        $out .= "<div class='content-full'>";
31
32        if ($reaction_data) {
33            $question = null;
34            if ($reaction_data['action'] == 'unsubscribe') {
35                if (($reaction_data['notification_type'] ?? null) !== null) {
36                    $question = "<p>Willst du wirklich <b>alle E-Mail dieser Art abbestellen?</b></p>";
37                } elseif (isset($reaction_data['notification_type_all'])) {
38                    $question = "<p>Willst du wirklich <b>jegliche E-Mails von OL Zimmerberg abbestellen?</b></p>";
39                } else {
40                    $question = "<p>Hier ist etwas falsch gelaufen! Dies ist eine unbekannte Aktion. Trotzdem probieren?</p>";
41                }
42            }
43            if ($reaction_data['action'] == 'reset_password') {
44                $question = "<p>Willst du wirklich <b>dein Passwort zurücksetzen?</b></p>";
45            }
46            if ($reaction_data['action'] == 'verify_email') {
47                $question = "<p>Willst du <b>deine E-Mail-Adresse bestätigen?</b></p>";
48            }
49            if ($reaction_data['action'] == 'delete_news') {
50                $question = "<p>Willst du wirklich <b>deinen anonymen Forumseintrag löschen?</b></p>";
51            }
52            if ($question) {
53                $out .= <<<ZZZZZZZZZZ
54                    {$question}
55                    <p>
56                        <a
57                            class='btn btn-secondary'
58                            href='{$code_href}'
59                            role='button'
60                        >
61                            Abbrechen
62                        </a>
63                        <button
64                            id='execute-reaction-button'
65                            class='btn btn-danger'
66                            type='submit'
67                            onclick='olz.olzExecuteEmailReaction({$js_token})'
68                        >
69                            Ausführen
70                        </button>
71                    </p>
72                    <div id='email-reaction-success-message' class='alert alert-success' role='alert'></div>
73                    <div id='email-reaction-error-message' class='alert alert-danger' role='alert'></div>
74                    ZZZZZZZZZZ;
75            } else {
76                $out .= "<div class='alert alert-danger' role='alert'>Ungültiger Link!</div>";
77            }
78        } else {
79            $out .= "<div class='alert alert-danger' role='alert'>Ungültiger Link!</div>";
80        }
81
82        $out .= "</div>";
83
84        $out .= OlzFooter::render();
85        return $out;
86    }
87}