X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FText%2FTradition%2FDirectory.pm;h=743ab6c911b3bf66fbb3d024dbd1a3040ed52280;hb=7cb56251fa02e6d1f39ec90a78791118fcc5d287;hp=1f69d94e6ca0be5e1395f938215a8da119a2ee3f;hpb=d1906a56713cd28fa8f7e617e34700c5bb515240;p=scpubgit%2Fstemmatology.git diff --git a/lib/Text/Tradition/Directory.pm b/lib/Text/Tradition/Directory.pm index 1f69d94..743ab6c 100644 --- a/lib/Text/Tradition/Directory.pm +++ b/lib/Text/Tradition/Directory.pm @@ -221,12 +221,11 @@ around BUILDARGS => sub { return $class->$orig( $args ); }; +## These checks don't cover store($id, $obj) before [ qw/ store update insert delete / ] => sub { my $self = shift; my @nontrad; foreach my $obj ( @_ ) { -# if( ref( $obj ) && ref( $obj ) ne 'Text::Tradition' ) { - if( ref( $obj ) && ref( $obj ) ne 'Text::Tradition' && ref ($obj) ne 'Text::Tradition::User' ) { # Is it an id => Tradition hash? @@ -278,7 +277,10 @@ sub user_traditionlist { my ($self, $user) = @_; my @tlist; - if(ref $user) { + if(ref $user && $user->is_admin) { + ## Admin sees all + return $self->traditionlist(); + } elsif(ref $user) { ## We have a user object already, so just fetch its traditions and use tose foreach my $t (@{ $user->traditions }) { push( @tlist, { 'id' => $self->object_to_id( $t ), @@ -366,6 +368,7 @@ sub add_user { my ($self, $userinfo) = @_; my $username = $userinfo->{url} || $userinfo->{username}; my $password = $userinfo->{password}; + my $role = $userinfo->{role} || 'user'; return unless ($username =~ /^https?:/ || ($username && $self->validate_password($password))) ; @@ -373,6 +376,7 @@ sub add_user { my $user = Text::Tradition::User->new( id => $username, password => ($password ? crypt_password($password) : ''), + role => $role, ); $self->store($user->kiokudb_object_id, $user);