|
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 44-54
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
Link Here
|
| 44 |
type => "opac", |
40 |
type => "opac", |
| 45 |
} |
41 |
} |
| 46 |
); |
42 |
); |
|
|
43 |
my $patron = Koha::Patrons->find($borrowernumber); |
| 44 |
my $user_email = $patron ? $patron->notice_email_address : undef; |
| 47 |
|
45 |
|
| 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 ( $email_add ) { |
49 |
if ( $email_add && $user_email ) { |
| 52 |
die "Wrong CSRF token" |
50 |
die "Wrong CSRF token" |
| 53 |
unless Koha::Token->new->check_csrf( |
51 |
unless Koha::Token->new->check_csrf( |
| 54 |
{ |
52 |
{ |
|
Lines 57-65
if ( $email_add ) {
Link Here
|
| 57 |
} |
55 |
} |
| 58 |
); |
56 |
); |
| 59 |
|
57 |
|
| 60 |
my $patron = Koha::Patrons->find($borrowernumber); |
|
|
| 61 |
my $user_email = $patron->notice_email_address; |
| 62 |
|
| 63 |
my $comment = $query->param('comment'); |
58 |
my $comment = $query->param('comment'); |
| 64 |
|
59 |
|
| 65 |
my @bibs = split( /\//, $bib_list ); |
60 |
my @bibs = split( /\//, $bib_list ); |
|
Lines 70-81
if ( $email_add ) {
Link Here
|
| 70 |
} |
65 |
} |
| 71 |
|
66 |
|
| 72 |
if ( !defined $iso2709 ) { |
67 |
if ( !defined $iso2709 ) { |
| 73 |
carp "Error sending mail: empty basket"; |
68 |
$template->param( error => 'NO_BODY' ); |
| 74 |
$template->param( error => 1 ); |
|
|
| 75 |
} |
| 76 |
elsif ( !defined $user_email or $user_email eq '' ) { |
| 77 |
carp "Error sending mail: sender's email address is invalid"; |
| 78 |
$template->param( error => 1 ); |
| 79 |
} |
69 |
} |
| 80 |
else { |
70 |
else { |
| 81 |
my %loops = ( biblio => \@bibs, ); |
71 |
my %loops = ( biblio => \@bibs, ); |
|
Lines 118-125
if ( $email_add ) {
Link Here
|
| 118 |
$template->param( email_add => $email_add ); |
108 |
$template->param( email_add => $email_add ); |
| 119 |
output_html_with_http_headers $query, $cookie, $template->output, undef, |
109 |
output_html_with_http_headers $query, $cookie, $template->output, undef, |
| 120 |
{ force_no_caching => 1 }; |
110 |
{ force_no_caching => 1 }; |
| 121 |
} |
111 |
|
| 122 |
else { |
112 |
} elsif( !$user_email ) { |
|
|
113 |
$template->param( email_add => 1, error => 'NO_REPLY_ADDRESS' ); |
| 114 |
output_html_with_http_headers $query, $cookie, $template->output; |
| 115 |
|
| 116 |
} else { |
| 123 |
my $new_session_id = $query->cookie('CGISESSID'); |
117 |
my $new_session_id = $query->cookie('CGISESSID'); |
| 124 |
$template->param( |
118 |
$template->param( |
| 125 |
bib_list => $bib_list, |
119 |
bib_list => $bib_list, |
| 126 |
- |
|
|