mirror of
https://github.com/derf/travelynx
synced 2024-11-10 15:04:17 +00:00
Allow status visibility to be limited to travelynx users
This commit is contained in:
parent
402a5597f5
commit
561ff4574b
4 changed files with 62 additions and 17 deletions
|
@ -215,15 +215,21 @@ sub privacy {
|
||||||
my $public_level = $user->{is_public};
|
my $public_level = $user->{is_public};
|
||||||
|
|
||||||
if ( $self->param('action') and $self->param('action') eq 'save' ) {
|
if ( $self->param('action') and $self->param('action') eq 'save' ) {
|
||||||
if ( $self->param('public_status') ) {
|
if ( $self->param('status_level') eq 'intern' ) {
|
||||||
|
$public_level |= 0x01;
|
||||||
|
$public_level &= ~0x02;
|
||||||
|
}
|
||||||
|
elsif ( $self->param('status_level') eq 'extern' ) {
|
||||||
$public_level |= 0x02;
|
$public_level |= 0x02;
|
||||||
|
$public_level &= ~0x01;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$public_level &= ~0x02;
|
$public_level &= ~0x03;
|
||||||
}
|
}
|
||||||
|
|
||||||
# public comment with non-public status does not make sense
|
# public comment with non-public status does not make sense
|
||||||
if ( $self->param('public_comment') and $self->param('public_status') )
|
if ( $self->param('public_comment')
|
||||||
|
and $self->param('status_level') ne 'private' )
|
||||||
{
|
{
|
||||||
$public_level |= 0x04;
|
$public_level |= 0x04;
|
||||||
}
|
}
|
||||||
|
@ -236,7 +242,11 @@ sub privacy {
|
||||||
$self->redirect_to('account');
|
$self->redirect_to('account');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$self->param( public_status => $public_level & 0x02 ? 1 : 0 );
|
$self->param(
|
||||||
|
status_level => $public_level & 0x01 ? 'intern'
|
||||||
|
: $public_level & 0x02 ? 'extern'
|
||||||
|
: 'private'
|
||||||
|
);
|
||||||
$self->param( public_comment => $public_level & 0x04 ? 1 : 0 );
|
$self->param( public_comment => $public_level & 0x04 ? 1 : 0 );
|
||||||
$self->render( 'privacy', name => $user->{name} );
|
$self->render( 'privacy', name => $user->{name} );
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,13 @@ sub user_status {
|
||||||
my $ts = $self->stash('ts');
|
my $ts = $self->stash('ts');
|
||||||
my $user = $self->get_privacy_by_name($name);
|
my $user = $self->get_privacy_by_name($name);
|
||||||
|
|
||||||
if ( $user and ( $user->{public_level} & 0x02 ) ) {
|
if (
|
||||||
|
$user
|
||||||
|
and ( $user->{public_level} & 0x02
|
||||||
|
or
|
||||||
|
( $user->{public_level} & 0x01 and $self->is_user_authenticated ) )
|
||||||
|
)
|
||||||
|
{
|
||||||
my $status = $self->get_user_status( $user->{id} );
|
my $status = $self->get_user_status( $user->{id} );
|
||||||
|
|
||||||
my %tw_data = (
|
my %tw_data = (
|
||||||
|
@ -81,6 +87,9 @@ sub user_status {
|
||||||
twitter => \%tw_data,
|
twitter => \%tw_data,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
elsif ( $user->{public_level} & 0x01 ) {
|
||||||
|
$self->render( 'login', redirect_to => $self->req->url );
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
$self->render('not_found');
|
$self->render('not_found');
|
||||||
}
|
}
|
||||||
|
@ -94,7 +103,13 @@ sub public_status_card {
|
||||||
|
|
||||||
delete $self->stash->{layout};
|
delete $self->stash->{layout};
|
||||||
|
|
||||||
if ( $user and ( $user->{public_level} & 0x02 ) ) {
|
if (
|
||||||
|
$user
|
||||||
|
and ( $user->{public_level} & 0x02
|
||||||
|
or
|
||||||
|
( $user->{public_level} & 0x01 and $self->is_user_authenticated ) )
|
||||||
|
)
|
||||||
|
{
|
||||||
my $status = $self->get_user_status( $user->{id} );
|
my $status = $self->get_user_status( $user->{id} );
|
||||||
$self->render(
|
$self->render(
|
||||||
'_public_status_card',
|
'_public_status_card',
|
||||||
|
|
|
@ -66,10 +66,13 @@
|
||||||
% if ($acc->{is_public} == 0) {
|
% if ($acc->{is_public} == 0) {
|
||||||
<span style="color: #999999;">Keine</span>
|
<span style="color: #999999;">Keine</span>
|
||||||
% }
|
% }
|
||||||
% if ($acc->{is_public} & 0x02) {
|
% if ($acc->{is_public} & 0x01) {
|
||||||
|
Aktueller Status (nur für angemeldete Accounts)
|
||||||
|
% }
|
||||||
|
% elsif ($acc->{is_public} & 0x02) {
|
||||||
Aktueller Status
|
Aktueller Status
|
||||||
% }
|
% }
|
||||||
% if (($acc->{is_public} & 0x06) == 0x06) {
|
% if ($acc->{is_public} & 0x04) {
|
||||||
mit Kommentar
|
mit Kommentar
|
||||||
% }
|
% }
|
||||||
</td>
|
</td>
|
||||||
|
|
|
@ -7,31 +7,48 @@
|
||||||
kennen.
|
kennen.
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<h2>Öffentliche Daten:</h2>
|
|
||||||
%= form_for '/account/privacy' => (method => 'POST') => begin
|
%= form_for '/account/privacy' => (method => 'POST') => begin
|
||||||
|
<h2>Aktueller Status</h2>
|
||||||
%= csrf_field
|
%= csrf_field
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="input-field col s12">
|
<div class="input-field col s12">
|
||||||
<label>
|
<label>
|
||||||
%= check_box public_status => 1
|
%= radio_button status_level => 'private'
|
||||||
<span>Aktueller Status</span>
|
<span>Nicht sichtbar</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="input-field col s12">
|
||||||
|
<label>
|
||||||
|
%= radio_button status_level => 'intern'
|
||||||
|
<span>Nur für angemeldete Accounts</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="input-field col s12">
|
||||||
|
<label>
|
||||||
|
%= radio_button status_level => 'extern'
|
||||||
|
<span>Öffentlich</span>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col s12">
|
<div class="col s12">
|
||||||
Wenn aktiv, ist dein aktueller Status unter <a href="/status/<%= $name
|
Hier kannst du auswählen, ob dein aktueller Status unter <a
|
||||||
%>">/status/<%= $name %></a> abrufbar. Wenn du eingecheckt bist,
|
href="/status/<%= $name %>">/status/<%= $name %></a> abrufbar ist.
|
||||||
werden dort Zug, Start- und Zielstation, Abfahrts- und Ankunftszeit
|
Wenn du eingecheckt bist, werden dort Zug, Start- und Zielstation,
|
||||||
gezeigt; andernfalls lediglich der Zielbahnhof der letzten Reise.
|
Abfahrts- und Ankunftszeit gezeigt; andernfalls lediglich der
|
||||||
Wann die letzte Reise beendet wurde, wird bewusst nicht angegeben.
|
Zielbahnhof der letzten Reise. Wann die letzte Reise beendet wurde,
|
||||||
|
wird bewusst nicht angegeben.
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="input-field col s12">
|
<div class="input-field col s12">
|
||||||
<label>
|
<label>
|
||||||
%= check_box public_comment => 1
|
%= check_box public_comment => 1
|
||||||
<span>Checkin-Kommentar</span>
|
<span>Mit Kommentar</span>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue