From d101ab8da14c1242eb4afdb4e34f37418e10bda7 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 get a warning message if you don't have the FA (Fast cataloguing) framework Note that the admin/marctagstructure.pl has already been tested in the previous patch. --- C4/Koha.pm | 19 ------------ admin/marctagstructure.pl | 7 ++--- circ/circulation-home.pl | 8 ++--- circ/circulation.pl | 3 +- .../prog/en/modules/admin/marctagstructure.tt | 34 +++++++++++----------- 5 files changed, 24 insertions(+), 47 deletions(-) diff --git a/C4/Koha.pm b/C4/Koha.pm index 8b6b220..c8291bf 100644 --- a/C4/Koha.pm +++ b/C4/Koha.pm @@ -42,7 +42,6 @@ BEGIN { &GetItemTypes &getitemtypeinfo &GetItemTypesCategorized &GetItemTypesByCategory &GetSupportName &GetSupportList - &getframeworkinfo &getallthemes &getFacets &getnbpages @@ -302,24 +301,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 b7ee972..8fa0739 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, ); @@ -205,7 +203,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 e31c7c5..9309d64 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -47,6 +47,7 @@ use Koha::Patron; use Koha::Patron::Debarments qw(GetDebarments IsDebarred); use Koha::DateUtils; use Koha::Database; +use Koha::BiblioFrameworks; use Koha::Patron::Messages; use Koha::Patron::Images; use Koha::SearchEngine; @@ -578,7 +579,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 2ff5822..3ba918c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marctagstructure.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marctagstructure.tt @@ -33,15 +33,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 %] @@ -53,17 +53,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. @@ -107,7 +107,7 @@ $(document).ready(function() {
- Cancel + Cancel
[% END %] @@ -121,10 +121,10 @@ $(document).ready(function() {
- +
-
+
@@ -133,7 +133,7 @@ $(document).ready(function() { [% IF ( delete_confirmed ) %]

Tag deleted

-
+
[% END %] @@ -141,8 +141,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.7.0