From f8132c1f31b3fae69df1624438c81ffeb0e0e7bd Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 26 Feb 2020 11:59:34 +0100 Subject: [PATCH] Bug 4461: Simplify recipients code As the feature is now turned off without KohaAdminEmailAddress, we only need to check if the email address of the library if defined. Not that we should not check for $library->branchreplyto or ReplytoDefault, but only $library->branchemail, as we do everywhere else (I think) Signed-off-by: Martin Renvoize Signed-off-by: David Nind Signed-off-by: Jonathan Druart --- .../en/modules/opac-reportproblem.tt | 100 +++++++++--------- opac/opac-reportproblem.pl | 31 +----- 2 files changed, 54 insertions(+), 77 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reportproblem.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reportproblem.tt index 965fefd0de..038e8462d6 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reportproblem.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reportproblem.tt @@ -25,57 +25,57 @@ [% ELSE %]
[% END %] -

Report a problem

+

Report a problem

- [% IF ( successfuladd ) %] -
Your problem report has been sent to the [% IF ( recipient == 'admin' ) %]Koha Administrator[% ELSE %][% recipient | html %][% END %].
- [% END %] - [% IF ( ( nolibemail and noadminemail ) or norecipients ) %] -
Unable to send problem reports.
- [% ELSE %] -
-
- -
-
    -
  1. - - [% IF !nolibemail and noadminemail %] - - [% ELSIF !noadminemail and nolibemail %] - - [% ELSE %] - - [% END %] -
  2. -
  3. - - - [% probpage | html %] -
  4. -
  5. - - - [% username | html %] -
  6. - - -
  7. -
  8. - - -
  9. -
-
-
- -
-
-
- [% END %] + [% IF ( successfuladd ) %] +
+ [% IF recipient == 'admin' %] + Your problem report has been sent to the Koha administrator. + [% ELSE %] + Your problem report has been sent to the library. + [% END %] +
+ [% END %] +
+
+ +
+
    +
  1. + + [% IF library.branchemail %] + + [% ELSE %] + Koha administrator + [% END %] +
  2. +
  3. + + + [% probpage | html %] +
  4. +
  5. + + + [% username | html %] +
  6. + + +
  7. +
  8. + + +
  9. +
+
+
+ +
+
+
diff --git a/opac/opac-reportproblem.pl b/opac/opac-reportproblem.pl index e12c5d5562..2d4d8b174d 100644 --- a/opac/opac-reportproblem.pl +++ b/opac/opac-reportproblem.pl @@ -52,40 +52,20 @@ my $member = Koha::Patrons->find($borrowernumber); my $username = $member->userid; my $branchcode = $member->branchcode; my $library = Koha::Libraries->find($branchcode); -my $recipients = 2; - -if ( - ( !defined($library->branchreplyto) || $library->branchreplyto eq '' ) && - ( C4::Context->preference('ReplytoDefault') eq '' ) && - ( !defined($library->branchemail) || $library->branchemail eq '' ) - ) { - $template->param( nolibemail => 1 ); - $recipients--; -} - -my $koha_admin = C4::Context->preference('KohaAdminEmailAddress'); -if ( $koha_admin eq '' ) { - $template->param( noadminemail => 1 ); - $recipients--; -} $template->param( username => $username, probpage => $problempage, + library => $library, ); my $op = $input->param('op') || ''; if ( $op eq 'addreport' ) { - if ( $recipients == 0 ){ - print $input->redirect("/cgi-bin/koha/opac-reportproblem?norecipients=1.pl"); - exit; - } - my $subject = $input->param('subject'); my $message = $input->param('message'); my $place = $input->param('place'); - my $recipient = $input->param('recipient') || 'library'; + my $recipient = $input->param('recipient') || 'admin'; my $problem = Koha::ProblemReport->new( { title => $subject, @@ -121,18 +101,15 @@ if ( $op eq 'addreport' ) { letter => $letter, borrowernumber => $borrowernumber, message_transport_type => $transport, - to_address => $koha_admin, + to_address => C4::Context->preference('KohaAdminEmailAddress'), from_address => $from_address, }); } else { - my $to_address = $library->branchreplyto || - C4::Context->preference('ReplytoDefault') || - $library->branchemail; C4::Letters::EnqueueLetter({ letter => $letter, borrowernumber => $borrowernumber, message_transport_type => $transport, - to_address => $to_address, + to_address => $library->branchemail, from_address => $from_address, }); } -- 2.20.1