adding Content-Disposition to header to allow for browsers to recognize
[koha.git] / search.pl
index f430dba..53d1f8d 100755 (executable)
--- a/search.pl
+++ b/search.pl
@@ -1,5 +1,6 @@
 #!/usr/bin/perl
 
+# $Id$
 # Copyright 2000-2002 Katipo Communications
 #
 # This file is part of Koha.
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 
+# $Log$
+# Revision 1.36  2005/06/20 14:39:11  tipaul
+# synch'ing 2.2 and head
+#
+# Revision 1.35.2.1  2005/05/27 10:02:50  hdl
+# Bug Fixing : Using old search.pl with subjectitems In normal mode display.
+# Problem : Changing Page doesn't work.
+#
+# Revision 1.35  2004/04/07 22:43:04  rangi
+# Fix for bug 217
+#
+# Revision 1.34  2004/02/11 08:35:31  tipaul
+# synch'ing 2.0.0 branch and head
+#
+# Revision 1.33  2003/12/19 17:28:03  tipaul
+# fix for #683
+#
+# Revision 1.32.2.2  2004/01/13 17:33:39  tipaul
+# removing useless (& buggy here) checkauth
+#
+# Revision 1.32.2.1  2003/12/19 17:28:42  tipaul
+# fix for 683
+#
+# Revision 1.32  2003/06/11 18:37:55  tonnesen
+# Using boolean_preference instead of preference for 'marc' setting
+#
+# Revision 1.31  2003/05/11 07:31:37  rangi
+# Removing duplicate use C4::Auth
+#
+
 use strict;
 require Exporter;
 use CGI;
@@ -24,17 +55,12 @@ use C4::Auth;
 use HTML::Template;
 use C4::Context;
 use C4::Search;
-use C4::Auth;
 use C4::Output;
 use C4::Interface::CGI::Output;
 
 my $query=new CGI;
 my $type=$query->param('type');
 
-#(-e "opac") && ($type='opac');
-
-my ($loggedinuser, $cookie, $sessionID) = checkauth($query, ($type eq 'opac') ? (1) : (0));
-
 my $startfrom=$query->param('startfrom');
 ($startfrom) || ($startfrom=0);
 
@@ -80,7 +106,7 @@ my @forminputs;                      # This is used in the form template.
 
 foreach my $term (qw(keyword subject author illustrator itemnumber
                     isbn date-before class dewey branch title abstract
-                    publisher ttype))
+                    publisher ttype subjectitems))
 {
        my $value = $query->param($term);
        next unless defined $value && $value ne "";
@@ -148,6 +174,14 @@ if ($search{"dewey"}){
     $search .= "&dewey=$search{dewey}";
     $searchdesc.="dewey $search{dewey}, ";
 }
+if ($search{"illustrator"}){
+    $search .= "&illustrator=$search{illustrator}";
+    $searchdesc.="illustrator $search{illustrator}, ";
+}
+if ($search{"itemnumber"}){
+    $search .= "&itemnumber=$search{itemnumber}";
+    $searchdesc.="barcode $search{itemnumber}, ";
+}
 $search.="&ttype=$search{ttype}";
 
 $search=~ s/ /%20/g;
@@ -169,7 +203,6 @@ $template->param(search => $search);
 $template->param(searchdesc => $searchdesc);
 $template->param(SEARCH_RESULTS => $resultsarray);
 #$template->param(includesdir => $includes);
-$template->param(loggedinuser => $loggedinuser);
 
 my @numbers = ();
 if ($count>10) {
@@ -193,12 +226,20 @@ if ($count>10) {
 }
 
 $template->param(numbers => \@numbers);
-if (C4::Context->preference('acquisitions') eq 'simple') {
+if (C4::Context->boolean_preference('marc') eq '1') {
        $template->param(script => "MARCdetail.pl");
 } else {
        $template->param(script => "detail.pl");
 }
 
-# Print the page
-output_html_with_http_headers $query, $cookie, $template->output;
-
+if ($search{"itemnumber"} && $count == 1){
+    # if its a barcode search by definition we will only have one result.
+    # And if we have a result
+    # lets jump straight to the detail.pl page
+    print $query->redirect("/cgi-bin/koha/detail.pl?type=intra&bib=$results[0]->{'biblionumber'}");
+}
+else {
+    # otherwise
+    # Print the page
+    output_html_with_http_headers $query, $cookie, $template->output;
+}