<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/usr/bin/perl
use EPrints;
use strict;

my $ep = EPrints-&gt;new();
my $repo = $ep-&gt;current_repository;
return unless( defined $repo );

my $params_defined = 1;

my $collection_eprintid = $repo-&gt;param( 'collection_eprintid' );
$params_defined &amp;&amp;= defined $collection_eprintid;

my $eprintid = $repo-&gt;param( 'eprinttoadd' );
$params_defined &amp;&amp;= ( defined $eprintid &amp;&amp; $eprintid =~ /^\d+$/ );

my $fieldname = $repo-&gt;param( 'fieldname' );
$params_defined &amp;&amp;= defined $fieldname;

my $action = $repo-&gt;param( 'action' );
$params_defined &amp;&amp;= defined $action;

my $user = $repo-&gt;current_user;
$params_defined &amp;&amp;= defined $user;

unless( $params_defined )
{
	return;
}

my $collection = $repo-&gt;eprint( $collection_eprintid );
unless( defined $collection )
{
	return;
}
# can user edit?
unless( $repo-&gt;current_user-&gt;allow( "eprint/edit" ) )
{
	return;
}

if( $collection-&gt;get_type ne 'collection' )
{
	return;
}

if( $action eq "add" )
{
	$collection-&gt;add_to_collection( $eprintid );
}

if( $action eq "remove" ) 
{
	$collection-&gt;remove_from_collection( $eprintid );
}

my $blacklist = $collection-&gt;get_blacklist( $fieldname );
my $div = EPrints::Plugin::InputForm::Component::Field::CollectionSelect::_render_selected_eprints( $repo, $collection, $fieldname, $blacklist );
print STDOUT $div-&gt;toString if( defined $div );

return;

</pre></body></html>