Difference between revisions of "RequestEprint"

From EPrints Documentation
Jump to: navigation, search
(Install scripts and phrases)
Line 33: Line 33:
  { name => "contact_email", type => "email" },
  { name => "contact_email", type => "email" },
Add a corresponding field to the database - see http://wiki2.eprints.org/w/EPrints2/AddingLiveFields
Add a corresponding field to the database - see http://wiki.eprints.org/w/EPrints2/AddingLiveFields
Add the <tt>contact_email</tt> field to eprint types in <tt>/opt/eprints2/archives/ARCHIVEID/cfg/metadata-types.xml</tt>.
Add the <tt>contact_email</tt> field to eprint types in <tt>/opt/eprints2/archives/ARCHIVEID/cfg/metadata-types.xml</tt>.

Revision as of 12:49, 12 March 2007

The Story

A new feature built into EPrints software could dramatically increase the rate of growth of open access (OA) content deposited in institutional repositories while, perversely it seems, allowing authors to opt out of providing OA. It's extremely simple, and if implemented carefully by the repository can produce immediate results without additional cost or resource implications.



This feature displays a "Request eprint" button on the abstract page of records with:

a) one or more restricted documents b) no documents

By clicking the button, users can submit their email address to EPrints. This generates an email to the author (or other recipient determined by EPrints - see below) requesting the restricted/missing items.

In the case of restricted documents, the email will contain 2 links:

  • Accept request (and optionally make the record Open Access from now on) - EPrints will email the documents to the requester
  • Reject request - EPrints will email the requester a rejection notice (the content of which can be edited)

At no point is the email address of the author (or other recipient) exposed without their consent.

Adding Request Eprint to your repository (2.3.13)

This feature will be part of the next release of EPrints. In the meantime, add the feature to existing releases by following these steps:

"Contact Email" field (optional)

To enable depositors to enter a contact email address directly.

Add an extra field to the eprint dataset in /opt/eprints2/archives/ARCHIVEID/cfg/ArchiveMetadataFieldsConfig.pm:

{ name => "contact_email", type => "email" },

Add a corresponding field to the database - see http://wiki.eprints.org/w/EPrints2/AddingLiveFields

Add the contact_email field to eprint types in /opt/eprints2/archives/ARCHIVEID/cfg/metadata-types.xml.

Add the following to the /opt/eprints2/archives/ARCHIVEID/cfg/phrases-en.xml or similar for whatever languages you support:

   <ep:phrase ref="eprint_fieldname_contact_email">Contact EMail</ep:phrase>
   <ep:phrase ref="eprint_fieldhelp_contact_email">Please enter your email address
     <br />Example: <span class="example">e.prints@soton.ac.uk</span>

Determine recipient of requests

Add an extra method to /opt/eprints2/archives/ARCHIVEID/cfg/ArchiveConfig.pm:

sub email_for_doc_request {
       my ( $session, $eprint ) = @_;
       # To turn off this feature, uncomment the line below
       #return undef;
       if( $eprint->is_set("contact_email") )
               return $eprint->get_value("contact_email");
       my $user = $eprint->get_user;
       if( $user->is_set("email") )
               return $user->get_value("email");
       return $session->get_repository->get_conf("adminemail");

This is how EPrints will determine who to send the request to. The method first checks the contact email field. If this is not set then it looks for the email address of the depositing user. Finally, it falls back to the archive administrator's email.

If you are using the "id" part of the the creators field for email addresses then you could also check there:

if( $eprint->is_set( "creators" ) )
       for( @{ $eprint->get_value( "creators" ) } )
               return $_->{id} if $_->{id} ne "";

Think carefully about how you configure this method

During trials on the University of Southampton Research Repository, this feature generated up to 50 requests per day. You probably don't want all of these requests to end up in the archive administrators inbox!

Install MIME::Lite

The MIME::Lite module is used by the request document scripts for sending email with attachments.

root> perl -MCPAN -e 'install MIME::Lite'

Install scripts and phrases


cp request_doc /opt/eprints2/cgi/
cp respond_doc /opt/eprints2/cgi/users/

Insert the phrases into /opt/eprints2/archives/ARCHIVEID/cfg/phrases-en.xml

Add button rendering

Add the Request eprint button rendering to the eprint_render method in /opt/eprints2/archives/ARCHIVEID/ArchiveRenderConfig.pm:

       # Request eprint
       if( $eprint->is_set( "full_text_status" ) )
               my $status = $eprint->get_value( "full_text_status" );
               if( $status ne "public" )
                       if( $session->get_archive->can_call( "email_for_doc_request" ) )
                               if( defined( $session->get_archive->call( "email_for_doc_request", $session, $eprint ) ) )
                                       # only render if there is a contact email address
                                       my $form = $session->render_form( "post", $session->get_archive->get_conf( "perl_url" ) . "/request_doc" );
                                       $form->appendChild( $session->render_hidden_field( "eprintid", $eprint->get_id ) );
                                       $form->appendChild( $session->render_action_buttons(
                                               "submit" => $session->phrase( "request:button" )
                                       ) );
                                       $page->appendChild( $form );

Note: the can_call function in /opt/eprints2/perl_lib/EPrints/Archive.pm was only introduced in ePrints 2.3.13 those using older versions of ePrints can simply download the newer ePrints, find the function can_call in the Archive.pm and copy it into their own Archive.pm or you could of course upgrade.

Restart apache and run generate_abstracts to make the button appear on existing abstract pages.

The button will only be rendered if the item is not Open Acess AND a contact email can be determined