[LON-CAPA-cvs] cvs: loncom /auth lonroles.pm /homework chemresponse.pm drawimage.pm edit.pm grades.pm imagechoice.pm imageresponse.pm lonhomework.pm randomlabel.pm /interface loncommon.pm loncreateuser.pm londocs.pm lonfeedback.pm lonmsg.pm lonnavdisplay.pm lonparmset.pm lonpopulate.pm lonpreferences.pm lonprintout.pm lonremote.pm lonviewclasslist.pm selfenroll.pm /interface/spreadsheet Spreadsheet.pm /lonnet/perl lonnet.pm /publisher loncfile.pm /xml lonxml.pm rat lonpageflip.pm lonuserstate.pm

raeburn lon-capa-cvs-allow@mail.lon-capa.org
Wed, 12 Mar 2008 02:47:38 -0000


This is a MIME encoded message

--raeburn1205290058
Content-Type: text/plain

raeburn		Tue Mar 11 22:47:38 2008 EDT

  Modified files:              
    /loncom/interface	loncommon.pm loncreateuser.pm londocs.pm 
                     	lonfeedback.pm lonmsg.pm lonnavdisplay.pm 
                     	lonparmset.pm lonpopulate.pm lonpreferences.pm 
                     	lonprintout.pm lonremote.pm lonviewclasslist.pm 
                     	selfenroll.pm 
    /loncom/interface/spreadsheet	Spreadsheet.pm 
    /rat	lonpageflip.pm lonuserstate.pm 
    /loncom/xml	lonxml.pm 
    /loncom/lonnet/perl	lonnet.pm 
    /loncom/publisher	loncfile.pm 
    /loncom/homework	chemresponse.pm drawimage.pm edit.pm grades.pm 
                    	imagechoice.pm imageresponse.pm lonhomework.pm 
                    	randomlabel.pm 
    /loncom/auth	lonroles.pm 
  Log:
  Change arguments accepted by lonnet::appenv() to:
  1. reference to hash
  2. (optional) reference to array.
  
  Change all instances where lonnet::appenv() is called to replace first argument passed (originally a hash) to a reference to the hash.
  
  - Modify lonnet.pm rev 1.35 code intended to prevent "dangerous" modifications of the environment, so it will actually do this.
  - Allow these modifications to be made in certain instances:
     DC switching to adhoc role
     CC switching to a different course role in the current course.
     user self-enrolling as a student
    
  
  
--raeburn1205290058
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20080311224738.txt"

Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.645 loncom/interface/loncommon.pm:1.646
--- loncom/interface/loncommon.pm:1.645	Thu Mar  6 16:42:51 2008
+++ loncom/interface/loncommon.pm	Tue Mar 11 22:45:06 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.645 2008/03/06 21:42:51 raeburn Exp $
+# $Id: loncommon.pm,v 1.646 2008/03/12 02:45:06 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -371,7 +371,7 @@
     unless ($resurl=~/^\/res/) { return 0; }
     $resurl=~s/\/$//;
     &Apache::lonnet::put('environment',{'lastresurl' => $resurl});
-    &Apache::lonnet::appenv('environment.lastresurl' => $resurl);
+    &Apache::lonnet::appenv({'environment.lastresurl' => $resurl});
     return 1;
 }
 
@@ -7487,7 +7487,7 @@
         $ValuesHash{$id.'.'.$key} = $value;
     }
     #
-    &Apache::lonnet::appenv(%ValuesHash);
+    &Apache::lonnet::appenv(\%ValuesHash);
     return '<img src="/cgi-bin/graph.png?'.$identifier.'" border="1" />';
 }
 
@@ -7577,7 +7577,7 @@
         $ValuesHash{$id.'.'.$key} = $value;
     }
     #
-    &Apache::lonnet::appenv(%ValuesHash);
+    &Apache::lonnet::appenv(\%ValuesHash);
     return '<img src="/cgi-bin/graph.png?'.$identifier.'" border="1" />';
 }
 
@@ -7679,7 +7679,7 @@
         $ValuesHash{$id.'.'.$key} = $value;
     }
     #
-    &Apache::lonnet::appenv(%ValuesHash);
+    &Apache::lonnet::appenv(\%ValuesHash);
     return '<img src="/cgi-bin/graph.png?'.$identifier.'" border="1" />';
 }
 
@@ -7811,7 +7811,7 @@
                                  'got error:'.$put_result);
     }
     # Make sure these settings stick around in this session, too
-    &Apache::lonnet::appenv(%AppHash);
+    &Apache::lonnet::appenv(\%AppHash);
     return;
 }
 
Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.237 loncom/interface/loncreateuser.pm:1.238
--- loncom/interface/loncreateuser.pm:1.237	Fri Mar  7 22:48:41 2008
+++ loncom/interface/loncreateuser.pm	Tue Mar 11 22:45:06 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Create a user
 #
-# $Id: loncreateuser.pm,v 1.237 2008/03/08 03:48:41 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.238 2008/03/12 02:45:06 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1986,7 +1986,7 @@
                     foreach my $key (keys(%changeHash)) {
                         $newenvhash{'environment.'.$key} = $changeHash{$key};
                     }
-                    &Apache::lonnet::appenv(%newenvhash);
+                    &Apache::lonnet::appenv(\%newenvhash);
                 }
             } else { # error occurred
                 $r->print('<span class="LC_error">'.&mt('Unable to successfully change environment for').' '.
@@ -3998,7 +3998,7 @@
                 foreach my $key (keys(%changes)) {
                     $newenvhash{'course.'.$env{'request.course.id'}.'.'.$key} = $changes{$key};
                 }
-                &Apache::lonnet::appenv(%newenvhash);
+                &Apache::lonnet::appenv(\%newenvhash);
             } else {
                 $r->print(&mt('An error occurred when saving changes to self-enrollment settings in this course.').'<br />'.&mt('The error was: [_1].',$putresult));
             }
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.303 loncom/interface/londocs.pm:1.304
--- loncom/interface/londocs.pm:1.303	Sun Jan 20 00:46:34 2008
+++ loncom/interface/londocs.pm	Tue Mar 11 22:45:07 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.303 2008/01/20 05:46:34 raeburn Exp $
+# $Id: londocs.pm,v 1.304 2008/03/12 02:45:07 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1205,8 +1205,8 @@
     }
     $url=~s{http(&colon;|:)//https(&colon;|:)//}{https$2//};
 
-    &Apache::lonnet::appenv('docs.markedcopy_title' => $title,
-			    'docs.markedcopy_url'   => $url);
+    &Apache::lonnet::appenv({'docs.markedcopy_title' => $title,
+			    'docs.markedcopy_url'   => $url});
     delete($env{'form.markcopy'});
 }
 
Index: loncom/interface/lonfeedback.pm
diff -u loncom/interface/lonfeedback.pm:1.252 loncom/interface/lonfeedback.pm:1.253
--- loncom/interface/lonfeedback.pm:1.252	Mon Feb 25 08:16:34 2008
+++ loncom/interface/lonfeedback.pm	Tue Mar 11 22:45:07 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Feedback
 #
-# $Id: lonfeedback.pm,v 1.252 2008/02/25 13:16:34 bisitz Exp $
+# $Id: lonfeedback.pm,v 1.253 2008/03/12 02:45:07 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -3557,7 +3557,7 @@
       my ($symb,$feedurl)=&get_feedurl_and_clean_symb($env{'form.symb'});
       if ($env{'form.cmd'} eq 'threadedon') {
 	  &Apache::lonnet::put('environment',{'threadeddiscussion' => 'on'});
-	  &Apache::lonnet::appenv('environment.threadeddiscussion' => 'on');
+	  &Apache::lonnet::appenv({'environment.threadeddiscussion' => 'on'});
       } else {
  	  &Apache::lonnet::del('environment',['threadeddiscussion']);
 	  &Apache::lonnet::delenv('environment\.threadeddiscussion');
@@ -3720,7 +3720,7 @@
       my $usersaw=&resource_output($feedurl);
 
 # Get resource answer (need to allow student to view grades for this to work)
-      &Apache::lonnet::appenv(('allowed.vgr'=>'F'));
+      &Apache::lonnet::appenv({'allowed.vgr'=>'F'});
       my $usersymb = &Apache::lonenc::check_encrypt($symb);
       my $useranswer=
           &Apache::loncommon::get_student_answers(
Index: loncom/interface/lonmsg.pm
diff -u loncom/interface/lonmsg.pm:1.210 loncom/interface/lonmsg.pm:1.211
--- loncom/interface/lonmsg.pm:1.210	Fri Aug 17 20:32:52 2007
+++ loncom/interface/lonmsg.pm	Tue Mar 11 22:45:07 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines for messaging
 #
-# $Id: lonmsg.pm,v 1.210 2007/08/18 00:32:52 albertel Exp $
+# $Id: lonmsg.pm,v 1.211 2008/03/12 02:45:07 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -385,7 +385,7 @@
 sub newmail {
     if ((time-$env{'user.mailcheck.time'})>300) {
         my %what=&Apache::lonnet::get('email_status',['recnewemail']);
-        &Apache::lonnet::appenv('user.mailcheck.time'=>time);
+        &Apache::lonnet::appenv({'user.mailcheck.time'=>time});
         if ($what{'recnewemail'}>0) { return 1; }
     }
     return 0;
Index: loncom/interface/lonnavdisplay.pm
diff -u loncom/interface/lonnavdisplay.pm:1.2 loncom/interface/lonnavdisplay.pm:1.3
--- loncom/interface/lonnavdisplay.pm:1.2	Thu Apr 19 21:54:29 2007
+++ loncom/interface/lonnavdisplay.pm	Tue Mar 11 22:45:07 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Navigate Maps Handler
 #
-# $Id: lonnavdisplay.pm,v 1.2 2007/04/20 01:54:29 albertel Exp $
+# $Id: lonnavdisplay.pm,v 1.3 2008/03/12 02:45:07 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -71,7 +71,7 @@
 				      "Select Action");
     if ($ENV{QUERY_STRING} eq 'collapseExternal') {
 	&Apache::lonnet::put('environment',{'remotenavmap' => 'off'});
-	&Apache::lonnet::appenv('environment.remotenavmap' => 'off');
+	&Apache::lonnet::appenv({'environment.remotenavmap' => 'off'});
 	my $menu=&Apache::lonmenu::reopenmenu();
 	my $navstatus=&Apache::lonmenu::get_nav_status();
 	if ($menu) {
@@ -110,7 +110,7 @@
     }
     if ($ENV{QUERY_STRING} =~ /^launchExternal/) {
 	&Apache::lonnet::put('environment',{'remotenavmap' => 'on'});
-	&Apache::lonnet::appenv('environment.remotenavmap' => 'on');
+	&Apache::lonnet::appenv({'environment.remotenavmap' => 'on'});
  	my $menu=&Apache::lonmenu::reopenmenu();
 	my $navstatus=&Apache::lonmenu::get_nav_status();
 	if ($menu) {
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.392 loncom/interface/lonparmset.pm:1.393
--- loncom/interface/lonparmset.pm:1.392	Thu Mar  6 16:37:59 2008
+++ loncom/interface/lonparmset.pm	Tue Mar 11 22:45:07 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set parameters for assessments
 #
-# $Id: lonparmset.pm,v 1.392 2008/03/06 21:37:59 raeburn Exp $
+# $Id: lonparmset.pm,v 1.393 2008/03/12 02:45:07 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2142,7 +2142,7 @@
                     }
                 }
                 if ($name eq 'description' && defined($value)) {
-                    &Apache::lonnet::appenv('course.'.$env{'request.course.id'}.'.description' => $value);
+                    &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.description' => $value});
                     if (ref($crsinfo{$env{'request.course.id'}}) eq 'HASH') {
                         $crsinfo{$env{'request.course.id'}}{'description'} = $value; 
                         my $putresult =
@@ -3604,7 +3604,7 @@
 	my $ordered_fields = join ",", @neworder;
         my $put_result = &Apache::lonnet::put('environment',
                            {'metadata.addedorder'=>$ordered_fields},$dom,$crs); 	
-	&Apache::lonnet::appenv('course.'.$env{'request.course.id'}.'.metadata.addedorder' => $ordered_fields);
+	&Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.metadata.addedorder' => $ordered_fields});
     }
     my $fields = &get_added_meta_fieldnames($env{'request.course.id'});
     my $ordered_fields;
Index: loncom/interface/lonpopulate.pm
diff -u loncom/interface/lonpopulate.pm:1.53 loncom/interface/lonpopulate.pm:1.54
--- loncom/interface/lonpopulate.pm:1.53	Thu Mar  6 16:42:51 2008
+++ loncom/interface/lonpopulate.pm	Tue Mar 11 22:45:07 2008
@@ -1,5 +1,5 @@
 # automated enrollment configuration handler
-# $Id: lonpopulate.pm,v 1.53 2008/03/06 21:42:51 raeburn Exp $
+# $Id: lonpopulate.pm,v 1.54 2008/03/12 02:45:07 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2485,7 +2485,7 @@
         }
     }
     if (keys(%newenv) > 0) {
-        &Apache::lonnet::appenv(%newenv);
+        &Apache::lonnet::appenv(\%newenv);
     }
     &print_reply($r,$response,$$tasktitleref{$action});
     return;
Index: loncom/interface/lonpreferences.pm
diff -u loncom/interface/lonpreferences.pm:1.115 loncom/interface/lonpreferences.pm:1.116
--- loncom/interface/lonpreferences.pm:1.115	Thu Mar  6 17:27:45 2008
+++ loncom/interface/lonpreferences.pm	Tue Mar 11 22:45:07 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Preferences
 #
-# $Id: lonpreferences.pm,v 1.115 2008/03/06 22:27:45 raeburn Exp $
+# $Id: lonpreferences.pm,v 1.116 2008/03/12 02:45:07 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -123,7 +123,7 @@
     my $r = shift;
     my $newsetting=$env{'form.wysiwyg'};
     &Apache::lonnet::put('environment',{'wysiwygeditor' => $newsetting});
-    &Apache::lonnet::appenv('environment.wysiwygeditor' => $newsetting);
+    &Apache::lonnet::appenv({'environment.wysiwygeditor' => $newsetting});
     $r->print('<p>'.&mt('Setting WYSIWYG editor to:').' '.&mt($newsetting).'</p>');
 }
 
@@ -167,7 +167,7 @@
     my $message='';
     if ($newlanguage) {
         &Apache::lonnet::put('environment',{'languages' => $newlanguage});
-        &Apache::lonnet::appenv('environment.languages' => $newlanguage);
+        &Apache::lonnet::appenv({'environment.languages' => $newlanguage});
         $message=&mt('Set new preferred languages to ').'<tt>"'.$newlanguage.'"</tt>.';
     } else {
         &Apache::lonnet::del('environment',['languages']);
@@ -252,16 +252,16 @@
     my $newtexengine  = $env{'form.texengine'};
     $newtexengine=~s/[^\-\w]//g;
     if ($newtexengine eq 'ttm') {
-	&Apache::lonnet::appenv('browser.mathml' => 1);
+	&Apache::lonnet::appenv({'browser.mathml' => 1});
     } else {
 	if ($env{'environment.texengine'} eq 'ttm') {
-	    &Apache::lonnet::appenv('browser.mathml' => 0);
+	    &Apache::lonnet::appenv({'browser.mathml' => 0});
 	}
     }
     my $message='';
     if ($newtexengine) {
         &Apache::lonnet::put('environment',{'texengine' => $newtexengine});
-        &Apache::lonnet::appenv('environment.texengine' => $newtexengine);
+        &Apache::lonnet::appenv({'environment.texengine' => $newtexengine});
         $message=&mt('Set new preferred math display to ').'<tt>"'.$newtexengine.'"</tt>.';
     } else {
         &Apache::lonnet::del('environment',['texengine']);
@@ -400,7 +400,7 @@
     my $message='<hr />';
     if ($hotlist_flag) {
         &Apache::lonnet::put('environment',{'recentroles' => $hotlist_flag});
-        &Apache::lonnet::appenv('environment.recentroles' => $hotlist_flag);
+        &Apache::lonnet::appenv({'environment.recentroles' => $hotlist_flag});
         $message=&mt('Recent '.$role.'s Hotlist is Enabled');
     } else {
         &Apache::lonnet::del('environment',['recentroles']);
@@ -409,7 +409,7 @@
     }
     if ($hotlist_n) {
         &Apache::lonnet::put('environment',{'recentrolesn' => $hotlist_n});
-        &Apache::lonnet::appenv('environment.recentrolesn' => $hotlist_n);
+        &Apache::lonnet::appenv({'environment.recentrolesn' => $hotlist_n});
         if ($hotlist_flag) {
             $message.="<br />".
 		&mt('Display [_1] Most Recent '.$role.'s',$hotlist_n)."\n";
@@ -495,7 +495,7 @@
     my $message='';
     if ($newscreen) {
         &Apache::lonnet::put('environment',{'screenname' => $newscreen});
-        &Apache::lonnet::appenv('environment.screenname' => $newscreen);
+        &Apache::lonnet::appenv({'environment.screenname' => $newscreen});
         $message=&mt('Set new screenname to ').'<tt>"'.$newscreen.'."</tt>.';
     } else {
         &Apache::lonnet::del('environment',['screenname']);
@@ -508,7 +508,7 @@
     $newscreen=~s/[^ \w]//g;
     if ($newscreen) {
         &Apache::lonnet::put('environment',{'nickname' => $newscreen});
-        &Apache::lonnet::appenv('environment.nickname' => $newscreen);
+        &Apache::lonnet::appenv({'environment.nickname' => $newscreen});
         $message.=&mt('Set new nickname to ').'<tt>"'.$newscreen.'"</tt>.';
     } else {
         &Apache::lonnet::del('environment',['nickname']);
@@ -563,7 +563,7 @@
     my $newicons  = $env{'form.menumode'};
 
     &Apache::lonnet::put('environment',{'icons' => $newicons});
-    &Apache::lonnet::appenv('environment.icons' => $newicons);
+    &Apache::lonnet::appenv({'environment.icons' => $newicons});
     $r->print(&mt('Set menu mode to [_1].',$newicons));
 }
 
@@ -605,7 +605,7 @@
     $newclickers=~s/^\,//;
     $newclickers=~s/\,$//;
     &Apache::lonnet::put('environment',{'clickers' => $newclickers});
-    &Apache::lonnet::appenv('environment.clickers' => $newclickers);
+    &Apache::lonnet::appenv({'environment.clickers' => $newclickers});
     $r->print(&mt('Registering clickers: [_1]',$newclickers));
 }
 
@@ -841,7 +841,7 @@
     $newscreen=~s/\,$//;
     if ($newscreen) {
         &Apache::lonnet::put('environment',{'msgforward' => $newscreen});
-        &Apache::lonnet::appenv('environment.msgforward' => $newscreen);
+        &Apache::lonnet::appenv({'environment.msgforward' => $newscreen});
         $message .= &mt('Set message forwarding to ').'<tt>"'.$newscreen.'"</tt>.'
                     .'<br />';
     } else {
@@ -882,7 +882,7 @@
     $notify_with_html =~ s/\s//gs;
     if ($notification) {
         &Apache::lonnet::put('environment',{'notification' => $notification});
-        &Apache::lonnet::appenv('environment.notification' => $notification);
+        &Apache::lonnet::appenv({'environment.notification' => $notification});
         $message.=&mt('Set non-critical message notification address(es) to ').'<tt>"'.$notification.'"</tt>.<br />';
     } else {
         &Apache::lonnet::del('environment',['notification']);
@@ -891,7 +891,7 @@
     }
     if ($critnotification) {
         &Apache::lonnet::put('environment',{'critnotification' => $critnotification});
-        &Apache::lonnet::appenv('environment.critnotification' => $critnotification);
+        &Apache::lonnet::appenv({'environment.critnotification' => $critnotification});
         $message.=&mt('Set critical message notification address(es) to ').'<tt>"'.$critnotification.'"</tt>.<br />';
     } else {
         &Apache::lonnet::del('environment',['critnotification']);
@@ -901,7 +901,7 @@
     if ($critnotification || $notification) {
         if ($notify_with_html) {
             &Apache::lonnet::put('environment',{'notifywithhtml' => $notify_with_html});
-            &Apache::lonnet::appenv('environment.notifywithhtml' => $notify_with_html);
+            &Apache::lonnet::appenv({'environment.notifywithhtml' => $notify_with_html});
             $message.=&mt('Set address(es) to receive excerpts with html retained ').'<tt>"'.$notify_with_html.'"</tt>.';
         } else {
             &Apache::lonnet::del('environment',['notifywithhtml']);
@@ -1017,7 +1017,7 @@
         my $entry='color.'.$function.'.'.$item;
 	if (($color=~/^\#[0-9A-Fa-f]{6}$/) && (!$env{'form.resetall'})) {
 	    &Apache::lonnet::put('environment',{$entry => $color});
-	    &Apache::lonnet::appenv('environment.'.$entry => $color);
+	    &Apache::lonnet::appenv({'environment.'.$entry => $color});
 	    $message.=&mt('Set '.$colortypes{$item}.' to ').'<tt>"'.$color.'"</tt>.<br />';
 	} else {
 	    &Apache::lonnet::del('environment',[$entry]);
@@ -1027,7 +1027,7 @@
     }
     my $now = time;
     &Apache::lonnet::put('environment',{'color.timestamp' => $now});
-    &Apache::lonnet::appenv('environment.color.timestamp' => $now);
+    &Apache::lonnet::appenv({'environment.color.timestamp' => $now});
 
     $r->print(<<ENDVCCOL);
 $message
@@ -1499,7 +1499,7 @@
         if ($newdisp eq 'unread') {
             $message .=&mt('In discussions: only new posts will be displayed.').'<br />';
             &Apache::lonnet::put('environment',{'discdisplay' => $newdisp});
-            &Apache::lonnet::appenv('environment.discdisplay' => $newdisp);
+            &Apache::lonnet::appenv({'environment.discdisplay' => $newdisp});
         } else {
             $message .= &mt('In discussions: all posts will be displayed.').'<br />';
             &Apache::lonnet::del('environment',['discdisplay']);
@@ -1511,7 +1511,7 @@
         if ($newmark eq 'ondisp') {
            $message.=&mt('In discussions: new posts will be cease to be identified as "NEW" after display.').'<br />';
             &Apache::lonnet::put('environment',{'discmarkread' => $newmark});
-            &Apache::lonnet::appenv('environment.discmarkread' => $newmark);
+            &Apache::lonnet::appenv({'environment.discmarkread' => $newmark});
         } else {
             $message.=&mt('In discussions: posts will be identified as "NEW" until marked as read by the reader.').'<br />';
             &Apache::lonnet::del('environment',['discmarkread']);
@@ -1576,7 +1576,7 @@
     if ($newdisp eq 'firstres') {
         $message .= $lt{'ywbt'}.'<br />';
         &Apache::lonnet::put('environment',{'course_init_display' => $newdisp});
-        &Apache::lonnet::appenv('environment.course_init_display' => $newdisp);
+        &Apache::lonnet::appenv({'environment.course_init_display' => $newdisp});
     } else {
         $message .= $lt{'apwb'}.'<br />';
         &Apache::lonnet::del('environment',['course_init_display']);
@@ -1932,7 +1932,7 @@
     if ($env{'user.debug'}) {
         &Apache::lonnet::delenv('user\.debug');
     } else {
-        &Apache::lonnet::appenv('user.debug' => 1);
+        &Apache::lonnet::appenv({'user.debug' => 1});
     }
 }
 
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.519 loncom/interface/lonprintout.pm:1.520
--- loncom/interface/lonprintout.pm:1.519	Tue Mar 11 05:52:56 2008
+++ loncom/interface/lonprintout.pm	Tue Mar 11 22:45:07 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Printout
 #
-# $Id: lonprintout.pm,v 1.519 2008/03/11 09:52:56 foxr Exp $
+# $Id: lonprintout.pm,v 1.520 2008/03/12 02:45:07 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1473,8 +1473,8 @@
     }
     
     if ($helper->{'VARS'}->{'style_file'}=~/\w/) {
-	&Apache::lonnet::appenv('construct.style' =>
-				$helper->{'VARS'}->{'style_file'});
+	&Apache::lonnet::appenv({'construct.style' =>
+				$helper->{'VARS'}->{'style_file'}});
     } elsif ($env{'construct.style'}) {
 	&Apache::lonnet::delenv('construct\\.style');
     }
@@ -1517,7 +1517,7 @@
 		    $rndseed=$helper->{'VARS'}->{'curseed'};
 		}
 		$form{'rndseed'}=$rndseed;
-		&Apache::lonnet::appenv(%moreenv);
+		&Apache::lonnet::appenv(\%moreenv);
 
 		&Apache::lonxml::clear_problem_counter();
 
@@ -2168,7 +2168,7 @@
 	#  yet.
 	my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
 	my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
-	&Apache::lonnet::appenv('cgi.'.$identifier.'.file'   => $filename,
+	&Apache::lonnet::appenv({'cgi.'.$identifier.'.file'   => $filename,
 				'cgi.'.$identifier.'.layout'  => $laystyle,
 				'cgi.'.$identifier.'.numcol'  => $numberofcolumns,
 				'cgi.'.$identifier.'.paper'  => $papersize,
@@ -2178,12 +2178,12 @@
 				'cgi.'.$identifier.'.role' => $perm{'pav'},
 				'cgi.'.$identifier.'.numberoffiles' => $#print_array,
 				'cgi.'.$identifier.'.studentnames' => $student_names,
-				'cgi.'.$identifier.'.backref' => $URLback,);
-	&Apache::lonnet::appenv("cgi.$identifier.user"    => $env{'user.name'},
+				'cgi.'.$identifier.'.backref' => $URLback,});
+	&Apache::lonnet::appenv({"cgi.$identifier.user"    => $env{'user.name'},
 				"cgi.$identifier.domain"  => $env{'user.domain'},
 				"cgi.$identifier.courseid" => $cnum, 
 				"cgi.$identifier.coursedom" => $cdom, 
-				"cgi.$identifier.resources" => $resources_printed);
+				"cgi.$identifier.resources" => $resources_printed});
 	
 	my $end_page = &Apache::loncommon::end_page();
 	$r->print(<<FINALEND);
Index: loncom/interface/lonremote.pm
diff -u loncom/interface/lonremote.pm:1.23 loncom/interface/lonremote.pm:1.24
--- loncom/interface/lonremote.pm:1.23	Sat Jan 19 20:12:56 2008
+++ loncom/interface/lonremote.pm	Tue Mar 11 22:45:07 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # User Authentication Module
 #
-# $Id: lonremote.pm,v 1.23 2008/01/20 01:12:56 www Exp $
+# $Id: lonremote.pm,v 1.24 2008/03/12 02:45:07 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -39,7 +39,7 @@
 sub launchremote {
     my ($r,$lowerurl)=@_;
     &Apache::lonnet::put('environment',{'remote' => 'on'});
-    &Apache::lonnet::appenv('environment.remote' => 'on');
+    &Apache::lonnet::appenv({'environment.remote' => 'on'});
 # -------------------------------------------------------- Menu script and info
     my $windowinfo=&Apache::lonmenu::open($env{'browser.os'});
     my $startupremote=&Apache::lonmenu::startupremote($lowerurl);
@@ -82,7 +82,7 @@
 $end_page
 ENDCOLLAPSE
    &Apache::lonnet::put('environment',{'remote' => 'off'});
-   &Apache::lonnet::appenv('environment.remote' => 'off');
+   &Apache::lonnet::appenv({'environment.remote' => 'off'});
 }
 
 sub handler {
Index: loncom/interface/lonviewclasslist.pm
diff -u loncom/interface/lonviewclasslist.pm:1.9 loncom/interface/lonviewclasslist.pm:1.10
--- loncom/interface/lonviewclasslist.pm:1.9	Thu Sep  6 20:09:07 2007
+++ loncom/interface/lonviewclasslist.pm	Tue Mar 11 22:45:07 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to display the classlist 
 #
-# $Id: lonviewclasslist.pm,v 1.9 2007/09/07 00:09:07 albertel Exp $
+# $Id: lonviewclasslist.pm,v 1.10 2008/03/12 02:45:07 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -337,7 +337,7 @@
         my $putresult = &Apache::lonnet::put('environment',
                                              \%changeHash,$udom,$uname);
         if ($putresult eq 'ok') {
-            &Apache::lonnet::appenv(%changeHash);
+            &Apache::lonnet::appenv(\%changeHash);
             my $result = &Apache::lonnet::put('publicroster',{$student => $showinroster,},$cdom,$cnum);
             if ($result eq 'ok') {
                 $output .= &mt('Display of your name in the student-viewable roster set to <b>[_1]</b>.',$visibility);
Index: loncom/interface/selfenroll.pm
diff -u loncom/interface/selfenroll.pm:1.1 loncom/interface/selfenroll.pm:1.2
--- loncom/interface/selfenroll.pm:1.1	Fri Mar  7 23:26:12 2008
+++ loncom/interface/selfenroll.pm	Tue Mar 11 22:45:07 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Allow users to self-enroll in a course
 #
-# $Id: selfenroll.pm,v 1.1 2008/03/08 04:26:12 raeburn Exp $
+# $Id: selfenroll.pm,v 1.2 2008/03/12 02:45:07 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -312,7 +312,7 @@
                                                 $area);
             &Apache::lonnet::set_userprivs(\%userroles,\%newrole,%newgroups);
             $userroles{'user.role.'.$spec} = $selfenroll_access_start.'.'.$selfenroll_access_end;
-            &Apache::lonnet::appenv(%userroles);
+            &Apache::lonnet::appenv(\%userroles,[$role]);
             if ($selfenroll_access_end && $selfenroll_access_end <= $now) {
                 $r->print(&mt('The end date for access to this course for users who self-enroll has passed.').'<br />'.&mt('Consequently, although a new role was created for you in the course, it is an inactive role which does not provide access to the course.'));
             } else {
Index: loncom/interface/spreadsheet/Spreadsheet.pm
diff -u loncom/interface/spreadsheet/Spreadsheet.pm:1.77 loncom/interface/spreadsheet/Spreadsheet.pm:1.78
--- loncom/interface/spreadsheet/Spreadsheet.pm:1.77	Tue Jan 23 13:22:47 2007
+++ loncom/interface/spreadsheet/Spreadsheet.pm	Tue Mar 11 22:45:27 2008
@@ -1,5 +1,5 @@
 #
-# $Id: Spreadsheet.pm,v 1.77 2007/01/23 18:22:47 albertel Exp $
+# $Id: Spreadsheet.pm,v 1.78 2008/03/12 02:45:27 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -210,8 +210,8 @@
             {'spreadsheet_default_'.$self->{'type'} => $self->filename()},
                                      $self->{'cdom'},$self->{'cnum'});
     return $result if ($result ne 'ok');
-    &Apache::lonnet::appenv('course.'.$self->{'cid'}.'.spreadsheet_default_'.
-			    $self->{'type'} => $self->filename());
+    &Apache::lonnet::appenv({'course.'.$self->{'cid'}.'.spreadsheet_default_'.
+			    $self->{'type'} => $self->filename()});
     my $symb = $self->{'symb'};
     $symb = '' if (! defined($symb));
     &Apache::lonnet::expirespread('','',$self->{'type'},$symb);    
@@ -1809,8 +1809,8 @@
                                 {'spreadsheet_default_'.$stype => $filename },
                                           $cdom,$cnum);
             return $reply if ($reply ne 'ok');
-	    &Apache::lonnet::appenv('course.'.$self->{'cid'}.'.spreadsheet_default_'.
-				    $self->{'type'} => $self->filename());
+	    &Apache::lonnet::appenv({'course.'.$self->{'cid'}.'.spreadsheet_default_'.
+				    $self->{'type'} => $self->filename()});
         } 
 	if ($self->{'type'} eq 'studentcalc') {
 	    &Apache::lonnet::expirespread('','','studentcalc','');
Index: rat/lonpageflip.pm
diff -u rat/lonpageflip.pm:1.74 rat/lonpageflip.pm:1.75
--- rat/lonpageflip.pm:1.74	Fri Oct 20 18:04:16 2006
+++ rat/lonpageflip.pm	Tue Mar 11 22:45:50 2008
@@ -2,7 +2,7 @@
 #
 # Page flip handler
 #
-# $Id: lonpageflip.pm,v 1.74 2006/10/20 22:04:16 albertel Exp $
+# $Id: lonpageflip.pm,v 1.75 2008/03/12 02:45:50 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -444,7 +444,7 @@
 			   $redirectsymb='';
                         }
                      }
-                     &Apache::lonnet::appenv('user.criticalcheck.time'=>time);
+                     &Apache::lonnet::appenv({'user.criticalcheck.time'=>time});
 		  }
 
 		  &Apache::loncommon::content_type($r,'text/html');
Index: rat/lonuserstate.pm
diff -u rat/lonuserstate.pm:1.127 rat/lonuserstate.pm:1.128
--- rat/lonuserstate.pm:1.127	Fri Nov 30 22:43:49 2007
+++ rat/lonuserstate.pm	Tue Mar 11 22:45:50 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Construct and maintain state and binary representation of course for user
 #
-# $Id: lonuserstate.pm,v 1.127 2007/12/01 03:43:49 albertel Exp $
+# $Id: lonuserstate.pm,v 1.128 2008/03/12 02:45:50 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -574,7 +574,7 @@
     my $courseuri=$uri;
     $courseuri=~s/^\/res\///;
     &Apache::lonnet::delenv('(acc\.|httpref\.)');
-    &Apache::lonnet::appenv(%acchash);
+    &Apache::lonnet::appenv(\%acchash);
 }
 
 # ---------------- Selectively delete from randompick maps and hidden url parms
@@ -630,7 +630,7 @@
     }
 # --------------------------------------- append randomout entry to environment
     if ($randomoutentry) {
-	&Apache::lonnet::appenv('acc.randomout' => $randomoutentry);
+	&Apache::lonnet::appenv({'acc.randomout' => $randomoutentry});
     }
 }
 
@@ -678,9 +678,9 @@
 	$hash{'is_map_0.0'}=1;
 	loadmap($uri,'0.0');
 	if (defined($hash{'map_start_'.$uri})) {
-	    &Apache::lonnet::appenv("request.course.id"  => $short,
-				    "request.course.fn"  => $fn,
-				    "request.course.uri" => $uri);
+	    &Apache::lonnet::appenv({"request.course.id"  => $short,
+				     "request.course.fn"  => $fn,
+				     "request.course.uri" => $uri});
 	    $env{'request.course.id'}=$short;
 	    &traceroute('0',$hash{'map_start_'.$uri},'&');
 	    &accinit($uri,$short,$fn);
@@ -751,9 +751,9 @@
 		(tie(%hash,'GDBM_File',"$fn.db",&GDBM_READER(),0640))) {
 		if (tie(%parmhash,'GDBM_File',$fn.'_parms.db',&GDBM_READER(),0640)) {
 		    $retfurl='/adm/navmaps';
-		    &Apache::lonnet::appenv("request.course.id"  => $short,
-					    "request.course.fn"  => $fn,
-					    "request.course.uri" => $uri);
+		    &Apache::lonnet::appenv({"request.course.id"  => $short,
+					     "request.course.fn"  => $fn,
+					     "request.course.uri" => $uri});
 		    untie(%hash);
 		    untie(%parmhash);
 		    last;
@@ -814,7 +814,7 @@
 	    }
 	}
     }
-    &Apache::lonnet::appenv('user.state.'.$env{'request.course.id'} => $state);
+    &Apache::lonnet::appenv({'user.state.'.$env{'request.course.id'} => $state});
     return $state;
 }
 
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.473 loncom/xml/lonxml.pm:1.474
--- loncom/xml/lonxml.pm:1.473	Fri Mar  7 16:17:04 2008
+++ loncom/xml/lonxml.pm	Tue Mar 11 22:46:03 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # XML Parser Module 
 #
-# $Id: lonxml.pm,v 1.473 2008/03/07 21:17:04 www Exp $
+# $Id: lonxml.pm,v 1.474 2008/03/12 02:46:03 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1121,7 +1121,7 @@
 }
 
 sub store_counter {
-    &Apache::lonnet::appenv(('form.counter' => $Apache::lonxml::counter));
+    &Apache::lonnet::appenv({'form.counter' => $Apache::lonxml::counter});
     $Apache::lonxml::counter_changed=0;
     return '';
 }
@@ -1142,7 +1142,7 @@
 
     sub restore_problem_counter {
 	if (defined($state)) {
-	    &Apache::lonnet::appenv(('form.counter' => $state));
+	    &Apache::lonnet::appenv({'form.counter' => $state});
 	}
     }
     sub get_problem_counter {
@@ -1379,7 +1379,7 @@
  	        &Apache::lonnet::hreflocation($thisdir,&unescape($_))}=$thisurl;
     }
     @extlinks=();
-    &Apache::lonnet::appenv(%httpref);
+    &Apache::lonnet::appenv(\%httpref);
 }
 
 sub register_ssi {
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.948 loncom/lonnet/perl/lonnet.pm:1.949
--- loncom/lonnet/perl/lonnet.pm:1.948	Mon Mar 10 19:26:28 2008
+++ loncom/lonnet/perl/lonnet.pm	Tue Mar 11 22:46:27 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.948 2008/03/10 23:26:28 raeburn Exp $
+# $Id: lonnet.pm,v 1.949 2008/03/12 02:46:27 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -448,27 +448,39 @@
 # ---------------------------------------------------------- Append Environment
 
 sub appenv {
-    my %newenv=@_;
-    foreach my $key (keys(%newenv)) {
-	if (($newenv{$key}=~/^user\.role/) || ($newenv{$key}=~/^user\.priv/)) {
-            &logthis("<font color=\"blue\">WARNING: ".
-                "Attempt to modify environment ".$key." to ".$newenv{$key}
-                .'</font>');
-	    delete($newenv{$key});
-        } else {
-            $env{$key}=$newenv{$key};
+    my ($newenv,$roles) = @_;
+    if (ref($newenv) eq 'HASH') {
+        foreach my $key (keys(%{$newenv})) {
+            my $refused = 0;
+	    if (($key =~ /^user\.role/) || ($key =~ /^user\.priv/)) {
+                $refused = 1;
+                if (ref($roles) eq 'ARRAY') {
+                    my ($type,$role) = ($key =~ /^user\.(role|priv)\.([^.]+)\./);
+                    if (grep(/^\Q$role\E$/,@{$roles})) {
+                        $refused = 0;
+                    }
+                }
+            }
+            if ($refused) {
+                &logthis("<font color=\"blue\">WARNING: ".
+                         "Attempt to modify environment ".$key." to ".$newenv->{$key}
+                         .'</font>');
+	        delete($newenv->{$key});
+            } else {
+                $env{$key}=$newenv->{$key};
+            }
+        }
+        my $opened = open(my $env_file,'+<',$env{'user.environment'});
+        if ($opened
+	    && &timed_flock($env_file,LOCK_EX)
+	    &&
+	    tie(my %disk_env,'GDBM_File',$env{'user.environment'},
+	        (&GDBM_WRITER()|&GDBM_NOLOCK()),0640)) {
+	    while (my ($key,$value) = each(%{$newenv})) {
+	        $disk_env{$key} = $value;
+	    }
+	    untie(%disk_env);
         }
-    }
-    my $opened = open(my $env_file,'+<',$env{'user.environment'});
-    if ($opened
-	&& &timed_flock($env_file,LOCK_EX)
-	&&
-	tie(my %disk_env,'GDBM_File',$env{'user.environment'},
-	    (&GDBM_WRITER()|&GDBM_NOLOCK()),0640)) {
-	while (my ($key,$value) = each(%newenv)) {
-	    $disk_env{$key} = $value;
-	}
-	untie(%disk_env);
     }
     return 'ok';
 }
@@ -1183,7 +1195,7 @@
 # key now belongs to user
 	    my $envkey='key.'.$cdom.'_'.$cnum;
             if (&put('environment',{$envkey => $ckey}) eq 'ok') {
-                &appenv('environment.'.$envkey => $ckey);
+                &appenv({'environment.'.$envkey => $ckey});
                 return 'ok';
             } else {
                 return 
@@ -1746,7 +1758,7 @@
     my %httpref=();
     my $httpurl=&hreflocation('',$url);
     $httpref{'httpref.'.$httpurl}=$srcurl;
-    &Apache::lonnet::appenv(%httpref);
+    &Apache::lonnet::appenv(\%httpref);
 }
 
 # --------- File operations in /home/httpd/html/userfiles/$domain/1/2/3/$course
@@ -3408,7 +3420,7 @@
        }
     }
     if (!$args->{'one_time'}) {
-	&appenv(%envhash);
+	&appenv(\%envhash);
     }
     return %returnhash;
 }
@@ -6351,7 +6363,7 @@
 	    untie(%bighash);
 	}
 	my $value = &docondval($sub_condition);
-	&appenv('user.state.'.$env{'request.course.id'}.".$number" => $value);
+	&appenv({'user.state.'.$env{'request.course.id'}.".$number" => $value});
 	return $value;
     }
     if ($env{'user.state.'.$env{'request.course.id'}}) {
@@ -6537,7 +6549,7 @@
 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
@@ -7439,7 +7451,7 @@
         if ($syval) {
 	    #unless ($syval=~/\_\d+$/) {
 		#unless ($env{'form.request.prefix'}=~/\.(\d+)\_$/) {
-		    #&appenv('request.ambiguous' => $thisfn);
+		    #&appenv({'request.ambiguous' => $thisfn});
 		    #return $env{$cache_str}='';
 		#}    
 		#$syval.=$1;
@@ -7491,7 +7503,7 @@
 	    return $env{$cache_str}=$syval;
         }
     }
-    &appenv('request.ambiguous' => $thisfn);
+    &appenv({'request.ambiguous' => $thisfn});
     return $env{$cache_str}='';
 }
 
@@ -8005,7 +8017,7 @@
     my (undef,$udom,$uname,$file)=split('/',$uri,4);
     if ($udom && $uname && $file) {
 	$file=~s|(\?\.*)*$||;
-        &appenv("userfile.$udom/$uname/$file" => $env{'request.course.id'});
+        &appenv({"userfile.$udom/$uname/$file" => $env{'request.course.id'}});
         return 'http://'.&hostname(&homeserver($uname,$udom)).'/'.$uri.
                (($uri=~/\?/)?'&':'?').'token='.$token.
                                '&tokenissued='.$perlvar{'lonHostID'};
@@ -8850,10 +8862,12 @@
 
 =item * 
 X<appenv()>
-B<appenv(%hash)>: the value of %hash is written to
+B<appenv($hashref,$rolesarrayref)>: the value of %{$hashref} is written to
 the user envirnoment file, and will be restored for each access this
 user makes during this session, also modifies the %env for the current
-process
+process. Optional rolesarrayref - if defined contains a reference to an array
+of roles which are exempt from the restriction on modifying user.role entries 
+in the user's environment.db and in %env.    
 
 =item *
 X<delenv()>
Index: loncom/publisher/loncfile.pm
diff -u loncom/publisher/loncfile.pm:1.87 loncom/publisher/loncfile.pm:1.88
--- loncom/publisher/loncfile.pm:1.87	Thu Oct 18 17:58:21 2007
+++ loncom/publisher/loncfile.pm	Tue Mar 11 22:46:38 2008
@@ -9,7 +9,7 @@
 #  and displays a page showing the results of the action.
 #
 #
-# $Id: loncfile.pm,v 1.87 2007/10/18 21:58:21 albertel Exp $
+# $Id: loncfile.pm,v 1.88 2008/03/12 02:46:38 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1128,8 +1128,8 @@
 
 sub decompress2 {
     my ($r, $user, $dir, $file) = @_;
-    &Apache::lonnet::appenv('cgi.file' => $file);
-    &Apache::lonnet::appenv('cgi.dir' => $dir);
+    &Apache::lonnet::appenv({'cgi.file' => $file});
+    &Apache::lonnet::appenv({'cgi.dir' => $dir});
     my $result=&Apache::lonnet::ssi_body('/cgi-bin/decompress.pl');
     $r->print($result);
     &Apache::lonnet::delenv('cgi.file');
Index: loncom/homework/chemresponse.pm
diff -u loncom/homework/chemresponse.pm:1.77 loncom/homework/chemresponse.pm:1.78
--- loncom/homework/chemresponse.pm:1.77	Wed Feb  6 11:32:30 2008
+++ loncom/homework/chemresponse.pm	Tue Mar 11 22:46:52 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # chemical equation style response
 #
-# $Id: chemresponse.pm,v 1.77 2008/02/06 16:32:30 raeburn Exp $
+# $Id: chemresponse.pm,v 1.78 2008/03/12 02:46:52 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -186,10 +186,10 @@
     my $result='<img alt="'.$smile.'" src="/cgi-bin/convertjme.pl?'.$id.'"';
     if ($options =~ /border/) { $result.= ' border="1"'; }
     $result.=' />';
-    &Apache::lonnet::appenv('cgi.'.$id.'.JME'   =>
-			    &escape($jme),
-			    'cgi.'.$id.'.PNG'   => 1,
-			    'cgi.'.$id.'.WIDTH' => $width);
+    &Apache::lonnet::appenv({'cgi.'.$id.'.JME'   =>
+			     &escape($jme),
+			     'cgi.'.$id.'.PNG'   => 1,
+			     'cgi.'.$id.'.WIDTH' => $width});
     return $result;
 }
 
@@ -365,9 +365,9 @@
 	if ($options =~ /border/) { $result.= ' border="1"'; }
 	$result.=' />';
 	&Apache::lonnet::appenv(
-            'cgi.'.$id.'.JME'   => &escape($molecule),
-	    'cgi.'.$id.'.PNG' => 1,
-	    'cgi.'.$id.'.WIDTH' => $width );
+            {'cgi.'.$id.'.JME'   => &escape($molecule),
+	     'cgi.'.$id.'.PNG' => 1,
+	     'cgi.'.$id.'.WIDTH' => $width});
     } elsif ($target eq 'tex') {
 	my $texwidth=&Apache::lonxml::get_param('texwidth',$parstack,$safeeval,undef,1);
 	my $webwidth=&Apache::lonxml::get_param('width', $parstack, $safeeval);
@@ -381,9 +381,9 @@
 	    '_'.time.'_'.$$.int(rand(1000)).'_organicstructure';
 	my $id=$filename;
 	&Apache::lonnet::appenv(
-		     'cgi.'.$id.'.JME'   => &escape($molecule),
-		     'cgi.'.$id.'.PS' => 1,
-		     'cgi.'.$id.'.WIDTH' => $texwidth );
+		     {'cgi.'.$id.'.JME'   => &escape($molecule),
+		      'cgi.'.$id.'.PS' => 1,
+		      'cgi.'.$id.'.WIDTH' => $texwidth});
 	$id=&escape($id);
 	&Apache::lonxml::register_ssi("/cgi-bin/convertjme.pl?$id");
 	if ($options =~ /border/) { $result.= '\fbox{'; }
Index: loncom/homework/drawimage.pm
diff -u loncom/homework/drawimage.pm:1.9 loncom/homework/drawimage.pm:1.10
--- loncom/homework/drawimage.pm:1.9	Tue May 30 08:45:36 2006
+++ loncom/homework/drawimage.pm	Tue Mar 11 22:46:52 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # programatic image drawing
 #
-# $Id: drawimage.pm,v 1.9 2006/05/30 12:45:36 www Exp $
+# $Id: drawimage.pm,v 1.10 2008/03/12 02:46:52 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -64,7 +64,7 @@
                            src='/adm/randomlabel.png?token=$cgi_id' />\n";
 	$args{"cgi.$cgi_id.SIZE"}=join(':',($width,$height));
 	$args{"cgi.$cgi_id.BGCOLOR"}=join(':',($bgcolor));
-	&Apache::lonnet::appenv(%args);
+	&Apache::lonnet::appenv(\%args);
 	if (@cgi_ids) {
 	    $cgi_id=pop(@cgi_ids);
 	} else {
Index: loncom/homework/edit.pm
diff -u loncom/homework/edit.pm:1.113 loncom/homework/edit.pm:1.114
--- loncom/homework/edit.pm:1.113	Mon Jan 14 22:09:09 2008
+++ loncom/homework/edit.pm	Tue Mar 11 22:46:52 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # edit mode helpers
 #
-# $Id: edit.pm,v 1.113 2008/01/15 03:09:09 raeburn Exp $
+# $Id: edit.pm,v 1.114 2008/03/12 02:46:52 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -880,7 +880,7 @@
 	$data{"imagechoice.$id.formwidth"}=$width.'_'.
 	    $Apache::edit::bgimgsrccurdepth;
     }
-    &Apache::lonnet::appenv(%data);
+    &Apache::lonnet::appenv(\%data);
     my $text="Click Coordinates";
     my $result='<a href="/adm/imagechoice?token='.$id.'" target="imagechoice">'.$text.'</a>';
     return $result;
@@ -913,7 +913,7 @@
 	$data{"imagechoice.$id.formwidth"}=$width.'_'.
 	    $Apache::edit::bgimgsrccurdepth;
     }
-    &Apache::lonnet::appenv(%data);
+    &Apache::lonnet::appenv(\%data);
     my $text="Enter Coordinates";
     if ($type eq 'polygon') { $text='Create Polygon Data'; }
     my $result='<a href="/adm/imagechoice?token='.$id.'" target="imagechoice">'.$text.'</a>';
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.513 loncom/homework/grades.pm:1.514
--- loncom/homework/grades.pm:1.513	Tue Mar  4 06:23:12 2008
+++ loncom/homework/grades.pm	Tue Mar 11 22:46:52 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.513 2008/03/04 11:23:12 foxr Exp $
+# $Id: grades.pm,v 1.514 2008/03/12 02:46:52 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1833,9 +1833,9 @@
 	join("\n",&Apache::loncommon::get_env_multiple('form.vPart'));
 
     my $identifier = &Apache::loncommon::get_cgi_id();
-    &Apache::lonnet::appenv('cgi.'.$identifier.'.students' => $all_students,
-                            'cgi.'.$identifier.'.symb' => $symb,
-                            'cgi.'.$identifier.'.parts' => $parts,);
+    &Apache::lonnet::appenv({'cgi.'.$identifier.'.students' => $all_students,
+                             'cgi.'.$identifier.'.symb' => $symb,
+                             'cgi.'.$identifier.'.parts' => $parts,});
     $r->print('<a href="/cgi-bin/multidownload.pl?'.$identifier.'">'.
 	      &mt('Download All Submitted Documents').'</a>');
     return
@@ -7492,7 +7492,7 @@
   	($uname,$udom)=split(/:/,$uname);
 
 	&Apache::lonxml::clear_problem_counter();
-  	&Apache::lonnet::appenv(%$scan_record);
+  	&Apache::lonnet::appenv($scan_record);
 
 	if (&scantron_clear_skip($scanlines,$scan_data,$i)) {
 	    &scantron_putfile($scanlines,$scan_data);
Index: loncom/homework/imagechoice.pm
diff -u loncom/homework/imagechoice.pm:1.13 loncom/homework/imagechoice.pm:1.14
--- loncom/homework/imagechoice.pm:1.13	Tue May  1 21:33:02 2007
+++ loncom/homework/imagechoice.pm	Tue Mar 11 22:46:53 2008
@@ -1,4 +1,4 @@
-# $Id: imagechoice.pm,v 1.13 2007/05/02 01:33:02 albertel Exp $
+# $Id: imagechoice.pm,v 1.14 2008/03/12 02:46:53 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -165,7 +165,7 @@
 	    $data=join(':',($env{"imagechoice.$id.coords"},
 			    $env{"form.image.x"},$env{"form.image.y"}));
 	}
-	&Apache::lonnet::appenv("imagechoice.$id.coords"=>$data);
+	&Apache::lonnet::appenv({"imagechoice.$id.coords"=>$data});
     }
     return int(scalar(split(':',$env{"imagechoice.$id.coords"}))/2);
 }
@@ -237,7 +237,7 @@
     &drawX(\%data,$imid,$x,$y);
     if ($type eq "polygon") { &drawPolygon(\%data,$id,$imid); }
     if ($type eq "box") { &drawBox(\%data,$id,$imid); }
-    &Apache::lonnet::appenv(%data);
+    &Apache::lonnet::appenv(\%data);
     return "/adm/randomlabel.png?token=$imid"
 }
 
Index: loncom/homework/imageresponse.pm
diff -u loncom/homework/imageresponse.pm:1.92 loncom/homework/imageresponse.pm:1.93
--- loncom/homework/imageresponse.pm:1.92	Fri Feb  1 17:05:45 2008
+++ loncom/homework/imageresponse.pm	Tue Mar 11 22:46:53 2008
@@ -2,7 +2,7 @@
 # The LearningOnline Network with CAPA
 # image click response style
 #
-# $Id: imageresponse.pm,v 1.92 2008/02/01 22:05:45 raeburn Exp $
+# $Id: imageresponse.pm,v 1.93 2008/03/12 02:46:53 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -223,7 +223,7 @@
 	    }
 	}
     }
-    &Apache::lonnet::appenv(%x);
+    &Apache::lonnet::appenv(\%x);
     return $id;
 }
 
Index: loncom/homework/lonhomework.pm
diff -u loncom/homework/lonhomework.pm:1.290 loncom/homework/lonhomework.pm:1.291
--- loncom/homework/lonhomework.pm:1.290	Mon Jan 21 12:20:45 2008
+++ loncom/homework/lonhomework.pm	Tue Mar 11 22:46:53 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Homework handler
 #
-# $Id: lonhomework.pm,v 1.290 2008/01/21 17:20:45 www Exp $
+# $Id: lonhomework.pm,v 1.291 2008/03/12 02:46:53 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1176,8 +1176,8 @@
 	    &Apache::lonnet::delenv('construct\\.style');
 	} elsif ($env{'form.style_file'} 
 	    && $env{'construct.style'} ne $env{'form.style_file'}) {
-	    &Apache::lonnet::appenv('construct.style' => 
-				        $env{'form.style_file'});
+	    &Apache::lonnet::appenv({'construct.style' => 
+				        $env{'form.style_file'}});
 	}
     }
 }
Index: loncom/homework/randomlabel.pm
diff -u loncom/homework/randomlabel.pm:1.90 loncom/homework/randomlabel.pm:1.91
--- loncom/homework/randomlabel.pm:1.90	Wed Oct 17 18:11:55 2007
+++ loncom/homework/randomlabel.pm	Tue Mar 11 22:46:53 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # random labelling tool
 #
-# $Id: randomlabel.pm,v 1.90 2007/10/17 22:11:55 albertel Exp $
+# $Id: randomlabel.pm,v 1.91 2008/03/12 02:46:53 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -178,7 +178,7 @@
 	$count = $Apache::randomlabel::obj_cnt;
 	if( $count != 0) { $args{"cgi.$cgi_id.OBJCOUNT"}=$count; }
 	$result.='<img src="/adm/randomlabel.png?token='.$cgi_id.'" /><br />'."\n";
-	&Apache::lonnet::appenv(%args);
+	&Apache::lonnet::appenv(\%args);
     } elsif ($target eq 'tex') {
 	$result='\end{picture}\\\\';
 	$result.= ' \vskip -'.$height_param.' mm }  \\\\ ';
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.185 loncom/auth/lonroles.pm:1.186
--- loncom/auth/lonroles.pm:1.185	Mon Mar 10 19:47:24 2008
+++ loncom/auth/lonroles.pm	Tue Mar 11 22:47:34 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # User Roles Screen
 #
-# $Id: lonroles.pm,v 1.185 2008/03/10 23:47:24 raeburn Exp $
+# $Id: lonroles.pm,v 1.186 2008/03/12 02:47:34 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -120,13 +120,13 @@
 	    &Apache::lonnet::put('email_status',\%temp);
 	    &Apache::lonnet::delenv('user.state.'.$env{'request.course.id'});
 	}
-	&Apache::lonnet::appenv("request.course.id"   => '',
-				"request.course.fn"   => '',
-				"request.course.uri"  => '',
-				"request.course.sec"  => '',
-				"request.role"        => 'cm',
-                                "request.role.adv"    => $env{'user.adv'},
-				"request.role.domain" => $env{'user.domain'});
+	&Apache::lonnet::appenv({"request.course.id"   => '',
+			 	 "request.course.fn"   => '',
+				 "request.course.uri"  => '',
+				 "request.course.sec"  => '',
+				 "request.role"        => 'cm',
+                                 "request.role.adv"    => $env{'user.adv'},
+				 "request.role.domain" => $env{'user.domain'}});
 # Check if user is a DC trying to enter a course or author space and needs privs to be created
         if ($numdc > 0) {
             foreach my $envkey (keys %env) {
@@ -274,10 +274,10 @@
 					 "Role ".$trolecode);
 		    
 		    &Apache::lonnet::appenv(
-					   'request.role'        => $trolecode,
-					   'request.role.domain' => $cdom,
-					   'request.course.sec'  => $csec,
-                                           'request.course.groups' => $cgrps);
+					   {'request.role'        => $trolecode,
+					    'request.role.domain' => $cdom,
+					    'request.course.sec'  => $csec,
+                                            'request.course.groups' => $cgrps});
                     my $tadv=0;
 
 		    if (($cnum) && ($role ne 'ca') && ($role ne 'aa')) {
@@ -288,7 +288,7 @@
 			    ($env{'form.orgurl'}!~/^\/adm\/flip/)) {
 			    my $dest=$env{'form.orgurl'};
 			    if (&Apache::lonnet::allowed('adv') eq 'F') { $tadv=1; }
-			    &Apache::lonnet::appenv('request.role.adv'=>$tadv);
+			    &Apache::lonnet::appenv({'request.role.adv'=>$tadv});
                             if (($ferr) && ($tadv)) {
 				&error_page($r,$ferr,$dest);
 			    } else {
@@ -298,7 +298,7 @@
 			} else {
 			    if (!$env{'request.course.id'}) {
 				&Apache::lonnet::appenv(
-				      "request.course.id"  => $cdom.'_'.$cnum);
+				      {"request.course.id"  => $cdom.'_'.$cnum});
 				$furl='/adm/roles?tryagain=1';
 				$msg=
 				    '<h1><span class="LC_error">'.
@@ -307,7 +307,7 @@
 				    '</span></h1><h3>'.&mt('Please try again.').'</h3>'.$ferr;
 			    }
 			    if (&Apache::lonnet::allowed('adv') eq 'F') { $tadv=1; }
-			    &Apache::lonnet::appenv('request.role.adv'=>$tadv);
+			    &Apache::lonnet::appenv({'request.role.adv'=>$tadv});
 
 			    if (($ferr) && ($tadv)) {
 				&error_page($r,$ferr,$furl);
@@ -1008,7 +1008,7 @@
                 &Apache::lonnet::set_userprivs(\%userroles,\%newrole,%newgroups);
                 my $adhocstart = $then-1;
                 $userroles{'user.role.'.$spec} = $adhocstart.'.';
-                &Apache::lonnet::appenv(%userroles);
+                &Apache::lonnet::appenv(\%userroles,[$role,'cm']);
             }
         }
     }
@@ -1158,19 +1158,19 @@
     my %ccrole = ();
     &Apache::lonnet::standard_roleprivs(\%ccrole,$role,$dcdom,$spec,$pickedcourse,$area);
     my ($author,$adv)= &Apache::lonnet::set_userprivs(\%userroles,\%ccrole);
-    &Apache::lonnet::appenv(%userroles);
+    &Apache::lonnet::appenv(\%userroles,[$role,'cm']);
 
     &Apache::lonnet::log($env{'user.domain'},
                          $env{'user.name'},
                          $env{'user.home'},
                         "Role ".$role);
     &Apache::lonnet::appenv(
-                          'request.role'        => $spec,
+                          {'request.role'        => $spec,
                           'request.role.domain' => $dcdom,
-                          'request.course.sec'  => '');
+                          'request.course.sec'  => ''});
     my $tadv=0;
     if (&Apache::lonnet::allowed('adv') eq 'F') { $tadv=1; }
-    &Apache::lonnet::appenv('request.role.adv'    => $tadv);
+    &Apache::lonnet::appenv({'request.role.adv'    => $tadv});
 }
 
 sub courseloadpage {

--raeburn1205290058--