Ticket #3569: RequestCopy_name_and_org.patch

File RequestCopy_name_and_org.patch, 5.0 KB (added by tmb, 5 years ago)
  • perl_lib/EPrints/Plugin/Screen/Public/RequestCopy.pm

    old new  
    9494        my $session = $self->{session}; 
    9595 
    9696        my $email = $session->param( "requester_email" ); 
     97        my $org = $session->param( "requester_org" ); 
     98        my $given = $session->param( "requester_name_given" ); 
     99        my $family = $session->param( "requester_name_family" ); 
     100        my $reason = $session->param( "reason" ); 
     101 
     102        unless( defined $email && $email ne ""  
     103                && EPrints::Utils::is_set( $org )  
     104                && EPrints::Utils::is_set( $given )  
     105                && EPrints::Utils::is_set( $family )  
     106        ) 
     107        { 
     108                $self->{processor}->{requester_email} = $email if EPrints::Utils::is_set( $email ); 
     109                $self->{processor}->{requester_org} = $org if EPrints::Utils::is_set( $org ); 
     110                $self->{processor}->{requester_name_given} = $given if EPrints::Utils::is_set( $given ); 
     111                $self->{processor}->{requester_name_family} = $family if EPrints::Utils::is_set( $family ); 
     112                $self->{processor}->{reason} = $reason if EPrints::Utils::is_set( $reason ); 
    97113 
    98         unless( defined $email && $email ne "" ) 
    99         { 
    100114                $self->{processor}->add_message( "error", $session->html_phrase( "request:no_email" ) ); 
    101115                return; 
    102116        } 
     
    111125        $data->{docid} = $doc->get_id if defined $doc; 
    112126        $data->{requester_email} = $email; 
    113127        $data->{email} = $contact_email; 
     128        $data->{requester_org} = $org; 
     129        $data->{requester_name} = { 
     130                given => $given, 
     131                family => $family, 
     132        }; 
    114133 
    115134        my $user = EPrints::DataObj::User::user_with_email( $session, $contact_email ); 
    116135        $data->{userid} = $user->get_id if defined $user; 
    117136 
    118         my $reason = $session->param( "reason" ); 
    119137        $data->{reason} = $reason if EPrints::Utils::is_set( $reason ); 
    120138 
    121139        my $request = $session->get_repository->get_dataset( "request" )->create_object( $session, $data ); 
     
    141159 
    142160        # Send request email 
    143161        my $subject = $session->phrase( "request/request_email:subject", eprint => $eprint->get_value( "title" ) ); 
     162        my $requester_details = $session->html_phrase( "request/request_email:requester_details", 
     163                name => $session->make_text( EPrints::Utils::make_name_string( $request->get_value( "requester_name" ), 1 ) ), 
     164                email => $request->render_value( "requester_email" ), 
     165                org => $request->render_value( "requester_org" ), 
     166        ); 
    144167        my $mail = $session->make_element( "mail" ); 
    145168        $mail->appendChild( $session->html_phrase( 
    146169                "request/request_email:body",  
    147170                eprint => $eprint->render_citation_link_staff, 
    148171                document => defined $doc ? $doc->render_value( "main" ) : $session->make_doc_fragment, 
    149                 requester => $session->make_text( $email ), 
     172                requester => $requester_details, 
    150173                reason => EPrints::Utils::is_set( $reason ) ? $session->make_text( $reason ) 
    151174                        : $session->html_phrase( "Plugin/Screen/EPrint/RequestRemoval:reason" ) ) ); 
    152175 
     
    186209                        message => $mail, 
    187210                        sig => $session->html_phrase( "mail_sig" ), 
    188211                        replyto_email => $email, 
     212                        replyto_name => EPrints::Utils::tree_to_utf8( $request->render_value( "requester_name" ) ), 
    189213                ); 
    190214        } 
    191215 
     
    206230                session => $session, 
    207231                langid => $session->get_langid, 
    208232                to_email => $email, 
     233                to_name => EPrints::Utils::tree_to_utf8( $request->render_value( "requester_name" ) ), 
    209234                subject => $session->phrase( "request/ack_email:subject", eprint=>$eprint->get_value( "title" ) ),  
    210235                message => $mail, 
    211236                sig => $session->html_phrase( "mail_sig" ) 
     
    238263        { 
    239264                $url.="&request_sent=".$self->{processor}->{request_sent}; 
    240265        } 
     266        return $url if defined $self->{processor}->{request_sent}; 
     267        $url.="&requester_email=".$self->{processor}->{requester_email} if defined $self->{processor}->{requester_email}; 
     268        $url.="&requester_org=".$self->{processor}->{requester_org} if defined $self->{processor}->{requester_org}; 
     269        $url.="&requester_name_given=".$self->{processor}->{requester_name_given} if defined $self->{processor}->{requester_name_given}; 
     270        $url.="&requester_name_family=".$self->{processor}->{requester_name_family} if defined $self->{processor}->{requester_name_family}; 
     271        $url.="&reason=".$self->{processor}->{reason} if defined $self->{processor}->{reason}; 
    241272        return $url; 
    242273}  
    243274 
     
    262293 
    263294        my $form = $session->render_input_form( 
    264295                fields => [  
     296                        $session->get_repository->get_dataset( "request" )->get_field( "requester_name" ), 
    265297                        $session->get_repository->get_dataset( "request" )->get_field( "requester_email" ), 
     298                        $session->get_repository->get_dataset( "request" )->get_field( "requester_org" ), 
    266299                        $session->get_repository->get_dataset( "request" )->get_field( "reason" ), 
    267300                ], 
     301                values => { 
     302                        requester_name => { 
     303                                given => $session->param( "requester_name_given" ) || "", 
     304                                family => $session->param( "requester_name_family" ) || "", 
     305                        }, 
     306                        requester_email => $session->param( "requester_email" ) || "", 
     307                        requester_org => $session->param( "requester_org" ) || "", 
     308                        reason => $session->param( "reason" ) || "", 
     309                }, 
    268310                show_names => 1, 
    269311                show_help => 1, 
    270312                buttons => { request => $session->phrase( "request:button" ) },