From 9ab9686250a31b6027d57a294739893ff31ca833 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Fri, 2 May 2014 22:46:23 +0000 Subject: [PATCH] Bug 10694: (follow-up) fix problems with the new Borrowers plugin TT plugins should *not* be duplicating business logic found in other modules. This patch replaces the copy-and-paste of the old IsDebarred logic with a call to the appropriate routine and updates the POD. Signed-off-by: Galen Charlton --- Koha/Template/Plugin/Borrowers.pm | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/Koha/Template/Plugin/Borrowers.pm b/Koha/Template/Plugin/Borrowers.pm index 29a6fef09f..b8f3de5d03 100644 --- a/Koha/Template/Plugin/Borrowers.pm +++ b/Koha/Template/Plugin/Borrowers.pm @@ -1,6 +1,7 @@ package Koha::Template::Plugin::Borrowers; # Copyright ByWater Solutions 2013 +# Copyright Equinox Software, Inc. 2014 # This file is part of Koha. # @@ -21,9 +22,7 @@ use Modern::Perl; use base qw( Template::Plugin ); -use Date::Calc qw/Today Add_Delta_YM check_date Date_to_Days/; - -use C4::Koha; +use Koha::Borrower::Debarments qw//; =pod @@ -34,7 +33,7 @@ Templates when it makes sense to do so. To use, first, include the line '[% USE Borrowers %]' at the top of the template to enable the plugin. -For example: [% IF Borrowers.IsDebarred( borrower.borrowernumber ) %] +For example: [% IF Borrowers.IsDebarred( borrower ) %] removes the necessity of setting a template variable in Perl code to find out if a patron is restricted even if that variable is not evaluated in any way in the script. @@ -46,13 +45,7 @@ sub IsDebarred { return unless $borrower; - if ( $borrower->{'debarred'} && check_date( split( /-/, $borrower->{'debarred'} ) ) ) { - if ( Date_to_Days(Date::Calc::Today) < Date_to_Days( split( /-/, $borrower->{'debarred'} ) ) ) { - return 1; - } - } - - return 0; + return Koha::Borrower::Debarments::IsDebarred($borrower->{borrowernumber}); } 1; -- 2.20.1