diff options
Diffstat (limited to 'lib/Travelynx')
-rw-r--r-- | lib/Travelynx/Command/database.pm | 54 | ||||
-rw-r--r-- | lib/Travelynx/Controller/Account.pm | 23 | ||||
-rwxr-xr-x | lib/Travelynx/Controller/Profile.pm | 9 | ||||
-rw-r--r-- | lib/Travelynx/Model/Users.pm | 35 |
4 files changed, 88 insertions, 33 deletions
diff --git a/lib/Travelynx/Command/database.pm b/lib/Travelynx/Command/database.pm index 805b595..339fd42 100644 --- a/lib/Travelynx/Command/database.pm +++ b/lib/Travelynx/Command/database.pm @@ -1589,6 +1589,60 @@ my @migrations = ( } ); }, + + # v39 -> v40 + # distinguish between public / travelynx / followers / private visibility + # for the history page, just like status visibility. + sub { + my ($db) = @_; + $db->query( + qq{ + alter table users alter public_level type integer; + } + ); + my $res = $db->select( 'users', [ 'id', 'public_level' ] ); + while ( my $row = $res->hash ) { + my $old_level = $row->{public_level}; + + # checkin and comment visibility remain unchanged + my $new_level = $old_level & 0x00ff; + + # past: account required + if ( $old_level & 0x100 ) { + $new_level |= 80 << 8; + } + + # past: public + elsif ( $old_level & 0x200 ) { + $new_level |= 100 << 8; + } + + # past: private + else { + $new_level |= 10 << 8; + } + + # past: infinite (default is 4 weeks) + if ( $old_level & 0x400 ) { + $new_level |= 0x10000; + } + + # show past journey on status page + if ( $old_level & 0x800 ) { + $new_level |= 0x8000; + } + + my $r = $db->update( + 'users', + { public_level => $new_level }, + { id => $row->{id} } + )->rows; + if ( $r != 1 ) { + die("oh no"); + } + } + $db->update( 'schema_version', { version => 40 } ); + }, ); # TODO add 'hafas' column to in_transit (and maybe journeys? undo/redo needs something to work with...) diff --git a/lib/Travelynx/Controller/Account.pm b/lib/Travelynx/Controller/Account.pm index 80914fb..bc24c05 100644 --- a/lib/Travelynx/Controller/Account.pm +++ b/lib/Travelynx/Controller/Account.pm @@ -456,8 +456,7 @@ sub do_logout { sub privacy { my ($self) = @_; - my $user = $self->current_user; - my $public_level = $user->{is_public}; + my $user = $self->current_user; if ( $self->param('action') and $self->param('action') eq 'save' ) { my %opt; @@ -467,21 +466,16 @@ sub privacy { $opt{default_visibility} = $default_visibility; } + my $past_visibility = $visibility_atoi{ $self->param('history_level') }; + if ( defined $past_visibility ) { + $opt{past_visibility} = $past_visibility; + } + $opt{comments_visible} = $self->param('public_comment') ? 1 : 0; $opt{past_all} = $self->param('history_age') eq 'infinite' ? 1 : 0; $opt{past_status} = $self->param('past_status') ? 1 : 0; - if ( $self->param('history_level') eq 'intern' ) { - $opt{past_visible} = 1; - } - elsif ( $self->param('history_level') eq 'extern' ) { - $opt{past_visible} = 2; - } - else { - $opt{past_visible} = 0; - } - $self->users->set_privacy( uid => $user->{id}, %opt @@ -495,10 +489,7 @@ sub privacy { status_level => $visibility_itoa{ $user->{default_visibility} } ); $self->param( public_comment => $user->{comments_visible} ); $self->param( - history_level => $user->{past_visible} & 0x01 ? 'intern' - : $user->{past_visible} & 0x02 ? 'extern' - : 'private' - ); + history_level => $visibility_itoa{ $user->{past_visibility} } ); $self->param( history_age => $user->{past_all} ? 'infinite' : 'month' ); $self->param( past_status => $user->{past_status} ); $self->render( 'privacy', name => $user->{name} ); diff --git a/lib/Travelynx/Controller/Profile.pm b/lib/Travelynx/Controller/Profile.pm index 005a811..d77e6f7 100755 --- a/lib/Travelynx/Controller/Profile.pm +++ b/lib/Travelynx/Controller/Profile.pm @@ -134,8 +134,13 @@ sub profile { my @journeys; - if ( $user->{past_visible} == 2 - or ( $user->{past_visible} == 1 and ( $my_user or $is_self ) ) ) + if ( + $user->{past_visibility_str} eq 'public' + or ( $user->{past_visibility_str} eq 'travelynx' + and ( $my_user or $is_self ) ) + or ( $user->{past_visibility_str} eq 'followers' + and ( ( $relation and $relation eq 'follows' ) or $is_self ) ) + ) { my %opt = ( diff --git a/lib/Travelynx/Model/Users.pm b/lib/Travelynx/Model/Users.pm index 1747989..95cab8f 100644 --- a/lib/Travelynx/Model/Users.pm +++ b/lib/Travelynx/Model/Users.pm @@ -191,12 +191,14 @@ sub get_privacy_by { default_visibility => $user->{public_level} & 0x7f, default_visibility_str => $visibility_itoa{ $user->{public_level} & 0x7f }, - comments_visible => $user->{public_level} & 0x80 ? 1 : 0, - past_visible => ( $user->{public_level} & 0x300 ) >> 8, - past_all => $user->{public_level} & 0x400 ? 1 : 0, - past_status => $user->{public_level} & 0x800 ? 1 : 0, - accept_follows => $user->{accept_follows} == 2 ? 1 : 0, - accept_follow_requests => $user->{accept_follows} == 1 ? 1 : 0, + comments_visible => $user->{public_level} & 0x80 ? 1 : 0, + past_visibility => ( $user->{public_level} & 0x7f00 ) >> 8, + past_visibility_str => + $visibility_itoa{ ( $user->{public_level} & 0x7f00 ) >> 8 }, + past_status => $user->{public_level} & 0x08000 ? 1 : 0, + past_all => $user->{public_level} & 0x10000 ? 1 : 0, + accept_follows => $user->{accept_follows} == 2 ? 1 : 0, + accept_follow_requests => $user->{accept_follows} == 1 ? 1 : 0, }; } return; @@ -211,9 +213,10 @@ sub set_privacy { if ( not defined $public_level and defined $opt{default_visibility} ) { $public_level = ( $opt{default_visibility} & 0x7f ) - | ( $opt{comments_visible} ? 0x80 : 0x00 ) - | ( ( ( $opt{past_visible} // 0 ) << 8 ) & 0x300 ) - | ( $opt{past_all} ? 0x400 : 0 ) | ( $opt{past_status} ? 0x800 : 0 ); + | ( $opt{comments_visible} ? 0x80 : 0 ) + | ( ( $opt{past_visibility} & 0x7f ) << 8 ) + | ( $opt{past_status} ? 0x08000 : 0 ) + | ( $opt{past_all} ? 0x10000 : 0 ); } $db->update( 'users', { public_level => $public_level }, { id => $uid } ); @@ -416,12 +419,14 @@ sub get { default_visibility => $user->{public_level} & 0x7f, default_visibility_str => $visibility_itoa{ $user->{public_level} & 0x7f }, - comments_visible => $user->{public_level} & 0x80 ? 1 : 0, - past_visible => ( $user->{public_level} & 0x300 ) >> 8, - past_all => $user->{public_level} & 0x400 ? 1 : 0, - past_status => $user->{public_level} & 0x800 ? 1 : 0, - email => $user->{email}, - sb_name => $user->{external_services} + comments_visible => $user->{public_level} & 0x80 ? 1 : 0, + past_visibility => ( $user->{public_level} & 0x7f00 ) >> 8, + past_visibility_str => + $visibility_itoa{ ( $user->{public_level} & 0x7f00 ) >> 8 }, + past_status => $user->{public_level} & 0x08000 ? 1 : 0, + past_all => $user->{public_level} & 0x10000 ? 1 : 0, + email => $user->{email}, + sb_name => $user->{external_services} ? $sb_templates[ $user->{external_services} & 0x07 ][0] : undef, sb_template => $user->{external_services} |