80 lines
2.4 KiB
PHP
80 lines
2.4 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
namespace App\Controllers;
|
||
|
|
|
||
|
|
use App\Core\Privacy;
|
||
|
|
|
||
|
|
class PrivacyController
|
||
|
|
{
|
||
|
|
public function show(): void
|
||
|
|
{
|
||
|
|
view('privacy', [
|
||
|
|
'state' => Privacy::state(),
|
||
|
|
'privacyError' => flash_pull('privacy_error'),
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function imprint(): void
|
||
|
|
{
|
||
|
|
view('imprint');
|
||
|
|
}
|
||
|
|
|
||
|
|
public function storeConsent(): void
|
||
|
|
{
|
||
|
|
$returnTo = Privacy::returnPath('/');
|
||
|
|
$alreadyAccepted = Privacy::accepted();
|
||
|
|
|
||
|
|
if (!$alreadyAccepted && input('privacy_notice') !== '1') {
|
||
|
|
flash_set('privacy_error', 'Bitte bestätige die Datenschutzhinweise, bevor du fortfährst.');
|
||
|
|
redirect($returnTo);
|
||
|
|
}
|
||
|
|
|
||
|
|
$mode = (string) input('consent_mode', 'essential');
|
||
|
|
$externalMedia = $mode === 'all' && input('external_media') === '1';
|
||
|
|
|
||
|
|
if (!Privacy::store($externalMedia)) {
|
||
|
|
flash_set('privacy_error', 'Die Einwilligung konnte nicht gespeichert werden. Bitte versuche es erneut.');
|
||
|
|
redirect($returnTo);
|
||
|
|
}
|
||
|
|
|
||
|
|
flash_set('privacy_status', $externalMedia
|
||
|
|
? 'Danke! Deine Einwilligung wurde gespeichert. Externe Inhalte dürfen geladen werden.'
|
||
|
|
: 'Danke! Deine Einwilligung wurde gespeichert. Externe Inhalte bleiben deaktiviert.');
|
||
|
|
|
||
|
|
redirect($returnTo);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function updateExternalMedia(): void
|
||
|
|
{
|
||
|
|
if (!Privacy::accepted()) {
|
||
|
|
redirect('/datenschutz');
|
||
|
|
}
|
||
|
|
|
||
|
|
$returnTo = Privacy::returnPath('/datenschutz#externe-inhalte');
|
||
|
|
$allowed = input('external_media') === '1';
|
||
|
|
|
||
|
|
if (!Privacy::setExternalMedia($allowed)) {
|
||
|
|
flash_set('privacy_error', 'Die Einstellung konnte nicht gespeichert werden. Bitte versuche es erneut.');
|
||
|
|
} else {
|
||
|
|
flash_set('privacy_status', $allowed
|
||
|
|
? 'Externe Inhalte (Google Maps, YouTube) sind jetzt erlaubt.'
|
||
|
|
: 'Externe Inhalte (Google Maps, YouTube) sind jetzt deaktiviert.');
|
||
|
|
}
|
||
|
|
|
||
|
|
redirect($returnTo);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function revoke(): void
|
||
|
|
{
|
||
|
|
if (!Privacy::revoke()) {
|
||
|
|
flash_set('privacy_error', 'Die Einwilligung konnte nicht widerrufen werden. Bitte versuche es erneut.');
|
||
|
|
redirect('/datenschutz');
|
||
|
|
}
|
||
|
|
|
||
|
|
flash_set('privacy_status', 'Deine Einwilligung wurde widerrufen. Du kannst sie auf dieser Seite erneut erteilen.');
|
||
|
|
redirect('/datenschutz');
|
||
|
|
}
|
||
|
|
}
|