diff options
| author | Daniel Friesel <derf@finalrewind.org> | 2019-12-08 11:06:17 +0100 | 
|---|---|---|
| committer | Daniel Friesel <derf@finalrewind.org> | 2019-12-08 11:06:17 +0100 | 
| commit | 561ff4574bb6078ce4c9f72647a9c3d1a92cac6e (patch) | |
| tree | 1402b28d03434d2c59207f31e2d192b044797bac /lib/Travelynx/Controller | |
| parent | 402a5597f5d095b059e8ee1a4a8b653c3187ff93 (diff) | |
Allow status visibility to be limited to travelynx users
Diffstat (limited to 'lib/Travelynx/Controller')
| -rw-r--r-- | lib/Travelynx/Controller/Account.pm | 18 | ||||
| -rwxr-xr-x | lib/Travelynx/Controller/Traveling.pm | 19 | 
2 files changed, 31 insertions, 6 deletions
| diff --git a/lib/Travelynx/Controller/Account.pm b/lib/Travelynx/Controller/Account.pm index 39335b9..cef79a5 100644 --- a/lib/Travelynx/Controller/Account.pm +++ b/lib/Travelynx/Controller/Account.pm @@ -215,15 +215,21 @@ sub privacy {  	my $public_level = $user->{is_public};  	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 &= ~0x01;  		}  		else { -			$public_level &= ~0x02; +			$public_level &= ~0x03;  		}  		# 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;  		} @@ -236,7 +242,11 @@ sub privacy {  		$self->redirect_to('account');  	}  	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->render( 'privacy', name => $user->{name} );  	} diff --git a/lib/Travelynx/Controller/Traveling.pm b/lib/Travelynx/Controller/Traveling.pm index 3f8f37e..7b48d28 100755 --- a/lib/Travelynx/Controller/Traveling.pm +++ b/lib/Travelynx/Controller/Traveling.pm @@ -35,7 +35,13 @@ sub user_status {  	my $ts   = $self->stash('ts');  	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 %tw_data = ( @@ -81,6 +87,9 @@ sub user_status {  			twitter      => \%tw_data,  		);  	} +	elsif ( $user->{public_level} & 0x01 ) { +		$self->render( 'login', redirect_to => $self->req->url ); +	}  	else {  		$self->render('not_found');  	} @@ -94,7 +103,13 @@ sub public_status_card {  	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} );  		$self->render(  			'_public_status_card', | 
