--- loncom/lonnet/perl/lonnet.pm	2005/04/18 22:28:19	1.627
+++ loncom/lonnet/perl/lonnet.pm	2005/05/05 20:50:38	1.633
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.627 2005/04/18 22:28:19 albertel Exp $
+# $Id: lonnet.pm,v 1.633 2005/05/05 20:50:38 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -258,6 +258,7 @@ sub critical {
 
 sub transfer_profile_to_env {
     my ($lonidsdir,$handle)=@_;
+    undef(%env);
     my @profile;
     {
 	open(my $idf,"$lonidsdir/$handle.id");
@@ -827,8 +828,11 @@ sub getsection {
 }
 
 sub save_cache {
+    my ($r)=@_;
+    if (! $r->is_initial_req()) { return DECLINED; }
     &purge_remembered();
     undef(%env);
+    return OK;
 }
 
 my $to_remember=-1;
@@ -2610,8 +2614,23 @@ sub put {
    return &reply("put:$udomain:$uname:$namespace:$items",$uhome);
 }
 
-# ---------------------------------------------------------- putstore interface
-                                                                                     
+# ------------------------------------------------------------ newput interface
+
+sub newput {
+   my ($namespace,$storehash,$udomain,$uname)=@_;
+   if (!$udomain) { $udomain=$env{'user.domain'}; }
+   if (!$uname) { $uname=$env{'user.name'}; }
+   my $uhome=&homeserver($uname,$udomain);
+   my $items='';
+   foreach my $key (keys(%$storehash)) {
+       $items.=&escape($key).'='.&freeze_escape($$storehash{$key}).'&';
+   }
+   $items=~s/\&$//;
+   return &reply("newput:$udomain:$uname:$namespace:$items",$uhome);
+}
+
+# ---------------------------------------------------------  putstore interface
+
 sub putstore {
    my ($namespace,$storehash,$udomain,$uname)=@_;
    if (!$udomain) { $udomain=$env{'user.domain'}; }
@@ -3753,7 +3772,6 @@ sub mark_as_readonly {
     my %current_permissions = &dump('file_permissions',$domain,$user);
     my ($tmp)=keys(%current_permissions);
     if ($tmp=~/^error:/) { undef(%current_permissions); }
-
     foreach my $file (@{$files}) {
         push(@{$current_permissions{$file}},$what);
     }
@@ -3832,17 +3850,21 @@ sub files_not_in_path {
 
 #--------------------------------------------------------------Get Marked as Read Only
 
+
 sub get_marked_as_readonly {
     my ($domain,$user,$what) = @_;
     my %current_permissions = &dump('file_permissions',$domain,$user);
     my ($tmp)=keys(%current_permissions);
     if ($tmp=~/^error:/) { undef(%current_permissions); }
-
     my @readonly_files;
+    my $cmp1=$what;
+    if (ref($what)) { $cmp1=join('',@{$what}) };
     while (my ($file_name,$value) = each(%current_permissions)) {
         if (ref($value) eq "ARRAY"){
             foreach my $stored_what (@{$value}) {
-                if ($stored_what eq $what) {
+                my $cmp2=$stored_what;
+                if (ref($stored_what)) { $cmp2=join('',@{$stored_what}) };
+                if ($cmp1 eq $cmp2) {
                     push(@readonly_files, $file_name);
                 } elsif (!defined($what)) {
                     push(@readonly_files, $file_name);
@@ -3877,13 +3899,13 @@ sub get_marked_as_readonly_hash {
 # ------------------------------------------------------------ Unmark as Read Only
 
 sub unmark_as_readonly {
-    # unmarks all files locked by $what 
-    # for portfolio submissions, $what contains $crsid and $symb
-    my ($domain,$user,$what) = @_;
+    # unmarks $file_name (if $file_name is defined), or all files locked by $what 
+    # for portfolio submissions, $what contains [$symb,$crsid] 
+    my ($domain,$user,$what,$file_name) = @_;
+    my $symb_crs = join('',@$what);
     my %current_permissions = &dump('file_permissions',$domain,$user);
     my ($tmp)=keys(%current_permissions);
     if ($tmp=~/^error:/) { undef(%current_permissions); }
-
     my @readonly_files = &get_marked_as_readonly($domain,$user,$what);
     foreach my $file(@readonly_files){
         my $current_locks = $current_permissions{$file};
@@ -3891,7 +3913,13 @@ sub unmark_as_readonly {
         my @del_keys;
         if (ref($current_locks) eq "ARRAY"){
             foreach my $locker (@{$current_locks}) {
-                unless ($locker eq $what) {
+                my $compare=$locker;
+                if (ref($locker)) { $compare=join('',@{$locker}) };
+                if ($compare eq $symb_crs) {
+                    if (defined($file_name) && ($file_name ne $file)) {
+                        push(@new_locks, $what);
+                    }
+                } else {
                     push(@new_locks, $what);
                 }
             }
@@ -4117,6 +4145,12 @@ sub get_courseresdata {
     return $result;
 }
 
+sub devalidateuserresdata {
+    my ($uname,$udom)=@_;
+    my $hashid="$udom:$uname";
+    &devalidate_cache_new('userres',$hashid);
+}
+
 sub get_userresdata {
     my ($uname,$udom)=@_;
     #most student don\'t have any data set, check if there is some data
@@ -4140,7 +4174,8 @@ sub get_userresdata {
 		 $uname." at ".$udom.": ".
 		 $tmp."</font>");
     } elsif ($tmp=~/error: 2 /) {
-	&EXT_cache_set($udom,$uname);
+	#&EXT_cache_set($udom,$uname);
+	&do_cache_new('userres',$hashid,undef,600);
     }
     return $tmp;
 }
@@ -4184,7 +4219,7 @@ sub EXT_cache_status {
 sub EXT_cache_set {
     my ($target_domain,$target_user) = @_;
     my $cachename = 'cache.EXT.'.$target_user.'.'.$target_domain;
-    &appenv($cachename => time);
+    #&appenv($cachename => time);
 }
 
 # --------------------------------------------------------- Value of a Variable
@@ -6167,7 +6202,10 @@ revokecustomrole($udom,$uname,$url,$role
 
 =item *
 
-coursedescription($courseid) : course description
+coursedescription($courseid) : returns a hash of information about the
+specified course id, including all environment settings for the
+course, the description of the course will be in the hash under the
+key 'description'
 
 =item *