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