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