From d4b7d7b93402811cca364d33c339d36b9db1d28a Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Thu, 19 Dec 2013 12:13:23 -0500 Subject: [PATCH] Bug 10626: Remove doubled up TT plugins - Merge KohaAuthorisedValues and AuthorisedValues This patch removes the KohaAuthorisedValues TT plugin; uses of it are replaced by the AuthorisedValues plugin, which does the same thing. Test Plan: 1) Apply this patch 2) View the pages that this patch has modified, make sure the branch name is still visible Signed-off-by: Chris Cormack Signed-off-by: Katrin Fischer Comments on second patch. Signed-off-by: Galen Charlton (cherry picked from commit b5b3d4c403f3df91578a3d49ed15811cd1386e52) Signed-off-by: Fridolin SOMERS --- Koha/Template/Plugin/AuthorisedValues.pm | 12 +++++ Koha/Template/Plugin/KohaAuthorisedValues.pm | 50 ------------------- .../prog/en/modules/circ/circulation.tt | 18 +++---- .../prog/en/modules/suggestion/suggestion.tt | 8 +-- .../prog/en/includes/item-status.inc | 4 +- .../prog/en/modules/opac-suggestions.tt | 4 +- 6 files changed, 29 insertions(+), 67 deletions(-) delete mode 100644 Koha/Template/Plugin/KohaAuthorisedValues.pm diff --git a/Koha/Template/Plugin/AuthorisedValues.pm b/Koha/Template/Plugin/AuthorisedValues.pm index 683a0ff3e5..0a19be240d 100644 --- a/Koha/Template/Plugin/AuthorisedValues.pm +++ b/Koha/Template/Plugin/AuthorisedValues.pm @@ -26,6 +26,18 @@ use Encode qw{encode decode}; use C4::Koha; +=pod + +To use, first, include the line '[% USE AuthorisedValues %]' at the top +of the template to enable the plugin. + +Now, in a template, you can get the description for an authorised value with +the following TT code: [% AuthorisedValues.GetByCode( 'CATEGORY', 'AUTHORISED_VALUE_CODE', 'IS_OPAC' ) %] + +The parameters are identical to those used by the subroutine C4::Koha::GetAuthorisedValueByCode. + +=cut + sub GetByCode { my ( $self, $category, $code, $opac ) = @_; return encode( 'UTF-8', GetAuthorisedValueByCode( $category, $code, $opac ) ); diff --git a/Koha/Template/Plugin/KohaAuthorisedValues.pm b/Koha/Template/Plugin/KohaAuthorisedValues.pm deleted file mode 100644 index 68b13479db..0000000000 --- a/Koha/Template/Plugin/KohaAuthorisedValues.pm +++ /dev/null @@ -1,50 +0,0 @@ -package Koha::Template::Plugin::KohaAuthorisedValues; - -# 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; -use base qw( Template::Plugin ); - -use C4::Koha; - -=pod - -This plugin allows one to get the description for an authorised value -from within a template. - -First, include the line '[% USE KohaAuthorisedValues %]' at the top -of the template to enable the plugin. - -To use, call KohaAuthorisedValues.GetByCode with the category -of the authorised value, the code to look up, and optionally, -the OPAC flag ( if set, it will return the OPAC description rather -than the Intranet description ). - -For example: [% KohaAuthorisedValues.GetByCode( 'LOST', item.itemlost, 1 ) %] -will print the OPAC description for the LOST value stored in item.itemlost. - -=cut - -sub GetByCode { - my ( $self, $category, $code, $opac ) = @_; - return GetAuthorisedValueByCode( $category, $code, $opac ); -} - -1; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt index 3596767822..3ecedd8642 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -3,7 +3,7 @@ [% IF ( export_remove_fields OR export_with_csv_profile ) %] [% SET exports_enabled = 1 %] [% END %] -[% USE KohaAuthorisedValues %] +[% USE AuthorisedValues %] [% INCLUDE 'doc-head-open.inc' %] [% SET destination = "circ" %] Koha › Circulation @@ -229,7 +229,7 @@ var MSG_EXPORT_SELECT_CHECKOUTS = _("You must select checkout(s) to export"); [% IF ( itemtype_notforloan ) %] Item type is normally not for loan. [% ELSIF ( item_notforloan ) %] - [% item_notforloan_lib = KohaAuthorisedValues.GetByCode( authvalcode_notforloan, item_notforloan, 0 ) %] + [% item_notforloan_lib = AuthorisedValues.GetByCode( authvalcode_notforloan, item_notforloan, 0 ) %] Item is normally not for loan [% IF (item_notforloan_lib) %]([% item_notforloan_lib %])[% END %]. [% END %] Check out anyway? @@ -362,7 +362,7 @@ var MSG_EXPORT_SELECT_CHECKOUTS = _("You must select checkout(s) to export"); [% IF ( itemtype_notforloan ) %] Item type not for loan. [% ELSIF ( item_notforloan ) %] - [% item_notforloan_lib = KohaAuthorisedValues.GetByCode( authvalcode_notforloan, item_notforloan, 0 ) %] + [% item_notforloan_lib = AuthorisedValues.GetByCode( authvalcode_notforloan, item_notforloan, 0 ) %] Item not for loan [% IF (item_notforloan_lib) %]([% item_notforloan_lib %])[% END %]. [% END %] </li> @@ -712,10 +712,10 @@ No patron matched <span class="ex">[% message %]</span> <span title="[% todayissue.dd_sort %]">[% todayissue.dd %]</span> [% IF ( todayissue.itemlost ) %] - <span class="lost">[% KohaAuthorisedValues.GetByCode( 'LOST', todayissue.itemlost ) %]</span> + <span class="lost">[% AuthorisedValues.GetByCode( 'LOST', todayissue.itemlost ) %]</span> [% END %] [% IF ( todayissue.damaged ) %] - <span class="dmg">[% KohaAuthorisedValues.GetByCode( 'DAMAGED', todayissue.damaged ) %]</span> + <span class="dmg">[% AuthorisedValues.GetByCode( 'DAMAGED', todayissue.damaged ) %]</span> [% END %] </td> <td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% todayissue.biblionumber %]&type=intra"><strong>[% todayissue.title |html %][% FOREACH subtitl IN todayissue.subtitle %] [% subtitl.subfield %][% END %]</strong></a>[% IF ( todayissue.author ) %], by [% todayissue.author %][% END %][% IF ( todayissue.itemnotes ) %]- <span class="circ-hlt">[% todayissue.itemnotes %]</span>[% END %] <a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% todayissue.biblionumber %]&itemnumber=[% todayissue.itemnumber %]#item[% todayissue.itemnumber %]">[% todayissue.barcode %]</a></td> @@ -799,10 +799,10 @@ No patron matched <span class="ex">[% message %]</span> <span title="[% previssue.dd_sort %]">[% previssue.dd %]</span> [% IF ( previssue.itemlost ) %] - <span class="lost">[% KohaAuthorisedValues.GetByCode( 'LOST', previssue.itemlost ) %]</span> + <span class="lost">[% AuthorisedValues.GetByCode( 'LOST', previssue.itemlost ) %]</span> [% END %] [% IF ( previssue.damaged ) %] - <span class="dmg">[% KohaAuthorisedValues.GetByCode( 'DAMAGED', previssue.damaged ) %]</span> + <span class="dmg">[% AuthorisedValues.GetByCode( 'DAMAGED', previssue.damaged ) %]</span> [% END %] </td> <td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% previssue.biblionumber %]&type=intra"><strong>[% previssue.title |html %][% FOREACH subtitl IN previssue.subtitle %] [% subtitl.subfield %][% END %]</strong></a>[% IF ( previssue.author ) %], by [% previssue.author %][% END %] [% IF ( previssue.itemnotes ) %]- [% previssue.itemnotes %][% END %] <a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% previssue.biblionumber %]&itemnumber=[% previssue.itemnumber %]#item[% previssue.itemnumber %]">[% previssue.barcode %]</a></td> @@ -940,10 +940,10 @@ No patron matched <span class="ex">[% message %]</span> <span title="[% relissue.dd_sort %]">[% relissue.dd %]</span></td> [% IF ( relissue.itemlost ) %] - <span class="lost">[% KohaAuthorisedValues.GetByCode( 'LOST', relissue.itemlost ) %]</span> + <span class="lost">[% AuthorisedValues.GetByCode( 'LOST', relissue.itemlost ) %]</span> [% END %] [% IF ( relissue.damaged ) %] - <span class="dmg">[% KohaAuthorisedValues.GetByCode( 'DAMAGED', relissue.damaged ) %]</span> + <span class="dmg">[% AuthorisedValues.GetByCode( 'DAMAGED', relissue.damaged ) %]</span> [% END %] </td> <td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% relissue.biblionumber %]&type=intra"><strong>[% relissue.title |html %][% FOREACH subtitl IN relissue.subtitle %] [% subtitl.subfield %][% END %]</strong></a>[% IF ( relissue.author ) %], by [% relissue.author %][% END %][% IF ( relissue.itemnotes ) %]- <span class="circ-hlt">[% relissue.itemnotes %]</span>[% END %] <a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% relissue.biblionumber %]&itemnumber=[% relissue.itemnumber %]#item[% relissue.itemnumber %]">[% relissue.barcode %]</a></td> 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 29f038039e..3b611fc699 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 Branches %] +[% USE AuthorisedValues %] [% INCLUDE 'doc-head-open.inc' %] <title>Koha › Acquisitions › [% IF ( op_save ) %] @@ -450,7 +450,7 @@ h4.local_collapse a { font-size : 80%; text-decoration: none; } fieldset.brief o [% ELSE %][% suggestion.suggestiontypelabel %][% END %] [% ELSE %] [% IF ( suggestion.suggestiontype ) %] - [% KohaAuthorisedValues.GetByCode( 'SUGGEST_STATUS', suggestion.suggestiontype ) %] + [% AuthorisedValues.GetByCode( 'SUGGEST_STATUS', suggestion.suggestiontype ) %] [% ELSE %] No name [% END %] @@ -517,8 +517,8 @@ h4.local_collapse a { font-size : 80%; text-decoration: none; } fieldset.brief o Rejected [% ELSIF ( suggestions_loo.CHECKED ) %] Checked - [% ELSIF KohaAuthorisedValues.GetByCode( 'SUGGEST_STATUS', suggestions_loo.STATUS ) %] - [% KohaAuthorisedValues.GetByCode( 'SUGGEST_STATUS', suggestions_loo.STATUS ) %] + [% ELSIF AuthorisedValues.GetByCode( 'SUGGEST_STATUS', suggestions_loo.STATUS ) %] + [% AuthorisedValues.GetByCode( 'SUGGEST_STATUS', suggestions_loo.STATUS ) %] [% END %] [% IF ( suggestions_loo.reason ) %] diff --git a/koha-tmpl/opac-tmpl/prog/en/includes/item-status.inc b/koha-tmpl/opac-tmpl/prog/en/includes/item-status.inc index d2651f080a..172a55a887 100644 --- a/koha-tmpl/opac-tmpl/prog/en/includes/item-status.inc +++ b/koha-tmpl/opac-tmpl/prog/en/includes/item-status.inc @@ -1,4 +1,4 @@ -[% USE KohaAuthorisedValues %] +[% USE AuthorisedValues %] [% IF ( item.itemlost ) %] [% av_lib_include = KohaAuthorisedValues.GetByCode( 'LOST', item.itemlost, 1 ) %] @@ -33,7 +33,7 @@ [% ELSIF ( item.notforloan_per_itemtype ) %] Not for loan [% IF ( item.restrictedopac ) %]<span class="restricted">([% item.restrictedopac %])</span>[% END %] [% ELSIF ( item.damaged ) %] - [% av_lib_include = KohaAuthorisedValues.GetByCode( 'DAMAGED', item.damaged, 1 ) %] + [% av_lib_include = AuthorisedValues.GetByCode( 'DAMAGED', item.damaged, 1 ) %] [% IF av_lib_include %] [% av_lib_include %] [% ELSE %] diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-suggestions.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-suggestions.tt index 631325999c..5e52d84bdb 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-suggestions.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-suggestions.tt @@ -1,5 +1,5 @@ [% USE Koha %] -[% USE KohaAuthorisedValues %] +[% USE AuthorisedValues %] [% INCLUDE 'doc-head-open.inc' %][% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog › [% IF ( op_add ) %]Enter a new purchase suggestion[% END %] [% IF ( op_else ) %]Purchase Suggestions[% END %] @@ -213,7 +213,7 @@ [% ELSIF ( suggestions_loo.ORDERED ) %]Ordered by the library [% ELSIF ( suggestions_loo.REJECTED ) %]Suggestion declined [% ELSIF ( suggestions_loo.AVAILABLE ) %]Available in the library - [% ELSE %] [% KohaAuthorisedValues.GetByCode( 'SUGGEST_STATUS', suggestions_loo.STATUS, 1 ) %] [% END %] + [% ELSE %] [% AuthorisedValues.GetByCode( 'SUGGEST_STATUS', suggestions_loo.STATUS, 1 ) %] [% END %] [% IF ( suggestions_loo.reason ) %]([% suggestions_loo.reason |html %])[% END %] </td> -- 2.39.5