From: Joris van Zundert Date: Fri, 31 Aug 2012 22:11:20 +0000 (+0200) Subject: Merge branch 'master' of github.com:tla/stemmatology X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=210142377733aef217db6fe779386ea793be59e9;hp=eb9838ec3810febc38481cc31415780f79bf8a4f;p=scpubgit%2Fstemmatology.git Merge branch 'master' of github.com:tla/stemmatology --- diff --git a/script/dblookup.pl b/script/dblookup.pl index 2346fde..16ee440 100755 --- a/script/dblookup.pl +++ b/script/dblookup.pl @@ -67,7 +67,8 @@ if( $list ) { next unless grep { $_ eq $tid } @uuids; } my $t = $kdb->lookup( $tid ); - print STDERR "$tid: Tradition '" . $t->name . "'\n"; + my $tstr = $t->public ? 'Public tradition' : 'Tradition'; + print STDERR "$tid: $tstr '" . $t->name . "'\n"; my @wits = map { $_->sigil } $t->witnesses; print STDERR "...with witnesses @wits\n"; my $c = $t->collation; diff --git a/stemmaweb/lib/stemmaweb/Controller/Relation.pm b/stemmaweb/lib/stemmaweb/Controller/Relation.pm index 961cfa1..2e9d444 100644 --- a/stemmaweb/lib/stemmaweb/Controller/Relation.pm +++ b/stemmaweb/lib/stemmaweb/Controller/Relation.pm @@ -381,18 +381,20 @@ sub _check_permission { my $user = $c->user_exists ? $c->user->get_object : undef; if( $user ) { $c->stash->{'permission'} = 'full' - if( $user->is_admin || $tradition->user->id eq $user->id ); + if( $user->is_admin || + ( $tradition->has_user && $tradition->user->id eq $user->id ) ); return 1; - } elsif( $tradition->public ) { + } + # Is it public? + if( $tradition->public ) { $c->stash->{'permission'} = 'readonly'; return 1; - } else { - # Forbidden! - $c->response->status( 403 ); - $c->response->body( 'You do not have permission to view this tradition.' ); - $c->detach( 'View::Plain' ); - return 0; - } + } + # Forbidden! + $c->response->status( 403 ); + $c->response->body( 'You do not have permission to view this tradition.' ); + $c->detach( 'View::Plain' ); + return 0; } sub _clean_booleans { diff --git a/stemmaweb/lib/stemmaweb/Controller/Root.pm b/stemmaweb/lib/stemmaweb/Controller/Root.pm index 7e9ff2b..3ff836f 100644 --- a/stemmaweb/lib/stemmaweb/Controller/Root.pm +++ b/stemmaweb/lib/stemmaweb/Controller/Root.pm @@ -291,10 +291,11 @@ sub _check_permission { if( $user ) { return 'full' if ( $user->is_admin || ( $tradition->has_user && $tradition->user->id eq $user->id ) ); - } elsif( $tradition->public ) { - return 'readonly'; - } - # else Forbidden! + } + # Text doesn't belong to us, so maybe it's public? + return 'readonly' if $tradition->public; + + # ...nope. Forbidden! $c->response->status( 403 ); $c->response->body( 'You do not have permission to view this tradition.' ); $c->detach( 'View::Plain' ); diff --git a/stemmaweb/lib/stemmaweb/Controller/Stexaminer.pm b/stemmaweb/lib/stemmaweb/Controller/Stexaminer.pm index d40ecbc..36679ee 100644 --- a/stemmaweb/lib/stemmaweb/Controller/Stexaminer.pm +++ b/stemmaweb/lib/stemmaweb/Controller/Stexaminer.pm @@ -102,18 +102,20 @@ sub _check_permission { my $user = $c->user_exists ? $c->user->get_object : undef; if( $user ) { $c->stash->{'permission'} = 'full' - if( $user->is_admin || $tradition->user->id eq $user->id ); + if( $user->is_admin || + ( $tradition->has_user && $tradition->user->id eq $user->id ) ); return 1; - } elsif( $tradition->public ) { + } + # Is it public? + if( $tradition->public ) { $c->stash->{'permission'} = 'readonly'; return 1; - } else { - # Forbidden! - $c->response->status( 403 ); - $c->response->body( 'You do not have permission to view this tradition.' ); - $c->detach( 'View::Plain' ); - return 0; - } + } + # Forbidden! + $c->response->status( 403 ); + $c->response->body( 'You do not have permission to view this tradition.' ); + $c->detach( 'View::Plain' ); + return 0; } =head2 graphsvg