first part of bug 490 fix
[koha_fer] / search.pl
index a46f82a..75de430 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.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;
+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));
+#(-e "opac") && ($type='opac');
 
+my ($loggedinuser, $cookie, $sessionID) = checkauth($query, ($type eq 'opac') ? (1) : (0));
 
 my $startfrom=$query->param('startfrom');
 ($startfrom) || ($startfrom=0);
 
 my $subject=$query->param('subject');
-my $template;
 # if it's a subject we need to use the subject.tmpl
+my ($template, $loggedinuser, $cookie);
 if ($subject) {
-       $template = gettemplate("catalogue/subject.tmpl",0);
+       ($template, $loggedinuser, $cookie)
+               = get_template_and_user({template_name => "catalogue/subject.tmpl",
+                            query => $query,
+                            type => "intranet",
+                            authnotrequired => 0,
+                            flagsrequired => {catalogue => 1},
+                            debug => 1,
+                            });
 } else {
-       $template = gettemplate("catalogue/searchresults.tmpl", 0);
+       ($template, $loggedinuser, $cookie)
+               = get_template_and_user({template_name => "catalogue/searchresults.tmpl",
+                            query => $query,
+                            type => "intranet",
+                            authnotrequired => 0,
+                            flagsrequired => {catalogue => 1},
+                            debug => 1,
+                            });
 }
 
 # %env
@@ -67,11 +91,11 @@ foreach my $term (qw(keyword subject author illustrator itemnumber
                     publisher ttype))
 {
        my $value = $query->param($term);
-
        next unless defined $value && $value ne "";
                                # Skip blank search terms
        $search{$term} = $value;
-       push @forminputs, { line => "$term=$value" };
+       push @forminputs, {     term => $term,
+                                                       value =>$value };
 }
 
 $template->param(FORMINPUTS => \@forminputs);
@@ -153,7 +177,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) {
@@ -177,7 +200,12 @@ if ($count>10) {
 }
 
 $template->param(numbers => \@numbers);
+if (C4::Context->boolean_preference('marc') eq '1') {
+       $template->param(script => "MARCdetail.pl");
+} else {
+       $template->param(script => "detail.pl");
+}
 
 # Print the page
-print $query->header(-cookie => $cookie), $template->output;
+output_html_with_http_headers $query, $cookie, $template->output;