Bug 5251 : Enhancement: [3.2] (Resubmission) Adding code to support using gmail as...
[koha.git] / opac / opac-search.pl
index 45cb766..778c7ca 100755 (executable)
@@ -1,6 +1,7 @@
 #!/usr/bin/perl
 
 # Copyright 2008 Garry Collum and the Koha Koha Development team
+# Copyright 2010 BibLibre
 #
 # This file is part of Koha.
 #
@@ -80,9 +81,12 @@ else {
     template_name => $template_name,
     query => $cgi,
     type => "opac",
-    authnotrequired => 1,
+    authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ),
     }
 );
+if ($template_name eq 'opac-results.tmpl') {
+   $template->param('COinSinOPACResults' => C4::Context->preference('COinSinOPACResults'));
+}
 
 if ($format eq 'rss2' or $format eq 'opensearchdescription' or $format eq 'atom') {
        $template->param($format => 1);
@@ -139,10 +143,9 @@ if (C4::Context->preference('TagsEnabled')) {
 #}
 
 # load the branches
-my $mybranch = ( C4::Context->preference('SearchMyLibraryFirst') && C4::Context->userenv && C4::Context->userenv->{branch} ) ? C4::Context->userenv->{branch} : '';
+
 my $branches = GetBranches();   # used later in *getRecords, probably should be internalized by those functions after caching in C4::Branch is established
 $template->param(
-    branchloop       => GetBranchesLoop($mybranch, 0),
     searchdomainloop => GetBranchCategories(undef,'searchdomain'),
 );
 
@@ -161,8 +164,8 @@ my $advanced_search_types = C4::Context->preference("AdvancedSearchTypes");
 
 if (!$advanced_search_types or $advanced_search_types eq 'itemtypes') {
        foreach my $thisitemtype ( sort {$itemtypes->{$a}->{'description'} cmp $itemtypes->{$b}->{'description'} } keys %$itemtypes ) {
-        my %row =(  number=>$cnt++,
-                               ccl => $itype_or_itemtype,
+           my %row =(  number=>$cnt++,
+               ccl => "$itype_or_itemtype,phr",
                 code => $thisitemtype,
                 selected => $selected,
                 description => $itemtypes->{$thisitemtype}->{'description'},
@@ -317,7 +320,7 @@ my @limits;
 @limits = split("\0",$params->{'limit'}) if $params->{'limit'};
 
 if($params->{'multibranchlimit'}) {
-push @limits, join(" or ", map { "branch: $_ "}  @{GetBranchesInCategory($params->{'multibranchlimit'})}) ;
+    push @limits, '('.join( " or ", map { "branch: $_ " } @{ GetBranchesInCategory( $params->{'multibranchlimit'} ) } ).')';
 }
 
 my $available;
@@ -468,9 +471,11 @@ for (my $i=0;$i<@servers;$i++) {
                                                                                limit=>$tag_quantity });
                        }
                }
-               foreach (@newresults) {
-                   $_->{coins} = GetCOinSBiblio($_->{'biblionumber'});
-               }
+                if (C4::Context->preference('COinSinOPACResults')) {
+                   foreach (@newresults) {
+                     $_->{coins} = GetCOinSBiblio($_->{'biblionumber'});
+                   }
+                }
       
        if ($results_hashref->{$server}->{"hits"}){
            $total = $total + $results_hashref->{$server}->{"hits"};
@@ -504,6 +509,7 @@ for (my $i=0;$i<@servers;$i++) {
                    $template->param(ShowOpacRecentSearchLink => 1);
                }
  
+            shift @recentSearches if (@recentSearches > 15);
                # Pushing the cookie back 
                $newsearchcookie = $cgi->cookie(
                                            -name => 'KohaOpacRecentSearches',
@@ -628,6 +634,7 @@ $template->param(
             total => $total,
             opacfacets => 1,
             facets_loop => $facets,
+           displayFacetCount=> C4::Context->preference('displayFacetCount')||0,
             scan => $scan,
             search_error => $error,
 );