From 7e4b649dcfa032c95c844cd14510bf83694d748a Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 11 Feb 2015 09:13:51 -0500 Subject: [PATCH] Bug 9303 [QA Followup] - Restore missing file --- .../bootstrap/en/modules/opac-memberentry.tt | 2 +- opac/svc/patron/show_checkouts_to_relatives | 49 ++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletions(-) create mode 100755 opac/svc/patron/show_checkouts_to_relatives diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt index a7f6160..6c24b01 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt @@ -826,7 +826,7 @@ [% IF borrower.guarantorid && !Koha.Preference('OPACPrivacy') && Koha.Preference('AllowPatronToSetCheckoutsVisibilityForGuarantor') %] $('#update_privacy_guarantor_checkouts').click( function() { - $.post( "/cgi-bin/koha/svc/patron/show_checkouts_to_relatives", { privacy_guarantor_checkouts: $('#privacy_guarantor_checkouts').val() }) + $.post( "/cgi-bin/koha/svc/patron/show_checkouts_to_relatives", { privacy_guarantor_checkouts: $('#privacy_guarantor_checkouts').val() }, null, 'json') .done(function( data ) { var message; if ( data.success ) { diff --git a/opac/svc/patron/show_checkouts_to_relatives b/opac/svc/patron/show_checkouts_to_relatives new file mode 100755 index 0000000..ac57849 --- /dev/null +++ b/opac/svc/patron/show_checkouts_to_relatives @@ -0,0 +1,49 @@ +#!/usr/bin/perl + +# Copyright 2015 ByWater Solutions +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# + +use Modern::Perl; + +use CGI; +use JSON qw(to_json); + +use C4::Auth qw(check_cookie_auth); +use Koha::Database; + +my $cgi = new CGI; + +my $privacy_guarantor_checkouts = $cgi->param('privacy_guarantor_checkouts'); + +my ( $auth_status, $sessionID ) = + check_cookie_auth( $cgi->cookie('CGISESSID') ); +if ( $auth_status ne "ok" ) { + exit 0; +} + +my $borrowernumber = C4::Context->userenv->{'number'}; +my $borrower = Koha::Database->new()->schema()->resultset('Borrower')->find( $borrowernumber ); + +if ( $borrower ) { + $borrower = $borrower->update( { privacy_guarantor_checkouts => $privacy_guarantor_checkouts } ); +} + +binmode STDOUT, ':encoding(UTF-8)'; +print $cgi->header( -type => 'text/plain', -charset => 'UTF-8' ); + +print to_json( { success => $borrower ? 1 : 0 } ); -- 1.7.2.5