From d601c506742adb9b16db64b22091f7e56133659b 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 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' --- Koha/Template/Plugin/Branches.pm | 2 +- .../prog/en/modules/acqui/basketgroup.tt | 10 +++++----- .../intranet-tmpl/prog/en/modules/circ/returns.tt | 4 ++-- .../prog/en/modules/serials/subscription-detail.tt | 4 ++-- .../prog/en/modules/suggestion/suggestion.tt | 16 ++++++++-------- ...ranchName.t => Koha_template_plugin_Branches.t} | 12 ++++++------ 6 files changed, 24 insertions(+), 24 deletions(-) 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 e9ff105..343158c 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-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tt index 6bb0048..cdf216a 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 %] @@ -274,8 +274,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 %] @@ -312,8 +312,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 98d2ae9..c39bdd4 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 959f14f..5696c39 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' %] @@ -102,7 +102,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 0b559fb..4c3c481 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 AuthorisedValues %] -[% USE KohaBranchName %] +[% USE Branches %] [% INCLUDE 'doc-head-open.inc' %] Koha › Acquisitions › [% IF ( op_save ) %] @@ -226,18 +226,18 @@ $(document).ready(function() { calcNewsuggTotal(); }); <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> @@ -354,18 +354,18 @@ $(document).ready(function() { calcNewsuggTotal(); }); <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> @@ -482,7 +482,7 @@ $(document).ready(function() { calcNewsuggTotal(); }); [% 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 dbba6da..c47c466 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'); -- 1.7.2.5