--- loncom/lonnet/perl/lonnet.pm	2003/02/10 20:03:13	1.324
+++ loncom/lonnet/perl/lonnet.pm	2003/02/13 21:57:48	1.328
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.324 2003/02/10 20:03:13 www Exp $
+# $Id: lonnet.pm,v 1.328 2003/02/13 21:57:48 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -76,7 +76,7 @@ qw(%perlvar %hostname %homecache %badSer
    %libserv %pr %prp %metacache %packagetab %titlecache 
    %courselogs %accesshash $processmarker $dumpcount 
    %coursedombuf %coursehombuf %courseresdatacache 
-   %domaindescription);
+   %domaindescription %domain_auth_def %domain_auth_arg_def);
 use IO::Socket;
 use GDBM_File;
 use Apache::Constants qw(:common :http);
@@ -1112,10 +1112,14 @@ sub expirespread {
 # ----------------------------------------------------- Devalidate Spreadsheets
 
 sub devalidate {
-    my $symb=shift;
+    my ($symb,$uname,$udom)=@_;
     my $cid=$ENV{'request.course.id'}; 
     if ($cid) {
-	my $key=$ENV{'user.name'}.':'.$ENV{'user.domain'}.':';
+# delete the stored spreadsheets for
+# - the student level sheet of this user in course's homespace
+# - the assessment level sheet for this resource 
+#   for this user in user's homespace
+	my $key=$uname.':'.$udom.':';
         my $status=
 	    &del('nohist_calculatedsheets',
 		 [$key.'studentcalc'],
@@ -1126,7 +1130,7 @@ sub devalidate {
 		 [$key.'assesscalc:'.$symb]);
         unless ($status eq 'ok ok') {
            &logthis('Could not devalidate spreadsheet '.
-                    $ENV{'user.name'}.' at '.$ENV{'user.domain'}.' for '.
+                    $uname.' at '.$udom.' for '.
 		    $symb.': '.$status);
         }
     }
@@ -1458,7 +1462,10 @@ sub store {
     $symb=&symbclean($symb);
     if (!$symb) { unless ($symb=&symbread()) { return ''; } }
 
-    &devalidate($symb);
+    if (!$domain) { $domain=$ENV{'user.domain'}; }
+    if (!$stuname) { $stuname=$ENV{'user.name'}; }
+
+    &devalidate($symb,$stuname,$domain);
 
     $symb=escape($symb);
     if (!$namespace) { 
@@ -1466,8 +1473,6 @@ sub store {
           return ''; 
        } 
     }
-    if (!$domain) { $domain=$ENV{'user.domain'}; }
-    if (!$stuname) { $stuname=$ENV{'user.name'}; }
     if (!$home) { $home=$ENV{'user.home'}; }
     my $namevalue='';
     foreach (keys %$storehash) {
@@ -1489,7 +1494,10 @@ sub cstore {
     $symb=&symbclean($symb);
     if (!$symb) { unless ($symb=&symbread()) { return ''; } }
 
-    &devalidate($symb);
+    if (!$domain) { $domain=$ENV{'user.domain'}; }
+    if (!$stuname) { $stuname=$ENV{'user.name'}; }
+
+    &devalidate($symb,$stuname,$domain);
 
     $symb=escape($symb);
     if (!$namespace) { 
@@ -1497,8 +1505,6 @@ sub cstore {
           return ''; 
        } 
     }
-    if (!$domain) { $domain=$ENV{'user.domain'}; }
-    if (!$stuname) { $stuname=$ENV{'user.name'}; }
     if (!$home) { $home=$ENV{'user.home'}; }
 
     my $namevalue='';
@@ -1749,11 +1755,12 @@ sub dump {
 
 # --------------------------------------------------------------- currentdump
 sub currentdump {
-   my ($namespace,$udomain,$uname)=@_;
-   if (!$udomain) { $udomain = $ENV{'user.domain'}; }
-   if (!$uname)   { $uname   = $ENV{'user.name'};   }
-   my $uhome = &homeserver($uname,$udomain);
-   my $rep=reply("currentdump:$udomain:$uname:$namespace",$uhome);
+   my ($courseid,$sdom,$sname)=@_;
+   $courseid = $ENV{'request.course.id'} if (! defined($courseid));
+   $sdom     = $ENV{'user.domain'}       if (! defined($sdom));
+   $sname    = $ENV{'user.name'}         if (! defined($sname));
+   my $uhome = &homeserver($sname,$sdom);
+   my $rep=reply('currentdump:'.$sdom.':'.$sname.':'.$courseid,$uhome);
    return if ($rep =~ /^(error:|no_such_host)/);
    #
    my %returnhash=();
@@ -1761,7 +1768,7 @@ sub currentdump {
    if ($rep eq "unknown_cmd") { 
        # an old lond will not know currentdump
        # Do a dump and make it look like a currentdump
-       my @tmp = &dump($namespace,$udomain,$uname,'.');
+       my @tmp = &dump($courseid,$sdom,$sname,'.');
        return if ($tmp[0] =~ /^(error:|no_such_host)/);
        my %hash = @tmp;
        @tmp=();
@@ -3566,6 +3573,29 @@ BEGIN {
     }
 }
 
+# ------------------------------------------------------------ Read domain file
+{
+    my $fh=Apache::File->new($Apache::lonnet::perlvar{'lonTabDir'}.
+                            '/domain.tab');
+    %domaindescription = ();
+    %domain_auth_def = ();
+    %domain_auth_arg_def = ();
+    if ($fh) {
+       while (<$fh>) {
+           next if /^\#/;
+           chomp;
+           my ($domain, $domain_description, $def_auth, $def_auth_arg)
+               = split(/:/,$_,4);
+           $domain_auth_def{$domain}=$def_auth;
+           $domain_auth_arg_def{$domain}=$def_auth_arg;
+           $domaindescription{$domain}=$domain_description;
+#          &logthis("Domain.tab: $domain, $domain_auth_def{$domain}, $domain_auth_arg_def{$domain},$domaindescription{$domain}");
+#          &logthis("Domain.tab: $domain ".$domaindescription{$domain} );
+       }
+    }
+}
+
+
 # ------------------------------------------------------------- Read hosts file
 {
     my $config=Apache::File->new("$perlvar{'lonTabDir'}/hosts.tab");
@@ -3579,7 +3609,6 @@ BEGIN {
 	 $hostdom{$id}=$domain;
 	 $hostip{$id}=$ip;
 	 $iphost{$ip}=$id;
-	 if ($domdescr) { $domaindescription{$domain}=$domdescr; }
 	 if ($role eq 'library') { $libserv{$id}=$name; }
        } else {
 	 if ($configline) {