X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=catalogue%2Fsearch.pl;h=b0fea2aa565704c78fd1530c72ea50a8b49c71a4;hb=ee3707d0de8ba0a0e88dcffad31f5b89997b3f5f;hp=ea3d323c90c7f648a6c91fa230db97a901684390;hpb=f7d5759a0d0f60b1446ec24d886961e2fe58c845;p=koha_fer diff --git a/catalogue/search.pl b/catalogue/search.pl index ea3d323c90..b0fea2aa56 100755 --- a/catalogue/search.pl +++ b/catalogue/search.pl @@ -15,9 +15,9 @@ # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR # A PARTICULAR PURPOSE. See the GNU General Public License for more details. # -# You should have received a copy of the GNU General Public License along with -# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. =head1 NAME @@ -79,7 +79,7 @@ There are several additional secondary functions performed that I will not cover in detail. =head3 1. Building Query Strings - + There are several types of queries needed in the process of search and retrieve: =over @@ -132,6 +132,7 @@ Not yet completed... =cut use strict; # always use +#use warnings; FIXME - Bug 2505 ## STEP 1. Load things that are used in both search page and # results page and decide which template to load, operations @@ -140,13 +141,15 @@ use strict; # always use ## load Koha modules use C4::Context; use C4::Output; -use C4::Auth; +use C4::Auth qw(:DEFAULT get_session); use C4::Search; use C4::Languages qw(getAllLanguages); use C4::Koha; +use C4::VirtualShelves qw(GetRecentShelves); use POSIX qw(ceil floor); use C4::Branch; # GetBranches +my $DisplayMultiPlaceHold = C4::Context->preference("DisplayMultiPlaceHold"); # create a new CGI object # FIXME: no_undef_params needs to be tested use CGI qw('-no_undef_params'); @@ -204,16 +207,20 @@ if (C4::Context->preference("marcflavour") eq "UNIMARC" ) { # load the branches my $branches = GetBranches(); -my @branch_loop; -# we need to know the borrower branch code to set a default branch -my $borrowerbranchcode = C4::Context->userenv->{'branch'}; - -for my $branch_hash (sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} } keys %$branches) { - # if independantbranches is activated, set the default branch to the borrower branch - my $selected = (C4::Context->preference("independantbranches") and ($borrowerbranchcode eq $branch_hash)) ? 1 : undef; - push @branch_loop, {value => "$branch_hash" , branchname => $branches->{$branch_hash}->{'branchname'}, selected => $selected}; -} +# Populate branch_loop with all branches sorted by their name. If +# independantbranches is activated, set the default branch to the borrower +# branch, except for superlibrarian who need to search all libraries. +my $user = C4::Context->userenv; +my @branch_loop = map { + { + value => $_, + branchname => $branches->{$_}->{branchname}, + selected => $user->{branch} eq $_ && C4::Branch::onlymine(), + } +} sort { + $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} +} keys %$branches; my $categories = GetBranchCategories(undef,'searchdomain'); @@ -317,6 +324,8 @@ if ( $template_type eq 'advsearch' ) { $template->param( expanded_options => $cgi->param('expanded_options')); } + $template->param(virtualshelves => C4::Context->preference("virtualshelves")); + output_html_with_http_headers $cgi, $cookie, $template->output; exit; } @@ -494,6 +503,12 @@ if (C4::Context->preference('NoZebra')) { ($error, $results_hashref, $facets) = getRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,$branches,$query_type,$scan); }; } +# This sorts the facets into alphabetical order +if ($facets) { + foreach my $f (@$facets) { + $f->{facets} = [ sort { uc($a->{facet_title_value}) cmp uc($b->{facet_title_value}) } @{ $f->{facets} } ]; + } +} if ($@ || $error) { $template->param(query_error => $error.$@); output_html_with_http_headers $cgi, $cookie, $template->output; @@ -508,7 +523,8 @@ for (my $i=0;$i<@servers;$i++) { if ($server =~/biblioserver/) { # this is the local bibliographic server $hits = $results_hashref->{$server}->{"hits"}; my $page = $cgi->param('page') || 0; - my @newresults = searchResults( $query_desc,$hits,$results_per_page,$offset,$scan,@{$results_hashref->{$server}->{"RECORDS"}}); + my @newresults = searchResults('intranet', $query_desc, $hits, $results_per_page, $offset, $scan, + @{$results_hashref->{$server}->{"RECORDS"}}); $total = $total + $results_hashref->{$server}->{"hits"}; ## If there's just one result, redirect to the detail page if ($total == 1) { @@ -537,6 +553,8 @@ for (my $i=0;$i<@servers;$i++) { $template->param(query_cgi => $query_cgi); $template->param(query_desc => $query_desc); $template->param(limit_desc => $limit_desc); + $template->param(offset => $offset); + $template->param(DisplayMultiPlaceHold => $DisplayMultiPlaceHold); $template->param (z3950_search_params => C4::Search::z3950_search_args($query_desc)); if ($query_desc || $limit_desc) { $template->param(searchdesc => 1); @@ -636,4 +654,26 @@ if ($query_desc || $limit_desc) { } # VI. BUILD THE TEMPLATE + +# Build drop-down list for 'Add To:' menu... + +my $row_count = 10; # FIXME:This probably should be a syspref +my ($pubshelves, $total) = GetRecentShelves(2, $row_count, undef); +my ($barshelves, $total) = GetRecentShelves(1, $row_count, $borrowernumber); + +my @pubshelves = @{$pubshelves}; +my @barshelves = @{$barshelves}; + +if (@pubshelves) { + $template->param( addpubshelves => scalar (@pubshelves)); + $template->param( addpubshelvesloop => @pubshelves); +} + +if (@barshelves) { + $template->param( addbarshelves => scalar (@barshelves)); + $template->param( addbarshelvesloop => @barshelves); +} + + + output_html_with_http_headers $cgi, $cookie, $template->output;