--- loncom/interface/groupsort.pm 2001/12/11 03:19:16 1.4 +++ loncom/interface/groupsort.pm 2002/01/17 12:17:50 1.6 @@ -2,7 +2,7 @@ # The LON-CAPA group sort handler # Allows for sorting prior to import into RAT. # -# $Id: groupsort.pm,v 1.4 2001/12/11 03:19:16 harris41 Exp $ +# $Id: groupsort.pm,v 1.6 2002/01/17 12:17:50 harris41 Exp $ # # Copyright Michigan State University Board of Trustees # @@ -28,6 +28,8 @@ # # YEAR=2001 # 8/7,8/8,10/14,10/15,12/10 Scott Harrison +# YEAR=2002 +# 1/17 Scott Harrison # ### @@ -114,7 +116,7 @@ END my %shash; # sort order (key is resource location, value is sort order) my %thash; # title (key is resource location, value is title) - map { + foreach (split(/&/,$ENV{'QUERY_STRING'})) { my ($name, $value) = split(/=/,$_); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg; @@ -124,7 +126,7 @@ END if ($name eq 'catalogmode') { $ENV{'form.'.$name}=$value; } - } (split(/&/,$ENV{'QUERY_STRING'})); + } my $diropendb; if ($ENV{'form.catalogmode'} eq 'groupsearch') { $diropendb = @@ -134,19 +136,42 @@ END $diropendb = "/home/httpd/perl/tmp/$domain\_$ENV{'user.name'}_indexer.db"; } + else { # choose last accessed + my $dsearch; my $dindex; + my $dsearcht; my $dindext; + $dsearch = + "/home/httpd/perl/tmp/$domain\_$ENV{'user.name'}_searchcat.db"; + if (-e $dsearch) { + $dsearcht=(stat($dsearch))[9]; + } + $dindex = + "/home/httpd/perl/tmp/$domain\_$ENV{'user.name'}_indexer.db"; + if (-e $dindex) { + $dindext=(stat($dindex))[9]; + } + if (!$dsearcht and !$dindext) { + $diropendb=''; + } + elsif ($dsearcht>$dindext) { + $diropendb=$dsearch; + } + else { + $diropendb=$dindex; + } + } if (tie(%hash,'GDBM_File',$diropendb,&GDBM_WRCREAT,0640)) { my $acts = $ENV{'form.acts'}; my @Acts = split(/b/,$acts); my %ahash; my %achash; my $ac = 0; - map { + foreach (@Acts) { my ($state,$ref) = split(/a/); $ahash{$ref} = $state; $achash{$ref} = $ac; $ac++; - } (@Acts); - map { + } + foreach (sort {$achash{$a} <=> $achash{$b}} (keys %ahash)) { my $key = $_; if ($ahash{$key} eq '1') { # my $keyz=join("
",keys %hash); @@ -162,25 +187,25 @@ END delete $hash{'store_'.$hash{'pre_'.$key.'_link'}}; } } - } sort {$achash{$a} <=> $achash{$b}} (keys %ahash); - map { + } + foreach (keys %hash) { if ($_ =~ /^store_/) { my $key = $_; $key =~ s/^store_//; $shash{$key} = $hash{'storectr_'.$key}; $thash{$key} = $hash{'store_'.$key}; } - } keys %hash; + } if ($ENV{'form.oldval'}) { my $newctr = 0; my %chash; - map { + foreach (sort {$shash{$a} <=> $shash{$b}} (keys %shash)) { my $key = $_; $newctr++; $shash{$key} = $newctr; $hash{'storectr_'.$key} = $newctr; $chash{$newctr} = $key; - } sort {$shash{$a} <=> $shash{$b}} (keys %shash); + } my $oldval = $ENV{'form.oldval'}; my $newval = $ENV{'form.newval'}; if ($oldval != $newval) { @@ -258,7 +283,7 @@ END "\n"); $r->print("Title\n"); $r->print("Path\n"); - map { + foreach (sort {$shash{$a}<=>$shash{$b}} (keys %shash)) { my $key=$_; $ctr++; my @file_ext = split(/\./,$key); @@ -273,7 +298,7 @@ END $r->print(""); $r->print("$thash{$key}\n"); $r->print("$key\n"); - } sort {$shash{$a}<=>$shash{$b}} (keys %shash); + } $r->print(""); $r->print(<