From a1865fa69e3a90e484e8423e256e1cb969b7e04d Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 14 Feb 2020 16:29:44 +0100 Subject: add privacy setting for showing history and latest arrival timestamp --- lib/Travelynx.pm | 3 +++ lib/Travelynx/Controller/Account.pm | 18 ++++++++++++++++++ templates/_public_status_card.html.ep | 9 ++++++++- templates/privacy.html.ep | 36 ++++++++++++++++++++++++++++++++++- 4 files changed, 64 insertions(+), 2 deletions(-) diff --git a/lib/Travelynx.pm b/lib/Travelynx.pm index 2b34b99..661572e 100755 --- a/lib/Travelynx.pm +++ b/lib/Travelynx.pm @@ -187,6 +187,9 @@ sub startup { status_intern => 0x01, status_extern => 0x02, status_comment => 0x04, + history_intern => 0x10, + history_latest => 0x20, + history_full => 0x40, }; } ); diff --git a/lib/Travelynx/Controller/Account.pm b/lib/Travelynx/Controller/Account.pm index cef79a5..135c52b 100644 --- a/lib/Travelynx/Controller/Account.pm +++ b/lib/Travelynx/Controller/Account.pm @@ -236,6 +236,19 @@ sub privacy { else { $public_level &= ~0x04; } + + if ( $self->param('history_level') eq 'intern' ) { + $public_level |= 0x10; + $public_level &= ~0x20; + } + elsif ( $self->param('history_level') eq 'extern' ) { + $public_level |= 0x20; + $public_level &= ~0x10; + } + else { + $public_level &= ~0x30; + } + $self->set_privacy( $user->{id}, $public_level ); $self->flash( success => 'privacy' ); @@ -248,6 +261,11 @@ sub privacy { : 'private' ); $self->param( public_comment => $public_level & 0x04 ? 1 : 0 ); + $self->param( + history_level => $public_level & 0x10 ? 'intern' + : $public_level & 0x20 ? 'extern' + : 'private' + ); $self->render( 'privacy', name => $user->{name} ); } } diff --git a/templates/_public_status_card.html.ep b/templates/_public_status_card.html.ep index 810c4b8..ced0c6f 100644 --- a/templates/_public_status_card.html.ep +++ b/templates/_public_status_card.html.ep @@ -163,7 +163,14 @@ <%= $name %> ist gerade nicht eingecheckt

% if ($journey->{arr_name}) { - Zuletzt gesehen in <%= $journey->{arr_name} %>. + Zuletzt gesehen + % if ($public_level & 0x30 and $journey->{real_arrival}->epoch) { + %= $journey->{real_arrival}->strftime('am %d.%m.%Y') + % } + in <%= $journey->{arr_name} %> + % if ($public_level & 0x30 and $journey->{real_arrival}->epoch) { + %= $journey->{real_arrival}->strftime('(Ankunft um %H:%M Uhr)') + % } % } % else { Noch keine Zugfahrten geloggt. diff --git a/templates/privacy.html.ep b/templates/privacy.html.ep index e8e6459..9439f8b 100644 --- a/templates/privacy.html.ep +++ b/templates/privacy.html.ep @@ -8,8 +8,8 @@ %= form_for '/account/privacy' => (method => 'POST') => begin +%= csrf_field

Aktueller Status

- %= csrf_field
+

Vergangene Zugfahrten

+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ Diese Einstellung bestimmt die Sichtbarkeit deiner letzten + zehn Zugfahrten mit allen dazu bekannten Details (Abfahrt, Ankunft, + Wagenreihung u.a.). Dies umfasst Angaben auf + /status/<%= $name %> sowie + eine Liste deiner letzten Fahrten. Die Implementierung folgt noch... +
+
-- cgit v1.2.3