From 8653e9b84ba1f56ed038074118c4da53142389f7 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Thu, 16 Feb 2012 15:25:39 -0500 Subject: [PATCH] Bug 3516 [REVISED] 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 | 7 +++ .../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, 87 insertions(+), 1 deletions(-) create mode 100755 opac/opac-patron-image.pl diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 20c880c..e8ae39f 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 d6b3fe8..9cefd0e 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -4719,6 +4719,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 24856b8..ee3a80b 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 be2e439..7f0e61a 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-userupdate.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-userupdate.tt @@ -11,12 +11,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. @@ -102,6 +105,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