Lines 1-59
Link Here
|
1 |
#!/usr/bin/perl |
|
|
2 |
|
3 |
# Copyright 2014 ByWater Solutions |
4 |
# |
5 |
# This file is part of Koha. |
6 |
# |
7 |
# Koha is free software; you can redistribute it and/or modify it under the |
8 |
# terms of the GNU General Public License as published by the Free Software |
9 |
# Foundation; either version 3 of the License, or (at your option) any later |
10 |
# version. |
11 |
# |
12 |
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY |
13 |
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
14 |
# A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
15 |
# |
16 |
# You should have received a copy of the GNU General Public License along |
17 |
# with Koha; if not, write to the Free Software Foundation, Inc., |
18 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
19 |
|
20 |
use Modern::Perl; |
21 |
|
22 |
use CGI; |
23 |
use JSON qw( to_json ); |
24 |
|
25 |
use C4::Auth; |
26 |
use C4::Context; |
27 |
|
28 |
use Koha::Patrons; |
29 |
|
30 |
my $cgi = CGI->new(); |
31 |
|
32 |
my $privacy_guarantor_fines = $cgi->param('privacy_guarantor_fines'); |
33 |
|
34 |
my ( $userid, $cookie, $sessionID, $flags ) = checkauth( $cgi, 1, {}, 'opac' ); |
35 |
|
36 |
my $borrowernumber = C4::Context->userenv ? C4::Context->userenv->{number} : undef; |
37 |
|
38 |
my $success = 0; |
39 |
if ( $borrowernumber && defined($privacy_guarantor_fines) ) { |
40 |
my $patron = Koha::Patrons->find($borrowernumber); |
41 |
|
42 |
if ( $patron ) { |
43 |
$patron->privacy_guarantor_fines($privacy_guarantor_fines); |
44 |
$success = $patron->store(); |
45 |
} |
46 |
} |
47 |
|
48 |
binmode STDOUT, ":encoding(UTF-8)"; |
49 |
print $cgi->header( |
50 |
-type => 'application/json', |
51 |
-charset => 'UTF-8' |
52 |
); |
53 |
|
54 |
print to_json( |
55 |
{ |
56 |
success => $success ? 1 : 0, |
57 |
privacy_guarantor_fines => $privacy_guarantor_fines, |
58 |
} |
59 |
); |
60 |
- |