From a5e07f3a6258c58ba7ab925f50ccf511da8736a4 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Thu, 16 Feb 2012 15:25:39 -0500 Subject: [PATCH] Bug 3516 - Display picture of patrons in OPAC Content-Type: text/plain; charset="utf-8" This patch adapts the patron image display script from the self-checkout module to optionally display the image of the logged-in user on their personal information page (opac-userupdate.pl). The script changes the method choosing which image to display from using a passed cardnumber to using the borrowernumber of the logged-in user. A system preference is added, OPACpatronimages, to control whether these images are displayed. --- installer/data/mysql/sysprefs.sql | 1 + installer/data/mysql/updatedatabase.pl | 9 +++- .../prog/en/modules/admin/preferences/opac.pref | 6 ++ .../opac-tmpl/prog/en/modules/opac-userupdate.tt | 8 +++- opac/opac-patron-image.pl | 57 ++++++++++++++++++++ opac/opac-userupdate.pl | 9 +++ 6 files changed, 88 insertions(+), 2 deletions(-) create mode 100755 opac/opac-patron-image.pl diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 0cc79b2..ea8c22a 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -96,6 +96,7 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('opacuserjs','','Define custom javascript for inclusion in OPAC','70|10','Textarea'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('opacuserlogin',1,'Enable or disable display of user login features',NULL,'YesNo'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('patronimages',0,'Enable patron images for the Staff Client',NULL,'YesNo'); +INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACpatronimages',0,'Enable patron images in the OPAC',NULL,'YesNo'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('printcirculationslips',1,'If ON, enable printing circulation receipts','','YesNo'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('RecordLocalUseOnReturn',0,'If ON, statistically record returns of unissued items as local use, instead of return',NULL,'YesNo'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('RequestOnOpac',1,'If ON, globally enables patron holds on OPAC',NULL,'YesNo'); diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 0ef0b1f..7bc3c0a 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -4670,7 +4670,7 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { SetVersion ($DBversion); } -$DBversion = "3.07.00.013"; #FIXME +$DBversion = "3.07.00.013"; if (C4::Context->preference("Version") < TransformToNum($DBversion)) { $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacExportOptions','bibtex|dc|marcxml|marc8|utf8|marcstd|mods|ris','Define available export options on OPAC detail page.','','free');"); print "Upgrade to $DBversion done (Bug 7345: Add system preference OpacExportOptions.)\n"; @@ -4684,6 +4684,13 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { SetVersion($DBversion); } +$DBversion = "3.07.00.XXX"; +if (C4::Context->preference("Version") < TransformToNum($DBversion)) { + $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OPACpatronimages',0,'Enable patron images in the OPAC',NULL,'YesNo');"); + print "Upgrade to $DBversion done (Bug 3516: Add the option to show patron images in the OPAC.)\n"; + SetVersion($DBversion); +} + =head1 FUNCTIONS =head2 DropAllForeignKeys($table) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref index be86733..aa91f2b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref @@ -235,6 +235,12 @@ OPAC: no: "Don't allow" - patrons to notify the library of changes to their contact information from the OPAC. - + - pref: OPACpatronimages + choices: + yes: Show + no: "Don't show" + - patron images on the patron information page in the OPAC. + - - pref: OPACFinesTab choices: yes: Allow diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-userupdate.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-userupdate.tt index 4508fbd..cfccfce 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-userupdate.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-userupdate.tt @@ -14,12 +14,15 @@
[% FOREACH BORROWER_INF IN BORROWER_INFO %] -

[% INCLUDE 'patron-title.inc' ifirstname = BORROWER_INF.firstname surname = BORROWER_INF.surname othernames = BORROWER_INF.othernames cardnumber = BORROWER_INF.cardnumber %]'s account > Your Personal Details

+

[% INCLUDE 'patron-title.inc' firstname = BORROWER_INF.firstname surname = BORROWER_INF.surname othernames = BORROWER_INF.othernames cardnumber = BORROWER_INF.cardnumber %]'s account > Your Personal Details

[% IF ( OPACPatronDetails ) %]
+[% IF ( display_patron_image ) %]

+ +

[% END %]
Name
  1. @@ -105,6 +108,9 @@ [% ELSE %]

    To make changes to your record please contact the library.

    +[% IF ( display_patron_image ) %]

    + +

    [% END %]
    Contact Information
      diff --git a/opac/opac-patron-image.pl b/opac/opac-patron-image.pl new file mode 100755 index 0000000..1935bea --- /dev/null +++ b/opac/opac-patron-image.pl @@ -0,0 +1,57 @@ +#!/usr/bin/perl +# +# Copyright 2009 LibLime +# Parts copyright 2012 Athens County Public Libraries +# +# 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 strict; +use warnings; +use C4::Members; +use C4::Auth; +my $query = new CGI; + +my ( $template, $borrowernumber, $cookie ) = get_template_and_user( + { + template_name => "opac-userupdate.tt", + query => $query, + type => "opac", + authnotrequired => 0, + flagsrequired => { borrow => 1 }, + debug => 1, + } +); + +unless (C4::Context->preference('OPACpatronimages')) { + print $query->header(status => '403 Forbidden - displaying patron images in the OPAC not enabled'); + exit; +} + +my ($borrower)=GetMember('borrowernumber' => $borrowernumber); +my $cardnumber = $borrower->{'cardnumber'}; +my ($imagedata, $dberror) = GetPatronImage($cardnumber); + +if ($dberror) { + print $query->header(status => '500 internal error'); +} + +if ($imagedata) { + print $query->header(-type => $imagedata->{'mimetype'}, + -Content_Length => length ($imagedata->{'imagefile'})), + $imagedata->{'imagefile'}; +} else { + print $query->header(status => '404 patron image not found'); +} diff --git a/opac/opac-userupdate.pl b/opac/opac-userupdate.pl index 297d5be..7402b45 100755 --- a/opac/opac-userupdate.pl +++ b/opac/opac-userupdate.pl @@ -170,6 +170,15 @@ for (@{ $checkout_prefs->{transports} }) { $borr->{"items_borrowed_$_"} = 1; } +if (C4::Context->preference('OPACpatronimages')) { + my ($image, $dberror) = GetPatronImage($borr->{'cardnumber'}); + if ($image) { + $template->param( + display_patron_image => 1 + ); + } +} + my @bordat; $bordat[0] = $borr; -- 1.7.3