From 0d40bd95480966a94541f8fb93b01307589a080f Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 10 Feb 2016 17:26:35 +0000 Subject: [PATCH] Bug 15801: Koha::BiblioFrameworks - Remove C4::Koha::getframeworkinfo This was the "Get" subroutine for the framework, it can be easily replaced with a call to the Koha::BiblioFrameworks->find method. This patch also replaces some confusing wordings (framework vs frameworkcode). Test plan: On the circulation home page, you should see a "Fast cataloguing" link if the FA framework exists. Note that the admin/marctagstructure.pl has already been tested in the previous patch. Signed-off-by: Bernardo Gonzalez Kriegel Link pops Ok No errors Signed-off-by: Marcel de Rooy --- C4/Koha.pm | 29 ++++-------------- admin/marctagstructure.pl | 7 ++--- circ/circulation-home.pl | 8 ++--- circ/circulation.pl | 3 +- .../prog/en/modules/admin/marctagstructure.tt | 34 +++++++++++----------- 5 files changed, 29 insertions(+), 52 deletions(-) diff --git a/C4/Koha.pm b/C4/Koha.pm index 0ab2531..9b28ecb 100644 --- a/C4/Koha.pm +++ b/C4/Koha.pm @@ -39,13 +39,12 @@ BEGIN { require Exporter; @ISA = qw(Exporter); @EXPORT = qw( - &GetPrinters &GetPrinter - &GetItemTypes &getitemtypeinfo + &GetPrinters &GetPrinter + &GetItemTypes &getitemtypeinfo &GetItemTypesCategorized &GetItemTypesByCategory - &getframeworkinfo - &getallthemes - &getFacets - &getnbpages + &getallthemes + &getFacets + &getnbpages &get_infos_of &get_notforloan_label_of &getitemtypeimagedir @@ -223,24 +222,6 @@ sub GetItemTypesByCategory { return @$tmp; } -=head2 getframeworkinfo - - $frameworkinfo = &getframeworkinfo($frameworkcode); - -Returns information about an frameworkcode. - -=cut - -sub getframeworkinfo { - my ($frameworkcode) = @_; - my $dbh = C4::Context->dbh; - my $sth = - $dbh->prepare("select * from biblio_framework where frameworkcode=?"); - $sth->execute($frameworkcode); - my $res = $sth->fetchrow_hashref; - return $res; -} - =head2 getitemtypeinfo $itemtype = &getitemtypeinfo($itemtype, [$interface]); diff --git a/admin/marctagstructure.pl b/admin/marctagstructure.pl index 2d46b86..575f4f4 100755 --- a/admin/marctagstructure.pl +++ b/admin/marctagstructure.pl @@ -35,8 +35,6 @@ my $input = new CGI; my $frameworkcode = $input->param('frameworkcode') || ''; # set to select framework my $existingframeworkcode = $input->param('existingframeworkcode') || ''; my $searchfield = $input->param('searchfield') || 0; -# set when we have to create a new framework (in frameworkcode) by copying an old one (in existingframeworkcode) -my $frameworkinfo = getframeworkinfo($frameworkcode); $searchfield=~ s/\,//g; my $offset = $input->param('offset') || 0; @@ -76,10 +74,10 @@ unless ($frameworkexist) { } } +my $framework = $frameworks->search({ frameworkcode => $frameworkcode })->next; $template->param( frameworks => $frameworks, - frameworkcode => $frameworkcode, - frameworktext => $frameworkinfo->{frameworktext}, + framework => $framework, script_name => $script_name, ( $op || 'else' ) => 1, ); @@ -209,7 +207,6 @@ if ($op eq 'add_form') { } $template->param(existingframeworkloop => \@existingframeworkloop, frameworkcode => $frameworkcode, -# FRtext => $frameworkinfo->{frameworktext}, ); ################## DEFAULT ################################## } else { # DEFAULT diff --git a/circ/circulation-home.pl b/circ/circulation-home.pl index 3821007..4f29f49 100755 --- a/circ/circulation-home.pl +++ b/circ/circulation-home.pl @@ -16,13 +16,12 @@ # along with Koha; if not, see . # -use strict; -#use warnings; FIXME - Bug 2505 +use Modern::Perl; use CGI qw ( -utf8 ); use C4::Auth; use C4::Output; use C4::Context; -use C4::Koha; +use Koha::BiblioFrameworks; my $query = new CGI; my ($template, $loggedinuser, $cookie, $flags) = get_template_and_user( @@ -36,8 +35,7 @@ my ($template, $loggedinuser, $cookie, $flags) = get_template_and_user( ); # Checking if there is a Fast Cataloging Framework -my $fa = getframeworkinfo('FA'); -$template->param( fast_cataloging => 1 ) if (defined $fa); +$template->param( fast_cataloging => 1 ) if Koha::BiblioFrameworks->find( 'FA' ); # Checking if the transfer page needs to be displayed $template->param( display_transfer => 1 ) if ( ($flags->{'superlibrarian'} == 1) || (C4::Context->preference("IndependentBranches") == 0) ); diff --git a/circ/circulation.pl b/circ/circulation.pl index eaecef7..e1ca58f 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -47,6 +47,7 @@ use Koha::Patron; use Koha::Patron::Debarments qw(GetDebarments); use Koha::DateUtils; use Koha::Database; +use Koha::BiblioFrameworks; use Koha::Patron::Messages; use Koha::Patron::Images; use Koha::SearchEngine; @@ -579,7 +580,7 @@ my $patron_messages = Koha::Patron::Messages->search( ); my $fast_cataloging = 0; -if (defined getframeworkinfo('FA')) { +if ( Koha::BiblioFrameworks->find('FA') ) { $fast_cataloging = 1 } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marctagstructure.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marctagstructure.tt index be536e8..6e46b6b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marctagstructure.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marctagstructure.tt @@ -38,15 +38,15 @@ $(document).ready(function() { › AdministrationMARC frameworks [% IF ( add_form ) %] -› [% frameworktext %] ([% frameworkcode %]) +› [% framework.frameworktext %] ([% framework.frameworkcode %]) › [% action %] [% searchfield %] [% ELSIF ( else ) %] -› [% IF ( frameworkcode ) %][% frameworktext %] ([% frameworkcode %])[% ELSE %]Default MARC framework[% END %] +› [% IF framework %][% framework.frameworktext %] ([% framework.frameworkcode %])[% ELSE %]Default MARC framework[% END %] [% ELSIF ( delete_confirm ) %] -› [% frameworktext %] ([% frameworkcode %]) +› [% framwork.frameworktext %] ([% framework.frameworkcode %]) › Confirm deletion of tag '[% searchfield %]' [% ELSIF ( delete_confirmed ) %] -› [% frameworktext %] ([% frameworkcode %]) +› [% framework.frameworktext %] ([% framework.frameworkcode %]) › Data deleted [% END %] @@ -58,17 +58,17 @@ $(document).ready(function() { [% IF ( else ) %] [% END %] -

MARC Framework for [% IF ( frameworkcode ) %][% frameworktext %] ([% frameworkcode %])[% ELSE %]default MARC framework[% END %]

+

MARC Framework for [% IF framework %][% framework.frameworktext %] ([% framework.frameworkcode %])[% ELSE %]default MARC framework[% END %]

[% IF ( add_form ) %]
[% IF ( use_heading_flags_p ) %][% IF ( heading_modify_tag_p ) %]Modify tag [% searchfield %][% END %][% IF ( heading_add_tag_p ) %]Add tag[% END %][% ELSE %][% action %][% END %] - +
  1. @@ -112,7 +112,7 @@ $(document).ready(function() {
- Cancel + Cancel
[% END %] @@ -126,10 +126,10 @@ $(document).ready(function() {
- +
-
+
@@ -138,7 +138,7 @@ $(document).ready(function() { [% IF ( delete_confirmed ) %]

Tag deleted

-
+
[% END %] @@ -146,8 +146,8 @@ $(document).ready(function() {
- - Create framework for [% frameworkcode %] ([% frameworktext %]) using + + Create framework for [% frameworkcode %] ([% framework.frameworktext %]) using - [% FOREACH framework IN frameworks %] - [% IF framework.frameworkcode == frameworkcode %] - + [% FOREACH f IN frameworks %] + [% IF f.frameworkcode == framework.frameworkcode %] + [% ELSE %] - + [% END %] [% END %] -- 2.1.4