2026-11-08 14:32:36 +01:00
< ? php
$current = auth_check () ? user () : null ;
$flashError = flash_pull ( 'error' );
2026-11-08 20:18:16 +01:00
$pushPublicKey = $pushPublicKey ? ? null ;
$pushEnabled = $pushEnabled ? ? false ;
$isOwnProfile = $current !== null && ( int ) $current -> id === ( int ) $user -> id ;
2026-11-10 10:36:53 +01:00
$privacyState = \App\Core\Privacy :: state ();
$privacyAccepted = \App\Core\Privacy :: accepted ();
$privacyAcceptedAt = null ;
if ( ! empty ( $privacyState [ 'accepted_at' ])) {
$privacyTimestamp = strtotime (( string ) $privacyState [ 'accepted_at' ]);
if ( $privacyTimestamp !== false ) {
$privacyAcceptedAt = date ( 'd.m.Y H:i' , $privacyTimestamp );
}
}
2026-11-08 14:32:36 +01:00
?>
2026-10-09 09:07:18 +02:00
< div class = " container text-center text-light mt-5 " >
2026-11-08 14:32:36 +01:00
< ? php if ( $flashError !== null ) : ?>
< div class = " alert alert-danger " role = " alert " >< ? = e ( $flashError ) ?> </div>
< ? php endif ; ?>
2026-11-08 20:21:48 +01:00
< h1 class = " text-center " >< ? = $isOwnProfile ? 'Einstellungen' : e ( $user -> name ) ?> </h1>
< ? php if ( $isOwnProfile ) : ?>
< p class = " text-center text-muted mb-4 " >< ? = e ( $user -> name ) ?> </p>
< ? php endif ; ?>
2026-10-09 09:07:18 +02:00
< form style = " background-color: #fff; " class = " text-dark " method = " post " action = " /member/<?= e( $user->id ) ?> "
enctype = " multipart/form-data " >
< ? = csrf_field () ?>
< input type = " hidden " name = " _method " value = " PUT " >
< input type = " hidden " name = " id " value = " <?= e( $user->id ) ?> " >
< div class = " form-group " style = " display:flex; " >
< label class = " ml-2 mt-4 " style = " width:150px; text-align:left; " for = " name " >< h4 > Name :</ h4 ></ label >
< input class = " mt-3 mr-2 form-control " type = " text " id = " name " style = " font-size:20px; " name = " name "
value = " <?= e(old('name') ?? $user->name ) ?> " required >
</ div >
< div class = " form-group " style = " display:flex; " >
< label class = " ml-2 mt-4 " style = " width:150px; text-align:left; " for = " mobile " >< h4 > Telefonnummer :</ h4 ></ label >
< input type = " text " class = " mt-3 mr-2 form-control " id = " mobile " style = " font-size:20px; " name = " mobile "
value = " <?= e(old('mobile') ?? $user->mobile ) ?> " required >
</ div >
< div class = " form-group " style = " display:flex; " >
< label class = " ml-2 mt-4 " style = " width:150px; text-align:left; " for = " email " >< h4 > EMail :</ h4 ></ label >
< input type = " text " class = " mt-3 mr-2 form-control " id = " email " style = " font-size:20px; " name = " email "
value = " <?= e(old('email') ?? $user->email ) ?> " required >
</ div >
< div class = " form-group " style = " display:flex; " >
< label class = " ml-2 mt-4 " style = " width:150px; text-align:left; " for = " bild " >< h4 > Bild :</ h4 ></ label >
< ? php if ( file_exists ( storage_path ( 'img_storage/user/' . $user -> id . '.jpg' ))) : ?>
< a href = " /img_storage/user/<?= e( $user->id ) ?>_gross.jpg " data - lightbox = " <?= e( $user->id ) ?>_gross.jpg "
data - title = " <?= e( $user->name ) ?> " >
< img src = " /img_storage/user/<?= e( $user->id ) ?>.jpg " id = " bild " class = " mt-3 ml-3 "
style = " width:256px;height:256px " >
</ a >
< ? php else : ?>
< img src = " /img/placeholder/user64x96.jpg " id = " bild " class = " mt-3 ml-3 " >
< ? php endif ; ?>
< input type = " file " class = " mt-3 mr-2 form-control " style = " font-size:20px; " name = " bild " value = " "
accept = " image/* " onchange = " preview_image(event) " >
</ div >
2026-11-10 10:36:53 +01:00
< p class = " small text-muted text-left ml-2 mb-3 " >
Mit dem Hochladen bestätigst du , dass du die erforderlichen Rechte am Bild hast und
abgebildete Personen mit der Veröffentlichung einverstanden sind .
</ p >
2026-10-09 09:07:18 +02:00
< ? php if ( $current && $current -> isAdmin ()) : ?>
< div class = " form-group " style = " display:flex; " >
< label class = " ml-2 mt-4 " style = " width:130px; text-align:left; " for = " role " >< h4 > Rolle :</ h4 ></ label >
< select name = " role " class = " dropdown-item ml-3 border form-control mt-3 mr-2 " style = " font-size:18px; " >
< option value = " GUEST " style = " font-size:18px; " class = " dropdown-item bg-light form-control " < ? = $user -> role === 'GUEST' ? 'selected' : '' ?> >GUEST</option>
< option value = " MEMBER " style = " font-size:18px; " class = " dropdown-item bg-light " < ? = $user -> role === 'MEMBER' ? 'selected' : '' ?> >MEMBER</option>
2026-11-08 18:07:28 +01:00
< option value = " TOUR GUIDE " style = " font-size:18px; " class = " dropdown-item bg-light " < ? = $user -> role === 'TOUR GUIDE' ? 'selected' : '' ?> >TOUR GUIDE</option>
2026-10-09 09:07:18 +02:00
< option value = " ADMIN " style = " font-size:18px; " class = " dropdown-item bg-light " < ? = $user -> role === 'ADMIN' ? 'selected' : '' ?> >ADMIN</option>
</ select >
</ div >
< ? php else : ?>
< div class = " form-group " style = " display:flex; " >
< label class = " ml-2 mt-4 " style = " width:130px; text-align:left; " for = " role " >< h4 > Rolle :</ h4 ></ label >
< h4 class = " mt-4 " >< ? = e ( $user -> role ) ?> </h4>
</ div >
< ? php endif ; ?>
< a href = " /member " class = " btn btn-primary col-2 mb-2 float-left " style = " margin-right:20px; " > Zurück </ a >
< ? php if ( $current && ( $current -> isAdmin () || ( int ) $current -> id === ( int ) $user -> id )) : ?>
< button type = " submit " class = " btn btn-danger col-2 mb-2 float-right mr-2 " > Speichern </ button >
2026-10-23 13:14:31 +02:00
< button type = " submit " form = " destroy-user-form " class = " btn btn-primary col-2 mb-2 float-left "
style = " margin-right:20px; " > Löschen </ button >
2026-10-09 09:07:18 +02:00
< ? php endif ; ?>
</ form >
2026-10-23 13:14:31 +02:00
< form id = " destroy-user-form " action = " /admin/destroy_user/<?= e( $user->id ) ?> " method = " POST " style = " display:none; " >
< ? = csrf_field () ?>
</ form >
2026-11-08 20:18:16 +01:00
2026-11-10 10:36:53 +01:00
< ? php if ( $isOwnProfile ) : ?>
< div class = " card text-dark mt-4 text-left " id = " privacy-settings " style = " clear: both; " >
< div class = " card-body " >
< h2 class = " h5 mb-2 " > Datenschutz & amp ; Einwilligungen </ h2 >
< p class = " mb-2 " >
< strong > Status :</ strong >
< ? php if ( $privacyAccepted ) : ?>
bestätigt < ? = $privacyAcceptedAt !== null ? ' am ' . e ( $privacyAcceptedAt ) : '' ?>
< ? php elseif ( ! empty ( $privacyState [ 'accepted' ])) : ?>
Die Datenschutzhinweise wurden geändert . Bitte erneut bestätigen .
< ? php else : ?>
noch nicht bestätigt
< ? php endif ; ?>
</ p >
< p class = " mb-3 " >
< strong > Externe Inhalte :</ strong >
< ? = \App\Core\Privacy :: externalMediaAllowed () ? 'erlaubt' : 'deaktiviert' ?>
< span class = " text-muted " > ( Google Maps , YouTube ) </ span >
</ p >
< a class = " btn btn-sm btn-outline-primary " href = " /datenschutz#einwilligung " >
Datenschutz - Einstellungen öffnen
</ a >
< ? php if ( $privacyAccepted ) : ?>
< form method = " post " action = " /datenschutz/widerruf " class = " d-inline-block ml-2 "
onsubmit = " return confirm('Möchtest du deine Datenschutz-Einwilligung wirklich widerrufen? Ohne erneute Zustimmung kannst du das Mitgliederportal nicht nutzen.'); " >
< ? = csrf_field () ?>
< button type = " submit " class = " btn btn-sm btn-outline-danger " > Einwilligung widerrufen </ button >
</ form >
< ? php endif ; ?>
</ div >
</ div >
< ? php endif ; ?>
2026-11-08 20:23:39 +01:00
< ? php if ( $isOwnProfile && $pushPublicKey !== null && ! is_desktop ()) : ?>
2026-11-08 20:29:03 +01:00
< div class = " card text-dark mt-4 text-left " id = " push-settings " style = " clear: both; "
2026-11-08 20:18:16 +01:00
data - vapid - key = " <?= e( $pushPublicKey ) ?> "
data - push - enabled = " <?= $pushEnabled ? '1' : '0' ?> " >
< div class = " card-body " >
< h2 class = " h5 mb-2 " > Benachrichtigungen ( App ) </ h2 >
< p class = " text-muted mb-3 " >
Diese Einstellung ist nur auf dem Smartphone sichtbar . Du erhältst eine
Nachricht , wenn eine neue Tour veröffentlicht oder eine Tour abgesagt wird .
</ p >
< div class = " form-check mb-2 " >
< input class = " form-check-input " type = " checkbox " id = " push-events " < ? = $pushEnabled ? 'checked' : '' ?> >
< label class = " form-check-label " for = " push-events " >
Bei neuen Touren und Absagen benachrichtigen
</ label >
</ div >
< p class = " small text-muted mb-2 " id = " push-hint " ></ p >
< button type = " button " class = " btn btn-sm btn-outline-primary " id = " push-test " < ? = $pushEnabled ? '' : 'hidden' ?> >
Test - Nachricht senden
</ button >
</ div >
</ div >
< script >
( function () {
var group = document . getElementById ( 'push-settings' );
var box = document . getElementById ( 'push-events' );
var hint = document . getElementById ( 'push-hint' );
var testButton = document . getElementById ( 'push-test' );
if ( ! group || ! box || ! hint || ! testButton ) {
return ;
}
var vapidKey = group . getAttribute ( 'data-vapid-key' ) || '' ;
2026-11-08 20:23:39 +01:00
var supported = 'serviceWorker' in navigator && 'PushManager' in window && 'Notification' in window ;
2026-11-08 20:18:16 +01:00
var isStandalone = window . matchMedia ( '(display-mode: standalone)' ) . matches
|| window . navigator . standalone === true ;
function setHint ( text , isError ) {
hint . textContent = text || '' ;
hint . className = 'small mb-2 ' + ( isError ? 'text-danger' : 'text-muted' );
}
function syncTestButton () {
testButton . hidden = ! box . checked ;
}
2026-11-08 20:23:39 +01:00
if ( ! vapidKey ) {
box . disabled = true ;
testButton . hidden = true ;
setHint ( 'Benachrichtigungen sind auf diesem Server noch nicht eingerichtet.' , true );
return ;
}
if ( ! supported ) {
box . disabled = true ;
testButton . hidden = true ;
setHint (
isStandalone
? 'Dieser Browser unterstützt keine Push-Benachrichtigungen.'
: 'Push-Benachrichtigungen brauchen einen unterstützten Browser. Auf dem iPhone: Seite in Safari öffnen, „Teilen“ → „Zum Home-Bildschirm“ wählen und die App vom Startbildschirm aus öffnen.' ,
true
);
return ;
}
2026-11-08 20:18:16 +01:00
function keyToBytes ( base64url ) {
var padding = new Array (( 4 - ( base64url . length % 4 )) % 4 + 1 ) . join ( '=' );
var base64 = ( base64url + padding ) . replace ( /-/ g , '+' ) . replace ( / _ / g , '/' );
var raw = window . atob ( base64 );
var bytes = new Uint8Array ( raw . length );
for ( var i = 0 ; i < raw . length ; i ++ ) {
bytes [ i ] = raw . charCodeAt ( i );
}
return bytes ;
}
function post ( path , payload ) {
var token = document . querySelector ( 'meta[name="csrf-token"]' );
var headers = { 'Content-Type' : 'application/json' };
if ( token ) {
headers [ 'X-CSRF-Token' ] = token . getAttribute ( 'content' );
}
return fetch ( path , {
method : 'POST' ,
headers : headers ,
credentials : 'same-origin' ,
body : JSON . stringify ( payload || {})
}) . then ( function ( response ) {
return response . json () . catch ( function () {
return {};
}) . then ( function ( data ) {
if ( ! response . ok ) {
throw new Error ( data && data . error ? data . error : 'Server meldet HTTP ' + response . status + '.' );
}
return data ;
});
});
}
function createSubscription ( registration ) {
return registration . pushManager . subscribe ({
userVisibleOnly : true ,
applicationServerKey : keyToBytes ( vapidKey )
});
}
function subscribe () {
return navigator . serviceWorker . ready . then ( function ( registration ) {
return registration . pushManager . getSubscription () . then ( function ( existing ) {
if ( existing ) {
return existing ;
}
return createSubscription ( registration ) . catch ( function ( error ) {
// Abo mit einem alten VAPID-Schlüssel: erneuern.
if ( error && error . name === 'InvalidStateError' ) {
return registration . pushManager . getSubscription () . then ( function ( old ) {
return old ? old . unsubscribe () : null ;
}) . then ( function () {
return createSubscription ( registration );
});
}
throw error ;
});
});
});
}
box . addEventListener ( 'change' , function () {
if ( box . disabled ) {
return ;
}
box . disabled = true ;
setHint ( '' );
var action ;
if ( box . checked ) {
action = Notification . requestPermission () . then ( function ( permission ) {
if ( permission !== 'granted' ) {
throw new Error ( 'Benachrichtigungen sind blockiert. Bitte in den Systemeinstellungen erlauben.' );
}
return subscribe ();
}) . then ( function ( subscription ) {
if ( ! subscription ) {
throw new Error ( 'Abo konnte nicht angelegt werden.' );
}
return post ( '/push/subscribe' , subscription . toJSON ());
}) . then ( function () {
setHint ( 'Benachrichtigungen sind jetzt auf diesem Gerät aktiv.' );
});
} else {
action = navigator . serviceWorker . ready . then ( function ( registration ) {
return registration . pushManager . getSubscription ();
}) . then ( function ( subscription ) {
return subscription ? subscription . unsubscribe () : null ;
}) . then ( function () {
return post ( '/push/unsubscribe' , {});
}) . then ( function () {
setHint ( 'Benachrichtigungen sind ausgeschaltet.' );
});
}
action . catch ( function ( error ) {
if ( box . checked ) {
box . checked = false ;
}
setHint ( error && error . message ? error . message : 'Aktion fehlgeschlagen.' , true );
}) . then ( function () {
box . disabled = false ;
syncTestButton ();
});
});
testButton . addEventListener ( 'click' , function () {
if ( testButton . disabled ) {
return ;
}
testButton . disabled = true ;
setHint ( 'Test-Nachricht wird gesendet …' );
navigator . serviceWorker . ready . then ( function ( registration ) {
return registration . pushManager . getSubscription ();
}) . then ( function ( subscription ) {
if ( ! subscription ) {
throw new Error ( 'Dieses Gerät hat noch kein Abo. Bitte den Haken aus- und wieder einschalten.' );
}
return post ( '/push/test' , { endpoint : subscription . endpoint });
}) . then ( function () {
setHint ( 'Test-Nachricht gesendet. Sie sollte jetzt auf diesem Gerät erscheinen.' );
}) . catch ( function ( error ) {
setHint ( error && error . message ? error . message : 'Test fehlgeschlagen.' , true );
}) . then ( function () {
testButton . disabled = false ;
});
});
syncTestButton ();
})();
</ script >
< ? php endif ; ?>
2026-10-09 09:07:18 +02:00
</ div >
< script >
function preview_image ( event ) {
var reader = new FileReader ();
reader . onload = function () {
var output = document . getElementById ( 'bild' );
output . src = reader . result ;
}
reader . readAsDataURL ( event . target . files [ 0 ]);
}
</ script >