From a6e2abdb93dd8baf9ee0a8688a1af204fb8adc60 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 25 Apr 2024 09:59:50 +0100 Subject: [PATCH] Bug 29393: (QA follow-up) Tidy add_message.pl Signed-off-by: Martin Renvoize Signed-off-by: Katrin Fischer --- circ/add_message.pl | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/circ/add_message.pl b/circ/add_message.pl index d5c1ad0640..08cf1e4d9f 100755 --- a/circ/add_message.pl +++ b/circ/add_message.pl @@ -21,8 +21,8 @@ use Modern::Perl; use CGI qw ( -utf8 ); -use C4::Auth qw( get_template_and_user ); -use C4::Output qw( output_and_exit ); +use C4::Auth qw( get_template_and_user ); +use C4::Output qw( output_and_exit ); use C4::Letters qw( GetPreparedLetter EnqueueLetter ); use Koha::Patron::Message; use Koha::Patrons; @@ -30,10 +30,11 @@ use Koha::Patrons; my $input = CGI->new; my ( $template, $loggedinuser, $cookie ) = get_template_and_user( - { template_name => "circ/circulation.tt", - query => $input, - type => "intranet", - flagsrequired => { borrowers => 'edit_borrowers' }, + { + template_name => "circ/circulation.tt", + query => $input, + type => "intranet", + flagsrequired => { borrowers => 'edit_borrowers' }, } ); @@ -47,11 +48,10 @@ my $borrower_subject = $input->param('borrower_subject'); my $letter_code = $input->param('select_patron_notice'); my $batch = $input->param('batch'); -if ( $op eq 'cud-edit_message' && $message_id) { +if ( $op eq 'cud-edit_message' && $message_id ) { my $message = Koha::Patron::Messages->find($message_id); $message->update( { message => $borrower_message } ) if $message; -} -elsif( $op eq 'cud-add_message' ) { +} elsif ( $op eq 'cud-add_message' ) { if ( $message_type eq 'L' or $message_type eq 'B' ) { Koha::Patron::Message->new( { @@ -64,9 +64,9 @@ elsif( $op eq 'cud-add_message' ) { } if ( $message_type eq 'E' ) { - my $logged_in_patron = Koha::Patrons->find( $loggedinuser ); - if ( !$logged_in_patron->has_permission({ borrowers => 'send_messages_to_borrowers' }) ) { - C4::Output::output_and_exit( $input, $cookie, $template, 'insufficient_permission' ) + my $logged_in_patron = Koha::Patrons->find($loggedinuser); + if ( !$logged_in_patron->has_permission( { borrowers => 'send_messages_to_borrowers' } ) ) { + C4::Output::output_and_exit( $input, $cookie, $template, 'insufficient_permission' ); } my $letter = { @@ -74,23 +74,21 @@ elsif( $op eq 'cud-add_message' ) { content => $borrower_message }; - my $patron = Koha::Patrons->find( $borrowernumber ); + my $patron = Koha::Patrons->find($borrowernumber); - if ( $letter_code ) { + if ($letter_code) { $letter = C4::Letters::GetPreparedLetter( module => 'add_message', letter_code => $letter_code, lang => $patron->lang, - tables => { - 'borrowers' => $borrowernumber - }, + tables => { 'borrowers' => $borrowernumber }, ); } C4::Letters::EnqueueLetter( { - letter => $letter, - borrowernumber => $borrowernumber, + letter => $letter, + borrowernumber => $borrowernumber, message_transport_type => 'email', } ) or warn "can't enqueue letter"; @@ -98,8 +96,9 @@ elsif( $op eq 'cud-add_message' ) { } my $url = $input->referer; -if ( $url ) { +if ($url) { if ( $url =~ m|circulation\.pl$| ) { + # Trick for POST form from batch checkouts $url .= "?borrowernumber=$borrowernumber"; $url .= "&batch=1" if $batch; -- 2.39.5