# EPrints Services/Shelves # add one or several EPrintIds to a Shelf use EPrints; use strict; use warnings; my $session = EPrints::Session->new(); exit(0) unless( defined $session ); my $user = $session->current_user; unless( defined $user ) { $session->send_http_header( content_type => "application/json" ); print STDOUT JSON::encode_json( { error => '
You must login to use the Shelves
' } ); $session->terminate; return; } my $shelfid = $session->param( 'shelfid' ); my $eprintids = $session->param( 'eprintids' ); unless( defined $shelfid && defined $eprintids ) { $session->terminate; return; } # instanciate shelf, check current user has the perms to write to it my $shelf = $session->dataset( 'shelf' )->dataobj( $shelfid ); unless( defined $shelf ) { $session->send_http_header( content_type => "application/json" ); print STDOUT JSON::encode_json( { error => '
Shelf #'.$shelfid.' does not exist.
' } ); $session->terminate; return; } unless( $shelf->has_editor( $user ) ) { $session->send_http_header( content_type => "application/json" ); print STDOUT JSON::encode_json( { error => '
You may not modify this Shelf.
' } ); $session->terminate; return; } # instanciate eprintid? or just add to shelf... my @ids = split( ',', $eprintids ); if(scalar(@ids)) { $shelf->add_items( @ids ); } $session->terminate;