Bug 10204 - Patron image no longer appears in the OPAC
[koha.git] / opac / opac-search.pl
index a0ba296..363a11e 100755 (executable)
@@ -63,6 +63,21 @@ my $DisplayMultiPlaceHold = C4::Context->preference("DisplayMultiPlaceHold");
 use CGI qw('-no_undef_params');
 my $cgi = new CGI;
 
+my $branch_group_limit = $cgi->param("branch_group_limit");
+if ( $branch_group_limit ) {
+    if ( $branch_group_limit =~ /^multibranchlimit/ ) {
+        $cgi->param(
+            -name => 'multibranchlimit',
+            -values => [ ( split( 'multibranchlimit-', $branch_group_limit ) )[1] ]
+        );
+    } else {
+        $cgi->append(
+            -name => 'limit',
+            -values => [ $branch_group_limit ]
+        );
+    }
+}
+
 BEGIN {
     if (C4::Context->preference('BakerTaylorEnabled')) {
         require C4::External::BakerTaylor;
@@ -77,6 +92,7 @@ my $template_name;
 my $template_type = 'basic';
 my @params = $cgi->param("limit");
 
+
 my $format = $cgi->param("format") || '';
 my $build_grouped_results = C4::Context->preference('OPACGroupResults');
 if ($format =~ /(rss|atom|opensearchdescription)/) {
@@ -636,7 +652,7 @@ for (my $i=0;$i<@servers;$i++) {
                 $newsearchcookie = $cgi->cookie(
                             -name => 'KohaOpacRecentSearches',
                             # We uri_escape the whole freezed structure so we're sure we won't have any encoding problems
-                            -value => uri_escape(freeze(\@recentSearches)),
+                            -value =>freeze(\@recentSearches),
                             -expires => ''
                 );
                 $cookie = [$cookie, $newsearchcookie];
@@ -699,6 +715,42 @@ for (my $i=0;$i<@servers;$i++) {
             $template->param(results_per_page =>  $results_per_page);
             my $hide = C4::Context->preference('OpacHiddenItems');
             $hide = ($hide =~ m/\S/) if $hide; # Just in case it has some spaces/new lines
+            my $branch = '';
+            if (C4::Context->userenv){
+                $branch = C4::Context->userenv->{branch};
+            }
+            if ( C4::Context->preference('HighlightOwnItemsOnOPAC') ) {
+                if (
+                    ( ( C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'PatronBranch' ) && $branch )
+                    ||
+                    C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'OpacURLBranch'
+                ) {
+                    my $branchname;
+                    if ( C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'PatronBranch' ) {
+                        $branchname = $branches->{$branch}->{'branchname'};
+                    }
+                    elsif (  C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'OpacURLBranch' ) {
+                        $branchname = $branches->{ $ENV{'BRANCHCODE'} }->{'branchname'};
+                    }
+
+                    foreach my $res ( @newresults ) {
+                        my @new_loop;
+                        my @top_loop;
+                        my @old_loop = @{$res->{'available_items_loop'}};
+                        foreach my $item ( @old_loop ) {
+                            if ( $item->{'branchname'} eq $branchname ) {
+                                $item->{'this_branch'} = 1;
+                                push( @top_loop, $item );
+                            } else {
+                                push( @new_loop, $item );
+                            }
+                        }
+                        my @complete_loop = ( @top_loop, @new_loop );
+                        $res->{'available_items_loop'} = \@complete_loop;
+                    }
+                }
+            }
+
             $template->param(
                 SEARCH_RESULTS => \@newresults,
                 OPACItemsResultsDisplay => (C4::Context->preference("OPACItemsResultsDisplay")),