Jump to content
Wiki Home
EPrints Home
Bazaar
Files
Main menu
Main menu
move to sidebar
hide
Navigation
Front Page
EPrints 3 Manual
EPrints Training Course
EPrints Glossary
Installing EPrints
How-to Configure EPrints
EPrints 3.2+ API
EPrints 3 Reference
EPrints Plugins
Wiki
All categories
Recent changes
Main Page
Help
EPrints Documentation
Search
Search
Appearance
Log in
Request account
Personal tools
Log in
Request account
Pages for logged out editors
learn more
Contributions
Talk
Editing
Altering the 'Request a copy' function
(section)
Page
Discussion
British English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==== Edit the local copy of the plugin ==== The package name and 'isa' need to be updated as this is a subclass of the existing plugin. Any methods that you don't need to change can also be removed (as they'll be inherited from the main RequestCopy module). '''PLEASE NOTE the example code below may have been taken from a different version of EPrints to the one you are running. DO NOT just copy and paste it. Please follow the process above to take a copy of RequestCopy from your server, and edit it!''' The changes are indicated with <code>### INSERTED CODE ###</code> comments. <source lang="perl"> ################################# # Example taken from https://github.com/eprints/eprints/blob/v3.3.16/perl_lib/EPrints/Plugin/Screen/Public/RequestCopy.pm ################################# package EPrints::Plugin::Screen::Public::RequestCopy::LocalRequestCopy; @ISA = ( 'EPrints::Plugin::Screen::Public::RequestCopy' ); use strict; sub action_request { my( $self ) = @_; my $session = $self->{session}; my $request = $self->{processor}->{dataobj}; my $rc = $self->workflow->update_from_form( $self->{processor} ); return if !$rc; # validation failed my $email = $request->value( "requester_email" ); my $use_pin_security = $session->config( 'use_request_copy_pin_security' ); my $eprint = $self->{processor}->{eprint}; my $doc = $self->{processor}->{document}; my $contact_email = $self->{processor}->{contact_email}; my $user = EPrints::DataObj::User::user_with_email( $session, $contact_email ); if( defined $user ) { $request->set_value( "userid", $user->id ); } $request = $self->{processor}->{dataset}->create_dataobj( $request->get_data ); my $history_data = { datasetid=>"request", objectid=>$request->get_id, action=>"create", }; if( defined $self->{processor}->{user} ) { $history_data->{userid} = $self->{processor}->{user}->get_id; } else { $history_data->{actor} = $email; } # Log request creation event my $history_ds = $session->dataset( "history" ); $history_ds->create_object( $session, $history_data ); # Send request email my $subject = $session->phrase( "request/request_email:subject", eprint => $eprint->get_value( "title" ) ); my $mail = $session->make_element( "mail" ); $mail->appendChild( $session->html_phrase( "request/request_email:body", eprint => $eprint->render_citation_link_staff, document => defined $doc ? $doc->render_value( "main" ) : $session->make_doc_fragment, requester => $request->render_citation( "requester" ), ### INSERTED CODE ### # this checks whether the value is set, and returns either the rendered value, or an empty document fragment # the pins for a phrase must be XML fragments - not scalar values. # The corresponding phrase (request/request_email:body) must also be updated to expect the new data. contact_num => $request->is_set( "contact_num" ) ? $request->render_value( "contact_num" ) : $session->make_doc_fragment, id_num => $request->is_set( "id_num" ) ? $request->render_value( "id_num" ) : $session->make_doc_fragment, ### END INSERTED CODE ### reason => $request->is_set( "reason" ) ? $request->render_value( "reason" ) : $session->html_phrase( "Plugin/Screen/EPrint/RequestRemoval:reason" ) ) ); my $result; if( ( defined $user || $use_pin_security ) && defined $doc ) { # Contact is a registered user or it doesn't matter # because we're using the pin security model, and # EPrints holds the requested document # Send email to contact with accept/reject links my $url; if ( $use_pin_security ) { # Handle the response via a non-authenticated CGI script $url = $session->get_url( host => 1, path => "cgi", "respond_to_doc_request" ); $url->query_form( pin => $request->get_value( 'pin' ), ); } else { # Handle the response via cgi/users/home which is authenticated $url = $session->get_url( host => 1, path => "cgi", "users/home" ); $url->query_form( screen => "Request::Respond", requestid => $request->id, ); } $mail->appendChild( $session->html_phrase( "request/request_email:links", accept => $session->render_link( "$url&action=accept" ), reject => $session->render_link( "$url&action=reject" ) ) ); my $to_name; if ( defined $user ) { $to_name = EPrints::Utils::tree_to_utf8( $user->render_description ); } else { $to_name = $contact_email; } $result = EPrints::Email::send_mail( session => $session, langid => $session->get_langid, to_name => $to_name, to_email => $contact_email, subject => $subject, message => $mail, sig => $session->html_phrase( "mail_sig" ), cc_list => EPrints::Utils::is_set( $session->config( "request_copy_cc" ) ) ? $session->config( "request_copy_cc" ) : [], ); } else { # Contact is non-registered user or EPrints holds no documents # Send email to contact with 'replyto' $result = EPrints::Email::send_mail( session => $session, langid => $session->get_langid, to_name => defined $user ? EPrints::Utils::tree_to_utf8( $user->render_description ) : "", to_email => $contact_email, subject => $subject, message => $mail, sig => $session->html_phrase( "mail_sig" ), replyto_email => $email, cc_list => EPrints::Utils::is_set( $session->config( "request_copy_cc" ) ) ? $session->config( "request_copy_cc" ) : [], ); } if( !$result ) { $self->{processor}->add_message( "error", $session->html_phrase( "general:email_failed" ) ); return; } # Send acknowledgement to requester $mail = $session->make_element( "mail" ); $mail->appendChild( $session->html_phrase( "request/ack_email:body", document => defined $doc ? $doc->render_value( "main" ) : $session->make_doc_fragment, eprint => $eprint->render_citation_link ) ); $result = EPrints::Email::send_mail( session => $session, langid => $session->get_langid, to_email => $email, subject => $session->phrase( "request/ack_email:subject", eprint=>$eprint->get_value( "title" ) ), message => $mail, sig => $session->html_phrase( "mail_sig" ) ); if( !$result ) { $self->{processor}->add_message( "error", $session->html_phrase( "general:email_failed" ) ); return; } $self->{processor}->add_message( "message", $session->html_phrase( "request/ack_page", link => $session->render_link( $eprint->get_url ) ) ); $self->{processor}->{request_sent} = 1; } 1; </source>
Summary:
Please note that all contributions to EPrints Documentation may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
EPrints Documentation:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)