Lines 21-33
use Modern::Perl;
Link Here
|
21 |
|
21 |
|
22 |
use CGI qw ( -utf8 ); |
22 |
use CGI qw ( -utf8 ); |
23 |
use Encode; |
23 |
use Encode; |
24 |
use Carp qw( carp ); |
|
|
25 |
use Try::Tiny qw( catch try ); |
26 |
|
24 |
|
27 |
use C4::Biblio qw( |
25 |
use C4::Auth qw( get_template_and_user ); |
28 |
GetMarcSubjects |
26 |
use C4::Biblio qw(GetMarcSubjects); |
29 |
); |
|
|
30 |
use C4::Auth qw( get_template_and_user ); |
31 |
use C4::Output qw( output_html_with_http_headers ); |
27 |
use C4::Output qw( output_html_with_http_headers ); |
32 |
use C4::Templates; |
28 |
use C4::Templates; |
33 |
use Koha::Biblios; |
29 |
use Koha::Biblios; |
Lines 43-58
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
Link Here
|
43 |
type => "opac", |
39 |
type => "opac", |
44 |
} |
40 |
} |
45 |
); |
41 |
); |
|
|
42 |
my $patron = Koha::Patrons->find($borrowernumber); |
43 |
my $user_email = $patron ? $patron->notice_email_address : undef; |
46 |
|
44 |
|
47 |
my $op = $query->param('op') || q{}; |
45 |
my $op = $query->param('op') || q{}; |
48 |
my $bib_list = $query->param('bib_list') || ''; |
46 |
my $bib_list = $query->param('bib_list') || ''; |
49 |
my $email_add = $query->param('email_add'); |
47 |
my $email_add = $query->param('email_add'); |
50 |
|
48 |
|
51 |
if ( $op eq "cud-send" && $email_add ) { |
49 |
if ( $op eq "cud-send" && $email_add && $user_email ) { |
52 |
|
|
|
53 |
my $patron = Koha::Patrons->find($borrowernumber); |
54 |
my $user_email = $patron->notice_email_address; |
55 |
|
56 |
my $comment = $query->param('comment'); |
50 |
my $comment = $query->param('comment'); |
57 |
|
51 |
|
58 |
my @bibs = split( /\//, $bib_list ); |
52 |
my @bibs = split( /\//, $bib_list ); |
Lines 63-74
if ( $op eq "cud-send" && $email_add ) {
Link Here
|
63 |
} |
57 |
} |
64 |
|
58 |
|
65 |
if ( !defined $iso2709 ) { |
59 |
if ( !defined $iso2709 ) { |
66 |
carp "Error sending mail: empty basket"; |
60 |
$template->param( error => 'NO_BODY' ); |
67 |
$template->param( error => 1 ); |
|
|
68 |
} |
69 |
elsif ( !defined $user_email or $user_email eq '' ) { |
70 |
carp "Error sending mail: sender's email address is invalid"; |
71 |
$template->param( error => 1 ); |
72 |
} |
61 |
} |
73 |
else { |
62 |
else { |
74 |
my %loops = ( biblio => \@bibs, ); |
63 |
my %loops = ( biblio => \@bibs, ); |
Lines 111-118
if ( $op eq "cud-send" && $email_add ) {
Link Here
|
111 |
$template->param( email_add => $email_add ); |
100 |
$template->param( email_add => $email_add ); |
112 |
output_html_with_http_headers $query, $cookie, $template->output, undef, |
101 |
output_html_with_http_headers $query, $cookie, $template->output, undef, |
113 |
{ force_no_caching => 1 }; |
102 |
{ force_no_caching => 1 }; |
114 |
} |
103 |
|
115 |
else { |
104 |
} elsif( !$user_email ) { |
|
|
105 |
$template->param( email_add => 1, error => 'NO_REPLY_ADDRESS' ); |
106 |
output_html_with_http_headers $query, $cookie, $template->output; |
107 |
|
108 |
} else { |
116 |
my $new_session_id = $query->cookie('CGISESSID'); |
109 |
my $new_session_id = $query->cookie('CGISESSID'); |
117 |
$template->param( |
110 |
$template->param( |
118 |
bib_list => $bib_list, |
111 |
bib_list => $bib_list, |
119 |
- |
|
|