X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2Fstemmaweb%2FController%2FStexaminer.pm;h=80d8827529ac977ecb31b33a76c6e9d8aa685cb7;hb=847e1ac6bbf676c2a7c9356918ba95f6e98cea60;hp=d40ecbc9591742b08331bffb61e3e3c07769b5e2;hpb=98a45925bfa64fc1e29c0841ecf88aba96908de4;p=scpubgit%2Fstemmaweb.git diff --git a/lib/stemmaweb/Controller/Stexaminer.pm b/lib/stemmaweb/Controller/Stexaminer.pm index d40ecbc..80d8827 100644 --- a/lib/stemmaweb/Controller/Stexaminer.pm +++ b/lib/stemmaweb/Controller/Stexaminer.pm @@ -37,7 +37,7 @@ sub index :Path :Args(2) { my $ok = _check_permission( $c, $tradition ); return unless $ok; if( $tradition->stemma_count ) { - my $stemma = $tradition->stemma(0); + my $stemma = $tradition->stemma( $stemid ); $c->stash->{svg} = $stemma->as_svg( { size => [ 600, 350 ] } ); $c->stash->{graphdot} = $stemma->editable({ linesep => ' ' }); $c->stash->{text_title} = $tradition->name; @@ -101,19 +101,17 @@ sub _check_permission { my( $c, $tradition ) = @_; 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 ); - return 1; - } elsif( $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; + return 'full' if ( $user->is_admin || + ( $tradition->has_user && $tradition->user->id eq $user->id ) ); } + # 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->forward('View::Plain'); + return 0; } =head2 graphsvg