From 093e3f52154aa15d16cadd497ad3ceadbee78fbf Mon Sep 17 00:00:00 2001 From: Joe Atzberger Date: Tue, 4 Dec 2007 17:40:48 -0600 Subject: [PATCH] opac subdir - Dates.pm integration and warnings fixes. Signed-off-by: Chris Cormack Signed-off-by: Joshua Ferraro --- opac/opac-account.pl | 5 +- opac/opac-alert-subscribe.pl | 2 +- opac/opac-detailprint.pl | 2 +- opac/opac-ics.pl | 2 +- opac/opac-logout.pl | 14 +-- opac/opac-readingrecord.pl | 2 +- opac/opac-reserve.pl | 2 +- opac/opac-search.pl | 46 ++++---- opac/opac-serial-issues.pl | 2 +- opac/opac-topissues.pl | 6 +- opac/opac-user.pl | 2 +- opac/opac-userdetails.pl | 2 +- opac/opac-userupdate.pl | 2 +- opac/sco/printer.pl | 210 ++++++++++++++--------------------- opac/sco/sco-circ.pl | 2 +- opac/sco/sco-main.pl | 2 +- 16 files changed, 128 insertions(+), 175 deletions(-) diff --git a/opac/opac-account.pl b/opac/opac-account.pl index 96d9c81713..0f84f1a83c 100755 --- a/opac/opac-account.pl +++ b/opac/opac-account.pl @@ -24,7 +24,7 @@ use C4::Members; use C4::Circulation; use C4::Auth; use C4::Output; -use C4::Date; +use C4::Dates; my $query = new CGI; my ( $template, $borrowernumber, $cookie ) = get_template_and_user( @@ -40,7 +40,6 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( # get borrower information .... my $borr = GetMemberDetails( $borrowernumber ); - my @bordat; $bordat[0] = $borr; @@ -63,7 +62,7 @@ for ( my $i = 0 ; $i < $numaccts ; $i++ ) { if ( $accts->[$i]{'accounttype'} ne 'F' && $accts->[$i]{'accounttype'} ne 'FU' ) { - $accts->[$i]{'print_title'}; + $accts->[$i]{'print_title'}; # FIXME: Useless use of hash element in void context } } diff --git a/opac/opac-alert-subscribe.pl b/opac/opac-alert-subscribe.pl index 9051e8c0c5..d357af4b0c 100755 --- a/opac/opac-alert-subscribe.pl +++ b/opac/opac-alert-subscribe.pl @@ -21,7 +21,7 @@ use strict; use CGI; use C4::Auth; -use C4::Date; +use C4::Dates; use C4::Output; use C4::Context; use C4::Koha; diff --git a/opac/opac-detailprint.pl b/opac/opac-detailprint.pl index 72a16c3728..35a19e9cfa 100755 --- a/opac/opac-detailprint.pl +++ b/opac/opac-detailprint.pl @@ -25,7 +25,7 @@ use CGI; use C4::Biblio; use C4::Auth; use C4::Output; -use C4::Date; +use C4::Dates; my $query = new CGI; my $type = $query->param('type'); diff --git a/opac/opac-ics.pl b/opac/opac-ics.pl index c927e4f1d3..58edfbfc34 100755 --- a/opac/opac-ics.pl +++ b/opac/opac-ics.pl @@ -30,7 +30,7 @@ use C4::Auth; use C4::Koha; use C4::Circulation; use C4::Members; -use C4::Date; +use C4::Dates; my $query = new CGI; my ( $template, $borrowernumber, $cookie ) = get_template_and_user( diff --git a/opac/opac-logout.pl b/opac/opac-logout.pl index ab141c47ce..e2dedcc759 100755 --- a/opac/opac-logout.pl +++ b/opac/opac-logout.pl @@ -26,7 +26,6 @@ my $query=new CGI; my $sessionID=$query->cookie('sessionID'); - if ($ENV{'REMOTE_USER'}) { print $query->header(); print startpage(); @@ -53,23 +52,26 @@ while (my ($sid, $u, $lasttime) = split(/:/, )) { $sessions->{$sid}->{'userid'}=$u; $sessions->{$sid}->{'lasttime'}=$lasttime; } +close S; open (S, ">/tmp/sessions"); foreach (keys %$sessions) { - my $userid=$sessions->{$_}->{'userid'}; + my $userid=$sessions->{$_}->{'userid'}; my $lasttime=$sessions->{$_}->{'lasttime'}; print S "$_:$userid:$lasttime\n"; } +close S; my $dbh = C4::Context->dbh; # Check that this is the ip that created the session before deleting it +# This script and function are apparently unfinished. --atz (Dec 4 2007) my $session = get_session($sessionID); $session->flush; $session->delete; my $sth=$dbh->prepare("delete from sessions where sessionID=?"); $sth->execute($sessionID); open L, ">>/tmp/sessionlog"; -my $time=localtime(time()); -printf L "%20s from %16s logged out at %30s (manual log out).\n", $userid, $ip, $time; +printf L "%20s from %16s logged out at %30s (manual log out).\n", $userid, $ip, localtime; + # where is $ip is coming from?? close L; my $cookie=$query->cookie(-name => 'sessionID', @@ -77,10 +79,6 @@ my $cookie=$query->cookie(-name => 'sessionID', -expires => '+1y'); # Should redirect to opac home page after logging out - print $query->redirect("/cgi-bin/koha/opac-main.pl"); - exit; -# - diff --git a/opac/opac-readingrecord.pl b/opac/opac-readingrecord.pl index b202ee5228..6ff2f98a94 100755 --- a/opac/opac-readingrecord.pl +++ b/opac/opac-readingrecord.pl @@ -23,7 +23,7 @@ use CGI; use C4::Auth; use C4::Koha; use C4::Circulation; -use C4::Date; +use C4::Dates; use C4::Members; use C4::Output; diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl index 7047265211..91577c5d93 100755 --- a/opac/opac-reserve.pl +++ b/opac/opac-reserve.pl @@ -24,7 +24,7 @@ use C4::Koha; use C4::Circulation; use C4::Reserves; use C4::Output; -use C4::Date; +use C4::Dates; use C4::Context; use C4::Members; use C4::Branch; # GetBranches diff --git a/opac/opac-search.pl b/opac/opac-search.pl index 2cb8677c83..58fc3f5a26 100755 --- a/opac/opac-search.pl +++ b/opac/opac-search.pl @@ -362,20 +362,19 @@ my @operators; # indexes are query qualifiers, like 'title', 'author', etc. They # can be single or multiple parameters separated by comma: kw,right-Truncation -my @indexes; -@indexes = split("\0",$params->{'idx'}); +my @indexes = split("\0",$params->{'idx'}); # if a simple index (only one) display the index used in the top search box -if (@indexes[0] && !@indexes[1]) { - $template->param("ms_".@indexes[0] => 1); +if ($indexes[0] && !$indexes[1]) { + $template->param("ms_".$indexes[0] => 1); } # an operand can be a single term, a phrase, or a complete ccl query my @operands; @operands = split("\0",$params->{'q'}) if $params->{'q'}; # if a simple search, display the value in the search box -if (@operands[0] && !@operands[1]) { - $template->param(ms_value => @operands[0]); +if ($operands[0] && !$operands[1]) { + $template->param(ms_value => $operands[0]); } # limits are use to limit to results to a pre-defined category such as branch or language @@ -408,35 +407,31 @@ my $hits; my $expanded_facet = $params->{'expand'}; # Define some global variables -my ( $error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$stopwords_removed,$query_type); +my ($error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$stopwords_removed,$query_type); my @results; ## I. BUILD THE QUERY ( $error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$stopwords_removed,$query_type) = buildQuery(\@operators,\@operands,\@indexes,\@limits,\@sort_by); -## parse the query_cgi string and put it into a form suitable for s -my @query_inputs; -for my $this_cgi ( split('&',$query_cgi) ) { - next unless $this_cgi; - $this_cgi =~ m/(.*=)(.*)/; - my $input_name = $1; - my $input_value = $2; - $input_name =~ s/=$//; - push @query_inputs, { input_name => $input_name, input_value => $input_value }; +sub _input_cgi_parse ($) { + my @elements; + for my $this_cgi ( split('&',shift) ) { + next unless $this_cgi; + $this_cgi =~ /(.*)=(.*)/; + my $input_name = $1; + my $input_value = $2; + push @elements, { input_name => $input_name, input_value => $input_value }; + } + return @elements; } + +## parse the query_cgi string and put it into a form suitable for s +my @query_inputs = _input_cgi_parse($query_cgi); $template->param ( QUERY_INPUTS => \@query_inputs ); ## parse the limit_cgi string and put it into a form suitable for s -my @limit_inputs; -for my $this_cgi ( split('&',$limit_cgi) ) { - next unless $this_cgi; - $this_cgi =~ m/(.*=)(.*)/; - my $input_name = $1; - my $input_value = $2; - $input_name =~ s/=$//; - push @limit_inputs, { input_name => $input_name, input_value => $input_value }; -} +my @limit_inputs = _input_cgi_parse($query_cgi); # add OPAC 'hidelostitems' # not items with @@ -467,7 +462,6 @@ if (C4::Context->preference('NoZebra')) { } if ($@ || $error) { $template->param(query_error => $error.$@); - output_html_with_http_headers $cgi, $cookie, $template->output; exit; } diff --git a/opac/opac-serial-issues.pl b/opac/opac-serial-issues.pl index 74cd6fa68d..d54ebdba6c 100755 --- a/opac/opac-serial-issues.pl +++ b/opac/opac-serial-issues.pl @@ -22,7 +22,7 @@ use strict; use CGI; use C4::Auth; use C4::Koha; -use C4::Date; +use C4::Dates; use C4::Serials; use C4::Letters; use C4::Output; diff --git a/opac/opac-topissues.pl b/opac/opac-topissues.pl index 6e995cea92..f47c138cef 100755 --- a/opac/opac-topissues.pl +++ b/opac/opac-topissues.pl @@ -94,8 +94,8 @@ $template->param(do_it => 1, results_loop => \@results, ); -# load the branches -my $branches = GetBranches(); +# load the branches ## again?? +$branches = GetBranches(); my @branch_loop; for my $branch_hash (sort keys %$branches ) { my $selected=(C4::Context->userenv && ($branch_hash eq C4::Context->userenv->{branch})) if (C4::Context->preference('SearchMyLibraryFirst')); @@ -109,7 +109,7 @@ for my $branch_hash (sort keys %$branches ) { $template->param( branchloop => \@branch_loop, "mylibraryfirst"=>C4::Context->preference("SearchMyLibraryFirst")); #doctype -my $itemtypes = GetItemTypes; +$itemtypes = GetItemTypes; my @itemtypeloop; foreach my $thisitemtype (keys %$itemtypes) { my %row =(value => $thisitemtype, diff --git a/opac/opac-user.pl b/opac/opac-user.pl index 2db17ea445..87374095a8 100755 --- a/opac/opac-user.pl +++ b/opac/opac-user.pl @@ -27,7 +27,7 @@ use C4::Reserves; use C4::Members; use C4::Output; use C4::Biblio; -use C4::Date; +use C4::Dates; use C4::Letters; use C4::Branch; # GetBranches diff --git a/opac/opac-userdetails.pl b/opac/opac-userdetails.pl index e09f523604..b3dcde9924 100755 --- a/opac/opac-userdetails.pl +++ b/opac/opac-userdetails.pl @@ -25,7 +25,7 @@ use C4::Koha; use C4::Circulation; use C4::Output; -use C4::Date; +use C4::Dates; use C4::Members; my $query = new CGI; diff --git a/opac/opac-userupdate.pl b/opac/opac-userupdate.pl index c2a5826505..45aaebf25b 100755 --- a/opac/opac-userupdate.pl +++ b/opac/opac-userupdate.pl @@ -27,7 +27,7 @@ use C4::Context; use C4::Koha; use C4::Circulation; use C4::Output; -use C4::Date; +use C4::Dates; use C4::Members; my $query = new CGI; diff --git a/opac/sco/printer.pl b/opac/sco/printer.pl index 32c4a131a8..8e89952b16 100755 --- a/opac/sco/printer.pl +++ b/opac/sco/printer.pl @@ -34,7 +34,7 @@ use C4::Authsco; use C4::Output; use C4::Koha; use HTML::Template::Pro; -use C4::Date; +use C4::Dates; my $query=new CGI; #my ($loggedinuser, $sessioncookie, $sessionID) = checkauth @@ -70,7 +70,7 @@ my $printer = getprinter($query, $printers); my $branchcookie; my $printercookie; if ($query->param('setcookies')) { - $branchcookie = $query->cookie(-name=>'branch', -value=>"$branch", -expires=>'+1y'); + $branchcookie = $query->cookie(-name=>'branch', -value=>"$branch", -expires=>'+1y'); $printercookie = $query->cookie(-name=>'printer', -value=>"$printer", -expires=>'+1y'); } @@ -91,9 +91,6 @@ my $todaysdate = (1900+$datearr[5]).sprintf ("%0.2d", ($datearr[4]+1)).sprintf ( #$template->param(BORROWER_INFO => \@bordat); - - - ######################End code modified by christina Lee############################ my $message; @@ -148,27 +145,23 @@ if (my $qnumber = $query->param('questionnumber')) { } - my ($iteminformation, $duedate, $rejected, $question, $questionnumber, $defaultanswer); #Begin code edited by Christina Lee #my $barc = 123456789; my $barc = cuecatbarcodedecode($barcode); - (my $year, my $month, my $day) = set_duedate($barc); #End code edited by Christina Lee # if the barcode is set if ($barcode) { $barcode = cuecatbarcodedecode($barcode); - - #note: edit code here --Christina Lee my ($datedue, $invalidduedate) = fixdate($year, $month, $day); unless ($invalidduedate) { $env{'datedue'}=$datedue; - my @time=localtime(time); + my @time=localtime(); my $date= (1900+$time[5])."-".($time[4]+1)."-".$time[3]; ($iteminformation, $duedate, $rejected, $question, $questionnumber, $defaultanswer, $message) = issuebook(\%env, $borr, $barcode, \%responses, $date); @@ -217,7 +210,7 @@ for (my $i=1; $i<32; $i++) { foreach (('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec')) { my $selected=''; if (($query->param('stickyduedate')) && ($month==$counter)) { - $selected='selected'; + $selected='selected'; } $monthoptions.="