From 0d2504fe478236db7838e8e6b8cdfb8adaa7e2e4 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Mon, 16 Jun 2014 04:52:06 -0400 Subject: [PATCH] Bug 9303 [QA Followup 6] - Allow patrons to set visibility from "your personal details" --- installer/data/mysql/updatedatabase.pl | 12 +++- .../bootstrap/en/modules/opac-memberentry.tt | 35 +++++++++++ .../opac-tmpl/prog/en/modules/opac-memberentry.tt | 35 +++++++++++ opac/svc/patron/show_checkouts_to_relatives | 60 ++++++++++++++++++++ 4 files changed, 140 insertions(+), 2 deletions(-) create mode 100755 opac/svc/patron/show_checkouts_to_relatives diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 54df81a..38bb052 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -8570,10 +8570,18 @@ if(CheckVersion($DBversion)) { ALTER TABLE deletedborrowers ADD privacy_relative_checkouts BOOLEAN NOT NULL DEFAULT '0' }); $dbh->do(q{ - ALTER TABLE old_issues ADD issue_id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST + ALTER TABLE old_issues + DROP PRIMARY KEY, + ADD issue_id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST, + DROP INDEX itemnumber_idx, + ADD UNIQUE itemnumber_idx (itemnumber); }); $dbh->do(q{ - ALTER TABLE issues ADD issue_id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST; + ALTER TABLE issues + DROP PRIMARY KEY, + ADD issue_id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST, + DROP INDEX itemnumber_idx, + ADD UNIQUE itemnumber_idx (itemnumber); }); $dbh->do(qq{ UPDATE issues SET issue_id = issue_id + ( SELECT COUNT(*) FROM old_issues ) ORDER BY issue_id DESC 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 4417171..a070061 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt @@ -54,6 +54,27 @@
You typed in the wrong characters in the box before submitting. Please try again.
[% END %] +
+ Privacy +
    +
  1. + + + + Update + + +
  2. +
+
+
[% UNLESS hidden.defined('branchcode') %] @@ -777,6 +798,20 @@ [% ELSE %] $( "#borrower_dateofbirth" ).datepicker({ yearRange: "c-120:c" }); [% END %] + + $('#update_privacy_relative_checkouts').click( function() { + $.post( "/cgi-bin/koha/svc/patron/show_checkouts_to_relatives", { privacy_relative_checkouts: $('#privacy_relative_checkouts').val() }) + .done(function( data ) { + var message; + if ( data.success ) { + message = _("Your setting has been updated!"); + } else { + message = _("Unable to update your setting!"); + } + + $('#update_privacy_relative_checkouts_message').fadeIn("slow").text( message ).delay( 5000 ).fadeOut("slow"); + }); + }); }); //]]> diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-memberentry.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-memberentry.tt index 0e21010..d35706a 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-memberentry.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-memberentry.tt @@ -20,6 +20,20 @@ [% ELSE %] $( "#borrower_dateofbirth" ).datepicker({ yearRange: "c-120:c" }); [% END %] + + $('#update_privacy_relative_checkouts').click( function() { + $.post( "/cgi-bin/koha/svc/patron/show_checkouts_to_relatives", { privacy_relative_checkouts: $('#privacy_relative_checkouts').val() }) + .done(function( data ) { + var message; + if ( data.success ) { + message = _("Your setting has been updated!"); + } else { + message = _("Unable to update your setting!"); + } + + $('#update_privacy_relative_checkouts_message').fadeIn("slow").text( message ).delay( 5000 ).fadeOut("slow"); + }); + }); }); //]]> @@ -62,6 +76,27 @@
You typed in the wrong characters in the box before submitting. Please try again.
[% END %] +
+ Privacy +
    +
  1. + + + + + + +
  2. +
+
+ [% UNLESS hidden.defined('branchcode') %] diff --git a/opac/svc/patron/show_checkouts_to_relatives b/opac/svc/patron/show_checkouts_to_relatives new file mode 100755 index 0000000..8e26c52 --- /dev/null +++ b/opac/svc/patron/show_checkouts_to_relatives @@ -0,0 +1,60 @@ +#!/usr/bin/perl + +# Copyright 2014 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 3 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 C4::Auth; +use C4::Context; +use Koha::Database; + +use JSON qw( to_json ); + +my $cgi = CGI->new(); + +my $privacy_relative_checkouts = $cgi->param('privacy_relative_checkouts'); + +my ( $userid, $cookie, $sessionID, $flags ) = checkauth( $cgi, 1, {}, 'opac' ); + +my $borrowernumber = + C4::Context->userenv ? C4::Context->userenv->{number} : undef; + +my $success = 0; +if ( $borrowernumber && defined($privacy_relative_checkouts) ) { + my $patron = + Koha::Database->new()->schema()->resultset('Borrower') + ->find($borrowernumber); + + $success = $patron->update( + { privacy_relative_checkouts => $privacy_relative_checkouts } ); +} + +binmode STDOUT, ":encoding(UTF-8)"; +print $cgi->header( + -type => 'application/json', + -charset => 'UTF-8' +); + +print to_json( + { + success => $success ? 1 : 0, + privacy_relative_checkouts => $privacy_relative_checkouts, + } +); -- 1.7.2.5