From 39487d634ecb2fbfe5819852ef295cdd3d214737 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 30 Aug 2016 12:44:14 -0300 Subject: [PATCH] Bug 11592: (QA followup) Add missing framework code to ViewPolicy filter calls This patch adds the frameworkcode option param, using each record's frameworkcode as expected by the filter. Otherwise the ViewPolicy filter falls back to the default framework. Signed-off-by: Tomas Cohen Arazi Signed-off-by: Mark Tompsett Signed-off-by: Kyle M Hall --- catalogue/ISBDdetail.pl | 16 +++++++++------- opac/opac-ISBDdetail.pl | 10 ++++++++-- opac/opac-MARCdetail.pl | 31 +++++++++++++++++++------------ opac/opac-basket.pl | 8 +++++++- opac/opac-detail.pl | 9 ++++++++- opac/opac-downloadcart.pl | 5 +++++ opac/opac-downloadshelf.pl | 7 +++++-- opac/opac-export.pl | 11 ++++++++--- opac/opac-shelves.pl | 5 +++++ opac/opac-showmarc.pl | 7 +++++-- 10 files changed, 79 insertions(+), 30 deletions(-) diff --git a/catalogue/ISBDdetail.pl b/catalogue/ISBDdetail.pl index cb5081f131..4679b9e1e3 100755 --- a/catalogue/ISBDdetail.pl +++ b/catalogue/ISBDdetail.pl @@ -77,13 +77,6 @@ if ( not defined $biblionumber ) { } my $record = GetMarcBiblio($biblionumber,1); -my $record_processor = Koha::RecordProcessor->new({ - filters => 'ViewPolicy', - options => { - interface => 'intranet', - }, -}); -$record_processor->process($record); if ( not defined $record ) { # biblionumber invalid -> report and exit @@ -95,6 +88,15 @@ if ( not defined $record ) { } my $framework = GetFrameworkCode( $biblionumber ); +my $record_processor = Koha::RecordProcessor->new({ + filters => 'ViewPolicy', + options => { + interface => 'intranet', + frameworkcode => $framework + }, +}); +$record_processor->process($record); + my $res = GetISBDView({ 'record' => $record, 'template' => 'intranet', diff --git a/opac/opac-ISBDdetail.pl b/opac/opac-ISBDdetail.pl index 3dc15df31c..c55829c30f 100755 --- a/opac/opac-ISBDdetail.pl +++ b/opac/opac-ISBDdetail.pl @@ -97,7 +97,14 @@ if ( ! $record ) { print $query->redirect("/cgi-bin/koha/errors/404.pl"); exit; } -my $record_processor = Koha::RecordProcessor->new({ filters => 'ViewPolicy' }); +my $framework = GetFrameworkCode( $biblionumber ); +my $record_processor = Koha::RecordProcessor->new({ + filters => 'ViewPolicy', + options => { + interface => 'opac', + frameworkcode => $framework + } +}); $record_processor->process($record); # some useful variables for enhanced content; @@ -149,7 +156,6 @@ $template->param( my $norequests = 1; my $allow_onshelf_holds; -my $framework = GetFrameworkCode( $biblionumber ); my $res = GetISBDView({ 'record' => $record, 'template' => 'opac', diff --git a/opac/opac-MARCdetail.pl b/opac/opac-MARCdetail.pl index b16538ae54..3c9c2c23c8 100755 --- a/opac/opac-MARCdetail.pl +++ b/opac/opac-MARCdetail.pl @@ -69,6 +69,12 @@ if ( ! $biblionumber ) { exit; } +my $record = GetMarcBiblio($biblionumber, 1); +if ( ! $record ) { + print $query->redirect("/cgi-bin/koha/errors/404.pl"); + exit; +} + my @all_items = GetItemsInfo($biblionumber); my @items2hide; if (scalar @all_items >= 1) { @@ -80,17 +86,18 @@ if (scalar @all_items >= 1) { } } -my $itemtype = &GetFrameworkCode($biblionumber); -my $tagslib = &GetMarcStructure( 0, $itemtype ); -my ($tag_itemnumber,$subtag_itemnumber) = &GetMarcFromKohaField('items.itemnumber',$itemtype); +my $framework = &GetFrameworkCode( $biblionumber ); +my $tagslib = &GetMarcStructure( 0, $framework ); +my ($tag_itemnumber,$subtag_itemnumber) = &GetMarcFromKohaField('items.itemnumber',$framework); my $biblio = GetBiblioData($biblionumber); -$biblionumber = $biblio->{biblionumber}; -my $record = GetMarcBiblio($biblionumber, 1); -if ( ! $record ) { - print $query->redirect("/cgi-bin/koha/errors/404.pl"); - exit; -} -my $record_processor = Koha::RecordProcessor->new({ filters => 'ViewPolicy' }); + +my $record_processor = Koha::RecordProcessor->new({ + filters => 'ViewPolicy', + options => { + interface => 'opac', + frameworkcode => $framework + } +}); $record_processor->process($record); # open template @@ -104,7 +111,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( } ); -my ($bt_tag,$bt_subtag) = GetMarcFromKohaField('biblio.title',$itemtype); +my ($bt_tag,$bt_subtag) = GetMarcFromKohaField('biblio.title',$framework); $template->param( bibliotitle => $biblio->{title}, ) if $tagslib->{$bt_tag}->{$bt_subtag}->{hidden} <= 0 && # <=0 OPAC visible. @@ -291,7 +298,7 @@ foreach my $field (@fields) { push @item_loop, $item if $item; } my ( $holdingbrtagf, $holdingbrtagsubf ) = - &GetMarcFromKohaField( "items.holdingbranch", $itemtype ); + &GetMarcFromKohaField( "items.holdingbranch", $framework ); @item_loop = sort { ($a->{$holdingbrtagsubf}||'') cmp ($b->{$holdingbrtagsubf}||'') } @item_loop; diff --git a/opac/opac-basket.pl b/opac/opac-basket.pl index 4fd2108c25..29337ea43f 100755 --- a/opac/opac-basket.pl +++ b/opac/opac-basket.pl @@ -63,7 +63,13 @@ foreach my $biblionumber ( @bibs ) { my $dat = &GetBiblioData($biblionumber); next unless $dat; - my $record = &GetMarcBiblio($biblionumber); + + my $record = &GetMarcBiblio( $biblionumber ); + my $framework = &GetFrameworkCode( $biblionumber ); + $record_processor->options({ + interface => 'opac', + frameworkcode => $framework + }); $record_processor->process($record); next unless $record; my $marcnotesarray = GetMarcNotes( $record, $marcflavour ); diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index 46abc6f12e..de1b72fec3 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -89,7 +89,14 @@ if ( ! $record ) { print $query->redirect("/cgi-bin/koha/errors/404.pl"); # escape early exit; } -my $record_processor = Koha::RecordProcessor->new({ filters => 'ViewPolicy' }); +my $framework = &GetFrameworkCode( $biblionumber ); +my $record_processor = Koha::RecordProcessor->new({ + filters => 'ViewPolicy', + options => { + interface => 'opac', + frameworkcode => $framework + } +}); $record_processor->process($record); # redirect if opacsuppression is enabled and biblio is suppressed diff --git a/opac/opac-downloadcart.pl b/opac/opac-downloadcart.pl index 1cf0de01ec..75ab4a1323 100755 --- a/opac/opac-downloadcart.pl +++ b/opac/opac-downloadcart.pl @@ -69,6 +69,11 @@ if ($bib_list && $format) { foreach my $biblio (@bibs) { my $record = GetMarcBiblio($biblio, 1); + my $framework = &GetFrameworkCode( $biblio ); + $record_processor->options({ + interface => 'opac', + frameworkcode => $framework + }); $record_processor->process($record); next unless $record; diff --git a/opac/opac-downloadshelf.pl b/opac/opac-downloadshelf.pl index 9f98d91b33..142577b882 100755 --- a/opac/opac-downloadshelf.pl +++ b/opac/opac-downloadshelf.pl @@ -53,7 +53,6 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user ( my $shelfnumber = $query->param('shelfnumber'); my $format = $query->param('format'); my $context = $query->param('context'); -my $dbh = C4::Context->dbh; my $shelf = Koha::Virtualshelves->find( $shelfnumber ); if ( $shelf and $shelf->can_be_viewed( $borrowernumber ) ) { @@ -83,6 +82,11 @@ if ( $shelf and $shelf->can_be_viewed( $borrowernumber ) ) { my $biblionumber = $content->biblionumber->biblionumber; my $record = GetMarcBiblio($biblionumber, 1); + my $framework = &GetFrameworkCode( $biblionumber ); + $record_processor->options({ + interface => 'opac', + frameworkcode => $framework + }); $record_processor->process($record); next unless $record; @@ -96,7 +100,6 @@ if ( $shelf and $shelf->can_be_viewed( $borrowernumber ) ) { $output .= marc2bibtex($record, $biblionumber); } elsif ( $format eq 'isbd' ) { - my $framework = GetFrameworkCode( $biblionumber ); $output .= GetISBDView({ 'record' => $record, 'template' => 'opac', diff --git a/opac/opac-export.pl b/opac/opac-export.pl index d5f4c4f61f..c0f18bf2b6 100755 --- a/opac/opac-export.pl +++ b/opac/opac-export.pl @@ -45,8 +45,14 @@ if(!$marc) { } # ASSERT: There is a biblionumber, because GetMarcBiblio returned something. - -my $record_processor = Koha::RecordProcessor->new({ filters => 'ViewPolicy' }); +my $framework = GetFrameworkCode( $biblionumber ); +my $record_processor = Koha::RecordProcessor->new({ + filters => 'ViewPolicy', + options => { + interface => 'opac', + frameworkcode => $framework + } +}); $record_processor->process($marc); if ($format =~ /endnote/) { @@ -90,7 +96,6 @@ elsif ($format =~ /marcstd/) { $format = 'marcstd'; } elsif ( $format =~ /isbd/ ) { - my $framework = GetFrameworkCode( $biblionumber ); $marc = GetISBDView({ 'record' => $marc, 'template' => 'opac', diff --git a/opac/opac-shelves.pl b/opac/opac-shelves.pl index 67c7313ebc..25120e7947 100755 --- a/opac/opac-shelves.pl +++ b/opac/opac-shelves.pl @@ -261,6 +261,11 @@ if ( $op eq 'view' ) { my $biblionumber = $content->biblionumber->biblionumber; my $this_item = GetBiblioData($biblionumber); my $record = GetMarcBiblio($biblionumber); + my $framework = GetFrameworkCode( $biblionumber ); + $record_processor->options({ + interface => 'opac', + frameworkcode => $framework + }); $record_processor->process($record); if ( $xslfile ) { diff --git a/opac/opac-showmarc.pl b/opac/opac-showmarc.pl index 18be49e301..250c519511 100755 --- a/opac/opac-showmarc.pl +++ b/opac/opac-showmarc.pl @@ -48,8 +48,11 @@ if ($importid) { } else { $record = GetMarcBiblio($biblionumber); - my $frameworkcode = GetFrameworkCode($biblionumber); - $record_processor->options({ frameworkcode => $frameworkcode}); + my $framework = GetFrameworkCode($biblionumber); + $record_processor->options({ + interface => 'opac', + frameworkcode => $framework + }); } if(!ref $record) { -- 2.39.5