bug 3436: add patron images to web self-check
authorGalen Charlton <galen.charlton@liblime.com>
Wed, 22 Jul 2009 21:43:41 +0000 (16:43 -0500)
committerGalen Charlton <gmcharlt@gmail.com>
Wed, 16 Sep 2009 11:36:31 +0000 (07:36 -0400)
Adds a new system preference, ShowPatronImageInWebBasedSelfCheck;
if this preference is ON, a patron's image is displayed
if available when using web-based self-check.

Note: a patch for updatedatabase.pl will be made when this
change is ready to push.

This change is sponsored by the Plano Independent School
District.

Signed-off-by: Galen Charlton <gmcharlt@gmail.com>
installer/data/mysql/en/mandatory/sysprefs.sql
installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql
koha-tmpl/opac-tmpl/prog/en/modules/sco/sco-main.tmpl
opac/sco/sco-main.pl
opac/sco/sco-patron-image.pl [new file with mode: 0755]

index fdbef70..6f60fa7 100644 (file)
@@ -261,3 +261,4 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('OPACFinesTab','1','If OFF the patron fines tab in the OPAC is disabled.','','YesNo');
 INSERT INTO systempreferences (variable,value,options,explanation,type)VALUES('DisplayOPACiconsXSLT', '1', '', 'If ON, displays the format, audience, type icons in XSLT MARC21 results and display pages.', 'YesNo');
 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AllowAllMessageDeletion','0','Allow any Library to delete any message','','YesNo');
+INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('ShowPatronImageInWebBasedSelfCheck', '0', 'If ON, displays patron image when a patron uses web-based self-checkout', '', 'YesNo');
index 3cb8878..bee360a 100644 (file)
@@ -260,3 +260,4 @@ INSERT INTO `systempreferences` ( `variable` , `value` , `options` , `explanatio
 INSERT INTO systempreferences (variable,value,options,explanation,type)VALUES('HidePatronName', '0', '', 'Active l''affichage du numéro des adhérents à la place de leur nom dans les pages de réservation et du catalogue.', 'YesNo');
 INSERT INTO systempreferences (variable,value,options,explanation,type)VALUES('DisplayOPACiconsXSLT', '1', '', 'Si activé, affiche le format, le type de public et les icônes de type en XSLT (MARC21)).', 'YesNo');
 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AllowAllMessageDeletion','0','Allow any Library to delete any message','','YesNo');
+INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('ShowPatronImageInWebBasedSelfCheck', '0', 'Si activé, affiche la photo de l''adhérent lors de l''utilisation de la console de prêt auto-contrôlé', '', 'YesNo');
index 4d5a88d..01e4454 100644 (file)
@@ -104,6 +104,9 @@ Sorry, This Self-Checkout Station has lost authentication.  Please contact the a
        <!-- TMPL_IF NAME="patronid" -->
        <!-- TMPL_IF NAME="validuser" -->
        <h3 class="warning">You are logged in as <!-- TMPL_VAR NAME="borrowername" -->.</h3>
+    <!-- TMPL_IF NAME="display_patron_image" -->
+        <img src="/cgi-bin/koha/sco/sco-patron-image.pl?cardnumber=<!-- TMPL_VAR NAME="cardnumber" -->" alt="" />
+    <!-- /TMPL_IF -->
        <!-- /TMPL_IF -->
        </div>
        <!-- TMPL_IF NAME="nouser" -->
index 9b15ac5..2a5afd0 100755 (executable)
@@ -165,6 +165,15 @@ if ($borrower->{cardnumber}) {
         inputfocus => $inputfocus,
                nofines => 1,
     );
+    if (C4::Context->preference('ShowPatronImageInWebBasedSelfCheck')) {
+        my ($image, $dberror) = GetPatronImage($borrower->{cardnumber});
+        if ($image) {
+            $template->param(
+                display_patron_image => 1,
+                cardnumber           => $borrower->{cardnumber},
+            );
+        }
+    }
 } else {
     $template->param(
         patronid   => $patronid,
diff --git a/opac/sco/sco-patron-image.pl b/opac/sco/sco-patron-image.pl
new file mode 100755 (executable)
index 0000000..8e94fde
--- /dev/null
@@ -0,0 +1,41 @@
+#!/usr/bin/perl
+#
+# Copyright 2009 LibLime
+#
+# 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., 59 Temple Place,
+# Suite 330, Boston, MA  02111-1307 USA
+
+use strict;
+use warnings;
+use C4::Service;
+use C4::Members;
+
+my ($query, $response) = C4::Service->init(circulate => 'circulate_remaining_permissions');
+my ($cardnumber) = C4::Service->require_params('cardnumber');
+
+my ($imagedata, $dberror) = GetPatronImage($cardnumber);
+
+if ($dberror) {
+    print $query->header(status => '500 internal error');
+}
+
+if ($imagedata) {
+    print $query->header(-type => $imagedata->{'mimetype'}, 
+                         -'Cache-Control' => 'no-store', 
+                         -Content_Length => length ($imagedata->{'imagefile'})), 
+          $imagedata->{'imagefile'};
+} else {
+    print $query->header(status => '404 patron image not found');
+}