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