--- loncom/lonnet/perl/lonnet.pm	2001/03/19 16:46:24	1.108
+++ loncom/lonnet/perl/lonnet.pm	2001/03/22 13:29:05	1.111
@@ -91,6 +91,7 @@
 # 02/27/01 Scott Harrison
 # 3/2 Gerd Kortemeyer
 # 3/15 Scott Harrison
+# 3/19,3/20 Gerd Kortemeyer
 
 package Apache::lonnet;
 
@@ -627,12 +628,60 @@ sub log {
     return critical("log:$dom:$nam:$what",$hom);
 }
 
+# --------------------------------------------- Set Expire Date for Spreadsheet
+
+sub expirespread {
+    my ($uname,$udom,$stype,$usymb)=@_;
+    my $cid=$ENV{'request.course.id'}; 
+    if ($cid) {
+       my $now=time;
+       my $key=$uname.':'.$udom.':'.$stype.':'.$usymb;
+       return &reply('put:'.$ENV{'course.'.$cid.'.domain'}.':'.
+                            $ENV{'course.'.$cid.'.num'}.
+	        	    ':nohist_expirationdates:'.
+                            &escape($key).'='.$now,
+                            $ENV{'course.'.$cid.'.home'})
+    }
+    return 'ok';
+}
+
+# ----------------------------------------------------- Devalidate Spreadsheets
+
+sub devalidate {
+    my $symb=shift;
+    my $cid=$ENV{'request.course.id'}; 
+    if ($cid) {
+	my $key=$ENV{'user.name'}.':'.$ENV{'user.domain'}.':';
+        my $status=
+          &reply('del:'.$ENV{'course.'.$cid.'.domain'}.':'.
+                        $ENV{'course.'.$cid.'.num'}.
+	                ':nohist_calculatedsheets:'.
+                        &escape($key.'studentcalc:'),
+                        $ENV{'course.'.$cid.'.home'})
+          .' '.
+          &reply('del:'.$ENV{'user.domain'}.':'.
+                        $ENV{'user.name'}.
+		        ':nohist_calculatedsheets_'.$cid.':'.
+                        &escape($key.'assesscalc:'.$symb),
+                        $ENV{'user.home'});
+        unless ($status eq 'ok ok') {
+           &logthis('Could not devalidate spreadsheet '.
+                    $ENV{'user.name'}.' at '.$ENV{'user.domain'}.' for '.
+		    $symb.': '.$status);
+        } 
+    }
+}
+
 # ----------------------------------------------------------------------- Store
 
 sub store {
     my %storehash=@_;
     my $symb;
-    unless ($symb=escape(&symbread())) { return ''; }
+    unless ($symb=&symbread()) { return ''; }
+
+    &devalidate($symb);
+
+    $symb=escape($symb);
     my $namespace;
     unless ($namespace=$ENV{'request.course.id'}) { return ''; }
     my $namevalue='';
@@ -650,7 +699,11 @@ sub store {
 sub cstore {
     my %storehash=@_;
     my $symb;
-    unless ($symb=escape(&symbread())) { return ''; }
+    unless ($symb=&symbread()) { return ''; }
+
+    &devalidate($symb);
+
+    $symb=escape($symb);
     my $namespace;
     unless ($namespace=$ENV{'request.course.id'}) { return ''; }
     my $namevalue='';
@@ -1189,6 +1242,7 @@ sub definerole {
 
 sub metadata_query {
     my ($query)=@_;
+    # need to put in a loop here and return list
     my $reply=&reply("querysend:".&escape($query),'msul3');
 }