Files/EditBufHacks

From EPrints Documentation
Jump to: navigation, search

Hacks for the Submission process

The submisson process is quite complex, you need to be careful to do modification on this section of the software. Those hacks are all done on the cgi 'edit_eprint' avaible in the dir .../cgi/users/staff/.

1)Hack to Bc the mail of rejection also to the editor

When a editor reject a paper, he writes a mail to the submitter. To send this mail as Bc you need to work in the sub bounce:

Lines arond 522

       # Get the user's details
       my $user = $eprint->get_user();
       my $editor = $session->current_user();

Lines from 568

       # Successfully transferred, mail the user with the reason
       if( $user->mail(
               "cgi/users/edit_eprint:subject_bounce",
               $mail,
               $session->current_user() ) )
       {
               # Successfully bounced, redirect
               #19/12/2006 TJL to send a copy to editor
               $editor->mail("cgi/users/edit_eprint:subject_bounce", $mail, $session->current_user() );
               $session->redirect( "buffer" );
               return;
       }


2)Hack to send a mail to the submitter when the paper is online.

This function is a option, as default is inactive. When it is active, the submitter receives a mail when his papers is gone on-line in the main archive. To do it you must:

a) add a new field in user metadata, in metadata-types.xml:

  <dataset name="user">
   <type name="user" >
     [...]
     <field name="onlinemail" />
     [...]
   <type name="editor" >
     [...]
     <field name="onlinemail" />
     [...]   
   <type name="admin" >
     [...]
     <field name="onlinemail" />
     [...]

In ArchiveMetadataFieldsConfig.pm:

  $fields->{user} = [
       [...]
       { name => "onlinemail", type => "boolean" },

In phrases-<lng>.xml

<ep:phrase ref="user_fieldname_onlinemail">An Email when the work is online</ep:phrase>

b) If you have a live archive go to http://wiki.eprints.org/w/Adding_a_Field_to_a_Live_Repository to insert the field with SQL in the archive.

c) Insert this sub at the end of the cgi:

sub intoArchMail
{
   my( $session, $eprint ) = @_;
   # Get the user's details
   my $user = $eprint->get_user();
   # We can't send a mail if there's no user associated.
   if( !defined $user ){
       return;
   }
   my $nome = EPrints::Utils::tree_to_utf8( $user->render_value("name") );
   my $start_work = EPrints::Utils::tree_to_utf8( $user->render_value("onlinemail") );
   if ($start_work eq 'Yes') {
       my $mail = $session->make_element( "mail" );
       $mail->appendChild( $session->make_text( "Dear $nome, your work is available on-line in E-LIS site.
                                           If you have questions write to the editor of your country
                                           from http://eprints.rclis.org/staff.html.

                                           Thank you for auto-archive your work" ) );
       $user->mail("cgi/users/edit_eprint:mail_suc_upload", $mail, $session->current_user() );
   }
   return;
}

d)Setup those lines in sub process when the cgi puts the paper in the main archive (line 144-170):

       if( $action eq "_toarchive" )
       {
               # Accept button pressed

               my $dsid = $eprint->get_dataset()->id();

               unless( $eprint->move_to_archive() )
               {
                       $session->render_error( $session->html_phrase(
                               "cgi/users/edit_eprint:cant_move",
                               id=>$session->make_text( $eprintid ) ) );
                       return;
               }

               # Successfully archived, redirect
               if( $dsid eq "buffer" )
               {
                       $session->redirect( "buffer" );
               }
               else
               {
                       $session->redirect( $session->get_archive()->get_conf( "userhome" ) );
               }
               #19/12/2006 TJL to send a mail when paper goes into main archive
               &intoArchMail( $session, $eprint );
               return;
       }

The code of the hacked cgi is avaible from http://eprints.rclis.org/fixsoft/edit_eprint.gz