Bug 11592: (QA followup) Add missing framework code to ViewPolicy filter calls
authorTomas Cohen Arazi <tomascohen@theke.io>
Tue, 30 Aug 2016 15:44:14 +0000 (12:44 -0300)
committerKyle M Hall <kyle@bywatersolutions.com>
Thu, 8 Sep 2016 11:54:22 +0000 (11:54 +0000)
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 <tomascohen@theke.io>
Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
catalogue/ISBDdetail.pl
opac/opac-ISBDdetail.pl
opac/opac-MARCdetail.pl
opac/opac-basket.pl
opac/opac-detail.pl
opac/opac-downloadcart.pl
opac/opac-downloadshelf.pl
opac/opac-export.pl
opac/opac-shelves.pl
opac/opac-showmarc.pl

index cb5081f..4679b9e 100755 (executable)
@@ -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',
index 3dc15df..c55829c 100755 (executable)
@@ -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',
index b16538a..3c9c2c2 100755 (executable)
@@ -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;
 
index 4fd2108..29337ea 100755 (executable)
@@ -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 );
index 46abc6f..de1b72f 100755 (executable)
@@ -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
index 1cf0de0..75ab4a1 100755 (executable)
@@ -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;
index 9f98d91..142577b 100755 (executable)
@@ -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',
index d5f4c4f..c0f18bf 100755 (executable)
@@ -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',
index 67c7313..25120e7 100755 (executable)
@@ -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 ) {
index 18be49e..250c519 100755 (executable)
@@ -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) {