Bug 29844: Fix ->search occurrences
[srvgit] / opac / opac-shelves.pl
index 90ec38c..f2d2ae6 100755 (executable)
@@ -83,8 +83,8 @@ if (C4::Context->preference("BakerTaylorEnabled")) {
 }
 
 my $referer  = $query->param('referer')  || $op;
-my $category = 1;
-$category = 2 if $query->param('category') && $query->param('category') == 2;
+my $public = 0;
+$public = 1 if $query->param('public') && $query->param('public') == 1;
 
 my ( $shelf, $shelfnumber, @messages );
 
@@ -96,7 +96,7 @@ if ( $op eq 'add_form' ) {
     $shelf       = Koha::Virtualshelves->find($shelfnumber);
 
     if ( $shelf ) {
-        $category = $shelf->category;
+        $public = $shelf->public;
         my $patron = Koha::Patrons->find( $shelf->owner );
         $template->param( owner => $patron, );
         unless ( $shelf->can_be_managed( $loggedinuser ) ) {
@@ -113,7 +113,7 @@ if ( $op eq 'add_form' ) {
             $shelf = Koha::Virtualshelf->new(
                 {   shelfname          => scalar $query->param('shelfname'),
                     sortfield          => scalar $query->param('sortfield'),
-                    category           => $category,
+                    public             => $public,
                     allow_change_from_owner => $allow_changes_from > 0,
                     allow_change_from_others => $allow_changes_from == ANYONE,
                     owner              => scalar $loggedinuser,
@@ -147,7 +147,7 @@ if ( $op eq 'add_form' ) {
             my $allow_changes_from = $query->param('allow_changes_from');
             $shelf->allow_change_from_owner( $allow_changes_from > 0 );
             $shelf->allow_change_from_others( $allow_changes_from == ANYONE );
-            $shelf->category( $category );
+            $shelf->public( $public );
             eval { $shelf->store };
 
             if ($@) {
@@ -259,7 +259,7 @@ if ( $op eq 'view' ) {
     $shelf = Koha::Virtualshelves->find($shelfnumber);
     if ( $shelf ) {
         if ( $shelf->can_be_viewed( $loggedinuser ) ) {
-            $category = $shelf->category;
+            $public = $shelf->public;
 
             # Sortfield param may still include sort order with :asc or :desc, but direction overrides it
             my( $sortfield, $direction );
@@ -303,11 +303,6 @@ if ( $op eq 'view' ) {
                 $categorycode = $patron ? $patron->categorycode : undef;
             }
 
-            # Lists display falls back to search results configuration
-            my $xslfile = C4::Context->preference('OPACXSLTListsDisplay') || "default";
-            my $lang   = C4::Languages::getlanguage();
-            my $sysxml = C4::XSLT::get_xslt_sysprefs();
-
             my $record_processor = Koha::RecordProcessor->new({ filters => 'ViewPolicy' });
 
             my $art_req_itypes;
@@ -374,13 +369,17 @@ if ( $op eq 'view' ) {
                     anonymous_session => ($loggedinuser) ? 0 : 1
                 };
                 $this_item->{XSLTBloc} = XSLTParse4Display(
-                    $biblionumber,          $record,
-                    "OPACXSLTListsDisplay", 1,
-                    undef,                 $sysxml,
-                    $xslfile,              $lang,
-                    $variables,            $items->reset
+                    {
+                        biblionumber   => $biblionumber,
+                        record         => $record,
+                        xsl_syspref    => "OPACXSLTListsDisplay",
+                        fix_amps       => 1,
+                        xslt_variables => $variables,
+                        items_rs       => $items->reset,
+                    }
                 );
 
+
                 if ( grep {$_ eq $biblionumber} @cart_list) {
                     $this_item->{incart} = 1;
                 }
@@ -401,7 +400,7 @@ if ( $op eq 'view' ) {
                 csv_profiles => [
                     Koha::CsvProfiles->search(
                         { type => 'marc', used_for => 'export_records', staff_only => 0 }
-                    )
+                    )->as_list
                 ],
             );
             if ( $page ) {
@@ -425,7 +424,7 @@ if ( $op eq 'view' ) {
 if ( $op eq 'list' ) {
     my $shelves;
     my ( $page, $rows ) = ( $query->param('page') || 1, 20 );
-    if ( $category == 1 ) {
+    if ( !$public ) {
         $shelves = Koha::Virtualshelves->get_private_shelves({ page => $page, rows => $rows, borrowernumber => $loggedinuser, });
     } else {
         $shelves = Koha::Virtualshelves->get_public_shelves({ page => $page, rows => $rows, });
@@ -436,7 +435,7 @@ if ( $op eq 'list' ) {
         shelves => $shelves,
         pagination_bar => pagination_bar(
             q||, $pager->last_page - $pager->first_page + 1,
-            $page, "page", { op => 'list', category => $category, }
+            $page, "page", { op => 'list', public => $public, }
         ),
     );
 }
@@ -446,7 +445,7 @@ $template->param(
     referer  => $referer,
     shelf    => $shelf,
     messages => \@messages,
-    category => $category,
+    public   => $public,
     print    => scalar $query->param('print') || 0,
     listsview => 1,
 );