From 6000bfdf87db3f7f43feb21efd3cac8b7de9c048 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Tue, 23 Jul 2013 09:52:08 -0400 Subject: [PATCH] Bug 10626 - Remove doubled up TT plugins - Merge KohaBranchName and Branches Looking at the TT plugin directory I notice we have some plugins that seem to do the same thing: KohaBranchName.pm Branches.pm This patch drops KohaBranchName in favor of Branches Test Plan: 1) Apply this patch 2) View a basket group, note the branch name is displayed 3) View a subscription's details, note the branch name is displayed 4) View suggestions, note the branch names are displayed 5) Return an item that needs transfered, note the branch name is displayed 6) Run 'prove t/db_dependent/Koha_template_plugin_Branches.t' Signed-off-by: Chris Cormack Signed-off-by: Katrin Fischer Passes all tests and QA script. Also tested with a branch name with umlauts. Signed-off-by: Galen Charlton --- Koha/Template/Plugin/Branches.pm | 2 +- Koha/Template/Plugin/KohaBranchName.pm | 33 ------------------- .../prog/en/modules/acqui/basketgroup.tt | 10 +++--- .../prog/en/modules/circ/returns.tt | 4 +-- .../en/modules/serials/subscription-detail.tt | 4 +-- .../prog/en/modules/suggestion/suggestion.tt | 16 ++++----- ...Name.t => Koha_template_plugin_Branches.t} | 12 +++---- 7 files changed, 24 insertions(+), 57 deletions(-) delete mode 100644 Koha/Template/Plugin/KohaBranchName.pm rename t/db_dependent/{Koha_template_plugin_KohaBranchName.t => Koha_template_plugin_Branches.t} (78%) diff --git a/Koha/Template/Plugin/Branches.pm b/Koha/Template/Plugin/Branches.pm index e9ff105f75..343158cc16 100644 --- a/Koha/Template/Plugin/Branches.pm +++ b/Koha/Template/Plugin/Branches.pm @@ -32,7 +32,7 @@ sub GetName { my $sth = C4::Context->dbh->prepare($query); $sth->execute($branchcode); my $b = $sth->fetchrow_hashref(); - return encode( 'UTF-8', $b->{'branchname'} ); + return $b ? encode( 'UTF-8', $b->{'branchname'} ) : q{}; } 1; diff --git a/Koha/Template/Plugin/KohaBranchName.pm b/Koha/Template/Plugin/KohaBranchName.pm deleted file mode 100644 index 51d1a441d1..0000000000 --- a/Koha/Template/Plugin/KohaBranchName.pm +++ /dev/null @@ -1,33 +0,0 @@ -package Koha::Template::Plugin::KohaBranchName; - -# Copyright Bywater Solutions 2012 - -# 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 Modern::Perl; - -use Template::Plugin::Filter; -use base qw( Template::Plugin::Filter ); - -use C4::Branch qw( GetBranchName );; - -sub filter { - my ($self, $branchcode) = @_; - my $name = GetBranchName( $branchcode ); - return defined($name) ? $name : ''; -} - -1; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tt index c7c9a1bccb..f256ec3716 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tt @@ -1,4 +1,4 @@ -[% USE KohaBranchName %] +[% USE Branches %] [% INCLUDE 'doc-head-open.inc' %] Koha › Basket grouping for [% booksellername |html %] @@ -269,8 +269,8 @@ function submitForm(form) { [% END %] [% basketgroup.id %] - [% basketgroup.billingplace | $KohaBranchName %] - [% IF (basketgroup.freedeliveryplace) %]Free delivery place[% ELSE %][% basketgroup.deliveryplace | $KohaBranchName %][% END %] + [% Branches.GetName( basketgroup.billingplace ) %] + [% IF (basketgroup.freedeliveryplace) %]Free delivery place[% ELSE %][% Branches.GetName( basketgroup.deliveryplace ) %][% END %] [% basketgroup.basketsqty %] @@ -307,8 +307,8 @@ function submitForm(form) { [% END %] [% basketgroup.id %] - [% basketgroup.billingplace | $KohaBranchName %] - [% IF (basketgroup.freedeliveryplace) %]Free delivery place[% ELSE %][% basketgroup.deliveryplace | $KohaBranchName %][% END %] + [% Branches.GetName( basketgroup.billingplace ) %] + [% IF (basketgroup.freedeliveryplace) %]Free delivery place[% ELSE %][% Branches.GetName( basketgroup.deliveryplace ) %][% END %] [% basketgroup.basketsqty %]
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt index fb3031176f..550c4ca666 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt @@ -1,5 +1,5 @@ [% USE KohaDates %] -[% USE KohaBranchName %] +[% USE Branches %] [% INCLUDE 'doc-head-open.inc' %] Koha › Circulation › Check in [% title |html %] @@ -92,7 +92,7 @@ $(document).ready(function () { [% END %] -[% IF ( WrongTransfer ) %]

Please return [% title |html %] to [% TransferWaitingAt | $KohaBranchName %]

Print slip or Cancel transfer

+[% IF ( WrongTransfer ) %]

Please return [% title |html %] to [% Branches.GetName( TransferWaitingAt ) %]

Print slip or Cancel transfer

[% IF ( wborcnum ) %]
Hold for:
  • [% borsurname %], [% borfirstname %] ([% borcnum %])
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt index ccac0bbf72..59b12a7f49 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt @@ -1,4 +1,4 @@ -[% USE KohaBranchName %] +[% USE Branches %] [% INCLUDE 'doc-head-open.inc' %] Koha › Serials › Details for subscription #[% subscriptionid %] [% INCLUDE 'doc-head-close.inc' %] @@ -87,7 +87,7 @@ $(document).ready(function() {
  • Librarian identity: [% librarian %]
  • Vendor: [% aqbooksellername %]
  • Biblio: [% bibliotitle %] ([% bibnum %])
  • -[% IF ( branchcode ) %]
  • Library: [% branchcode | $KohaBranchName %]
  • [% END %] +[% IF ( branchcode ) %]
  • Library: [% Branches.GetName( branchcode ) %]
  • [% END %] [% IF ( serialsadditems ) %]
  • Items: Serial receipt creates an item record.
  • [% ELSE %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt index 7c6c98df09..9f5c40e117 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt @@ -1,5 +1,5 @@ [% USE KohaAuthorisedValues %] -[% USE KohaBranchName %] +[% USE Branches %] [% INCLUDE 'doc-head-open.inc' %] Koha › Acquisitions › [% IF ( op_save ) %] @@ -242,18 +242,18 @@ h4.local_collapse a { font-size : 80%; text-decoration: none; } fieldset.brief o <tr> <th><span class="label">Suggestion creation</span> </th> <td>[% suggesteddate %]</td> - <td>[% IF ( suggestedby_borrowernumber ) %]<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% suggestedby_borrowernumber %]">[% suggestedby_surname %], [% suggestedby_firstname %]</a> [% suggestedby_branchcode | $KohaBranchName %] ([% suggestedby_description %])[% END %] + <td>[% IF ( suggestedby_borrowernumber ) %]<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% suggestedby_borrowernumber %]">[% suggestedby_surname %], [% suggestedby_firstname %]</a> [% Branches.GetName( suggestedby_branchcode ) %] ([% suggestedby_description %])[% END %] </td> </tr> <tr> <th><span class="label">Suggestion management</span> </th> <td>[% manageddate %]</td> - <td>[% IF ( managedby_borrowernumber ) %]<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% managedby_borrowernumber %]">[% managedby_surname %], [% managedby_firstname %]</a> [% managedby_branchcode | $KohaBranchName %] ([% managedby_description %])[% END %]</td> + <td>[% IF ( managedby_borrowernumber ) %]<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% managedby_borrowernumber %]">[% managedby_surname %], [% managedby_firstname %]</a> [% Branches.GetName( managedby_branchcode ) %] ([% managedby_description %])[% END %]</td> </tr> <tr> <th><span class="label">Suggestion accepted</span> </th> <td>[% accepteddate %]</td> - <td>[% IF ( acceptedby_borrowernumber ) %]<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% acceptedby_borrowernumber %]">[% acceptedby_surname %], [% acceptedby_firstname %]</a> [% acceptedby_branchcode | $KohaBranchName %] ([% acceptedby_description %])[% END %]</td> + <td>[% IF ( acceptedby_borrowernumber ) %]<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% acceptedby_borrowernumber %]">[% acceptedby_surname %], [% acceptedby_firstname %]</a> [% Branches.GetName( acceptedby_branchcode ) %] ([% acceptedby_description %])[% END %]</td> </tr> </tbody> </table></li></ol> @@ -374,18 +374,18 @@ h4.local_collapse a { font-size : 80%; text-decoration: none; } fieldset.brief o <tr> <th><label for="suggesteddate">Suggestion creation</label> </th> <td><input type="text" id="suggesteddate" name="suggesteddate" size="10" maxlength="10" value="[% suggesteddate %]"/></td> - <td><input type="hidden" id="suggestedby" name="suggestedby" value="[% suggestedby %]"/>[% IF ( suggestedby_borrowernumber ) %]<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% suggestedby_borrowernumber %]">[% suggestedby_surname %], [% suggestedby_firstname %]</a> [% suggestedby_branchcode | $KohaBranchName %] ([% suggestedby_description %])[% END %] + <td><input type="hidden" id="suggestedby" name="suggestedby" value="[% suggestedby %]"/>[% IF ( suggestedby_borrowernumber ) %]<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% suggestedby_borrowernumber %]">[% suggestedby_surname %], [% suggestedby_firstname %]</a> [% Branches.GetName( suggestedby_branchcode ) %] ([% suggestedby_description %])[% END %] </td> </tr> <tr> <th><label for="managedon">Suggestion management</label> </th> <td><input type="text" id="managedon" name="manageddate" size="10" maxlength="10" value="[% manageddate %]" /></td> - <td><input type="hidden" id="managedby" name="managedby" value="[% managedby %]"/>[% IF ( managedby_borrowernumber ) %]<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% managedby_borrowernumber %]">[% managedby_surname %], [% managedby_firstname %]</a> [% managedby_branchcode | $KohaBranchName %] ([% managedby_description %])[% END %]</td> + <td><input type="hidden" id="managedby" name="managedby" value="[% managedby %]"/>[% IF ( managedby_borrowernumber ) %]<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% managedby_borrowernumber %]">[% managedby_surname %], [% managedby_firstname %]</a> [% Branches.GetName( managedby_branchcode ) %] ([% managedby_description %])[% END %]</td> </tr> <tr> <th><label for="accepteddate">Suggestion accepted</label> </th> <td><input type="text" id="accepteddate" name="accepteddate" size="10" maxlength="10" value="[% accepteddate %]" /></td> - <td><input type="hidden" id="acceptedby" name="acceptedby" value="[% acceptedby %]"/>[% IF ( acceptedby_borrowernumber ) %]<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% acceptedby_borrowernumber %]">[% acceptedby_surname %], [% acceptedby_firstname %]</a> [% acceptedby_branchcode | $KohaBranchName %] ([% acceptedby_description %])[% END %]</td> + <td><input type="hidden" id="acceptedby" name="acceptedby" value="[% acceptedby %]"/>[% IF ( acceptedby_borrowernumber ) %]<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% acceptedby_borrowernumber %]">[% acceptedby_surname %], [% acceptedby_firstname %]</a> [% Branches.GetName( acceptedby_branchcode ) %] ([% acceptedby_description %])[% END %]</td> </tr> </tbody> </table></li></ol> @@ -503,7 +503,7 @@ h4.local_collapse a { font-size : 80%; text-decoration: none; } fieldset.brief o [% IF ( suggestions_loo.manageddate ) %] - [% suggestions_loo.manageddate %][% END %] </td> <td> - [% suggestions_loo.branchcode | $KohaBranchName %] + [% Branches.GetName( suggestions_loo.branchcode ) %] </td> <td> [% suggestions_loo.budget_name %] diff --git a/t/db_dependent/Koha_template_plugin_KohaBranchName.t b/t/db_dependent/Koha_template_plugin_Branches.t similarity index 78% rename from t/db_dependent/Koha_template_plugin_KohaBranchName.t rename to t/db_dependent/Koha_template_plugin_Branches.t index dbba6da7a1..c47c4668f0 100644 --- a/t/db_dependent/Koha_template_plugin_KohaBranchName.t +++ b/t/db_dependent/Koha_template_plugin_Branches.t @@ -21,17 +21,17 @@ use Modern::Perl; use Test::More tests => 5; BEGIN { - use_ok('Koha::Template::Plugin::KohaBranchName'); + use_ok('Koha::Template::Plugin::Branches'); } -my $filter = Koha::Template::Plugin::KohaBranchName->new(); -ok($filter, "initialized KohaBranchName plugin"); +my $plugin = Koha::Template::Plugin::Branches->new(); +ok($plugin, "initialized Branches plugin"); -my $name = $filter->filter('CPL'); +my $name = $plugin->GetName('CPL'); is($name, 'Centerville', 'retrieved expected name for CPL'); -$name = $filter->filter('__ANY__'); +$name = $plugin->GetName('__ANY__'); is($name, '', 'received empty string as name of the "__ANY__" placeholder library code'); -$name = $filter->filter(undef); +$name = $plugin->GetName(undef); is($name, '', 'received empty string as name of NULL/undefined library code'); -- 2.39.5