[LON-CAPA-cvs] cvs: rat / lonambiguous.pm lonpage.pm lonpageflip.pm lonratedt.pm lonratmenu.pm lonratparms.pm lonratsrv.pm lonsequence.pm lonuserstate.pm lonwrapper.pm doc/gutshtml SessionOn2.html SessionThree.html doc/homework homework5.html storage.html worktime.html doc/loncapafiles loncapafiles.lpml doc/techtips worktime-new-1.html worktime.html loncom lonenc.pm loncom/auth lonacc.pm lonauth.pm loncacc.pm londatecheck.pm lonlogin.pm lonlogout.pm lonracc.pm lonroles.pm lonuploadedacc.pm loncom/automation Autocreate.pl loncom/cgi barcode.png decompress.pl graph.png loncgi.pm thumbnail.gif loncom/enrollment Autoenroll.pl Enrollment.pm loncom/homework bridgetask.pm chemresponse.pm convertjme.pl edit.pm essayresponse.pm externalresponse.pm grades.pm hint.pm imagechoice.pm imageresponse.pm inputtags.pm lonhomework.pm lonsimpleproblemedit.pm matchresponse.pm optionresponse.pm outputtags.pm radiobuttonresponse.pm randomlabel.pm randomlylabel.pm response.pm structuretags.pm loncom/homework/caparesponse caparesponse.pm loncom/html/adm/help searchcat.html loncom/html/adm/help/tex Developer_Tutorial.tex Guts_Apache_Env.tex loncom/html/adm/helper course.initialization.helper resettimes.helper loncom/html/res/adm/pages/annotator admannotations.pm loncom/html/res/adm/pages/bookmarkmenu admbookmarks.pm loncom/imspackages imsexport.pm imsimport.pm imsimportdocs.pm imsprocessor.pm loncom/interface groupsort.pm lonaboutme.pm lonannounce.pm lonbulletin.pm lonchat.pm lonchatfetch.pm loncommon.pm loncommunicate.pm loncoursedata.pm loncreatecourse.pm loncreateuser.pm londocs.pm londropadd.pm lonerrorhandler.pm lonevaluate.pm lonfeedback.pm lonhelp.pm lonhelper.pm lonhelpmenu.pm lonhtmlcommon.pm lonindexer.pm lonmanagekeys.pm lonmenu.pm lonmeta.pm lonmodifycourse.pm lonmsg.pm lonmysql.pm lonnavmaps.pm lonparmset.pm lonpickcode.pm lonpickcourse.pm lonpickstudent.pm lonpopulate.pm lonpreferences.pm lonprintout.pm lonquickgrades.pm lonremote.pm lonsearchcat.pm lonsimplepage.pm lonsource.pm lonspeller.pm lonstatistics.pm lo

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 07 Apr 2005 06:56:32 -0000


This is a MIME encoded message

--albertel1112856992
Content-Type: text/plain

albertel		Thu Apr  7 02:56:32 2005 EDT

  Modified files:              
    /doc/gutshtml	SessionOn2.html SessionThree.html 
    /doc/homework	homework5.html storage.html worktime.html 
    /doc/loncapafiles	loncapafiles.lpml 
    /doc/techtips	worktime-new-1.html worktime.html 
    /loncom	lonenc.pm 
    /loncom/auth	lonacc.pm lonauth.pm loncacc.pm londatecheck.pm 
                	lonlogin.pm lonlogout.pm lonracc.pm lonroles.pm 
                	lonuploadedacc.pm 
    /loncom/automation	Autocreate.pl 
    /loncom/cgi	barcode.png decompress.pl graph.png loncgi.pm 
               	thumbnail.gif 
    /loncom/enrollment	Autoenroll.pl Enrollment.pm 
    /loncom/homework	bridgetask.pm chemresponse.pm convertjme.pl 
                    	edit.pm essayresponse.pm externalresponse.pm 
                    	grades.pm hint.pm imagechoice.pm imageresponse.pm 
                    	inputtags.pm lonhomework.pm 
                    	lonsimpleproblemedit.pm matchresponse.pm 
                    	optionresponse.pm outputtags.pm 
                    	radiobuttonresponse.pm randomlabel.pm 
                    	randomlylabel.pm response.pm structuretags.pm 
    /loncom/homework/caparesponse	caparesponse.pm 
    /loncom/html/adm/help	searchcat.html 
    /loncom/html/adm/help/tex	Developer_Tutorial.tex 
                             	Guts_Apache_Env.tex 
    /loncom/html/adm/helper	course.initialization.helper 
                           	resettimes.helper 
    /loncom/html/res/adm/pages/annotator	admannotations.pm 
    /loncom/html/res/adm/pages/bookmarkmenu	admbookmarks.pm 
    /loncom/imspackages	imsexport.pm imsimport.pm imsimportdocs.pm 
                       	imsprocessor.pm 
    /loncom/interface	groupsort.pm lonaboutme.pm lonannounce.pm 
                     	lonbulletin.pm lonchat.pm lonchatfetch.pm 
                     	loncommon.pm loncommunicate.pm loncoursedata.pm 
                     	loncreatecourse.pm loncreateuser.pm londocs.pm 
                     	londropadd.pm lonerrorhandler.pm lonevaluate.pm 
                     	lonfeedback.pm lonhelp.pm lonhelper.pm 
                     	lonhelpmenu.pm lonhtmlcommon.pm lonindexer.pm 
                     	lonmanagekeys.pm lonmenu.pm lonmeta.pm 
                     	lonmodifycourse.pm lonmsg.pm lonmysql.pm 
                     	lonnavmaps.pm lonparmset.pm lonpickcode.pm 
                     	lonpickcourse.pm lonpickstudent.pm lonpopulate.pm 
                     	lonpreferences.pm lonprintout.pm 
                     	lonquickgrades.pm lonremote.pm lonsearchcat.pm 
                     	lonsimplepage.pm lonsource.pm lonspeller.pm 
                     	lonstatistics.pm lonsupportreq.pm lonsyllabus.pm 
                     	lontest.pm lontrackstudent.pm lonviewclasslist.pm 
                     	lonwhatsnew.pm portfolio.pm printout.pl 
    /loncom/interface/spreadsheet	Spreadsheet.pm assesscalc.pm 
                                 	classcalc.pm lonspreadsheet.pm 
                                 	studentcalc.pm 
    /loncom/interface/statistics	loncorrectproblemplot.pm 
                                	lonproblemanalysis.pm 
                                	lonproblemstatistics.pm 
                                	lonstathelpers.pm 
                                	lonstudentassessment.pm 
                                	lonstudentsubmissions.pm 
                                	lonsubmissiontimeanalysis.pm 
                                	lonsurveyreports.pm 
    /loncom/lonnet/perl	lonnet.pm lonrep.pm lonuploadrep.pm 
    /loncom/publisher	loncfile.pm lonconstruct.pm londiff.pm 
                     	lonpubdir.pm lonpublisher.pm lonpubmenu.pm 
                     	lonretrieve.pm lonrights.pm lonunauthorized.pm 
                     	lonupload.pm testbankimport.pm 
    /loncom/xml	londefdef.pm lonplot.pm lontex.pm lontexconvert.pm 
               	lonxml.pm scripttag.pm 
    /rat	lonambiguous.pm lonpage.pm lonpageflip.pm lonratedt.pm 
        	lonratmenu.pm lonratparms.pm lonratsrv.pm lonsequence.pm 
        	lonuserstate.pm lonwrapper.pm 
  Log:
  - ENV -> env
  
  
--albertel1112856992
Content-Type: text/plain
Content-Disposition: attachment; filename="albertel-20050407025632.txt"

Index: doc/gutshtml/SessionOn2.html
diff -u doc/gutshtml/SessionOn2.html:1.2 doc/gutshtml/SessionOn2.html:1.3
--- doc/gutshtml/SessionOn2.html:1.2	Tue Jul 22 10:47:00 2003
+++ doc/gutshtml/SessionOn2.html	Thu Apr  7 02:56:20 2005
@@ -2022,7 +2022,7 @@
 
     <li>grade_target, grade_username, grade_domain, grade_symb - the vaules take 
 
-      precedence over the the normal ENV settings of these, use &amp;Apache::lonxml::whichuser() 
+      precedence over the the normal env settings of these, use &amp;Apache::lonxml::whichuser() 
 
       to get back the correct vaues of the items </li>
 
@@ -2308,7 +2308,7 @@
 
 style='color:black'> - the internal name for a course, usually found in </span><span
 
-style='font-family:"Courier New";color:black'>$ENV{'request.course.id'}</span><span
+style='font-family:"Courier New";color:black'>$env{'request.course.id'}</span><span
 
 style='color:black'> which is what will be looked at if no value is passed to 
 
@@ -2322,7 +2322,7 @@
 
 style='color:black'> - the domain that the user belongs to, usually found in </span><span
 
-style='font-family:"Courier New";color:black'>$ENV{'user.domain'}</span><span
+style='font-family:"Courier New";color:black'>$env{'user.domain'}</span><span
 
 style='color:black'> which is what will be looked at if no value is passed to 
 
@@ -2336,7 +2336,7 @@
 
 style='color:black'> - the login name for the user, usually found in </span><span
 
-style='font-family:"Courier New";color:black'>$ENV{'user.name'}</span><span
+style='font-family:"Courier New";color:black'>$env{'user.name'}</span><span
 
 style='color:black'> which is what will be looked at if no value is passed to 
 
@@ -2350,13 +2350,13 @@
 
 style='color:black'> - the homeserver for the user, usually found in </span><span
 
-style='font-family:"Courier New";color:black'>$ENV{'user.home'}</span><span
+style='font-family:"Courier New";color:black'>$env{'user.home'}</span><span
 
 style='color:black'> but can be easily gotten from a domain and name through </span><span
 
 style='font-family:"Courier New";color:black'>&amp;Apache::lonnet::homeserver($uname,$domain)</span><span
 
-style='color:black'>. If no value is passed to store/restore the value in %ENV 
+style='color:black'>. If no value is passed to store/restore the value in %env 
 
     will be used. </span></p>
 
Index: doc/gutshtml/SessionThree.html
diff -u doc/gutshtml/SessionThree.html:1.2 doc/gutshtml/SessionThree.html:1.3
--- doc/gutshtml/SessionThree.html:1.2	Tue Jul 22 10:47:00 2003
+++ doc/gutshtml/SessionThree.html	Thu Apr  7 02:56:20 2005
@@ -72,11 +72,11 @@
     <li><code><span style='font-family:
      Courier'>appenv(%hash)</span></code> : the value of %hash 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 </li>
+      during this session, also modifies the %env for the current process </li>
     <li><code><span style='font-family:
      Courier'>delenv($regexp)</span></code> : removes all items from the session 
       environment file that matches the regular expression in $regexp. The values 
-      are also delted from the current processes %ENV. </li>
+      are also delted from the current processes %env. </li>
   </ul>
   <h3><a name="user_information"></a><a name="_Toc421867059">User Information</a></h3>
   <ul type=disc>
@@ -226,7 +226,7 @@
      "Courier New"'>symbverify($symb,$thisfn):</span> verifies that $symb actually 
       exists and is a possible symb for the URL in $thisfn, returns a 1 on success, 
       0 on failure, user must be in a course, as it assumes the existance of the 
-      course init hash, and uses $ENV('request.course.id'}</li>
+      course init hash, and uses $env('request.course.id'}</li>
     <li><span style='font-family:
      "Courier New"'>symbclean($symb):</span> removes versions numbers from a symb, 
       returns the cleaned symb</li>
@@ -247,7 +247,7 @@
       : return unique, unfakeable, receipt </li>
     <li><code><span
      style='font-family:Courier'>receipt()</span></code> : API to ireceipt working 
-      off of ENV values; given out to users </li>
+      off of env values; given out to users </li>
     <li><code><span
      style='font-family:Courier'>countacc($url)</span></code> : count the number 
       of accesses to a given URL </li>
@@ -275,7 +275,7 @@
      style='font-family:Courier'>store($storehash,$symb,$namespace,$udom,$uname)</span></code> 
       : stores hash permanently for this url; hashref needs to be given and should 
       be a \%hashname; the remaining args aren't required and if they aren't passed 
-      or are '' they will be derived from the ENV </li>
+      or are '' they will be derived from the env </li>
     <li><code><span
      style='font-family:Courier'>cstore($storehash,$symb,$namespace,$udom,$uname)</span></code> 
       : same as store but uses critical subroutine </li>
Index: doc/homework/homework5.html
diff -u doc/homework/homework5.html:1.22 doc/homework/homework5.html:1.23
--- doc/homework/homework5.html:1.22	Wed Nov 13 18:28:30 2002
+++ doc/homework/homework5.html	Thu Apr  7 02:56:20 2005
@@ -1154,7 +1154,7 @@
     <ul>
       <li>
 	grade_target, grade_username, grade_domain, grade_symb - the
-	vaules take precedence over the the normal ENV settings of
+	vaules take precedence over the the normal env settings of
 	these, use &Apache::lonxml::whichuser() to get back the
 	correct vaues of the items
       </li>
Index: doc/homework/storage.html
diff -u doc/homework/storage.html:1.2 doc/homework/storage.html:1.3
--- doc/homework/storage.html:1.2	Thu May 31 17:21:49 2001
+++ doc/homework/storage.html	Thu Apr  7 02:56:20 2005
@@ -93,17 +93,17 @@
       </li>
       <li>
 	<i>$courseid</i> - the internal name for a course, usually
-	found in <tt>$ENV{'request.course.id'}</tt> which is what will
+	found in <tt>$env{'request.course.id'}</tt> which is what will
 	be looked at if no value is passed to the functions.
       </li>
       <li>
 	<i>$domain</i> - the domain that the user belongs to, usually
-	found in <tt>$ENV{'user.domain'}</tt> which is what will be
+	found in <tt>$env{'user.domain'}</tt> which is what will be
 	looked at if no value is passed to the functions.
       </li>
       <li>
 	<i>$uname</i> - the login name for the user, usually
-	found in <tt>$ENV{'user.name'}</tt> which is what will
+	found in <tt>$env{'user.name'}</tt> which is what will
 	be looked at if no value is passed to the functions.
       </li>
       <li>
Index: doc/homework/worktime.html
diff -u doc/homework/worktime.html:1.3 doc/homework/worktime.html:1.4
--- doc/homework/worktime.html:1.3	Tue May 25 12:02:22 2004
+++ doc/homework/worktime.html	Thu Apr  7 02:56:20 2005
@@ -58,7 +58,7 @@
 	$r->content_type('text/html');
 	$r->send_http_header;
 	return OK if $r->header_only;
-	<i>$r->print("The username handler is in use by $ENV{'user.name'}");</i>
+	<i>$r->print("The username handler is in use by $env{'user.name'}");</i>
 	return OK;
 }
 1;
@@ -75,7 +75,7 @@
 	$r->content_type('text/html');
 	$r->send_http_header;
 	return OK if $r->header_only;
-	<i>$r->print("The username handler is in use by $ENV{'user.name'} looking for "
+	<i>$r->print("The username handler is in use by $env{'user.name'} looking for "
                      .$r->uri."&lt;br&gt;");</i>
 	<b>my $file=&Apache::lonnet::filelocation("",$r->uri);</b>
 	<b>my $contents=&Apache::lonnet::getfile($file);</b>
@@ -96,7 +96,7 @@
 	$r->content_type('text/html');
 	$r->send_http_header;
 	return OK if $r->header_only;
-	$r->print("The username handler is in use by $ENV{'user.name'} looking for "
+	$r->print("The username handler is in use by $env{'user.name'} looking for "
                    .$r->uri."&lt;br&gt;");
 	my $file=&Apache::lonnet::filelocation("",$r->uri);
 	my $contents=&Apache::lonnet::getfile($file);
@@ -118,7 +118,7 @@
         $r->content_type('text/html');
         $r->send_http_header;
         return OK if $r->header_only;
-        $r->print("The username handler is in use by $ENV{'user.name'} looking for "
+        $r->print("The username handler is in use by $env{'user.name'} looking for "
                    .$r->uri."&lt;br&gt;");
         my $file=&amp;Apache::lonnet::filelocation("",$r->uri);
         my $contents=&amp;Apache::lonnet::getfile($file);
@@ -131,9 +131,9 @@
         } else {
                 $r->print("&lt;br&gt;Last time you said $hash{'info'}");
         }
-        if ($ENV{'form.info'}) {
-                $r->print("&lt;br&gt;Now you say $ENV{'form.info'}");
-                $hash{'info'}=$ENV{'form.info'};
+        if ($env{'form.info'}) {
+                $r->print("&lt;br&gt;Now you say $env{'form.info'}");
+                $hash{'info'}=$env{'form.info'};
                 &amp;Apache::lonnet::put('username',%hash);
         }</b>
         return OK;
Index: doc/loncapafiles/loncapafiles.lpml
diff -u doc/loncapafiles/loncapafiles.lpml:1.419 doc/loncapafiles/loncapafiles.lpml:1.420
--- doc/loncapafiles/loncapafiles.lpml:1.419	Mon Mar 21 14:29:13 2005
+++ doc/loncapafiles/loncapafiles.lpml	Thu Apr  7 02:56:20 2005
@@ -2,7 +2,7 @@
  "http://lpml.sourceforge.net/DTD/lpml.dtd">
 <!-- loncapafiles.lpml -->
 
-<!-- $Id: loncapafiles.lpml,v 1.419 2005/03/21 19:29:13 matthew Exp $ -->
+<!-- $Id: loncapafiles.lpml,v 1.420 2005/04/07 06:56:20 albertel Exp $ -->
 
 <!--
 
@@ -6020,6 +6020,7 @@
     </description>
 <filenames>
 activity_to_accesscount.pl;
+clean_db.pl;
 dump_db.pl;
 escape.pl;
 excise_from_db.pl;
Index: doc/techtips/worktime-new-1.html
diff -u doc/techtips/worktime-new-1.html:1.1 doc/techtips/worktime-new-1.html:1.2
--- doc/techtips/worktime-new-1.html:1.1	Fri Jun 28 16:56:50 2002
+++ doc/techtips/worktime-new-1.html	Thu Apr  7 02:56:20 2005
@@ -206,7 +206,7 @@
 	$r->content_type('text/html');
 	$r->send_http_header;
 	return OK if $r->header_only;
-	<i>$r->print("The workshop handler is in use by $ENV{'user.name'}");</i>
+	<i>$r->print("The workshop handler is in use by $env{'user.name'}");</i>
 	return OK;
 }
 1;
@@ -223,7 +223,7 @@
 	$r->content_type('text/html');
 	$r->send_http_header;
 	return OK if $r->header_only;
-	<i>$r->print("The workshop handler is in use by $ENV{'user.name'} looking for "
+	<i>$r->print("The workshop handler is in use by $env{'user.name'} looking for "
                      .$r->uri."&lt;br&gt;");</i>
 	<b>my $file=&amp;Apache::lonnet::filelocation("",$r->uri);</b>
 	<b>my $contents=&amp;Apache::lonnet::getfile($file);</b>
@@ -244,7 +244,7 @@
 	$r->content_type('text/html');
 	$r->send_http_header;
 	return OK if $r->header_only;
-	$r->print("The workshop handler is in use by $ENV{'user.name'} looking for "
+	$r->print("The workshop handler is in use by $env{'user.name'} looking for "
                    .$r->uri."&lt;br&gt;");
 	my $file=&amp;Apache::lonnet::filelocation("",$r->uri);
 	my $contents=&amp;Apache::lonnet::getfile($file);
@@ -266,7 +266,7 @@
         $r->content_type('text/html');
         $r->send_http_header;
         return OK if $r->header_only;
-        $r->print("The workshop handler is in use by $ENV{'user.name'} looking for "
+        $r->print("The workshop handler is in use by $env{'user.name'} looking for "
                    .$r->uri."&lt;br&gt;");
         my $file=&amp;amp;Apache::lonnet::filelocation("",$r->uri);
         my $contents=&amp;amp;Apache::lonnet::getfile($file);
@@ -279,9 +279,9 @@
         } else {
                 $r->print("&lt;br&gt;Last time you said $hash{'info'}");
         }
-        if ($ENV{'form.info'}) {
-                $r->print("&lt;br&gt;Now you say $ENV{'form.info'}");
-                $hash{'info'}=$ENV{'form.info'};
+        if ($env{'form.info'}) {
+                $r->print("&lt;br&gt;Now you say $env{'form.info'}");
+                $hash{'info'}=$env{'form.info'};
                 &amp;Apache::lonnet::put('workshop',\%hash);
         }</b>
         return OK;
Index: doc/techtips/worktime.html
diff -u doc/techtips/worktime.html:1.1 doc/techtips/worktime.html:1.2
--- doc/techtips/worktime.html:1.1	Fri Jun 28 16:56:50 2002
+++ doc/techtips/worktime.html	Thu Apr  7 02:56:20 2005
@@ -40,7 +40,7 @@
 	$r->content_type('text/html');
 	$r->send_http_header;
 	return OK if $r->header_only;
-	<i>$r->print("The username handler is in use by $ENV{'user.name'}");</i>
+	<i>$r->print("The username handler is in use by $env{'user.name'}");</i>
 	return OK;
 }
 1;
@@ -57,7 +57,7 @@
 	$r->content_type('text/html');
 	$r->send_http_header;
 	return OK if $r->header_only;
-	<i>$r->print("The username handler is in use by $ENV{'user.name'} looking for "
+	<i>$r->print("The username handler is in use by $env{'user.name'} looking for "
                      .$r->uri."&lt;br&gt;");</i>
 	<b>my $file=&Apache::lonnet::filelocation("",$r->uri);</b>
 	<b>my $contents=&Apache::lonnet::getfile($file);</b>
@@ -78,7 +78,7 @@
 	$r->content_type('text/html');
 	$r->send_http_header;
 	return OK if $r->header_only;
-	$r->print("The username handler is in use by $ENV{'user.name'} looking for "
+	$r->print("The username handler is in use by $env{'user.name'} looking for "
                    .$r->uri."&lt;br&gt;");
 	my $file=&Apache::lonnet::filelocation("",$r->uri);
 	my $contents=&Apache::lonnet::getfile($file);
@@ -100,7 +100,7 @@
         $r->content_type('text/html');
         $r->send_http_header;
         return OK if $r->header_only;
-        $r->print("The username handler is in use by $ENV{'user.name'} looking for "
+        $r->print("The username handler is in use by $env{'user.name'} looking for "
                    .$r->uri."&lt;br&gt;");
         my $file=&amp;Apache::lonnet::filelocation("",$r->uri);
         my $contents=&amp;Apache::lonnet::getfile($file);
@@ -113,9 +113,9 @@
         } else {
                 $r->print("&lt;br&gt;Last time you said $hash{'info'}");
         }
-        if ($ENV{'form.info'}) {
-                $r->print("&lt;br&gt;Now you say $ENV{'form.info'}");
-                $hash{'info'}=$ENV{'form.info'};
+        if ($env{'form.info'}) {
+                $r->print("&lt;br&gt;Now you say $env{'form.info'}");
+                $hash{'info'}=$env{'form.info'};
                 &amp;Apache::lonnet::put('username',%hash);
         }</b>
         return OK;
Index: loncom/lonenc.pm
diff -u loncom/lonenc.pm:1.10 loncom/lonenc.pm:1.11
--- loncom/lonenc.pm:1.10	Wed Jan 19 13:16:35 2005
+++ loncom/lonenc.pm	Thu Apr  7 02:56:20 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # URL translation for encrypted filenames
 #
-# $Id: lonenc.pm,v 1.10 2005/01/19 18:16:35 albertel Exp $
+# $Id: lonenc.pm,v 1.11 2005/04/07 06:56:20 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -30,7 +30,7 @@
 
 use strict;
 use Apache::Constants qw(:common :remotehost);
-use Apache::lonnet();
+use Apache::lonnet;
 use Apache::File();
 use Apache::loncommon;
 use Crypt::IDEA;
@@ -45,7 +45,7 @@
 	my $handle=$lonid->value;
         $handle=~s/\W//g;
         my $lonidsdir=$r->dir_config('lonIDsDir');
-	$ENV{'request.enc'}=1;
+	$env{'request.enc'}=1;
         if ((-e "$lonidsdir/$handle.id") && ($handle ne '')) {
 # Initialize Environment
             &Apache::lonnet::transfer_profile_to_env($lonidsdir,$handle);
@@ -60,7 +60,7 @@
 }
 
 sub encryptseed {
-    my $seed=$ENV{'course.'.$ENV{'request.course.id'}.'.internal.encseed'};
+    my $seed=$env{'course.'.$env{'request.course.id'}.'.internal.encseed'};
     $seed=~s/[^0-9a-f]/0/g;
     $seed.='0123456789abcdef';
     $seed=substr($seed.$seed,0,32);
@@ -83,7 +83,7 @@
 				  pack("H16",substr($uri,$encidx,16))
 				  );
     }
-    $ENV{'request.enc'}=1;
+    $env{'request.enc'}=1;
     $decuri=&remove_noise($decuri);
     return substr($decuri,0,$cmdlength);
 }
@@ -111,7 +111,7 @@
 
 sub encrypted {
     my $uri=shift;
-    if ($ENV{'request.role.adv'}) { return($uri); }
+    if ($env{'request.role.adv'}) { return($uri); }
     my $seed=&encryptseed();
     unless ($seed) {
 	return $uri;
@@ -132,7 +132,7 @@
 
 sub check_encrypt {
     my $str=shift;
-    if ($ENV{'request.enc'}) { return &Apache::lonenc::encrypted($str); }
+    if ($env{'request.enc'}) { return &Apache::lonenc::encrypted($str); }
     return $str;
 }
 
@@ -149,7 +149,7 @@
 sub encrypt_ref {
     my ($token,$elements)=@_;
     my $html;
-    if ($ENV{'request.enc'}) {
+    if ($env{'request.enc'}) {
 	while (my ($name,$value)= each(%{ $elements })) {
 	    if (!$value) { next; }
 	    my $href=&Apache::lonnet::hreflocation($Apache::lonxml::pwd[-1],$value);
Index: loncom/auth/lonacc.pm
diff -u loncom/auth/lonacc.pm:1.63 loncom/auth/lonacc.pm:1.64
--- loncom/auth/lonacc.pm:1.63	Mon Feb 28 19:22:57 2005
+++ loncom/auth/lonacc.pm	Thu Apr  7 02:56:20 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Cookie Based Access Handler
 #
-# $Id: lonacc.pm,v 1.63 2005/03/01 00:22:57 albertel Exp $
+# $Id: lonacc.pm,v 1.64 2005/04/07 06:56:20 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -71,12 +71,12 @@
 # -------------------------------------------------------------- Resource State
 
             if ($requrl=~/^\/+(res|uploaded)\//) {
-               $ENV{'request.state'} = "published";
+               $env{'request.state'} = "published";
 	    } else {
-	       $ENV{'request.state'} = 'unknown';
+	       $env{'request.state'} = 'unknown';
             }
-            $ENV{'request.filename'} = $r->filename;
-            $ENV{'request.noversionuri'} = &Apache::lonnet::deversion($requrl);
+            $env{'request.filename'} = $r->filename;
+            $env{'request.noversionuri'} = &Apache::lonnet::deversion($requrl);
 # -------------------------------------------------------- Load POST parameters
 
 	    &Apache::loncommon::get_posted_cgi($r);
@@ -86,24 +86,24 @@
             if ($requrl!~/^\/adm|public|prtspool\//) {
 		my $access=&Apache::lonnet::allowed('bre',$requrl);
                 if ($access eq '1') {
-		   $ENV{'user.error.msg'}="$requrl:bre:0:0:Choose Course";
+		   $env{'user.error.msg'}="$requrl:bre:0:0:Choose Course";
 	           return HTTP_NOT_ACCEPTABLE; 
                 }
                 if (($access ne '2') && ($access ne 'F')) {
-		   $ENV{'user.error.msg'}="$requrl:bre:1:1:Access Denied";
+		   $env{'user.error.msg'}="$requrl:bre:1:1:Access Denied";
 	           return HTTP_NOT_ACCEPTABLE; 
                 }
             }
 	    if ($requrl =~ m|^/prtspool/|) {
-		my $start='/prtspool/'.$ENV{'user.name'}.'_'.
-		    $ENV{'user.domain'};
+		my $start='/prtspool/'.$env{'user.name'}.'_'.
+		    $env{'user.domain'};
 		if ($requrl !~ /^\Q$start\E/) {
-		    $ENV{'user.error.msg'}="$requrl:bre:1:1:Access Denied";
+		    $env{'user.error.msg'}="$requrl:bre:1:1:Access Denied";
 		    return HTTP_NOT_ACCEPTABLE;
 		}
 	    }
 # ------------------------------------------------------------- This is allowed
-          if ($ENV{'request.course.id'}) {
+          if ($env{'request.course.id'}) {
 	    &Apache::lonnet::countacc($requrl);
             $requrl=~/\.(\w+)$/;
             if ((&Apache::loncommon::fileembstyle($1) eq 'ssi') ||
@@ -117,8 +117,8 @@
                 if ($query) {
 		    &Apache::loncommon::get_unprocessed_cgi($query,['symb']);
                 }
-                if ($ENV{'form.symb'}) {
-		    $symb=&Apache::lonnet::symbclean($ENV{'form.symb'});
+                if ($env{'form.symb'}) {
+		    $symb=&Apache::lonnet::symbclean($env{'form.symb'});
                     if ($requrl =~ m|^/adm/wrapper/|) {
                         my ($map,$mid,$murl)=&Apache::lonnet::decode_symb($symb);
                         &Apache::lonnet::symblist($map,$murl => [$murl,$mid],
@@ -132,7 +132,7 @@
 		    } else {
 			$r->log_reason('Invalid symb for '.$requrl.': '.
                                        $symb);
-		        $ENV{'user.error.msg'}=
+		        $env{'user.error.msg'}=
                                 "$requrl:bre:1:1:Invalid Access";
   	                return HTTP_NOT_ACCEPTABLE; 
                     }
@@ -141,7 +141,7 @@
 		    if (&Apache::lonnet::is_on_map($requrl) && $symb &&
 			!&Apache::lonnet::symbverify($symb,$requrl)) {
 			$r->log_reason('Invalid symb for '.$requrl.': '.$symb);
-		        $ENV{'user.error.msg'}=
+		        $env{'user.error.msg'}=
                                 "$requrl:bre:1:1:Invalid Access";
   	                return HTTP_NOT_ACCEPTABLE; 
 		    }
@@ -151,7 +151,7 @@
 						'last_known' =>[$murl,$mid]);
 		    }
                 }
-                $ENV{'request.symb'}=$symb;
+                $env{'request.symb'}=$symb;
                 &Apache::lonnet::courseacclog($symb);
             } else {
 # ------------------------------------------------------- This is other content
@@ -169,19 +169,19 @@
 	|| (&Apache::lonnet::metadata($requrl,'copyright') eq 'public')) {
         &Apache::lonnet::logthis('Granting public access: '.$requrl);
 	&Apache::loncommon::get_posted_cgi($r);
-	$ENV{'user.name'}='public';
-        $ENV{'user.domain'}='public';
-        $ENV{'request.state'} = "published";
-        $ENV{'request.publicaccess'} = 1;
-        $ENV{'request.filename'} = $r->filename;
+	$env{'user.name'}='public';
+        $env{'user.domain'}='public';
+        $env{'request.state'} = "published";
+        $env{'request.publicaccess'} = 1;
+        $env{'request.filename'} = $r->filename;
 	my ($httpbrowser,  $clientbrowser, $clientversion,
 	    $clientmathml, $clientunicode, $clientos) =
 		&Apache::loncommon::decode_user_agent($r);
-	$ENV{'browser.type'}=$clientbrowser;
-        $ENV{'browser.version'}=$clientversion;
-        $ENV{'browser.mathml'}=$clientmathml;
-        $ENV{'browser.unicode'}=$clientunicode;
-        $ENV{'browser.os'}=$clientos;
+	$env{'browser.type'}=$clientbrowser;
+        $env{'browser.version'}=$clientversion;
+        $env{'browser.mathml'}=$clientmathml;
+        $env{'browser.unicode'}=$clientunicode;
+        $env{'browser.os'}=$clientos;
 
         return OK;
     }
@@ -191,8 +191,8 @@
 #        ($requrl=~/^\/adm\/(roles|logout|email|menu|remote)/) ||
 #        ($requrl=~m|^/prtspool/|)) {
 # -------------------------- Store where they wanted to go and get login screen
-	$ENV{'request.querystring'}=$r->args;
-	$ENV{'request.firsturl'}=$requrl;
+	$env{'request.querystring'}=$r->args;
+	$env{'request.firsturl'}=$requrl;
        return FORBIDDEN;
 #   } else {
 # --------------------------------------------------------------------- Goodbye
Index: loncom/auth/lonauth.pm
diff -u loncom/auth/lonauth.pm:1.65 loncom/auth/lonauth.pm:1.66
--- loncom/auth/lonauth.pm:1.65	Sat Feb 26 00:37:23 2005
+++ loncom/auth/lonauth.pm	Thu Apr  7 02:56:21 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # User Authentication Module
 #
-# $Id: lonauth.pm,v 1.65 2005/02/26 05:37:23 albertel Exp $
+# $Id: lonauth.pm,v 1.66 2005/04/07 06:56:21 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -25,13 +25,6 @@
 #
 # http://www.lon-capa.org/
 #
-# 5/21/99,5/22,5/25,5/26,5/27,5/29,6/2,6/11,6/14,6/15
-# 16/11,12/16,
-# 1/14,2/24,2/28,2/29,3/7,5/29,5/30,5/31,6/1,6/5,6/29,
-# 7/1,7/10,10/2,10/5,10/9,10/26,10/30,11/10,
-# 05/28,05/29 Gerd Kortemeyer
-# 07/28,08/03 Gerd Kortemeyer
-# 8/20 Gerd Kortemeyer
 
 package Apache::lonauth;
 
@@ -43,7 +36,7 @@
 use DynaLoader; # for Crypt::DES version
 use Crypt::DES;
 use Apache::loncommon();
-use Apache::lonnet();
+use Apache::lonnet;
 use Apache::lonmenu();
 use Fcntl qw(:flock);
 use Apache::lonlocal;
@@ -107,7 +100,7 @@
     if (($userenv{'interface'}) && (!$FORM{'interface'})) {
 	$FORM{'interface'}=$userenv{'interface'};
     }
-    $ENV{'environment.remote'}=$userenv{'remote'};
+    $env{'environment.remote'}=$userenv{'remote'};
     if ($userenv{'texengine'} eq 'ttm') { $clientmathml=1; }
 
 # --------------- Do not trust query string to be put directly into environment
@@ -143,12 +136,12 @@
 	print $idf "request.course.uri=\n";
 	print $idf "request.course.sec=\n";
 	print $idf "request.role=cm\n";
-        print $idf "request.role.adv=$ENV{'user.adv'}\n";
+        print $idf "request.role.adv=$env{'user.adv'}\n";
 	print $idf "request.host=$ENV{'REMOTE_ADDR'}\n";
 	if ($FORM{'interface'}) {
 	    $FORM{'interface'}=~s/\W//gs;
 	    print $idf "browser.interface=$FORM{'interface'}\n";
-	    $ENV{'browser.interface'}=$FORM{'interface'};
+	    $env{'browser.interface'}=$FORM{'interface'};
 	    foreach ('imagesuppress','appletsuppress',
 		     'embedsuppress','fontenhance','blackwhite') {
 		if (($FORM{$_} eq 'true') ||
@@ -160,9 +153,9 @@
 	if ($userroles ne '') { print $idf "$userroles"; }
 	$idf->close();
     }
-    $ENV{'request.role'}='cm';
-    $ENV{'request.role.adv'}=$ENV{'user.adv'};
-    $ENV{'browser.type'}=$clientbrowser;
+    $env{'request.role'}='cm';
+    $env{'request.role.adv'}=$env{'user.adv'};
+    $env{'browser.type'}=$clientbrowser;
 # -------------------------------------------------------------------- Log this
 
     &Apache::lonnet::log($domain,$username,$authhost,
@@ -189,8 +182,8 @@
     my $bodytag=&Apache::loncommon::bodytag('Successful Login');
     my $add=&addcontent();
     my $continuelink;
-    if (($ENV{'browser.interface'} eq 'textual') ||
-        ($ENV{'environment.remote'} eq 'off')) {
+    if (($env{'browser.interface'} eq 'textual') ||
+        ($env{'environment.remote'} eq 'off')) {
 	$continuelink="<a href=\"$lowerurl\">".&mt('Continue')."</a>";
     }
 # ------------------------------------------------- Output for successful login
Index: loncom/auth/loncacc.pm
diff -u loncom/auth/loncacc.pm:1.37 loncom/auth/loncacc.pm:1.38
--- loncom/auth/loncacc.pm:1.37	Fri Oct 29 16:44:30 2004
+++ loncom/auth/loncacc.pm	Thu Apr  7 02:56:21 2005
@@ -2,7 +2,7 @@
 # Cookie Based Access Handler for Construction Area
 # (lonacc: 5/21/99,5/22,5/29,5/31 Gerd Kortemeyer)
 #
-# $Id: loncacc.pm,v 1.37 2004/10/29 20:44:30 raeburn Exp $
+# $Id: loncacc.pm,v 1.38 2005/04/07 06:56:21 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -26,14 +26,6 @@
 #
 # http://www.lon-capa.org/
 #
-# YEAR=2000
-# 6/15,16/11,22/11,
-# YEAR=2001
-# 01/06,01/11,6/1,9/25,9/28,11/22,12/25,12/26,
-# 01/06/01,05/04,05/05,05/09 Gerd Kortemeyer
-# YEAR=2002
-# 1/4 Gerd Kortemeyer
-###
 
 package Apache::loncacc;
 
@@ -43,7 +35,7 @@
 use CGI::Cookie();
 use Fcntl qw(:flock);
 use Apache::lonlocal;
-use Apache::lonnet();
+use Apache::lonnet;
 
 
 sub constructaccess {
@@ -53,9 +45,9 @@
     # We do not allow editing of previous versions of files.
     if ($url=~/\.(\d+)\.(\w+)$/) { return ''; }
     my @possibledomains = &Apache::lonnet::current_machine_domains();
-    if ($ownername eq $ENV{'user.name'}) {
+    if ($ownername eq $env{'user.name'}) {
 	foreach my $domain (@possibledomains) {
-	    if ($domain eq $ENV{'user.domain'}) {
+	    if ($domain eq $env{'user.domain'}) {
 		return ($ownername,$domain);
 	    }
 	}
@@ -63,7 +55,7 @@
     
     foreach my $domain (@possibledomains) {
 	my $capriv='user.priv.ca./'.$domain.'/'.$ownername.'./';
-	foreach (keys %ENV) {
+	foreach (keys %env) {
 	    if ($_ eq $capriv) {
 		return ($ownername,$domain);
 	    }
@@ -75,7 +67,7 @@
 sub handler {
     my $r = shift;
     my $requrl=$r->uri;
-    $ENV{'request.editurl'}=$requrl;
+    $env{'request.editurl'}=$requrl;
     my %cookies=CGI::Cookie->parse($r->header_in('Cookie'));
     my $lonid=$cookies{'lonID'};
     my $cookie;
@@ -95,8 +87,8 @@
 
 # -------------------------------------------------------------- Resource State
 
-            $ENV{'request.state'}    = "construct";
-            $ENV{'request.filename'} = $r->filename;
+            $env{'request.state'}    = "construct";
+            $env{'request.filename'} = $r->filename;
 
             unless (&constructaccess($requrl,$r->dir_config('lonDefDomain'))) {
                 $r->log_reason("Unauthorized $requrl", $r->filename); 
@@ -115,7 +107,7 @@
 
 # ----------------------------------------------- Store where they wanted to go
 
-    $ENV{'request.firsturl'}=$requrl;
+    $env{'request.firsturl'}=$requrl;
     return FORBIDDEN;
 }
 
Index: loncom/auth/londatecheck.pm
diff -u loncom/auth/londatecheck.pm:1.7 loncom/auth/londatecheck.pm:1.8
--- loncom/auth/londatecheck.pm:1.7	Mon Aug 23 15:34:00 2004
+++ loncom/auth/londatecheck.pm	Thu Apr  7 02:56:21 2005
@@ -1,5 +1,5 @@
 # Checks contentopen/close settings disable subsequent PerlHandlers if not open
-# $Id: londatecheck.pm,v 1.7 2004/08/23 19:34:00 albertel Exp $
+# $Id: londatecheck.pm,v 1.8 2005/04/07 06:56:21 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -26,12 +26,12 @@
 
 use strict;
 package Apache::londatecheck;
-use Apache::lonnet();
+use Apache::lonnet;
 use Apache::lonlocal;
 use Apache::Constants qw(:common :http :methods);
 
 sub content_date_check {
-    my $symb=$ENV{'request.symb'};
+    my $symb=$env{'request.symb'};
     my $open=&Apache::lonnet::EXT('resource.0.contentopen',$symb);
     my $close=&Apache::lonnet::EXT('resource.0.contentclose',$symb);
     if ( (defined($open)  && $open  ne '' && time < $open) ) {
Index: loncom/auth/lonlogin.pm
diff -u loncom/auth/lonlogin.pm:1.62 loncom/auth/lonlogin.pm:1.63
--- loncom/auth/lonlogin.pm:1.62	Thu Dec 30 11:04:37 2004
+++ loncom/auth/lonlogin.pm	Thu Apr  7 02:56:21 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Login Screen
 #
-# $Id: lonlogin.pm,v 1.62 2004/12/30 16:04:37 raeburn Exp $
+# $Id: lonlogin.pm,v 1.63 2005/04/07 06:56:21 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -32,7 +32,7 @@
 use Apache::Constants qw(:common);
 use CGI::Cookie();
 use Apache::File ();
-use Apache::lonnet();
+use Apache::lonnet;
 use Apache::loncommon();
 use Apache::lonauth();
 use Apache::lonlocal;
@@ -84,23 +84,23 @@
 # ---------------------------------------------------- No valid token, continue
 
     &Apache::loncommon::get_unprocessed_cgi
-     ($ENV{'QUERY_STRING'}.'&'.$ENV{'request.querystring'},
+     ($ENV{'QUERY_STRING'}.'&'.$env{'request.querystring'},
       ['interface','username','domain','firsturl','localpath','localres']);
  
 
 # ----------------------------------------------------------- Process Interface
-    $ENV{'form.interface'}=~s/\W//g;
+    $env{'form.interface'}=~s/\W//g;
 
     my $textbrowsers=$r->dir_config('lonTextBrowsers');
     my $httpbrowser=$ENV{"HTTP_USER_AGENT"};
     
     foreach (split(/\:/,$textbrowsers)) {
 	if ($httpbrowser=~/$_/i) {
-	    $ENV{'form.interface'}='textual';
+	    $env{'form.interface'}='textual';
         }
     }
 
-    my $fullgraph=($ENV{'form.interface'} ne 'textual');
+    my $fullgraph=($env{'form.interface'} ne 'textual');
     my $port_to_use=$r->dir_config('lonhttpdPort');
     if (!defined($port_to_use)) {
 	$port_to_use='8080';
@@ -108,9 +108,9 @@
     my $iconpath= 'http://'.$ENV{'HTTP_HOST'}.':'.$port_to_use.
                   $r->dir_config('lonIconsURL');
     my $domain  = $r->dir_config('lonDefDomain');
-    if (($ENV{'form.domain'}) && 
-	 ($Apache::lonnet::domaindescription{$ENV{'form.domain'}})) {
-	$domain=$ENV{'form.domain'};
+    if (($env{'form.domain'}) && 
+	 ($Apache::lonnet::domaindescription{$env{'form.domain'}})) {
+	$domain=$env{'form.domain'};
     }
     my $role    = $r->dir_config('lonRole');
     my $loadlim = $r->dir_config('lonLoadLim');
@@ -124,8 +124,8 @@
 
 # --------------------------------------------- Default values for login fields
 
-    my $authusername=($ENV{'form.username'}?$ENV{'form.username'}:'');
-    my $authdomain=($ENV{'form.domain'}?$ENV{'form.domain'}:$domain);
+    my $authusername=($env{'form.username'}?$env{'form.username'}:'');
+    my $authdomain=($env{'form.domain'}?$env{'form.domain'}:$domain);
 
 # ---------------------------------------------------------- Determine own load
     my $loadavg;
@@ -140,7 +140,7 @@
 # ------------------------------------------------------- Do the load balancing
     my $otherserver='http://'.$ENV{'SERVER_NAME'};
     my $firsturl=
-    ($ENV{'request.firsturl'}?$ENV{'request.firsturl'}:$ENV{'form.firsturl'});
+    ($env{'request.firsturl'}?$env{'request.firsturl'}:$env{'form.firsturl'});
 # ---------------------------------------- Are we access server and overloaded?
     if (($role eq 'access') &&
 	(($userloadpercent>100.0)||($loadpercent>100.0))) {
@@ -321,7 +321,7 @@
   <form name="server" action="$otherserver/adm/authenticate" method="post" target="_top">
    <input type="hidden" name="logtoken" value="$logtoken" />
    <input type="hidden" name="serverid" value="$lonhost" />
-   <input type="hidden" name="interface" value="$ENV{'form.interface'}" />
+   <input type="hidden" name="interface" value="$env{'form.interface'}" />
    <input type="hidden" name="uname" value="" />
    <input type="hidden" name="upass" value="" />
    <input type="hidden" name="udom" value="" />
@@ -331,8 +331,8 @@
    <input type="hidden" name="fontenhance"  value="" />
    <input type="hidden" name="blackwhite"  value="" />
    <input type="hidden" name="remember"  value="" />
-   <input type="hidden" name="localpath" value="$ENV{'form.localpath'}" />
-   <input type="hidden" name="localres" value="$ENV{'form.localres'}" />
+   <input type="hidden" name="localpath" value="$env{'form.localpath'}" />
+   <input type="hidden" name="localres" value="$env{'form.localres'}" />
   </form>
 ENDSERVERFORM
     if ($fullgraph) { $r->print(<<ENDTOP);
Index: loncom/auth/lonlogout.pm
diff -u loncom/auth/lonlogout.pm:1.13 loncom/auth/lonlogout.pm:1.14
--- loncom/auth/lonlogout.pm:1.13	Wed Jul 21 16:19:01 2004
+++ loncom/auth/lonlogout.pm	Thu Apr  7 02:56:21 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Logout Handler
 #
-# $Id: lonlogout.pm,v 1.13 2004/07/21 20:19:01 albertel Exp $
+# $Id: lonlogout.pm,v 1.14 2005/04/07 06:56:21 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -25,10 +25,6 @@
 #
 # http://www.lon-capa.org/
 #
-# (Cookie Based Access Handler
-# 5/21/99,5/22,5/29,5/31,6/15,16/11,22/11,
-# 01/06,01/13 Gerd Kortemeyer)
-# 05/31,11/29,12/29 Gerd Kortemeyer
 
 package Apache::lonlogout;
 
@@ -83,9 +79,9 @@
     my $switch='';
     my $bodytag='';
     my $relogmessage='';
-    if ($ENV{'form.handover'}) {
+    if ($env{'form.handover'}) {
        $switch='<meta HTTP-EQUIV="Refresh" CONTENT="0.5; url='.
-	   $ENV{'form.handover'}.'">';
+	   $env{'form.handover'}.'">';
        $bodytag=&Apache::loncommon::bodytag('Switching Server ...');
    } else {
        $bodytag=&Apache::loncommon::bodytag('Logged Out');
Index: loncom/auth/lonracc.pm
diff -u loncom/auth/lonracc.pm:1.16 loncom/auth/lonracc.pm:1.17
--- loncom/auth/lonracc.pm:1.16	Thu Feb 10 17:30:56 2005
+++ loncom/auth/lonracc.pm	Thu Apr  7 02:56:21 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Access Handler for File Transfers
 #
-# $Id: lonracc.pm,v 1.16 2005/02/10 22:30:56 albertel Exp $
+# $Id: lonracc.pm,v 1.17 2005/04/07 06:56:21 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -30,7 +30,7 @@
 
 use strict;
 use Apache::Constants qw(:common :remotehost);
-use Apache::lonnet();
+use Apache::lonnet;
 use Apache::File();
 use IO::Socket;
 
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.117 loncom/auth/lonroles.pm:1.118
--- loncom/auth/lonroles.pm:1.117	Thu Mar  3 02:32:49 2005
+++ loncom/auth/lonroles.pm	Thu Apr  7 02:56:21 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # User Roles Screen
 #
-# $Id: lonroles.pm,v 1.117 2005/03/03 07:32:49 albertel Exp $
+# $Id: lonroles.pm,v 1.118 2005/04/07 06:56:21 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -30,7 +30,7 @@
 package Apache::lonroles;
 
 use strict;
-use Apache::lonnet();
+use Apache::lonnet;
 use Apache::lonuserstate();
 use Apache::Constants qw(:common);
 use Apache::File();
@@ -80,29 +80,29 @@
     my $r = shift;
 
     my $now=time;
-    my $then=$ENV{'user.login.time'};
+    my $then=$env{'user.login.time'};
     my $envkey;
     my %dcroles = ();
     my $numdc = &check_fordc(\%dcroles,$then);
 
 # ================================================================== Roles Init
-    if ($ENV{'form.selectrole'}) {
-	if ($ENV{'request.course.id'}) {
-	    my %temp=('logout_'.$ENV{'request.course.id'} => time);
+    if ($env{'form.selectrole'}) {
+	if ($env{'request.course.id'}) {
+	    my %temp=('logout_'.$env{'request.course.id'} => time);
 	    &Apache::lonnet::put('email_status',\%temp);
-	    &Apache::lonnet::delenv('user.state.'.$ENV{'request.course.id'});
+	    &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'});
+                                "request.role.adv"    => $env{'user.adv'},
+				"request.role.domain" => $env{'user.domain'});
 
 # Check if user is a DC trying to enter a course and needs privs to be created
         if ($numdc > 0) {
-            foreach my $envkey (keys %ENV) {
+            foreach my $envkey (keys %env) {
                 if ($envkey =~ m-^form\.cc\./(\w+)/(\w+)$-) {
                     if ($dcroles{$1}) {
                         my $cckey = 'user.role.cc./'.$1.'/'.$2;
@@ -113,16 +113,16 @@
             }
         }
 
-        foreach $envkey (keys %ENV) {
+        foreach $envkey (keys %env) {
             next if ($envkey!~/^user\.role\./);
             my ($where,$trolecode,$role,$tstatus,$tend,$tstart);
             &role_status($envkey,$then,$now,\$role,\$where,\$trolecode,\$tstatus,\$tstart,\$tend);
-            if ($ENV{'form.'.$trolecode}) {
+            if ($env{'form.'.$trolecode}) {
 		if ($tstatus eq 'is') {
 		    $where=~s/^\///;
 		    my ($cdom,$cnum,$csec)=split(/\//,$where);
 # store role if recent_role list being kept
-                    if ($ENV{'environment.recentroles'}) {
+                    if ($env{'environment.recentroles'}) {
 			&Apache::lonhtmlcommon::store_recent('roles',
 							     $trolecode,' ');
                     }
@@ -130,20 +130,20 @@
 
 # check for keyed access
 		    if (($role eq 'st') && 
-                       ($ENV{'course.'.$cdom.'_'.$cnum.'.keyaccess'} eq 'yes')) {
+                       ($env{'course.'.$cdom.'_'.$cnum.'.keyaccess'} eq 'yes')) {
 # who is key authority?
 			my $authdom=$cdom;
 			my $authnum=$cnum;
-			if ($ENV{'course.'.$cdom.'_'.$cnum.'.keyauth'}) {
+			if ($env{'course.'.$cdom.'_'.$cnum.'.keyauth'}) {
 			    ($authnum,$authdom)=
-				split(/\W/,$ENV{'course.'.$cdom.'_'.$cnum.'.keyauth'});
+				split(/\W/,$env{'course.'.$cdom.'_'.$cnum.'.keyauth'});
 			}
 # check with key authority
 			unless (&Apache::lonnet::validate_access_key(
-				     $ENV{'environment.key.'.$cdom.'_'.$cnum},
+				     $env{'environment.key.'.$cdom.'_'.$cnum},
 					     $authdom,$authnum)) {
 # there is no valid key
-			     if ($ENV{'form.newkey'}) {
+			     if ($env{'form.newkey'}) {
 # student attempts to register a new key
 				 &Apache::loncommon::content_type($r,'text/html');
 				 &Apache::loncommon::no_cache($r);
@@ -155,11 +155,11 @@
 				 my $message=&mt('Successfully registered key');
 				 my $assignresult=
 				     &Apache::lonnet::assign_access_key(
-						     $ENV{'form.newkey'},
+						     $env{'form.newkey'},
 						     $authdom,$authnum,
 						     $cdom,$cnum,
-                                                     $ENV{'user.domain'},
-						     $ENV{'user.name'},
+                                                     $env{'user.domain'},
+						     $env{'user.name'},
 	      'Assigned from '.$ENV{'REMOTE_ADDR'}.' at '.localtime().' for '.
                                                      $trolecode);
 				 unless ($assignresult eq 'ok') {
@@ -205,7 +205,7 @@
 <form method="post">
 <input type="hidden" name="selectrole" value="1" />
 <input type="hidden" name="$trolecode" value="1" />
-<input type="text" size="20" name="newkey" value="$ENV{'form.newkey'}" />
+<input type="text" size="20" name="newkey" value="$env{'form.newkey'}" />
 <input type="submit" value="Enter key" />
 </form>
 </body></html>
@@ -214,9 +214,9 @@
 			     }
 			 }
 		     }
-		    &Apache::lonnet::log($ENV{'user.domain'},
-					 $ENV{'user.name'},
-					 $ENV{'user.home'},
+		    &Apache::lonnet::log($env{'user.domain'},
+					 $env{'user.name'},
+					 $env{'user.home'},
 					 "Role ".$trolecode);
 		    
 		    &Apache::lonnet::appenv(
@@ -229,9 +229,9 @@
 		    if (($cnum) && ($role ne 'ca')) {
 			my ($furl,$ferr)=
 			    &Apache::lonuserstate::readmap($cdom.'/'.$cnum);
-			if (($ENV{'form.orgurl'}) && 
-			    ($ENV{'form.orgurl'}!~/^\/adm\/flip/)) {
-			    my $dest=$ENV{'form.orgurl'};
+			if (($env{'form.orgurl'}) && 
+			    ($env{'form.orgurl'}!~/^\/adm\/flip/)) {
+			    my $dest=$env{'form.orgurl'};
 			    if ( &Apache::lonnet::mod_perl_version() == 2 ) {
 				&Apache::lonnet::cleanenv();
 			    }
@@ -240,7 +240,7 @@
 			    $r->internal_redirect($dest);
 			    return OK;
 			} else {
-			    unless ($ENV{'request.course.id'}) {
+			    unless ($env{'request.course.id'}) {
 				&Apache::lonnet::appenv(
 				      "request.course.id"  => $cdom.'_'.$cnum);
 				$furl='/adm/roles?tryagain=1';
@@ -259,14 +259,14 @@
 				$courseid = substr($courseid, 1);
 			    }
 			    $courseid =~ s/\//_/;
-			    if ($role eq 'cc' && $ENV{'course.' . $courseid . 
+			    if ($role eq 'cc' && $env{'course.' . $courseid . 
 							  '.course.helper.not.run'}) {
 				$furl = "/adm/helper/course.initialization.helper";
 			    }
                             # Send the user to the course they selected
                             &redirect_user($r,&mt('Entering Course'),
                                            $furl,$msg,
-					   $ENV{'environment.remotenavmap'});
+					   $env{'environment.remotenavmap'});
                             return OK;
 			}
 		    }
@@ -275,7 +275,7 @@
                     if ($role =~ /^(au|ca)$/) {
                         my $redirect_url = '/priv/';
                         if ($role eq 'au') {
-                            $redirect_url.=$ENV{'user.name'};
+                            $redirect_url.=$env{'user.name'};
                         } else {
                             $where =~ /\/(.*)$/;
                             $redirect_url .= $1;
@@ -322,17 +322,17 @@
 
 # ------------------------------------------ Get Error Message from Environment
 
-    my ($fn,$priv,$nochoose,$error,$msg)=split(/:/,$ENV{'user.error.msg'});
-    if ($ENV{'user.error.msg'}) {
+    my ($fn,$priv,$nochoose,$error,$msg)=split(/:/,$env{'user.error.msg'});
+    if ($env{'user.error.msg'}) {
 	$r->log_reason(
-   "$msg for $ENV{'user.name'} domain $ENV{'user.domain'} access $priv",$fn);
+   "$msg for $env{'user.name'} domain $env{'user.domain'} access $priv",$fn);
     }
 
 # ------------------------------------------------- Can this user re-init, etc?
 
-    my $advanced=$ENV{'user.adv'};
+    my $advanced=$env{'user.adv'};
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['tryagain']);
-    my $tryagain=$ENV{'form.tryagain'};
+    my $tryagain=$env{'form.tryagain'};
 
 # -------------------------------------------------------- Generate Page Output
 # --------------------------------------------------------------- Error Header?
@@ -343,7 +343,7 @@
         $r->print("Resource: ".&Apache::lonenc::check_encrypt($fn)."\n");
         $r->print("Action  : $msg\n</pre><hr>");
     } else {
-        if ($ENV{'user.error.msg'}) {
+        if ($env{'user.error.msg'}) {
 	    $r->print(
  '<h3><font color=red>'.
  &mt('You need to choose another user role or enter a specific course for this function').'</font></h3>');
@@ -356,7 +356,7 @@
         } else {
 	    $r->print("<h2>".&mt('Sorry ...')."</h2>\n".
 		      &mt('This resource might be part of'));
-	    if ($ENV{'request.course.id'}) {
+	    if ($env{'request.course.id'}) {
 		$r->print(&mt(' another'));
 	    } else {
 		$r->print(&mt(' a certain'));
@@ -368,7 +368,7 @@
         if ($advanced) {
 	    $r->print(&mt("Your home server is ").
 		      $Apache::lonnet::hostname{&Apache::lonnet::homeserver
-                      ($ENV{'user.name'},$ENV{'user.domain'})}.
+                      ($env{'user.name'},$env{'user.domain'})}.
 		      "<br />\n");
 	    $r->print(&mt(
       "Author and Co-Author roles may not be available on servers other than your home server."));
@@ -380,10 +380,10 @@
         $r->print('<input type="hidden" name="orgurl" value="'.$fn.'" />');
         $r->print('<input type="hidden" name="selectrole" value="1" />');
     }
-    if ($ENV{'user.adv'}) {
+    if ($env{'user.adv'}) {
 	$r->print(
 	      '<br /><label>'.&mt('Show all roles').': <input type="checkbox" name="showall"');
-	if ($ENV{'form.showall'}) { $r->print(' checked="checked" '); }
+	if ($env{'form.showall'}) { $r->print(' checked="checked" '); }
 	$r->print(' /></label><input type="submit" value="'.&mt('Display').'" />');
     }
 
@@ -391,7 +391,7 @@
     my $countactive=0;
     my $inrole=0;
     my $possiblerole='';
-    foreach $envkey (sort keys %ENV) {
+    foreach $envkey (sort keys %env) {
         my $button = 1;
         my $switchserver='';
 	my $roletext;
@@ -410,12 +410,12 @@
             if ($tend) {
                 $tpend=&Apache::lonlocal::locallocaltime($tend);
             }
-            if ($ENV{'request.role'} eq $trolecode) {
+            if ($env{'request.role'} eq $trolecode) {
 		$tstatus='selected';
             }
             my $tbg;
             if (($tstatus eq 'is') || ($tstatus eq 'selected') ||
-                ($ENV{'form.showall'})) {
+                ($env{'form.showall'})) {
                 if ($tstatus eq 'is') {
                     $tbg='#77FF77';
                     $tfont='#003300';
@@ -464,8 +464,8 @@
 			$button=0;
                         $switchserver=&Apache::lonnet::escape('http://'.
                          $Apache::lonnet::hostname{$home}.
-                         '/adm/login?domain='.$ENV{'user.domain'}.
-			  '&username='.$ENV{'user.name'}.
+                         '/adm/login?domain='.$env{'user.domain'}.
+			  '&username='.$env{'user.name'}.
                           '&firsturl=/priv/'.$trest.'/');
                     }
                     #next if ($home eq 'no_host');
@@ -474,13 +474,13 @@
                     $twhere=&mt('User').': '.$trest.'<br />'.&mt('Domain').
 			': '.$tdom.'<br />'.
                         ' '.&mt('Server').':&nbsp;'.$home;
-                    $ENV{'course.'.$tdom.'_'.$trest.'.description'}='ca';
+                    $env{'course.'.$tdom.'_'.$trest.'.description'}='ca';
 		    $tremark.=&Apache::lonhtmlcommon::authorbombs('/res/'.$tdom.'/'.$trest.'/');
 		    $sortkey=$role."$trest:$tdom";
                 } elsif ($role eq 'au') {
                     # Authors
                     my $home = &Apache::lonnet::homeserver
-                        ($ENV{'user.name'},$ENV{'user.domain'});
+                        ($env{'user.name'},$env{'user.domain'});
 		    my $allowed=0;
 		    my @ids=&Apache::lonnet::current_machine_ids();
 		    foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
@@ -488,17 +488,17 @@
 			$button=0;
                         $switchserver=&Apache::lonnet::escape('http://'.
                          $Apache::lonnet::hostname{$home}.
-                          '/adm/login?domain='.$ENV{'user.domain'}.
-			   '&username='.$ENV{'user.name'}.
-                           '&firsturl=/priv/'.$ENV{'user.name'}.'/');
+                          '/adm/login?domain='.$env{'user.domain'}.
+			   '&username='.$env{'user.name'}.
+                           '&firsturl=/priv/'.$env{'user.name'}.'/');
                     }
                     #next if ($home eq 'no_host');
                     $home = $Apache::lonnet::hostname{$home};
                     $ttype='Construction Space';
                     $twhere=&mt('Domain').': '.$tdom.'<br />'.&mt('Server').
 			':&nbsp;'.$home;
-                    $ENV{'course.'.$tdom.'_'.$trest.'.description'}='ca';
-		    $tremark.=&Apache::lonhtmlcommon::authorbombs('/res/'.$tdom.'/'.$ENV{'user.name'}.'/');
+                    $env{'course.'.$tdom.'_'.$trest.'.description'}='ca';
+		    $tremark.=&Apache::lonhtmlcommon::authorbombs('/res/'.$tdom.'/'.$env{'user.name'}.'/');
 		    $sortkey=$role;
                 } elsif ($trest) {
                     $ttype='Course';
@@ -506,8 +506,8 @@
                         $ttype.='<br>'.&mt('Section/Group').': '.$tsection;
 		    }
                     my $tcourseid=$tdom.'_'.$trest;
-                    if ($ENV{'course.'.$tcourseid.'.description'}) {
-                        $twhere=$ENV{'course.'.$tcourseid.'.description'};
+                    if ($env{'course.'.$tcourseid.'.description'}) {
+                        $twhere=$env{'course.'.$tcourseid.'.description'};
 			$sortkey=$role."\0".$tdom."\0".$twhere."\0".$envkey;
                         unless ($twhere eq &mt('Currently not available')) {
 			    $twhere.=' <font size="-2">'.
@@ -525,7 +525,7 @@
                               '</font>';
                         } else {
                             $twhere=&mt('Currently not available');
-                            $ENV{'course.'.$tcourseid.'.description'}=$twhere;
+                            $env{'course.'.$tcourseid.'.description'}=$twhere;
 			    $sortkey=$role."\0".$tdom."\0".$twhere."\0".$envkey;
                         }
                     }
@@ -558,7 +558,7 @@
 	$r->print('</form></body></html>');
 	return OK;
 # Is there only one choice?
-    } elsif (($countactive==1) && ($ENV{'request.role'} eq 'cm')) {
+    } elsif (($countactive==1) && ($env{'request.role'} eq 'cm')) {
 	$r->print('<h3>'.&mt('Please stand by.').'</h3>'.
 	    '<input type="hidden" name="'.$possiblerole.'" value="1" />');
 	$r->print("</form>\n");
@@ -588,9 +588,9 @@
 	if ($haverole) { $doheaders++; }
     }
 
-    if ($ENV{'environment.recentroles'}) {
+    if ($env{'environment.recentroles'}) {
         my %recent_roles =
-               &Apache::lonhtmlcommon::get_recent('roles',$ENV{'environment.recentrolesn'});
+               &Apache::lonhtmlcommon::get_recent('roles',$env{'environment.recentrolesn'});
 	my $output='';
 	foreach (sort(keys(%recent_roles))) {
 	    if (defined($roletext{'user.role.'.$_})) {
@@ -636,7 +636,7 @@
     }
     my $tremark='';
     my $tfont='#003300';
-    if ($ENV{'request.role'} eq 'cm') {
+    if ($env{'request.role'} eq 'cm') {
 	$r->print('<tr bgcolor="#11CC55">');
         $tremark=&mt('Currently selected. ');
         $tfont='#002200';
@@ -644,7 +644,7 @@
         $r->print('<tr bgcolor="#77FF77">');
     }
     unless ($nochoose) {
-	if ($ENV{'request.role'} ne 'cm') {
+	if ($env{'request.role'} ne 'cm') {
 	    $r->print('<td><input type=submit value="'.
 		      &mt('Select').'" name="cm"></td>');
 	} else {
@@ -660,24 +660,24 @@
 	$r->print("</form>\n");
     }
 # ------------------------------------------------------------ Privileges Info
-    if (($advanced) && (($ENV{'user.error.msg'}) || ($error))) {
+    if (($advanced) && (($env{'user.error.msg'}) || ($error))) {
 	$r->print('<hr><h2>Current Privileges</h2>');
 
-	foreach $envkey (sort keys %ENV) {
-	    if ($envkey=~/^user\.priv\.$ENV{'request.role'}\./) {
+	foreach $envkey (sort keys %env) {
+	    if ($envkey=~/^user\.priv\.$env{'request.role'}\./) {
 		my $where=$envkey;
-		$where=~s/^user\.priv\.$ENV{'request.role'}\.//;
+		$where=~s/^user\.priv\.$env{'request.role'}\.//;
 		my $ttype;
 		my $twhere;
 		my ($tdom,$trest,$tsec)=
 		    split(/\//,Apache::lonnet::declutter($where));
 		if ($trest) {
-		    if ($ENV{'course.'.$tdom.'_'.$trest.'.description'} eq 'ca') {
+		    if ($env{'course.'.$tdom.'_'.$trest.'.description'} eq 'ca') {
 			$ttype='Construction Space';
 			$twhere='User: '.$trest.', Domain: '.$tdom;
 		    } else {
 			$ttype='Course';
-			$twhere=$ENV{'course.'.$tdom.'_'.$trest.'.description'};
+			$twhere=$env{'course.'.$tdom.'_'.$trest.'.description'};
 			if ($tsec) {
 			    $twhere.=' (Section/Group: '.$tsec.')';
 			}
@@ -690,7 +690,7 @@
 		    $twhere='/';
 		}
 		$r->print("\n<h3>".$ttype.': '.$twhere.'</h3><ul>');
-		foreach (sort split(/:/,$ENV{$envkey})) {
+		foreach (sort split(/:/,$env{$envkey})) {
 		    if ($_) {
 			my ($prv,$restr)=split(/\&/,$_);
 			my $trestr='';
@@ -726,12 +726,12 @@
 sub role_status {
     my ($rolekey,$then,$now,$role,$where,$trolecode,$tstatus,$tstart,$tend) = @_;
     my @pwhere = ();
-    if (exists($ENV{$rolekey}) && $ENV{$rolekey} ne '') {
+    if (exists($env{$rolekey}) && $env{$rolekey} ne '') {
         (undef,undef,$$role,@pwhere)=split(/\./,$rolekey);
         unless (!defined($$role) || $$role eq '') {
             $$where=join('.',@pwhere);
             $$trolecode=$$role.'.'.$$where;
-            ($$tstart,$$tend)=split(/\./,$ENV{$rolekey});
+            ($$tstart,$$tend)=split(/\./,$env{$rolekey});
             $$tstatus='is';
             if ($$tstart && $$tstart>$then) {
 		$$tstatus='future';
@@ -791,7 +791,7 @@
 
 sub check_privs {
     my ($cckey,$then,$now) = @_;
-    if ($ENV{$cckey}) {
+    if ($env{$cckey}) {
         my ($role,$where,$trolecode,$tstart,$tend,$tremark,$tstatus,$tpstart,$tpend,$tfont);
         &role_status($cckey,$then,$now,\$role,\$where,\$trolecode,\$tstatus,\$tstart,\$tend);
         unless (($tstatus eq 'is') || ($tstatus eq 'will_not')) {
@@ -805,12 +805,12 @@
 sub check_fordc {
     my ($dcroles,$then) = @_;
     my $numdc = 0;
-    if ($ENV{'user.adv'}) {
-        foreach my $envkey (sort keys %ENV) {
+    if ($env{'user.adv'}) {
+        foreach my $envkey (sort keys %env) {
             if ($envkey=~/^user\.role\.dc\.\/(\w+)\/$/) {
                 my $dcdom = $1;
                 my $livedc = 1;
-                my ($tstart,$tend)=split(/\./,$ENV{$envkey});
+                my ($tstart,$tend)=split(/\./,$env{$envkey});
                 if ($tstart && $tstart>$then) { $livedc = 0; }
                 if ($tend   && $tend  <$then) { $livedc = 0; }
                 if ($livedc) {
@@ -907,8 +907,8 @@
 sub display_cc_role {
     my $rolekey = shift;
     my $roletext;
-    my $advanced = $ENV{'user.adv'};
-    my $tryagain = $ENV{'form.tryagain'};
+    my $advanced = $env{'user.adv'};
+    my $tryagain = $env{'form.tryagain'};
     unless ($rolekey =~/^error\:/) {
         if ($rolekey =~ m-^user\.role.cc\./(\w+)/(\w+)$-) {
             my $tcourseid = $1.'_'.$2;
@@ -925,7 +925,7 @@
                         '</font>';
             } else {
                 $twhere=&mt('Currently not available');
-                $ENV{'course.'.$tcourseid.'.description'}=$twhere;
+                $env{'course.'.$tcourseid.'.description'}=$twhere;
             }
             $twhere.="<br />".&mt('Domain').":".$1;
             $roletext = &build_roletext($trolecode,$1,$2,'is',$tryagain,$advanced,'',$tbg,$tfont,$trole,&mt('Course'),$twhere,'','','',1,'');
@@ -964,7 +964,7 @@
     my $area = '/'.$dcdom.'/'.$pickedcourse;
     my $role = 'cc';
     my $spec = $role.'.'.$area;
-    my $userroles = &Apache::lonnet::set_arearole($role,$area,'','',$dcdom,$ENV{'user.name'});
+    my $userroles = &Apache::lonnet::set_arearole($role,$area,'','',$dcdom,$env{'user.name'});
     my %ccrole = ();
     &Apache::lonnet::standard_roleprivs(\%ccrole,$role,$dcdom,$spec,$pickedcourse,$area);
     my ($author,$adv)= &Apache::lonnet::set_userprivs(\$userroles,\%ccrole);
@@ -975,9 +975,9 @@
         $newccroles{$key} = $val;
     }
     &Apache::lonnet::appenv(%newccroles);
-    &Apache::lonnet::log($ENV{'user.domain'},
-                         $ENV{'user.name'},
-                         $ENV{'user.home'},
+    &Apache::lonnet::log($env{'user.domain'},
+                         $env{'user.name'},
+                         $env{'user.home'},
                         "Role ".$role);
     &Apache::lonnet::appenv(
                           'request.role'        => $role,
Index: loncom/auth/lonuploadedacc.pm
diff -u loncom/auth/lonuploadedacc.pm:1.11 loncom/auth/lonuploadedacc.pm:1.12
--- loncom/auth/lonuploadedacc.pm:1.11	Tue Oct 26 11:03:08 2004
+++ loncom/auth/lonuploadedacc.pm	Thu Apr  7 02:56:21 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Access Handler for User Files
 #
-# $Id: lonuploadedacc.pm,v 1.11 2004/10/26 15:03:08 albertel Exp $
+# $Id: lonuploadedacc.pm,v 1.12 2005/04/07 06:56:21 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -44,7 +44,7 @@
 
 use strict;
 use Apache::Constants qw(:common :http);
-use Apache::lonnet();
+use Apache::lonnet;
 
 sub handler {
     my $r = shift;
@@ -52,17 +52,17 @@
     &Apache::loncommon::get_unprocessed_cgi($args,['token','tokenissued']); 
     my (undef,undef,$udom,$uname,$ufile)=split(/\//,$r->uri,5);
     $ufile=~s/^[\~\.]+//;
-    my $remoteserver=$ENV{'form.tokenissued'};
+    my $remoteserver=$env{'form.tokenissued'};
     my $reply=&Apache::lonnet::reply('tokenauthuserfile:'.
-                 $udom.'/'.$uname.'/'.$ufile.':'.$ENV{'form.token'},
+                 $udom.'/'.$uname.'/'.$ufile.':'.$env{'form.token'},
 				     $remoteserver);
     if ($reply eq 'ok') {
        return OK;
    } elsif ($reply eq 'con_lost' || $reply eq 'no_such_host') {
-       &Apache::lonnet::logthis("Server unavailable for userfile access $uname at $udom for $ufile with $remoteserver token $ENV{'form.token'}: $reply");
+       &Apache::lonnet::logthis("Server unavailable for userfile access $uname at $udom for $ufile with $remoteserver token $env{'form.token'}: $reply");
        return HTTP_SERVICE_UNAVAILABLE;
    } else {
-       &Apache::lonnet::logthis("Refused userfile access $uname at $udom for $ufile with $remoteserver token $ENV{'form.token'}: $reply");
+       &Apache::lonnet::logthis("Refused userfile access $uname at $udom for $ufile with $remoteserver token $env{'form.token'}: $reply");
        return FORBIDDEN;
    }
 }
Index: loncom/automation/Autocreate.pl
diff -u loncom/automation/Autocreate.pl:1.1 loncom/automation/Autocreate.pl:1.2
--- loncom/automation/Autocreate.pl:1.1	Fri Mar  4 10:09:06 2005
+++ loncom/automation/Autocreate.pl	Thu Apr  7 02:56:21 2005
@@ -67,8 +67,8 @@
     closedir(DIR);
     my %courseids = ();
     my $cccflag = 0;
-    unless ($ENV{'allowed.ccc'}) {
-        $ENV{'allowed.ccc'} = 'F';
+    unless ($env{'allowed.ccc'}) {
+        $env{'allowed.ccc'} = 'F';
         $cccflag = 1;
     }
     my $wwwid=getpwnam('www');
@@ -116,7 +116,7 @@
     }
 
     if ($cccflag) {
-        delete($ENV{'allowed.ccc'});
+        delete($env{'allowed.ccc'});
     }
     print $fh "-- ".localtime(time)." Autocreation messages end\n*******************\n\n";
     close($fh);
Index: loncom/cgi/barcode.png
diff -u loncom/cgi/barcode.png:1.11 loncom/cgi/barcode.png:1.12
--- loncom/cgi/barcode.png:1.11	Mon Feb  3 13:03:52 2003
+++ loncom/cgi/barcode.png	Thu Apr  7 02:56:21 2005
@@ -3,7 +3,7 @@
 # The LearningOnline Network with CAPA
 # barcode.png - A CGI script that dynamically outputs a barcode.
 #
-# $Id: barcode.png,v 1.11 2003/02/03 18:03:52 harris41 Exp $
+# $Id: barcode.png,v 1.12 2005/04/07 06:56:21 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -27,9 +27,6 @@
 #
 # http://www.lon-capa.org/
 #
-# YEAR=2001
-# 8/15,9/28,12/11
-#
 ###
 
 # I'm using format=Code39.
@@ -43,12 +40,13 @@
 use GD::Barcode::Code39;
 
 $|=1;   # Autoflush after each print/write
+my %env;
 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;
     if ($name eq 'encode') {
-	$ENV{'form.'.$name}=$value;
+	$env{'form.'.$name}=$value;
     }
 }
 
@@ -58,10 +56,10 @@
 
 END
 
-unless(defined($ENV{'form.encode'}) and length($ENV{'form.encode'})) {
-    $ENV{'form.encode'}='***ERROR***UNDEFINED***';
+unless(defined($env{'form.encode'}) and length($env{'form.encode'})) {
+    $env{'form.encode'}='***ERROR***UNDEFINED***';
 }
-my $text = '*'.uc($ENV{'form.encode'}).'*';
+my $text = '*'.uc($env{'form.encode'}).'*';
 my $oGdBar=GD::Barcode::Code39->new($text);
 if ($GD::Barcode::errStr or !defined($oGdBar)) {
     warn($GD::Barcode::errStr);
Index: loncom/cgi/decompress.pl
diff -u loncom/cgi/decompress.pl:1.12 loncom/cgi/decompress.pl:1.13
--- loncom/cgi/decompress.pl:1.12	Wed Jun  9 15:04:47 2004
+++ loncom/cgi/decompress.pl	Thu Apr  7 02:56:21 2005
@@ -31,8 +31,8 @@
 ####
 use strict;
 use lib '/home/httpd/lib/perl';
-use LONCAPA::loncgi ();
-my %origENV=%ENV;
+use LONCAPA::loncgi;
+
 if(! &LONCAPA::loncgi::check_cookie_and_load_env()) {
     print "Content-type: text/html\n\n";
     print <<END;
@@ -40,9 +40,8 @@
 END
 } else {
     print "Content-type: text/html\n\n";
-    my $file=$ENV{'cgi.file'};
-    my $dir=$ENV{'cgi.dir'}; 
-    %ENV=%origENV;
+    my $file=$env{'cgi.file'};
+    my $dir=$env{'cgi.dir'}; 
     if(! $file || ! $dir) {
         print <<END;
         <html><body>Bad Enviroment!</body></html>
Index: loncom/cgi/graph.png
diff -u loncom/cgi/graph.png:1.33 loncom/cgi/graph.png:1.34
--- loncom/cgi/graph.png:1.33	Thu Jan  8 10:50:17 2004
+++ loncom/cgi/graph.png	Thu Apr  7 02:56:21 2005
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 #
-# $Id: graph.png,v 1.33 2004/01/08 15:50:17 matthew Exp $
+# $Id: graph.png,v 1.34 2005/04/07 06:56:21 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -59,7 +59,7 @@
 use GD::Graph::lines;
 use GD::Graph::colour;
 use GD::Graph::Data;
-use LONCAPA::loncgi();
+use LONCAPA::loncgi;
 
 sub unescape {
     my $str=shift;
@@ -92,8 +92,8 @@
 # usage: &get_env($name,$default)
 sub get_env {
     my $key = 'cgi.'.$id.'.'.(shift());
-    return shift if (! exists($ENV{$key}));
-    return $ENV{$key};
+    return shift if (! exists($env{$key}));
+    return $env{$key};
 }
 
 if (! &LONCAPA::loncgi::check_cookie_and_load_env()) {
Index: loncom/cgi/loncgi.pm
diff -u loncom/cgi/loncgi.pm:1.2 loncom/cgi/loncgi.pm:1.3
--- loncom/cgi/loncgi.pm:1.2	Tue Apr  5 16:43:27 2005
+++ loncom/cgi/loncgi.pm	Thu Apr  7 02:56:21 2005
@@ -1,7 +1,7 @@
 #
 # LON-CAPA helpers for cgi-bin scripts
 #
-# $Id: loncgi.pm,v 1.2 2005/04/05 20:43:27 albertel Exp $
+# $Id: loncgi.pm,v 1.3 2005/04/07 06:56:21 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -81,7 +81,7 @@
 Inputs: none
 
 Returns: 1 if the user has a LON-CAPA cookie 0 if not.
-Loads the users environment into the %ENV hash if the cookie is correct.
+Loads the users environment into the %env hash if the cookie is correct.
 
 =cut
 
@@ -134,7 +134,7 @@
 
 =item transfer_profile_to_env
 
-Load the users environment into the %ENV hash.
+Load the users environment into the %env hash.
 
 Inputs: $handle, the name of the users LON-CAPA cookie.
 
Index: loncom/cgi/thumbnail.gif
diff -u loncom/cgi/thumbnail.gif:1.3 loncom/cgi/thumbnail.gif:1.4
--- loncom/cgi/thumbnail.gif:1.3	Mon Feb  3 13:03:52 2003
+++ loncom/cgi/thumbnail.gif	Thu Apr  7 02:56:21 2005
@@ -25,9 +25,6 @@
 #
 # http://www.lon-capa.org/
 #
-# YEAR=2001
-# 8/15,9/28,12/11
-#
 ###
 
 # Example usage: /cgi-bin/thumbnail.gif?url=...
@@ -56,18 +53,20 @@
   return $location;
 }
 
+my %env;
+
 $|=1;   # Autoflush after each print/write
 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;
     if ($name eq 'url') {
-	$ENV{'form.'.$name}=$value;
+	$env{'form.'.$name}=$value;
     }
 }
 
 
-my $ofn=&filelocation('',$ENV{'form.url'});
+my $ofn=&filelocation('',$env{'form.url'});
 my $fn=$ofn.'.thumbnail';
 
 my $exists=1;
Index: loncom/enrollment/Autoenroll.pl
diff -u loncom/enrollment/Autoenroll.pl:1.12 loncom/enrollment/Autoenroll.pl:1.13
--- loncom/enrollment/Autoenroll.pl:1.12	Sat Nov 27 12:23:09 2004
+++ loncom/enrollment/Autoenroll.pl	Thu Apr  7 02:56:21 2005
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 #
 #Automated Enrollment script
-# $Id: Autoenroll.pl,v 1.12 2004/11/27 17:23:09 raeburn Exp $
+# $Id: Autoenroll.pl,v 1.13 2005/04/07 06:56:21 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -48,7 +48,7 @@
     foreach my $dom (@domains) {
     #only run if configured to
         if (! &localenroll::run($dom)) { next; }
-        $ENV{'user.domain'} = $dom;
+        $env{'user.domain'} = $dom;
     # Determine the courses
         my %courses = &Apache::lonnet::courseiddump($dom,'.',1,'.','.',1,\@hostids); 
         my %affiliates = ();
@@ -136,10 +136,10 @@
                         if ($changecount > 0) {
                             unless ($enrollvar{$crs}{notifylist}  eq '') {
 # Send message about enrollment changes to notifylist.
-# Set $ENV{'user.name'}, $ENV{'user.home'} for use by logging in lonmsg
+# Set $env{'user.name'}, $env{'user.home'} for use by logging in lonmsg
                                 unless ( ($enrollvar{$crs}{'courseowner'} eq '') || (!defined($enrollvar{$crs}{'courseowner'}) )  ) {
-                                    $ENV{'user.name'} = $enrollvar{$crs}{'courseowner'};
-                                    $ENV{'user.home'} = &Apache::lonnet::homeserver($ENV{'user.name'},$dom);
+                                    $env{'user.name'} = $enrollvar{$crs}{'courseowner'};
+                                    $env{'user.home'} = &Apache::lonnet::homeserver($env{'user.name'},$dom);
 
                                     my $subject = "Student enrollment changes in $enrollvar{$crs}{coursecode}";
                                     my $message = "The following $changecount change(s) occurred in $enrollvar{$crs}{description} - $enrollvar{$crs}{coursecode} as a result of the automated classlist update:\n\n".$response;
@@ -158,10 +158,10 @@
                                     }
                                     if ( ($enrollvar{$crs}{notifylist} eq '') && ($newusermsg ne '') ) {
                                         my $subject = "New user accounts in  $enrollvar{$crs}{'coursecode'}";
-                                        my $status =  &Apache::lonmsg::user_normal_msg($ENV{'user.name'},$dom,$subject,$newusermsg);
+                                        my $status =  &Apache::lonmsg::user_normal_msg($env{'user.name'},$dom,$subject,$newusermsg);
                                     }
-                                    delete($ENV{'user.name'});
-                                    delete($ENV{'user.home'});
+                                    delete($env{'user.name'});
+                                    delete($env{'user.home'});
                                 }
                             }
                         }
@@ -181,7 +181,7 @@
         }
         print $fh "-- ".localtime(time)." Enrollment messages end\n*******************\n\n";
         close($fh);
-        delete($ENV{'user.domain'});
+        delete($env{'user.domain'});
 # Check for photos
     }
 
Index: loncom/enrollment/Enrollment.pm
diff -u loncom/enrollment/Enrollment.pm:1.21 loncom/enrollment/Enrollment.pm:1.22
--- loncom/enrollment/Enrollment.pm:1.21	Sat Jan 29 20:07:35 2005
+++ loncom/enrollment/Enrollment.pm	Thu Apr  7 02:56:21 2005
@@ -1,5 +1,5 @@
 # Automated Enrollment manager
-# $Id: Enrollment.pm,v 1.21 2005/01/30 01:07:35 raeburn Exp $
+# $Id: Enrollment.pm,v 1.22 2005/04/07 06:56:21 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -194,7 +194,7 @@
     }
 # Explicitly allow access to creation/modification of students if called as an automated process.
     if ($context eq 'automated') {
-        $ENV{'allowed.cst'}='F';
+        $env{'allowed.cst'}='F';
     }
 
 # Compare IDs with existing LON-CAPA enrollment for this class
@@ -355,7 +355,7 @@
 
 # Terminated explictly allowed access to student creation/modification
     if ($context eq 'automated') {
-        delete($ENV{'allowed.cst'});
+        delete($env{'allowed.cst'});
     }
     if ($enrollcount > 0) {
         if ($context eq "updatenow") {
Index: loncom/homework/bridgetask.pm
diff -u loncom/homework/bridgetask.pm:1.10 loncom/homework/bridgetask.pm:1.11
--- loncom/homework/bridgetask.pm:1.10	Tue Apr  5 11:39:41 2005
+++ loncom/homework/bridgetask.pm	Thu Apr  7 02:56:21 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # definition of tags that give a structure to a document
 #
-# $Id: bridgetask.pm,v 1.10 2005/04/05 15:39:41 albertel Exp $
+# $Id: bridgetask.pm,v 1.11 2005/04/07 06:56:21 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -56,14 +56,14 @@
 
 sub proctor_check_auth {
     my ($slot)=@_;
-    my $user=$ENV{'form.proctorname'};
-    my $domain=$ENV{'form.proctordomain'};
+    my $user=$env{'form.proctorname'};
+    my $domain=$env{'form.proctordomain'};
     
     my @allowed=split(",",$slot->{'proctor'});
     foreach my $possible (@allowed) {
 	my ($puser,$pdom)=(split('@',$possible));
 	if ($puser eq $user && $pdom eq $domain) {
-	    my $authhost=&Apache::lonnet::authenticate($puser,$ENV{'form.proctorpassword'},$pdom);
+	    my $authhost=&Apache::lonnet::authenticate($puser,$env{'form.proctorpassword'},$pdom);
 	    if ($authhost ne 'no_host') {
 		$Apache::lonhomework::results{'resource.checkedin'}=
 		    $user.'@'.$domain;
@@ -152,10 +152,10 @@
               $body_tag_start \n $form_tag_start".	
 	      '<input type="hidden" name="submitted" value="yes" />';
 	    # if we are viewing someone else preserve that info
-	    if (defined $ENV{'form.grade_symb'}) {
+	    if (defined $env{'form.grade_symb'}) {
 		foreach my $field ('symb','courseid','domain','username') {
 		    $result .= '<input type="hidden" name="grade_'.$field.
-			'" value="'.$ENV{"form.grade_$field"}.'" />'."\n";
+			'" value="'.$env{"form.grade_$field"}.'" />'."\n";
 		}
 	    }
 	}
@@ -173,7 +173,7 @@
     if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' ||
 	$target eq 'tex') {
 	if (
-	    (($target eq 'web') && ($ENV{'request.state'} ne 'construct')) ||
+	    (($target eq 'web') && ($env{'request.state'} ne 'construct')) ||
 	    ($target eq 'answer') || ($target eq 'tex')
 	   ) {
 	    if ($target eq 'web') {
@@ -327,10 +327,10 @@
     my ($slot) = @_;
     my (undef,undef,$domain,$user) = &Apache::lonxml::whichuser();
     my $url=&Apache::lonnet::studentphoto($domain,$user,'jpg');
-    $user=$ENV{'form.proctorname'};
-    if ($ENV{'form.proctordomain'}) { $domain=$ENV{'form.proctordomain'}; }
+    $user=$env{'form.proctorname'};
+    if ($env{'form.proctordomain'}) { $domain=$env{'form.proctordomain'}; }
     my $msg;
-    if ($ENV{'form.proctorpassword'}) {
+    if ($env{'form.proctorpassword'}) {
 	$msg='<p><font color="red">'.&mt("Failed to authenticate the proctor.")
 	    .'</font></p>';
     }
@@ -338,7 +338,7 @@
 <h2>Proctor Validation</h2>
     <p>Your room's proctor needs to validate your access to this resource.</p>
     $msg
-<form name="checkout" method="POST" action="$ENV{'request.uri'}">
+<form name="checkout" method="POST" action="$env{'request.uri'}">
 <input type="hidden" name="validate" value="yes" />
 <input type="hidden" name="submitted" value="yes" />
 <table>
Index: loncom/homework/chemresponse.pm
diff -u loncom/homework/chemresponse.pm:1.49 loncom/homework/chemresponse.pm:1.50
--- loncom/homework/chemresponse.pm:1.49	Tue Feb 22 16:33:27 2005
+++ loncom/homework/chemresponse.pm	Thu Apr  7 02:56:21 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # chemical equation style response
 #
-# $Id: chemresponse.pm,v 1.49 2005/02/22 21:33:27 albertel Exp $
+# $Id: chemresponse.pm,v 1.50 2005/04/07 06:56:21 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -235,7 +235,7 @@
 	    }
 	    &Apache::response::handle_previous(\%previous,$ad);
 	    $Apache::lonhomework::results{"resource.$partid.$id.awarddetail"}=$ad;
-	    $Apache::lonhomework::results{"resource.$partid.$id.molecule"}=$ENV{"form.MOLECULE_$id"};
+	    $Apache::lonhomework::results{"resource.$partid.$id.molecule"}=$env{"form.MOLECULE_$id"};
 	}
     } elsif ($target eq "edit") {
 	$result.= &Apache::edit::tag_end($target,$token,'');
@@ -272,7 +272,7 @@
 	if (!$texwidth) { $texwidth='90'; }
 	my $molecule=&Apache::lonxml::get_param('molecule',$parstack,$safeeval);
 	my $options=&Apache::lonxml::get_param('options',$parstack,$safeeval);
-	my $filename = $ENV{'user.name'}.'_'.$ENV{'user.domain'}.
+	my $filename = $env{'user.name'}.'_'.$env{'user.domain'}.
 	    '_'.time.'_'.$$.int(rand(1000)).'_organicstructure';
 	my $id=$filename;
 	&Apache::lonnet::appenv(
Index: loncom/homework/convertjme.pl
diff -u loncom/homework/convertjme.pl:1.13 loncom/homework/convertjme.pl:1.14
--- loncom/homework/convertjme.pl:1.13	Wed Feb  9 16:50:06 2005
+++ loncom/homework/convertjme.pl	Thu Apr  7 02:56:21 2005
@@ -2,7 +2,7 @@
 # The LearningOnline Network with CAPA
 # Dynamically converts JME strings into either a png or ps file.
 #
-# $Id: convertjme.pl,v 1.13 2005/02/09 21:50:06 albertel Exp $
+# $Id: convertjme.pl,v 1.14 2005/04/07 06:56:21 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -34,7 +34,7 @@
 ### For standalone operation, set $loncapa to 0, and comment out both uses
 my $loncapa=1;
 use lib '/home/httpd/lib/perl';
-use LONCAPA::loncgi();
+use LONCAPA::loncgi;
 
 
 use GD;
@@ -66,11 +66,11 @@
 my ($id,$width,$ps,$png,@JMEstring);
 if ($loncapa) {
     $id=$ENV{'QUERY_STRING'};
-    $width = $ENV{'cgi.'.$id.'.WIDTH'};
+    $width = $env{'cgi.'.$id.'.WIDTH'};
     if (!$width) { $width = 400; }
-    $png = $ENV{'cgi.'.$id.'.PNG'};
-    $ps = $ENV{'cgi.'.$id.'.PS'};
-    @JMEstring=&unescape($ENV{'cgi.'.$id.'.JME'});
+    $png = $env{'cgi.'.$id.'.PNG'};
+    $ps = $env{'cgi.'.$id.'.PS'};
+    @JMEstring=&unescape($env{'cgi.'.$id.'.JME'});
 } else {
     @JMEstring = @ARGV;
     $width = shift @JMEstring;
Index: loncom/homework/edit.pm
diff -u loncom/homework/edit.pm:1.91 loncom/homework/edit.pm:1.92
--- loncom/homework/edit.pm:1.91	Thu Mar 17 08:56:32 2005
+++ loncom/homework/edit.pm	Thu Apr  7 02:56:21 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # edit mode helpers
 #
-# $Id: edit.pm,v 1.91 2005/03/17 13:56:32 albertel Exp $
+# $Id: edit.pm,v 1.92 2005/04/07 06:56:21 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -29,7 +29,7 @@
 package Apache::edit; 
 
 use strict;
-use Apache::lonnet();
+use Apache::lonnet;
 use HTML::Entities();
 use Apache::lonlocal;
 
@@ -147,7 +147,7 @@
 }
 
 sub handle_delete {
-    if (!$ENV{"form.delete_$Apache::lonxml::curdepth"}) { return ''; }
+    if (!$env{"form.delete_$Apache::lonxml::curdepth"}) { return ''; }
     my ($space,$target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
     my $result=0;
     if ($space) {
@@ -222,9 +222,9 @@
 }
 
 sub handle_insert {
-    if ($ENV{"form.insert_$Apache::lonxml::curdepth"} eq '') { return ''; }
+    if ($env{"form.insert_$Apache::lonxml::curdepth"} eq '') { return ''; }
     my $result;
-    my $tagnum = $ENV{"form.insert_$Apache::lonxml::curdepth"};
+    my $tagnum = $env{"form.insert_$Apache::lonxml::curdepth"};
     my $func=$Apache::lonxml::insertlist{"$tagnum.function"};
     if ($func eq 'default') {
 	my $newtag=$Apache::lonxml::insertlist{"$tagnum.tag"};
@@ -247,10 +247,10 @@
 
 sub handle_insertafter {
     my $tagname=shift;
-    if ($ENV{"form.insert_after_$tagname\_$Apache::lonxml::curdepth"} eq '')
+    if ($env{"form.insert_after_$tagname\_$Apache::lonxml::curdepth"} eq '')
     { return ''; }
     my $result;
-    my $tagnum =$ENV{"form.insert_after_$tagname\_$Apache::lonxml::curdepth"};
+    my $tagnum =$env{"form.insert_after_$tagname\_$Apache::lonxml::curdepth"};
     my $func=$Apache::lonxml::insertlist{"$tagnum.function"};
     if ($func eq 'default') {
 	my $newtag=$Apache::lonxml::insertlist{"$tagnum.tag"};
@@ -532,12 +532,12 @@
 sub modifiedfield {
     my ($endtag,$parser) = @_;
     my $result;
-#  foreach my $envkey (sort keys %ENV) {
-#    &Apache::lonxml::debug("$envkey ---- $ENV{$envkey}");
+#  foreach my $envkey (sort keys %env) {
+#    &Apache::lonxml::debug("$envkey ---- $env{$envkey}");
 #  }
 #  &Apache::lonxml::debug("I want homework_edit_$Apache::lonxml::curdepth");
-#  &Apache::lonxml::debug($ENV{"form.homework_edit_$Apache::lonxml::curdepth"});
-    $result=$ENV{"form.homework_edit_$Apache::lonxml::curdepth"};
+#  &Apache::lonxml::debug($env{"form.homework_edit_$Apache::lonxml::curdepth"});
+    $result=$env{"form.homework_edit_$Apache::lonxml::curdepth"};
     my $bodytext=&Apache::lonxml::get_all_text($endtag,$parser);
     # textareas throw away intial \n 
     if ($bodytext=~/^\n/) { $result="\n".$result; }
@@ -553,7 +553,7 @@
 	#just want the string that it was set to
 	my $value=$token->[2]->{$arg};
 	my $element=&html_element_name($arg);
-	my $newvalue=$ENV{"form.$element"};
+	my $newvalue=$env{"form.$element"};
 	&Apache::lonxml::debug("for:$arg: cur is :$value: new is :$newvalue:");
 	if (defined($newvalue) && $value ne $newvalue) {
 	    if (ref($newvalue) eq 'ARRAY') {
Index: loncom/homework/essayresponse.pm
diff -u loncom/homework/essayresponse.pm:1.61 loncom/homework/essayresponse.pm:1.62
--- loncom/homework/essayresponse.pm:1.61	Tue Apr  5 11:38:57 2005
+++ loncom/homework/essayresponse.pm	Thu Apr  7 02:56:21 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # essay (ungraded) style responses
 #
-# $Id: essayresponse.pm,v 1.61 2005/04/05 15:38:57 albertel Exp $
+# $Id: essayresponse.pm,v 1.62 2005/04/07 06:56:21 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -29,7 +29,7 @@
 package Apache::essayresponse;
 use strict;
 use Apache::lonxml();
-use Apache::lonnet();
+use Apache::lonnet;
 use Apache::lonlocal;
 
 BEGIN {
@@ -59,7 +59,7 @@
 	    $result .='<tr><td>'.
 		'Collaborators: <input type="text" size="70" max="80" name="HWCOL'.
 		$part.'_'.$id.'" value="'.$coll.'" /><br />'.
-		&mt('(Enter maximum [_1] collaborators using username or username@domain, e.g. smithje or smithje@[_2].)',$ncol,$ENV{'user.domain'}).'<br />';
+		&mt('(Enter maximum [_1] collaborators using username or username@domain, e.g. smithje or smithje@[_2].)',$ncol,$env{'user.domain'}).'<br />';
 	    $result .= &check_collaborators($ncol,$coll) if ($coll =~ /\w+/);
 	    $result .='</td></tr>';
 	}
@@ -77,7 +77,7 @@
     my $increment     = 1;
     my $result;
     if ( $target eq 'grade' ) {
-	my $collaborators = $ENV{'form.HWCOL'.$part.'_'.$id};	
+	my $collaborators = $env{'form.HWCOL'.$part.'_'.$id};	
 	if ($collaborators =~ /[^\s]/) {
 	    my $previous_list= &HTML::Entities::encode($Apache::lonhomework::history{"resource.$part.$id.collaborators"},'<>&"');
 	    $Apache::lonhomework::results{"resource.$part.$id.collaborators"}=$collaborators
@@ -86,12 +86,12 @@
 	if (  &Apache::response::submitted('scantron') ) {
 	    $increment=&Apache::response::scored_response($part,$id);
 	} elsif ( &Apache::response::submitted() ) {
-	    my $response      = $ENV{'form.HWVAL_'.$id};
-            my $filename= $ENV{'form.HWFILE'.$part.'_'.$id.'.filename'};
-            my $portfiles = $ENV{'form.HWPORT'.$part.'_'.$id};
+	    my $response      = $env{'form.HWVAL_'.$id};
+            my $filename= $env{'form.HWFILE'.$part.'_'.$id.'.filename'};
+            my $portfiles = $env{'form.HWPORT'.$part.'_'.$id};
 	    if (( $response =~ /[^\s]/) || ($filename =~ /[^\s]/) || ($portfiles =~ /[^\s]/)) {
  		my $award='DRAFT';
-        	if ($ENV{'form.HWDRAFT'.$part.'_'.$id} eq 'yes') {
+        	if ($env{'form.HWDRAFT'.$part.'_'.$id} eq 'yes') {
 		    $award='SUBMITTED';
 		}
                 my $uploadedflag=0;
@@ -127,7 +127,7 @@
 	if ($Apache::lonhomework::type eq 'exam') {
 	    my $repetition=&Apache::response::repetition();
 	    $result.='\begin{enumerate}';
-	    if ($ENV{'request.state'} eq "construct" ) {$result.='\item[\strut]';}
+	    if ($env{'request.state'} eq "construct" ) {$result.='\item[\strut]';}
 	    for (my $i=0;$i<$repetition;$i++) {
 		$result.='\item[\textbf{'.($Apache::lonxml::counter+$i).
 		    '}.]\textit{'.&mt('Leave blank on scoring form').
@@ -149,9 +149,9 @@
 sub file_submission {
     my ($part,$id,$which,$award,$uploadedflag)=@_;
     my $files;
-    if ($which eq 'portfiles') { $files= $ENV{'form.HWPORT'.$part.'_'.$id}; }
+    if ($which eq 'portfiles') { $files= $env{'form.HWPORT'.$part.'_'.$id}; }
     if ($which eq 'filename') {
-	$files = $ENV{'form.HWFILE'.$part.'_'.$id.'.filename'};
+	$files = $env{'form.HWFILE'.$part.'_'.$id.'.filename'};
     }
     
     if ($files =~ /[^\s]/) {
@@ -194,8 +194,8 @@
 sub check_collaborators {
     my ($ncol,$coll) = @_;
     my %classlist=&Apache::lonnet::dump('classlist',
-					$ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
-					$ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+					$env{'course.'.$env{'request.course.id'}.'.domain'},
+					$env{'course.'.$env{'request.course.id'}.'.num'});
     my (@badcollaborators,$result);
     my (@collaborators) = split(/\,?\s+/,$coll);
     foreach (@collaborators) {
@@ -203,7 +203,7 @@
 	if (/@/) {
 	    $collaborator =~ s/@/:/;
 	} else {
-	    $collaborator = $_.':'.$ENV{'user.domain'};
+	    $collaborator = $_.':'.$env{'user.domain'};
 	}
 	push @badcollaborators, $_ if (!grep /^$collaborator/i,keys %classlist);
     }
Index: loncom/homework/externalresponse.pm
diff -u loncom/homework/externalresponse.pm:1.3 loncom/homework/externalresponse.pm:1.4
--- loncom/homework/externalresponse.pm:1.3	Mon Apr  7 22:40:56 2003
+++ loncom/homework/externalresponse.pm	Thu Apr  7 02:56:21 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # external style responses
 #
-# $Id: externalresponse.pm,v 1.3 2003/04/08 02:40:56 albertel Exp $
+# $Id: externalresponse.pm,v 1.4 2005/04/07 06:56:21 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -30,6 +30,7 @@
 use strict;
 use HTTP::Request::Common;
 use Apache::loncapagrade;
+use Apache::lonnet;
 
 BEGIN {
   &Apache::lonxml::register('Apache::externalresponse',('externalresponse'));
@@ -50,9 +51,9 @@
   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
   my $result;
   if ($target eq 'grade') {
-    if ( defined $ENV{'form.submitted'}) {
+    if ( defined $env{'form.submitted'}) {
       my $id = $Apache::inputtags::response['-1'];
-      my $response = $ENV{'form.HWVAL_'.$id};
+      my $response = $env{'form.HWVAL_'.$id};
       if ( $response =~ /[^\s]/) {
 	my $url = &Apache::lonxml::get_param('url',$parstack,$safeeval);
 	my $answer = &Apache::lonxml::get_param('answer',$parstack,$safeeval);
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.256 loncom/homework/grades.pm:1.257
--- loncom/homework/grades.pm:1.256	Mon Apr  4 19:56:44 2005
+++ loncom/homework/grades.pm	Thu Apr  7 02:56:21 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.256 2005/04/04 23:56:44 banghart Exp $
+# $Id: grades.pm,v 1.257 2005/04/07 06:56:21 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -80,8 +80,8 @@
 # --- Get the symbolic name of a problem and the url
 sub get_symb_and_url {
     my ($request,$silent) = @_;
-    (my $url=$ENV{'form.url'}) =~ s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;
-    my $symb=($ENV{'form.symb'} ne '' ? $ENV{'form.symb'} : (&Apache::lonnet::symbread($url)));
+    (my $url=$env{'form.url'}) =~ s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;
+    my $symb=($env{'form.symb'} ne '' ? $env{'form.symb'} : (&Apache::lonnet::symbread($url)));
     if ($symb eq '') { 
 	if (!$silent) {
 	    $request->print("Unable to handle ambiguous references:$url:.");
@@ -99,7 +99,7 @@
 	return '<b>&nbsp;Fullname&nbsp;</b><font color="#999999">(Username)</font>';
     } else {
 	return '&nbsp;'.$fullname.'<font color="#999999">&nbsp;('.$uname.
-	    ($ENV{'user.domain'} eq $udom ? '' : ' ('.$udom.')').')</font>';
+	    ($env{'user.domain'} eq $udom ? '' : ' ('.$udom.')').')</font>';
     }
 }
 
@@ -107,7 +107,7 @@
 #--- Indicate if a response type is coded handgraded or not. ---
 sub response_type {
     my ($url,$symb) = shift;
-    $symb=($ENV{'form.symb'} ne '' ? $ENV{'form.symb'} : (&Apache::lonnet::symbread($url))) if ($symb eq '');
+    $symb=($env{'form.symb'} ne '' ? $env{'form.symb'} : (&Apache::lonnet::symbread($url))) if ($symb eq '');
     my $allkeys = &Apache::lonnet::metadata($url,'keys');
     my %vPart;
     foreach my $partid (&Apache::loncommon::get_env_multiple('form.vPart')) {
@@ -141,7 +141,7 @@
 sub get_display_part {
     my ($partID,$url,$symb)=@_;
     if (!defined($symb) || $symb eq '') {
-	$symb=$ENV{'form.symb'};
+	$symb=$env{'form.symb'};
 	if ($symb eq '') { $symb=&Apache::lonnet::symbread($url) }
     }
     my $display=&Apache::lonnet::EXT('resource.'.$partID.'.display',$symb);
@@ -199,7 +199,7 @@
 				       ('grade_domain' => $udom),
 				       ('grade_symb' => $symb),
 				       ('grade_courseid' => 
-					        $ENV{'request.course.id'}),
+					        $env{'request.course.id'}),
 				       ('grade_username' => $uname));
     (undef,$subresult)=split(/_HASH_REF__/,$subresult,2);
     my %analyze=&Apache::lonnet::str2hash($subresult);
@@ -270,17 +270,17 @@
 	    '<tr valign="top"><td>'.$grayFont.'Option ID</font></td>'.
 	    $grayFont.$bottomrow.'</tr>'.'</table></blockquote>';
     } elsif ($response eq 'essay') {
-	if (! exists ($ENV{'form.'.$symb})) {
+	if (! exists ($env{'form.'.$symb})) {
 	    my (%keyhash) = &Apache::lonnet::dump('nohist_handgrade',
-						  $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
-						  $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+						  $env{'course.'.$env{'request.course.id'}.'.domain'},
+						  $env{'course.'.$env{'request.course.id'}.'.num'});
 
-	    my $loginuser = $ENV{'user.name'}.':'.$ENV{'user.domain'};
-	    $ENV{'form.keywords'} = $keyhash{$symb.'_keywords'} ne '' ? $keyhash{$symb.'_keywords'} : '';
-	    $ENV{'form.kwclr'}    = $keyhash{$loginuser.'_kwclr'} ne '' ? $keyhash{$loginuser.'_kwclr'} : 'red';
-	    $ENV{'form.kwsize'}   = $keyhash{$loginuser.'_kwsize'} ne '' ? $keyhash{$loginuser.'_kwsize'} : '0';
-	    $ENV{'form.kwstyle'}  = $keyhash{$loginuser.'_kwstyle'} ne '' ? $keyhash{$loginuser.'_kwstyle'} : '';
-	    $ENV{'form.'.$symb} = 1; # so that we don't have to read it from disk for multiple sub of the same prob.
+	    my $loginuser = $env{'user.name'}.':'.$env{'user.domain'};
+	    $env{'form.keywords'} = $keyhash{$symb.'_keywords'} ne '' ? $keyhash{$symb.'_keywords'} : '';
+	    $env{'form.kwclr'}    = $keyhash{$loginuser.'_kwclr'} ne '' ? $keyhash{$loginuser.'_kwclr'} : 'red';
+	    $env{'form.kwsize'}   = $keyhash{$loginuser.'_kwsize'} ne '' ? $keyhash{$loginuser.'_kwsize'} : '0';
+	    $env{'form.kwstyle'}  = $keyhash{$loginuser.'_kwstyle'} ne '' ? $keyhash{$loginuser.'_kwstyle'} : '';
+	    $env{'form.'.$symb} = 1; # so that we don't have to read it from disk for multiple sub of the same prob.
 	}
 	$answer =~ s-\n-<br />-g;
 	return '<br /><br /><blockquote><tt>'.&keywords_highlight($answer).'</tt></blockquote>';
@@ -349,8 +349,8 @@
         my $status   = 
             $classlist->{$student}->[&Apache::loncoursedata::CL_STATUS()];
 	# filter students according to status selected
-	if ($filterlist && $ENV{'form.Status'} ne 'Any') {
-	    if ($ENV{'form.Status'} ne $status) {
+	if ($filterlist && $env{'form.Status'} ne 'Any') {
+	    if ($env{'form.Status'} ne $status) {
 		delete ($classlist->{$student});
 		next;
 	    }
@@ -415,7 +415,7 @@
 #--- Retrieve the grade status of a student for all the parts
 sub student_gradeStatus {
     my ($url,$symb,$udom,$uname,$partlist) = @_;
-    my %record     = &Apache::lonnet::restore($symb,$ENV{'request.course.id'},$udom,$uname);
+    my %record     = &Apache::lonnet::restore($symb,$env{'request.course.id'},$udom,$uname);
     my %partstatus = ();
     foreach (@$partlist) {
 	my ($status,undef)   = split(/_/,$record{"resource.$_.solved"},2);
@@ -442,9 +442,9 @@
     $jscript.= '<form action="/adm/grades" method="post" name="onestudent">'."\n".
 	'<input type="hidden" name="symb"    value="'.$symb.'" />'."\n".
 	'<input type="hidden" name="url"     value="'.$url.'" />'."\n".
-	'<input type="hidden" name="saveState" value="'.$ENV{'form.saveState'}.'" />'."\n".
-	'<input type="hidden" name="probTitle" value="'.$ENV{'form.probTitle'}.'" />'."\n".
-	'<input type="hidden" name="Status"  value="'.$ENV{'form.Status'}.'" />'."\n".
+	'<input type="hidden" name="saveState" value="'.$env{'form.saveState'}.'" />'."\n".
+	'<input type="hidden" name="probTitle" value="'.$env{'form.probTitle'}.'" />'."\n".
+	'<input type="hidden" name="Status"  value="'.$env{'form.Status'}.'" />'."\n".
 	'<input type="hidden" name="command" value="submission" />'."\n".
 	'<input type="hidden" name="student" value="" />'."\n".
 	'<input type="hidden" name="userdom" value="" />'."\n".
@@ -505,25 +505,25 @@
 sub verifyreceipt {
     my $request  = shift;
 
-    my $courseid = $ENV{'request.course.id'};
+    my $courseid = $env{'request.course.id'};
     my $receipt  = &Apache::lonnet::recprefix($courseid).'-'.
-	$ENV{'form.receipt'};
+	$env{'form.receipt'};
     $receipt     =~ s/[^\-\d]//g;
-    my $url      = $ENV{'form.url'};
-    my $symb     = $ENV{'form.symb'};
+    my $url      = $env{'form.url'};
+    my $symb     = $env{'form.symb'};
     unless ($symb) {
 	$symb    = &Apache::lonnet::symbread($url);
     }
 
     my $title.='<h3><font color="#339933">Verifying Submission Receipt '.
 	$receipt.'</h3></font>'."\n".
-	'<font size=+1><b>Resource: </b>'.$ENV{'form.probTitle'}.'</font><br><br>'."\n";
+	'<font size=+1><b>Resource: </b>'.$env{'form.probTitle'}.'</font><br><br>'."\n";
 
     my ($string,$contents,$matches) = ('','',0);
     my (undef,undef,$fullname) = &getclasslist('all','0');
     
     my $receiptparts=0;
-    if ($ENV{"course.$courseid.receiptalg"} eq 'receipt2') { $receiptparts=1; }
+    if ($env{"course.$courseid.receiptalg"} eq 'receipt2') { $receiptparts=1; }
     my $parts=['0'];
     if ($receiptparts) { ($parts)=&response_type($url,$symb); }
     foreach (sort {lc($$fullname{$a}) cmp lc($$fullname{$b}) } keys %$fullname) {
@@ -572,19 +572,19 @@
     my ($request) = shift;
 
     my ($symb,$url) = &get_symb_and_url($request);
-    my $cdom      = $ENV{"course.$ENV{'request.course.id'}.domain"};
-    my $cnum      = $ENV{"course.$ENV{'request.course.id'}.num"};
-    my $getsec    = $ENV{'form.section'} eq '' ? 'all' : $ENV{'form.section'};
-    my $submitonly= $ENV{'form.submitonly'} eq '' ? 'all' : $ENV{'form.submitonly'};
-
-    my $viewgrade = $ENV{'form.showgrading'} eq 'yes' ? 'View/Grade/Regrade' : 'View';
-    $ENV{'form.probTitle'} = $ENV{'form.probTitle'} eq '' ? 
-	&Apache::lonnet::gettitle($symb) : $ENV{'form.probTitle'};
+    my $cdom      = $env{"course.$env{'request.course.id'}.domain"};
+    my $cnum      = $env{"course.$env{'request.course.id'}.num"};
+    my $getsec    = $env{'form.section'} eq '' ? 'all' : $env{'form.section'};
+    my $submitonly= $env{'form.submitonly'} eq '' ? 'all' : $env{'form.submitonly'};
+
+    my $viewgrade = $env{'form.showgrading'} eq 'yes' ? 'View/Grade/Regrade' : 'View';
+    $env{'form.probTitle'} = $env{'form.probTitle'} eq '' ? 
+	&Apache::lonnet::gettitle($symb) : $env{'form.probTitle'};
 
     my $result='<h3><font color="#339933">&nbsp;'.$viewgrade.
 	' Submissions for a Student or a Group of Students</font></h3>';
 
-    my ($table,undef,$hdgrade,$partlist,$handgrade) = &showResourceInfo($url,$ENV{'form.probTitle'},($ENV{'form.showgrading'} eq 'yes'));
+    my ($table,undef,$hdgrade,$partlist,$handgrade) = &showResourceInfo($url,$env{'form.probTitle'},($env{'form.showgrading'} eq 'yes'));
 
     $request->print(<<LISTJAVASCRIPT);
 <script type="text/javascript" language="javascript">
@@ -622,7 +622,7 @@
     &commonJSfunctions($request);
     $request->print($result);
 
-    my $checkhdgrade = ($ENV{'form.handgrade'} eq 'yes' && scalar(@$partlist) > 1 ) ? 'checked' : '';
+    my $checkhdgrade = ($env{'form.handgrade'} eq 'yes' && scalar(@$partlist) > 1 ) ? 'checked' : '';
     my $checklastsub = $checkhdgrade eq '' ? 'checked' : '';
     my $gradeTable='<form action="/adm/grades" method="post" name="gradesub">'.
 	"\n".$table.
@@ -633,12 +633,12 @@
 	'<input type="radio" name="vAns" value="yes" /> one student '."\n".
 	'<input type="radio" name="vAns" value="all" checked="on" /> all students <br />'."\n".
 	'&nbsp;<b>Submissions: </b>'."\n";
-    if ($ENV{'form.handgrade'} eq 'yes' && scalar(@$partlist) > 1) {
+    if ($env{'form.handgrade'} eq 'yes' && scalar(@$partlist) > 1) {
 	$gradeTable.='<input type="radio" name="lastSub" value="hdgrade" '.$checkhdgrade.' /> essay part only'."\n";
     }
 
-    my $saveStatus = $ENV{'form.Status'} eq '' ? 'Active' : $ENV{'form.Status'};
-    $ENV{'form.Status'} = $saveStatus;
+    my $saveStatus = $env{'form.Status'} eq '' ? 'Active' : $env{'form.Status'};
+    $env{'form.Status'} = $saveStatus;
 
     $gradeTable.='<input type="radio" name="lastSub" value="lastonly" '.$checklastsub.' /> last submission only'."\n".
 	'<input type="radio" name="lastSub" value="last" /> last submission & parts info'."\n".
@@ -646,16 +646,16 @@
 	'<input type="radio" name="lastSub" value="all" /> all details'."\n".
 	'<input type="hidden" name="section"     value="'.$getsec.'" />'."\n".
 	'<input type="hidden" name="submitonly"  value="'.$submitonly.'" />'."\n".
-	'<input type="hidden" name="handgrade"   value="'.$ENV{'form.handgrade'}.'" /><br />'."\n".
-	'<input type="hidden" name="showgrading" value="'.$ENV{'form.showgrading'}.'" /><br />'."\n".
-	'<input type="hidden" name="saveState"   value="'.$ENV{'form.saveState'}.'" />'."\n".
-	'<input type="hidden" name="probTitle"   value="'.$ENV{'form.probTitle'}.'" />'."\n".
+	'<input type="hidden" name="handgrade"   value="'.$env{'form.handgrade'}.'" /><br />'."\n".
+	'<input type="hidden" name="showgrading" value="'.$env{'form.showgrading'}.'" /><br />'."\n".
+	'<input type="hidden" name="saveState"   value="'.$env{'form.saveState'}.'" />'."\n".
+	'<input type="hidden" name="probTitle"   value="'.$env{'form.probTitle'}.'" />'."\n".
 	'<input type="hidden" name="url"  value="'.$url.'" />'."\n".
 	'<input type="hidden" name="symb" value="'.$symb.'" />'."\n".
 	'<input type="hidden" name="saveStatusOld" value="'.$saveStatus.'" />'."\n";
 
-    if (exists($ENV{'form.gradingMenu'}) && exists($ENV{'form.Status'})) {
-	$gradeTable.='<input type="hidden" name="Status"   value="'.$ENV{'form.Status'}.'" />'."\n";
+    if (exists($env{'form.gradingMenu'}) && exists($env{'form.Status'})) {
+	$gradeTable.='<input type="hidden" name="Status"   value="'.$env{'form.Status'}.'" />'."\n";
     } else {
 	$gradeTable.='<b>Student Status:</b> '.
 	    &Apache::lonhtmlcommon::StatusOptions($saveStatus,undef,1,'javascript:reLoadList(this.form);').'<br />';
@@ -679,7 +679,7 @@
     while ($loop < 2) {
 	$gradeTable.='<td><b>&nbsp;No.</b>&nbsp;</td><td><b>&nbsp;Select&nbsp;</b></td>'.
 	    '<td>'.&nameUserString('header').'&nbsp;Section/Group</td>';
-	if ($ENV{'form.showgrading'} eq 'yes' && $submitonly ne 'all') {
+	if ($env{'form.showgrading'} eq 'yes' && $submitonly ne 'all') {
 	    foreach (sort(@$partlist)) {
 		my $display_part=&get_display_part((split(/_/))[0],$url,$symb);
 		$gradeTable.='<td><b>&nbsp;Part: '.$display_part.
@@ -695,7 +695,7 @@
     foreach my $student (sort {lc($$fullname{$a}) cmp lc($$fullname{$b}) } keys %$fullname) {
 	my ($uname,$udom) = split(/:/,$student);
 	my %status = ();
-	if ($ENV{'form.showgrading'} eq 'yes' && $submitonly ne 'all') {
+	if ($env{'form.showgrading'} eq 'yes' && $submitonly ne 'all') {
 	    (%status) =&student_gradeStatus($url,$symb,$udom,$uname,$partlist);
 	    my $submitted = 0;
 	    my $graded = 0;
@@ -734,7 +734,7 @@
 	       &nameUserString(undef,$$fullname{$student},$uname,$udom).
 	       '&nbsp;'.$section.'</td>'."\n";
 
-	    if ($ENV{'form.showgrading'} eq 'yes' && $submitonly ne 'all') {
+	    if ($env{'form.showgrading'} eq 'yes' && $submitonly ne 'all') {
 		foreach (sort keys(%status)) {
 		    next if (/^resource.*?submitted_by$/);
 		    $gradeTable.='<td align="middle">&nbsp;'.$status{$_}.'&nbsp;</td>'."\n";
@@ -746,7 +746,7 @@
     }
     if ($ctr%2 ==1) {
 	$gradeTable.='<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>';
-	    if ($ENV{'form.showgrading'} eq 'yes' && $submitonly ne 'all') {
+	    if ($env{'form.showgrading'} eq 'yes' && $submitonly ne 'all') {
 		foreach (@$partlist) {
 		    $gradeTable.='<td>&nbsp;</td>';
 		}
@@ -834,9 +834,9 @@
 
     foreach (@stuchecked) {
 	my ($uname,$udom,$fullname) = split(/:/);
-	$ENV{'form.student'}        = $uname;
-	$ENV{'form.userdom'}        = $udom;
-	$ENV{'form.fullname'}       = $fullname;
+	$env{'form.student'}        = $uname;
+	$env{'form.userdom'}        = $udom;
+	$env{'form.fullname'}       = $fullname;
 	&submission($request,$ctr,$total);
 	$ctr++;
     }
@@ -1394,7 +1394,7 @@
     my $rendered;
     if ($mode eq 'both' or $mode eq 'text') {
 	$rendered=&Apache::loncommon::get_student_view($symb,$uname,$udom,
-					     $ENV{'request.course.id'});
+					     $env{'request.course.id'});
     }
     if ($removeform) {
 	$rendered=~s|<form(.*?)>||g;
@@ -1404,7 +1404,7 @@
     my $companswer;
     if ($mode eq 'both' or $mode eq 'answer') {
 	$companswer=&Apache::loncommon::get_student_answers($symb,$uname,$udom,
-						    $ENV{'request.course.id'});
+						    $env{'request.course.id'});
     }
     if ($removeform) {
 	$companswer=~s|<form(.*?)>||g;
@@ -1420,7 +1420,7 @@
 	} else {
 	    $result.='Correct answer: ';
 	}
-	$result.=$ENV{'form.fullname'}.'</b></td></tr>';
+	$result.=$env{'form.fullname'}.'</b></td></tr>';
     }
     if ($mode eq 'both') {
 	$result.='<tr><td bgcolor="#ffffff">'.$rendered.'<br />';
@@ -1439,41 +1439,41 @@
 sub submission {
     my ($request,$counter,$total) = @_;
 
-    (my $url=$ENV{'form.url'})=~s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;
-    my ($uname,$udom)     = ($ENV{'form.student'},$ENV{'form.userdom'});
-    $udom = ($udom eq '' ? $ENV{'user.domain'} : $udom); #has form.userdom changed for a student?
-    my $usec = &Apache::lonnet::getsection($udom,$uname,$ENV{'request.course.id'});
-    $ENV{'form.fullname'} = &Apache::loncommon::plainname($uname,$udom,'lastname') if $ENV{'form.fullname'} eq '';
+    (my $url=$env{'form.url'})=~s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;
+    my ($uname,$udom)     = ($env{'form.student'},$env{'form.userdom'});
+    $udom = ($udom eq '' ? $env{'user.domain'} : $udom); #has form.userdom changed for a student?
+    my $usec = &Apache::lonnet::getsection($udom,$uname,$env{'request.course.id'});
+    $env{'form.fullname'} = &Apache::loncommon::plainname($uname,$udom,'lastname') if $env{'form.fullname'} eq '';
 
-    my $symb=($ENV{'form.symb'} ne '' ? $ENV{'form.symb'} : (&Apache::lonnet::symbread($url)));
+    my $symb=($env{'form.symb'} ne '' ? $env{'form.symb'} : (&Apache::lonnet::symbread($url)));
     if ($symb eq '') { $request->print("Unable to handle ambiguous references:$url:."); return ''; }
 
     if (!&canview($usec)) {
 	$request->print('<font color="red">Unable to view requested student.('.
 			$uname.'@'.$udom.' in section '.$usec.' in course id '.
-			$ENV{'request.course.id'}.')</font>');
+			$env{'request.course.id'}.')</font>');
 	$request->print(&show_grading_menu_form($symb,$url));
 	return;
     }
 
-    if (!$ENV{'form.lastSub'}) { $ENV{'form.lastSub'} = 'datesub'; }
-    if (!$ENV{'form.vProb'}) { $ENV{'form.vProb'} = 'yes'; }
-    if (!$ENV{'form.vAns'}) { $ENV{'form.vAns'} = 'yes'; }
-    my $last = ($ENV{'form.lastSub'} eq 'last' ? 'last' : '');
+    if (!$env{'form.lastSub'}) { $env{'form.lastSub'} = 'datesub'; }
+    if (!$env{'form.vProb'}) { $env{'form.vProb'} = 'yes'; }
+    if (!$env{'form.vAns'}) { $env{'form.vAns'} = 'yes'; }
+    my $last = ($env{'form.lastSub'} eq 'last' ? 'last' : '');
     my $checkIcon = '<img src="'.$request->dir_config('lonIconsURL').
 	'/check.gif" height="16" border="0" />';
 
     # header info
     if ($counter == 0) {
 	&sub_page_js($request);
-	&sub_page_kw_js($request) if ($ENV{'form.handgrade'} eq 'yes');
-	$ENV{'form.probTitle'} = $ENV{'form.probTitle'} eq '' ? 
-	    &Apache::lonnet::gettitle($symb) : $ENV{'form.probTitle'};
+	&sub_page_kw_js($request) if ($env{'form.handgrade'} eq 'yes');
+	$env{'form.probTitle'} = $env{'form.probTitle'} eq '' ? 
+	    &Apache::lonnet::gettitle($symb) : $env{'form.probTitle'};
 
 	$request->print('<h3>&nbsp;<font color="#339933">Submission Record</font></h3>'."\n".
-			'<font size=+1>&nbsp;<b>Resource: </b>'.$ENV{'form.probTitle'}.'</font>'."\n");
+			'<font size=+1>&nbsp;<b>Resource: </b>'.$env{'form.probTitle'}.'</font>'."\n");
 
-	if ($ENV{'form.handgrade'} eq 'no') {
+	if ($env{'form.handgrade'} eq 'no') {
 	    my $checkMark='<br /><br />&nbsp;<b>Note:</b> Part(s) graded correct by the computer is marked with a '.
 		$checkIcon.' symbol.'."\n";
 	    $request->print($checkMark);
@@ -1481,13 +1481,13 @@
 
 	# option to display problem, only once else it cause problems 
         # with the form later since the problem has a form.
-	if ($ENV{'form.vProb'} eq 'yes' or $ENV{'form.vAns'} eq 'yes') {
+	if ($env{'form.vProb'} eq 'yes' or $env{'form.vAns'} eq 'yes') {
 	    my $mode;
-	    if ($ENV{'form.vProb'} eq 'yes' && $ENV{'form.vAns'} eq 'yes') {
+	    if ($env{'form.vProb'} eq 'yes' && $env{'form.vAns'} eq 'yes') {
 		$mode='both';
-	    } elsif ($ENV{'form.vProb'} eq 'yes') {
+	    } elsif ($env{'form.vProb'} eq 'yes') {
 		$mode='text';
-	    } elsif ($ENV{'form.vAns'} eq 'yes') {
+	    } elsif ($env{'form.vAns'} eq 'yes') {
 		$mode='answer';
 	    }
 	    $request->print(&show_problem($request,$symb,$uname,$udom,0,1,$mode));
@@ -1496,60 +1496,60 @@
 	# kwclr is the only variable that is guaranteed to be non blank 
         # if this subroutine has been called once.
 	my %keyhash = ();
-	if ($ENV{'form.kwclr'} eq '' && $ENV{'form.handgrade'} eq 'yes') {
+	if ($env{'form.kwclr'} eq '' && $env{'form.handgrade'} eq 'yes') {
 	    %keyhash = &Apache::lonnet::dump('nohist_handgrade',
-					     $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
-					     $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+					     $env{'course.'.$env{'request.course.id'}.'.domain'},
+					     $env{'course.'.$env{'request.course.id'}.'.num'});
 
-	    my $loginuser = $ENV{'user.name'}.':'.$ENV{'user.domain'};
-	    $ENV{'form.keywords'} = $keyhash{$symb.'_keywords'} ne '' ? $keyhash{$symb.'_keywords'} : '';
-	    $ENV{'form.kwclr'}    = $keyhash{$loginuser.'_kwclr'} ne '' ? $keyhash{$loginuser.'_kwclr'} : 'red';
-	    $ENV{'form.kwsize'}   = $keyhash{$loginuser.'_kwsize'} ne '' ? $keyhash{$loginuser.'_kwsize'} : '0';
-	    $ENV{'form.kwstyle'}  = $keyhash{$loginuser.'_kwstyle'} ne '' ? $keyhash{$loginuser.'_kwstyle'} : '';
-	    $ENV{'form.msgsub'}   = $keyhash{$symb.'_subject'} ne '' ? 
-		$keyhash{$symb.'_subject'} : $ENV{'form.probTitle'};
-	    $ENV{'form.savemsgN'} = $keyhash{$symb.'_savemsgN'} ne '' ? $keyhash{$symb.'_savemsgN'} : '0';
+	    my $loginuser = $env{'user.name'}.':'.$env{'user.domain'};
+	    $env{'form.keywords'} = $keyhash{$symb.'_keywords'} ne '' ? $keyhash{$symb.'_keywords'} : '';
+	    $env{'form.kwclr'}    = $keyhash{$loginuser.'_kwclr'} ne '' ? $keyhash{$loginuser.'_kwclr'} : 'red';
+	    $env{'form.kwsize'}   = $keyhash{$loginuser.'_kwsize'} ne '' ? $keyhash{$loginuser.'_kwsize'} : '0';
+	    $env{'form.kwstyle'}  = $keyhash{$loginuser.'_kwstyle'} ne '' ? $keyhash{$loginuser.'_kwstyle'} : '';
+	    $env{'form.msgsub'}   = $keyhash{$symb.'_subject'} ne '' ? 
+		$keyhash{$symb.'_subject'} : $env{'form.probTitle'};
+	    $env{'form.savemsgN'} = $keyhash{$symb.'_savemsgN'} ne '' ? $keyhash{$symb.'_savemsgN'} : '0';
 	}
-	my $overRideScore = $ENV{'form.overRideScore'} eq '' ? 'no' : $ENV{'form.overRideScore'};
+	my $overRideScore = $env{'form.overRideScore'} eq '' ? 'no' : $env{'form.overRideScore'};
 
 	$request->print('<form action="/adm/grades" method="post" name="SCORE">'."\n".
 			'<input type="hidden" name="command"    value="handgrade" />'."\n".
-			'<input type="hidden" name="saveState"  value="'.$ENV{'form.saveState'}.'" />'."\n".
-			'<input type="hidden" name="Status"     value="'.$ENV{'form.Status'}.'" />'."\n".
+			'<input type="hidden" name="saveState"  value="'.$env{'form.saveState'}.'" />'."\n".
+			'<input type="hidden" name="Status"     value="'.$env{'form.Status'}.'" />'."\n".
 			'<input type="hidden" name="overRideScore" value="'.$overRideScore.'" />'."\n".
-			'<input type="hidden" name="probTitle"  value="'.$ENV{'form.probTitle'}.'" />'."\n".
+			'<input type="hidden" name="probTitle"  value="'.$env{'form.probTitle'}.'" />'."\n".
 			'<input type="hidden" name="refresh"    value="off" />'."\n".
 			'<input type="hidden" name="studentNo"  value="" />'."\n".
 			'<input type="hidden" name="gradeOpt"   value="" />'."\n".
 			'<input type="hidden" name="symb"       value="'.$symb.'" />'."\n".
 			'<input type="hidden" name="url"        value="'.$url.'" />'."\n".
-			'<input type="hidden" name="showgrading" value="'.$ENV{'form.showgrading'}.'" />'."\n".
-			'<input type="hidden" name="vProb"      value="'.$ENV{'form.vProb'}.'" />'."\n".
-			'<input type="hidden" name="vAns"       value="'.$ENV{'form.vAns'}.'" />'."\n".
-			'<input type="hidden" name="lastSub"    value="'.$ENV{'form.lastSub'}.'" />'."\n".
-			'<input type="hidden" name="section"    value="'.$ENV{'form.section'}.'">'."\n".
-			'<input type="hidden" name="submitonly" value="'.$ENV{'form.submitonly'}.'">'."\n".
-			'<input type="hidden" name="handgrade"  value="'.$ENV{'form.handgrade'}.'">'."\n".
+			'<input type="hidden" name="showgrading" value="'.$env{'form.showgrading'}.'" />'."\n".
+			'<input type="hidden" name="vProb"      value="'.$env{'form.vProb'}.'" />'."\n".
+			'<input type="hidden" name="vAns"       value="'.$env{'form.vAns'}.'" />'."\n".
+			'<input type="hidden" name="lastSub"    value="'.$env{'form.lastSub'}.'" />'."\n".
+			'<input type="hidden" name="section"    value="'.$env{'form.section'}.'">'."\n".
+			'<input type="hidden" name="submitonly" value="'.$env{'form.submitonly'}.'">'."\n".
+			'<input type="hidden" name="handgrade"  value="'.$env{'form.handgrade'}.'">'."\n".
 			'<input type="hidden" name="NCT"'.
-			' value="'.($ENV{'form.NTSTU'} ne '' ? $ENV{'form.NTSTU'} : $total+1).'" />'."\n");
-	if ($ENV{'form.handgrade'} eq 'yes') {
-	    $request->print('<input type="hidden" name="keywords" value="'.$ENV{'form.keywords'}.'" />'."\n".
-			    '<input type="hidden" name="kwclr"    value="'.$ENV{'form.kwclr'}.'" />'."\n".
-			    '<input type="hidden" name="kwsize"   value="'.$ENV{'form.kwsize'}.'" />'."\n".
-			    '<input type="hidden" name="kwstyle"  value="'.$ENV{'form.kwstyle'}.'" />'."\n".
-			    '<input type="hidden" name="msgsub"   value="'.$ENV{'form.msgsub'}.'" />'."\n".
+			' value="'.($env{'form.NTSTU'} ne '' ? $env{'form.NTSTU'} : $total+1).'" />'."\n");
+	if ($env{'form.handgrade'} eq 'yes') {
+	    $request->print('<input type="hidden" name="keywords" value="'.$env{'form.keywords'}.'" />'."\n".
+			    '<input type="hidden" name="kwclr"    value="'.$env{'form.kwclr'}.'" />'."\n".
+			    '<input type="hidden" name="kwsize"   value="'.$env{'form.kwsize'}.'" />'."\n".
+			    '<input type="hidden" name="kwstyle"  value="'.$env{'form.kwstyle'}.'" />'."\n".
+			    '<input type="hidden" name="msgsub"   value="'.$env{'form.msgsub'}.'" />'."\n".
 			    '<input type="hidden" name="shownSub" value="0" />'."\n".
-			    '<input type="hidden" name="savemsgN" value="'.$ENV{'form.savemsgN'}.'" />'."\n");
+			    '<input type="hidden" name="savemsgN" value="'.$env{'form.savemsgN'}.'" />'."\n");
 	    foreach my $partid (&Apache::loncommon::get_env_multiple('form.vPart')) {
 		$request->print('<input type="hidden" name="vPart" value="'.$partid.'" />'."\n");
 	    }
 	}
 	
 	my ($cts,$prnmsg) = (1,'');
-	while ($cts <= $ENV{'form.savemsgN'}) {
+	while ($cts <= $env{'form.savemsgN'}) {
 	    $prnmsg.='<input type="hidden" name="savemsg'.$cts.'" value="'.
 		(!exists($keyhash{$symb.'_savemsg'.$cts}) ? 
-		 &Apache::lonfeedback::clear_out_html($ENV{'form.savemsg'.$cts}) :
+		 &Apache::lonfeedback::clear_out_html($env{'form.savemsg'.$cts}) :
 		 &Apache::lonfeedback::clear_out_html($keyhash{$symb.'_savemsg'.$cts})).
 		'" />'."\n".
 		'<input type="hidden" name="shownOnce'.$cts.'" value="0" />'."\n";
@@ -1557,7 +1557,7 @@
 	}
 	$request->print($prnmsg);
 
-	if ($ENV{'form.handgrade'} eq 'yes' && $ENV{'form.showgrading'} eq 'yes') {
+	if ($env{'form.handgrade'} eq 'yes' && $env{'form.showgrading'} eq 'yes') {
 #
 # Print out the keyword options line
 #
@@ -1579,20 +1579,20 @@
         }
     }
 
-    if ($ENV{'form.vProb'} eq 'all' or $ENV{'form.vAns'} eq 'all') {
+    if ($env{'form.vProb'} eq 'all' or $env{'form.vAns'} eq 'all') {
 	$request->print('<br /><br /><br />') if ($counter > 0);
 	my $mode;
-	if ($ENV{'form.vProb'} eq 'all' && $ENV{'form.vAns'} eq 'all') {
+	if ($env{'form.vProb'} eq 'all' && $env{'form.vAns'} eq 'all') {
 	    $mode='both';
-	} elsif ($ENV{'form.vProb'} eq 'all' ) {
+	} elsif ($env{'form.vProb'} eq 'all' ) {
 	    $mode='text';
-	} elsif ($ENV{'form.vAns'} eq 'all') {
+	} elsif ($env{'form.vAns'} eq 'all') {
 	    $mode='answer';
 	}
 	$request->print(&show_problem($request,$symb,$uname,$udom,1,1,$mode));
     }
 
-    my %record = &Apache::lonnet::restore($symb,$ENV{'request.course.id'},$udom,$uname);
+    my %record = &Apache::lonnet::restore($symb,$env{'request.course.id'},$udom,$uname);
 
     my ($partlist,$handgrade,$responseType) = &response_type($url,$symb);
 
@@ -1601,14 +1601,14 @@
     my $result='<table border="0" width=100%><tr><td bgcolor="#777777">'."\n".
 	'<table border="0" width=100%><tr bgcolor="#edffff"><td>'."\n";
 
-    $result.='<b>Fullname: </b>'.&nameUserString(undef,$ENV{'form.fullname'},$uname,$udom).'<br />'."\n";
+    $result.='<b>Fullname: </b>'.&nameUserString(undef,$env{'form.fullname'},$uname,$udom).'<br />'."\n";
     $result.='<input type="hidden" name="name'.$counter.
-	'" value="'.$ENV{'form.fullname'}.'" />'."\n";
+	'" value="'.$env{'form.fullname'}.'" />'."\n";
 
     # If any part of the problem is an essay-response (handgraded), then check for collaborators
     my @col_fullnames;
     my ($classlist,$fullname);
-    if ($ENV{'form.handgrade'} eq 'yes') {
+    if ($env{'form.handgrade'} eq 'yes') {
 	($classlist,undef,$fullname) = &getclasslist('all','0');
 	for (keys (%$handgrade)) {
 	    my $ncol = &Apache::lonnet::EXT('resource.'.$_.
@@ -1669,7 +1669,7 @@
     #                  (for multi-response type part)
     #             (3) Last submission plus the parts info
     #             (4) The whole record for this student
-    if ($ENV{'form.lastSub'} =~ /^(lastonly|hdgrade)$/) {
+    if ($env{'form.lastSub'} =~ /^(lastonly|hdgrade)$/) {
 	my ($string,$timestamp)= &get_last_submission(\%record);
 	my $lastsubonly=''.
 	    ($$timestamp eq '' ? '' : '<b>Date Submitted:</b> '.
@@ -1681,15 +1681,15 @@
 	    for my $part (sort keys(%$handgrade)) {
 		my ($partid,$respid) = split(/_/,$part);
 		my $display_part=&get_display_part($partid,$url,$symb);
-		if ($ENV{"form.$uname:$udom:$partid:submitted_by"}) {
+		if ($env{"form.$uname:$udom:$partid:submitted_by"}) {
 		    if (exists($seenparts{$partid})) { next; }
 		    $seenparts{$partid}=1;
 		    my $submitby='<b>Part:</b> '.$display_part.
 			' <b>Collaborative submission by:</b> '.
 			'<a href="javascript:viewSubmitter(\''.
-			$ENV{"form.$uname:$udom:$partid:submitted_by"}.
+			$env{"form.$uname:$udom:$partid:submitted_by"}.
 			'\')"; TARGET=_self>'.
-			$$fullname{$ENV{"form.$uname:$udom:$partid:submitted_by"}}.'</a><br />';
+			$$fullname{$env{"form.$uname:$udom:$partid:submitted_by"}}.'</a><br />';
 		    $request->print($submitby);
 		    next;
 		}
@@ -1707,7 +1707,7 @@
 		    my ($ressub,$subval) = split(/:/,$_,2);
 		    # Similarity check
 		    my $similar='';
-		    if($ENV{'form.checkPlag'}){
+		    if($env{'form.checkPlag'}){
 			my ($oname,$odom,$ocrsid,$oessay,$osim)=
 			    &most_similar($uname,$udom,$subval);
 			if ($osim) {
@@ -1721,8 +1721,8 @@
 			}
 		    }
 		    my $order=&get_order($partid,$respid,$symb,$uname,$udom);
-		    if ($ENV{'form.lastSub'} eq 'lastonly' || 
-			($ENV{'form.lastSub'} eq 'hdgrade' && 
+		    if ($env{'form.lastSub'} eq 'lastonly' || 
+			($env{'form.lastSub'} eq 'hdgrade' && 
 			 $$handgrade{$part} eq 'yes')) {
 			my $display_part=&get_display_part($partid,$url,$symb);
 			$lastsubonly.='<tr><td bgcolor="#ffffe6"><b>Part:</b> '.
@@ -1759,12 +1759,12 @@
 	}
 	$lastsubonly.='</td></tr><tr bgcolor="#ffffff"><td>'."\n";
 	$request->print($lastsubonly);
-    } elsif ($ENV{'form.lastSub'} eq 'datesub') {
+    } elsif ($env{'form.lastSub'} eq 'datesub') {
 	my (undef,$responseType,undef,$parts) = &showResourceInfo($url);
 	$request->print(&displaySubByDates($symb,\%record,$parts,$responseType,$checkIcon,$uname,$udom));
-    } elsif ($ENV{'form.lastSub'} =~ /^(last|all)$/) {
+    } elsif ($env{'form.lastSub'} =~ /^(last|all)$/) {
 	$request->print(&Apache::loncommon::get_previous_attempt($symb,$uname,$udom,
-								 $ENV{'request.course.id'},
+								 $env{'request.course.id'},
 								 $last,'.submission',
 								 'Apache::grades::keywords_highlight'));
     }
@@ -1773,13 +1773,13 @@
 	.$udom.'" />'."\n");
     
     # return if view submission with no grading option
-    if ($ENV{'form.showgrading'} eq '' || (!&canmodify($usec))) {
+    if ($env{'form.showgrading'} eq '' || (!&canmodify($usec))) {
 	my $toGrade.='<input type="button" value="Grade Student" '.
 	    'onClick="javascript:checksubmit(this.form,\'Grade Student\',\''
 	    .$counter.'\');" TARGET=_self> &nbsp;'."\n" if (&canmodify($usec));
 	$toGrade.='</td></tr></table></td></tr></table>'."\n";
-	if (($ENV{'form.command'} eq 'submission') || 
-	    ($ENV{'form.command'} eq 'processGroup' && $counter == $total)) {
+	if (($env{'form.command'} eq 'submission') || 
+	    ($env{'form.command'} eq 'processGroup' && $counter == $total)) {
 	    $toGrade.='</form>'.&show_grading_menu_form($symb,$url) 
 	}
 	$request->print($toGrade);
@@ -1789,8 +1789,8 @@
     }
 
     # essay grading message center
-    if ($ENV{'form.handgrade'} eq 'yes') {
-	my ($lastname,$givenn) = split(/,/,$ENV{'form.fullname'});
+    if ($env{'form.handgrade'} eq 'yes') {
+	my ($lastname,$givenn) = split(/,/,$env{'form.fullname'});
 	my $msgfor = $givenn.' '.$lastname;
 	if (scalar(@col_fullnames) > 0) {
 	    my $lastone = pop @col_fullnames;
@@ -1805,7 +1805,7 @@
 	    '<img src="'.$request->dir_config('lonIconsURL').
 	    '/mailbkgrd.gif" width="14" height="10" name="mailicon'.$counter.'" />'."\n".
 	    '<br />&nbsp;(Message will be sent when you click on Save & Next below.)'."\n" 
-	    if ($ENV{'form.handgrade'} eq 'yes');
+	    if ($env{'form.handgrade'} eq 'yes');
 	$request->print($result);
     }
 
@@ -1816,7 +1816,7 @@
 	my ($partid,$respid) = split(/_/);
 	next if ($seen{$partid} > 0);
 	$seen{$partid}++;
-	next if ($$handgrade{$_} =~ /:no$/ && $ENV{'form.lastSub'} =~ /^(hdgrade)$/);
+	next if ($$handgrade{$_} =~ /:no$/ && $env{'form.lastSub'} =~ /^(hdgrade)$/);
 	push @partlist,$partid;
 	push @gradePartRespid,$partid.'.'.$respid;
 
@@ -1844,7 +1844,7 @@
 	    '<option>1</option><option>2</option>'.
 	    '<option>3</option><option>5</option>'.
 	    '<option>7</option><option>10</option></select>'."\n";
-	my $nsel = ($ENV{'form.NTSTU'} ne '' ? $ENV{'form.NTSTU'} : '1');
+	my $nsel = ($env{'form.NTSTU'} ne '' ? $env{'form.NTSTU'} : '1');
 	$ntstu =~ s/<option>$nsel</<option selected="on">$nsel</;
 	$endform.=$ntstu.'student(s) &nbsp;&nbsp;';
 	$endform.='<input type="button" value="Previous" '.
@@ -1888,12 +1888,12 @@
 #--- High light keywords, with style choosen by user.
 sub keywords_highlight {
     my $string    = shift;
-    my $size      = $ENV{'form.kwsize'} eq '0' ? '' : 'size='.$ENV{'form.kwsize'};
-    my $styleon   = $ENV{'form.kwstyle'} eq ''  ? '' : $ENV{'form.kwstyle'};
+    my $size      = $env{'form.kwsize'} eq '0' ? '' : 'size='.$env{'form.kwsize'};
+    my $styleon   = $env{'form.kwstyle'} eq ''  ? '' : $env{'form.kwstyle'};
     (my $styleoff = $styleon) =~ s/\</\<\//;
-    my @keylist   = split(/[,\s+]/,$ENV{'form.keywords'});
+    my @keylist   = split(/[,\s+]/,$env{'form.keywords'});
     foreach (@keylist) {
-	$string =~ s/\b\Q$_\E(\b|\.)/<font color\=$ENV{'form.kwclr'} $size\>$styleon$_$styleoff<\/font>/gi;
+	$string =~ s/\b\Q$_\E(\b|\.)/<font color\=$env{'form.kwclr'} $size\>$styleon$_$styleoff<\/font>/gi;
     }
     return $string;
 }
@@ -1901,15 +1901,15 @@
 #--- Called from submission routine
 sub processHandGrade {
     my ($request) = shift;
-    my $url    = $ENV{'form.url'};
-    my $symb   = $ENV{'form.symb'};
-    my $button = $ENV{'form.gradeOpt'};
-    my $ngrade = $ENV{'form.NCT'};
-    my $ntstu  = $ENV{'form.NTSTU'};
+    my $url    = $env{'form.url'};
+    my $symb   = $env{'form.symb'};
+    my $button = $env{'form.gradeOpt'};
+    my $ngrade = $env{'form.NCT'};
+    my $ntstu  = $env{'form.NTSTU'};
     if ($button eq 'Save & Next') {
 	my $ctr = 0;
 	while ($ctr < $ngrade) {
-	    my ($uname,$udom) = split(/:/,$ENV{'form.unamedom'.$ctr});
+	    my ($uname,$udom) = split(/:/,$env{'form.unamedom'.$ctr});
 	    my ($errorflag,$pts,$wgt) = &saveHandGrade($request,$url,$symb,$uname,$udom,$ctr);
 	    if ($errorflag eq 'no_score') {
 		$ctr++;
@@ -1920,36 +1920,36 @@
 		$ctr++;
 		next;
 	    }
-	    my $includemsg = $ENV{'form.includemsg'.$ctr};
+	    my $includemsg = $env{'form.includemsg'.$ctr};
 	    my ($subject,$message,$msgstatus) = ('','','');
 	    if ($includemsg =~ /savemsg|newmsg\Q$ctr\E/) {
-		$subject = $ENV{'form.msgsub'} if ($includemsg =~ /^msgsub/);
+		$subject = $env{'form.msgsub'} if ($includemsg =~ /^msgsub/);
 		my (@msgnum) = split(/,/,$includemsg);
 		foreach (@msgnum) {
-		    $message.=$ENV{'form.'.$_} if ($_ =~ /savemsg|newmsg/ && $_ ne '');
+		    $message.=$env{'form.'.$_} if ($_ =~ /savemsg|newmsg/ && $_ ne '');
 		}
 		$message =&Apache::lonfeedback::clear_out_html($message);
 		$message.="\n\nPoint".($pts > 1 ? 's':'').' awarded = '.$pts.' out of '.$wgt;
 		$message.=" for <a href=\"".
 		    &Apache::lonnet::clutter($url).
-		    "?symb=$symb\">$ENV{'form.probTitle'}</a>";
+		    "?symb=$symb\">$env{'form.probTitle'}</a>";
 		$msgstatus = &Apache::lonmsg::user_normal_msg ($uname,$udom,
-							       $ENV{'form.msgsub'},$message);
+							       $env{'form.msgsub'},$message);
 	    }
-	    if ($ENV{'form.collaborator'.$ctr}) {
+	    if ($env{'form.collaborator'.$ctr}) {
 		my @collabstrs=&Apache::loncommon::get_env_multiple("form.collaborator$ctr");
 		foreach my $collabstr (@collabstrs) {
 		    my ($part,@collaborators) = split(/:/,$collabstr);
 		    foreach (@collaborators) {
 			my ($errorflag,$pts,$wgt) = 
 			    &saveHandGrade($request,$url,$symb,$_,$udom,$ctr,
-					   $ENV{'form.unamedom'.$ctr},$part);
+					   $env{'form.unamedom'.$ctr},$part);
 			if ($errorflag eq 'not_allowed') {
 			    $request->print("<font color=\"red\">Not allowed to modify grades for $_:$udom</font>");
 			    next;
 			} else {
 			    if ($message ne '') {
-				$msgstatus = &Apache::lonmsg::user_normal_msg($_,$udom,$ENV{'form.msgsub'},$message);
+				$msgstatus = &Apache::lonmsg::user_normal_msg($_,$udom,$env{'form.msgsub'},$message);
 			    }
 			    
 			}
@@ -1960,61 +1960,61 @@
 	}
     }
 
-    if ($ENV{'form.handgrade'} eq 'yes') {
+    if ($env{'form.handgrade'} eq 'yes') {
 	# Keywords sorted in alphabatical order
-	my $loginuser = $ENV{'user.name'}.':'.$ENV{'user.domain'};
+	my $loginuser = $env{'user.name'}.':'.$env{'user.domain'};
 	my %keyhash = ();
-	$ENV{'form.keywords'}           =~ s/,\s{0,}|\s+/ /g;
-	$ENV{'form.keywords'}           =~ s/^\s+|\s+$//;
-	my (@keywords) = sort(split(/\s+/,$ENV{'form.keywords'}));
-	$ENV{'form.keywords'} = join(' ',@keywords);
-	$keyhash{$symb.'_keywords'}     = $ENV{'form.keywords'};
-	$keyhash{$symb.'_subject'}      = $ENV{'form.msgsub'};
-	$keyhash{$loginuser.'_kwclr'}   = $ENV{'form.kwclr'};
-	$keyhash{$loginuser.'_kwsize'}  = $ENV{'form.kwsize'};
-	$keyhash{$loginuser.'_kwstyle'} = $ENV{'form.kwstyle'};
+	$env{'form.keywords'}           =~ s/,\s{0,}|\s+/ /g;
+	$env{'form.keywords'}           =~ s/^\s+|\s+$//;
+	my (@keywords) = sort(split(/\s+/,$env{'form.keywords'}));
+	$env{'form.keywords'} = join(' ',@keywords);
+	$keyhash{$symb.'_keywords'}     = $env{'form.keywords'};
+	$keyhash{$symb.'_subject'}      = $env{'form.msgsub'};
+	$keyhash{$loginuser.'_kwclr'}   = $env{'form.kwclr'};
+	$keyhash{$loginuser.'_kwsize'}  = $env{'form.kwsize'};
+	$keyhash{$loginuser.'_kwstyle'} = $env{'form.kwstyle'};
 
 	# message center - Order of message gets changed. Blank line is eliminated.
-	# New messages are saved in ENV for the next student.
+	# New messages are saved in env for the next student.
 	# All messages are saved in nohist_handgrade.db
 	my ($ctr,$idx) = (1,1);
-	while ($ctr <= $ENV{'form.savemsgN'}) {
-	    if ($ENV{'form.savemsg'.$ctr} ne '') {
-		$keyhash{$symb.'_savemsg'.$idx} = $ENV{'form.savemsg'.$ctr};
+	while ($ctr <= $env{'form.savemsgN'}) {
+	    if ($env{'form.savemsg'.$ctr} ne '') {
+		$keyhash{$symb.'_savemsg'.$idx} = $env{'form.savemsg'.$ctr};
 		$idx++;
 	    }
 	    $ctr++;
 	}
 	$ctr = 0;
 	while ($ctr < $ngrade) {
-	    if ($ENV{'form.newmsg'.$ctr} ne '') {
-		$keyhash{$symb.'_savemsg'.$idx} = $ENV{'form.newmsg'.$ctr};
-		$ENV{'form.savemsg'.$idx} = $ENV{'form.newmsg'.$ctr};
+	    if ($env{'form.newmsg'.$ctr} ne '') {
+		$keyhash{$symb.'_savemsg'.$idx} = $env{'form.newmsg'.$ctr};
+		$env{'form.savemsg'.$idx} = $env{'form.newmsg'.$ctr};
 		$idx++;
 	    }
 	    $ctr++;
 	}
-	$ENV{'form.savemsgN'} = --$idx;
-	$keyhash{$symb.'_savemsgN'} = $ENV{'form.savemsgN'};
+	$env{'form.savemsgN'} = --$idx;
+	$keyhash{$symb.'_savemsgN'} = $env{'form.savemsgN'};
 	my $putresult = &Apache::lonnet::put
 	    ('nohist_handgrade',\%keyhash,
-	     $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
-	     $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+	     $env{'course.'.$env{'request.course.id'}.'.domain'},
+	     $env{'course.'.$env{'request.course.id'}.'.num'});
     }
     # Called by Save & Refresh from Highlight Attribute Window
-    my (undef,undef,$fullname) = &getclasslist($ENV{'form.section'},'1');
-    if ($ENV{'form.refresh'} eq 'on') {
+    my (undef,undef,$fullname) = &getclasslist($env{'form.section'},'1');
+    if ($env{'form.refresh'} eq 'on') {
 	my ($ctr,$total) = (0,0);
 	while ($ctr < $ngrade) {
-	    $total++ if  $ENV{'form.unamedom'.$ctr} ne '';
+	    $total++ if  $env{'form.unamedom'.$ctr} ne '';
 	    $ctr++;
 	}
-	$ENV{'form.NTSTU'}=$ngrade;
+	$env{'form.NTSTU'}=$ngrade;
 	$ctr = 0;
 	while ($ctr < $total) {
-	    my $processUser = $ENV{'form.unamedom'.$ctr};
-	    ($ENV{'form.student'},$ENV{'form.userdom'}) = split(/:/,$processUser);
-	    $ENV{'form.fullname'} = $$fullname{$processUser};
+	    my $processUser = $env{'form.unamedom'.$ctr};
+	    ($env{'form.student'},$env{'form.userdom'}) = split(/:/,$processUser);
+	    $env{'form.fullname'} = $$fullname{$processUser};
 	    &submission($request,$ctr,$total-1);
 	    $ctr++;
 	}
@@ -2023,20 +2023,20 @@
 
 # Go directly to grade student - from submission or link from chart page
     if ($button eq 'Grade Student') {
-	(undef,undef,$ENV{'form.handgrade'},undef,undef) = &showResourceInfo($url);
-	my $processUser = $ENV{'form.unamedom'.$ENV{'form.studentNo'}};
-	($ENV{'form.student'},$ENV{'form.userdom'}) = split(/:/,$processUser);
-	$ENV{'form.fullname'} = $$fullname{$processUser};
+	(undef,undef,$env{'form.handgrade'},undef,undef) = &showResourceInfo($url);
+	my $processUser = $env{'form.unamedom'.$env{'form.studentNo'}};
+	($env{'form.student'},$env{'form.userdom'}) = split(/:/,$processUser);
+	$env{'form.fullname'} = $$fullname{$processUser};
 	&submission($request,0,0);
 	return '';
     }
 
     # Get the next/previous one or group of students
-    my $firststu = $ENV{'form.unamedom0'};
-    my $laststu = $ENV{'form.unamedom'.($ngrade-1)};
+    my $firststu = $env{'form.unamedom0'};
+    my $laststu = $env{'form.unamedom'.($ngrade-1)};
     my $ctr = 2;
     while ($laststu eq '') {
-	$laststu  = $ENV{'form.unamedom'.($ngrade-$ctr)};
+	$laststu  = $env{'form.unamedom'.($ngrade-$ctr)};
 	$ctr++;
 	$laststu = $firststu if ($ctr > $ngrade);
     }
@@ -2057,10 +2057,10 @@
     @parsedlist = reverse @parsedlist if ($button eq 'Previous');
     my ($partlist) = &response_type($url);
     foreach my $student (@parsedlist) {
-	my $submitonly=$ENV{'form.submitonly'};
+	my $submitonly=$env{'form.submitonly'};
 	my ($uname,$udom) = split(/:/,$student);
 	if ($submitonly =~ /^(yes|graded|incorrect)$/) {
-#	    my %record = &Apache::lonnet::restore($symb,$ENV{'request.course.id'},$udom,$uname);
+#	    my %record = &Apache::lonnet::restore($symb,$env{'request.course.id'},$udom,$uname);
 	    my %status=&student_gradeStatus($url,$symb,$udom,$uname,$partlist);
 	    my $submitted = 0;
 	    my $ungraded = 0;
@@ -2090,9 +2090,9 @@
 
     foreach (sort @nextlist) {
 	my ($uname,$udom,$submitter) = split(/:/);
-	$ENV{'form.student'}  = $uname;
-	$ENV{'form.userdom'}  = $udom;
-	$ENV{'form.fullname'} = $$fullname{$_};
+	$env{'form.student'}  = $uname;
+	$env{'form.userdom'}  = $udom;
+	$env{'form.fullname'} = $$fullname{$_};
 	&submission($request,$ctr,$total);
 	$ctr++;
     }
@@ -2110,23 +2110,23 @@
 sub saveHandGrade {
     my ($request,$url,$symb,$stuname,$domain,$newflg,$submitter,$part) = @_;
     my $usec = &Apache::lonnet::getsection($domain,$stuname,
-					   $ENV{'request.course.id'});
+					   $env{'request.course.id'});
     if (!&canmodify($usec)) { return('not_allowed'); }
-    my %record     = &Apache::lonnet::restore($symb,$ENV{'request.course.id'},$domain,$stuname);
+    my %record     = &Apache::lonnet::restore($symb,$env{'request.course.id'},$domain,$stuname);
     my @parts_graded;
     my %newrecord  = ();
     my ($pts,$wgt) = ('','');
-    foreach (split(/:/,$ENV{'form.partlist'.$newflg})) {
+    foreach (split(/:/,$env{'form.partlist'.$newflg})) {
 	#collaborator may vary for different parts
 	if ($submitter && $_ ne $part) { next; }
-	my $dropMenu = $ENV{'form.GD_SEL'.$newflg.'_'.$_};
+	my $dropMenu = $env{'form.GD_SEL'.$newflg.'_'.$_};
 	if ($dropMenu eq 'excused') {
 	    if ($record{'resource.'.$_.'.solved'} ne 'excused') {
 		$newrecord{'resource.'.$_.'.solved'} = 'excused';
 		if (exists($record{'resource.'.$_.'.awarded'})) {
 		    $newrecord{'resource.'.$_.'.awarded'} = '';
 		}
-	    $newrecord{'resource.'.$_.'.regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}";
+	    $newrecord{'resource.'.$_.'.regrader'}="$env{'user.name'}:$env{'user.domain'}";
 	    }
 	} elsif ($dropMenu eq 'reset status'
 		 && exists($record{'resource.'.$_.'.solved'})) { #don't bother if no old records -> no attempts
@@ -2134,16 +2134,16 @@
 		if ($key=~/^resource\.\Q$_\E\./) { $newrecord{$key} = ''; }
 	    }
 	    $newrecord{'resource.'.$_.'.regrader'}=
-		"$ENV{'user.name'}:$ENV{'user.domain'}";
+		"$env{'user.name'}:$env{'user.domain'}";
 	} elsif ($dropMenu eq '') {
-	    $pts = ($ENV{'form.GD_BOX'.$newflg.'_'.$_} ne '' ? 
-		    $ENV{'form.GD_BOX'.$newflg.'_'.$_} : 
-		    $ENV{'form.RADVAL'.$newflg.'_'.$_});
-	    if ($pts eq '' && $ENV{'form.GD_SEL'.$newflg.'_'.$_} eq '') {
+	    $pts = ($env{'form.GD_BOX'.$newflg.'_'.$_} ne '' ? 
+		    $env{'form.GD_BOX'.$newflg.'_'.$_} : 
+		    $env{'form.RADVAL'.$newflg.'_'.$_});
+	    if ($pts eq '' && $env{'form.GD_SEL'.$newflg.'_'.$_} eq '') {
 		next;
 	    }
-	    $wgt = $ENV{'form.WGT'.$newflg.'_'.$_} eq '' ? 1 : 
-		$ENV{'form.WGT'.$newflg.'_'.$_};
+	    $wgt = $env{'form.WGT'.$newflg.'_'.$_} eq '' ? 1 : 
+		$env{'form.WGT'.$newflg.'_'.$_};
 	    my $partial= $pts/$wgt;
 	    if ($partial eq $record{'resource.'.$_.'.awarded'}) {
 		#do not update score for part if not changed.
@@ -2169,13 +2169,13 @@
 		$newrecord{'resource.'.$_.'.submitted_by'} = $submitter;
 	    }
 	    $newrecord{'resource.'.$_.'.regrader'}=
-		"$ENV{'user.name'}:$ENV{'user.domain'}";
+		"$env{'user.name'}:$env{'user.domain'}";
 	}
     }
     if (scalar(keys(%newrecord)) > 0) {
-        &version_portfiles(\%record, \@parts_graded, $ENV{'request.course.id'}, $symb, $domain, $stuname);
+        &version_portfiles(\%record, \@parts_graded, $env{'request.course.id'}, $symb, $domain, $stuname);
 	&Apache::lonnet::cstore(\%newrecord,$symb,
-				$ENV{'request.course.id'},$domain,$stuname);
+				$env{'request.course.id'},$domain,$stuname);
     }
     return '',$pts,$wgt;
 }
@@ -2403,16 +2403,16 @@
     my ($request) = shift;
     &viewgrades_js($request);
 
-    my ($symb,$url) = ($ENV{'form.symb'},$ENV{'form.url'}); 
+    my ($symb,$url) = ($env{'form.symb'},$env{'form.url'}); 
     #need to make sure we have the correct data for later EXT calls, 
     #thus invalidate the cache
     &Apache::lonnet::devalidatecourseresdata(
-                 $ENV{'course.'.$ENV{'request.course.id'}.'.num'},
-                 $ENV{'course.'.$ENV{'request.course.id'}.'.domain'});
+                 $env{'course.'.$env{'request.course.id'}.'.num'},
+                 $env{'course.'.$env{'request.course.id'}.'.domain'});
     &Apache::lonnet::clear_EXT_cache_status();
 
     my $result='<h3><font color="#339933">'.&mt('Manual Grading').'</font></h3>';
-    $result.='<font size=+1><b>Current Resource: </b>'.$ENV{'form.probTitle'}.'</font>'."\n";
+    $result.='<font size=+1><b>Current Resource: </b>'.$env{'form.probTitle'}.'</font>'."\n";
 
     #view individual student submission form - called using Javascript viewOneStudent
     $result.=&jscriptNform($url,$symb);
@@ -2422,18 +2422,18 @@
 	'<input type="hidden" name="symb"    value="'.$symb.'" />'."\n".
 	'<input type="hidden" name="url"     value="'.$url.'" />'."\n".
 	'<input type="hidden" name="command" value="editgrades" />'."\n".
-	'<input type="hidden" name="section" value="'.$ENV{'form.section'}.'" />'."\n".
-	'<input type="hidden" name="saveState" value="'.$ENV{'form.saveState'}.'" />'."\n".
-	'<input type="hidden" name="Status" value="'.$ENV{'form.Status'}.'" />'."\n".
-	'<input type="hidden" name="probTitle" value="'.$ENV{'form.probTitle'}.'" />'."\n";
+	'<input type="hidden" name="section" value="'.$env{'form.section'}.'" />'."\n".
+	'<input type="hidden" name="saveState" value="'.$env{'form.saveState'}.'" />'."\n".
+	'<input type="hidden" name="Status" value="'.$env{'form.Status'}.'" />'."\n".
+	'<input type="hidden" name="probTitle" value="'.$env{'form.probTitle'}.'" />'."\n";
 
     my $sectionClass;
-    if ($ENV{'form.section'} eq 'all') {
+    if ($env{'form.section'} eq 'all') {
 	$sectionClass='Class </h3>';
-    } elsif ($ENV{'form.section'} eq 'none') {
+    } elsif ($env{'form.section'} eq 'none') {
 	$sectionClass='Students in no Section </h3>';
     } else {
-	$sectionClass='Students in Section '.$ENV{'form.section'}.'</h3>';
+	$sectionClass='Students in Section '.$env{'form.section'}.'</h3>';
     }
     $result.='<h3>Assign Common Grade To '.$sectionClass;
     $result.= '<table border=0><tr><td bgcolor="#777777">'."\n".
@@ -2513,11 +2513,11 @@
 
     #get info for each student
     #list all the students - with points and grade status
-    my (undef,undef,$fullname) = &getclasslist($ENV{'form.section'},'1');
+    my (undef,undef,$fullname) = &getclasslist($env{'form.section'},'1');
     my $ctr = 0;
     foreach (sort {lc($$fullname{$a}) cmp lc($$fullname{$b}) } keys %$fullname) {
 	$ctr++;
-	$result.=&viewstudentgrade($url,$symb,$ENV{'request.course.id'},
+	$result.=&viewstudentgrade($url,$symb,$env{'request.course.id'},
 				   $_,$$fullname{$_},\@parts,\%weight,$ctr);
     }
     $result.='</table></td></tr></table>';
@@ -2526,8 +2526,8 @@
 	'onClick="javascript:submit();" TARGET=_self /></form>'."\n";
     if (scalar(%$fullname) eq 0) {
 	my $colspan=3+scalar(@parts);
-	$result='<font color="red">There are no students in section "'.$ENV{'form.section'}.
-	    '" with enrollment status "'.$ENV{'form.Status'}.'" to modify or grade.</font>';
+	$result='<font color="red">There are no students in section "'.$env{'form.section'}.
+	    '" with enrollment status "'.$env{'form.Status'}.'" to modify or grade.</font>';
     }
     $result.=&show_grading_menu_form($symb,$url);
     return $result;
@@ -2544,7 +2544,7 @@
 	"\n".$ctr.'&nbsp;</td><td>&nbsp;'.
 	'<a href="javascript:viewOneStudent(\''.$uname.'\',\''.$udom.
 	'\')"; TARGET=_self>'.$fullname.'</a> '.
-	'<font color="#999999">('.$uname.($ENV{'user.domain'} eq $udom ? '' : ':'.$udom).')</font></td>'."\n";
+	'<font color="#999999">('.$uname.($env{'user.domain'} eq $udom ? '' : ':'.$udom).')</font></td>'."\n";
     foreach my $apart (@$parts) {
 	my ($part,$type) = &split_part_type($apart);
 	my $score=$record{"resource.$part.$type"};
@@ -2587,11 +2587,11 @@
 sub editgrades {
     my ($request) = @_;
 
-    my $symb=$ENV{'form.symb'};
-    my $url =$ENV{'form.url'};
+    my $symb=$env{'form.symb'};
+    my $url =$env{'form.url'};
     my $title='<h3><font color="#339933">Current Grade Status</font></h3>';
-    $title.='<font size=+1><b>Current Resource: </b>'.$ENV{'form.probTitle'}.'</font><br />'."\n";
-    $title.='<font size=+1><b>Section: </b>'.$ENV{'form.section'}.'</font>'."\n";
+    $title.='<font size=+1><b>Current Resource: </b>'.$env{'form.probTitle'}.'</font><br />'."\n";
+    $title.='<font size=+1><b>Section: </b>'.$env{'form.section'}.'</font>'."\n";
 
     my $result= '<table border="0"><tr><td bgcolor="#777777">'."\n";
     $result.= '<table border="0"><tr bgcolor="#deffff">'.
@@ -2605,7 +2605,7 @@
 		    'ungraded' =>'ungraded_attempted',
 		    'nothing'  => '',
 		    );
-    my ($classlist,undef,$fullname) = &getclasslist($ENV{'form.section'},'0');
+    my ($classlist,undef,$fullname) = &getclasslist($env{'form.section'},'0');
 
     my (@partid);
     my %weight = ();
@@ -2614,10 +2614,10 @@
 
     my (@parts) = sort(&getpartlist($url,$symb));
     my $header;
-    while ($ctr < $ENV{'form.totalparts'}) {
-	my $partid = $ENV{'form.partid_'.$ctr};
+    while ($ctr < $env{'form.totalparts'}) {
+	my $partid = $env{'form.partid_'.$ctr};
 	push @partid,$partid;
-	$weight{$partid} = $ENV{'form.weight_'.$partid};
+	$weight{$partid} = $env{'form.weight_'.$partid};
 	$ctr++;
     }
     foreach my $partid (@partid) {
@@ -2648,9 +2648,9 @@
     $result .= '</tr>'."\n";
     my $noupdate;
     my ($updateCtr,$noupdateCtr) = (1,1);
-    for ($i=0; $i<$ENV{'form.total'}; $i++) {
+    for ($i=0; $i<$env{'form.total'}; $i++) {
 	my $line;
-	my $user = $ENV{'form.ctr'.$i};
+	my $user = $env{'form.ctr'.$i};
 	my $usercolon = $user;
 	$usercolon =~s/_/:/;
 	my ($uname,$udom)=split(/_/,$user);
@@ -2664,23 +2664,23 @@
 	    next;
 	}
 	foreach (@partid) {
-	    my $old_aw    = $ENV{'form.GD_'.$user.'_'.$_.'_awarded_s'};
+	    my $old_aw    = $env{'form.GD_'.$user.'_'.$_.'_awarded_s'};
 	    my $old_part_pcr = $old_aw/($weight{$_} ne '0' ? $weight{$_}:1);
 	    my $old_part  = $old_aw eq '' ? '' : $old_part_pcr;
-	    my $old_score = $scoreptr{$ENV{'form.GD_'.$user.'_'.$_.'_solved_s'}};
+	    my $old_score = $scoreptr{$env{'form.GD_'.$user.'_'.$_.'_solved_s'}};
 
-	    my $awarded   = $ENV{'form.GD_'.$user.'_'.$_.'_awarded'};
+	    my $awarded   = $env{'form.GD_'.$user.'_'.$_.'_awarded'};
 	    my $pcr       = $awarded/($weight{$_} ne '0' ? $weight{$_} : 1);
 	    my $partial   = $awarded eq '' ? '' : $pcr;
 	    my $score;
 	    if ($partial eq '') {
-		$score = $scoreptr{$ENV{'form.GD_'.$user.'_'.$_.'_solved_s'}};
+		$score = $scoreptr{$env{'form.GD_'.$user.'_'.$_.'_solved_s'}};
 	    } elsif ($partial > 0) {
 		$score = 'correct_by_override';
 	    } elsif ($partial == 0) {
 		$score = 'incorrect_by_override';
 	    }
-	    my $dropMenu = $ENV{'form.GD_'.$user.'_'.$_.'_solved'};
+	    my $dropMenu = $env{'form.GD_'.$user.'_'.$_.'_solved'};
 	    $score = 'excused' if (($dropMenu eq 'excused') && ($score ne 'excused'));
 
 	    if ($dropMenu eq 'reset status' &&
@@ -2689,7 +2689,7 @@
 		$newrecord{'resource.'.$_.'.solved'} = '';
 		$newrecord{'resource.'.$_.'.award'} = '';
 		$newrecord{'resource.'.$_.'.awarded'} = 0;
-		$newrecord{'resource.'.$_.'.regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}";
+		$newrecord{'resource.'.$_.'.regrader'}="$env{'user.name'}:$env{'user.domain'}";
 		$updateflag = 1;
 	    } elsif (!($old_part eq $partial && $old_score eq $score)) {
 		$updateflag = 1;
@@ -2708,11 +2708,11 @@
 		my ($part,$type) = &split_part_type($stores);
 		if ($part !~ m/^\Q$partid\E/) { next;}
 		if ($type eq 'awarded' || $type eq 'solved') { next; }
-		my $old_aw    = $ENV{'form.GD_'.$user.'_'.$part.'_'.$type.'_s'};
-		my $awarded   = $ENV{'form.GD_'.$user.'_'.$part.'_'.$type};
+		my $old_aw    = $env{'form.GD_'.$user.'_'.$part.'_'.$type.'_s'};
+		my $awarded   = $env{'form.GD_'.$user.'_'.$part.'_'.$type};
 		if ($awarded ne '' && $awarded ne $old_aw) {
 		    $newrecord{'resource.'.$part.'.'.$type}= $awarded;
-		    $newrecord{'resource.'.$part.'.regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}";
+		    $newrecord{'resource.'.$part.'.regrader'}="$env{'user.name'}:$env{'user.domain'}";
 		    $updateflag=1;
 		}
 		$line .= '<td align="center">'.$old_aw.'&nbsp;</td>'.
@@ -2722,7 +2722,7 @@
 	$line.='</tr>'."\n";
 	if ($updateflag) {
 	    $count++;
-	    &Apache::lonnet::cstore(\%newrecord,$symb,$ENV{'request.course.id'},
+	    &Apache::lonnet::cstore(\%newrecord,$symb,$env{'request.course.id'},
 				    $udom,$uname);
 	    $result.='<tr bgcolor="#ffffde"><td align="right">&nbsp;'.$updateCtr.'&nbsp;</td>'.$line;
 	    $updateCtr++;
@@ -2740,7 +2740,7 @@
 	&show_grading_menu_form ($symb,$url);
     my $msg = '<br /><b>Number of records updated = '.$rec_update.
 	' for '.$count.' student'.($count <= 1 ? '' : 's').'.</b><br />'.
-	'<b>Total number of students = '.$ENV{'form.total'}.'</b><br />';
+	'<b>Total number of students = '.$env{'form.total'}.'</b><br />';
     return $title.$msg.$result;
 }
 
@@ -2842,14 +2842,14 @@
 sub csvuploadmap_header {
     my ($request,$symb,$url,$datatoken,$distotal)= @_;
     my $javascript;
-    if ($ENV{'form.upfile_associate'} eq 'reverse') {
+    if ($env{'form.upfile_associate'} eq 'reverse') {
 	$javascript=&csvupload_javascript_reverse_associate();
     } else {
 	$javascript=&csvupload_javascript_forward_associate();
     }
 
-    my ($result) = &showResourceInfo($url,$ENV{'form.probTitle'});
-    my $checked=(($ENV{'form.noFirstLine'})?' checked="checked"':'');
+    my ($result) = &showResourceInfo($url,$env{'form.probTitle'});
+    my $checked=(($env{'form.noFirstLine'})?' checked="checked"':'');
     my $ignore=&mt('Ignore First Line');
     $request->print(<<ENDPICK);
 <form method="post" enctype="multipart/form-data" action="/adm/grades" name="gradesupload">
@@ -2865,14 +2865,14 @@
 <input type="hidden" name="associate"  value="" />
 <input type="hidden" name="phase"      value="three" />
 <input type="hidden" name="datatoken"  value="$datatoken" />
-<input type="hidden" name="fileupload" value="$ENV{'form.fileupload'}" />
-<input type="hidden" name="upfiletype" value="$ENV{'form.upfiletype'}" />
+<input type="hidden" name="fileupload" value="$env{'form.fileupload'}" />
+<input type="hidden" name="upfiletype" value="$env{'form.upfiletype'}" />
 <input type="hidden" name="upfile_associate" 
-                                       value="$ENV{'form.upfile_associate'}" />
+                                       value="$env{'form.upfile_associate'}" />
 <input type="hidden" name="symb"       value="$symb" />
 <input type="hidden" name="url"        value="$url" />
-<input type="hidden" name="saveState"  value="$ENV{'form.saveState'}" />
-<input type="hidden" name="probTitle"  value="$ENV{'form.probTitle'}" />
+<input type="hidden" name="saveState"  value="$env{'form.saveState'}" />
+<input type="hidden" name="probTitle"  value="$env{'form.probTitle'}" />
 <input type="hidden" name="command"    value="csvuploadoptions" />
 <hr />
 <script type="text/javascript" language="Javascript">
@@ -2929,8 +2929,8 @@
     }
     </script>
 CSVFORMJS
-    $ENV{'form.probTitle'} = &Apache::lonnet::gettitle($symb);
-    my ($table) = &showResourceInfo($url,$ENV{'form.probTitle'});
+    $env{'form.probTitle'} = &Apache::lonnet::gettitle($symb);
+    my ($table) = &showResourceInfo($url,$env{'form.probTitle'});
     $result.=$table;
     $result.='<br /><table width=100% border=0><tr><td bgcolor="#777777">'."\n";
     $result.='<table width=100% border=0><tr bgcolor="#e6ffff"><td>'."\n";
@@ -2944,8 +2944,8 @@
 <input type="hidden" name="symb" value="$symb" />
 <input type="hidden" name="url" value="$url" />
 <input type="hidden" name="command" value="csvuploadmap" />
-<input type="hidden" name="probTitle" value="$ENV{'form.probTitle'}" />
-<input type="hidden" name="saveState"  value="$ENV{'form.saveState'}" />
+<input type="hidden" name="probTitle" value="$env{'form.probTitle'}" />
+<input type="hidden" name="saveState"  value="$env{'form.saveState'}" />
 $upfile_select
 <br /><input type="button" onClick="javascript:checkUpload(this.form);" value="Upload Scores" />
 <label><input type="checkbox" name="noFirstLine" />$ignore</lable>
@@ -2964,20 +2964,20 @@
     if (!$symb) {return '';}
 
     my $datatoken;
-    if (!$ENV{'form.datatoken'}) {
+    if (!$env{'form.datatoken'}) {
 	$datatoken=&Apache::loncommon::upfile_store($request);
     } else {
-	$datatoken=$ENV{'form.datatoken'};
+	$datatoken=$env{'form.datatoken'};
 	&Apache::loncommon::load_tmp_file($request);
     }
     my @records=&Apache::loncommon::upfile_record_sep();
-    if ($ENV{'form.noFirstLine'}) { shift(@records); }
+    if ($env{'form.noFirstLine'}) { shift(@records); }
     &csvuploadmap_header($request,$symb,$url,$datatoken,$#records+1);
     my ($i,$keyfields);
     if (@records) {
 	my @fields=&csvupload_fields($url,$symb);
 
-	if ($ENV{'form.upfile_associate'} eq 'reverse') {	
+	if ($env{'form.upfile_associate'} eq 'reverse') {	
 	    &Apache::loncommon::csv_print_samples($request,\@records);
 	    $i=&Apache::loncommon::csv_print_select_table($request,\@records,
 							  \@fields);
@@ -3000,7 +3000,7 @@
 sub csvuploadoptions {
     my ($request)= @_;
     my ($symb,$url)=&get_symb_and_url($request);
-    my $checked=(($ENV{'form.noFirstLine'})?'1':'0');
+    my $checked=(($env{'form.noFirstLine'})?'1':'0');
     my $ignore=&mt('Ignore First Line');
     $request->print(<<ENDPICK);
 <form method="post" enctype="multipart/form-data" action="/adm/grades" name="gradesupload">
@@ -3022,15 +3022,15 @@
 ENDPICK
     my %fields=&get_fields();
     if (!defined($fields{'domain'})) {
-	my $domform = &Apache::loncommon::select_dom_form($ENV{'request.role.domain'},'default_domain');
+	my $domform = &Apache::loncommon::select_dom_form($env{'request.role.domain'},'default_domain');
 	$request->print("\n<p> Users are in domain: ".$domform."</p>\n");
     }
-    foreach my $key (sort(keys(%ENV))) {
+    foreach my $key (sort(keys(%env))) {
 	if ($key !~ /^form\.(.*)$/) { next; }
 	my $cleankey=$1;
 	if ($cleankey eq 'command') { next; }
 	$request->print('<input type="hidden" name="'.$cleankey.
-			'"  value="'.$ENV{$key}.'" />'."\n");
+			'"  value="'.$env{$key}.'" />'."\n");
     }
     # FIXME do a check for any duplicated user ids...
     # FIXME do a check for any invalid user ids?...
@@ -3041,15 +3041,15 @@
 
 sub get_fields {
     my %fields;
-    my @keyfields = split(/\,/,$ENV{'form.keyfields'});
-    for (my $i=0; $i<=$ENV{'form.nfields'}; $i++) {
-	if ($ENV{'form.upfile_associate'} eq 'reverse') {
-	    if ($ENV{'form.f'.$i} ne 'none') {
-		$fields{$keyfields[$i]}=$ENV{'form.f'.$i};
+    my @keyfields = split(/\,/,$env{'form.keyfields'});
+    for (my $i=0; $i<=$env{'form.nfields'}; $i++) {
+	if ($env{'form.upfile_associate'} eq 'reverse') {
+	    if ($env{'form.f'.$i} ne 'none') {
+		$fields{$keyfields[$i]}=$env{'form.f'.$i};
 	    }
 	} else {
-	    if ($ENV{'form.f'.$i} ne 'none') {
-		$fields{$ENV{'form.f'.$i}}=$keyfields[$i];
+	    if ($env{'form.f'.$i} ne 'none') {
+		$fields{$env{'form.f'.$i}}=$keyfields[$i];
 	    }
 	}
     }
@@ -3062,10 +3062,10 @@
     if (!$symb) {return '';}
     &Apache::loncommon::load_tmp_file($request);
     my @gradedata = &Apache::loncommon::upfile_record_sep();
-    if ($ENV{'form.noFirstLine'}) { shift(@gradedata); }
+    if ($env{'form.noFirstLine'}) { shift(@gradedata); }
     my %fields=&get_fields();
     $request->print('<h3>Assigning Grades</h3>');
-    my $courseid=$ENV{'request.course.id'};
+    my $courseid=$env{'request.course.id'};
     my ($classlist) = &getclasslist('all',0);
     my @notallowed;
     my @skipped;
@@ -3076,7 +3076,7 @@
 	if ($entries{$fields{'domain'}}) {
 	    $domain=$entries{$fields{'domain'}};
 	} else {
-	    $domain=$ENV{'form.default_domain'};
+	    $domain=$env{'form.default_domain'};
 	}
 	$domain=~s/\s//g;
 	my $username=$entries{$fields{'username'}};
@@ -3128,9 +3128,9 @@
 	    }
 	}
 	if (! %grades) { push(@skipped,"$username:$domain no data to store"); }
-	$grades{"resource.regrader"}="$ENV{'user.name'}:$ENV{'user.domain'}";
+	$grades{"resource.regrader"}="$env{'user.name'}:$env{'user.domain'}";
 #	&Apache::lonnet::logthis(" storing ".(join('-',%grades)));
-	&Apache::lonnet::cstore(\%grades,$symb,$ENV{'request.course.id'},
+	&Apache::lonnet::cstore(\%grades,$symb,$env{'request.course.id'},
 				$domain,$username);
 	$request->print('.');
 	$request->rflush();
@@ -3177,9 +3177,9 @@
 LISTJAVASCRIPT
     &commonJSfunctions($request);
     my ($symb,$url) = &get_symb_and_url($request);
-    my $cdom      = $ENV{"course.$ENV{'request.course.id'}.domain"};
-    my $cnum      = $ENV{"course.$ENV{'request.course.id'}.num"};
-    my $getsec    = $ENV{'form.section'} eq '' ? 'all' : $ENV{'form.section'};
+    my $cdom      = $env{"course.$env{'request.course.id'}.domain"};
+    my $cnum      = $env{"course.$env{'request.course.id'}.num"};
+    my $getsec    = $env{'form.section'} eq '' ? 'all' : $env{'form.section'};
 
     my $result='<h3><font color="#339933">&nbsp;'.
 	'Manual Grading by Page or Sequence</font></h3>';
@@ -3218,11 +3218,11 @@
 	'<input type="radio" name="lastSub" value="all" /> all details'."\n";
 
     $result.='<input type="hidden" name="section"     value="'.$getsec.'" />'."\n".
-	'<input type="hidden" name="Status"  value="'.$ENV{'form.Status'}.'" />'."\n".
+	'<input type="hidden" name="Status"  value="'.$env{'form.Status'}.'" />'."\n".
 	'<input type="hidden" name="command" value="displayPage" />'."\n".
 	'<input type="hidden" name="url"     value="'.$url.'" />'."\n".
 	'<input type="hidden" name="symb"    value="'.$symb.'" />'."\n".
-	'<input type="hidden" name="saveState" value="'.$ENV{'form.saveState'}.'" />'."<br />\n";
+	'<input type="hidden" name="saveState" value="'.$env{'form.saveState'}.'" />'."<br />\n";
 
     $result.='&nbsp;<input type="button" '.
 	'onClick="javascript:checkPickOne(this.form);"value="Next->" /><br />'."\n";
@@ -3287,34 +3287,34 @@
     my ($request) = shift;
 
     my ($symb,$url) = &get_symb_and_url($request);
-    my $cdom      = $ENV{"course.$ENV{'request.course.id'}.domain"};
-    my $cnum      = $ENV{"course.$ENV{'request.course.id'}.num"};
-    my $getsec    = $ENV{'form.section'} eq '' ? 'all' : $ENV{'form.section'};
-    my $pageTitle = $ENV{'form.page'};
+    my $cdom      = $env{"course.$env{'request.course.id'}.domain"};
+    my $cnum      = $env{"course.$env{'request.course.id'}.num"};
+    my $getsec    = $env{'form.section'} eq '' ? 'all' : $env{'form.section'};
+    my $pageTitle = $env{'form.page'};
     my ($classlist,undef,$fullname) = &getclasslist($getsec,'1');
-    my ($uname,$udom) = split(/:/,$ENV{'form.student'});
-    my $usec=$classlist->{$ENV{'form.student'}}[5];
+    my ($uname,$udom) = split(/:/,$env{'form.student'});
+    my $usec=$classlist->{$env{'form.student'}}[5];
 
     #need to make sure we have the correct data for later EXT calls, 
     #thus invalidate the cache
     &Apache::lonnet::devalidatecourseresdata(
-                 $ENV{'course.'.$ENV{'request.course.id'}.'.num'},
-                 $ENV{'course.'.$ENV{'request.course.id'}.'.domain'});
+                 $env{'course.'.$env{'request.course.id'}.'.num'},
+                 $env{'course.'.$env{'request.course.id'}.'.domain'});
     &Apache::lonnet::clear_EXT_cache_status();
 
     if (!&canview($usec)) {
-	$request->print('<font color="red">Unable to view requested student.('.$ENV{'form.student'}.')</font>');
+	$request->print('<font color="red">Unable to view requested student.('.$env{'form.student'}.')</font>');
 	$request->print(&show_grading_menu_form($symb,$url));
 	return;
     }
-    my $result='<h3><font color="#339933">&nbsp;'.$ENV{'form.title'}.'</font></h3>';
-    $result.='<h3>&nbsp;Student: '.&nameUserString(undef,$$fullname{$ENV{'form.student'}},$uname,$udom).
+    my $result='<h3><font color="#339933">&nbsp;'.$env{'form.title'}.'</font></h3>';
+    $result.='<h3>&nbsp;Student: '.&nameUserString(undef,$$fullname{$env{'form.student'}},$uname,$udom).
 	'</h3>'."\n";
     &sub_page_js($request);
     $request->print($result);
 
     my $navmap = Apache::lonnavmaps::navmap->new();
-    my ($mapUrl, $id, $resUrl)=&Apache::lonnet::decode_symb($ENV{'form.page'});
+    my ($mapUrl, $id, $resUrl)=&Apache::lonnet::decode_symb($env{'form.page'});
     my $map = $navmap->getResourceByUrl($resUrl); # add to navmaps
 
     my $iterator = $navmap->getIterator($map->map_start(),
@@ -3322,14 +3322,14 @@
 
     my $studentTable='<form action="/adm/grades" method="post" name="gradePage">'."\n".
 	'<input type="hidden" name="command" value="gradeByPage" />'."\n".
-	'<input type="hidden" name="fullname" value="'.$$fullname{$ENV{'form.student'}}.'" />'."\n".
-	'<input type="hidden" name="student" value="'.$ENV{'form.student'}.'" />'."\n".
+	'<input type="hidden" name="fullname" value="'.$$fullname{$env{'form.student'}}.'" />'."\n".
+	'<input type="hidden" name="student" value="'.$env{'form.student'}.'" />'."\n".
 	'<input type="hidden" name="page"    value="'.$pageTitle.'" />'."\n".
-	'<input type="hidden" name="title"   value="'.$ENV{'form.title'}.'" />'."\n".
+	'<input type="hidden" name="title"   value="'.$env{'form.title'}.'" />'."\n".
 	'<input type="hidden" name="url"     value="'.$url.'" />'."\n".
 	'<input type="hidden" name="symb"    value="'.$symb.'" />'."\n".
 	'<input type="hidden" name="overRideScore" value="no" />'."\n".
-	'<input type="hidden" name="saveState" value="'.$ENV{'form.saveState'}.'" />'."\n";
+	'<input type="hidden" name="saveState" value="'.$env{'form.saveState'}.'" />'."\n";
 
     my $checkIcon = '<img src="'.$request->dir_config('lonIconsURL').
 	'/check.gif" height="16" border="0" />';
@@ -3339,7 +3339,7 @@
 	'<table border="0"><tr><td bgcolor="#777777">'.
 	'<table border="0"><tr bgcolor="#e6ffff">'.
 	'<td align="center"><b>&nbsp;Prob.&nbsp;</b></td>'.
-	'<td><b>&nbsp;'.($ENV{'form.vProb'} eq 'no' ? 'Title' : 'Problem Text').'/Grade</b></td></tr>';
+	'<td><b>&nbsp;'.($env{'form.vProb'} eq 'no' ? 'Title' : 'Problem Text').'/Grade</b></td></tr>';
 
     my ($depth,$question,$prob) = (1,1,1);
     $iterator->next(); # skip the first BEGIN_MAP
@@ -3355,11 +3355,11 @@
 	    $studentTable.='<tr bgcolor="#ffffe6"><td align="center" valign="top" >'.$prob.
 		(scalar(@{$parts}) == 1 ? '' : '<br>('.scalar(@{$parts}).'&nbsp;parts)').'</td>';
 	    $studentTable.='<td valign="top">';
-	    if ($ENV{'form.vProb'} eq 'yes' ) {
+	    if ($env{'form.vProb'} eq 'yes' ) {
 		$studentTable.=&show_problem($request,$symbx,$uname,$udom,1,
 					     undef,'both');
 	    } else {
-		my $companswer = &Apache::loncommon::get_student_answers($symbx,$uname,$udom,$ENV{'request.course.id'});
+		my $companswer = &Apache::loncommon::get_student_answers($symbx,$uname,$udom,$env{'request.course.id'});
 		$companswer =~ s|<form(.*?)>||g;
 		$companswer =~ s|</form>||g;
 #		while ($companswer =~ /(<a href\=\"javascript:newWindow.*?Script Vars<\/a>)/s) { #<a href="javascript:newWindow</a>
@@ -3370,9 +3370,9 @@
 		$studentTable.='&nbsp;<b>'.$title.'</b>&nbsp;<br>&nbsp;<b>Correct answer:</b><br>'.$companswer;
 	    }
 
-	    my %record = &Apache::lonnet::restore($symbx,$ENV{'request.course.id'},$udom,$uname);
+	    my %record = &Apache::lonnet::restore($symbx,$env{'request.course.id'},$udom,$uname);
 
-	    if ($ENV{'form.lastSub'} eq 'datesub') {
+	    if ($env{'form.lastSub'} eq 'datesub') {
 		if ($record{'version'} eq '') {
 		    $studentTable.='<br />&nbsp;<font color="red">No recorded submission for this problem</font><br />';
 		} else {
@@ -3389,10 +3389,10 @@
 		    $studentTable.= &displaySubByDates($symbx,\%record,$parts,\%responseType,$checkIcon,$uname,$udom);
 
 		}
-	    } elsif ($ENV{'form.lastSub'} eq 'all') {
-		my $last = ($ENV{'form.lastSub'} eq 'last' ? 'last' : '');
+	    } elsif ($env{'form.lastSub'} eq 'all') {
+		my $last = ($env{'form.lastSub'} eq 'last' ? 'last' : '');
 		$studentTable.=&Apache::loncommon::get_previous_attempt($symbx,$uname,$udom,
-									$ENV{'request.course.id'},
+									$env{'request.course.id'},
 									'','.submission');
  
 	    }
@@ -3501,26 +3501,26 @@
 sub updateGradeByPage {
     my ($request) = shift;
 
-    my $cdom      = $ENV{"course.$ENV{'request.course.id'}.domain"};
-    my $cnum      = $ENV{"course.$ENV{'request.course.id'}.num"};
-    my $getsec    = $ENV{'form.section'} eq '' ? 'all' : $ENV{'form.section'};
-    my $pageTitle = $ENV{'form.page'};
+    my $cdom      = $env{"course.$env{'request.course.id'}.domain"};
+    my $cnum      = $env{"course.$env{'request.course.id'}.num"};
+    my $getsec    = $env{'form.section'} eq '' ? 'all' : $env{'form.section'};
+    my $pageTitle = $env{'form.page'};
     my ($classlist,undef,$fullname) = &getclasslist($getsec,'1');
-    my ($uname,$udom) = split(/:/,$ENV{'form.student'});
-    my $usec=$classlist->{$ENV{'form.student'}}[5];
+    my ($uname,$udom) = split(/:/,$env{'form.student'});
+    my $usec=$classlist->{$env{'form.student'}}[5];
     if (!&canmodify($usec)) {
-	$request->print('<font color="red">Unable to modify requested student.('.$ENV{'form.student'}.'</font>');
-	$request->print(&show_grading_menu_form($ENV{'form.symb'},$ENV{'form.url'}));
+	$request->print('<font color="red">Unable to modify requested student.('.$env{'form.student'}.'</font>');
+	$request->print(&show_grading_menu_form($env{'form.symb'},$env{'form.url'}));
 	return;
     }
-    my $result='<h3><font color="#339933">&nbsp;'.$ENV{'form.title'}.'</font></h3>';
-    $result.='<h3>&nbsp;Student: '.&nameUserString(undef,$ENV{'form.fullname'},$uname,$udom).
+    my $result='<h3><font color="#339933">&nbsp;'.$env{'form.title'}.'</font></h3>';
+    $result.='<h3>&nbsp;Student: '.&nameUserString(undef,$env{'form.fullname'},$uname,$udom).
 	'</h3>'."\n";
 
     $request->print($result);
 
     my $navmap = Apache::lonnavmaps::navmap->new();
-    my ($mapUrl, $id, $resUrl) = &Apache::lonnet::decode_symb( $ENV{'form.page'});
+    my ($mapUrl, $id, $resUrl) = &Apache::lonnet::decode_symb( $env{'form.page'});
     my $map = $navmap->getResourceByUrl($resUrl); # add to navmaps
 
     my $iterator = $navmap->getIterator($map->map_start(),
@@ -3551,11 +3551,11 @@
 	    my %newrecord=();
 	    my @displayPts=();
 	    foreach my $partid (@{$parts}) {
-		my $newpts = $ENV{'form.GD_BOX'.$question.'_'.$partid};
-		my $oldpts = $ENV{'form.oldpts'.$question.'_'.$partid};
+		my $newpts = $env{'form.GD_BOX'.$question.'_'.$partid};
+		my $oldpts = $env{'form.oldpts'.$question.'_'.$partid};
 
-		my $wgt = $ENV{'form.WGT'.$question.'_'.$partid} != 0 ? 
-		    $ENV{'form.WGT'.$question.'_'.$partid} : 1;
+		my $wgt = $env{'form.WGT'.$question.'_'.$partid} != 0 ? 
+		    $env{'form.WGT'.$question.'_'.$partid} : 1;
 		my $partial = $newpts/$wgt;
 		my $score;
 		if ($partial > 0) {
@@ -3563,23 +3563,23 @@
 		} elsif ($newpts ne '') { #empty is taken as 0
 		    $score = 'incorrect_by_override';
 		}
-		my $dropMenu = $ENV{'form.GD_SEL'.$question.'_'.$partid};
+		my $dropMenu = $env{'form.GD_SEL'.$question.'_'.$partid};
 		if ($dropMenu eq 'excused') {
 		    $partial = '';
 		    $score = 'excused';
 		} elsif ($dropMenu eq 'reset status'
-			 && $ENV{'form.solved'.$question.'_'.$partid} ne '') { #update only if previous record exists
+			 && $env{'form.solved'.$question.'_'.$partid} ne '') { #update only if previous record exists
 		    $newrecord{'resource.'.$partid.'.tries'} = 0;
 		    $newrecord{'resource.'.$partid.'.solved'} = '';
 		    $newrecord{'resource.'.$partid.'.award'} = '';
 		    $newrecord{'resource.'.$partid.'.awarded'} = 0;
-		    $newrecord{'resource.'.$partid.'.regrader'} = "$ENV{'user.name'}:$ENV{'user.domain'}";
+		    $newrecord{'resource.'.$partid.'.regrader'} = "$env{'user.name'}:$env{'user.domain'}";
 		    $changeflag++;
 		    $newpts = '';
 		}
 		my $display_part=&get_display_part($partid,undef,
 						   $curRes->symb());
-		my $oldstatus = $ENV{'form.solved'.$question.'_'.$partid};
+		my $oldstatus = $env{'form.solved'.$question.'_'.$partid};
 		$displayPts[0].='&nbsp;<b>Part:</b> '.$display_part.' = '.
 		    (($oldstatus eq 'excused') ? 'excused' : $oldpts).
 		    '&nbsp;<br>';
@@ -3592,13 +3592,13 @@
 
 		$newrecord{'resource.'.$partid.'.awarded'}  = $partial if $partial ne '';
 		$newrecord{'resource.'.$partid.'.solved'}   = $score if $score ne '';
-		$newrecord{'resource.'.$partid.'.regrader'} = "$ENV{'user.name'}:$ENV{'user.domain'}"
+		$newrecord{'resource.'.$partid.'.regrader'} = "$env{'user.name'}:$env{'user.domain'}"
 		    if (scalar(keys(%newrecord)) > 0);
 
 		$changeflag++;
 	    }
 	    if (scalar(keys(%newrecord)) > 0) {
-		&Apache::lonnet::cstore(\%newrecord,$symbx,$ENV{'request.course.id'},
+		&Apache::lonnet::cstore(\%newrecord,$symbx,$env{'request.course.id'},
 					$udom,$uname);
 	    }
 
@@ -3612,7 +3612,7 @@
     }
 
     $studentTable.='</td></tr></table></td></tr></table>';
-    $studentTable.=&show_grading_menu_form($ENV{'form.symb'},$ENV{'form.url'});
+    $studentTable.=&show_grading_menu_form($env{'form.symb'},$env{'form.url'});
     my $grademsg=($changeflag == 0 ? 'No score was changed or updated.' :
 		  'The scores were changed for '.
 		  $changeflag.' problem'.($changeflag == 1 ? '.' : 's.'));
@@ -3634,8 +3634,8 @@
     return '
       <input type="hidden" name="symb"    value="'.$symb.'" />'."\n".
      '<input type="hidden" name="url"     value="'.$url.'" />'."\n".
-     '<input type="hidden" name="saveState" value="'.$ENV{'form.saveState'}.'" />'."\n".
-     '<input type="hidden" name="probTitle" value="'.$ENV{'form.probTitle'}.'" />'."\n";
+     '<input type="hidden" name="saveState" value="'.$env{'form.saveState'}.'" />'."\n".
+     '<input type="hidden" name="probTitle" value="'.$env{'form.probTitle'}.'" />'."\n";
 }
 
 sub getSequenceDropDown {
@@ -3656,8 +3656,8 @@
 }
 
 sub scantron_filenames {
-    my $cdom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
-    my $cname=$ENV{'course.'.$ENV{'request.course.id'}.'.num'};
+    my $cdom=$env{'course.'.$env{'request.course.id'}.'.domain'};
+    my $cname=$env{'course.'.$env{'request.course.id'}.'.num'};
     my @files=&Apache::lonnet::dirlist('userfiles',$cdom,$cname,
 				    &Apache::loncommon::propath($cdom,$cname));
     my @possiblenames;
@@ -3696,8 +3696,8 @@
 }
 
 sub scantron_CODElist {
-    my $cdom = $ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
-    my $cnum = $ENV{'course.'.$ENV{'request.course.id'}.'.num'};
+    my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+    my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
     my @names=&Apache::lonnet::getkeys('CODEs',$cdom,$cnum);
     my $namechoice='<option></option>';
     foreach my $name (sort {uc($a) cmp uc($b)} @names) {
@@ -3782,8 +3782,8 @@
    
     $r->print($result);
 
-    if (&Apache::lonnet::allowed('usc',$ENV{'request.role.domain'}) ||
-        &Apache::lonnet::allowed('usc',$ENV{'request.course.id'})) {
+    if (&Apache::lonnet::allowed('usc',$env{'request.role.domain'}) ||
+        &Apache::lonnet::allowed('usc',$env{'request.course.id'})) {
 
         $r->print(<<SCANTRONFORM);
     <tr>
@@ -3798,8 +3798,8 @@
             <td>
 SCANTRONFORM
     my $default_form_data=&defaultFormData(&get_symb_and_url($r,1));
-    my $cdom= $ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
-    my $cnum= $ENV{'course.'.$ENV{'request.course.id'}.'.num'};
+    my $cdom= $env{'course.'.$env{'request.course.id'}.'.domain'};
+    my $cnum= $env{'course.'.$env{'request.course.id'}.'.num'};
     $r->print(<<UPLOAD);
               <script type="text/javascript" language="javascript">
     function checkUpload(formname) {
@@ -3957,7 +3957,7 @@
 
 sub scan_data {
     my ($scan_data,$key,$value,$delete)=@_;
-    my $filename=$ENV{'form.scantron_selectfile'};
+    my $filename=$env{'form.scantron_selectfile'};
     if (defined($value)) {
 	$scan_data->{$filename.'_'.$key} = $value;
     }
@@ -4086,50 +4086,50 @@
 
 sub scantron_process_corrections {
     my ($r) = @_;
-    my %scantron_config=&get_scantron_config($ENV{'form.scantron_format'});
+    my %scantron_config=&get_scantron_config($env{'form.scantron_format'});
     my ($scanlines,$scan_data)=&scantron_getfile();
     my $classlist=&Apache::loncoursedata::get_classlist();
-    my $which=$ENV{'form.scantron_line'};
+    my $which=$env{'form.scantron_line'};
     my $line=&scantron_get_line($scanlines,$scan_data,$which);
     my ($skip,$err,$errmsg);
-    if ($ENV{'form.scantron_skip_record'}) {
+    if ($env{'form.scantron_skip_record'}) {
 	$skip=1;
-    } elsif ($ENV{'form.scantron_corrections'} =~ /^(duplicate|incorrect)ID$/) {
-	my $newstudent=$ENV{'form.scantron_username'}.':'.
-	    $ENV{'form.scantron_domain'};
+    } elsif ($env{'form.scantron_corrections'} =~ /^(duplicate|incorrect)ID$/) {
+	my $newstudent=$env{'form.scantron_username'}.':'.
+	    $env{'form.scantron_domain'};
 	my $newid=$classlist->{$newstudent}->[&Apache::loncoursedata::CL_ID];
 	($line,$err,$errmsg)=
 	    &scantron_fixup_scanline(\%scantron_config,$scan_data,$line,$which,
 				     'ID',{'newid'=>$newid,
-				    'username'=>$ENV{'form.scantron_username'},
-				    'domain'=>$ENV{'form.scantron_domain'}});
-    } elsif ($ENV{'form.scantron_corrections'} =~ /^(duplicate|incorrect)CODE$/) {
-	my $resolution=$ENV{'form.scantron_CODE_resolution'};
+				    'username'=>$env{'form.scantron_username'},
+				    'domain'=>$env{'form.scantron_domain'}});
+    } elsif ($env{'form.scantron_corrections'} =~ /^(duplicate|incorrect)CODE$/) {
+	my $resolution=$env{'form.scantron_CODE_resolution'};
 	my $newCODE;
 	my %args;
 	if      ($resolution eq 'use_unfound') {
 	    $newCODE='use_unfound';
 	} elsif ($resolution eq 'use_found') {
-	    $newCODE=$ENV{'form.scantron_CODE_selectedvalue'};
+	    $newCODE=$env{'form.scantron_CODE_selectedvalue'};
 	} elsif ($resolution eq 'use_typed') {
-	    $newCODE=$ENV{'form.scantron_CODE_newvalue'};
+	    $newCODE=$env{'form.scantron_CODE_newvalue'};
 	} elsif ($resolution =~ /^use_closest_(\d+)/) {
-	    $newCODE=$ENV{"form.scantron_CODE_closest_$1"};
+	    $newCODE=$env{"form.scantron_CODE_closest_$1"};
 	}
-	if ($ENV{'form.scantron_corrections'} eq 'duplicateCODE') {
+	if ($env{'form.scantron_corrections'} eq 'duplicateCODE') {
 	    $args{'CODE_ignore_dup'}=1;
 	}
 	$args{'CODE'}=$newCODE;
 	($line,$err,$errmsg)=
 	    &scantron_fixup_scanline(\%scantron_config,$scan_data,$line,$which,
 				     'CODE',\%args);
-    } elsif ($ENV{'form.scantron_corrections'} =~ /^(missing|double)bubble$/) {
-	foreach my $question (split(',',$ENV{'form.scantron_questions'})) {
+    } elsif ($env{'form.scantron_corrections'} =~ /^(missing|double)bubble$/) {
+	foreach my $question (split(',',$env{'form.scantron_questions'})) {
 	    ($line,$err,$errmsg)=
 		&scantron_fixup_scanline(\%scantron_config,$scan_data,$line,
 					 $which,'answer',
 					 { 'question'=>$question,
-		       'response'=>$ENV{"form.scantron_correct_Q_$question"}});
+		       'response'=>$env{"form.scantron_correct_Q_$question"}});
 	    if ($err) { last; }
 	}
     }
@@ -4156,7 +4156,7 @@
 
 sub should_be_skipped {
     my ($scan_data,$i)=@_;
-    if ($ENV{'form.scantron_options_redo'} !~ /^redo_/) {
+    if ($env{'form.scantron_options_redo'} !~ /^redo_/) {
 	# not redoing old skips
 	return 0;
     }
@@ -4187,7 +4187,7 @@
 
 sub scantron_warning_screen {
     my ($button_text)=@_;
-    my $title=&Apache::lonnet::gettitle($ENV{'form.selectpage'});
+    my $title=&Apache::lonnet::gettitle($env{'form.selectpage'});
     return (<<STUFF);
 <p>
 <font color="red">Please double check the information
@@ -4195,7 +4195,7 @@
 </p>
 <table>
 <tr><td><b>Sequence To be Graded:</b></td><td>$title</td></tr>
-<tr><td><b>Data File that will be used:</b></td><td><tt>$ENV{'form.scantron_selectfile'}</tt></td></tr>
+<tr><td><b>Data File that will be used:</b></td><td><tt>$env{'form.scantron_selectfile'}</tt></td></tr>
 </table>
 </font>
 <br />
@@ -4212,17 +4212,17 @@
     if (!$symb) {return '';}
     my $default_form_data=&defaultFormData($symb,$url);
     $r->print(&scantron_form_start().$default_form_data);
-    if ( $ENV{'form.selectpage'} eq '' ||
-	 $ENV{'form.scantron_selectfile'} eq '' ||
-	 $ENV{'form.scantron_format'} eq '' ) {
+    if ( $env{'form.selectpage'} eq '' ||
+	 $env{'form.scantron_selectfile'} eq '' ||
+	 $env{'form.scantron_format'} eq '' ) {
 	$r->print("<p>You have forgetten to specify some information. Please go Back and try again.</p>");
-	if ( $ENV{'form.selectpage'} eq '') {
+	if ( $env{'form.selectpage'} eq '') {
 	    $r->print('<p><font color="red">You have not selected a Sequence to grade</font></p>');
 	} 
-	if ( $ENV{'form.scantron_selectfile'} eq '') {
+	if ( $env{'form.scantron_selectfile'} eq '') {
 	    $r->print('<p><font color="red">You have not selected a file that contains the student\'s response data.</font></p>');
 	} 
-	if ( $ENV{'form.scantron_format'} eq '') {
+	if ( $env{'form.scantron_format'} eq '') {
 	    $r->print('<p><font color="red">You have not selected a the format of the student\'s response data.</font></p>');
 	} 
     } else {
@@ -4241,14 +4241,14 @@
     my ($max_bubble)=@_;
     my $result= <<SCANTRONFORM;
 <form method="post" enctype="multipart/form-data" action="/adm/grades" name="scantronupload">
-  <input type="hidden" name="selectpage" value="$ENV{'form.selectpage'}" />
-  <input type="hidden" name="scantron_format" value="$ENV{'form.scantron_format'}" />
-  <input type="hidden" name="scantron_selectfile" value="$ENV{'form.scantron_selectfile'}" />
+  <input type="hidden" name="selectpage" value="$env{'form.selectpage'}" />
+  <input type="hidden" name="scantron_format" value="$env{'form.scantron_format'}" />
+  <input type="hidden" name="scantron_selectfile" value="$env{'form.scantron_selectfile'}" />
   <input type="hidden" name="scantron_maxbubble" value="$max_bubble" />
-  <input type="hidden" name="scantron_CODElist" value="$ENV{'form.scantron_CODElist'}" />
-  <input type="hidden" name="scantron_CODEunique" value="$ENV{'form.scantron_CODEunique'}" />
-  <input type="hidden" name="scantron_options_redo" value="$ENV{'form.scantron_options_redo'}" />
-  <input type="hidden" name="scantron_options_ignore" value="$ENV{'form.scantron_options_ignore'}" />
+  <input type="hidden" name="scantron_CODElist" value="$env{'form.scantron_CODElist'}" />
+  <input type="hidden" name="scantron_CODEunique" value="$env{'form.scantron_CODEunique'}" />
+  <input type="hidden" name="scantron_options_redo" value="$env{'form.scantron_options_redo'}" />
+  <input type="hidden" name="scantron_options_ignore" value="$env{'form.scantron_options_ignore'}" />
 SCANTRONFORM
     return $result;
 }
@@ -4261,23 +4261,23 @@
     
     # do the detection of only doing skipped records first befroe we delete
     # them  when doing the corrections reset
-    if ($ENV{'form.scantron_options_redo'} ne 'redo_skipped_ready') {
+    if ($env{'form.scantron_options_redo'} ne 'redo_skipped_ready') {
 	&reset_skipping_status();
     }
-    if ($ENV{'form.scantron_options_redo'} eq 'redo_skipped') {
+    if ($env{'form.scantron_options_redo'} eq 'redo_skipped') {
 	&remember_current_skipped();
 	&scantron_remove_file('skipped');
-	$ENV{'form.scantron_options_redo'}='redo_skipped_ready';
+	$env{'form.scantron_options_redo'}='redo_skipped_ready';
     }
 
-    if ($ENV{'form.scantron_options_ignore'} eq 'ignore_corrections') {
+    if ($env{'form.scantron_options_ignore'} eq 'ignore_corrections') {
 	&check_for_error($r,&scantron_remove_file('corrected'));
 	&check_for_error($r,&scantron_remove_file('skipped'));
 	&check_for_error($r,&scantron_remove_scan_data());
-	$ENV{'form.scantron_options_ignore'}='done';
+	$env{'form.scantron_options_ignore'}='done';
     }
 
-    if ($ENV{'form.scantron_corrections'}) {
+    if ($env{'form.scantron_corrections'}) {
 	&scantron_process_corrections($r);
     }
     $r->print("<p>Gathering neccessary info.</p>");$r->rflush();
@@ -4291,10 +4291,10 @@
 			  'CODE',
 			  'doublebubble',
 			  'missingbubbles');
-    if (!$ENV{'form.validatepass'}) {
-	$ENV{'form.validatepass'} = 0;
+    if (!$env{'form.validatepass'}) {
+	$env{'form.validatepass'} = 0;
     }
-    my $currentphase=$ENV{'form.validatepass'};
+    my $currentphase=$env{'form.validatepass'};
 
     my $stop=0;
     while (!$stop && $currentphase < scalar(@validate_phases)) {
@@ -4332,27 +4332,27 @@
 
 sub scantron_remove_file {
     my ($which)=@_;
-    my $cname=$ENV{'course.'.$ENV{'request.course.id'}.'.num'};
-    my $cdom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
+    my $cname=$env{'course.'.$env{'request.course.id'}.'.num'};
+    my $cdom=$env{'course.'.$env{'request.course.id'}.'.domain'};
     my $file='scantron_';
     if ($which eq 'corrected' || $which eq 'skipped') {
 	$file.=$which.'_';
     } else {
 	return 'refused';
     }
-    $file.=$ENV{'form.scantron_selectfile'};
+    $file.=$env{'form.scantron_selectfile'};
     return &Apache::lonnet::removeuserfile($cname,$cdom,$file);
 }
 
 sub scantron_remove_scan_data {
-    my $cname=$ENV{'course.'.$ENV{'request.course.id'}.'.num'};
-    my $cdom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
+    my $cname=$env{'course.'.$env{'request.course.id'}.'.num'};
+    my $cdom=$env{'course.'.$env{'request.course.id'}.'.domain'};
     my @keys=&Apache::lonnet::getkeys('nohist_scantrondata',$cdom,$cname);
     my @todelete;
-    my $filename=$ENV{'form.scantron_selectfile'};
+    my $filename=$env{'form.scantron_selectfile'};
     foreach my $key (@keys) {
 	if ($key=~/^\Q$filename\E_/) {
-	    if ($ENV{'form.scantron_options_redo'} eq 'redo_skipped_ready' &&
+	    if ($env{'form.scantron_options_redo'} eq 'redo_skipped_ready' &&
 		$key=~/remember_skipping/) {
 		next;
 	    }
@@ -4368,25 +4368,25 @@
 
 sub scantron_getfile {
     #FIXME really would prefer a scantron directory
-    my $cname=$ENV{'course.'.$ENV{'request.course.id'}.'.num'};
-    my $cdom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
+    my $cname=$env{'course.'.$env{'request.course.id'}.'.num'};
+    my $cdom=$env{'course.'.$env{'request.course.id'}.'.domain'};
     my $lines;
     $lines=&Apache::lonnet::getfile('/uploaded/'.$cdom.'/'.$cname.'/'.
-		       'scantron_orig_'.$ENV{'form.scantron_selectfile'});
+		       'scantron_orig_'.$env{'form.scantron_selectfile'});
     my %scanlines;
     $scanlines{'orig'}=[(split("\n",$lines,-1))];
     my $temp=$scanlines{'orig'};
     $scanlines{'count'}=$#$temp;
 
     $lines=&Apache::lonnet::getfile('/uploaded/'.$cdom.'/'.$cname.'/'.
-		       'scantron_corrected_'.$ENV{'form.scantron_selectfile'});
+		       'scantron_corrected_'.$env{'form.scantron_selectfile'});
     if ($lines eq '-1') {
 	$scanlines{'corrected'}=[];
     } else {
 	$scanlines{'corrected'}=[(split("\n",$lines,-1))];
     }
     $lines=&Apache::lonnet::getfile('/uploaded/'.$cdom.'/'.$cname.'/'.
-		       'scantron_skipped_'.$ENV{'form.scantron_selectfile'});
+		       'scantron_skipped_'.$env{'form.scantron_selectfile'});
     if ($lines eq '-1') {
 	$scanlines{'skipped'}=[];
     } else {
@@ -4400,10 +4400,10 @@
 
 sub lonnet_putfile {
     my ($contents,$filename)=@_;
-    my $docuname=$ENV{'course.'.$ENV{'request.course.id'}.'.num'};
-    my $docudom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
-    my $docuhome=$ENV{'course.'.$ENV{'request.course.id'}.'.home'};
-    $ENV{'form.sillywaytopassafilearound'}=$contents;
+    my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
+    my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
+    my $docuhome=$env{'course.'.$env{'request.course.id'}.'.home'};
+    $env{'form.sillywaytopassafilearound'}=$contents;
     &Apache::lonnet::finishuserfileupload($docuname,$docudom,$docuhome,'sillywaytopassafilearound',$filename);
 
 }
@@ -4411,19 +4411,19 @@
 sub scantron_putfile {
     my ($scanlines,$scan_data) = @_;
     #FIXME really would prefer a scantron directory
-    my $cname=$ENV{'course.'.$ENV{'request.course.id'}.'.num'};
-    my $cdom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
+    my $cname=$env{'course.'.$env{'request.course.id'}.'.num'};
+    my $cdom=$env{'course.'.$env{'request.course.id'}.'.domain'};
     if ($scanlines) {
 	my $prefix='scantron_';
 # no need to update orig, shouldn't change
 #   &lonnet_putfile(join("\n",@{$scanlines->{'orig'}}),$prefix.'orig_'.
-#		    $ENV{'form.scantron_selectfile'});
+#		    $env{'form.scantron_selectfile'});
 	&lonnet_putfile(join("\n",@{$scanlines->{'corrected'}}),
 			$prefix.'corrected_'.
-			$ENV{'form.scantron_selectfile'});
+			$env{'form.scantron_selectfile'});
 	&lonnet_putfile(join("\n",@{$scanlines->{'skipped'}}),
 			$prefix.'skipped_'.
-			$ENV{'form.scantron_selectfile'});
+			$env{'form.scantron_selectfile'});
     }
     &Apache::lonnet::put('nohist_scantrondata',$scan_data,$cdom,$cname);
 }
@@ -4465,7 +4465,7 @@
     my %idmap=&username_to_idmap($classlist);
 
     #get scantron line setup
-    my %scantron_config=&get_scantron_config($ENV{'form.scantron_format'});
+    my %scantron_config=&get_scantron_config($env{'form.scantron_format'});
     my ($scanlines,$scan_data)=&scantron_getfile();
 
     my %found=('ids'=>{},'usernames'=>{});
@@ -4557,7 +4557,7 @@
 				       'scantron_username','scantron_domain'));
 	$r->print(": <input type='text' name='scantron_username' value='' />");
 	$r->print("\n@".
-		 &Apache::loncommon::select_dom_form($ENV{'request.role.domain'},'scantron_domain'));
+		 &Apache::loncommon::select_dom_form($env{'request.role.domain'},'scantron_domain'));
 
 	$r->print('</li>');
     } elsif ($error =~ /CODE$/) {
@@ -4599,10 +4599,10 @@
 ENDSCRIPT
 	my $href="/adm/pickcode?".
 	   "form=".&Apache::lonnet::escape("scantronupload").
-	   "&scantron_format=".&Apache::lonnet::escape($ENV{'form.scantron_format'}).
-	   "&scantron_CODElist=".&Apache::lonnet::escape($ENV{'form.scantron_CODElist'}).
+	   "&scantron_format=".&Apache::lonnet::escape($env{'form.scantron_format'}).
+	   "&scantron_CODElist=".&Apache::lonnet::escape($env{'form.scantron_CODElist'}).
 	   "&curCODE=".&Apache::lonnet::escape($$scan_record{'scantron.CODE'}).
-	   "&scantron_selectfile=".&Apache::lonnet::escape($ENV{'form.scantron_selectfile'});
+	   "&scantron_selectfile=".&Apache::lonnet::escape($env{'form.scantron_selectfile'});
 	$r->print("<input type='radio' name='scantron_CODE_resolution' value='use_found' /> <a target='_blank' href='$href'>Select</a> a CODE from the list of all CODEs and use it. Selected CODE is <input readonly='true' type='text' size='8' name='scantron_CODE_selectedvalue' onfocus=\"javascript:change_radio('use_found')\" onchange=\"javascript:change_radio('use_found')\" />");
 	$r->print("\n<br />");
 	$r->print("<input type='radio' name='scantron_CODE_resolution' value='use_typed' /> Use <input type='text' size='8' name='scantron_CODE_newvalue' onfocus=\"javascript:change_radio('use_typed')\" onkeypress=\"javascript:change_radio('use_typed')\" /> as the CODE.");
@@ -4678,9 +4678,9 @@
 }
 
 sub get_codes {
-    my $old_name=$ENV{'form.scantron_CODElist'};
-    my $cdom =$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
-    my $cnum =$ENV{'course.'.$ENV{'request.course.id'}.'.num'};
+    my $old_name=$env{'form.scantron_CODElist'};
+    my $cdom =$env{'course.'.$env{'request.course.id'}.'.domain'};
+    my $cnum =$env{'course.'.$env{'request.course.id'}.'.num'};
     my %result=&Apache::lonnet::get('CODEs',[$old_name],$cdom,$cnum);
     my %allcodes=map {(&Apache::lonprintout::num_to_letters($_),1)} split(',',$result{$old_name});
     return %allcodes;
@@ -4688,11 +4688,11 @@
 
 sub scantron_validate_CODE {
     my ($r,$currentphase) = @_;
-    my %scantron_config=&get_scantron_config($ENV{'form.scantron_format'});
+    my %scantron_config=&get_scantron_config($env{'form.scantron_format'});
     if ($scantron_config{'CODElocation'} &&
 	$scantron_config{'CODEstart'} &&
 	$scantron_config{'CODElength'}) {
-	if (!defined($ENV{'form.scantron_CODElist'})) {
+	if (!defined($env{'form.scantron_CODElist'})) {
 	    &FIXME_blow_up()
 	}
     } else {
@@ -4725,7 +4725,7 @@
 	    return(1,$currentphase);
 	}
 	if (exists($usedCODEs{$CODE}) 
-	    && $ENV{'form.scantron_CODEunique'} eq 'yes'
+	    && $env{'form.scantron_CODEunique'} eq 'yes'
 	    && !$$scan_record{'scantron.CODE_ignore_dup'}) {
 	    &scantron_get_correction($r,$i,$scan_record,
 				     \%scantron_config,
@@ -4744,7 +4744,7 @@
     my %idmap=&username_to_idmap($classlist);
 
     #get scantron line setup
-    my %scantron_config=&get_scantron_config($ENV{'form.scantron_format'});
+    my %scantron_config=&get_scantron_config($env{'form.scantron_format'});
     my ($scanlines,$scan_data)=&scantron_getfile();
     for (my $i=0;$i<=$scanlines->{'count'};$i++) {
 	my $line=&scantron_get_line($scanlines,$scan_data,$i);
@@ -4762,13 +4762,13 @@
 
 sub scantron_get_maxbubble {
     my ($r)=@_;
-    if (defined($ENV{'form.scantron_maxbubble'}) &&
-	$ENV{'form.scantron_maxbubble'}) {
-	return $ENV{'form.scantron_maxbubble'};
+    if (defined($env{'form.scantron_maxbubble'}) &&
+	$env{'form.scantron_maxbubble'}) {
+	return $env{'form.scantron_maxbubble'};
     }
     my $navmap=Apache::lonnavmaps::navmap->new();
     my (undef,undef,$sequence)=
-	&Apache::lonnet::decode_symb($ENV{'form.selectpage'});
+	&Apache::lonnet::decode_symb($env{'form.selectpage'});
     my $map=$navmap->getResourceByUrl($sequence);
     my @resources=$navmap->retrieveResources($map,\&scantron_filter,1,0);
     &Apache::lonnet::delenv('form.counter');
@@ -4776,13 +4776,13 @@
 	my $result=&Apache::lonnet::ssi($resource->src().'?symb='.&Apache::lonnet::escape($resource->symb()));
     }
     &Apache::lonnet::delenv('scantron\.');
-    my $envfile=$ENV{'user.environment'};
+    my $envfile=$env{'user.environment'};
     $envfile=~/\/([^\/]+)\.id$/;
     $envfile=$1;
     &Apache::lonnet::transfer_profile_to_env($r->dir_config('lonIDsDir'),
 					     $envfile);
-    $ENV{'form.scantron_maxbubble'}=$ENV{'form.counter'}-1;
-    return $ENV{'form.scantron_maxbubble'};
+    $env{'form.scantron_maxbubble'}=$env{'form.counter'}-1;
+    return $env{'form.scantron_maxbubble'};
 }
 
 sub scantron_validate_missingbubbles {
@@ -4792,7 +4792,7 @@
     my %idmap=&username_to_idmap($classlist);
 
     #get scantron line setup
-    my %scantron_config=&get_scantron_config($ENV{'form.scantron_format'});
+    my %scantron_config=&get_scantron_config($env{'form.scantron_format'});
     my ($scanlines,$scan_data)=&scantron_getfile();
     my $max_bubble=&scantron_get_maxbubble();
     if (!$max_bubble) { $max_bubble=2**31; }
@@ -4819,12 +4819,12 @@
 
 sub scantron_process_students {
     my ($r) = @_;
-    my (undef,undef,$sequence)=&Apache::lonnet::decode_symb($ENV{'form.selectpage'});
+    my (undef,undef,$sequence)=&Apache::lonnet::decode_symb($env{'form.selectpage'});
     my ($symb,$url)=&get_symb_and_url($r);
     if (!$symb) {return '';}
     my $default_form_data=&defaultFormData($symb,$url);
 
-    my %scantron_config=&get_scantron_config($ENV{'form.scantron_format'});
+    my %scantron_config=&get_scantron_config($env{'form.scantron_format'});
     my ($scanlines,$scan_data)=&scantron_getfile();
     my $classlist=&Apache::loncoursedata::get_classlist();
     my %idmap=&username_to_idmap($classlist);
@@ -4885,7 +4885,7 @@
 		      'grade_target'  =>'grade',
 		      'grade_username'=>$uname,
 		      'grade_domain'  =>$udom,
-		      'grade_courseid'=>$ENV{'request.course.id'},
+		      'grade_courseid'=>$env{'request.course.id'},
 		      'grade_symb'    =>$resource->symb());
 	    if (exists($scan_record->{'scantron.CODE'}) &&
 		$scan_record->{'scantron.CODE'}) {
@@ -4896,7 +4896,7 @@
 	    my $result=&Apache::lonnet::ssi($resource->src(),%form);
 	    if ($result ne '') {
 		&Apache::lonnet::logthis("scantron grading error -> $result");
-		&Apache::lonnet::logthis("scantron grading error info name $uname domain $udom course $ENV{'request.course.id'} url ".$resource->src());
+		&Apache::lonnet::logthis("scantron grading error info name $uname domain $udom course $env{'request.course.id'} url ".$resource->src());
 	    }
 	    if (&Apache::loncommon::connection_aborted($r)) { last; }
 	}
@@ -4917,11 +4917,11 @@
 
 sub scantron_upload_scantron_data {
     my ($r)=@_;
-    $r->print(&Apache::loncommon::coursebrowser_javascript($ENV{'request.role.domain'}));
+    $r->print(&Apache::loncommon::coursebrowser_javascript($env{'request.role.domain'}));
     my $select_link=&Apache::loncommon::selectcourse_link('rules','courseid',
 							  'domainid',
 							  'coursename');
-    my $domsel=&Apache::loncommon::select_dom_form($ENV{'request.role.domain'},
+    my $domsel=&Apache::loncommon::select_dom_form($env{'request.role.domain'},
 						   'domainid');
     my $default_form_data=&defaultFormData(&get_symb_and_url($r,1));
     $r->print(<<UPLOAD);
@@ -4959,9 +4959,9 @@
 	'<input type="hidden" name="command" value="scantronupload" />'."\n".
 	'<input type="submit" name="submit" value="Do Another Upload" />'."\n".
 	'</form>'."\n";
-    if (!&Apache::lonnet::allowed('usc',$ENV{'form.domainid'}) &&
+    if (!&Apache::lonnet::allowed('usc',$env{'form.domainid'}) &&
 	!&Apache::lonnet::allowed('usc',
-			    $ENV{'form.domainid'}.'_'.$ENV{'form.courseid'})) {
+			    $env{'form.domainid'}.'_'.$env{'form.courseid'})) {
 	$r->print("You are not allowed to upload Scantron data to the requested course.<br />");
 	if ($symb) {
 	    $r->print(&show_grading_menu_form($symb,$url));
@@ -4970,11 +4970,11 @@
 	}
 	return '';
     }
-    my %coursedata=&Apache::lonnet::coursedescription($ENV{'form.domainid'}.'_'.$ENV{'form.courseid'});
+    my %coursedata=&Apache::lonnet::coursedescription($env{'form.domainid'}.'_'.$env{'form.courseid'});
     $r->print("Doing upload to ".$coursedata{'description'}." <br />");
-    my $home=&Apache::lonnet::homeserver($ENV{'form.courseid'},
-					 $ENV{'form.domainid'});
-    my $fname=$ENV{'form.upfile.filename'};
+    my $home=&Apache::lonnet::homeserver($env{'form.courseid'},
+					 $env{'form.domainid'});
+    my $fname=$env{'form.upfile.filename'};
     #FIXME
     #copied from lonnet::userfileupload()
     #make that function able to target a specified course
@@ -4990,14 +4990,14 @@
     unless ($fname) { return 'error: no uploaded file'; }
     my $uploadedfile=$fname;
     $fname='scantron_orig_'.$fname;
-    if (length($ENV{'form.upfile'}) < 2) {
-	$r->print("<font color='red'>Error:</font> The file you attempted to upload, <tt>".&HTML::Entities::encode($ENV{'form.upfile.filename'},'<>&"')."</tt>, contained no information. Please check that you entered the correct filename.");
+    if (length($env{'form.upfile'}) < 2) {
+	$r->print("<font color='red'>Error:</font> The file you attempted to upload, <tt>".&HTML::Entities::encode($env{'form.upfile.filename'},'<>&"')."</tt>, contained no information. Please check that you entered the correct filename.");
     } else {
-	my $result=&Apache::lonnet::finishuserfileupload($ENV{'form.courseid'},$ENV{'form.domainid'},$home,'upfile',$fname);
+	my $result=&Apache::lonnet::finishuserfileupload($env{'form.courseid'},$env{'form.domainid'},$home,'upfile',$fname);
 	if ($result =~ m|^/uploaded/|) {
-	    $r->print("<font color='green'>Success:</font> Successfully uploaded ".(length($ENV{'form.upfile'})-1)." bytes of data into location <tt>".$result."</tt>");
+	    $r->print("<font color='green'>Success:</font> Successfully uploaded ".(length($env{'form.upfile'})-1)." bytes of data into location <tt>".$result."</tt>");
 	} else {
-	    $r->print("<font color='red'>Error:</font> An error (".$result.") occurred when attempting to upload the file, <tt>".&HTML::Entities::encode($ENV{'form.upfile.filename'},'<>&"')."</tt>");
+	    $r->print("<font color='red'>Error:</font> An error (".$result.") occurred when attempting to upload the file, <tt>".&HTML::Entities::encode($env{'form.upfile.filename'},'<>&"')."</tt>");
 	}
     }
     if ($symb) {
@@ -5020,9 +5020,9 @@
 sub scantron_download_scantron_data {
     my ($r)=@_;
     my $default_form_data=&defaultFormData(&get_symb_and_url($r,1));
-    my $cname=$ENV{'course.'.$ENV{'request.course.id'}.'.num'};
-    my $cdom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
-    my $file=$ENV{'form.scantron_selectfile'};
+    my $cname=$env{'course.'.$env{'request.course.id'}.'.num'};
+    my $cdom=$env{'course.'.$env{'request.course.id'}.'.domain'};
+    my $file=$env{'form.scantron_selectfile'};
     if (! &valid_file($file)) {
 	$r->print(<<ERROR);
 	<p>
@@ -5065,7 +5065,7 @@
     my $result.='<br /><form action="/adm/grades" method="post">'."\n".
 	'<input type="hidden" name="symb" value="'.$symb.'" />'."\n".
 	'<input type="hidden" name="url" value="'.$url.'" />'."\n".
-	'<input type="hidden" name="saveState"  value="'.$ENV{'form.saveState'}.'" />'."\n".
+	'<input type="hidden" name="saveState"  value="'.$env{'form.saveState'}.'" />'."\n".
 	'<input type="hidden" name="command" value="gradingmenu" />'."\n".
 	'<input type="submit" name="submit" value="Grading Menu" />'."\n".
 	'</form>'."\n";
@@ -5075,8 +5075,8 @@
 # -- Retrieve choices for grading form
 sub savedState {
     my %savedState = ();
-    if ($ENV{'form.saveState'}) {
-	foreach (split(/:/,$ENV{'form.saveState'})) {
+    if ($env{'form.saveState'}) {
+	foreach (split(/:/,$env{'form.saveState'})) {
 	    my ($key,$value) = split(/=/,$_,2);
 	    $savedState{$key} = $value;
 	}
@@ -5206,11 +5206,11 @@
 	'<input type="button" onClick="javascript:checkChoice(this.form,\'4\',\'scantron_selectphase\');'.
 	'" value="'.&mt('Grade').'" /> scantron forms</td></tr>'."\n";
 
-    if ((&Apache::lonnet::allowed('mgr',$ENV{'request.course.id'})) && ($symb)) {
+    if ((&Apache::lonnet::allowed('mgr',$env{'request.course.id'})) && ($symb)) {
 	$result.='<tr bgcolor="#ffffe6"valign="top"><td>'.
 	    '<input type="button" onClick="javascript:checkChoice(this.form,\'5\',\'verify\');" value="'.&mt('Verify').'" />'.
 	    ' '.&mt('receipt').': '.
-	    &Apache::lonnet::recprefix($ENV{'request.course.id'}).
+	    &Apache::lonnet::recprefix($env{'request.course.id'}).
 	    '-<input type="text" name="receipt" size="4" onChange="javascript:checkReceiptNo(this.form,\'OK\')">'.
 	    '</td></tr>'."\n";
     } 
@@ -5228,7 +5228,7 @@
     my $request=$_[0];
 
     undef(%perm);
-    if ($ENV{'browser.mathml'}) {
+    if ($env{'browser.mathml'}) {
 	&Apache::loncommon::content_type($request,'text/xml');
     } else {
 	&Apache::loncommon::content_type($request,'text/html');
@@ -5236,8 +5236,8 @@
     $request->send_http_header;
     return '' if $request->header_only;
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'});
-    my $url=$ENV{'form.url'};
-    my $symb=$ENV{'form.symb'};
+    my $url=$env{'form.url'};
+    my $symb=$env{'form.symb'};
     my @commands=&Apache::loncommon::get_env_multiple('form.command');
     my $command=$commands[0];
     if ($#commands > 0) {
@@ -5245,16 +5245,16 @@
     }
     if (!$url) {
 	my ($temp1,$temp2);
-	($temp1,$temp2,$ENV{'form.url'})=&Apache::lonnet::decode_symb($symb);
-	$url = $ENV{'form.url'};
+	($temp1,$temp2,$env{'form.url'})=&Apache::lonnet::decode_symb($symb);
+	$url = $env{'form.url'};
     }
     &send_header($request);
     if ($url eq '' && $symb eq '' && $command eq '') {
-	if ($ENV{'user.adv'}) {
-	    if (($ENV{'form.codeone'}) && ($ENV{'form.codetwo'}) &&
-		($ENV{'form.codethree'})) {
-		my $token=$ENV{'form.codeone'}.'*'.$ENV{'form.codetwo'}.'*'.
-		    $ENV{'form.codethree'};
+	if ($env{'user.adv'}) {
+	    if (($env{'form.codeone'}) && ($env{'form.codetwo'}) &&
+		($env{'form.codethree'})) {
+		my $token=$env{'form.codeone'}.'*'.$env{'form.codetwo'}.'*'.
+		    $env{'form.codethree'};
 		my ($tsymb,$tuname,$tudom,$tcrsid)=
 		    &Apache::lonnet::checkin($token);
 		if ($tsymb) {
@@ -5276,22 +5276,22 @@
 	    }
 	}
     } else {
-	if (!($perm{'vgr'}=&Apache::lonnet::allowed('vgr',$ENV{'request.course.id'}))) {
-	    if ($perm{'vgr'}=&Apache::lonnet::allowed('vgr',$ENV{'request.course.id'}.'/'.$ENV{'request.course.sec'})) {
-		$perm{'vgr_section'}=$ENV{'request.course.sec'};
+	if (!($perm{'vgr'}=&Apache::lonnet::allowed('vgr',$env{'request.course.id'}))) {
+	    if ($perm{'vgr'}=&Apache::lonnet::allowed('vgr',$env{'request.course.id'}.'/'.$env{'request.course.sec'})) {
+		$perm{'vgr_section'}=$env{'request.course.sec'};
 	    } else {
 		delete($perm{'vgr'});
 	    }
 	}
-	if (!($perm{'mgr'}=&Apache::lonnet::allowed('mgr',$ENV{'request.course.id'}))) {
-	    if ($perm{'mgr'}=&Apache::lonnet::allowed('mgr',$ENV{'request.course.id'}.'/'.$ENV{'request.course.sec'})) {
-		$perm{'mgr_section'}=$ENV{'request.course.sec'};
+	if (!($perm{'mgr'}=&Apache::lonnet::allowed('mgr',$env{'request.course.id'}))) {
+	    if ($perm{'mgr'}=&Apache::lonnet::allowed('mgr',$env{'request.course.id'}.'/'.$env{'request.course.sec'})) {
+		$perm{'mgr_section'}=$env{'request.course.sec'};
 	    } else {
 		delete($perm{'mgr'});
 	    }
 	}
 	if ($command eq 'submission' && $perm{'vgr'}) {
-	    ($ENV{'form.student'} eq '' ? &listStudents($request) : &submission($request,0,0));
+	    ($env{'form.student'} eq '' ? &listStudents($request) : &submission($request,0,0));
 	} elsif ($command eq 'pickStudentPage' && $perm{'vgr'}) {
 	    &pickStudentPage($request);
 	} elsif ($command eq 'displayPage' && $perm{'vgr'}) {
@@ -5317,13 +5317,13 @@
 	} elsif ($command eq 'csvuploadmap' && $perm{'mgr'} ) {
 	    $request->print(&csvuploadmap($request));
 	} elsif ($command eq 'csvuploadoptions' && $perm{'mgr'}) {
-	    if ($ENV{'form.associate'} ne 'Reverse Association') {
+	    if ($env{'form.associate'} ne 'Reverse Association') {
 		$request->print(&csvuploadoptions($request));
 	    } else {
-		if ( $ENV{'form.upfile_associate'} ne 'reverse' ) {
-		    $ENV{'form.upfile_associate'} = 'reverse';
+		if ( $env{'form.upfile_associate'} ne 'reverse' ) {
+		    $env{'form.upfile_associate'} = 'reverse';
 		} else {
-		    $ENV{'form.upfile_associate'} = 'forward';
+		    $env{'form.upfile_associate'} = 'forward';
 		}
 		$request->print(&csvuploadmap($request));
 	    }
@@ -5338,15 +5338,15 @@
 	} elsif ($command eq 'scantron_process' && $perm{'mgr'}) {
 	    $request->print(&scantron_process_students($request));
  	} elsif ($command eq 'scantronupload' && 
- 		 (&Apache::lonnet::allowed('usc',$ENV{'request.role.domain'})||
-		  &Apache::lonnet::allowed('usc',$ENV{'request.course.id'}))) {
+ 		 (&Apache::lonnet::allowed('usc',$env{'request.role.domain'})||
+		  &Apache::lonnet::allowed('usc',$env{'request.course.id'}))) {
  	    $request->print(&scantron_upload_scantron_data($request)); 
  	} elsif ($command eq 'scantronupload_save' &&
- 		 (&Apache::lonnet::allowed('usc',$ENV{'request.role.domain'})||
-		  &Apache::lonnet::allowed('usc',$ENV{'request.course.id'}))) {
+ 		 (&Apache::lonnet::allowed('usc',$env{'request.role.domain'})||
+		  &Apache::lonnet::allowed('usc',$env{'request.course.id'}))) {
  	    $request->print(&scantron_upload_scantron_data_save($request));
  	} elsif ($command eq 'scantron_download' &&
-		 &Apache::lonnet::allowed('usc',$ENV{'request.course.id'})) {
+		 &Apache::lonnet::allowed('usc',$env{'request.course.id'})) {
  	    $request->print(&scantron_download_scantron_data($request));
 	} elsif ($command) {
 	    $request->print("Access Denied ($command)");
Index: loncom/homework/hint.pm
diff -u loncom/homework/hint.pm:1.58 loncom/homework/hint.pm:1.59
--- loncom/homework/hint.pm:1.58	Mon Dec  6 14:48:22 2004
+++ loncom/homework/hint.pm	Thu Apr  7 02:56:21 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # implements the tags that control the hints
 #
-# $Id: hint.pm,v 1.58 2004/12/06 19:48:22 albertel Exp $
+# $Id: hint.pm,v 1.59 2005/04/07 06:56:21 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -29,7 +29,7 @@
 package Apache::hinttags; 
 
 use strict;
-use Apache::lonnet();
+use Apache::lonnet;
 use capa;
 use Apache::lonlocal;
 
Index: loncom/homework/imagechoice.pm
diff -u loncom/homework/imagechoice.pm:1.7 loncom/homework/imagechoice.pm:1.8
--- loncom/homework/imagechoice.pm:1.7	Thu Feb 17 04:01:03 2005
+++ loncom/homework/imagechoice.pm	Thu Apr  7 02:56:21 2005
@@ -1,4 +1,4 @@
-# $Id: imagechoice.pm,v 1.7 2005/02/17 09:01:03 albertel Exp $
+# $Id: imagechoice.pm,v 1.8 2005/04/07 06:56:21 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -25,7 +25,7 @@
 package Apache::imagechoice;
 use strict;
 use Apache::Constants qw(:common :http);
-
+use Apache::lonnet;
 
 sub deletedata {
     my ($id)=@_;
@@ -56,26 +56,26 @@
 sub storedata {
     my ($r,$type,$filename,$id)=@_;
 
-    my (undef,@coords)=split(':',$ENV{"imagechoice.$id.coords"});
+    my (undef,@coords)=split(':',$env{"imagechoice.$id.coords"});
 
     my ($output,$needimage);
 
-    if ($ENV{"imagechoice.$id.formwidth"}) {
-	$output.='opener.document.forms.'.$ENV{"imagechoice.$id.formname"}.'.'.$ENV{"imagechoice.$id.formwidth"}.'.value=document.pickimg.width;';
+    if ($env{"imagechoice.$id.formwidth"}) {
+	$output.='opener.document.forms.'.$env{"imagechoice.$id.formname"}.'.'.$env{"imagechoice.$id.formwidth"}.'.value=document.pickimg.width;';
 	$needimage=1;
     }
-    if ($ENV{"imagechoice.$id.formheight"}) {
-	$output.='opener.document.forms.'.$ENV{"imagechoice.$id.formname"}.'.'.$ENV{"imagechoice.$id.formheight"}.'.value=document.pickimg.height;';
+    if ($env{"imagechoice.$id.formheight"}) {
+	$output.='opener.document.forms.'.$env{"imagechoice.$id.formname"}.'.'.$env{"imagechoice.$id.formheight"}.'.value=document.pickimg.height;';
 	$needimage=1;
     }
 
     if ($type eq 'point') {
-	my (undef,$x,$y)=split(':',$ENV{"imagechoice.$id.coords"});
-	if ($ENV{"imagechoice.$id.formx"}) {
-	    $output.='opener.document.forms.'.$ENV{"imagechoice.$id.formname"}.'.'.$ENV{"imagechoice.$id.formx"}.'.value='.$x.';';
+	my (undef,$x,$y)=split(':',$env{"imagechoice.$id.coords"});
+	if ($env{"imagechoice.$id.formx"}) {
+	    $output.='opener.document.forms.'.$env{"imagechoice.$id.formname"}.'.'.$env{"imagechoice.$id.formx"}.'.value='.$x.';';
 	}
-	if ($ENV{"imagechoice.$id.formy"}) {
-	    $output.='opener.document.forms.'.$ENV{"imagechoice.$id.formname"}.'.'.$ENV{"imagechoice.$id.formy"}.'.value='.$y.';';
+	if ($env{"imagechoice.$id.formy"}) {
+	    $output.='opener.document.forms.'.$env{"imagechoice.$id.formname"}.'.'.$env{"imagechoice.$id.formy"}.'.value='.$y.';';
 	}
     } elsif ($type eq 'polygon' or $type eq 'box') {
 	my $coordstr;
@@ -83,7 +83,7 @@
 	    $coordstr.='('.shift(@coords).','.shift(@coords).')-';
 	}
 	chop($coordstr);
-	$output.='opener.document.forms.'.$ENV{"imagechoice.$id.formname"}.'.'.$ENV{"imagechoice.$id.formcoord"}.'.value="'.$coordstr.'";';
+	$output.='opener.document.forms.'.$env{"imagechoice.$id.formname"}.'.'.$env{"imagechoice.$id.formcoord"}.'.value="'.$coordstr.'";';
     }
 
     &deletedata($id);
@@ -95,7 +95,7 @@
     my $heading='Select Position on Image';
     my $nextstage='';
     if ($type eq 'box') {
-	my (undef,@coords)=split(':',$ENV{"imagechoice.$id.coords"});
+	my (undef,@coords)=split(':',$env{"imagechoice.$id.coords"});
 	my $step=scalar(@coords)/2;
 	if ($step == 0) { 
 	    $heading='Select First Coordinate on Image';
@@ -131,17 +131,17 @@
 
 sub savecoord {
     my ($id,$type)=@_;
-    if (defined($ENV{"form.image.x"}) && defined($ENV{"form.image.y"})) {
+    if (defined($env{"form.image.x"}) && defined($env{"form.image.y"})) {
 	my $data;
 	if ($type eq 'point') {
-	    $data=join(':',(undef,$ENV{"form.image.x"},$ENV{"form.image.y"}));
+	    $data=join(':',(undef,$env{"form.image.x"},$env{"form.image.y"}));
 	} else {
-	    $data=join(':',($ENV{"imagechoice.$id.coords"},
-			    $ENV{"form.image.x"},$ENV{"form.image.y"}));
+	    $data=join(':',($env{"imagechoice.$id.coords"},
+			    $env{"form.image.x"},$env{"form.image.y"}));
 	}
 	&Apache::lonnet::appenv("imagechoice.$id.coords"=>$data);
     }
-    return int(scalar(split(':',$ENV{"imagechoice.$id.coords"}))/2);
+    return int(scalar(split(':',$env{"imagechoice.$id.coords"}))/2);
 }
 
 sub add_obj {
@@ -174,7 +174,7 @@
 
 sub drawPolygon {
     my ($data,$id,$imid)=@_;
-    my (undef,@coords)=split(':',$ENV{"imagechoice.$id.coords"});
+    my (undef,@coords)=split(':',$env{"imagechoice.$id.coords"});
     my $coordstr;
     while (@coords) {
 	$coordstr.='('.shift(@coords).','.shift(@coords).')-';
@@ -190,7 +190,7 @@
 
 sub drawBox {
     my ($data,$id,$imid)=@_;
-    my (undef,@coords)=split(':',$ENV{"imagechoice.$id.coords"});
+    my (undef,@coords)=split(':',$env{"imagechoice.$id.coords"});
     if (scalar(@coords) < 4) { return ''; }
     my $width = 1;
     my $extrawidth = 2;
@@ -202,7 +202,7 @@
 sub drawimage {
     my ($r,$type,$filename,$id)=@_;
     my $imid=&Apache::loncommon::get_cgi_id();
-    my (undef,@coords)=split(':',$ENV{"imagechoice.$id.coords"});
+    my (undef,@coords)=split(':',$env{"imagechoice.$id.coords"});
     if (scalar(@coords) < 2) { return &Apache::lonnet::hreflocation('',$filename); }
     my %data;
     $data{"cgi.$imid.BGIMG"}=$filename;
@@ -221,18 +221,18 @@
     $r->send_http_header;
     my %data;
     my (undef,$id) = split(/=/,$ENV{'QUERY_STRING'});
-    my $filename = &Apache::lonnet::unescape($ENV{"imagechoice.$id.file"});
-    my $formname = $ENV{"imagechoice.$id.formname"};
-    if ($ENV{'form.cancel'} eq 'Cancel') {
+    my $filename = &Apache::lonnet::unescape($env{"imagechoice.$id.file"});
+    my $formname = $env{"imagechoice.$id.formname"};
+    if ($env{'form.cancel'} eq 'Cancel') {
 	&deletedata($id);
 	&closewindow($r,'',$filename);
 	return OK;
     }
-    my $type=$ENV{"imagechoice.$id.type"};
-    if (defined($ENV{'form.type'})) { $type=$ENV{'form.type'}; }
+    my $type=$env{"imagechoice.$id.type"};
+    if (defined($env{'form.type'})) { $type=$env{'form.type'}; }
     my $numcoords=&savecoord($id,$type);
     my $imurl=&drawimage($r,$type,$filename,$id);
-    if (($ENV{'form.finish'} eq 'Finish')) {
+    if (($env{'form.finish'} eq 'Finish')) {
 	&storedata($r,$type,$imurl,$id);
     } else {
 	&getcoord($r,$type,$imurl,$id);
Index: loncom/homework/imageresponse.pm
diff -u loncom/homework/imageresponse.pm:1.64 loncom/homework/imageresponse.pm:1.65
--- loncom/homework/imageresponse.pm:1.64	Wed Mar 16 16:35:17 2005
+++ loncom/homework/imageresponse.pm	Thu Apr  7 02:56:21 2005
@@ -2,7 +2,7 @@
 # The LearningOnline Network with CAPA
 # image click response style
 #
-# $Id: imageresponse.pm,v 1.64 2005/03/16 21:35:17 raeburn Exp $
+# $Id: imageresponse.pm,v 1.65 2005/04/07 06:56:21 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -36,6 +36,7 @@
 use Apache::londefdef();
 use Apache::Constants qw(:common :http);
 use Apache::lonlocal;
+use Apache::lonnet;
 
 BEGIN {
     &Apache::lonxml::register('Apache::imageresponse',('imageresponse'));
@@ -242,8 +243,8 @@
     my $id=$Apache::inputtags::response['-1'];
     my $temp=1;
     foreach my $name (@whichopt) {
-	$x=$ENV{"form.HWVAL_$id:$temp.x"};
-	$y=$ENV{"form.HWVAL_$id:$temp.y"};
+	$x=$env{"form.HWVAL_$id:$temp.x"};
+	$y=$env{"form.HWVAL_$id:$temp.y"};
 	&Apache::lonxml::debug("Got a x of $x and a y of $y for $name");
 	if (defined($x) && defined($y) &&
 	    defined(@{ $Apache::response::foilgroup{"$name.area"} })) {
@@ -294,7 +295,7 @@
 	if ($target eq 'web' || $target eq 'tex') {
 	    $result=&displayfoils($target,@whichopt);
 	} elsif ($target eq 'grade') {
-	    if ( defined $ENV{'form.submitted'}) { &gradefoils(@whichopt); }
+	    if ( defined $env{'form.submitted'}) { &gradefoils(@whichopt); }
 	} elsif ( $target eq 'analyze') {
 	    &Apache::response::analyze_store_foilgroup(\@whichopt,
 						      ['text','image','area']);
Index: loncom/homework/inputtags.pm
diff -u loncom/homework/inputtags.pm:1.164 loncom/homework/inputtags.pm:1.165
--- loncom/homework/inputtags.pm:1.164	Tue Apr  5 11:39:41 2005
+++ loncom/homework/inputtags.pm	Thu Apr  7 02:56:21 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # input  definitons
 #
-# $Id: inputtags.pm,v 1.164 2005/04/05 15:39:41 albertel Exp $
+# $Id: inputtags.pm,v 1.165 2005/04/07 06:56:21 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -30,6 +30,7 @@
 use strict;
 use Apache::loncommon;
 use Apache::lonlocal;
+use Apache::lonnet;
 
 BEGIN {
     &Apache::lonxml::register('Apache::inputtags',('hiddenline','textfield','textline'));
@@ -148,9 +149,9 @@
 	}
     } elsif ($target eq 'grade') {
 	my $seedtext=&Apache::lonxml::get_all_text("/textfield",$parser);
-	if ($seedtext eq $ENV{'form.HWVAL_'.$resid}) {
+	if ($seedtext eq $env{'form.HWVAL_'.$resid}) {
 	    # if the seed text is still there it wasn't a real submission
-	    $ENV{'form.HWVAL_'.$resid}='';
+	    $env{'form.HWVAL_'.$resid}='';
 	}
     } elsif ($target eq 'edit') {
 	$result.=&Apache::edit::tag_start($target,$token);
@@ -421,8 +422,8 @@
 		$message.=" ".&mt("Computer's answer now shown above.");
 	    }
 	    $added_computer_text=1;
-	    unless ($ENV{'course.'.
-			     $ENV{'request.course.id'}.
+	    unless ($env{'course.'.
+			     $env{'request.course.id'}.
 			     '.disable_receipt_display'} eq 'yes') { 
 		$message.=(($target eq 'web')?'<br />':' ').
 		    &mt('Your receipt is').' '.&Apache::lonnet::receipt($Apache::inputtags::part).
@@ -454,8 +455,8 @@
 		$message.=" ".&mt("Computer's answer now shown above.");
 	    }
 	    $added_computer_text=1;
-	    unless ($ENV{'course.'.
-			     $ENV{'request.course.id'}.
+	    unless ($env{'course.'.
+			     $env{'request.course.id'}.
 			     '.disable_receipt_display'} eq 'yes') { 
 		$message.=(($target eq 'web')?'<br />':' ').
 		    'Your receipt is '.&Apache::lonnet::receipt($Apache::inputtags::part).
@@ -609,10 +610,10 @@
 sub setgradedata {
     my ($award,$msg,$id,$previously_used) = @_;
     if ($Apache::lonhomework::scantronmode && 
-	&Apache::lonnet::validCODE($ENV{'form.CODE'})) {
-	$Apache::lonhomework::results{"resource.CODE"}=$ENV{'form.CODE'};
+	&Apache::lonnet::validCODE($env{'form.CODE'})) {
+	$Apache::lonhomework::results{"resource.CODE"}=$env{'form.CODE'};
     } elsif ($Apache::lonhomework::scantronmode && 
-	     $ENV{'form.CODE'} eq '' &&
+	     $env{'form.CODE'} eq '' &&
 	     $Apache::lonhomework::history{"resource.CODE"} ne '') {
 	$Apache::lonhomework::results{"resource.CODE"}='';
     }
@@ -729,7 +730,7 @@
     my ($target) = @_;
     my $id = $Apache::inputtags::part;
     my $response='';
-    if ( defined $ENV{'form.submitted'}) {
+    if ( defined $env{'form.submitted'}) {
 	my (@awards,@msgs);
 	foreach $response (@Apache::inputtags::response) {
 	    &Apache::lonxml::debug("looking for response.$id.$response.awarddetail");
@@ -814,7 +815,7 @@
 	}
 	if ( $showbutton ) {
 	    if ($target eq 'tex') {
-		if ($ENV{'request.state'} ne "construct" && $Apache::lonhomework::type ne 'exam' && $ENV{'form.suppress_tries'} ne 'yes') {
+		if ($env{'request.state'} ne "construct" && $Apache::lonhomework::type ne 'exam' && $env{'form.suppress_tries'} ne 'yes') {
 		    $trystr = ' {\vskip 1 mm \small \textit{'.$tries_text.'} '.$tries.'/'.$maxtries.'} \vskip 2 mm ';
 		} else {
 		    $trystr = '\vskip 0 mm ';
@@ -822,7 +823,7 @@
 	    } else {
 		$trystr = "<td><nobr>".$tries_text." $tries";
 		if ($Apache::lonhomework::parsing_a_task) {
-		} elsif($ENV{'request.state'} ne 'construct') {
+		} elsif($env{'request.state'} ne 'construct') {
 		    $trystr.="/$maxtries";
 		} else {
 		    if (defined($Apache::inputtags::params{'maxtries'})) {
Index: loncom/homework/lonhomework.pm
diff -u loncom/homework/lonhomework.pm:1.203 loncom/homework/lonhomework.pm:1.204
--- loncom/homework/lonhomework.pm:1.203	Mon Apr  4 14:13:16 2005
+++ loncom/homework/lonhomework.pm	Thu Apr  7 02:56:21 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Homework handler
 #
-# $Id: lonhomework.pm,v 1.203 2005/04/04 18:13:16 albertel Exp $
+# $Id: lonhomework.pm,v 1.204 2005/04/07 06:56:21 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -30,7 +30,7 @@
 use strict;
 use Apache::style();
 use Apache::lonxml();
-use Apache::lonnet();
+use Apache::lonnet;
 use Apache::lonplot();
 use Apache::inputtags();
 use Apache::structuretags();
@@ -72,53 +72,53 @@
 #                       contruct   - is a /priv/ resource
 #      form.grade_target - a form parameter requesting a specific target
 sub get_target {
-    &Apache::lonxml::debug("request.state = $ENV{'request.state'}");
-    if( defined($ENV{'form.grade_target'})) {
-	&Apache::lonxml::debug("form.grade_target= $ENV{'form.grade_target'}");
+    &Apache::lonxml::debug("request.state = $env{'request.state'}");
+    if( defined($env{'form.grade_target'})) {
+	&Apache::lonxml::debug("form.grade_target= $env{'form.grade_target'}");
     } else {
 	&Apache::lonxml::debug("form.grade_target <undefined>");
     }
-    if (($ENV{'request.state'} eq "published") ||
-	($ENV{'request.state'} eq "uploaded")) {
-	if ( defined($ENV{'form.grade_target'}  ) 
-	     && ($ENV{'form.grade_target'} eq 'tex')) {
-	    return ($ENV{'form.grade_target'});
-	} elsif ( defined($ENV{'form.grade_target'}  ) 
+    if (($env{'request.state'} eq "published") ||
+	($env{'request.state'} eq "uploaded")) {
+	if ( defined($env{'form.grade_target'}  ) 
+	     && ($env{'form.grade_target'} eq 'tex')) {
+	    return ($env{'form.grade_target'});
+	} elsif ( defined($env{'form.grade_target'}  ) 
 		  && ($Apache::lonhomework::viewgrades eq 'F' )) {
-	    return ($ENV{'form.grade_target'});
+	    return ($env{'form.grade_target'});
 	}
 
-	if ( defined($ENV{'form.submitted'}) &&
-	     ( !defined($ENV{'form.resetdata'})) &&
-	     ( !defined($ENV{'form.newrandomization'}))) {
+	if ( defined($env{'form.submitted'}) &&
+	     ( !defined($env{'form.resetdata'})) &&
+	     ( !defined($env{'form.newrandomization'}))) {
 	    return ('grade', 'web');
 	} else {
 	    return ('web');
 	}
-    } elsif ($ENV{'request.state'} eq "construct") {
-	if ( defined($ENV{'form.grade_target'}) ) {
-	    return ($ENV{'form.grade_target'});
+    } elsif ($env{'request.state'} eq "construct") {
+	if ( defined($env{'form.grade_target'}) ) {
+	    return ($env{'form.grade_target'});
 	}
-	if ( defined($ENV{'form.preview'})) {
-	    if ( defined($ENV{'form.submitted'})) {
+	if ( defined($env{'form.preview'})) {
+	    if ( defined($env{'form.submitted'})) {
 		return ('grade', 'web');
 	    } else {
 		return ('web');
 	    }
 	} else {
-	    if ( $ENV{'form.problemmode'} eq &mt('View') ||
-		 $ENV{'form.problemmode'} eq &mt('Discard Edits and View')) {
-		if ( defined($ENV{'form.submitted'}) &&
-		     (!defined($ENV{'form.resetdata'})) &&
-		     (!defined($ENV{'form.newrandomization'}))) {
+	    if ( $env{'form.problemmode'} eq &mt('View') ||
+		 $env{'form.problemmode'} eq &mt('Discard Edits and View')) {
+		if ( defined($env{'form.submitted'}) &&
+		     (!defined($env{'form.resetdata'})) &&
+		     (!defined($env{'form.newrandomization'}))) {
 		    return ('grade', 'web','answer');
 		} else {
 		    return ('web','answer');
 		}
-	    } elsif ( $ENV{'form.problemmode'} eq &mt('Edit') ||
-		      $ENV{'form.problemmode'} eq 'Edit') {
-		if ( $ENV{'form.submitted'} eq 'edit' ) {
-		    if ( $ENV{'form.submit'} eq &mt('Submit Changes and View') ) {
+	    } elsif ( $env{'form.problemmode'} eq &mt('Edit') ||
+		      $env{'form.problemmode'} eq 'Edit') {
+		if ( $env{'form.submitted'} eq 'edit' ) {
+		    if ( $env{'form.submit'} eq &mt('Submit Changes and View') ) {
 			return ('modified','web','answer');
 		    } else {
 			return ('modified','edit');
@@ -143,7 +143,7 @@
 sub send_header {
     my ($request)= @_;
     $request->print(&Apache::lontexconvert::header());
-#  $request->print('<form name='.$ENV{'form.request.prefix'}.'lonhomework method="POST" action="'.$request->uri.'">');
+#  $request->print('<form name='.$env{'form.request.prefix'}.'lonhomework method="POST" action="'.$request->uri.'">');
 }
 
 sub createmenu {
@@ -230,7 +230,7 @@
 	$status eq 'UNAVAILABLE') {
 	return ($status,$datemsg);
     }
-    if ($ENV{'request.state'} eq "construct") {
+    if ($env{'request.state'} eq "construct") {
 	return ($status,$datemsg);
     }
     
@@ -274,16 +274,16 @@
     my $type;
     my $passed;
 
-    if ($ENV{'request.state'} eq "construct") {
-	if ($ENV{'form.problemstate'}) {
-	    if ($ENV{'form.problemstate'} =~ /^CANNOT_ANSWER/) {
-		if ( ! ($ENV{'form.problemstate'} eq 'CANNOT_ANSWER_correct' &&
+    if ($env{'request.state'} eq "construct") {
+	if ($env{'form.problemstate'}) {
+	    if ($env{'form.problemstate'} =~ /^CANNOT_ANSWER/) {
+		if ( ! ($env{'form.problemstate'} eq 'CANNOT_ANSWER_correct' &&
 			lc($Apache::lonhomework::problemstatus) eq 'no')) {
 		    return ('CANNOT_ANSWER',
 			    &mt('is in this state due to author settings.'));
 		}
 	    } else {
-		return ($ENV{'form.problemstate'},
+		return ($env{'form.problemstate'},
 			&mt('is in this state due to author settings.'));
 	    }
 	}
@@ -296,7 +296,7 @@
     &Apache::lonxml::debug("checking for part :$id:");
     &Apache::lonxml::debug("time:".time);
 
-    if ($ENV{'request.state'} ne "construct") {
+    if ($env{'request.state'} ne "construct") {
 	my $allowed=&check_ip_acc(&Apache::lonnet::EXT("resource.$id.acc"));
 	if (!$allowed && ($Apache::lonhomework::browse ne 'F')) {
 	    $status='INVALID_ACCESS';
@@ -354,7 +354,7 @@
 	my $maxtries = &Apache::lonnet::EXT("resource.$id.maxtries");
 	if ( $tries eq '' ) { $tries = '0'; }
 	if ( $maxtries eq '' && 
-	     $ENV{'request.state'} ne 'construct') { $maxtries = '2'; } 
+	     $env{'request.state'} ne 'construct') { $maxtries = '2'; } 
 	if ($maxtries && $tries >= $maxtries) { $status = 'CANNOT_ANSWER'; }
 	# if (correct and show prob status) or excused then CANNOT_ANSWER
 	if(($Apache::lonhomework::history{"resource.$id.solved"}=~/^correct/
@@ -464,20 +464,20 @@
 }
 
 sub setuppermissions {
-    $Apache::lonhomework::browse= &Apache::lonnet::allowed('bre',$ENV{'request.filename'});
-    my $viewgrades = &Apache::lonnet::allowed('vgr',$ENV{'request.course.id'});
+    $Apache::lonhomework::browse= &Apache::lonnet::allowed('bre',$env{'request.filename'});
+    my $viewgrades = &Apache::lonnet::allowed('vgr',$env{'request.course.id'});
     if (! $viewgrades && 
-	exists($ENV{'request.course.sec'}) && 
-	$ENV{'request.course.sec'} !~ /^\s*$/) {
-	$viewgrades = &Apache::lonnet::allowed('vgr',$ENV{'request.course.id'}.
-                                               '/'.$ENV{'request.course.sec'});
+	exists($env{'request.course.sec'}) && 
+	$env{'request.course.sec'} !~ /^\s*$/) {
+	$viewgrades = &Apache::lonnet::allowed('vgr',$env{'request.course.id'}.
+                                               '/'.$env{'request.course.sec'});
     }
     $Apache::lonhomework::viewgrades = $viewgrades; # File global variable...dirt.
     if ($Apache::lonhomework::browse eq 'F' && 
-	$ENV{'form.devalidatecourseresdata'} eq 'on') {
+	$env{'form.devalidatecourseresdata'} eq 'on') {
 	my (undef,$courseid) = &Apache::lonxml::whichuser();
-	&Apache::lonnet::devalidatecourseresdata($ENV{"course.$courseid.num"},
-					      $ENV{"course.$courseid.domain"});
+	&Apache::lonnet::devalidatecourseresdata($env{"course.$courseid.num"},
+					      $env{"course.$courseid.domain"});
     }
     return ''
 }
@@ -504,7 +504,7 @@
 
     &Apache::lonnet::correct_line_ends($result);
 
-    if ($ENV{'form.Undo'} eq &mt('undo')) {
+    if ($env{'form.Undo'} eq &mt('undo')) {
 	my $error=0;
 	if (!copy($file,$filetmp)) { $error=1; }
 	if ((!$error) && (!copy($filebak,$file))) { $error=1; }
@@ -542,7 +542,7 @@
 sub analyze_header {
     my ($request) = @_;
     my $bodytag='<body bgcolor="#ffffff">';
-    if ($ENV{'environment.remote'} eq 'off') {
+    if ($env{'environment.remote'} eq 'off') {
 	$bodytag=&Apache::loncommon::bodytag();
     }
     my $html=&Apache::lonxml::xmlbegin();
@@ -550,7 +550,7 @@
             <head><title>'.&mt("Analyzing a problem").'</title></head>
             '.$bodytag.&Apache::lonxml::message_location().'
             <form name="lonhomework" method="POST" action="'.
-	    &HTML::Entities::encode($ENV{'request.uri'},'<>&"').'">'.
+	    &HTML::Entities::encode($env{'request.uri'},'<>&"').'">'.
 	    &Apache::structuretags::remember_problem_state().'
             <input type="submit" name="problemmode" value="'.&mt("EditXML").'" />
             <input type="submit" name="problemmode" value="'.&mt('Edit').'" />
@@ -576,14 +576,14 @@
     my $result;
     my %overall;
     my %allparts;
-    my $rndseed=$ENV{'form.rndseed'};
+    my $rndseed=$env{'form.rndseed'};
     &analyze_header($request);
     my %prog_state=
 	&Apache::lonhtmlcommon::Create_PrgWin($request,&mt('Analyze Progress'),
 					      &mt('Getting Problem Variants'),
-					      $ENV{'form.numtoanalyze'},
+					      $env{'form.numtoanalyze'},
 					      'inline',undef);
-    for(my $i=1;$i<$ENV{'form.numtoanalyze'}+1;$i++) {
+    for(my $i=1;$i<$env{'form.numtoanalyze'}+1;$i++) {
 	&Apache::lonhtmlcommon::Increment_PrgWin($request,\%prog_state,
 						 &mt('last problem'));
 	if (&Apache::loncommon::connection_aborted($request)) { return; }
@@ -648,15 +648,15 @@
 			       " <i>$file</i></b>");
 	$problem='';
     }
-    if (defined($ENV{'form.editxmltext'}) || defined($ENV{'form.Undo'})) {
+    if (defined($env{'form.editxmltext'}) || defined($env{'form.Undo'})) {
 	my $error=&handle_save_or_undo($request,\$problem,
-				       \$ENV{'form.editxmltext'});
+				       \$env{'form.editxmltext'});
 	if (!$error) { $problem=&Apache::lonnet::getfile($file); }
     }
-    &Apache::lonhomework::showhashsubset(\%ENV,'^form');
-    if ( $ENV{'form.submit'} eq &mt('Submit Changes and View') ) {
-	&Apache::lonhomework::showhashsubset(\%ENV,'^form');
-	$ENV{'form.problemmode'}='View';
+    &Apache::lonhomework::showhashsubset(\%env,'^form');
+    if ( $env{'form.submit'} eq &mt('Submit Changes and View') ) {
+	&Apache::lonhomework::showhashsubset(\%env,'^form');
+	$env{'form.problemmode'}='View';
 	&renderpage($request,$file);
     } else {
 	my ($rows,$cols) = &Apache::edit::textarea_sizes(\$problem);
@@ -670,13 +670,13 @@
 	if ($cols < 70) { $cols = 70; }
 	if ($rows < 20) { $rows = 20; }
 	my $bodytag='<body bgcolor="#ffffff">';
-	if ($ENV{'environment.remote'} eq 'off') {
+	if ($env{'environment.remote'} eq 'off') {
 	    $bodytag=&Apache::loncommon::bodytag();
 	}
 	my $html=&Apache::lonxml::xmlbegin();
 	$result.=$html.$bodytag.&Apache::lonxml::message_location().'
             <form name="lonhomework" method="POST" action="'.
-	    &HTML::Entities::encode($ENV{'request.uri'},'<>&"').'">'.
+	    &HTML::Entities::encode($env{'request.uri'},'<>&"').'">'.
 	    &Apache::structuretags::remember_problem_state().'
             <input type="hidden" name="problemmode" value="'.&mt('EditXML').'" />
             <input type="submit" name="problemmode" accesskey="d" value="'.&mt('Discard Edits and View').'" />
@@ -703,7 +703,7 @@
     my ($request,$file) = @_;
 
     my (@targets) = &get_target();
-    &Apache::lonhomework::showhashsubset(\%ENV,'form.');
+    &Apache::lonhomework::showhashsubset(\%env,'form.');
     &Apache::lonxml::debug("Running targets ".join(':',@targets));
     my $overall_result;
     foreach my $target (@targets) {
@@ -725,7 +725,7 @@
 	my $result = '';
 	if ($target eq 'analyze') { %Apache::lonhomework::analyze=(); }
 	if ($target eq 'answer') { &showhash(%Apache::lonhomework::history); }
-	if ($target eq 'web') {&Apache::lonhomework::showhashsubset(\%ENV,'^form');}
+	if ($target eq 'web') {&Apache::lonhomework::showhashsubset(\%env,'^form');}
 
 	&Apache::lonxml::debug("Should be parsing now");
 	$result = &Apache::lonxml::xmlparse($request, $target, $problem,
@@ -785,14 +785,14 @@
     $extension=~s:^.*\.([\w]+)$:$1:;
     &Apache::lonxml::debug("Looking for :$extension:");
     my $templatelist=&get_template_list('',$extension);
-    if ($ENV{'form.template'} &&
-	$ENV{'form.template'} ne "Select a $extension template") {
+    if ($env{'form.template'} &&
+	$env{'form.template'} ne "Select a $extension template") {
 	use File::Copy;
-	my $file = &get_template_list($ENV{'form.template'},$extension);
+	my $file = &get_template_list($env{'form.template'},$extension);
 	my $dest = &Apache::lonnet::filelocation("",$request->uri);
 	copy($file,$dest);
 	&renderpage($request,$dest);
-    } elsif($ENV{'form.newfile'} && !$templatelist) {
+    } elsif($env{'form.newfile'} && !$templatelist) {
 	# I don't like hard-coded filenames but for now, this will work.
 	use File::Copy;
 	my $templatefilename =
@@ -807,12 +807,12 @@
 	$shownurl=~s-^/~-/priv/-;
 	my $dest = &Apache::lonnet::filelocation("",$request->uri);
 	my $errormsg;
-	if ($ENV{'form.newfile'}) {
+	if ($env{'form.newfile'}) {
 	    $errormsg='<p><font color="red">'.&mt('You did not select a template.').'</font></p>'."\n";
 	}
 	my $instructions;
 	my $bodytag=&Apache::loncommon::bodytag(undef,undef,undef,
-					($ENV{'environment.remote'} ne 'off'));
+					($env{'environment.remote'} ne 'off'));
 	if ($templatelist) { $instructions=&mt(", select a template from the pull-down menu below.").'<br />'.&mt("Then");}
 	my %lt=&Apache::lonlocal::texthash( 'create' => 'Creating a new',
 			  'resource' => 'resource',
@@ -864,24 +864,24 @@
     #my $t0 = [&gettimeofday()];
     my $request=$_[0];
     
-    $Apache::lonxml::debug=$ENV{'user.debug'};
-    $ENV{'request.uri'}=$request->uri;
+    $Apache::lonxml::debug=$env{'user.debug'};
+    $env{'request.uri'}=$request->uri;
     &setuppermissions();
     # some times multiple problemmodes are submitted, need to select
     # the last one
-    if ( defined($ENV{'form.problemmode'}) && ref($ENV{'form.problemmode'}) ) {
-	my $mode=$ENV{'form.problemmode'}->[-1];
-	undef $ENV{'form.problemmode'};
-	$ENV{'form.problemmode'}=$mode;
+    if ( defined($env{'form.problemmode'}) && ref($env{'form.problemmode'}) ) {
+	my $mode=$env{'form.problemmode'}->[-1];
+	undef $env{'form.problemmode'};
+	$env{'form.problemmode'}=$mode;
     }
 
     my $file=&Apache::lonnet::filelocation("",$request->uri);
 
     #check if we know where we are
-    if ($ENV{'request.course.fn'} && !&Apache::lonnet::symbread()) { 
+    if ($env{'request.course.fn'} && !&Apache::lonnet::symbread()) { 
 	# if we are browsing we might not be able to know where we are
 	if ($Apache::lonhomework::browse ne 'F' && 
-	    $ENV{'request.state'} ne "construct") {
+	    $env{'request.state'} ne "construct") {
 	    #should know where we are, so ask
 	    if ( &Apache::lonnet::mod_perl_version() == 2 ) {
 		&Apache::lonnet::cleanenv();
@@ -892,31 +892,31 @@
     }
     if (&setupheader($request)) { return OK; }
     &Apache::lonxml::debug("Permissions:$Apache::lonhomework::browse:$Apache::lonhomework::viewgrades:");
-    &Apache::lonxml::debug("Problem Mode ".$ENV{'form.problemmode'});
+    &Apache::lonxml::debug("Problem Mode ".$env{'form.problemmode'});
     my ($symb) = &Apache::lonxml::whichuser();
     &Apache::lonxml::debug('symb is '.$symb);
-    if ($ENV{'request.state'} eq "construct" || $symb eq '') {
-	if ($ENV{'form.resetdata'} eq &mt('Reset Submissions') ||
-	    $ENV{'form.resetdata'} eq &mt('New Problem Variation') ||
-	    $ENV{'form.newrandomization'} eq &mt('New Randomization')) {
+    if ($env{'request.state'} eq "construct" || $symb eq '') {
+	if ($env{'form.resetdata'} eq &mt('Reset Submissions') ||
+	    $env{'form.resetdata'} eq &mt('New Problem Variation') ||
+	    $env{'form.newrandomization'} eq &mt('New Randomization')) {
 	    my ($symb,$courseid,$domain,$name) = &Apache::lonxml::whichuser();
 	    &Apache::lonnet::tmpreset($symb,'',$domain,$name);
 	    &Apache::lonxml::debug("Attempt reset");
 	}
     }
-    if ($ENV{'request.state'} eq "construct") {
+    if ($env{'request.state'} eq "construct") {
 	if ( -e $file ) {
 	    &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
 						    ['problemmode']);
-	    if (!(defined $ENV{'form.problemmode'})) {
+	    if (!(defined $env{'form.problemmode'})) {
 		#first visit to problem in construction space
 		#&view_or_edit_menu($request);
-		$ENV{'form.problemmode'}='View';
+		$env{'form.problemmode'}='View';
 		&renderpage($request,$file);
-	    } elsif ($ENV{'form.problemmode'} eq &mt('EditXML') ||
-		     $ENV{'form.problemmode'} eq 'EditXML') {
+	    } elsif ($env{'form.problemmode'} eq &mt('EditXML') ||
+		     $env{'form.problemmode'} eq 'EditXML') {
 		&editxmlmode($request,$file);
-	    } elsif ($ENV{'form.problemmode'} eq &mt('Calculate answers')) {
+	    } elsif ($env{'form.problemmode'} eq &mt('Calculate answers')) {
 		&analyze($request,$file);
 	    } else {
 		&renderpage($request,$file);
Index: loncom/homework/lonsimpleproblemedit.pm
diff -u loncom/homework/lonsimpleproblemedit.pm:1.14 loncom/homework/lonsimpleproblemedit.pm:1.15
--- loncom/homework/lonsimpleproblemedit.pm:1.14	Thu Mar 17 08:56:32 2005
+++ loncom/homework/lonsimpleproblemedit.pm	Thu Apr  7 02:56:22 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Simple Problem Parameter Setting "Editor"
 #
-# $Id: lonsimpleproblemedit.pm,v 1.14 2005/03/17 13:56:32 albertel Exp $
+# $Id: lonsimpleproblemedit.pm,v 1.15 2005/04/07 06:56:22 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -56,7 +56,7 @@
 	      'simple_edit_button' => 'off',
 	      'devalidatecourseresdata'=>'on');
     return &Apache::loncommon::get_student_view($symb,time,time,
-						$ENV{'request.course.id'},
+						$env{'request.course.id'},
 						'web',\%data);
 }
 
@@ -150,7 +150,7 @@
     }
 
 # -------------------------------------------------------------------- Allowed?
-    unless (&Apache::lonnet::allowed('mdc',$ENV{'request.course.id'})) {
+    unless (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
 	return HTTP_NOT_ACCEPTABLE; 
     }
 # ----------------------------------------------------------------- Send header
@@ -162,44 +162,44 @@
     my $symb=&Apache::lonnet::symbread();
 
 # ------------------------------------------------ Prefix for everything stored
-    $prefix=$ENV{'request.course.id'}.'.'.$symb.'.0.';
+    $prefix=$env{'request.course.id'}.'.'.$symb.'.0.';
 # ---------------------------------------------------------- Anything to store?
 
-    if (($symb) && (defined($ENV{'form.questiontype'}))) {
+    if (($symb) && (defined($env{'form.questiontype'}))) {
         my %storecontent=();
         undef %storecontent;
-        if ($ENV{'form.questiontype'} eq 'option') {
-	    my %curoptions=&evaloptionhash($ENV{'form.options'});
-	    if ($ENV{'form.delopt'}) {
-		delete $curoptions{$ENV{'form.delopt'}};
+        if ($env{'form.questiontype'} eq 'option') {
+	    my %curoptions=&evaloptionhash($env{'form.options'});
+	    if ($env{'form.delopt'}) {
+		delete $curoptions{$env{'form.delopt'}};
 	    }
-	    if ($ENV{'form.newopt'}) {
-		$ENV{'form.newopt'}=~s/\'/\\\'/g;
-                $curoptions{$ENV{'form.newopt'}}=$ENV{'form.newopt'};
+	    if ($env{'form.newopt'}) {
+		$env{'form.newopt'}=~s/\'/\\\'/g;
+                $curoptions{$env{'form.newopt'}}=$env{'form.newopt'};
 	    }
-            $ENV{'form.options'}="('".join("','",keys %curoptions)."')";
+            $env{'form.options'}="('".join("','",keys %curoptions)."')";
 	}
-	$ENV{'form.hiddenparts'}='!'.$ENV{'form.questiontype'};
-        foreach (keys %ENV) {
+	$env{'form.hiddenparts'}='!'.$env{'form.questiontype'};
+        foreach (keys %env) {
 	    if ($_=~/^form\.(\w+)$/) {
                 my $parm=$1;
-		$storecontent{$prefix.$parm}=$ENV{'form.'.$parm};
+		$storecontent{$prefix.$parm}=$env{'form.'.$parm};
                 $storecontent{$prefix.$parm}=~s/^\s+//s;
 		$storecontent{$prefix.$parm}=~s/\s+$//s;
 	    }
 	}
 	my $reply=&Apache::lonnet::cput
 	    ('resourcedata',\%storecontent,
-	     $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
-	     $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+	     $env{'course.'.$env{'request.course.id'}.'.domain'},
+	     $env{'course.'.$env{'request.course.id'}.'.num'});
 
     }
 # ------------------------------------------------------------------- Read Data
 
     %qparms=&Apache::lonnet::dump('resourcedata',
-		     $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
-		     $ENV{'course.'.$ENV{'request.course.id'}.'.num'},
-		     $ENV{'request.course.id'}.'.'.$symb);
+		     $env{'course.'.$env{'request.course.id'}.'.domain'},
+		     $env{'course.'.$env{'request.course.id'}.'.num'},
+		     $env{'request.course.id'}.'.'.$symb);
 
 # ------------------------------------------------------------ Print the screen
     $r->print(<<ENDDOCUMENT);
Index: loncom/homework/matchresponse.pm
diff -u loncom/homework/matchresponse.pm:1.51 loncom/homework/matchresponse.pm:1.52
--- loncom/homework/matchresponse.pm:1.51	Fri Feb 11 20:13:56 2005
+++ loncom/homework/matchresponse.pm	Thu Apr  7 02:56:22 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Full matching style response
 #
-# $Id: matchresponse.pm,v 1.51 2005/02/12 01:13:56 albertel Exp $
+# $Id: matchresponse.pm,v 1.52 2005/04/07 06:56:22 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -32,6 +32,7 @@
 use Math::Random();
 use Apache::optionresponse();
 use Apache::lonlocal;
+use Apache::lonnet;
 
 BEGIN {
     &Apache::lonxml::register('Apache::matchresponse',('matchresponse'));
@@ -510,7 +511,7 @@
 	    $result='<table><tr><td valign="top">'.$question.
 		'</td><td valign="top">'.$result.'</td></tr></table>';
 	} else {
-	    my $tabsize=&Apache::londefdef::recalc($ENV{'form.textwidth'});
+	    my $tabsize=&Apache::londefdef::recalc($env{'form.textwidth'});
 	    my ($lefttabsize,$righttabsize)=(0,0);
 	    if ($Apache::matchresponse::TeXitemgroupwidth ne '') {
 		$Apache::matchresponse::TeXitemgroupwidth=~/(\d*.?\d*)/;
@@ -532,7 +533,7 @@
 	    $result='<table><tr><td valign="top">'.$result.
 		'</td><td valign="top">'.$question.'</td></tr></table>';
 	} else {
-	    my $tabsize=&Apache::londefdef::recalc($ENV{'form.textwidth'});
+	    my $tabsize=&Apache::londefdef::recalc($env{'form.textwidth'});
 	    my ($lefttabsize,$righttabsize)=(0,0);
 	    if ($Apache::matchresponse::TeXitemgroupwidth ne '') {
 		$Apache::matchresponse::TeXitemgroupwidth=~/(\d*.?\d*)/;
Index: loncom/homework/optionresponse.pm
diff -u loncom/homework/optionresponse.pm:1.124 loncom/homework/optionresponse.pm:1.125
--- loncom/homework/optionresponse.pm:1.124	Mon Jan 31 17:00:40 2005
+++ loncom/homework/optionresponse.pm	Thu Apr  7 02:56:22 2005
@@ -1,7 +1,7 @@
 # LearningOnline Network with CAPA
 # option list style responses
 #
-# $Id: optionresponse.pm,v 1.124 2005/01/31 22:00:40 albertel Exp $
+# $Id: optionresponse.pm,v 1.125 2005/04/07 06:56:22 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -29,6 +29,7 @@
 use strict;
 use Apache::response();
 use Apache::lonlocal;
+use Apache::lonnet;
 
 BEGIN {
   &Apache::lonxml::register('Apache::optionresponse',('optionresponse'));
@@ -121,14 +122,14 @@
     my @options;
     my $optchanged=0;
     eval '@options ='.&Apache::lonxml::get_param('options',$parstack,$safeeval);
-    if ($ENV{"form.$Apache::lonxml::curdepth.deleteopt"}) {
-      my $delopt=$ENV{"form.$Apache::lonxml::curdepth.deleteopt"};
+    if ($env{"form.$Apache::lonxml::curdepth.deleteopt"}) {
+      my $delopt=$env{"form.$Apache::lonxml::curdepth.deleteopt"};
       &Apache::lonxml::debug("Deleting :$delopt:");
       splice(@options,$delopt-1,1);
       $optchanged=1;
     }
-    if ($ENV{"form.$Apache::lonxml::curdepth.options"}) {
-      my $newopt = $ENV{"form.$Apache::lonxml::curdepth.options"};
+    if ($env{"form.$Apache::lonxml::curdepth.options"}) {
+      my $newopt = $env{"form.$Apache::lonxml::curdepth.options"};
       if ($options[0]) {
 	push(@options,$newopt);
       } else {
@@ -192,7 +193,7 @@
 	my $ignored=0;
 	foreach $name (@whichopt) {
 	  my $response=&Apache::response::getresponse($temp);
-	  if ($ENV{'form.submitted'} eq 'scantron' && $response=~/\S/) {
+	  if ($env{'form.submitted'} eq 'scantron' && $response=~/\S/) {
 	      $response = $opt[$response];
 	  }
 	  if ( $response =~ /[^\s]/) {
@@ -511,11 +512,11 @@
     my $number_of_bubbles = $#opt + 1;
     my $current_length = 0;
     my $textwidth;
-    if ($ENV{'form.textwidth'} ne '') {
-	$ENV{'form.textwidth'}=~/(\d+)/;
+    if ($env{'form.textwidth'} ne '') {
+	$env{'form.textwidth'}=~/(\d+)/;
 	$textwidth=$1;
     } else {
-	$ENV{'textwidth'}=~/(\d*)\.?(\d*)/;
+	$env{'form.textwidth'}=~/(\d*)\.?(\d*)/;
 	$textwidth=$1.'.'.$2;
     }
     for (my $ind=0;$ind<=$number_of_bubbles;$ind++) {
Index: loncom/homework/outputtags.pm
diff -u loncom/homework/outputtags.pm:1.37 loncom/homework/outputtags.pm:1.38
--- loncom/homework/outputtags.pm:1.37	Mon Mar 28 16:49:31 2005
+++ loncom/homework/outputtags.pm	Thu Apr  7 02:56:22 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # tags that create controlled output
 #
-# $Id: outputtags.pm,v 1.37 2005/03/28 21:49:31 albertel Exp $
+# $Id: outputtags.pm,v 1.38 2005/04/07 06:56:22 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -122,7 +122,7 @@
 
 sub multipart {
     my ($uri)=@_;
-    if (!defined($uri)) { $uri=$ENV{'request.uri'}; }
+    if (!defined($uri)) { $uri=$env{'request.uri'}; }
     my @parts;
     my $metadata = &Apache::lonnet::metadata($uri,'packages');
     foreach (split(/\,/,$metadata)) {
@@ -152,7 +152,7 @@
 	    if (!defined($weight) || ($weight eq '')) { $weight=1; }
 	    $result.=$weight;
 	} else {
-	    my @parts=&multipart($ENV{'request.uri'});
+	    my @parts=&multipart($env{'request.uri'});
 	    my $weight;
 	    if (@parts) {
 	        foreach my $part (@parts) {
@@ -185,7 +185,7 @@
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
     my $result;
     my (undef,undef,$domain,$user) = &Apache::lonxml::whichuser();
-    if ($target eq 'web' && $user eq $ENV{'user.name'}) {
+    if ($target eq 'web' && $user eq $env{'user.name'}) {
 	my $url=&Apache::lonnet::studentphoto($domain,$user,"gif");
 	my $args;
 	my $width=&Apache::lonxml::get_param('width',$parstack,$safeeval);
@@ -196,7 +196,7 @@
 	if ($align) { $args.=" align=\"$align\" "; }
 	$result.=" <img $args src=\"$url\" alt=\"$user\@$domain\" />";
     }
-    if ($target eq 'tex' && $ENV{'request.role'} =~ /^cc/) {
+    if ($target eq 'tex' && $env{'request.role'} =~ /^cc/) {
 	my $url=&Apache::lonnet::studentphoto($domain,$user,"eps");
 	my $ua=new LWP::UserAgent;
 	my $request=new HTTP::Request('GET',$url);
Index: loncom/homework/radiobuttonresponse.pm
diff -u loncom/homework/radiobuttonresponse.pm:1.99 loncom/homework/radiobuttonresponse.pm:1.100
--- loncom/homework/radiobuttonresponse.pm:1.99	Mon Jan 31 17:00:40 2005
+++ loncom/homework/radiobuttonresponse.pm	Thu Apr  7 02:56:22 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # mutliple choice style responses
 #
-# $Id: radiobuttonresponse.pm,v 1.99 2005/01/31 22:00:40 albertel Exp $
+# $Id: radiobuttonresponse.pm,v 1.100 2005/04/07 06:56:22 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -30,6 +30,7 @@
 use strict;
 use HTML::Entities();
 use Apache::lonlocal;
+use Apache::lonnet;
 
 BEGIN {
     &Apache::lonxml::register('Apache::radiobuttonresponse',('radiobuttonresponse'));
@@ -115,7 +116,7 @@
 
 sub storesurvey {
     if ( !&Apache::response::submitted() ) { return ''; }
-    my $response = $ENV{'form.HWVAL_'.$Apache::inputtags::response['-1']};
+    my $response = $env{'form.HWVAL_'.$Apache::inputtags::response['-1']};
     &Apache::lonxml::debug("Here I am!:$response:");
     if ( $response !~ /[0-9]+/) { return ''; }
     my $part = $Apache::inputtags::part;
@@ -139,10 +140,10 @@
     my ($answer,@whichfoils)=&whichfoils($max,$randomize);
     if ( !&Apache::response::submitted() ) { return; }
     my $response;
-    if ($ENV{'form.submitted'} eq 'scantron') {
+    if ($env{'form.submitted'} eq 'scantron') {
 	$response=&Apache::response::getresponse();
     } else {
-	$response = $ENV{'form.HWVAL_'.$Apache::inputtags::response['-1']};
+	$response = $env{'form.HWVAL_'.$Apache::inputtags::response['-1']};
     }
     if ( $response !~ /[0-9]+/) { return; }
     my $part=$Apache::inputtags::part;
Index: loncom/homework/randomlabel.pm
diff -u loncom/homework/randomlabel.pm:1.66 loncom/homework/randomlabel.pm:1.67
--- loncom/homework/randomlabel.pm:1.66	Wed Mar 16 16:35:17 2005
+++ loncom/homework/randomlabel.pm	Thu Apr  7 02:56:22 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # random labelling tool
 #
-# $Id: randomlabel.pm,v 1.66 2005/03/16 21:35:17 raeburn Exp $
+# $Id: randomlabel.pm,v 1.67 2005/04/07 06:56:22 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -25,9 +25,6 @@
 #
 # http://www.lon-capa.org/
 #
-# 7/20/2001 Isaac Tsai, initial syntax
-# 8/10/2001 Isaac Tsai, 
-# 8/30/2001 Isaac Tsai, 
 # SYNTAX:
 # <randomlabel bgimg="URL" width="12" height="45" texwidth="50">
 #    <labelgroup name="GroupOne" type="image">
Index: loncom/homework/randomlylabel.pm
diff -u loncom/homework/randomlylabel.pm:1.25 loncom/homework/randomlylabel.pm:1.26
--- loncom/homework/randomlylabel.pm:1.25	Wed Mar 23 10:27:48 2005
+++ loncom/homework/randomlylabel.pm	Thu Apr  7 02:56:22 2005
@@ -2,7 +2,7 @@
 # The LearningOnline Network with CAPA
 # randomlabel.png: composite together text and images into 1 image
 #
-# $Id: randomlylabel.pm,v 1.25 2005/03/23 15:27:48 www Exp $
+# $Id: randomlylabel.pm,v 1.26 2005/04/07 06:56:22 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -205,6 +205,7 @@
 use GD;
 use GD::Polyline();
 use LWP::UserAgent();
+use Apache::lonnet;
 
 sub get_image {
     my ($imgsrc,$set_trans)=@_;
@@ -275,8 +276,8 @@
 	&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'});
 	$prefix='form.';
     }
-    if (defined($ENV{$prefix."BGIMG"})) {
-	my $bgimg=&Apache::lonnet::unescape($ENV{$prefix."BGIMG"});
+    if (defined($env{$prefix."BGIMG"})) {
+	my $bgimg=&Apache::lonnet::unescape($env{$prefix."BGIMG"});
 	#&Apache::lonnet::logthis("BGIMG is ".$bgimg);
 	$image=&get_image($bgimg,0);
 	if (! defined($image)) {
@@ -284,10 +285,10 @@
 				     $id.'-'.$bgimg);
 	    return OK;
 	}
-    } elsif (defined($ENV{$prefix."SIZE"})) {
-	my ($width,$height)=split(':',$ENV{$prefix."SIZE"});
+    } elsif (defined($env{$prefix."SIZE"})) {
+	my ($width,$height)=split(':',$env{$prefix."SIZE"});
 	$image = new GD::Image($width,$height,1);
-	my ($bgcolor)=split(':',$ENV{$prefix."BGCOLOR"});
+	my ($bgcolor)=split(':',$env{$prefix."BGCOLOR"});
 	if ($bgcolor ne 'transparent') {
 	    $bgcolor=&get_color_from_hexstring($image,$bgcolor);
 #	$image->rectangle(0,0,$width,$height,$bgcolor);
@@ -302,12 +303,12 @@
 	return OK;
     }
     #binmode(STDOUT);
-    my @objtypes=split(':',$ENV{$prefix."OBJTYPE"});
-    foreach(my $i=0;$i<$ENV{$prefix."OBJCOUNT"};$i++) {
+    my @objtypes=split(':',$env{$prefix."OBJTYPE"});
+    foreach(my $i=0;$i<$env{$prefix."OBJCOUNT"};$i++) {
 	my $type=shift(@objtypes);
 	if ($type eq 'LINE') {
 	    my ($x1,$y1,$x2,$y2,$color,$thickness)=
-		split(':',$ENV{$prefix."OBJ$i"});
+		split(':',$env{$prefix."OBJ$i"});
 	    my $imcolor=&get_color_from_hexstring($image,$color);
 	    if (!defined($thickness)) { $thickness=1; }
 	    $image->setThickness($thickness);
@@ -315,7 +316,7 @@
 	    $image->line($x1,$y1,$x2,$y2,$imcolor);
 	} elsif ($type eq 'RECTANGLE') {
 	    my ($x1,$y1,$x2,$y2,$color,$thickness,$filled)=
-		split(':',$ENV{$prefix."OBJ$i"});
+		split(':',$env{$prefix."OBJ$i"});
 	    if ($x1 > $x2) { my $temp=$x1;$x1=$x2;$x2=$temp; }
 	    if ($y1 > $y2) { my $temp=$y1;$y1=$y2;$y2=$temp; }
 	    my $imcolor=&get_color_from_hexstring($image,$color);
@@ -328,12 +329,12 @@
 		$image->rectangle($x1,$y1,$x2,$y2,$imcolor);
 	    }
 	} elsif ($type eq 'POLYGON') {
-	    my ($color,$width,$open,$filled)=split(':',$ENV{$prefix."OBJ$i"});
+	    my ($color,$width,$open,$filled)=split(':',$env{$prefix."OBJ$i"});
 	    my $imcolor=&get_color_from_hexstring($image,$color);
 	    my $polygon = (($open && lc ($open ne 'no')) ?
 			   (new GD::Polyline) : (new GD::Polygon));
 	    my $added=0;
-	    foreach my $coord (split('-',$ENV{$prefix."OBJEXTRA$i"})) {
+	    foreach my $coord (split('-',$env{$prefix."OBJEXTRA$i"})) {
 		my ($x,$y)=($coord=~m/\(([0-9]+),([0-9]+)\)/);
 		$polygon->addPt($x,$y);
 		$added++;
@@ -351,7 +352,7 @@
 	    }
 	} elsif ($type eq 'ARC') {
 	    my ($x,$y,$width,$height,$start,$end,$color,$thickness,$filled)=
-		split(':',$ENV{$prefix."OBJ$i"});
+		split(':',$env{$prefix."OBJ$i"});
 	    if (!$color) { $color='000000'; }
 	    my $imcolor=&get_color_from_hexstring($image,$color);
 	    if (!defined($thickness)) { $thickness=1; }
@@ -364,13 +365,13 @@
 		$image->arc($x,$y,$width,$height,$start,$end,$imcolor);
 	    }
 	} elsif ($type eq 'FILL') {
-	    my ($x,$y,$color)=split(':',$ENV{$prefix."OBJ$i"});
+	    my ($x,$y,$color)=split(':',$env{$prefix."OBJ$i"});
 	    if (!$color) { $color='000000'; }
 	    my $imcolor=&get_color_from_hexstring($image,$color);
 	    $image->fill($x,$y,$imcolor);
 	} elsif ($type eq 'IMAGE') {
 	    my ($x,$y,$file,$transparent,$srcX,$srcY,$destW,$destH,$srcW,
-		$srcH)=split(':',$ENV{$prefix."OBJ$i"});
+		$srcH)=split(':',$env{$prefix."OBJ$i"});
 	    $file=&Apache::lonnet::unescape($file);
 	    if (!defined($transparent)) { $transparent=1; }
 	    my $subimage=&get_image($file,$transparent);
@@ -387,7 +388,7 @@
 				$srcW,$srcH);
 	} elsif ($type eq 'LABEL') {
 	    my ($x,$y,$text,$font,$color,$direction)=
-		split(':',$ENV{$prefix."OBJ$i"});
+		split(':',$env{$prefix."OBJ$i"});
 	    $text=&Apache::lonnet::unescape($text);
 	    my $imcolor=&get_color_from_hexstring($image,$color);
 	    my $type='normal';
Index: loncom/homework/response.pm
diff -u loncom/homework/response.pm:1.119 loncom/homework/response.pm:1.120
--- loncom/homework/response.pm:1.119	Mon Apr  4 14:14:58 2005
+++ loncom/homework/response.pm	Thu Apr  7 02:56:22 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # various response type definitons response definition
 #
-# $Id: response.pm,v 1.119 2005/04/04 18:14:58 albertel Exp $
+# $Id: response.pm,v 1.120 2005/04/07 06:56:22 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -29,6 +29,7 @@
 package Apache::response;
 use strict;
 use Apache::lonlocal;
+use Apache::lonnet;
 
 BEGIN {
     &Apache::lonxml::register('Apache::response',('responseparam','parameter','dataresponse'));
@@ -303,7 +304,7 @@
 sub view_or_modify {
     my ($symb,$courseid,$domain,$name) = &Apache::lonxml::whichuser();
     my $myself=0;
-    if ( ($name eq $ENV{'user.name'}) && ($domain eq $ENV{'user.domain'}) ) {
+    if ( ($name eq $env{'user.name'}) && ($domain eq $env{'user.domain'}) ) {
 	$myself=1;
     }
     my $vgr=&Apache::lonnet::allowed('vgr',$courseid);
@@ -334,14 +335,14 @@
     my $result;
     if ( $target eq 'web' ) {
     } elsif ($target eq 'grade' ) {
-	if ( defined $ENV{'form.submitted'}) {
+	if ( defined $env{'form.submitted'}) {
 	    my ($symb,$courseid,$domain,$name)=&Apache::lonxml::whichuser();
 	    my $allowed=&Apache::lonnet::allowed('mgr',$courseid);
 	    if ($allowed) {
 		&Apache::response::setup_params('dataresponse',$safeeval);
 		my $partid = $Apache::inputtags::part;
 		my $id = $Apache::inputtags::response['-1'];
-		my $response = $ENV{'form.HWVAL_'.$id};
+		my $response = $env{'form.HWVAL_'.$id};
 		my $name = &Apache::lonxml::get_param('name',$parstack,$safeeval);
 		if ( $response =~ /[^\s]/) {
 		    $Apache::lonhomework::results{"resource.$partid.$id.$name"}=$response;
@@ -409,8 +410,8 @@
 						     $safeeval,'name','type',
 						     'description','default');
 	my $element=&Apache::edit::html_element_name('parameter_package');
-	if (defined($ENV{"form.$element"}) && $ENV{"form.$element"} ne '') {
-	    my $name=$ENV{"form.$element"};
+	if (defined($env{"form.$element"}) && $env{"form.$element"} ne '') {
+	    my $name=$env{"form.$element"};
 	    my $tag=&decide_package($tagstack);
 	    $token->[2]->{'name'}=$name;
 	    $token->[2]->{'type'}=
@@ -427,7 +428,7 @@
 	}
     } elsif ($target eq 'grade' || $target eq 'answer' || $target eq 'web' ||
 	     $target eq 'tex' || $target eq 'analyze' ) {
-	if ($ENV{'request.state'} eq 'construct') {
+	if ($env{'request.state'} eq 'construct') {
 	    my $name   =&Apache::lonxml::get_param('name',$parstack,$safeeval);
 	    my $default=&Apache::lonxml::get_param('default',$parstack,
 						     $safeeval);
@@ -458,7 +459,7 @@
 sub setup_params {
     my ($tag,$safeeval) = @_;
 
-    if ($ENV{'request.state'} eq 'construct') { return; }
+    if ($env{'request.state'} eq 'construct') { return; }
     my %paramlist=();
     foreach my $key (keys(%Apache::lonnet::packagetab)) {
 	if ($key =~ /^$tag/) {
@@ -490,7 +491,7 @@
 sub answer_header {
     my ($type) = @_;
     my $result;
-    if ($ENV{'form.answer_output_mode'} eq 'tex') {
+    if ($env{'form.answer_output_mode'} eq 'tex') {
 	$result = ' \vskip 0 mm \begin{tabular}{|c|}\hline Answer for Part: \verb|'.
                   $Apache::inputtags::part.'| \\\\ \hline ';
     } else {
@@ -503,7 +504,7 @@
 sub answer_part {
     my ($type,$answer) = @_;
     my $result;
-    if ($ENV{'form.answer_output_mode'} eq 'tex') {
+    if ($env{'form.answer_output_mode'} eq 'tex') {
 	$result = ' \verb|'.$answer.'|\\\\ \hline ';
     } else {
 	$result = '<td>'.$answer.'</td>';
@@ -514,7 +515,7 @@
 sub answer_footer {
     my ($type) = @_;
     my $result;
-    if ($ENV{'form.answer_output_mode'} eq 'tex') {
+    if ($env{'form.answer_output_mode'} eq 'tex') {
 	$result = ' \end{tabular} \vskip 0 mm ';
     } else {
 	$result = '</tr></table>';
@@ -523,10 +524,10 @@
 }
 
 sub showallfoils {
-    if (defined($ENV{'form.showallfoils'})) {
+    if (defined($env{'form.showallfoils'})) {
 	my ($symb)=&Apache::lonxml::whichuser();
-	if (($ENV{'request.state'} eq 'construct') || 
-	    ($ENV{'user.adv'} && $symb eq '')      ||
+	if (($env{'request.state'} eq 'construct') || 
+	    ($env{'user.adv'} && $symb eq '')      ||
             ($Apache::lonhomework::viewgrades) ) {
 	    return 1;
 	}
@@ -548,10 +549,10 @@
 		    'I'=>8,'J'=>9,'K'=>10,'L'=>11,'M'=>12,'N'=>13,'O'=>14,
 		    'P'=>15,'Q'=>16,'R'=>17,'S'=>18,'T'=>19,'U'=>20,'V'=>21,
 		    'W'=>22,'X'=>23,'Y'=>24,'Z'=>25);
-    if ($ENV{'form.submitted'} eq 'scantron') {
+    if ($env{'form.submitted'} eq 'scantron') {
 	my $part  = $Apache::inputtags::part;
 	my $id    = $Apache::inputtags::response[-1];
-	$response = $ENV{'scantron.'.($Apache::lonxml::counter+$temp-1).
+	$response = $env{'scantron.'.($Apache::lonxml::counter+$temp-1).
 			 '.answer'};
 	# save bubbled letter for later
 	$Apache::lonhomework::results{"resource.$part.$id.scantron"}.=
@@ -564,7 +565,7 @@
 	    }
 	}
     } else {
-	$response = $ENV{$formparm};
+	$response = $env{$formparm};
     }
     return $response;
 }
@@ -715,7 +716,7 @@
 sub get_response_param {
     my ($id,$name,$default)=@_;
     my $parameter;
-    if ($ENV{'request.state'} eq 'construct' &&
+    if ($env{'request.state'} eq 'construct' &&
 	defined($Apache::inputtags::params{$name})) {
 	$parameter=$Apache::inputtags::params{$name};
     } else {
@@ -731,12 +732,12 @@
     my ($who)=@_;
     
     # when scatron grading any submission is a submission
-    if ($ENV{'form.submitted'} eq 'scantron') { return 1; }
+    if ($env{'form.submitted'} eq 'scantron') { return 1; }
     # if the caller only cared if this was a scantron submission
     if ($who eq 'scantron') { return 0; }
     # if the Submit Answer button for this particular part was pressed
     my $partid=$Apache::inputtags::part;
-    if (defined($ENV{'form.submit_'.$partid})) { return 1; }
+    if (defined($env{'form.submit_'.$partid})) { return 1; }
     # otherwise no submission occured
     return 0;
 }
Index: loncom/homework/structuretags.pm
diff -u loncom/homework/structuretags.pm:1.283 loncom/homework/structuretags.pm:1.284
--- loncom/homework/structuretags.pm:1.283	Fri Apr  1 13:08:14 2005
+++ loncom/homework/structuretags.pm	Thu Apr  7 02:56:22 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # definition of tags that give a structure to a document
 #
-# $Id: structuretags.pm,v 1.283 2005/04/01 18:08:14 albertel Exp $
+# $Id: structuretags.pm,v 1.284 2005/04/07 06:56:22 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -88,8 +88,8 @@
 	    &Apache::lonxml::fontsettings();     
     }
     my $body_tag_start;
-    if (!defined($found{'body'}) && $ENV{'request.state'} eq 'construct'
-	&& $ENV{'environment.remote'} eq 'off') {
+    if (!defined($found{'body'}) && $env{'request.state'} eq 'construct'
+	&& $env{'environment.remote'} eq 'off') {
 	$body_tag_start=&Apache::loncommon::bodytag();
 	$body_tag_start.=&Apache::lonxml::message_location();
     } elsif (!defined($found{'body'})) {
@@ -97,7 +97,7 @@
 	    'onunload="'.&Apache::lonmenu::unloadevents().'" ';
 	my $background=&Apache::lonxml::get_param('background',$parstack,
 						  $safeeval);
-	if ($ENV{'browser.imagesuppress'} eq 'on') { $background=''; }
+	if ($env{'browser.imagesuppress'} eq 'on') { $background=''; }
 	if ($background) {
 	    $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
 		$background;
@@ -105,23 +105,23 @@
 	} else {
 	    my $bgcolor=&Apache::lonxml::get_param('bgcolor',$parstack,
 						   $safeeval);
-	    if (($bgcolor) && ($ENV{'browser.blackwhite'} ne 'on')) {
+	    if (($bgcolor) && ($env{'browser.blackwhite'} ne 'on')) {
 		$body_tag_start.='bgcolor="'.$bgcolor.'" ';
 	    } else {
 		$body_tag_start.='bgcolor="#ffffff"';
 	    }
 	}
-	if ($ENV{'browser.fontenhance'} eq 'on') {
+	if ($env{'browser.fontenhance'} eq 'on') {
 	    $body_tag_start.=' style="font-size: x-large;" ';
 	}
 	$body_tag_start.='>'.&Apache::lonmenu::menubuttons(undef,$target,1);
-	if ($ENV{'environment.texengine'} eq 'jsMath') {
+	if ($env{'environment.texengine'} eq 'jsMath') {
 	    $body_tag_start.='<script type="text/javascript">
                      function NoFontMessage () {}
                    </script>'."\n".
 		       '<script src="/adm/jsMath/jsMath.js"></script>'."\n";
 	}
-	if ($target eq 'web' && $ENV{'request.state'} ne 'construct') {
+	if ($target eq 'web' && $env{'request.state'} ne 'construct') {
 	    my ($symb,undef,undef,undef,$publicuser)=
 		&Apache::lonxml::whichuser();
 	    if ($symb eq '' && !$publicuser) {
@@ -135,8 +135,8 @@
     my $form_tag_start;
     if (!defined($found{'form'})) {
 	$form_tag_start='<form name="lonhomework" enctype="multipart/form-data" method="POST" action="';
-	my $uri=$ENV{'request.uri'};
-	if ($ENV{'request.enc'}) { $uri=&Apache::lonenc::encrypted($uri); }
+	my $uri=$env{'request.uri'};
+	if ($env{'request.enc'}) { $uri=&Apache::lonenc::encrypted($uri); }
 	$form_tag_start.=$uri.'">';
     }
     return ($result,$head_tag_start,$body_tag_start,$form_tag_start);
@@ -155,7 +155,7 @@
 	if ($name eq 'con_lost') { $name = ''; }
     }
     if ($name!~/\S+/) {
-	$name=$ENV{'request.uri'};
+	$name=$env{'request.uri'};
 	$name=~s-.*/([^/]+)$-$1-;
     }
     $Apache::lonhomework::name=$name;
@@ -166,23 +166,23 @@
     my ($safeeval)=@_;
     my $rndseed;
     my ($symb)=&Apache::lonxml::whichuser();
-    if ($ENV{'request.state'} eq "construct" || $symb eq '' ||
+    if ($env{'request.state'} eq "construct" || $symb eq '' ||
           $Apache::lonhomework::history{'resource.CODE'}) {
-	$rndseed=$ENV{'form.rndseed'};
+	$rndseed=$env{'form.rndseed'};
 	if (!$rndseed) {
 	    $rndseed=$Apache::lonhomework::history{'rndseed'};
 	    if (!$rndseed) {
 		$rndseed=time;
 	    }
-	    $ENV{'form.rndseed'}=$rndseed;
+	    $env{'form.rndseed'}=$rndseed;
 	}
-	if ($ENV{'form.resetdata'} eq &mt('New Problem Variation') ||
-	    $ENV{'form.newrandomization'} eq &mt('New Randomization')) {
+	if ($env{'form.resetdata'} eq &mt('New Problem Variation') ||
+	    $env{'form.newrandomization'} eq &mt('New Randomization')) {
 	    srand(time);
 	    $rndseed=int(rand(2100000000));
-	    $ENV{'form.rndseed'}=$rndseed;
-	    delete($ENV{'form.resetdata'});
-	    delete($ENV{'form.newrandomization'});
+	    $env{'form.rndseed'}=$rndseed;
+	    delete($env{'form.resetdata'});
+	    delete($env{'form.newrandomization'});
 	}
 	if (defined($rndseed) && $rndseed ne int($rndseed)) {
 	   $rndseed=join(',',&Math::Random::random_seed_from_phrase($rndseed));
@@ -200,9 +200,9 @@
 
 sub remember_problem_state {
     return '
-       <input type="hidden" name="problemstate" value="'.$ENV{'form.problemstate'}.'" />
-       <input type="hidden" name="problemtype" value="'.$ENV{'form.problemtype'}.'" />
-       <input type="hidden" name="problemstatus" value="'.$ENV{'form.problemstatus'}.'" />';
+       <input type="hidden" name="problemstate" value="'.$env{'form.problemstate'}.'" />
+       <input type="hidden" name="problemtype" value="'.$env{'form.problemtype'}.'" />
+       <input type="hidden" name="problemstatus" value="'.$env{'form.problemstatus'}.'" />';
 }
 
 sub problem_edit_header {
@@ -229,7 +229,7 @@
 sub option {
     my ($value,$name) = @_;
     my $result ="<option value='".$value."' ";
-    if ($ENV{'form.'.$name} eq $value) {
+    if ($env{'form.'.$name} eq $value) {
 	$result.=" selected='on' ";
     }
     $result.='>';
@@ -248,7 +248,7 @@
 	       $rndseed.'"
            onchange="javascript:document.lonhomework.changerandseed.click()" /></nobr>
              <label><input type="checkbox" name="showallfoils" ';
-    if (defined($ENV{'form.showallfoils'})) { $result.='checked="on"'; }
+    if (defined($env{'form.showallfoils'})) { $result.='checked="on"'; }
     $result.= ' />'.&mt('&nbsp;Show&nbsp;All&nbsp;Foils').
 	&Apache::loncommon::help_open_topic('Problem_Editor_Testing_Area','Testing Problems').
 	'</label><hr />';
@@ -283,7 +283,7 @@
 </nobr>
 <input type='submit' name='changeproblemmode' value='".&mt("Change")."' />
 <hr />";
-    my $numtoanalyze=$ENV{'form.numtoanalyze'};
+    my $numtoanalyze=$env{'form.numtoanalyze'};
     if (!$numtoanalyze) { $numtoanalyze=20; }
     $result.= '<input type="submit" name="problemmode" value='.
 	&mt('"Calculate answers').'" /> for
@@ -299,9 +299,9 @@
     %Apache::lonhomework::results=();
     %Apache::lonhomework::history=();
     my ($symb,$courseid,$domain,$name) = &Apache::lonxml::whichuser();
-    if ($ENV{'request.state'} eq 'construct' || $symb eq '') {
+    if ($env{'request.state'} eq 'construct' || $symb eq '') {
 	%Apache::lonhomework::history=
-	    &Apache::lonnet::tmprestore($ENV{'request.uri'},'',$domain,$name);
+	    &Apache::lonnet::tmprestore($env{'request.uri'},'',$domain,$name);
 	my ($temp)=keys %Apache::lonhomework::history ;
 	&Apache::lonxml::debug("Return message of $temp");
     } else {
@@ -322,10 +322,10 @@
     my ($temp) = keys %Apache::lonhomework::results;
     if ( $temp ne '' ) {
 	my ($symb,$courseid,$domain,$name) = &Apache::lonxml::whichuser();
-	if ($ENV{'request.state'} eq 'construct' || $symb eq '') {
-	    $Apache::lonhomework::results{'rndseed'}=$ENV{'form.rndseed'};
+	if ($env{'request.state'} eq 'construct' || $symb eq '') {
+	    $Apache::lonhomework::results{'rndseed'}=$env{'form.rndseed'};
 	    $result=&Apache::lonnet::tmpstore(\%Apache::lonhomework::results,
-					$ENV{'request.uri'},'',$domain,$name);
+					$env{'request.uri'},'',$domain,$name);
 	    &Apache::lonxml::debug('Construct Store return message:'.$result);
 	} else {
 	    $result=&Apache::lonnet::cstore(\%Apache::lonhomework::results,
@@ -349,7 +349,7 @@
 <font color="red">
 <p>$lt{'warning'}</p>
 </font>
-<form name="checkout" method="POST" action="$ENV{'request.uri'}">
+<form name="checkout" method="POST" action="$env{'request.uri'}">
 <input type="hidden" name="doescheckout" value="yes" />
 <input type="button" name="checkoutbutton" value="$lt{'checkout'}" onClick="javascript:if (confirm('$lt{'checkout?'}')) { document.checkout.submit(); }" />
 </form>
@@ -363,7 +363,7 @@
     &Apache::lonxml::debug("map is $map title is $foldertitle");
     return (<<ENDCHECKOUT);
 <h2>The resources in "$foldertitle" are open for a limited time. Once you click the 'Show Resource' button below you have $time to complete all resources "$foldertitle".</h2>
-<form name="markaccess" method="POST" action="$ENV{'request.uri'}">
+<form name="markaccess" method="POST" action="$env{'request.uri'}">
 <input type="hidden" name="markaccess" value="yes" />
 <input type="button" name="accessbutton" value="Show Resource" onClick="javascript:if (confirm('Start Timer?')) { document.markaccess.submit(); }" />
 </form>
@@ -410,7 +410,7 @@
 
 sub set_problem_state {
     my ($part)=@_;
-    if ($ENV{'form.problemstate'} eq 'CANNOT_ANSWER_correct') {
+    if ($env{'form.problemstate'} eq 'CANNOT_ANSWER_correct') {
 	$Apache::lonhomework::history{"resource.$part.solved"}=
 	    'correct_by_student';
     }
@@ -419,13 +419,13 @@
 sub get_problem_status {
     my ($part)=@_;
     my $problem_status;
-    if ($ENV{'request.state'} eq 'construct' &&
-	defined($ENV{'form.problemstatus'})) {
-	$problem_status=$ENV{'form.problemstatus'};
+    if ($env{'request.state'} eq 'construct' &&
+	defined($env{'form.problemstatus'})) {
+	$problem_status=$env{'form.problemstatus'};
     } else {
 	$problem_status=&Apache::lonnet::EXT("resource.$part.problemstatus");
 	&Apache::lonxml::debug("problem status for $part is $problem_status");
-	&Apache::lonxml::debug("env probstat is ".$ENV{'form.problemstatus'});
+	&Apache::lonxml::debug("env probstat is ".$env{'form.problemstatus'});
     }
     return $problem_status;
 }
@@ -443,7 +443,7 @@
     $Apache::lonhomework::parsing_a_problem=1;
     &init_problem_globals('problem');
 
-    if (defined($ENV{'scantron.maxquest'})) {
+    if (defined($env{'scantron.maxquest'})) {
 	$Apache::lonhomework::scantronmode=1;
     }
 
@@ -452,16 +452,16 @@
 	if ($target eq 'web') {
 	    &Apache::lonhomework::showhash(%Apache::lonhomework::history);
 	}
-       	if ($ENV{'request.state'} eq 'construct') { &set_problem_state('0'); }
+       	if ($env{'request.state'} eq 'construct') { &set_problem_state('0'); }
 	$Apache::lonhomework::type=&Apache::lonnet::EXT('resource.0.type');
-	if (($ENV{'request.state'} eq 'construct') &&
-	    defined($ENV{'form.problemtype'})) {
-	    $Apache::lonhomework::type=$ENV{'form.problemtype'};
+	if (($env{'request.state'} eq 'construct') &&
+	    defined($env{'form.problemtype'})) {
+	    $Apache::lonhomework::type=$env{'form.problemtype'};
 	}
 	&Apache::lonxml::debug("Found this to be of type :$Apache::ltonhomework::type:");
     }
     if ($Apache::lonhomework::type eq '' ) {
-	my $uri=$ENV{'request.uri'};
+	my $uri=$env{'request.uri'};
 	if ($uri=~/\.(\w+)$/) {
 	    $Apache::lonhomework::type=$1;
 	    &Apache::lonxml::debug("Using type of $1");
@@ -481,7 +481,7 @@
     #should get back a <html> or the neccesary stuff to start XML/MathML
     my ($result,$head_tag_start,$body_tag_start,$form_tag_start)=
 	&page_start($target,$token,$tagstack,$parstack,$parser,$safeeval);
-    if ($target eq 'tex' and $ENV{'request.symb'} =~ m/\.page_/) {$result='';}
+    if ($target eq 'tex' and $env{'request.symb'} =~ m/\.page_/) {$result='';}
 
     if ($target eq 'analyze') { my $rndseed=&setup_rndseed($safeeval); }
     if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
@@ -490,30 +490,30 @@
 	if ($Apache::lonhomework::type eq 'exam') {
 	    my $token=
 		$Apache::lonhomework::history{"resource.0.outtoken"};
-	    if (($ENV{'form.doescheckout'}) && (!$token)) {
+	    if (($env{'form.doescheckout'}) && (!$token)) {
 		$token=&Apache::lonxml::maketoken();
 		$Apache::lonhomework::history{"resource.0.outtoken"}=
 		    $token;
 	    }
 	    $body_tag_start.=&Apache::lonxml::printtokenheader($target,$token);
 	}
-	if ($ENV{'form.markaccess'}) {
+	if ($env{'form.markaccess'}) {
 	    &Apache::lonnet::set_first_access('map');
 	}
 	#handle rand seed in construction space
 	my $rndseed=&setup_rndseed($safeeval);
 	my ($symb)=&Apache::lonxml::whichuser();
-	if ($ENV{'request.state'} ne "construct" && $symb eq '') {
+	if ($env{'request.state'} ne "construct" && $symb eq '') {
 	    $form_tag_start.='<input type="hidden" name="rndseed" value="'.
 		$rndseed.'" />'.
 		    '<input type="submit" name="resetdata"
                              value="'.&mt('New Problem Variation').'" />'.
 		    '<input type="hidden" name="username"
-                             value="'.$ENV{'form.username'}.'" />';
-	    if ($ENV{'user.adv'}) {
+                             value="'.$env{'form.username'}.'" />';
+	    if ($env{'user.adv'}) {
 		$form_tag_start.=
 		    ' <input type="checkbox" name="showallfoils" ';
-		if (defined($ENV{'form.showallfoils'})) {
+		if (defined($env{'form.showallfoils'})) {
 		    $form_tag_start.='checked="on"';
 		}
 		$form_tag_start.= ' />'.&mt('&nbsp;Show&nbsp;All&nbsp;Foils');
@@ -563,24 +563,24 @@
               $body_tag_start \n $form_tag_start".	
 	      '<input type="hidden" name="submitted" value="yes" />';
 	    # create a page header and exit
-	    if ($ENV{'request.state'} eq "construct") {
-		$result.= &problem_web_to_edit_header($ENV{'form.rndseed'});
+	    if ($env{'request.state'} eq "construct") {
+		$result.= &problem_web_to_edit_header($env{'form.rndseed'});
 	    }
 	    # if we are viewing someone else preserve that info
-	    if (defined $ENV{'form.grade_symb'}) {
+	    if (defined $env{'form.grade_symb'}) {
 		foreach my $field ('symb','courseid','domain','username') {
 		    $result .= '<input type="hidden" name="grade_'.$field.
-			'" value="'.$ENV{"form.grade_$field"}.'" />'."\n";
+			'" value="'.$env{"form.grade_$field"}.'" />'."\n";
 		}
 	    }
 	} elsif ($target eq 'tex') {
 	    my $startminipage = '';
-	    if (not $ENV{'form.problem_split'}=~/yes/) {
+	    if (not $env{'form.problem_split'}=~/yes/) {
 		$startminipage = '\begin{minipage}{\textwidth}';
 	    }
 	    my $id = $Apache::inputtags::part;
 	    my $weight = &Apache::lonnet::EXT("resource.$id.weight");
-	    my $packages=&Apache::lonnet::metadata($ENV{'request.uri'},'packages');
+	    my $packages=&Apache::lonnet::metadata($env{'request.uri'},'packages');
 	    my @packages = split /,/,$packages;
 	    my $allow_print_points = 0;
 	    foreach my $partial_key (@packages) {
@@ -593,7 +593,7 @@
 	    my $duedate = &Apache::lonnet::EXT("resource.$id.duedate"); 
 	    $duedate = POSIX::strftime("%c",localtime($duedate));
 	    my $temp_file;
-	    my $filename = "/home/httpd/prtspool/$ENV{'user.name'}_$ENV{'user.domain'}_printout.due";
+	    my $filename = "/home/httpd/prtspool/$env{'user.name'}_$env{'user.domain'}_printout.due";
 	    if (-e $filename) {
 		$temp_file = Apache::File->new($filename);
 	    } else {
@@ -606,19 +606,19 @@
 	    if ($due_file_content ne $duedate) {
 		$temp_file = Apache::File->new('>'.$filename);
 		print $temp_file "$duedate\n";
-		if (not $ENV{'request.symb'} =~ m/\.page_/) {
+		if (not $env{'request.symb'} =~ m/\.page_/) {
 		    if(not $duedate=~m/1969/ and $Apache::lonhomework::type ne 'exam') {
-			$result .= '\begin{document} \typeout{STAMPOFPASSEDRESOURCESTART Resource <h2>"'.$name_of_resourse.'"</h2> located in <br /><small><b>'.$ENV{'request.uri'}.'</b></small><br /> STAMPOFPASSEDRESOURCEEND} \noindent\textit{Due date: '.$duedate.'} \vskip 1 mm\noindent '.$startminipage.'\addcontentsline{toc}{subsection}{'.$name_of_resourse.'}';	
+			$result .= '\begin{document} \typeout{STAMPOFPASSEDRESOURCESTART Resource <h2>"'.$name_of_resourse.'"</h2> located in <br /><small><b>'.$env{'request.uri'}.'</b></small><br /> STAMPOFPASSEDRESOURCEEND} \noindent\textit{Due date: '.$duedate.'} \vskip 1 mm\noindent '.$startminipage.'\addcontentsline{toc}{subsection}{'.$name_of_resourse.'}';	
 		    } else {
-			$result .= '\begin{document} \typeout{STAMPOFPASSEDRESOURCESTART Resource <h2>"'.$name_of_resourse.'"</h2> located in <br /><small><b>'.$ENV{'request.uri'}.'</b></small><br /> STAMPOFPASSEDRESOURCEEND} \noindent \vskip 1 mm \noindent'.$startminipage.'\addcontentsline{toc}{subsection}{'.$name_of_resourse.'}';
+			$result .= '\begin{document} \typeout{STAMPOFPASSEDRESOURCESTART Resource <h2>"'.$name_of_resourse.'"</h2> located in <br /><small><b>'.$env{'request.uri'}.'</b></small><br /> STAMPOFPASSEDRESOURCEEND} \noindent \vskip 1 mm \noindent'.$startminipage.'\addcontentsline{toc}{subsection}{'.$name_of_resourse.'}';
 			if ($Apache::lonhomework::type eq 'exam' and $allow_print_points==1) { $result .= '\fbox{\textit{'.$weight.' pt}}';}
 		    }
 		} else {
 		    $result .= '\vskip 1mm\textit{Due date: '.$duedate.'} \\\\\\\\';
 		}
 	    } else {
-		if (not $ENV{'request.symb'} =~ m/\.page_/) {
-		    $result .= '\begin{document} \typeout{STAMPOFPASSEDRESOURCESTART Resource <h2>"'.$name_of_resourse.'"</h2> located in <br /><small><b>'.$ENV{'request.uri'}.'</b></small><br /> STAMPOFPASSEDRESOURCEEND} \noindent \vskip 1 mm\noindent'.$startminipage.'\addcontentsline{toc}{subsection}{'.$name_of_resourse.'}';	
+		if (not $env{'request.symb'} =~ m/\.page_/) {
+		    $result .= '\begin{document} \typeout{STAMPOFPASSEDRESOURCESTART Resource <h2>"'.$name_of_resourse.'"</h2> located in <br /><small><b>'.$env{'request.uri'}.'</b></small><br /> STAMPOFPASSEDRESOURCEEND} \noindent \vskip 1 mm\noindent'.$startminipage.'\addcontentsline{toc}{subsection}{'.$name_of_resourse.'}';	
 		    if (($Apache::lonhomework::type eq 'exam') and ($allow_print_points==1)) { $result .= '\fbox{\textit{'.$weight.' pt}}';}
 		} else {
 		    $result .= '\vskip 1mm \\\\\\\\';
@@ -665,11 +665,11 @@
 	    $result.= $gradestatus;
 	}
 	if (
-	    (($target eq 'web') && ($ENV{'request.state'} ne 'construct')) ||
+	    (($target eq 'web') && ($env{'request.state'} ne 'construct')) ||
 	    ($target eq 'answer') || ($target eq 'tex')
 	   ) {
 	    if ($target ne 'tex' &&
-		$ENV{'form.answer_output_mode'} ne 'tex') {
+		$env{'form.answer_output_mode'} ne 'tex') {
 		$result.="</form>";
 		$result.=&Apache::lonhtmlcommon::htmlareaselectactive(@Apache::lonxml::htmlareafields);
 	    }
@@ -677,15 +677,15 @@
 		$result.=&Apache::lonxml::xmlend().'</html>';
 	    } elsif ($target eq 'tex') {
 		my $endminipage = '';
-		if (not $ENV{'form.problem_split'}=~/yes/) {
+		if (not $env{'form.problem_split'}=~/yes/) {
 		    $endminipage = '\end{minipage}';
 		}
-                if ($ENV{'form.print_discussions'} eq 'yes') {
+                if ($env{'form.print_discussions'} eq 'yes') {
 		    $result.=&Apache::lonxml::xmlend($target,$parser);
 		    $result=~s/<\/html>//;
 		} else {
 		    $result .= '\keephidden{ENDOFPROBLEM}\vskip 0.5mm\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill}';
-		    if (not $ENV{'request.symb'} =~ m/\.page_/) {
+		    if (not $env{'request.symb'} =~ m/\.page_/) {
 			$result .= $endminipage.'\end{document} ';
 		    } else {
 			$result .= '';
@@ -697,8 +697,8 @@
 	    &Apache::lonhomework::showhash(%Apache::lonhomework::results);
 	    &finalize_storage();
 	}
-	if ($target eq 'answer' && ($ENV{'request.state'} eq 'construct')
-	    && $ENV{'form.answer_output_mode'} ne 'tex') {
+	if ($target eq 'answer' && ($env{'request.state'} eq 'construct')
+	    && $env{'form.answer_output_mode'} ne 'tex') {
 	    $result.='</html>'; # normally we get it from xmlend, but in CSTR
 	                        # we always show answer mode too.
 	}
@@ -714,7 +714,7 @@
 	$result = &problem_edit_footer();
     }
 
-    if ($ENV{'request.state'} eq 'construct' && $target eq 'web') {
+    if ($env{'request.state'} eq 'construct' && $target eq 'web') {
 	&Apache::inputtags::check_for_duplicate_ids();
     }
 
@@ -742,7 +742,7 @@
 	$result=$token->[4];
 	$result.=&Apache::edit::handle_insert();
     } elsif ($target eq 'web' && $$tagstack[0] ne 'problem' &&
-	     $ENV{'request.state'} eq "construct" ) {
+	     $env{'request.state'} eq "construct" ) {
 	($result,$head_tag_start,$body_tag_start,$form_tag_start)=
 	    &page_start($target,$token,$tagstack,$parstack,$parser,$safeeval);
 	my $name=&get_resource_name($parstack,$safeeval);
@@ -761,7 +761,7 @@
     if ($target eq 'edit') {
 	$result=&problem_edit_footer();
     } elsif ($target eq 'web' && $$tagstack[0] ne 'problem' &&
-	     $ENV{'request.state'} eq "construct") {
+	     $env{'request.state'} eq "construct") {
 	$result.='</form>'.&Apache::loncommon::endbodytag().
 	    &Apache::lonxml::xmlend();
     }
@@ -897,8 +897,8 @@
 
     if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
 	$target eq 'tex' || $target eq 'analyze') {
-        $result=($ENV{'request.role'}=~/^(in|cc|au|ca|li)/);
-	if ( (! $result) or ($ENV{'form.instructor_comments'} eq 'hide')) {
+        $result=($env{'request.role'}=~/^(in|cc|au|ca|li)/);
+	if ( (! $result) or ($env{'form.instructor_comments'} eq 'hide')) {
 	    my $skip=&Apache::lonxml::get_all_text("/instructorcomment",
 						   $parser,$style);
 	    &Apache::lonxml::debug("skipping ahead :$skip: $$parser[-1]");
@@ -1110,7 +1110,7 @@
 	    my $expression='$external::datestatus="'.$status.'";';
 	    $expression.='$external::gradestatus="'.$Apache::lonhomework::history{"resource.$id.solved"}.'";';
 	    &Apache::run::run($expression,$safeeval);
-	    if ($ENV{'request.state'} eq 'construct') {
+	    if ($env{'request.state'} eq 'construct') {
 		&set_problem_state($Apache::inputtags::part); 
 	    }
 	    if (( $status eq 'CLOSED' ) ||
@@ -1123,7 +1123,7 @@
 		if ( $target eq "web" ) {
 		    $result="<br />".&mt('Part is not open to be viewed. It')." $accessmsg<br />";
 		} elsif ( $target eq 'tex' ) {
-		    if (not $ENV{'form.problem_split'}=~/yes/) {
+		    if (not $env{'form.problem_split'}=~/yes/) {
 			$result="\\end{minipage}\\vskip 0 mm ".&mt('Part is not open to be viewed. It')." $accessmsg \\\\\\begin{minipage}{\\textwidth}";
 		    } else {
 			$result="\\vskip 0 mm ".&mt('Part is not open to be viewed. It')." $accessmsg \\\\";
@@ -1131,7 +1131,7 @@
 		}
 	    } else {
 		if ($target eq 'tex') {
-		    if (not $ENV{'form.problem_split'}=~/yes/) {
+		    if (not $env{'form.problem_split'}=~/yes/) {
 			if ($$tagstack[-2] eq 'td') {
 			    $result.='\vskip 0 mm \noindent \begin{minipage}{\textwidth}\noindent';
 			} else {
@@ -1139,7 +1139,7 @@
 			}
 		    }
 		    my $weight = &Apache::lonnet::EXT("resource.$id.weight");
-		    my $allkeys=&Apache::lonnet::metadata($ENV{'request.uri'},'packages');
+		    my $allkeys=&Apache::lonnet::metadata($env{'request.uri'},'packages');
 		    my @allkeys = split /,/,$allkeys;
 		    my $allow_print_points = 0;
 		    foreach my $partial_key (@allkeys) {
@@ -1390,10 +1390,10 @@
 sub start_simpleeditbutton {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
     my $result='';
-    if (($ENV{'form.simple_edit_button'} ne 'off') &&
+    if (($env{'form.simple_edit_button'} ne 'off') &&
 	($target eq 'web') &&
-        (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) {
-        my $url=$ENV{'request.noversionuri'};
+        (&Apache::lonnet::allowed('srm',$env{'request.course.id'}))) {
+        my $url=$env{'request.noversionuri'};
         $url=~s/\?.*$//;
 	my ($symb) = &Apache::lonxml::whichuser();
 	$result='<table width="100%" bgcolor="#FFFFAA" border="2"><tr><td>'.
Index: loncom/homework/caparesponse/caparesponse.pm
diff -u loncom/homework/caparesponse/caparesponse.pm:1.165 loncom/homework/caparesponse/caparesponse.pm:1.166
--- loncom/homework/caparesponse/caparesponse.pm:1.165	Wed Feb 23 18:41:23 2005
+++ loncom/homework/caparesponse/caparesponse.pm	Thu Apr  7 02:56:22 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # caparesponse definition
 #
-# $Id: caparesponse.pm,v 1.165 2005/02/23 23:41:23 albertel Exp $
+# $Id: caparesponse.pm,v 1.166 2005/04/07 06:56:22 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -30,6 +30,7 @@
 use strict;
 use capa;
 use Apache::lonlocal;
+use Apache::lonnet;
 
 BEGIN {
     &Apache::lonxml::register('Apache::caparesponse',('caparesponse','numericalresponse','stringresponse','formularesponse'));
@@ -348,7 +349,7 @@
 	    if ($target eq 'answer') {
 		if ($high && $tag eq 'numericalresponse') { $ans.=' ['.$low.','.$high.']'; }
 		if (defined($sighigh) && $tag eq 'numericalresponse') {
-		    if ($ENV{'form.answer_output_mode'} eq 'tex') {
+		    if ($env{'form.answer_output_mode'} eq 'tex') {
 			$ans.= " Sig $siglow - $sighigh";
 		    } else {
 			$ans.= " Sig <i>$siglow - $sighigh</i>";
@@ -369,7 +370,7 @@
 	if (defined($unit) and ($unit ne '') and
 	    $tag eq 'numericalresponse') {
 	    if ($target eq 'answer') {
-		if ($ENV{'form.answer_output_mode'} eq 'tex') {
+		if ($env{'form.answer_output_mode'} eq 'tex') {
 		    $result.=&Apache::response::answer_part($tag,
 							    " Unit: $unit ");
 		} else {
@@ -415,11 +416,11 @@
     }
     $cell_width+=8; 
     my $textwidth;
-    if ($ENV{'form.textwidth'} ne '') {
-	$ENV{'form.textwidth'}=~/(\d*)\.?(\d*)/;
+    if ($env{'form.textwidth'} ne '') {
+	$env{'form.textwidth'}=~/(\d*)\.?(\d*)/;
 	$textwidth=$1.'.'.$2;
     } else {
-	$ENV{'textwidth'}=~/(\d+)\.?(\d*)/;
+	$env{'form.textwidth'}=~/(\d+)\.?(\d*)/;
 	$textwidth=$1.'.'.$2;
     }
     my $bubbles_per_line=int($textwidth/$cell_width);
@@ -526,8 +527,8 @@
 sub get_sigrange {
     my ($sig)=@_;
     &Apache::lonxml::debug("Got a sig of :$sig:");
-    my $courseid=$ENV{'request.course.id'};
-    if (lc($ENV{"course.$courseid.disablesigfigs"}) eq 'yes') {
+    my $courseid=$env{'request.course.id'};
+    if (lc($env{"course.$courseid.disablesigfigs"}) eq 'yes') {
 	return (15,0);
     }
     my $sig_lbound;
@@ -547,7 +548,7 @@
 	($sig_lbound > 15) ||
 	($sig =~/(\+|-)/ ) ) {
 	my $errormsg=&mt("Invalid Significant figures detected")." ($sig)";
-	if ($ENV{'request.state'} eq 'construct') {
+	if ($env{'request.state'} eq 'construct') {
 	    $errormsg.=
 		&Apache::loncommon::help_open_topic('Significant_Figures');
 	}
@@ -711,7 +712,7 @@
 	    $string='Regular Expression';
 	}
 	if ($target eq 'answer') {
-	    if ($ENV{'form.answer_output_mode'} eq 'tex') {
+	    if ($env{'form.answer_output_mode'} eq 'tex') {
 		$result.=&Apache::response::answer_part('stringresponse',
 							"$string");
 	    } else {
Index: loncom/html/adm/help/searchcat.html
diff -u loncom/html/adm/help/searchcat.html:1.2 loncom/html/adm/help/searchcat.html:1.3
--- loncom/html/adm/help/searchcat.html:1.2	Wed Nov 28 12:00:07 2001
+++ loncom/html/adm/help/searchcat.html	Thu Apr  7 02:56:22 2005
@@ -158,7 +158,7 @@
  
 * either user specific (georgio can only browse and search
    /res/DOMAIN/georgio)
-* or has advanced status as indicated by $ENV{'user.adv'}
+* or has advanced status as indicated by $env{'user.adv'}
 </pre> 
 </li>
 <li>
Index: loncom/html/adm/help/tex/Developer_Tutorial.tex
diff -u loncom/html/adm/help/tex/Developer_Tutorial.tex:1.5 loncom/html/adm/help/tex/Developer_Tutorial.tex:1.6
--- loncom/html/adm/help/tex/Developer_Tutorial.tex:1.5	Mon May 17 18:08:56 2004
+++ loncom/html/adm/help/tex/Developer_Tutorial.tex	Thu Apr  7 02:56:22 2005
@@ -363,7 +363,7 @@
 
 ~~~~if~(\$r->header\_only)~\{
 
-~~~~~~~~if~(\$ENV\{'browser.mathml'\})~\{
+~~~~~~~~if~(\$env\{'browser.mathml'\})~\{
 
 ~~~~~~~~~~~~\$r->content\_type('text/xml');
 
@@ -381,7 +381,7 @@
 
 ~~~~\#~Send~header,~don't~cache~this~page
 
-~~~~if~(\$ENV\{'browser.mathml'\})~\{
+~~~~if~(\$env\{'browser.mathml'\})~\{
 
 ~~~~~~~~\$r->content\_type('text/xml');
 
@@ -453,7 +453,7 @@
 Remove the {}``Hello world!'' line and replace it with this:
 
 \begin{lyxcode}
-\$ENV\{'form.condition'\}~=~1;
+\$env\{'form.condition'\}~=~1;
 
 my~\$renderArgs~=~\{~'cols'~=>~{[}Apache::lonnavmaps::resource{]},
 
@@ -470,11 +470,11 @@
 contains routines that help render navmaps. For more information,
 see later in this manual or type \texttt{man Apache::lonnavmaps}.
 This ensures these routines are loaded into memory.
-\item \texttt{\textbf{\$ENV\{'form.condition'\} = 1;}}: This is an an argument
+\item \texttt{\textbf{\$env\{'form.condition'\} = 1;}}: This is an an argument
 being passed to the Apache::lonnavmaps::render routine in a rather
 unorthodox way. This will cause the navmap to render all of the resources,
 by default, except for what we explicitly exclude. Since we're not
-going to exclude anything (which we would do with \texttt{\$ENV\{'form.filter'\}}),
+going to exclude anything (which we would do with \texttt{\$env\{'form.filter'\}}),
 all resources will be shown.
 \item \texttt{\textbf{my \$renderArgs\ldots{}\$r\};}}: Since the \texttt{render}
 routine takes a \emph{lot} of arguments, the \texttt{render} routine
@@ -524,7 +524,7 @@
 
 The first thing we need to do to accomplish this is to add an HTML
 form to the screen so we have something to submit. Just above the
-\texttt{\$ENV\{'form.condition'\}} line, add the following:
+\texttt{\$env\{'form.condition'\}} line, add the following:
 
 \begin{lyxcode}
 \$r->print(\char`\"{}<form~method='post'><input~type='hidden'~name='submission'~value='1'~/>\char`\"{});
@@ -549,15 +549,15 @@
 \subsubsection{Seeing The Incoming Data}
 
 LON-CAPA automatically processing incoming POST data and exposes it
-to you in the \texttt{\%ENV} hash. The data will appear in \texttt{\$ENV\{'form.\$varname'\}},
+to you in the \texttt{\%env} hash. The data will appear in \texttt{\$env\{'form.\$varname'\}},
 where \texttt{\$varname} is the variable name of the HTML form element.
 In this case, since we have an element named {}``submission'', a
-{}``1'' will appear in \texttt{\$ENV\{'form.submission'\}} when
+{}``1'' will appear in \texttt{\$env\{'form.submission'\}} when
 we hit the {}``Increment'' button. To see this, add the following
 after the \texttt{bodytag} call:
 
 \begin{lyxcode}
-if~(\$ENV\{'form.submission'\})~\{
+if~(\$env\{'form.submission'\})~\{
 
 ~~~~\$r->print('<p>Form~submitted.</p>');
 
@@ -572,10 +572,10 @@
 When you hit {}``Increment'', {}``Form submitted.'' will appear.
 
 Note this only applies to POST'ed data. If you use GET, the data will
-appear on the query string. For your code, this will show up in \texttt{\$ENV\{QUERY\_STRING\}}.
+appear on the query string. For your code, this will show up in \texttt{\$env\{QUERY\_STRING\}}.
 If you want to invoke LON-CAPA's processing on that string, so you
-see the variables in \texttt{\%ENV}, use
-\texttt{Apache::loncommon::get\_unprocessed\_cgi(\$ENV\{QUERY\_STRING\});}.
+see the variables in \texttt{\%env}, use
+\texttt{Apache::loncommon::get\_unprocessed\_cgi(\$env\{QUERY\_STRING\});}.
 This is particularly useful for cases where input may be coming in via
 either POST or GET.
 
@@ -625,7 +625,7 @@
 code:
 
 \begin{lyxcode}
-foreach~(keys~\%ENV)~\{
+foreach~(keys~\%env)~\{
 
 ~~~~if~(substr(\$\_,~0,~10)~eq~'form.symb.')~\{
 
@@ -658,7 +658,7 @@
 
 Let's go ahead and retrieve the hash we're going to store. If it doesn't
 already exist, it will end up getting created implicitly. Before the
-\texttt{foreach (keys \%ENV)}, add 
+\texttt{foreach (keys \%env)}, add 
 
 \begin{lyxcode}
 my~\%countHash~=~Apache::lonnet::restore('tutorial');
@@ -680,7 +680,7 @@
 this:
 
 \begin{lyxcode}
-foreach~(keys~\%ENV)~\{
+foreach~(keys~\%env)~\{
 
 ~~~~if~(substr(\$\_,~0,~10)~eq~'form.symb.')~\{
 
@@ -772,7 +772,7 @@
   them for practice)
 
 \begin{lyxcode}
-if~(\$ENV{'form.submission'})~{
+if~(\$env{'form.submission'})~{
 
 ~~~~\$r->print('<p>'.\&mt('Form submitted').'</p>');
 
@@ -876,7 +876,7 @@
 
 ~~~~if~(\$r->header\_only)~\{
 
-~~~~~~~~if~(\$ENV\{'browser.mathml'\})~\{
+~~~~~~~~if~(\$env\{'browser.mathml'\})~\{
 
 ~~~~~~~~~~~~\$r->content\_type('text/xml');
 
@@ -894,7 +894,7 @@
 
 ~~~~\#~Send~header,~don't~cache~this~page
 
-~~~~if~(\$ENV\{'browser.mathml'\})~\{
+~~~~if~(\$env\{'browser.mathml'\})~\{
 
 ~~~~~~~~\$r->content\_type('text/xml');
 
@@ -926,7 +926,7 @@
 
 
 
-~~~~if~(\$ENV\{'form.submission'\})~\{
+~~~~if~(\$env\{'form.submission'\})~\{
 
 ~~~~~~~~\$r->print('<p>'~.~\&mt('Form~submitted.')~.'</p>');
 
@@ -942,7 +942,7 @@
 
 ~~~~my~\%newHash~=~();
 
-~~~~foreach~(keys~\%ENV)~\{
+~~~~foreach~(keys~\%env)~\{
 
 ~~~~~~~~if~(substr(\$\_,~0,~10)~eq~'form.symb.')~\{
 
@@ -976,7 +976,7 @@
 
 ~~~~~~~~~~~~~~\char`\"{}name='submission'~value='1'~/>\char`\"{});
 
-~~~~\$ENV\{'form.condition'\}~=~1;
+~~~~\$env\{'form.condition'\}~=~1;
 
 ~~~~my~\$renderArgs~=~\{~'cols'~=>~{[}Apache::lonnavmaps::resource,
 
Index: loncom/html/adm/help/tex/Guts_Apache_Env.tex
diff -u loncom/html/adm/help/tex/Guts_Apache_Env.tex:1.2 loncom/html/adm/help/tex/Guts_Apache_Env.tex:1.3
--- loncom/html/adm/help/tex/Guts_Apache_Env.tex:1.2	Mon May 17 18:08:56 2004
+++ loncom/html/adm/help/tex/Guts_Apache_Env.tex	Thu Apr  7 02:56:22 2005
@@ -1,10 +1,10 @@
 \label{Guts_Apache_Env}
 
-The environment is accessible through the global hash named \%ENV.
+The environment is accessible through the global hash named \%env.
 In addition to the standard variables placed in the environment by
-the Apache server, LON-CAPA places a lot of information in the \%ENV.
+the Apache server, LON-CAPA places a lot of information in the \%env.
 You can see this information by going to \texttt{/adm/test}; the top
-part of that screen will show your current \%ENV. (You may need to
+part of that screen will show your current \%env. (You may need to
 modify \texttt{/home/httpd/lonTabs/htpasswd} before you can view that
 handler and change the password for \texttt{lonadm}.)
 
@@ -12,17 +12,17 @@
 and permission routines (such as \texttt{Apache::lonnet::allowed}),
 and are very rarely directly manipulated. 
 
-Generally, the \%ENV is informally organized into {}``namespaces'',
+Generally, the \%env is informally organized into {}``namespaces'',
 such as {}``browser'' (containing browser information), {}``course''
 (containing course-specific information), etc. For the following table,
 the full name of the variable is the name shown on the left, prepended
-by the section it is in. For instance, the first \%ENV member shown
-below is \$ENV\{'browser.mathml'\}. Only generally useful portions
-of the \%ENV are covered here.
+by the section it is in. For instance, the first \%env member shown
+below is \$env\{'browser.mathml'\}. Only generally useful portions
+of the \%env are covered here.
 
 \begin{longtable}{|c|c|}
 \hline 
-\textbf{\%ENV name}&
+\textbf{\%env name}&
 \textbf{Description}\tabularnewline
 \hline
 \endfirsthead
Index: loncom/html/adm/helper/course.initialization.helper
diff -u loncom/html/adm/helper/course.initialization.helper:1.14 loncom/html/adm/helper/course.initialization.helper:1.15
--- loncom/html/adm/helper/course.initialization.helper:1.14	Wed Jun  2 13:31:03 2004
+++ loncom/html/adm/helper/course.initialization.helper	Thu Apr  7 02:56:22 2005
@@ -1,18 +1,18 @@
 <helper title="Course Initialization Helper" requiredpriv='opa'>
 
   <exec>
-    my $courseid = $ENV{'request.course.id'};
-    my $crsdom = $ENV{'course.'.$courseid.'.domain'};
-    my $crsnum = $ENV{'course.'.$courseid.'.num'};
+    my $courseid = $env{'request.course.id'};
+    my $crsdom = $env{'course.'.$courseid.'.domain'};
+    my $crsnum = $env{'course.'.$courseid.'.num'};
     $helper->{DATA}->{DOM} = $crsdom;
     $helper->{DATA}->{CRS} = $crsnum;
 
-    $helper->{DATA}->{FIRST_RUN} = $ENV{'course.'.$crsnum.
+    $helper->{DATA}->{FIRST_RUN} = $env{'course.'.$crsnum.
                                         '.course.intialization.not.run'};
     # Delete the 'course.initialization.not.run' course environment
     Apache::lonnet::put('environment', {'course.helper.not.run' => 0}, 
                         $crsdom, $crsnum);
-    Apache::lonnet::coursedescription($ENV{'request.course.id'});
+    Apache::lonnet::coursedescription($env{'request.course.id'});
 
     $helper->{DATA}->{GETVAL} = sub {
         my @resultlist = &Apache::lonnet::get('environment', [shift()], 
@@ -27,7 +27,7 @@
                                  $helper->{DATA}->{DOM},
                                  $helper->{DATA}->{CRS});
             # Try to fix bug 1757
-            Apache::lonnet::coursedescription($ENV{'request.course.id'});
+            Apache::lonnet::coursedescription($env{'request.course.id'});
             return 1;
         } else {
             return 0;
@@ -242,7 +242,7 @@
          screen, by pushing the <b>Course Environment</b> button.</p>
       </message>
     <condition>
-      <clause>$ENV{'course.'.$ENV{'request.course.id'}.'.clonedfrom'}</clause>
+      <clause>$env{'course.'.$env{'request.course.id'}.'.clonedfrom'}</clause>
       <message>After you select <b>Finish Course Initialization</b>,
                you will be taken to the Parameter Overview screen to
                update the dates for this cloned course.</message>
Index: loncom/html/adm/helper/resettimes.helper
diff -u loncom/html/adm/helper/resettimes.helper:1.2 loncom/html/adm/helper/resettimes.helper:1.3
--- loncom/html/adm/helper/resettimes.helper:1.2	Sun Jan 16 03:21:49 2005
+++ loncom/html/adm/helper/resettimes.helper	Thu Apr  7 02:56:22 2005
@@ -23,7 +23,7 @@
       <exec>
          my ($uname,$udom,$sec,$fullname)=split(':',$helper->{'VARS'}{'stu1'});
          my %times=&Apache::lonnet::dump('firstaccesstimes',$udom,$uname,
-					 "^$ENV{'request.course.id'}\0");
+					 "^$env{'request.course.id'}\0");
          foreach my $res (sort(keys(%times))) {
 	     my (undef,$symb)=split("\0",$res);
 	     my $escsymb=&Apache::lonnet::escape($symb);
@@ -63,7 +63,7 @@
         &Apache::lonnet::logthis($helper->{'VARS'}{'delete'});
         if ($helper->{'STATE'} ne 'FinishStu') { return; }
         my $result;
-        my $courseid=$ENV{'request.course.id'};
+        my $courseid=$env{'request.course.id'};
         my ($uname,$udom,$sec,$fullname)=split(':',$helper->{'VARS'}{'stu1'});
         &Apache::lonnet::logthis($helper->{'VARS'}{'delete'});
         foreach my $escsymb (split(/\|\|\|/,$helper->{'VARS'}{'delete'})) {
@@ -121,7 +121,7 @@
         if ($helper->{'STATE'} ne 'FINISH') { return; }
         my $result;
         my $symb=$helper->{'VARS'}{'res2'};
-        my $key=$ENV{'request.course.id'}."\0".$symb;
+        my $key=$env{'request.course.id'}."\0".$symb;
 	my @names=split(/\|\|\|/,$helper->{'VARS'}{'stu1'});
 	foreach my $name (@names) {
 	    my ($uname,$udom,$sec,$fullname)=split(':',$name);
Index: loncom/html/res/adm/pages/annotator/admannotations.pm
diff -u loncom/html/res/adm/pages/annotator/admannotations.pm:1.18 loncom/html/res/adm/pages/annotator/admannotations.pm:1.19
--- loncom/html/res/adm/pages/annotator/admannotations.pm:1.18	Mon Jun 23 14:54:37 2003
+++ loncom/html/res/adm/pages/annotator/admannotations.pm	Thu Apr  7 02:56:22 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # This will take annotations and then plug them into a page.
 #
-# $Id: admannotations.pm,v 1.18 2003/06/23 18:54:37 www Exp $
+# $Id: admannotations.pm,v 1.19 2005/04/07 06:56:22 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -25,18 +25,13 @@
 #
 # http://www.lon-capa.org/
 #
-# 08/25/00 Ben Tyszka
-#
-# 10/17,10/18,10/20 Gerd Kortemeyer
-#
-#
 ##################
 
 package Apache::admannotations;
 
 use strict;
 use Apache::Constants qw(:common);
-use Apache::lonnet();
+use Apache::lonnet;
 
 # --------------------------------------------------------------Put annotation
 
@@ -144,20 +139,20 @@
   my $page;
   my %annot_hash;
 
-  my $urlold=$ENV{'form.urlold'};
+  my $urlold=$env{'form.urlold'};
   $urlold=~s/^http\:\/\///;
   $urlold=~s/^[^\/]+//;
   $urlold=~s/\?.*$//;
-  my $urlnew=$ENV{'form.urlnew'};
+  my $urlnew=$env{'form.urlnew'};
   $urlnew=~s/^http\:\/\///;
   $urlnew=~s/^[^\/]+//;
   $urlnew=~s/\?.*$//;
-  my $annotation=$ENV{'form.annotation'};
+  my $annotation=$env{'form.annotation'};
 
   if ($urlold) {
       write_annotation($urlold,$annotation);
   }
-  if (exists($ENV{'form.urlnew'})) {
+  if (exists($env{'form.urlnew'})) {
       unless ($urlnew) {
           $page=construct_error("Cannot annotate current window. Please point your browser to a LON-CAPA page and then 'continue'.","continue");
       } else {
@@ -166,7 +161,7 @@
 	  } else {
 	      %annot_hash=get_annotation($urlnew);
 	  }
-	  $page=construct_editor($annot_hash{$urlnew},$ENV{'form.urlnew'});
+	  $page=construct_editor($annot_hash{$urlnew},$env{'form.urlnew'});
       }
   }
   $r->print($page);
Index: loncom/html/res/adm/pages/bookmarkmenu/admbookmarks.pm
diff -u loncom/html/res/adm/pages/bookmarkmenu/admbookmarks.pm:1.29 loncom/html/res/adm/pages/bookmarkmenu/admbookmarks.pm:1.30
--- loncom/html/res/adm/pages/bookmarkmenu/admbookmarks.pm:1.29	Mon Jun 23 15:03:33 2003
+++ loncom/html/res/adm/pages/bookmarkmenu/admbookmarks.pm	Thu Apr  7 02:56:22 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The bookmarks handler
 #
-# $Id: admbookmarks.pm,v 1.29 2003/06/23 19:03:33 www Exp $
+# $Id: admbookmarks.pm,v 1.30 2005/04/07 06:56:22 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -35,7 +35,7 @@
 
 use strict;
 use Apache::Constants qw(:common);
-use Apache::lonnet();
+use Apache::lonnet;
 
 # --------------------------------------------------------------Put bookmarks
 
@@ -180,8 +180,8 @@
   my $page;
   $r->content_type('text/html');
   $r->send_http_header;
-  if (defined($ENV{'form.hiddenbookmarks'})) {
-      $marks{'bookmarks'}=$ENV{'form.hiddenbookmarks'};
+  if (defined($env{'form.hiddenbookmarks'})) {
+      $marks{'bookmarks'}=$env{'form.hiddenbookmarks'};
       write_bookmarks($marks{'bookmarks'});
       $page=construct_toolbar();
   } else {
@@ -191,8 +191,8 @@
 	  # in order to re-enable connection detection
 	  $page=construct_error("Connection broken with home server. Please contact your system administrator");
       } else {
-	  if (defined($ENV{'form.address'})) {
-	      $page=add_bookmark($ENV{'form.address'},$ENV{'form.title'},$marks{'bookmarks'});
+	  if (defined($env{'form.address'})) {
+	      $page=add_bookmark($env{'form.address'},$env{'form.title'},$marks{'bookmarks'});
 	  } else {
 	      if ($marks{'bookmarks'} eq "") {
 		  $marks{'bookmarks'}=defaultmarks();
Index: loncom/imspackages/imsexport.pm
diff -u loncom/imspackages/imsexport.pm:1.2 loncom/imspackages/imsexport.pm:1.3
--- loncom/imspackages/imsexport.pm:1.2	Thu Dec 23 11:31:28 2004
+++ loncom/imspackages/imsexport.pm	Thu Apr  7 02:56:22 2005
@@ -30,11 +30,11 @@
     my ($symb) = @_;
     my $output;
     my %qparms = &Apache::lonnet::dump('resourcedata',
-                  $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
-                  $ENV{'course.'.$ENV{'request.course.id'}.'.num'},
-                  $ENV{'request.course.id'}.'.'.$symb);
+                  $env{'course.'.$env{'request.course.id'}.'.domain'},
+                  $env{'course.'.$env{'request.course.id'}.'.num'},
+                  $env{'request.course.id'}.'.'.$symb);
     if ($symb) {
-        my $prefix=$ENV{'request.course.id'}.'.'.$symb.'.0.';
+        my $prefix=$env{'request.course.id'}.'.'.$symb.'.0.';
         my $qtype=$qparms{$prefix.'questiontype'};
         my $qtext=$qparms{$prefix.'questiontext'};
         my $hint=$qparms{$prefix.'hinttext'};
@@ -169,8 +169,8 @@
 
 sub templatedpage {
     my ($content_type,$timestamp,$count,$uploads,$udom,$uname) = @_;
-    my $cdom = $ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
-    my $cnum = $ENV{'course.'.$ENV{'request.course.id'}.'.num'};  
+    my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+    my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};  
     my $output = '
 <'.$content_type.'>';
     my %syllabusdata=();
Index: loncom/imspackages/imsimport.pm
diff -u loncom/imspackages/imsimport.pm:1.10 loncom/imspackages/imsimport.pm:1.11
--- loncom/imspackages/imsimport.pm:1.10	Mon Feb 21 18:47:46 2005
+++ loncom/imspackages/imsimport.pm	Thu Apr  7 02:56:22 2005
@@ -365,8 +365,8 @@
 sub display_two {
     my ($r,$zipupload,$areas,$areaname,$cmsmap,$uname,$newdir,$numcrs,$fullpath) = @_;
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['folder','source']);
-    my $cms = $ENV{'form.source'};
-    my $dirname = $ENV{'form.newdir'};
+    my $cms = $env{'form.source'};
+    my $dirname = $env{'form.newdir'};
     my $tempdir = &Apache::imsprocessor::create_tempdir('CSTR',$dirname,'');
     my $fname = &Apache::imsprocessor::uploadzip('CSTR',$tempdir,$zipupload);
     my $unzip_result = '';
@@ -557,7 +557,7 @@
       </tr>
       <tr>
        <td colspan='2'>&nbsp;
-          <input type="hidden" name="newdir" value="$ENV{'form.newdir'}" />
+          <input type="hidden" name="newdir" value="$env{'form.newdir'}" />
           <input type="hidden" name="conditions" value="$conditions" />
           <input type="hidden" name="source" value="$cms" />
           <input type="hidden" name="tempdir" value="$tempdir" />
@@ -610,16 +610,16 @@
     my $db_handling = '';
     my $timenow = time; 
     my $announce_handling = 'ok';
-    my $cms = $ENV{'form.source'};
-    if ( defined($ENV{'form.bb_crs'}) ) {
-        ($cdom,$crs) = split/\//,$ENV{'form.bb_crs'};
+    my $cms = $env{'form.source'};
+    if ( defined($env{'form.bb_crs'}) ) {
+        ($cdom,$crs) = split/\//,$env{'form.bb_crs'};
         $chome = &Apache::lonnet::homeserver($crs,$cdom);
     } 
     my $user_crs = '';
     my $user_cdom = '';
     my $user_handling = '';
-    if ( defined($ENV{'form.user_crs'}) ) {
-        ($user_cdom,$user_crs) = split/\//,$ENV{'form.user_crs'};
+    if ( defined($env{'form.user_crs'}) ) {
+        ($user_cdom,$user_crs) = split/\//,$env{'form.user_crs'};
     }
     my $seqstem = "/res/$udom/$uname/$newdir";
     my %importareas = ();
@@ -645,10 +645,10 @@
     my @sequences = ();
     my @resrcfiles = ();
 
-    my $tempdir = $ENV{'form.tempdir'};
+    my $tempdir = $env{'form.tempdir'};
 
     foreach my $area (@{$areas}) {
-        if (defined($ENV{"form.$area"}) ) {
+        if (defined($env{"form.$area"}) ) {
             if ($cms eq 'angel' && $area eq 'doc') {
                 foreach (@{$$cmsmap{$cms}{$area}}) {
                     $importareas{$_} = 1;
@@ -657,9 +657,9 @@
                 $importareas{$$cmsmap{$cms}{$area}} = 1;
             }
             if ($area eq 'board') {
-                $db_handling = $ENV{'form.db_handling'};
+                $db_handling = $env{'form.db_handling'};
             } elsif ($area eq 'users') {
-                $user_handling = $ENV{'form.user_handling'};
+                $user_handling = $env{'form.user_handling'};
             }
         }
     }
@@ -805,36 +805,36 @@
     my $qcount = '';
 
 # get personal information for this user
-    my $user=$ENV{'user.name'};
-    my $dom=$ENV{'user.domain'};
+    my $user=$env{'user.name'};
+    my $dom=$env{'user.domain'};
 
 #
 # re-attach user
 #
-    if ($ENV{'form.uploaduname'}) {
-        $ENV{'form.filename'}='/priv/'.$ENV{'form.uploaduname'}.'/'.
-            $ENV{'form.filename'};
+    if ($env{'form.uploaduname'}) {
+        $env{'form.filename'}='/priv/'.$env{'form.uploaduname'}.'/'.
+            $env{'form.filename'};
     }
     ($uname,$udom)=
-        &Apache::loncacc::constructaccess($ENV{'form.filename'},
+        &Apache::loncacc::constructaccess($env{'form.filename'},
                                           $r->dir_config('lonDefDomain'));
     unless (($uname) && ($udom)) {
         $r->log_reason($uname.' at '.$udom.
-                       ' trying to publish file '.$ENV{'form.filename'}.
+                       ' trying to publish file '.$env{'form.filename'}.
                        ' - not authorized',
                        $r->filename);
         return HTTP_NOT_ACCEPTABLE;
     }
                                                                                              
     my $fn;
-    if ($ENV{'form.filename'}) {
-        $fn=$ENV{'form.filename'};
+    if ($env{'form.filename'}) {
+        $fn=$env{'form.filename'};
         $fn=~s/^http\:\/\/[^\/]+\///;
         $fn=~s/^\///;
         $fn=~s/(\~|priv\/)(\w+)//;
         $fn=~s/\/+/\//g;
     } else {
-        $r->log_reason($ENV{'user.name'}.' at '.$ENV{'user.domain'}.
+        $r->log_reason($env{'user.name'}.' at '.$env{'user.domain'}.
                        ' unspecified filename for upload', $r->filename);
         return HTTP_NOT_FOUND;
     }
@@ -856,35 +856,35 @@
     &Apache::loncommon::content_type($r,'text/html');
     $r->send_http_header;
 
-    if ($ENV{'form.phase'} eq 'two') {
+    if ($env{'form.phase'} eq 'two') {
         &jscript_one($fullpath,\$javascript,$uname,$udom);
-    } elsif ($ENV{'form.phase'} eq 'three') {
+    } elsif ($env{'form.phase'} eq 'three') {
         &jscript_two(\$javascript,$user,$dom,\$numcrs);
-    } elsif ($ENV{'form.phase'} eq 'four') {
+    } elsif ($env{'form.phase'} eq 'four') {
         &jscript_three(\$javascript);
     }
     $r->print("<html><head><title>LON-CAPA Construction Space</title><script type=\"text/javascript\">\n//<!--\n$javascript\n// --></script>\n</head>");
                                                                                              
     $r->print(&Apache::loncommon::bodytag('Upload IMS package to Construction Space',undef,$loadentries));
                                                                                              
-    if (($uname ne $ENV{'user.name'}) || ($udom ne $ENV{'user.domain'})) {
+    if (($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) {
         $r->print('<h3><font color=red>'.&mt('Co-Author').': '.$uname.
                   &mt(' at ').$udom.'</font></h3>');
     }   
-    if ($ENV{'form.phase'} eq 'two') {
+    if ($env{'form.phase'} eq 'two') {
         my $flag = &Apache::lonupload::phasetwo($r,$fn,$uname,$udom,'imsimport');
         if ($flag eq 'ok') {
             &display_one($r,$uname,$fn,$fullpath);
         }
-    } elsif ( ($ENV{'form.phase'} eq 'three') || ($ENV{'form.phase'} eq 'four') ) {
-        my $docroot = $ENV{'form.newdir'};
+    } elsif ( ($env{'form.phase'} eq 'three') || ($env{'form.phase'} eq 'four') ) {
+        my $docroot = $env{'form.newdir'};
         my $newdir = '';
         if ($docroot =~ m|public_html/(.+)$|) {
             $newdir = $1;
         }
-        if ($ENV{'form.phase'} eq 'three') {
+        if ($env{'form.phase'} eq 'three') {
             &display_two ($r,$zipupload,\@areas,\%areaname,\%cmsmap,$uname,$newdir,\$numcrs,$fullpath);
-        } elsif ($ENV{'form.phase'} eq 'four') {
+        } elsif ($env{'form.phase'} eq 'four') {
             &display_three ($r,$uname,$udom,\@areas,\%areaname,\%cmsmap,$docroot,$newdir);
         }
     } else {
Index: loncom/imspackages/imsimportdocs.pm
diff -u loncom/imspackages/imsimportdocs.pm:1.11 loncom/imspackages/imsimportdocs.pm:1.12
--- loncom/imspackages/imsimportdocs.pm:1.11	Mon Feb 21 18:47:46 2005
+++ loncom/imspackages/imsimportdocs.pm	Thu Apr  7 02:56:22 2005
@@ -143,19 +143,19 @@
     &Apache::imsprocessor::ims_config(\@areas,\%cmsmap,\%areaname);
 
 # get course data
-    my $coursenum=$ENV{'course.'.$ENV{'request.course.id'}.'.num'};
-    my $coursedom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
-    my $coursehome=$ENV{'course.'.$ENV{'request.course.id'}.'.home'};
+    my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'};
+    my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'};
+    my $coursehome=$env{'course.'.$env{'request.course.id'}.'.home'};
 
 # get personal data
  
-    my $uname=$ENV{'user.name'};
-    my $udom=$ENV{'user.domain'};
+    my $uname=$env{'user.name'};
+    my $udom=$env{'user.domain'};
     my $plainname=&Apache::lonnet::escape(
                      &Apache::loncommon::plainname($uname,$udom));
 
 # does this user have privileges to post, etc?
-    my $allowed=&Apache::lonnet::allowed('mdc',$ENV{'request.course.id'});
+    my $allowed=&Apache::lonnet::allowed('mdc',$env{'request.course.id'});
     unless ($allowed) {
         $r->print("<html><head><title>The LearningOnline Network with CAPA</title></head>");
         $r->print(&Apache::loncommon::bodytag('Import IMS package',undef,'',1));  
@@ -166,11 +166,11 @@
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
        ['phase']);
 
-    if ($ENV{'form.phase'} eq 'one') {    
+    if ($env{'form.phase'} eq 'one') {    
         &jscript_one(\$javascript);
-    } elsif ($ENV{'form.phase'} eq 'two') {
+    } elsif ($env{'form.phase'} eq 'two') {
         &jscript_two(\$javascript);
-    } elsif ($ENV{'form.phase'} eq 'three') {
+    } elsif ($env{'form.phase'} eq 'three') {
         &jscript_three(\$javascript);
     }
 
@@ -188,11 +188,11 @@
 ENDHEAD
 # -------------------------------------------------------------------- Body tag
     $r->print(&Apache::loncommon::bodytag('Import IMS package',undef,'',1));
-    if ($ENV{'form.phase'} eq 'one') {
+    if ($env{'form.phase'} eq 'one') {
         &display_one($r);       
-    } elsif ($ENV{'form.phase'} eq 'two') {
+    } elsif ($env{'form.phase'} eq 'two') {
         &display_two($r,$coursenum,\@areas,\%areaname,%cmsmap);
-    } elsif ($ENV{'form.phase'} eq 'three') {
+    } elsif ($env{'form.phase'} eq 'three') {
         &display_three($r,$coursenum,$coursedom,$coursehome,$uname,$udom,\@areas,%cmsmap);
     }   
     $r->print("</body><html>");
@@ -259,7 +259,7 @@
       </tr>
       <tr>
        <td colspan='2'>&nbsp;
-        <input type="hidden" name="folder" value="$ENV{'form.folder'}" />
+        <input type="hidden" name="folder" value="$env{'form.folder'}" />
         <input type="hidden" name="phase" value="two" />
         <input type="file" name="uploadname" size="40" />
        </td>
@@ -300,7 +300,7 @@
 sub display_two {
     my ($r,$crs,$areasref,$areaname,%cmsmap) = @_;
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['folder','source']);
-    my $cms = $ENV{'form.source'};
+    my $cms = $env{'form.source'};
     my $timenow = time;
     my $tempdir = &Apache::imsprocessor::create_tempdir('DOCS',$crs,$timenow);
     my $fname = &Apache::imsprocessor::uploadzip('DOCS',$tempdir);
@@ -467,7 +467,7 @@
       </tr>
       <tr>
        <td colspan='2'>&nbsp;
-          <input type="hidden" name="folder" value="$ENV{'form.folder'}" />
+          <input type="hidden" name="folder" value="$env{'form.folder'}" />
           <input type="hidden" name="source" value="$cms" />
           <input type="hidden" name="tempdir" value="$tempdir" />
           <input type="hidden" name="phase" value="three" />
@@ -503,9 +503,9 @@
 
 sub display_three {
     my ($r,$crs,$cdom,$chome,$uname,$udom,$areas,%cmsmap) = @_;
-    my $folder = $ENV{'form.folder'};
-    my $cms = $ENV{'form.source'};
-    my $tempdir = $ENV{'form.tempdir'};
+    my $folder = $env{'form.folder'};
+    my $cms = $env{'form.source'};
+    my $tempdir = $env{'form.tempdir'};
     my $longcrs = '';
     if ($crs =~ m/^(\d)(\d)(\d)/) {
         $longcrs = $1.'/'.$2.'/'.$3.'/'.$crs;
@@ -541,15 +541,15 @@
     my $toplevel = '';
     my $foldername = '';
     my %topitems = ();
-    if (defined($ENV{'form.toplevel'}) ) {
-        $toplevel = $ENV{'form.toplevel'};     
+    if (defined($env{'form.toplevel'}) ) {
+        $toplevel = $env{'form.toplevel'};     
     }
-    if (defined($ENV{'form.foldername'}) ) {
-        $foldername = $ENV{'form.foldername'}; 
+    if (defined($env{'form.foldername'}) ) {
+        $foldername = $env{'form.foldername'}; 
     }
 
     foreach my $area (@{$areas}) {
-        if (defined($ENV{"form.$area"}) && ($ENV{'form.'.$area} ne '')) {
+        if (defined($env{"form.$area"}) && ($env{'form.'.$area} ne '')) {
             if ($cms eq 'angel' && $area eq 'doc') {
                 foreach (@{$cmsmap{$cms}{$area}}) {
                     $importareas{$_} = 1;
@@ -558,9 +558,9 @@
                 $importareas{$cmsmap{$cms}{$area}} = 1;
             }
             if ($area eq 'board') {
-                $db_handling = $ENV{'form.db_handling'};
+                $db_handling = $env{'form.db_handling'};
             } elsif ($area eq 'users') {
-                $user_handling = $ENV{'form.user_handling'};
+                $user_handling = $env{'form.user_handling'};
             }
         }
     }
@@ -642,7 +642,7 @@
             }
         } elsif ($toplevel eq 'newfolder') {
             my $url = &Apache::lonnet::unescape("/uploaded/$cdom/$crs/$timenow/sequences/Top.sequence");
-            my $name = &Apache::lonnet::unescape("$ENV{'form.foldername'}");
+            my $name = &Apache::lonnet::unescape("$env{'form.foldername'}");
             push @imports, $name, $url;
         }
         my $errtext='';
@@ -688,7 +688,7 @@
            <input type="hidden" name="orgurl" value="/adm/coursedocs" />
            <input type="hidden" name="selectrole" value="1" />
            <h3><font color="red">Changes will become active for your current session after
-           <input type="hidden" name="$ENV{'request.role'}" value="1" />
+           <input type="hidden" name="$env{'request.role'}" value="1" />
            <input type="button" value="|;
     $initblock .= &mt('re-initializing course');
     $initblock .= qq|" onClick="javascript:init(this.form)"/>|;
Index: loncom/imspackages/imsprocessor.pm
diff -u loncom/imspackages/imsprocessor.pm:1.18 loncom/imspackages/imsprocessor.pm:1.19
--- loncom/imspackages/imsprocessor.pm:1.18	Wed Mar 23 15:55:33 2005
+++ loncom/imspackages/imsprocessor.pm	Thu Apr  7 02:56:22 2005
@@ -95,7 +95,7 @@
     my ($context,$tempdir,$source) = @_;
     my $fname;
     if ($context eq 'DOCS') {
-        $fname=$ENV{'form.uploadname.filename'};
+        $fname=$env{'form.uploadname.filename'};
 # Replace Windows backslashes by forward slashes
         $fname=~s/\\/\//g;
 # Get rid of everything but the actual filename
@@ -107,9 +107,9 @@
 # See if there is anything left
         unless ($fname) { return 'error: no uploaded file'; }
 # Save the file
-        chomp($ENV{'form.uploadname'});
+        chomp($env{'form.uploadname'});
         open(my $fh,'>'.$tempdir.'/'.$fname);
-        print $fh $ENV{'form.uploadname'};
+        print $fh $env{'form.uploadname'};
         close($fh);
     } elsif ($context eq 'CSTR') {
         if ($source =~ m/\/([^\/]+)$/) {
@@ -128,14 +128,8 @@
         return 'no zip';
     }
     if ($filename =~ m|\.zip$|i) {
-    # unzip can cause an sh launch which can pass along all of %ENV
-    # which can be too large for /bin/sh to handle
-        my %oldENV=%ENV;
-        undef(%ENV);
         open(OUTPUT, "unzip -o $zipfile -d $tempdir  2> /dev/null |");
         close(OUTPUT);
-        %ENV=%oldENV;
-        undef(%oldENV);
     } else {
         return 'nozip';
     }
@@ -2290,7 +2284,7 @@
     my $randompickflag = 0;
     my ($cid,$cdom,$cnum);
     if ($context eq 'DOCS') {
-        $cid = $ENV{'request.course.id'};
+        $cid = $env{'request.course.id'};
         ($cdom,$cnum) = split/_/,$cid;
     }
     my $destresdir = $destdir;
Index: loncom/interface/groupsort.pm
diff -u loncom/interface/groupsort.pm:1.30 loncom/interface/groupsort.pm:1.31
--- loncom/interface/groupsort.pm:1.30	Thu Feb 17 03:29:42 2005
+++ loncom/interface/groupsort.pm	Thu Apr  7 02:56:22 2005
@@ -2,7 +2,7 @@
 # The LON-CAPA group sort handler
 # Allows for sorting prior to import into RAT.
 #
-# $Id: groupsort.pm,v 1.30 2005/02/17 08:29:42 albertel Exp $
+# $Id: groupsort.pm,v 1.31 2005/04/07 06:56:22 albertel Exp $
 # 
 # Copyright Michigan State University Board of Trustees
 #
@@ -69,7 +69,7 @@
 
 # finish_import looks different for graphical or "simple" RAT
     my $finishimport='';
-    if ($ENV{'form.mode'} eq 'simple' || $ENV{'form.mode'} eq '') {
+    if ($env{'form.mode'} eq 'simple' || $env{'form.mode'} eq '') {
         $finishimport=(<<ENDSMP);
 function finish_import() {
     opener.document.forms.simpleedit.importdetail.value='';
@@ -150,17 +150,17 @@
 
     my $diropendb;
 # ------------------------------ which file do we open? Easy if explictly given
-    if ($ENV{'form.catalogmode'} eq 'groupsearch') {
+    if ($env{'form.catalogmode'} eq 'groupsearch') {
 	$diropendb = 
-	    "/home/httpd/perl/tmp/$ENV{'user.domain'}_$ENV{'user.name'}_searchcat.db";
+	    "/home/httpd/perl/tmp/$env{'user.domain'}_$env{'user.name'}_searchcat.db";
     }
-    elsif ($ENV{'form.catalogmode'} eq 'groupimport') {
+    elsif ($env{'form.catalogmode'} eq 'groupimport') {
 	$diropendb = 
-	    "/home/httpd/perl/tmp/$ENV{'user.domain'}_$ENV{'user.name'}_indexer.db";
+	    "/home/httpd/perl/tmp/$env{'user.domain'}_$env{'user.name'}_indexer.db";
     }
-    elsif ($ENV{'form.catalogmode'} eq 'groupsec') {
+    elsif ($env{'form.catalogmode'} eq 'groupsec') {
 	$diropendb = 
-	    "/home/httpd/perl/tmp/$ENV{'user.domain'}_$ENV{'user.name'}_groupsec.db";
+	    "/home/httpd/perl/tmp/$env{'user.domain'}_$env{'user.name'}_groupsec.db";
     }
 # --------------------- not explicitly given, choose the one most recently used
     else { # choose last accessed
@@ -168,19 +168,19 @@
         my @dbst;
 
 	$dbfn[0] =
-	    "/home/httpd/perl/tmp/$ENV{'user.domain'}_$ENV{'user.name'}_searchcat.db";
+	    "/home/httpd/perl/tmp/$env{'user.domain'}_$env{'user.name'}_searchcat.db";
         $dbst[0]=-1;
 	if (-e $dbfn[0]) {
 	    $dbst[0]=(stat($dbfn[0]))[9];
 	}
 	$dbfn[1] =
-            "/home/httpd/perl/tmp/$ENV{'user.domain'}_$ENV{'user.name'}_indexer.db";
+            "/home/httpd/perl/tmp/$env{'user.domain'}_$env{'user.name'}_indexer.db";
         $dbst[1]=-1;
 	if (-e $dbfn[1]) {
             $dbst[1]=(stat($dbfn[1]))[9];
         }
 	$dbfn[2] =
-            "/home/httpd/perl/tmp/$ENV{'user.domain'}_$ENV{'user.name'}_groupsec.db";
+            "/home/httpd/perl/tmp/$env{'user.domain'}_$env{'user.name'}_groupsec.db";
         $dbst[2]=-1;
 	if (-e $dbfn[2]) {
             $dbst[2]=(stat($dbfn[2]))[9];
@@ -202,7 +202,7 @@
     }
 # ----------------------------- diropendb is now the filename of the db to open
     if (tie(%hash,'GDBM_File',$diropendb,&GDBM_WRCREAT(),0640)) {
-	my $acts = $ENV{'form.acts'};
+	my $acts = $env{'form.acts'};
 	my @Acts = split(/b/,$acts);
 	my %ahash;
 	my %achash;
@@ -242,7 +242,7 @@
 		}
 	    }
 	}
-	if ($ENV{'form.oldval'}) {
+	if ($env{'form.oldval'}) {
 	    my $newctr = 0;
 	    my %chash;
 	    foreach (sort {$shash{$a} <=> $shash{$b}} (keys %shash)) {
@@ -252,8 +252,8 @@
 		$hash{'storectr_'.$key} = $newctr;
 		$chash{$newctr} = $key;
 	    }
-	    my $oldval = $ENV{'form.oldval'};
-	    my $newval = $ENV{'form.newval'};
+	    my $oldval = $env{'form.oldval'};
+	    my $newval = $env{'form.newval'};
 	    if ($oldval != $newval) {
 		# when newval==0, then push down and delete
 		if ($newval!=0) {
@@ -314,18 +314,18 @@
 <input type="hidden" name="fnum" value="$clen" />
 <input type="hidden" name="oldval" value="" />
 <input type="hidden" name="newval" value="" />
-<input type="hidden" name="mode" value="$ENV{'form.mode'}" />
+<input type="hidden" name="mode" value="$env{'form.mode'}" />
 END
 
         # --- Expand here if "GO BACK" button desired
-        if ($ENV{'form.catalogmode'} eq 'groupimport') {
+        if ($env{'form.catalogmode'} eq 'groupimport') {
             my $resurl = &Apache::loncommon::lastresurl();
 	    $r->print(<<END);
 <input type="button" name="alter" value="$lt{'gb'}"
  onClick="window.location='$resurl?catalogmode=groupimport'" />&nbsp;
 END
         }
-	if ($ENV{'form.catalogmode'} eq 'groupsearch') {
+	if ($env{'form.catalogmode'} eq 'groupsearch') {
 	    $r->print(<<END);
 <input type="button" name="alter" value="$lt{'ns'}"
  onClick="window.location='/adm/searchcat?catalogmode=groupsearch&cleargroupsort=1'" />&nbsp;
@@ -351,7 +351,7 @@
 <input type="hidden" name="fnum" value="$clen" />
 <input type="hidden" name="oldval" value="" />
 <input type="hidden" name="newval" value="" />
-<input type="hidden" name="mode" value="$ENV{'form.mode'}" />
+<input type="hidden" name="mode" value="$env{'form.mode'}" />
 END
     }
     foreach (sort {$shash{$a}<=>$shash{$b}} (keys %shash)) {
Index: loncom/interface/lonaboutme.pm
diff -u loncom/interface/lonaboutme.pm:1.36 loncom/interface/lonaboutme.pm:1.37
--- loncom/interface/lonaboutme.pm:1.36	Thu Feb 17 03:29:42 2005
+++ loncom/interface/lonaboutme.pm	Thu Apr  7 02:56:22 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # "About Me" Personal Information
 #
-# $Id: lonaboutme.pm,v 1.36 2005/02/17 08:29:42 albertel Exp $
+# $Id: lonaboutme.pm,v 1.37 2005/04/07 06:56:22 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -41,7 +41,7 @@
     &Apache::loncommon::content_type($r,'text/html');
     $r->send_http_header;
     return OK if $r->header_only;
-    my $target=$ENV{'form.grade_target'};
+    my $target=$env{'form.grade_target'};
 # ------------------------------------------------------------ Print the screen
     if ($target ne 'tex') {
 	my $html=&Apache::lonxml::xmlbegin();
@@ -51,7 +51,7 @@
 <title>The LearningOnline Network with CAPA</title>
 ENDDOCUMENT
     } else {
-	$r->print(&Apache::lonprintout::print_latex_header($ENV{'form.latex_type'}));
+	$r->print(&Apache::lonprintout::print_latex_header($env{'form.latex_type'}));
     }
     my (undef,undef,$cdom,$cnum)=split(/\//,$r->uri);
 # Is this even a user?
@@ -71,21 +71,21 @@
                             ($ENV{'QUERY_STRING'},['forcestudent','register']);
 # ----------------------------------------------------- Force menu registration
     my $addentries='';
-    if ($ENV{'form.register'}) {
+    if ($env{'form.register'}) {
        $addentries=' onLoad="'.&Apache::lonmenu::loadevents().
 	   '" onUnload="'.&Apache::lonmenu::unloadevents().'"';
        $r->print(&Apache::lonmenu::registerurl(1));
     }
 # --------------------------------------------------------------- Force Student
     my $forcestudent='';
-    if ($ENV{'form.forcestudent'}) { $forcestudent='student'; };
+    if ($env{'form.forcestudent'}) { $forcestudent='student'; };
        
 # --------------------------------------- There is such a user, get environment
     my %courseenv=&Apache::lonnet::dump('environment',$cdom,$cnum);
     if ($target ne 'tex') {
 	$r->print('</head>'.&Apache::loncommon::bodytag
                   ("Personal Information",$forcestudent,$addentries,'',$cdom,
-                   $ENV{'form.register'}));
+                   $env{'form.register'}));
 	$r->print('<h1>'.&Apache::loncommon::plainname($cnum,$cdom).'</h1>');
     } else {
 	$r->print('\noindent{\large\textbf{'.&Apache::loncommon::plainname($cnum,$cdom).'}}\\\\\\\\');
@@ -106,8 +106,8 @@
 
 # does this user have privileges to post, etc?
 
-       my $privleged=$allowed=(($ENV{'user.name'} eq $cnum) && 
-			       ($ENV{'user.domain'} eq $cdom));
+       my $privleged=$allowed=(($env{'user.name'} eq $cnum) && 
+			       ($env{'user.domain'} eq $cdom));
        if ($forcestudent or $target eq 'tex') { $allowed=0; }
  
        if ($allowed) {
@@ -120,9 +120,9 @@
 	   $r->print('<p><a href="'.$r->uri.'?forceedit=1"><font size="+1">'.
 		     &mt('Edit').'</font></a></p>');
        }
-      if (($ENV{'form.uploaddoc.filename'}) &&
-          ($ENV{'form.storeupl'}) && ($allowed)) {
- 	  if ($ENV{'form.uploaddoc.filename'}=~/\.(gif|jpg|png|jpeg)$/i) {
+      if (($env{'form.uploaddoc.filename'}) &&
+          ($env{'form.storeupl'}) && ($allowed)) {
+ 	  if ($env{'form.uploaddoc.filename'}=~/\.(gif|jpg|png|jpeg)$/i) {
 	      if ($syllabus{'uploaded.photourl'}) {
 		  &Apache::lonnet::removeuploadedurl($syllabus{'uploaded.photourl'});
 	      }
@@ -132,19 +132,19 @@
           $syllabus{'uploaded.lastmodified'}=time;
           &Apache::lonnet::put('aboutme',\%syllabus,$cdom,$cnum);
        }
-    if ($allowed && $ENV{'form.delupl'}) {
+    if ($allowed && $env{'form.delupl'}) {
 	if ($syllabus{'uploaded.photourl'}) {
 	    &Apache::lonnet::removeuploadedurl($syllabus{'uploaded.photourl'});
 	    delete($syllabus{'uploaded.photourl'});
 	    &Apache::lonnet::del('aboutme',['uploaded.photourl'],$cdom,$cnum);
 	}
     }
-       if (($allowed) && ($ENV{'form.storesyl'})) {
+       if (($allowed) && ($env{'form.storesyl'})) {
 	   foreach (keys %syllabusfields) {
-               my $field=$ENV{'form.'.$_};
+               my $field=$env{'form.'.$_};
                $field=~s/\s+$//s;
                $field=&Apache::lonfeedback::clear_out_html($field,
-                                                           $ENV{'user.adv'});
+                                                           $env{'user.adv'});
 	       $syllabus{$_}=$field;
            }
            $syllabus{'uploaded.lastmodified'}=time;
@@ -210,8 +210,8 @@
     } else {
        $r->print('<p>'.&mt('No personal information provided').'.</p>');
     }
-    if ($ENV{'request.course.id'}) {
-	if (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) {
+    if ($env{'request.course.id'}) {
+	if (&Apache::lonnet::allowed('srm',$env{'request.course.id'})) {
 	    if ($target ne 'tex') {
 		$r->print('<a name="coursecomment" />');
 		$r->print('<hr /><h3>'.
@@ -222,10 +222,10 @@
                 &Apache::lonmsg::disfacetoface($r,$cnum,$cdom);
                 $r->print('<hr />');
                 if (&Apache::lonnet::allowed('vsa',
-                                             $ENV{'request.course.id'}) ||
+                                             $env{'request.course.id'}) ||
                     &Apache::lonnet::allowed('vsa',
-                                             $ENV{'request.course.id'}.'/'.
-                                             $ENV{'request.course.sec'})) {
+                                             $env{'request.course.id'}.'/'.
+                                             $env{'request.course.sec'})) {
                     $r->print(&Apache::loncommon::track_student_link
                               ('View recent activity by this student',
                                $cnum,$cdom).('&nbsp;'x2));
Index: loncom/interface/lonannounce.pm
diff -u loncom/interface/lonannounce.pm:1.33 loncom/interface/lonannounce.pm:1.34
--- loncom/interface/lonannounce.pm:1.33	Thu Feb 17 03:29:42 2005
+++ loncom/interface/lonannounce.pm	Thu Apr  7 02:56:22 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Announce
 #
-# $Id: lonannounce.pm,v 1.33 2005/02/17 08:29:42 albertel Exp $
+# $Id: lonannounce.pm,v 1.34 2005/04/07 06:56:22 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -33,6 +33,7 @@
 use Apache::loncommon;
 use Apache::lonhtmlcommon();
 use Apache::lonlocal;
+use Apache::lonnet;
 use HTML::Entities();
 
 my %todayhash;
@@ -61,8 +62,8 @@
 
 sub readcalendar {
     my $courseid=shift;
-    my $coursenum=$ENV{'course.'.$courseid.'.num'};
-    my $coursedom=$ENV{'course.'.$courseid.'.domain'};
+    my $coursenum=$env{'course.'.$courseid.'.num'};
+    my $coursedom=$env{'course.'.$courseid.'.domain'};
     my %thiscal=&Apache::lonnet::dump('calendar',$coursedom,$coursenum);
     my %returnhash=();
     foreach (keys %thiscal) {
@@ -70,7 +71,7 @@
 	   $returnhash{$courseid.'@'.$_}=$thiscal{$_};
         }
     }
-    if ($courseid eq $ENV{'request.course.id'}) {
+    if ($courseid eq $env{'request.course.id'}) {
 	my %resourcedata=
 	    &Apache::lonnet::dump('resourcedata',$coursedom,$coursenum);
 	foreach my $thiskey (sort keys %resourcedata) {
@@ -81,11 +82,11 @@
 		if ($middle=~/^\[(.*)\]\./) {
 		    my $sec=$1;
 		    # if we have a section don't show ones that aren't ours
-		    if ($ENV{'request.course.sec'} &&
-			$ENV{'request.course.sec'} ne $sec) { next; }
+		    if ($env{'request.course.sec'} &&
+			$env{'request.course.sec'} ne $sec) { next; }
 		    # if a student without a section don't show any section ones
-		    if (!$ENV{'request.role.adv'} &&
-			!$ENV{'request.course.sec'}) { next; }
+		    if (!$env{'request.role.adv'} &&
+			!$env{'request.course.sec'}) { next; }
 		    $section=&mt('Group/Section').': '.$1;
 		    $middle=~s/^\[(.*)\]\.//;
 		}
@@ -142,16 +143,16 @@
 		$msg=~s/INTERNAL\://gs;
 		$internalflag=1;
 	    }
-            my $fullmsg=&mt('Calendar Announcement for ').$ENV{'course.'.$courseid.'.description'}.
+            my $fullmsg=&mt('Calendar Announcement for ').$env{'course.'.$courseid.'.description'}.
 		'\n'.&Apache::lonlocal::locallocaltime($start);
 	    if ($start!=$end) {
 		$fullmsg.=' - '.&Apache::lonlocal::locallocaltime($end);
 	    }
 	    $fullmsg.=':\n'.$msg;
-            if ($courseid eq $ENV{'request.course.id'}) {
-              if ((&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))
+            if ($courseid eq $env{'request.course.id'}) {
+              if ((&Apache::lonnet::allowed('srm',$env{'request.course.id'}))
                && (!$showedcheck{$start.'_'.$end})
-	       && ($ENV{'form.pickdate'} ne 'yes')
+	       && ($env{'form.pickdate'} ne 'yes')
 	       && (!$internalflag)) {
                $output.='<input type="checkbox" name="remove_'.$start.'_'.
 		   $end.'">';
@@ -179,7 +180,7 @@
         if ($_) {
 	    my ($courseid,$start,$end,@msg)=split(/\@/,$_);
             my $msg=join('@',@msg);
-            my $fullmsg=&mt('Calendar Announcement for ').$ENV{'course.'.$courseid.'.description'}.
+            my $fullmsg=&mt('Calendar Announcement for ').$env{'course.'.$courseid.'.description'}.
 		'\n'.&Apache::lonlocal::locallocaltime($start);
 	    if ($start!=$end) {
 		$fullmsg.=' - '.&Apache::lonlocal::locallocaltime($end);
@@ -256,7 +257,7 @@
 
 sub tfont {
     my $text=shift;
-    if ($ENV{'form.pickdate'} eq 'yes') {
+    if ($env{'form.pickdate'} eq 'yes') {
 	return '<font size="1">'.$text.'</font>';
     } else {
 	return $text;
@@ -265,7 +266,7 @@
 
 sub picklink {
     my ($text,$day,$month,$year)=@_;
-    if ($ENV{'form.pickdate'} eq 'yes') {
+    if ($env{'form.pickdate'} eq 'yes') {
 	return '<a href="javascript:dialin('.$day.','.$month.','.$year.')">'.
 	    $text.'</a>';
     } else {
@@ -277,14 +278,14 @@
     return (<<ENDDIA);
 <script language="Javascript">
 function dialin(day,month,year) {
-	opener.document.$ENV{'form.formname'}.$ENV{'form.element'}\_year.value=year;
-    var slct=opener.document.$ENV{'form.formname'}.$ENV{'form.element'}\_month;
+	opener.document.$env{'form.formname'}.$env{'form.element'}\_year.value=year;
+    var slct=opener.document.$env{'form.formname'}.$env{'form.element'}\_month;
     var i;
     for (i=0;i<slct.length;i++) {
         if (slct.options[i].value==month) { slct.selectedIndex=i; }
     }
-    opener.document.$ENV{'form.formname'}.$ENV{'form.element'}\_day.value=day;
-    opener.$ENV{'form.element'}\_checkday();
+    opener.document.$env{'form.formname'}.$env{'form.element'}\_day.value=day;
+    opener.$env{'form.element'}\_checkday();
     self.close();
 }
 </script>
@@ -308,14 +309,14 @@
                              ['month','year','pickdate','formname','element']);
 # --------------------------------------------------- Decide what month to show
     my $year=$todayhash{'year'};
-    if ($ENV{'form.year'}) { $year=$ENV{'form.year'}; }
+    if ($env{'form.year'}) { $year=$env{'form.year'}; }
     my $month=$todayhash{'month'};
-    if ($ENV{'form.month'}) { $month=$ENV{'form.month'}; }
+    if ($env{'form.month'}) { $month=$env{'form.month'}; }
 
 # ---------------------------------------------- See if we are in pickdate mode
-    my $pickdatemode=($ENV{'form.pickdate'} eq 'yes');
-    my $pickinfo='&pickdate=yes&formname='.$ENV{'form.formname'}.
-	'&element='.$ENV{'form.element'};
+    my $pickdatemode=($env{'form.pickdate'} eq 'yes');
+    my $pickinfo='&pickdate=yes&formname='.$env{'form.formname'}.
+	'&element='.$env{'form.element'};
 # --------------------------------------------- Find out first day of the month
 
     my %firstday=&Apache::loncommon::timehash(
@@ -354,14 +355,14 @@
     }
 # does this user have privileges to post, etc?
     my $allowed=0;
-    if ($ENV{'request.course.id'}) {
-       $allowed=&Apache::lonnet::allowed('srm',$ENV{'request.course.id'});
+    if ($env{'request.course.id'}) {
+       $allowed=&Apache::lonnet::allowed('srm',$env{'request.course.id'});
     }
 # does this user have privileges to post to servers?
     my $serverpost=0;
-    if ($ENV{'request.role.domain'}) {
+    if ($env{'request.role.domain'}) {
 	$serverpost=&Apache::lonnet::allowed('psa',
-					     $ENV{'request.role.domain'});
+					     $env{'request.role.domain'});
     } else {
 	$serverpost=&Apache::lonnet::allowed('psa','/');
     }
@@ -372,12 +373,12 @@
     }
 # ------------------------------------------------------------ Process commands
     if ($serverpost) {
-	if ($ENV{'form.serveraction'}) {
-	    foreach (keys %ENV) {
+	if ($env{'form.serveraction'}) {
+	    foreach (keys %env) {
 		if ($_=~/^form\.postto\_(\w+)/) {
 		    $r->print( 
 			'<br />Posting '.$1.': '.&Apache::lonnet::postannounce
-			($1,$ENV{'form.serverannnounce'}));
+			($1,$env{'form.serverannnounce'}));
 		}
 	    }
 	}
@@ -402,10 +403,10 @@
   '<br /><input type="submit" name="serveraction" value="Post"></form><hr />');
     }
     if ($allowed) {
-        my $coursenum=$ENV{'course.'.$ENV{'request.course.id'}.'.num'};
-        my $coursedom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
+        my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'};
+        my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'};
 # ----------------------------------------------------- Store new submitted one
-        if ($ENV{'form.action'} eq 'new') {
+        if ($env{'form.action'} eq 'new') {
 	    my $startdate = 
 		&Apache::lonhtmlcommon::get_date_from_form('startdate');
 	    my $enddate   = 
@@ -419,12 +420,12 @@
             }
 	    &Apache::lonnet::put('calendar',{ 
 		$startdate.'_'.$enddate => 
-		    $ENV{'form.msg'} },$coursedom,$coursenum);
+		    $env{'form.msg'} },$coursedom,$coursenum);
         }
 # ---------------------------------------------------------------- Remove items
-        if ($ENV{'form.action'} eq 'del') {
+        if ($env{'form.action'} eq 'del') {
 	    my @delwhich=();
-            foreach (keys %ENV) {
+            foreach (keys %env) {
 		if ($_=~/^form\.remove\_(.+)$/) {
 		    push(@delwhich,$1);
                 }
Index: loncom/interface/lonbulletin.pm
diff -u loncom/interface/lonbulletin.pm:1.28 loncom/interface/lonbulletin.pm:1.29
--- loncom/interface/lonbulletin.pm:1.28	Thu Feb 17 03:29:42 2005
+++ loncom/interface/lonbulletin.pm	Thu Apr  7 02:56:22 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Bulletin Board Handler
 #
-# $Id: lonbulletin.pm,v 1.28 2005/02/17 08:29:42 albertel Exp $
+# $Id: lonbulletin.pm,v 1.29 2005/04/07 06:56:22 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -41,7 +41,7 @@
     &Apache::loncommon::content_type($r,'text/html');
     $r->send_http_header;
     return OK if $r->header_only;
-    my $target=$ENV{'form.grade_target'};
+    my $target=$env{'form.grade_target'};
 
 # ------------------------------------------------------------ Print the screen
     if ($target ne 'tex') {
@@ -52,11 +52,11 @@
 <title>The LearningOnline Network with CAPA</title>
 ENDDOCUMENT
 } else {
-	$r->print(&Apache::lonprintout::print_latex_header($ENV{'form.latex_type'}));
+	$r->print(&Apache::lonprintout::print_latex_header($env{'form.latex_type'}));
     }
     my (undef,undef,undef,undef,$marker)=split(/\//,$r->uri);
 # Is this even in a course?
-    unless ($ENV{'request.course.id'}) {
+    unless ($env{'request.course.id'}) {
 	$r->print('</head><body>Not in a course</body></html>');
         return OK;
     }
@@ -68,8 +68,8 @@
         return OK;
     }
 
-    my $dom = $ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
-    my $crs = $ENV{'course.'.$ENV{'request.course.id'}.'.num'};
+    my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+    my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
 
 # --------------------------------------------------------- The syllabus fields
     my %syllabusfields=&Apache::lonlocal::texthash(
@@ -82,22 +82,22 @@
                 ($ENV{'QUERY_STRING'},['forcestudent','forceedit','register','origpage']);
 # ----------------------------------------------------- Force menu registration
     my $addentries='';
-    if ($ENV{'form.register'}) {
+    if ($env{'form.register'}) {
        $addentries=' onLoad="'.&Apache::lonmenu::loadevents();
-       if ($ENV{'form.origpage'}) {
+       if ($env{'form.origpage'}) {
            $addentries .= "document.location='#newpost';";
        }
        $addentries .= '" onUnload="'.&Apache::lonmenu::unloadevents().'"';
        $r->print(&Apache::lonmenu::registerurl(1));
-    } elsif ($ENV{'form.origpage'}) {
+    } elsif ($env{'form.origpage'}) {
          $addentries = "onLoad=\"document.location='#newpost';\"";
     }
 # --------------------------------------------------------------- Force Student
     my $forcestudent='';
-    if ($ENV{'form.forcestudent'}) { $forcestudent='student'; }
+    if ($env{'form.forcestudent'}) { $forcestudent='student'; }
 
     my $forceedit='';
-    if ($ENV{'form.forceedit'}) { $forceedit='edit'; }
+    if ($env{'form.forceedit'}) { $forceedit='edit'; }
 
     my %syllabus=&Apache::lonnet::dump('bulletinpage_'.$marker,$dom,$crs);
        
@@ -105,9 +105,9 @@
     if ($target ne 'tex') {   
 	$r->print('</head>'.&Apache::loncommon::bodytag
                   ("Bulletin Board/Discussion",$forcestudent,$addentries,'',$dom,
-                  $ENV{'form.register'}));
+                  $env{'form.register'}));
     }
-    my $allowed=&Apache::lonnet::allowed('mdc',$ENV{'request.course.id'});
+    my $allowed=&Apache::lonnet::allowed('mdc',$env{'request.course.id'});
 
     my $privileged=$allowed;
     if (($syllabus{'uploaded.lastmodified'}) && (!$forceedit)) {
@@ -126,9 +126,9 @@
 		    .&mt('Edit').'</font></a>');
       } 
 
-      if (($ENV{'form.uploaddoc.filename'}) &&
-          ($ENV{'form.storeupl'}) && ($allowed)) {
- 	  if ($ENV{'form.uploaddoc.filename'}=~/\.(gif|jpg|png|jpeg)$/i) {
+      if (($env{'form.uploaddoc.filename'}) &&
+          ($env{'form.storeupl'}) && ($allowed)) {
+ 	  if ($env{'form.uploaddoc.filename'}=~/\.(gif|jpg|png|jpeg)$/i) {
 	      if ($syllabus{'uploaded.photourl'}) {
 		  &Apache::lonnet::removeuploadedurl($syllabus{'uploaded.photourl'});
 	      }
@@ -138,9 +138,9 @@
           $syllabus{'uploaded.lastmodified'}=time;
           &Apache::lonnet::put('bulletinpage_'.$marker,\%syllabus,$dom,$crs);
        }
-       if (($allowed) && ($ENV{'form.storesyl'})) {
+       if (($allowed) && ($env{'form.storesyl'})) {
 	   foreach (keys %syllabusfields) {
-               my $field=$ENV{'form.'.$_};
+               my $field=$env{'form.'.$_};
                $field=~s/\s+$//s;
                $field=&Apache::lonfeedback::clear_out_html($field,1);
 	       $syllabus{$_}=$field;
Index: loncom/interface/lonchat.pm
diff -u loncom/interface/lonchat.pm:1.9 loncom/interface/lonchat.pm:1.10
--- loncom/interface/lonchat.pm:1.9	Thu Feb 17 03:50:20 2005
+++ loncom/interface/lonchat.pm	Thu Apr  7 02:56:22 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Chat
 #
-# $Id: lonchat.pm,v 1.9 2005/02/17 08:50:20 albertel Exp $
+# $Id: lonchat.pm,v 1.10 2005/04/07 06:56:22 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -31,20 +31,21 @@
 use strict;
 use Apache::Constants qw(:common :http);
 use Apache::loncommon;
+use Apache::lonnet;
 
 sub handler {
     my $r = shift;
     &Apache::loncommon::content_type($r,'text/html');
     $r->send_http_header;
     return OK if $r->header_only;
-    if (! &Apache::lonnet::allowed('plc',$ENV{'request.course.id'}.
-              ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:'')
+    if (! &Apache::lonnet::allowed('plc',$env{'request.course.id'}.
+              ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')
                                    )) {
         return HTTP_NOT_ACCEPTABLE;
     }
 
-    if ($ENV{'form.newchat'}) {
-	&Apache::lonnet::chatsend(&Apache::lonfeedback::clear_out_html($ENV{'form.newchat'}),$ENV{'form.anonymous'});
+    if ($env{'form.newchat'}) {
+	&Apache::lonnet::chatsend(&Apache::lonfeedback::clear_out_html($env{'form.newchat'}),$env{'form.anonymous'});
     }
 # --------------------------------------------------- Print login screen header
     my $latexHelp = Apache::loncommon::helpLatexCheatsheet();
Index: loncom/interface/lonchatfetch.pm
diff -u loncom/interface/lonchatfetch.pm:1.16 loncom/interface/lonchatfetch.pm:1.17
--- loncom/interface/lonchatfetch.pm:1.16	Thu Feb 17 03:50:20 2005
+++ loncom/interface/lonchatfetch.pm	Thu Apr  7 02:56:22 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Chat Fetching
 #
-# $Id: lonchatfetch.pm,v 1.16 2005/02/17 08:50:20 albertel Exp $
+# $Id: lonchatfetch.pm,v 1.17 2005/04/07 06:56:22 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -37,8 +37,8 @@
 sub handler {
     my $r = shift;
 
-    if (! &Apache::lonnet::allowed('pch',$ENV{'request.course.id'}.
-             ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))
+    if (! &Apache::lonnet::allowed('pch',$env{'request.course.id'}.
+             ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))
         ) {
         return HTTP_NOT_ACCEPTABLE;
     }
@@ -47,7 +47,7 @@
     if ($loaderror) { return $loaderror; }
     $loaderror=
        &Apache::lonnet::overloaderror($r,
-         $ENV{'course.'.$ENV{'request.course.id'}.'.home'});
+         $env{'course.'.$env{'request.course.id'}.'.home'});
     if ($loaderror) { return $loaderror; }
 
     &Apache::loncommon::content_type($r,'text/html');
@@ -56,13 +56,13 @@
 
 # ------------------------------------------------------------ retrieve entries
 
-    my $cnum=$ENV{'course.'.$ENV{'request.course.id'}.'.num'};
-    my $cdom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
-    my $chome=$ENV{'course.'.$ENV{'request.course.id'}.'.home'};
+    my $cnum=$env{'course.'.$env{'request.course.id'}.'.num'};
+    my $cdom=$env{'course.'.$env{'request.course.id'}.'.domain'};
+    my $chome=$env{'course.'.$env{'request.course.id'}.'.home'};
 
     my @entries=split(/\:/,
        &Apache::lonnet::reply(
-        "chatretr:$cdom:$cnum:$ENV{'user.domain'}:$ENV{'user.name'}",$chome));
+        "chatretr:$cdom:$cnum:$env{'user.domain'}:$env{'user.name'}",$chome));
 # Figure out what the last valid entry-id is
     my ($lastid,$thentime,$idnum);
     foreach (@entries) {
@@ -73,9 +73,9 @@
 	}
     }
 # ----------------------------------------------------------- Can see identity?
-    my $crs='/'.$ENV{'request.course.id'};
-    if ($ENV{'request.course.sec'}) {
-       $crs.='_'.$ENV{'request.course.sec'};
+    my $crs='/'.$env{'request.course.id'};
+    if ($env{'request.course.sec'}) {
+       $crs.='_'.$env{'request.course.sec'};
     }                 
     $crs=~s/\_/\//g;
     my $seeid=&Apache::lonnet::allowed('rin',$crs);
@@ -84,7 +84,7 @@
     my $include=0;
     my $newstuff='';
     my $bottomid='';
-    unless ($ENV{'form.lastid'}) { 
+    unless ($env{'form.lastid'}) { 
        $include=1; 
        my $html=&Apache::lonxml::xmlbegin();
        $newstuff=$html.'<head></head><body bgcolor="#FFFFFF">';
@@ -106,8 +106,8 @@
 	    $contrib=~s/\n/\<br \/\>/g;
 	    ($contrib,my $errors)=&Apache::lontexconvert::msgtexconverted($contrib);
 	    if ($errors) { $contrib.="[Message not fully displayed due to incorrect embedded TeX]"; }
-	    if ($errors && $snum eq $ENV{'user.name'} &&
-		$sdom eq $ENV{'user.domain'} ) {
+	    if ($errors && $snum eq $env{'user.name'} &&
+		$sdom eq $env{'user.domain'} ) {
 		$contrib.="<br />[TeX error message: $errors]";
 	    }
 	    $contrib=~s/\n/ /g;
@@ -146,7 +146,7 @@
 	    $bottomid=$id;
 	} else {
 	    $_=~/^(\w+)/;
-	    if ($1 eq $ENV{'form.lastid'}) { $include=1; }
+	    if ($1 eq $env{'form.lastid'}) { $include=1; }
 	}
     }
     my $participant_output=join('<br />',sort @participants);
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.257 loncom/interface/loncommon.pm:1.258
--- loncom/interface/loncommon.pm:1.257	Tue Mar 22 10:32:07 2005
+++ loncom/interface/loncommon.pm	Thu Apr  7 02:56:22 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.257 2005/03/22 15:32:07 matthew Exp $
+# $Id: loncommon.pm,v 1.258 2005/04/07 06:56:22 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -55,7 +55,7 @@
 package Apache::loncommon;
 
 use strict;
-use Apache::lonnet();
+use Apache::lonnet;
 use GDBM_File;
 use POSIX qw(strftime mktime);
 use Apache::Constants qw(:common :http :methods);
@@ -311,8 +311,8 @@
 }
 
 sub lastresurl {
-    if ($ENV{'environment.lastresurl'}) {
-	return $ENV{'environment.lastresurl'}
+    if ($env{'environment.lastresurl'}) {
+	return $env{'environment.lastresurl'}
     } else {
 	return '/res';
     }
@@ -329,9 +329,9 @@
 
 sub studentbrowser_javascript {
    unless (
-            (($ENV{'request.course.id'}) && 
-             (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})))
-         || ($ENV{'request.role'}=~/^(au|dc|su)/)
+            (($env{'request.course.id'}) && 
+             (&Apache::lonnet::allowed('srm',$env{'request.course.id'})))
+         || ($env{'request.role'}=~/^(au|dc|su)/)
           ) { return ''; }  
    return (<<'ENDSTDBRW');
 <script type="text/javascript" language="Javascript" >
@@ -360,14 +360,14 @@
 
 sub selectstudent_link {
    my ($form,$unameele,$udomele)=@_;
-   if ($ENV{'request.course.id'}) {  
-       unless (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) {
+   if ($env{'request.course.id'}) {  
+       unless (&Apache::lonnet::allowed('srm',$env{'request.course.id'})) {
 	   return '';
        }
        return "<a href='".'javascript:openstdbrowser("'.$form.'","'.$unameele.
         '","'.$udomele.'");'."'>".&mt('Select User')."</a>";
    }
-   if ($ENV{'request.role'}=~/^(au|dc|su)/) {
+   if ($env{'request.role'}=~/^(au|dc|su)/) {
        return "<a href='".'javascript:openstdbrowser("'.$form.'","'.$unameele.
         '","'.$udomele.'",1);'."'>".&mt('Select User')."</a>";
    }
@@ -593,8 +593,8 @@
     my ($topic, $text, $stayOnPage, $width, $height) = @_;
     $text = "" if (not defined $text);
     $stayOnPage = 0 if (not defined $stayOnPage);
-    if ($ENV{'browser.interface'} eq 'textual' ||
-	$ENV{'environment.remote'} eq 'off' ) {
+    if ($env{'browser.interface'} eq 'textual' ||
+	$env{'environment.remote'} eq 'off' ) {
 	$stayOnPage=1;
     }
     $width = 350 if (not defined $width);
@@ -659,8 +659,8 @@
     my ($color,$topic,$component_help,$function,$faq,$bug,$stayOnPage,$width,$height,$text) = @_;
     $text = "" if (not defined $text);
     $stayOnPage = 0 if (not defined $stayOnPage);
-    if ($ENV{'browser.interface'} eq 'textual' ||
-        $ENV{'environment.remote'} eq 'off' ) {
+    if ($env{'browser.interface'} eq 'textual' ||
+        $env{'environment.remote'} eq 'off' ) {
         $stayOnPage=1;
     }
     $width = 620 if (not defined $width);
@@ -742,12 +742,12 @@
 
 sub help_open_bug {
     my ($topic, $text, $stayOnPage, $width, $height) = @_;
-    unless ($ENV{'user.adv'}) { return ''; }
+    unless ($env{'user.adv'}) { return ''; }
     unless ($Apache::lonnet::perlvar{'BugzillaHost'}) { return ''; }
     $text = "" if (not defined $text);
     $stayOnPage = 0 if (not defined $stayOnPage);
-    if ($ENV{'browser.interface'} eq 'textual' ||
-	$ENV{'environment.remote'} eq 'off' ) {
+    if ($env{'browser.interface'} eq 'textual' ||
+	$env{'environment.remote'} eq 'off' ) {
 	$stayOnPage=1;
     }
     $width = 600 if (not defined $width);
@@ -787,12 +787,12 @@
 
 sub help_open_faq {
     my ($topic, $text, $stayOnPage, $width, $height) = @_;
-    unless ($ENV{'user.adv'}) { return ''; }
+    unless ($env{'user.adv'}) { return ''; }
     unless ($Apache::lonnet::perlvar{'FAQHost'}) { return ''; }
     $text = "" if (not defined $text);
     $stayOnPage = 0 if (not defined $stayOnPage);
-    if ($ENV{'browser.interface'} eq 'textual' ||
-	$ENV{'environment.remote'} eq 'off' ) {
+    if ($env{'browser.interface'} eq 'textual' ||
+	$env{'environment.remote'} eq 'off' ) {
 	$stayOnPage=1;
     }
     $width = 350 if (not defined $width);
@@ -865,8 +865,8 @@
 
 sub change_content_javascript {
     # If we're on Netscape 4, we need to use Layer-based code
-    if ($ENV{'browser.type'} eq 'netscape' &&
-	$ENV{'browser.version'} =~ /^4\./) {
+    if ($env{'browser.type'} eq 'netscape' &&
+	$env{'browser.version'} =~ /^4\./) {
 	return (<<NETSCAPE4);
 	function change(name, content) {
 	    doc = document.layers[name+"___escape"].layers[0].document;
@@ -903,8 +903,8 @@
 sub changable_area {
     my ($name, $origContent) = @_;
 
-    if ($ENV{'browser.type'} eq 'netscape' &&
-	$ENV{'browser.version'} =~ /^4\./) {
+    if ($env{'browser.type'} eq 'netscape' &&
+	$env{'browser.version'} =~ /^4\./) {
 	# If this is netscape 4, we need to use the Layer tag
 	return "<ilayer width='100%' id='${name}___escape' overflow='none'><layer width='100%' id='$name' overflow='none'>$origContent</layer></ilayer>";
     } else {
@@ -1024,7 +1024,7 @@
         #
     # Create the excel spreadsheet
     my $filename = '/prtspool/'.
-        $ENV{'user.name'}.'_'.$ENV{'user.domain'}.'_'.
+        $env{'user.name'}.'_'.$env{'user.domain'}.'_'.
         time.'_'.rand(1000000000).'.xls';
     my $workbook  = Spreadsheet::WriteExcel->new('/home/httpd'.$filename);
     if (! defined($workbook)) {
@@ -1067,7 +1067,7 @@
     if (! defined($suffix)) { $suffix = 'txt'; };
     my $fh;
     my $filename = '/prtspool/'.
-        $ENV{'user.name'}.'_'.$ENV{'user.domain'}.'_'.
+        $env{'user.name'}.'_'.$env{'user.domain'}.'_'.
         time.'_'.rand(1000000000).'.'.$suffix;
     $fh = Apache::File->new('>/home/httpd'.$filename);
     if (! defined($fh)) {
@@ -1904,13 +1904,13 @@
 sub nickname {
     my ($uname,$udom)=@_;
     my %names;
-    if ($uname eq $ENV{'user.name'} &&
-	$udom eq $ENV{'user.domain'}) {
-	%names=('nickname'   => $ENV{'environment.nickname'}  ,
-		'firstname'  => $ENV{'environment.firstname'} ,
-		'middlename' => $ENV{'environment.middlename'},
-		'lastname'   => $ENV{'environment.lastname'}  ,
-		'generation' => $ENV{'environment.generation'});
+    if ($uname eq $env{'user.name'} &&
+	$udom eq $env{'user.domain'}) {
+	%names=('nickname'   => $env{'environment.nickname'}  ,
+		'firstname'  => $env{'environment.firstname'} ,
+		'middlename' => $env{'environment.middlename'},
+		'lastname'   => $env{'environment.lastname'}  ,
+		'generation' => $env{'environment.generation'});
     } else {
 	%names=&Apache::lonnet::get('environment',
 				    ['nickname','firstname','middlename',
@@ -1941,8 +1941,8 @@
 
 sub screenname {
     my ($uname,$udom)=@_;
-    if ($uname eq $ENV{'user.name'} &&
-	$udom eq $ENV{'user.domain'}) {return $ENV{'environment.screenname'};}
+    if ($uname eq $env{'user.name'} &&
+	$udom eq $env{'user.domain'}) {return $env{'environment.screenname'};}
     my %names=&Apache::lonnet::get('environment',['screenname'],$udom,$uname);
     return $names{'screenname'};
 }
@@ -2190,8 +2190,8 @@
 	$languages{$_}=1;
     }
     &get_unprocessed_cgi($ENV{'QUERY_STRING'},['displaylanguage']);
-    if ($ENV{'form.displaylanguage'}) {
-	foreach (split(/\s*(\,|\;|\:)\s*/,$ENV{'form.displaylanguage'})) {
+    if ($env{'form.displaylanguage'}) {
+	foreach (split(/\s*(\,|\;|\:)\s*/,$env{'form.displaylanguage'})) {
 	    $languages{$_}=1;
         }
     }
@@ -2200,24 +2200,24 @@
 
 sub preferred_languages {
     my @languages=();
-    if ($ENV{'course.'.$ENV{'request.course.id'}.'.languages'}) {
+    if ($env{'course.'.$env{'request.course.id'}.'.languages'}) {
 	@languages=(@languages,split(/\s*(\,|\;|\:)\s*/,
-	         $ENV{'course.'.$ENV{'request.course.id'}.'.languages'}));
+	         $env{'course.'.$env{'request.course.id'}.'.languages'}));
     }
-    if ($ENV{'environment.languages'}) {
-	@languages=split(/\s*(\,|\;|\:)\s*/,$ENV{'environment.languages'});
+    if ($env{'environment.languages'}) {
+	@languages=split(/\s*(\,|\;|\:)\s*/,$env{'environment.languages'});
     }
     my $browser=(split(/\;/,$ENV{'HTTP_ACCEPT_LANGUAGE'}))[0];
     if ($browser) {
 	@languages=(@languages,split(/\s*(\,|\;|\:)\s*/,$browser));
     }
-    if ($Apache::lonnet::domain_lang_def{$ENV{'user.domain'}}) {
+    if ($Apache::lonnet::domain_lang_def{$env{'user.domain'}}) {
 	@languages=(@languages,
-		$Apache::lonnet::domain_lang_def{$ENV{'user.domain'}});
+		$Apache::lonnet::domain_lang_def{$env{'user.domain'}});
     }
-    if ($Apache::lonnet::domain_lang_def{$ENV{'request.role.domain'}}) {
+    if ($Apache::lonnet::domain_lang_def{$env{'request.role.domain'}}) {
 	@languages=(@languages,
-		$Apache::lonnet::domain_lang_def{$ENV{'request.role.domain'}});
+		$Apache::lonnet::domain_lang_def{$env{'request.role.domain'}});
     }
     if ($Apache::lonnet::domain_lang_def{
 	                          $Apache::lonnet::perlvar{'lonDefDomain'}}) {
@@ -2539,9 +2539,9 @@
 sub findallcourses {
     my %courses=();
     my $now=time;
-    foreach (keys %ENV) {
+    foreach (keys %env) {
 	if ($_=~/^user\.role\.\w+\.\/(\w+)\/(\w+)/) {
-	    my ($starttime,$endtime)=$ENV{$_};
+	    my ($starttime,$endtime)=$env{$_};
             my $active=1;
             if ($starttime) {
 		if ($now<$starttime) { $active=0; }
@@ -2578,9 +2578,9 @@
    if (! $domain) {
         # Determine domain if we have not been given one
         $domain = $Apache::lonnet::perlvar{'lonDefDomain'};
-        if ($ENV{'user.domain'}) { $domain=$ENV{'user.domain'}; }
-        if ($ENV{'request.role.domain'}) { 
-            $domain=$ENV{'request.role.domain'}; 
+        if ($env{'user.domain'}) { $domain=$env{'user.domain'}; }
+        if ($env{'request.role.domain'}) { 
+            $domain=$env{'request.role.domain'}; 
         }
     }
     return $domain;
@@ -2625,7 +2625,7 @@
 ##############################################
 sub designparm {
     my ($which,$domain)=@_;
-    if ($ENV{'browser.blackwhite'} eq 'on') {
+    if ($env{'browser.blackwhite'} eq 'on') {
 	if ($which=~/\.(font|alink|vlink|link)$/) {
 	    return '#000000';
 	}
@@ -2636,8 +2636,8 @@
 	    return '#CCCCCC';
 	}
     }
-    if ($ENV{'environment.color.'.$which}) {
-	return $ENV{'environment.color.'.$which};
+    if ($env{'environment.color.'.$which}) {
+	return $env{'environment.color.'.$which};
     }
     $domain=&determinedomain($domain);
     if ($designhash{$domain.'.'.$which}) {
@@ -2703,16 +2703,16 @@
 # Accessibility font enhance
     unless ($addentries) { $addentries=''; }
     my $addstyle='';
-    if ($ENV{'browser.fontenhance'} eq 'on') {
+    if ($env{'browser.fontenhance'} eq 'on') {
 	$addstyle=' font-size: x-large;';
     }
  # role and realm
     my ($role,$realm)
-       =&Apache::lonnet::plaintext((split(/\./,$ENV{'request.role'}))[0]);
+       =&Apache::lonnet::plaintext((split(/\./,$env{'request.role'}))[0]);
 # realm
-    if ($ENV{'request.course.id'}) {
+    if ($env{'request.course.id'}) {
 	$realm=
-         $ENV{'course.'.$ENV{'request.course.id'}.'.description'};
+         $env{'course.'.$env{'request.course.id'}.'.description'};
     }
     unless ($realm) { $realm='&nbsp;'; }
 # Set messages
@@ -2729,7 +2729,7 @@
 <body bgcolor="$pgbg" text="$font" alink="$alink" vlink="$vlink" link="$link"
 style="margin-top: 0px;$addstyle" $addentries>
 END
-    if ($ENV{'environment.texengine'} eq 'jsMath') {
+    if ($env{'environment.texengine'} eq 'jsMath') {
 	$bodytag.='<script type="text/javascript">
                      function NoFontMessage () {}
                    </script>'."\n".
@@ -2740,21 +2740,21 @@
                    $lonhttpdPort.$img.'" alt="'.$function.'" />';
     if ($bodyonly) {
         return $bodytag;
-    } elsif ($ENV{'browser.interface'} eq 'textual') {
+    } elsif ($env{'browser.interface'} eq 'textual') {
 # Accessibility
           
         return $bodytag.&Apache::lonmenu::menubuttons($forcereg,'web',
                                                       $forcereg).
                '<h1>LON-CAPA: '.$title.'</h1>';
-    } elsif ($ENV{'environment.remote'} eq 'off') {
+    } elsif ($env{'environment.remote'} eq 'off') {
 # No Remote
 	my $roleinfo=(<<ENDROLE);
 <td bgcolor="$tabbg" align="right">
 <font size="2" face="Arial, Helvetica, sans-serif">
-    $ENV{'environment.firstname'}
-    $ENV{'environment.middlename'}
-    $ENV{'environment.lastname'}
-    $ENV{'environment.generation'}
+    $env{'environment.firstname'}
+    $env{'environment.middlename'}
+    $env{'environment.lastname'}
+    $env{'environment.generation'}
     </font>&nbsp;
 <br />
 <font size="2" face="Arial, Helvetica, sans-serif">$role</font>&nbsp;
@@ -2768,9 +2768,9 @@
             $titleinfo = $customtitle;
         }
 
-	if ($ENV{'request.state'} eq 'construct') {
+	if ($env{'request.state'} eq 'construct') {
 	    my ($uname,$thisdisfn)=
-		($ENV{'request.filename'} =~ m|^/home/([^/]+)/public_html/(.*)|);
+		($env{'request.filename'} =~ m|^/home/([^/]+)/public_html/(.*)|);
 	    my $formaction='/priv/'.$uname.'/'.$thisdisfn;
 	    $formaction=~s/\/+/\//g;
             unless ($customtitle) {  #this is for resources; directories have customtitle, and crumbs and select recent are created in lonpubdir.pm  
@@ -2798,7 +2798,7 @@
                          'cellspacing="3" cellpadding="3">'.
                          '<tr><td rowspan="3" bgcolor="'.$tabbg.'">'.
                          $titleinfo.'</td>'.$roleinfo.'</tr></table>';
-        if ($ENV{'request.state'} eq 'construct') {
+        if ($env{'request.state'} eq 'construct') {
             $bodytag .= &Apache::lonmenu::menubuttons($forcereg,'web',$forcereg,$titletable);
 	} else {
             $bodytag .= &Apache::lonmenu::menubuttons($forcereg,'web',$forcereg).
@@ -2817,11 +2817,11 @@
     #
     # Extra info if you are the DC
     my $dc_info = '';
-    if ($ENV{'user.adv'} && exists($ENV{'user.role.dc./'.
-                        $ENV{'course.'.$ENV{'request.course.id'}.
+    if ($env{'user.adv'} && exists($env{'user.role.dc./'.
+                        $env{'course.'.$env{'request.course.id'}.
                                  '.domain'}.'/'})) {
-        my $cid = $ENV{'request.course.id'};
-        $dc_info.= $cid.' '.$ENV{'course.'.$cid.'.internal.coursecode'};
+        my $cid = $env{'request.course.id'};
+        $dc_info.= $cid.' '.$env{'course.'.$cid.'.internal.coursecode'};
         $dc_info = '('.$dc_info.')';
     }
     #
@@ -2837,10 +2837,10 @@
 $titleinfo $dc_info
 </td><td bgcolor="$tabbg" align="right">
 <font size="2" face="Arial, Helvetica, sans-serif">
-    $ENV{'environment.firstname'}
-    $ENV{'environment.middlename'}
-    $ENV{'environment.lastname'}
-    $ENV{'environment.generation'}
+    $env{'environment.firstname'}
+    $env{'environment.middlename'}
+    $env{'environment.lastname'}
+    $env{'environment.generation'}
     </font>&nbsp;
 </td>
 </tr>
@@ -2880,7 +2880,7 @@
 
 sub endbodytag {
     my $endbodytag='</body>';
-    if ($ENV{'environment.texengine'} eq 'jsMath') {
+    if ($env{'environment.texengine'} eq 'jsMath') {
 	$endbodytag='<script type="text/javascript">jsMath.Process()</script>'.
 	    "\n".$endbodytag;
     }
@@ -2901,13 +2901,13 @@
 ###############################################
 sub get_users_function {
     my $function = 'student';
-    if ($ENV{'request.role'}=~/^(cc|in|ta|ep)/) {
+    if ($env{'request.role'}=~/^(cc|in|ta|ep)/) {
         $function='coordinator';
     }
-    if ($ENV{'request.role'}=~/^(su|dc|ad|li)/) {
+    if ($env{'request.role'}=~/^(su|dc|ad|li)/) {
         $function='admin';
     }
-    if (($ENV{'request.role'}=~/^(au|ca)/) ||
+    if (($env{'request.role'}=~/^(au|ca)/) ||
         ($ENV{'REQUEST_URI'}=~/^(\/priv|\~)/)) {
         $function='author';
     }
@@ -3001,8 +3001,8 @@
 		if ($name) {
 		    chomp($value);
 		    if ($fname) {
-			$ENV{"form.$name.filename"}=$fname;
-			$ENV{"form.$name.mimetype"}=$fmime;
+			$env{"form.$name.filename"}=$fname;
+			$env{"form.$name.mimetype"}=$fmime;
 		    } else {
 			$value=~s/\s+$//s;
 		    }
@@ -3034,7 +3034,7 @@
 	    }
 	}
     }
-    $ENV{'request.method'}=$ENV{'REQUEST_METHOD'};
+    $env{'request.method'}=$ENV{'REQUEST_METHOD'};
     $r->method_number(M_GET);
     $r->method('GET');
     $r->headers_in->unset('Content-length');
@@ -3044,14 +3044,14 @@
 
 =item * get_unprocessed_cgi($query,$possible_names)
 
-Modify the %ENV hash to contain unprocessed CGI form parameters held in
+Modify the %env hash to contain unprocessed CGI form parameters held in
 $query.  The parameters listed in $possible_names (an array reference),
-will be set in $ENV{'form.name'} if they do not already exist.
+will be set in $env{'form.name'} if they do not already exist.
 
 Typically called with $ENV{'QUERY_STRING'} as the first parameter.  
 $possible_names is an ref to an array of form element names.  As an example:
 get_unprocessed_cgi($ENV{'QUERY_STRING'},['uname','udom']);
-will result in $ENV{'form.uname'} and $ENV{'form.udom'} being set.
+will result in $env{'form.uname'} and $env{'form.udom'} being set.
 
 =cut
 
@@ -3065,7 +3065,7 @@
       $value =~ tr/+/ /;
       $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
       &Apache::lonxml::debug("Seting :$name: to :$value:");
-      unless (defined($ENV{'form.'.$name})) { &add_to_env('form.'.$name,$value) };
+      unless (defined($env{'form.'.$name})) { &add_to_env('form.'.$name,$value) };
     }
   }
 }
@@ -3079,7 +3079,7 @@
 =cut
 
 sub cacheheader {
-    unless ($ENV{'request.method'} eq 'GET') { return ''; }
+    unless ($env{'request.method'} eq 'GET') { return ''; }
     my $date=strftime("%a, %d %b %Y %H:%M:%S GMT",gmtime);
     my $output .='<meta HTTP-EQUIV="Expires" CONTENT="'.$date.'" />
                 <meta HTTP-EQUIV="Cache-control" CONTENT="no-cache" />
@@ -3098,7 +3098,7 @@
 sub no_cache {
     my ($r) = @_;
     if ($ENV{'REQUEST_METHOD'} ne 'GET' &&
-	$ENV{'request.method'} ne 'GET') { return ''; }
+	$env{'request.method'} ne 'GET') { return ''; }
     my $date=strftime("%a, %d %b %Y %H:%M:%S GMT",gmtime(time));
     $r->no_cache(1);
     $r->header_out("Expires" => $date);
@@ -3107,7 +3107,7 @@
 
 sub content_type {
     my ($r,$type,$charset) = @_;
-    if ($ENV{'browser.mathml'} && $type eq 'text/html') { $type='text/xml'; }
+    if ($env{'browser.mathml'} && $type eq 'text/html') { $type='text/xml'; }
     unless ($charset) {
 	$charset=&Apache::lonlocal::current_encoding;
     }
@@ -3123,7 +3123,7 @@
 
 =item * add_to_env($name,$value) 
 
-adds $name to the %ENV hash with value
+adds $name to the %env hash with value
 $value, if $name already exists, the entry is converted to an array
 reference and $value is added to the array.
 
@@ -3131,17 +3131,21 @@
 
 sub add_to_env {
   my ($name,$value)=@_;
-  if (defined($ENV{$name})) {
-    if (ref($ENV{$name})) {
+  if (defined($env{$name})) {
+    if (ref($env{$name})) {
       #already have multiple values
+      push(@{ $env{$name} },$value);
       push(@{ $ENV{$name} },$value);
     } else {
       #first time seeing multiple values, convert hash entry to an arrayref
-      my $first=$ENV{$name};
+      my $first=$env{$name};
+      undef($env{$name});
       undef($ENV{$name});
+      push(@{ $env{$name} },$first,$value);
       push(@{ $ENV{$name} },$first,$value);
     }
   } else {
+    $env{$name}=$value;
     $ENV{$name}=$value;
   }
 }
@@ -3150,7 +3154,7 @@
 
 =item * get_env_multiple($name) 
 
-gets $name from the %ENV hash, it seemlessly handles the cases where multiple
+gets $name from the %env hash, it seemlessly handles the cases where multiple
 values may be defined and end up as an array ref.
 
 returns an array of values
@@ -3160,12 +3164,12 @@
 sub get_env_multiple {
     my ($name) = @_;
     my @values;
-    if (defined($ENV{$name})) {
+    if (defined($env{$name})) {
         # exists is it an array
-        if (ref($ENV{$name})) {
-            @values=@{ $ENV{$name} };
+        if (ref($env{$name})) {
+            @values=@{ $env{$name} };
         } else {
-            $values[0]=$ENV{$name};
+            $values[0]=$env{$name};
         }
     }
     return(@values);
@@ -3183,25 +3187,25 @@
 =item * upfile_store($r)
 
 Store uploaded file, $r should be the HTTP Request object,
-needs $ENV{'form.upfile'}
+needs $env{'form.upfile'}
 returns $datatoken to be put into hidden field
 
 =cut
 
 sub upfile_store {
     my $r=shift;
-    $ENV{'form.upfile'}=~s/\r/\n/gs;
-    $ENV{'form.upfile'}=~s/\f/\n/gs;
-    $ENV{'form.upfile'}=~s/\n+/\n/gs;
-    $ENV{'form.upfile'}=~s/\n+$//gs;
+    $env{'form.upfile'}=~s/\r/\n/gs;
+    $env{'form.upfile'}=~s/\f/\n/gs;
+    $env{'form.upfile'}=~s/\n+/\n/gs;
+    $env{'form.upfile'}=~s/\n+$//gs;
 
-    my $datatoken=$ENV{'user.name'}.'_'.$ENV{'user.domain'}.
-	'_enroll_'.$ENV{'request.course.id'}.'_'.time.'_'.$$;
+    my $datatoken=$env{'user.name'}.'_'.$env{'user.domain'}.
+	'_enroll_'.$env{'request.course.id'}.'_'.time.'_'.$$;
     {
         my $datafile = $r->dir_config('lonDaemons').
                            '/tmp/'.$datatoken.'.tmp';
         if ( open(my $fh,">$datafile") ) {
-            print $fh $ENV{'form.upfile'};
+            print $fh $env{'form.upfile'};
             close($fh);
         }
     }
@@ -3213,8 +3217,8 @@
 =item * load_tmp_file($r)
 
 Load uploaded file from tmp, $r should be the HTTP Request object,
-needs $ENV{'form.datatoken'},
-sets $ENV{'form.upfile'} to the contents of the file
+needs $env{'form.datatoken'},
+sets $env{'form.upfile'} to the contents of the file
 
 =cut
 
@@ -3223,13 +3227,13 @@
     my @studentdata=();
     {
         my $studentfile = $r->dir_config('lonDaemons').
-                              '/tmp/'.$ENV{'form.datatoken'}.'.tmp';
+                              '/tmp/'.$env{'form.datatoken'}.'.tmp';
         if ( open(my $fh,"<$studentfile") ) {
             @studentdata=<$fh>;
             close($fh);
         }
     }
-    $ENV{'form.upfile'}=join('',@studentdata);
+    $env{'form.upfile'}=join('',@studentdata);
 }
 
 =pod
@@ -3238,15 +3242,15 @@
 
 Separate uploaded file into records
 returns array of records,
-needs $ENV{'form.upfile'} and $ENV{'form.upfiletype'}
+needs $env{'form.upfile'} and $env{'form.upfiletype'}
 
 =cut
 
 sub upfile_record_sep {
-    if ($ENV{'form.upfiletype'} eq 'xml') {
+    if ($env{'form.upfiletype'} eq 'xml') {
     } else {
 	my @records;
-	foreach my $line (split(/\n/,$ENV{'form.upfile'})) {
+	foreach my $line (split(/\n/,$env{'form.upfile'})) {
 	    if ($line=~/^\s*$/) { next; }
 	    push(@records,$line);
 	}
@@ -3258,15 +3262,15 @@
 
 =item * record_sep($record)
 
-Separate a record into fields $record should be an item from the upfile_record_sep(), needs $ENV{'form.upfiletype'}
+Separate a record into fields $record should be an item from the upfile_record_sep(), needs $env{'form.upfiletype'}
 
 =cut
 
 sub record_sep {
     my $record=shift;
     my %components=();
-    if ($ENV{'form.upfiletype'} eq 'xml') {
-    } elsif ($ENV{'form.upfiletype'} eq 'space') {
+    if ($env{'form.upfiletype'} eq 'xml') {
+    } elsif ($env{'form.upfiletype'} eq 'space') {
         my $i=0;
         foreach (split(/\s+/,$record)) {
             my $field=$_;
@@ -3275,7 +3279,7 @@
             $components{$i}=$field;
             $i++;
         }
-    } elsif ($ENV{'form.upfiletype'} eq 'tab') {
+    } elsif ($env{'form.upfiletype'} eq 'tab') {
         my $i=0;
         foreach (split(/\t/,$record)) {
             my $field=$_;
@@ -3966,34 +3970,34 @@
 sub store_course_settings {
     # save to the environment
     # appenv the same items, just to be safe
-    my $courseid = $ENV{'request.course.id'};
-    my $coursedom = $ENV{'course.'.$courseid.'.domain'};
+    my $courseid = $env{'request.course.id'};
+    my $coursedom = $env{'course.'.$courseid.'.domain'};
     my ($prefix,$Settings) = @_;
     my %SaveHash;
     my %AppHash;
     while (my ($setting,$type) = each(%$Settings)) {
         my $basename = 'internal.'.$prefix.'.'.$setting;
         my $envname = 'course.'.$courseid.'.'.$basename;
-        if (exists($ENV{'form.'.$setting})) {
+        if (exists($env{'form.'.$setting})) {
             # Save this value away
             if ($type eq 'scalar' &&
-                (! exists($ENV{$envname}) || 
-                 $ENV{$envname} ne $ENV{'form.'.$setting})) {
-                $SaveHash{$basename} = $ENV{'form.'.$setting};
-                $AppHash{$envname}   = $ENV{'form.'.$setting};
+                (! exists($env{$envname}) || 
+                 $env{$envname} ne $env{'form.'.$setting})) {
+                $SaveHash{$basename} = $env{'form.'.$setting};
+                $AppHash{$envname}   = $env{'form.'.$setting};
             } elsif ($type eq 'array') {
                 my $stored_form;
-                if (ref($ENV{'form.'.$setting})) {
+                if (ref($env{'form.'.$setting})) {
                     $stored_form = join(',',
                                         map {
                                             &Apache::lonnet::escape($_);
-                                        } sort(@{$ENV{'form.'.$setting}}));
+                                        } sort(@{$env{'form.'.$setting}}));
                 } else {
                     $stored_form = 
-                        &Apache::lonnet::escape($ENV{'form.'.$setting});
+                        &Apache::lonnet::escape($env{'form.'.$setting});
                 }
                 # Determine if the array contents are the same.
-                if ($stored_form ne $ENV{$envname}) {
+                if ($stored_form ne $env{$envname}) {
                     $SaveHash{$basename} = $stored_form;
                     $AppHash{$envname}   = $stored_form;
                 }
@@ -4002,7 +4006,7 @@
     }
     my $put_result = &Apache::lonnet::put('environment',\%SaveHash,
                                           $coursedom,
-                                          $ENV{'course.'.$courseid.'.num'});
+                                          $env{'course.'.$courseid.'.num'});
     if ($put_result !~ /^(ok|delayed)/) {
         &Apache::lonnet::logthis('unable to save form parameters, '.
                                  'got error:'.$put_result);
@@ -4013,20 +4017,20 @@
 }
 
 sub restore_course_settings {
-    my $courseid = $ENV{'request.course.id'};
+    my $courseid = $env{'request.course.id'};
     my ($prefix,$Settings) = @_;
     while (my ($setting,$type) = each(%$Settings)) {
-        next if (exists($ENV{'form.'.$setting}));
+        next if (exists($env{'form.'.$setting}));
         my $envname = 'course.'.$courseid.'.internal.'.$prefix.
             '.'.$setting;
-        if (exists($ENV{$envname})) {
+        if (exists($env{$envname})) {
             if ($type eq 'scalar') {
-                $ENV{'form.'.$setting} = $ENV{$envname};
+                $env{'form.'.$setting} = $env{$envname};
             } elsif ($type eq 'array') {
-                $ENV{'form.'.$setting} = [ 
+                $env{'form.'.$setting} = [ 
                                            map { 
                                                &Apache::lonnet::unescape($_); 
-                                           } split(',',$ENV{$envname})
+                                           } split(',',$env{$envname})
                                            ];
             }
         }
Index: loncom/interface/loncommunicate.pm
diff -u loncom/interface/loncommunicate.pm:1.27 loncom/interface/loncommunicate.pm:1.28
--- loncom/interface/loncommunicate.pm:1.27	Thu Feb 17 03:29:42 2005
+++ loncom/interface/loncommunicate.pm	Thu Apr  7 02:56:23 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Communicate
 #
-# $Id: loncommunicate.pm,v 1.27 2005/02/17 08:29:42 albertel Exp $
+# $Id: loncommunicate.pm,v 1.28 2005/04/07 06:56:23 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -34,6 +34,7 @@
 use Apache::lonmsg();
 use Apache::loncommon;
 use Apache::lonlocal;
+use Apache::lonnet;
 
 sub menu {
     my $r=shift;
@@ -65,8 +66,8 @@
   <b><a href="/adm/email?compose=individual">$lt{'smu'}</a></b>
 </td></tr>
 END
-    if (($ENV{'request.course.id'}) && 
-        (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) {
+    if (($env{'request.course.id'}) && 
+        (&Apache::lonnet::allowed('srm',$env{'request.course.id'}))) {
         $r->print(<<END);
 <tr><td bgcolor="#FFFFAA">
     <b><a href="/adm/email?compose=group">$lt{'bmc'}</a></b>$help{'Course_Broadcast_Message'}
Index: loncom/interface/loncoursedata.pm
diff -u loncom/interface/loncoursedata.pm:1.145 loncom/interface/loncoursedata.pm:1.146
--- loncom/interface/loncoursedata.pm:1.145	Mon Mar  7 15:12:08 2005
+++ loncom/interface/loncoursedata.pm	Thu Apr  7 02:56:23 2005
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: loncoursedata.pm,v 1.145 2005/03/07 20:12:08 matthew Exp $
+# $Id: loncoursedata.pm,v 1.146 2005/04/07 06:56:23 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -50,7 +50,7 @@
 
 use strict;
 use Apache::Constants qw(:common :http);
-use Apache::lonnet();
+use Apache::lonnet;
 use Apache::lonhtmlcommon;
 use Time::HiRes;
 use Apache::lonmysql;
@@ -71,8 +71,8 @@
     my %Discuss=();
     my %contrib=&Apache::lonnet::dump(
                 $courseID,
-                $ENV{'course.'.$courseID.'.domain'},
-                $ENV{'course.'.$courseID.'.num'});
+                $env{'course.'.$courseID.'.domain'},
+                $env{'course.'.$courseID.'.num'});
 				 
     #my %contrib=&DownloadCourseInformation($name, $courseID, 0);
 
@@ -645,7 +645,7 @@
 ################################################
 sub delete_caches {
     my $courseid = shift;
-    $courseid = $ENV{'request.course.id'} if (! defined($courseid));
+    $courseid = $env{'request.course.id'} if (! defined($courseid));
     #
     &setup_table_names($courseid);
     #
@@ -861,7 +861,7 @@
 sub populate_student_table {
     my ($courseid) = @_;
     if (! defined($courseid)) {
-        $courseid = $ENV{'request.course.id'};
+        $courseid = $env{'request.course.id'};
     }
     #
     &setup_table_names($courseid);
@@ -1351,7 +1351,7 @@
 ######################################
 sub ensure_tables_are_set_up {
     my ($courseid) = @_;
-    $courseid = $ENV{'request.course.id'} if (! defined($courseid));
+    $courseid = $env{'request.course.id'} if (! defined($courseid));
     # 
     # Clean out package variables
     &setup_table_names($courseid);
@@ -1408,7 +1408,7 @@
     my ($sname,$sdom,$courseid) = @_;
     my $status = 'okay';   # return value
     #
-    $courseid = $ENV{'request.course.id'} if (! defined($courseid));
+    $courseid = $env{'request.course.id'} if (! defined($courseid));
     &ensure_tables_are_set_up($courseid);
     #
     # Get the update time for the user
@@ -1457,7 +1457,7 @@
     my ($sname,$sdom,$courseid) = @_;
     my $status = 'okay';   # return value
     #
-    $courseid = $ENV{'request.course.id'} if (! defined($courseid));
+    $courseid = $env{'request.course.id'} if (! defined($courseid));
     &ensure_tables_are_set_up($courseid);
     #
     # Get the update time for the user
@@ -1633,7 +1633,7 @@
 sub get_current_state {
     my ($sname,$sdom,$symb,$courseid,$forcedownload)=@_;
     #
-    $courseid = $ENV{'request.course.id'} if (! defined($courseid));
+    $courseid = $env{'request.course.id'} if (! defined($courseid));
     #
     return () if (! defined($sname) || ! defined($sdom));
     #
@@ -1736,7 +1736,7 @@
 sub get_problem_statistics {
     my ($Sections,$status,$symb,$part,$courseid,$starttime,$endtime) = @_;
     return if (! defined($symb) || ! defined($part));
-    $courseid = $ENV{'request.course.id'} if (! defined($courseid));
+    $courseid = $env{'request.course.id'} if (! defined($courseid));
     #
     &setup_table_names($courseid);
     my $symb_id = &get_symb_id($symb);
@@ -1885,7 +1885,7 @@
 sub populate_weight_table {
     my ($courseid) = @_;
     if (! defined($courseid)) {
-        $courseid = $ENV{'request.course.id'};
+        $courseid = $env{'request.course.id'};
     }
     #
     &setup_table_names($courseid);
@@ -2035,7 +2035,7 @@
     my ($resources,$Sections,$enrollment,$courseid,$starttime,$endtime) = @_;
     return if (! defined($resources) || ! ref($resources) eq 'ARRAY');
     if (! defined($courseid)) {
-        $courseid = $ENV{'request.course.id'};
+        $courseid = $env{'request.course.id'};
     }
     #
     &setup_table_names($courseid);
@@ -2095,7 +2095,7 @@
 sub get_sum_of_scores {
     my ($symb,$part,$students,$courseid,$starttime,$endtime) = @_;
     if (! defined($courseid)) {
-        $courseid = $ENV{'request.course.id'};
+        $courseid = $env{'request.course.id'};
     }
     if (defined($students) && 
         ((@$students == 0) ||
@@ -2159,7 +2159,7 @@
 sub score_stats {
     my ($Sections,$enrollment,$symbs,$starttime,$endtime,$courseid)=@_;
     if (! defined($courseid)) {
-        $courseid = $ENV{'request.course.id'};
+        $courseid = $env{'request.course.id'};
     }
     #
     &setup_table_names($courseid);
@@ -2233,7 +2233,7 @@
 sub count_stats {
     my ($Sections,$enrollment,$symbs,$starttime,$endtime,$courseid)=@_;
     if (! defined($courseid)) {
-        $courseid = $ENV{'request.course.id'};
+        $courseid = $env{'request.course.id'};
     }
     #
     &setup_table_names($courseid);
@@ -2290,7 +2290,7 @@
 ######################################################
 sub get_student_data {
     my ($students,$courseid) = @_;
-    $courseid = $ENV{'request.course.id'} if (! defined($courseid));
+    $courseid = $env{'request.course.id'} if (! defined($courseid));
     &setup_table_names($courseid);
     my $dbh = &Apache::lonmysql::get_dbh();
     return undef if (! defined($dbh));
@@ -2331,7 +2331,7 @@
     my ($Sections,$enrollment,$symb,$response,$courseid) = @_;
     return undef if (! defined($symb) || 
                ! defined($response));
-    $courseid = $ENV{'request.course.id'} if (! defined($courseid));
+    $courseid = $env{'request.course.id'} if (! defined($courseid));
     #
     &setup_table_names($courseid);
     my $symb_id = &get_symb_id($symb);
@@ -2404,7 +2404,7 @@
     my ($student,$symb,$response,$courseid) = @_;
     return undef if (! defined($symb) || 
                      ! defined($response));
-    $courseid = $ENV{'request.course.id'} if (! defined($courseid));
+    $courseid = $env{'request.course.id'} if (! defined($courseid));
     #
     &setup_table_names($courseid);
     my $symb_id = &get_symb_id($symb);
@@ -2460,7 +2460,7 @@
     my ($sections,$enrollment,$symb,$part,$courseid) = @_;
     return undef if (! defined($symb) || 
                      ! defined($part));
-    $courseid = $ENV{'request.course.id'} if (! defined($courseid));
+    $courseid = $env{'request.course.id'} if (! defined($courseid));
     #
     &setup_table_names($courseid);
     my $symb_id = &get_symb_id($symb);
@@ -2527,7 +2527,7 @@
 ################################################
 sub get_student_scores {
     my ($sections,$Symbs,$enrollment,$courseid,$starttime,$endtime) = @_;
-    $courseid = $ENV{'request.course.id'} if (! defined($courseid));
+    $courseid = $env{'request.course.id'} if (! defined($courseid));
     &setup_table_names($courseid);
     my $dbh = &Apache::lonmysql::get_dbh();
     return (undef) if (! defined($dbh));
@@ -2617,7 +2617,7 @@
 sub setup_table_names {
     my ($courseid) = @_;
     if (! defined($courseid)) {
-        $courseid = $ENV{'request.course.id'};
+        $courseid = $env{'request.course.id'};
     }
     #
     if (! defined($current_course) || $current_course ne $courseid) {
@@ -2692,8 +2692,8 @@
 
 Optional arguments are $cid, $cdom, and $cnum (course id, course domain,
 and course number, respectively).  Any omitted arguments will be taken 
-from the current environment ($ENV{'request.course.id'},
-$ENV{'course.'.$cid.'.domain'}, and $ENV{'course.'.$cid.'.num'}).
+from the current environment ($env{'request.course.id'},
+$env{'course.'.$cid.'.domain'}, and $env{'course.'.$cid.'.num'}).
 
 Returns a reference to a hash which contains:
  keys    '$sname:$sdom'
@@ -2721,9 +2721,9 @@
 
 sub get_classlist {
     my ($cid,$cdom,$cnum) = @_;
-    $cid = $cid || $ENV{'request.course.id'};
-    $cdom = $cdom || $ENV{'course.'.$cid.'.domain'};
-    $cnum = $cnum || $ENV{'course.'.$cid.'.num'};
+    $cid = $cid || $env{'request.course.id'};
+    $cdom = $cdom || $env{'course.'.$cid.'.domain'};
+    $cnum = $cnum || $env{'course.'.$cid.'.num'};
     my $now = time;
     #
     my %classlist=&Apache::lonnet::dump('classlist',$cdom,$cnum);
Index: loncom/interface/loncreatecourse.pm
diff -u loncom/interface/loncreatecourse.pm:1.77 loncom/interface/loncreatecourse.pm:1.78
--- loncom/interface/loncreatecourse.pm:1.77	Thu Mar  3 16:24:24 2005
+++ loncom/interface/loncreatecourse.pm	Thu Apr  7 02:56:23 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Create a course
 #
-# $Id: loncreatecourse.pm,v 1.77 2005/03/03 21:24:24 raeburn Exp $
+# $Id: loncreatecourse.pm,v 1.78 2005/04/07 06:56:23 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -86,7 +86,7 @@
 # ============================================================ Write a userfile
 
 sub writefile {
-    (my $courseid, my $which,$ENV{'form.output'})=@_;
+    (my $courseid, my $which,$env{'form.output'})=@_;
     my %crsdata=&Apache::lonnet::coursedescription($courseid);
     return &Apache::lonnet::finishuserfileupload(
 					  $crsdata{'num'},$crsdata{'domain'},
@@ -238,7 +238,7 @@
 
 sub print_course_creation_page {
     my $r=shift;
-    my $defdom=$ENV{'request.role.domain'};
+    my $defdom=$env{'request.role.domain'};
     my %host_servers = &Apache::loncommon::get_library_servers($defdom);
     my $course_home = '<select name="course_home" size="1">'."\n";
     foreach my $server (sort(keys(%host_servers))) {
@@ -253,10 +253,10 @@
     my $bodytag=&Apache::loncommon::bodytag('Create a New Course');
     my $helplink=&Apache::loncommon::help_open_topic('Create_Course',&mt('Help on Creating Courses'));
     my $cloneform=&Apache::loncommon::select_dom_form
-	($ENV{'request.role.domain'},'clonedomain').
+	($env{'request.role.domain'},'clonedomain').
 		     &Apache::loncommon::selectcourse_link
 		     ('ccrs','clonecourse','clonedomain');
-    my $coursebrowserjs=&Apache::loncommon::coursebrowser_javascript($ENV{'request.role.domain'});
+    my $coursebrowserjs=&Apache::loncommon::coursebrowser_javascript($env{'request.role.domain'});
     my $starttime = time;
     my $endtime = time+(6*30*24*60*60); # 6 months from now, approx
     my $enroll_table = &Apache::londropadd::date_setting_table($starttime,$endtime,'create_enrolldates');
@@ -572,8 +572,8 @@
 
 sub create_course {
     my $r=shift;
-    my $ccuname=$ENV{'form.ccuname'};
-    my $ccdomain=$ENV{'form.ccdomain'};
+    my $ccuname=$env{'form.ccuname'};
+    my $ccdomain=$env{'form.ccdomain'};
     $ccuname=~s/\W//g;
     $ccdomain=~s/\W//g;
 
@@ -585,19 +585,19 @@
     my $autharg;
     my $authtype;
 
-    if ($ENV{'form.login'} eq 'krb') {
+    if ($env{'form.login'} eq 'krb') {
         $authtype = 'krb';
-        $authtype .=$ENV{'form.krbver'};
-        $autharg = $ENV{'form.krbarg'};
-    } elsif ($ENV{'form.login'} eq 'int') {
+        $authtype .=$env{'form.krbver'};
+        $autharg = $env{'form.krbarg'};
+    } elsif ($env{'form.login'} eq 'int') {
         $authtype ='internal';
-        if ((defined($ENV{'form.intarg'})) && ($ENV{'form.intarg'})) {
-            $autharg = $ENV{'form.intarg'};
+        if ((defined($env{'form.intarg'})) && ($env{'form.intarg'})) {
+            $autharg = $env{'form.intarg'};
         }
-    } elsif ($ENV{'form.login'} eq 'loc') {
+    } elsif ($env{'form.login'} eq 'loc') {
         $authtype = 'localauth';
-        if ((defined($ENV{'form.locarg'})) && ($ENV{'form.locarg'})) {
-            $autharg = $ENV{'form.locarg'};
+        if ((defined($env{'form.locarg'})) && ($env{'form.locarg'})) {
+            $autharg = $env{'form.locarg'};
         }
     }
 
@@ -615,39 +615,39 @@
     my $args = {
                ccuname => $ccuname,
                ccdomain => $ccdomain,
-               cdescr => $ENV{'form.title'},
-               curl => $ENV{'form.topmap'},
-               course_domain => $ENV{'request.role.domain'},
-               course_home =>  $ENV{'form.course_home'},
-               nonstandard => $ENV{'form.nonstandard'},
-               crscode => $ENV{'form.crscode'},
-               clonecourse => $ENV{'form.clonecourse'},
-               clonedomain => $ENV{'form.clonedomain'},
-               crsid => $ENV{'form.crsid'},
-               curruser => $ENV{'user.name'},
-               crssections => $ENV{'form.crssections'},
-               crsxlist => $ENV{'form.crsxlist'},
-               autoadds => $ENV{'form.autoadds'},
-               autodrops => $ENV{'form.autodrops'},
-               notify_owner => $ENV{'form.notify_owner'},
-               notify_dc => $ENV{'form.notify_dc'},
-               no_end_date => $ENV{'form.no_end_date'},
-               showphotos => $ENV{'form.showphotos'},
+               cdescr => $env{'form.title'},
+               curl => $env{'form.topmap'},
+               course_domain => $env{'request.role.domain'},
+               course_home =>  $env{'form.course_home'},
+               nonstandard => $env{'form.nonstandard'},
+               crscode => $env{'form.crscode'},
+               clonecourse => $env{'form.clonecourse'},
+               clonedomain => $env{'form.clonedomain'},
+               crsid => $env{'form.crsid'},
+               curruser => $env{'user.name'},
+               crssections => $env{'form.crssections'},
+               crsxlist => $env{'form.crsxlist'},
+               autoadds => $env{'form.autoadds'},
+               autodrops => $env{'form.autodrops'},
+               notify_owner => $env{'form.notify_owner'},
+               notify_dc => $env{'form.notify_dc'},
+               no_end_date => $env{'form.no_end_date'},
+               showphotos => $env{'form.showphotos'},
                authtype => $authtype,
                autharg => $autharg,
                enrollstart => $enrollstart,
                enrollend => $enrollend,
                startaccess => $startaccess,
                endaccess => $endaccess,
-               setpolicy => $ENV{'form.setpolicy'},
-               setcontent => $ENV{'form.setcontent'},
-               reshome => $ENV{'form.reshome'},
-               setkeys => $ENV{'form.setkeys'},
-               keyauth => $ENV{'form.keyauth'},
-               disresdis => $ENV{'form.disresdis'},
-               disablechat => $ENV{'form.disablechat'},
-               openall => $ENV{'form.openall'},
-               firstres => $ENV{'form.firstres'}
+               setpolicy => $env{'form.setpolicy'},
+               setcontent => $env{'form.setcontent'},
+               reshome => $env{'form.reshome'},
+               setkeys => $env{'form.setkeys'},
+               keyauth => $env{'form.keyauth'},
+               disresdis => $env{'form.disresdis'},
+               disablechat => $env{'form.disablechat'},
+               openall => $env{'form.openall'},
+               firstres => $env{'form.firstres'}
                };
 
     #
@@ -669,14 +669,14 @@
     }
     # Check the proposed home server for the course
     my %host_servers = &Apache::loncommon::get_library_servers
-        ($ENV{'request.role.domain'});
-    if (! exists($host_servers{$ENV{'form.course_home'}})) {
+        ($env{'request.role.domain'});
+    if (! exists($host_servers{$env{'form.course_home'}})) {
         $r->print(&mt('Invalid home server for course').': '.
-                  $ENV{'form.course_home'}.'</body></html>');
+                  $env{'form.course_home'}.'</body></html>');
         return;
     }
     my ($courseid,$crsudom,$crsunum);
-    $r->print(&construct_course($args,\$logmsg,\$courseid,\$crsudom,\$crsunum,$ENV{'user.domain'},$ENV{'user.name'}));
+    $r->print(&construct_course($args,\$logmsg,\$courseid,\$crsudom,\$crsunum,$env{'user.domain'},$env{'user.name'}));
 
 #
 # Make the requested user a course coordinator
@@ -686,7 +686,7 @@
                $ccuname.' at '.$ccdomain.': '.
     &Apache::lonnet::assignrole($ccdomain,$ccuname,$courseid,'cc').'<p>');
    }
-    if ($ENV{'form.setkeys'}) {
+    if ($env{'form.setkeys'}) {
         $r->print(
  '<p><a href="/adm/managekeys?cid='.$crsudom.'_'.$crsunum.'">'.&mt('Manage Access Keys').'</a></p>');
     }
@@ -970,17 +970,17 @@
        return OK;
     }
 
-    if (&Apache::lonnet::allowed('ccc',$ENV{'request.role.domain'})) {
+    if (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) {
        &Apache::loncommon::content_type($r,'text/html');
        $r->send_http_header;
 
-       if ($ENV{'form.phase'} eq 'two') {
+       if ($env{'form.phase'} eq 'two') {
            &create_course($r);
        } else {
 	   &print_course_creation_page($r);
        }
    } else {
-      $ENV{'user.error.msg'}=
+      $env{'user.error.msg'}=
         "/adm/createcourse:ccc:0:0:Cannot create courses";
       return HTTP_NOT_ACCEPTABLE; 
    }
Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.100 loncom/interface/loncreateuser.pm:1.101
--- loncom/interface/loncreateuser.pm:1.100	Thu Feb 17 03:29:42 2005
+++ loncom/interface/loncreateuser.pm	Thu Apr  7 02:56:23 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Create a user
 #
-# $Id: loncreateuser.pm,v 1.100 2005/02/17 08:29:42 albertel Exp $
+# $Id: loncreateuser.pm,v 1.101 2005/04/07 06:56:23 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -108,9 +108,9 @@
 
 sub authorpriv {
     my ($auname,$audom)=@_;
-    if (($auname ne $ENV{'user.name'}) ||
-        (($audom ne $ENV{'user.domain'}) &&
-         ($audom ne $ENV{'request.role.domain'}))) { return ''; }
+    if (($auname ne $env{'user.name'}) ||
+        (($audom ne $env{'user.domain'}) &&
+         ($audom ne $env{'request.role.domain'}))) { return ''; }
     unless (&Apache::lonnet::allowed('cca',$audom)) { return ''; }
     return 1;
 }
@@ -119,7 +119,7 @@
 
 sub print_username_entry_form {
     my $r=shift;
-    my $defdom=$ENV{'request.role.domain'};
+    my $defdom=$env{'request.role.domain'};
     my @domains = &Apache::loncommon::get_domains();
     my $domform = &Apache::loncommon::select_dom_form($defdom,'ccdomain');
     my $html=&Apache::lonxml::xmlbegin();
@@ -171,8 +171,8 @@
 # =================================================================== Phase two
 sub print_user_modification_page {
     my $r=shift;
-    my $ccuname=$ENV{'form.ccuname'};
-    my $ccdomain=$ENV{'form.ccdomain'};
+    my $ccuname=$env{'form.ccuname'};
+    my $ccdomain=$env{'form.ccdomain'};
 
     $ccuname=~s/\W//g;
     $ccdomain=~s/\W//g;
@@ -182,7 +182,7 @@
         return;
     }
 
-    my $defdom=$ENV{'request.role.domain'};
+    my $defdom=$env{'request.role.domain'};
 
     my ($krbdef,$krbdefdom) =
        &Apache::loncommon::get_kerberos_defaults($defdom);
@@ -199,7 +199,7 @@
     my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
     my $dc_setcourse_code = '';
     my $loaditem;
-    if ($ENV{'request.role'} =~ m-^dc\./(\w+)/$-) {
+    if ($env{'request.role'} =~ m-^dc\./(\w+)/$-) {
         my $dcdom = $1;
         $loaditem = qq|OnLoad="document.cu.coursedesc.value=''"|;
         $dc_setcourse_code = <<"ENDSCRIPT";
@@ -374,7 +374,7 @@
     foreach (values(%Apache::lonnet::hostdom)) {
        $incdomains{$_}=1;
     }
-    foreach (keys(%ENV)) {
+    foreach (keys(%env)) {
 	if ($_=~/^user\.priv\.cm\.\/(\w+)\/(\w+)/) {
 	    $inccourses{$1.'_'.$2}=1;
         }
@@ -675,7 +675,7 @@
 		$currentauth=~/^internal:/ or
 		$currentauth=~/^localauth:/
 		) { # bad authentication scheme
-	    if (&Apache::lonnet::allowed('mau',$ENV{'request.role.domain'})) {
+	    if (&Apache::lonnet::allowed('mau',$env{'request.role.domain'})) {
                 &initialize_authen_forms();
 		my %lt=&Apache::lonlocal::texthash(
                                'err'   => "ERROR",
@@ -740,7 +740,7 @@
                     "<p>$authformint</p><p>$authformfsys</p>";
 	    }
             $authformcurrent.=' <i>(will override current values)</i><br />';
-            if (&Apache::lonnet::allowed('mau',$ENV{'request.role.domain'})) {
+            if (&Apache::lonnet::allowed('mau',$env{'request.role.domain'})) {
 		# Current user has login modification privileges
 		my %lt=&Apache::lonlocal::texthash(
                                'ccld'  => "Change Current Login Data",
@@ -765,11 +765,11 @@
 #
 # Co-Author
 # 
-    if (&authorpriv($ENV{'user.name'},$ENV{'request.role.domain'}) &&
-        ($ENV{'user.name'} ne $ccuname || $ENV{'user.domain'} ne $ccdomain)) {
+    if (&authorpriv($env{'user.name'},$env{'request.role.domain'}) &&
+        ($env{'user.name'} ne $ccuname || $env{'user.domain'} ne $ccdomain)) {
         # No sense in assigning co-author role to yourself
-	my $cuname=$ENV{'user.name'};
-        my $cudom=$ENV{'request.role.domain'};
+	my $cuname=$env{'user.name'};
+        my $cudom=$env{'request.role.domain'};
 	   my %lt=&Apache::lonlocal::texthash(
 		    'cs'   => "Construction Space",
                     'act'  => "Activate",                    
@@ -842,7 +842,7 @@
 #
     my $num_sections;
 
-    if ($ENV{'request.role'} =~ m-^dc\./(\w+)/$-) {
+    if ($env{'request.role'} =~ m-^dc\./(\w+)/$-) {
         $r->print(&course_level_dc($1));
         $r->print('<hr /><input type="button" value="'.&mt('Modify User').'" onClick="setCourse()">'."\n");
     } else {
@@ -855,8 +855,8 @@
 # ================================================================= Phase Three
 sub update_user_data {
     my $r=shift;
-    my $uhome=&Apache::lonnet::homeserver($ENV{'form.ccuname'},
-                                          $ENV{'form.ccdomain'});
+    my $uhome=&Apache::lonnet::homeserver($env{'form.ccuname'},
+                                          $env{'form.ccdomain'});
     # Error messages
     my $error     = '<font color="#ff0000">'.&mt('Error').':</font>';
     my $end       = '</body></html>';
@@ -869,61 +869,61 @@
 </head>
 ENDTHREEHEAD
     my $title;
-    if (exists($ENV{'form.makeuser'})) {
+    if (exists($env{'form.makeuser'})) {
 	$title='Set Privileges for New User';
     } else {
         $title='Modify User Privileges';
     }
     $r->print(&Apache::loncommon::bodytag($title));
     # Check Inputs
-    if (! $ENV{'form.ccuname'} ) {
+    if (! $env{'form.ccuname'} ) {
 	$r->print($error.&mt('No login name specified').'.'.$end);
 	return;
     }
-    if (  $ENV{'form.ccuname'}  =~/\W/) {
+    if (  $env{'form.ccuname'}  =~/\W/) {
 	$r->print($error.&mt('Invalid login name').'.  '.
 		  &mt('Only letters, numbers, and underscores are valid').'.'.
 		  $end);
 	return;
     }
-    if (! $ENV{'form.ccdomain'}       ) {
+    if (! $env{'form.ccdomain'}       ) {
 	$r->print($error.&mt('No domain specified').'.'.$end);
 	return;
     }
-    if (  $ENV{'form.ccdomain'} =~/\W/) {
+    if (  $env{'form.ccdomain'} =~/\W/) {
 	$r->print($error.&mt ('Invalid domain name').'.  '.
 		  &mt('Only letters, numbers, and underscores are valid').'.'.
 		  $end);
 	return;
     }
-    if (! exists($ENV{'form.makeuser'})) {
+    if (! exists($env{'form.makeuser'})) {
         # Modifying an existing user, so check the validity of the name
         if ($uhome eq 'no_host') {
             $r->print($error.&mt('Unable to determine home server for ').
-                      $ENV{'form.ccuname'}.&mt(' in domain ').
-                      $ENV{'form.ccdomain'}.'.');
+                      $env{'form.ccuname'}.&mt(' in domain ').
+                      $env{'form.ccdomain'}.'.');
             return;
         }
     }
     # Determine authentication method and password for the user being modified
     my $amode='';
     my $genpwd='';
-    if ($ENV{'form.login'} eq 'krb') {
+    if ($env{'form.login'} eq 'krb') {
 	$amode='krb';
-	$amode.=$ENV{'form.krbver'};
-	$genpwd=$ENV{'form.krbarg'};
-    } elsif ($ENV{'form.login'} eq 'int') {
+	$amode.=$env{'form.krbver'};
+	$genpwd=$env{'form.krbarg'};
+    } elsif ($env{'form.login'} eq 'int') {
 	$amode='internal';
-	$genpwd=$ENV{'form.intarg'};
-    } elsif ($ENV{'form.login'} eq 'fsys') {
+	$genpwd=$env{'form.intarg'};
+    } elsif ($env{'form.login'} eq 'fsys') {
 	$amode='unix';
-	$genpwd=$ENV{'form.fsysarg'};
-    } elsif ($ENV{'form.login'} eq 'loc') {
+	$genpwd=$env{'form.fsysarg'};
+    } elsif ($env{'form.login'} eq 'loc') {
 	$amode='localauth';
-	$genpwd=$ENV{'form.locarg'};
+	$genpwd=$env{'form.locarg'};
 	$genpwd=" " if (!$genpwd);
-    } elsif (($ENV{'form.login'} eq 'nochange') ||
-             ($ENV{'form.login'} eq ''        )) { 
+    } elsif (($env{'form.login'} eq 'nochange') ||
+             ($env{'form.login'} eq ''        )) { 
         # There is no need to tell the user we did not change what they
         # did not ask us to change.
         # If they are creating a new user but have not specified login
@@ -932,14 +932,14 @@
 	    $r->print($error.&mt('Invalid login mode or password').$end);    
 	    return;
     }
-    if ($ENV{'form.makeuser'}) {
+    if ($env{'form.makeuser'}) {
         # Create a new user
 	my %lt=&Apache::lonlocal::texthash(
                     'cru'  => "Creating user",                    
                     'id'   => "in domain"
 					   );
 	$r->print(<<ENDNEWUSERHEAD);
-<h3>$lt{'cru'} "$ENV{'form.ccuname'}" $lt{'id'} "$ENV{'form.ccdomain'}"</h3>
+<h3>$lt{'cru'} "$env{'form.ccuname'}" $lt{'id'} "$env{'form.ccdomain'}"</h3>
 ENDNEWUSERHEAD
         # Check for the authentication mode and password
         if (! $amode || ! $genpwd) {
@@ -947,12 +947,12 @@
 	    return;
 	}
         # Determine desired host
-        my $desiredhost = $ENV{'form.hserver'};
+        my $desiredhost = $env{'form.hserver'};
         if (lc($desiredhost) eq 'default') {
             $desiredhost = undef;
         } else {
             my %home_servers = &Apache::loncommon::get_library_servers
-                ($ENV{'form.ccdomain'});  
+                ($env{'form.ccdomain'});  
             if (! exists($home_servers{$desiredhost})) {
                 $r->print($error.&mt('Invalid home server specified'));
                 return;
@@ -960,49 +960,49 @@
         }
 	# Call modifyuser
 	my $result = &Apache::lonnet::modifyuser
-	    ($ENV{'form.ccdomain'},$ENV{'form.ccuname'},$ENV{'form.cstid'},
-             $amode,$genpwd,$ENV{'form.cfirst'},
-             $ENV{'form.cmiddle'},$ENV{'form.clast'},$ENV{'form.cgen'},
+	    ($env{'form.ccdomain'},$env{'form.ccuname'},$env{'form.cstid'},
+             $amode,$genpwd,$env{'form.cfirst'},
+             $env{'form.cmiddle'},$env{'form.clast'},$env{'form.cgen'},
              undef,$desiredhost
 	     );
 	$r->print(&mt('Generating user').': '.$result);
-        my $home = &Apache::lonnet::homeserver($ENV{'form.ccuname'},
-                                               $ENV{'form.ccdomain'});
+        my $home = &Apache::lonnet::homeserver($env{'form.ccuname'},
+                                               $env{'form.ccdomain'});
         $r->print('<br />'.&mt('Home server').': '.$home.' '.
                   $Apache::lonnet::libserv{$home});
-    } elsif (($ENV{'form.login'} ne 'nochange') &&
-             ($ENV{'form.login'} ne ''        )) {
+    } elsif (($env{'form.login'} ne 'nochange') &&
+             ($env{'form.login'} ne ''        )) {
 	# Modify user privileges
     my %lt=&Apache::lonlocal::texthash(
                     'usr'  => "User",                    
                     'id'   => "in domain"
 				       );
 	$r->print(<<ENDMODIFYUSERHEAD);
-<h2>$lt{'usr'} "$ENV{'form.ccuname'}" $lt{'id'} "$ENV{'form.ccdomain'}"</h2>
+<h2>$lt{'usr'} "$env{'form.ccuname'}" $lt{'id'} "$env{'form.ccdomain'}"</h2>
 ENDMODIFYUSERHEAD
         if (! $amode || ! $genpwd) {
 	    $r->print($error.'Invalid login mode or password'.$end);    
 	    return;
 	}
 	# Only allow authentification modification if the person has authority
-	if (&Apache::lonnet::allowed('mau',$ENV{'form.ccdomain'})) {
+	if (&Apache::lonnet::allowed('mau',$env{'form.ccdomain'})) {
 	    $r->print('Modifying authentication: '.
                       &Apache::lonnet::modifyuserauth(
-		       $ENV{'form.ccdomain'},$ENV{'form.ccuname'},
+		       $env{'form.ccdomain'},$env{'form.ccuname'},
                        $amode,$genpwd));
             $r->print('<br>'.&mt('Home server').': '.&Apache::lonnet::homeserver
-		  ($ENV{'form.ccuname'},$ENV{'form.ccdomain'}));
+		  ($env{'form.ccuname'},$env{'form.ccdomain'}));
 	} else {
 	    # Okay, this is a non-fatal error.
 	    $r->print($error.&mt('You do not have the authority to modify this users authentification information').'.');    
 	}
     }
     ##
-    if (! $ENV{'form.makeuser'} ) {
+    if (! $env{'form.makeuser'} ) {
         # Check for need to change
         my %userenv = &Apache::lonnet::get
             ('environment',['firstname','middlename','lastname','generation'],
-             $ENV{'form.ccdomain'},$ENV{'form.ccuname'});
+             $env{'form.ccdomain'},$env{'form.ccuname'});
         my ($tmp) = keys(%userenv);
         if ($tmp =~ /^(con_lost|error)/i) { 
             %userenv = ();
@@ -1010,22 +1010,22 @@
         # Check to see if we need to change user information
         foreach ('firstname','middlename','lastname','generation') {
             # Strip leading and trailing whitespace
-            $ENV{'form.c'.$_} =~ s/(\s+$|^\s+)//g; 
+            $env{'form.c'.$_} =~ s/(\s+$|^\s+)//g; 
         }
-        if (&Apache::lonnet::allowed('mau',$ENV{'form.ccdomain'}) && 
-            ($ENV{'form.cfirstname'}  ne $userenv{'firstname'}  ||
-             $ENV{'form.cmiddlename'} ne $userenv{'middlename'} ||
-             $ENV{'form.clastname'}   ne $userenv{'lastname'}   ||
-             $ENV{'form.cgeneration'} ne $userenv{'generation'} )) {
+        if (&Apache::lonnet::allowed('mau',$env{'form.ccdomain'}) && 
+            ($env{'form.cfirstname'}  ne $userenv{'firstname'}  ||
+             $env{'form.cmiddlename'} ne $userenv{'middlename'} ||
+             $env{'form.clastname'}   ne $userenv{'lastname'}   ||
+             $env{'form.cgeneration'} ne $userenv{'generation'} )) {
             # Make the change
             my %changeHash;
-            $changeHash{'firstname'}  = $ENV{'form.cfirstname'};
-            $changeHash{'middlename'} = $ENV{'form.cmiddlename'};
-            $changeHash{'lastname'}   = $ENV{'form.clastname'};
-            $changeHash{'generation'} = $ENV{'form.cgeneration'};
+            $changeHash{'firstname'}  = $env{'form.cfirstname'};
+            $changeHash{'middlename'} = $env{'form.cmiddlename'};
+            $changeHash{'lastname'}   = $env{'form.clastname'};
+            $changeHash{'generation'} = $env{'form.cgeneration'};
             my $putresult = &Apache::lonnet::put
                 ('environment',\%changeHash,
-                 $ENV{'form.ccdomain'},$ENV{'form.ccuname'});
+                 $env{'form.ccdomain'},$env{'form.ccuname'});
             if ($putresult eq 'ok') {
             # Tell the user we changed the name
 		my %lt=&Apache::lonlocal::texthash(
@@ -1051,18 +1051,18 @@
     <td>$userenv{'lastname'}   </td>
     <td>$userenv{'generation'} </td></tr>
 <tr><td>$lt{'chto'}</td>
-    <td>$ENV{'form.cfirstname'}  </td>
-    <td>$ENV{'form.cmiddlename'} </td>
-    <td>$ENV{'form.clastname'}   </td>
-    <td>$ENV{'form.cgeneration'} </td></tr>
+    <td>$env{'form.cfirstname'}  </td>
+    <td>$env{'form.cmiddlename'} </td>
+    <td>$env{'form.clastname'}   </td>
+    <td>$env{'form.cgeneration'} </td></tr>
 </table>
 END
             } else { # error occurred
                 $r->print("<h2>".&mt('Unable to successfully change environment for')." ".
-                      $ENV{'form.ccuname'}." ".&mt('in domain')." ".
-                      $ENV{'form.ccdomain'}."</h2>");
+                      $env{'form.ccuname'}." ".&mt('in domain')." ".
+                      $env{'form.ccdomain'}."</h2>");
             }
-        }  else { # End of if ($ENV ... ) logic
+        }  else { # End of if ($env ... ) logic
             # They did not want to change the users name but we can
             # still tell them what the name is
 	    my %lt=&Apache::lonlocal::texthash(
@@ -1071,7 +1071,7 @@
                            'gen'  => "Generation"
 					       );
                 $r->print(<<"END");
-<h2>$lt{'usr'} "$ENV{'form.ccuname'}" $lt{'id'} "$ENV{'form.ccdomain'}"</h2>
+<h2>$lt{'usr'} "$env{'form.ccuname'}" $lt{'id'} "$env{'form.ccdomain'}"</h2>
 <h4>$userenv{'firstname'} $userenv{'middlename'} $userenv{'lastname'} </h4>
 <h4>$lt{'gen'}: $userenv{'generation'}</h4>
 END
@@ -1080,57 +1080,57 @@
     ##
     my $now=time;
     $r->print('<h3>'.&mt('Modifying Roles').'</h3>');
-    foreach (keys (%ENV)) {
-	next if (! $ENV{$_});
+    foreach (keys (%env)) {
+	next if (! $env{$_});
 	# Revoke roles
 	if ($_=~/^form\.rev/) {
 	    if ($_=~/^form\.rev\:([^\_]+)\_([^\_\.]+)$/) {
 # Revoke standard role
 	        $r->print(&mt('Revoking').' '.$2.' in '.$1.': <b>'.
-                     &Apache::lonnet::revokerole($ENV{'form.ccdomain'},
-                     $ENV{'form.ccuname'},$1,$2).'</b><br>');
+                     &Apache::lonnet::revokerole($env{'form.ccdomain'},
+                     $env{'form.ccuname'},$1,$2).'</b><br>');
 		if ($2 eq 'st') {
 		    $1=~/^\/(\w+)\/(\w+)/;
 		    my $cid=$1.'_'.$2;
 		    $r->print(&mt('Drop from classlist').': <b>'.
 			 &Apache::lonnet::critical('put:'.
-                             $ENV{'course.'.$cid.'.domain'}.':'.
-	                     $ENV{'course.'.$cid.'.num'}.':classlist:'.
-                         &Apache::lonnet::escape($ENV{'form.ccuname'}.':'.
-                             $ENV{'form.ccdomain'}).'='.
+                             $env{'course.'.$cid.'.domain'}.':'.
+	                     $env{'course.'.$cid.'.num'}.':classlist:'.
+                         &Apache::lonnet::escape($env{'form.ccuname'}.':'.
+                             $env{'form.ccdomain'}).'='.
                          &Apache::lonnet::escape($now.':'),
-	                     $ENV{'course.'.$cid.'.home'}).'</b><br>');
+	                     $env{'course.'.$cid.'.home'}).'</b><br>');
 		}
 	    } 
 	    if ($_=~/^form\.rev\:([^\_]+)\_cr\.cr\/(\w+)\/(\w+)\/(\w+)$/) {
 # Revoke custom role
 		$r->print(&mt('Revoking custom role').
                       ' '.$4.' by '.$3.'@'.$2.' in '.$1.': <b>'.
-                      &Apache::lonnet::revokecustomrole($ENV{'form.ccdomain'},
-				  $ENV{'form.ccuname'},$1,$2,$3,$4).
+                      &Apache::lonnet::revokecustomrole($env{'form.ccdomain'},
+				  $env{'form.ccuname'},$1,$2,$3,$4).
 		'</b><br>');
 	    }
 	} elsif ($_=~/^form\.del/) {
 	    if ($_=~/^form\.del\:([^\_]+)\_([^\_]+)$/) {
 	        $r->print(&mt('Deleting').' '.$2.' in '.$1.': '.
-                     &Apache::lonnet::assignrole($ENV{'form.ccdomain'},
-                     $ENV{'form.ccuname'},$1,$2,$now,0,1).'<br>');
+                     &Apache::lonnet::assignrole($env{'form.ccdomain'},
+                     $env{'form.ccuname'},$1,$2,$now,0,1).'<br>');
 		if ($2 eq 'st') {
 		    $1=~/^\/(\w+)\/(\w+)/;
 		    my $cid=$1.'_'.$2;
 		    $r->print(&mt('Drop from classlist').': <b>'.
 			 &Apache::lonnet::critical('put:'.
-                             $ENV{'course.'.$cid.'.domain'}.':'.
-	                     $ENV{'course.'.$cid.'.num'}.':classlist:'.
-                         &Apache::lonnet::escape($ENV{'form.ccuname'}.':'.
-                             $ENV{'form.ccdomain'}).'='.
+                             $env{'course.'.$cid.'.domain'}.':'.
+	                     $env{'course.'.$cid.'.num'}.':classlist:'.
+                         &Apache::lonnet::escape($env{'form.ccuname'}.':'.
+                             $env{'form.ccdomain'}).'='.
                          &Apache::lonnet::escape($now.':'),
-	                     $ENV{'course.'.$cid.'.home'}).'</b><br>');
+	                     $env{'course.'.$cid.'.home'}).'</b><br>');
 		}
 	    } 
 	} elsif ($_=~/^form\.ren/) {
-            my $udom = $ENV{'form.ccdomain'};
-            my $uname = $ENV{'form.ccuname'};
+            my $udom = $env{'form.ccdomain'};
+            my $uname = $env{'form.ccuname'};
 	    if ($_=~/^form\.ren\:([^\_]+)\_([^\_]+)$/) {
                 my $url = $1;
                 my $role = $2;
@@ -1149,32 +1149,32 @@
                         }
                     }
                 } else {
-		    my $result=&Apache::lonnet::assignrole($ENV{'form.ccdomain'},
-                               $ENV{'form.ccuname'},$url,$role,0,$now);
+		    my $result=&Apache::lonnet::assignrole($env{'form.ccdomain'},
+                               $env{'form.ccuname'},$url,$role,0,$now);
 		    $output = &mt('Re-Enabling [_1] in [_2]: [_3]',
 			      $role,$url,$result).'<br />';
 		}
                 $r->print($output);
 	    } 
 	} elsif ($_=~/^form\.act/) {
-            my $udom = $ENV{'form.ccdomain'};
-            my $uname = $ENV{'form.ccuname'};
+            my $udom = $env{'form.ccdomain'};
+            my $uname = $env{'form.ccuname'};
 	    if ($_=~/^form\.act\_([^\_]+)\_([^\_]+)\_cr_cr_([^\_]+)_(\w+)_([^\_]+)$/) {
                 # Activate a custom role
 		my ($one,$two,$three,$four,$five)=($1,$2,$3,$4,$5);
 		my $url='/'.$one.'/'.$two;
 		my $full=$one.'_'.$two.'_cr_cr_'.$three.'_'.$four.'_'.$five;
 
-                my $start = ( $ENV{'form.start_'.$full} ?
-                              $ENV{'form.start_'.$full} :
+                my $start = ( $env{'form.start_'.$full} ?
+                              $env{'form.start_'.$full} :
                               $now );
-                my $end   = ( $ENV{'form.end_'.$full} ?
-                              $ENV{'form.end_'.$full} :
+                my $end   = ( $env{'form.end_'.$full} ?
+                              $env{'form.end_'.$full} :
                               0 );
                                                                                      
                 # split multiple sections
                 my %sections = ();
-                my $num_sections = &build_roles($ENV{'form.sec_'.$full},\%sections,$5);
+                my $num_sections = &build_roles($env{'form.sec_'.$full},\%sections,$5);
                 if ($num_sections == 0) {
                     $r->print(&commit_customrole($udom,$uname,$url,$three,$four,$five,$start,$end));
                 } else {
@@ -1187,17 +1187,17 @@
 		# Activate roles for sections with 3 id numbers
 		# set start, end times, and the url for the class
 		my ($one,$two,$three)=($1,$2,$3);
-		my $start = ( $ENV{'form.start_'.$one.'_'.$two.'_'.$three} ? 
-			      $ENV{'form.start_'.$one.'_'.$two.'_'.$three} : 
+		my $start = ( $env{'form.start_'.$one.'_'.$two.'_'.$three} ? 
+			      $env{'form.start_'.$one.'_'.$two.'_'.$three} : 
 			      $now );
-		my $end   = ( $ENV{'form.end_'.$one.'_'.$two.'_'.$three} ? 
-			      $ENV{'form.end_'.$one.'_'.$two.'_'.$three} :
+		my $end   = ( $env{'form.end_'.$one.'_'.$two.'_'.$three} ? 
+			      $env{'form.end_'.$one.'_'.$two.'_'.$three} :
 			      0 );
 		my $url='/'.$one.'/'.$two;
                 my $type = 'three';
                 # split multiple sections
                 my %sections = ();
-                my $num_sections = &build_roles($ENV{'form.sec_'.$one.'_'.$two.'_'.$three},\%sections,$three);
+                my $num_sections = &build_roles($env{'form.sec_'.$one.'_'.$two.'_'.$three},\%sections,$three);
                 if ($num_sections == 0) {
                     $r->print(&commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,''));
                 } else {
@@ -1218,16 +1218,16 @@
 	    } elsif ($_=~/^form\.act\_([^\_]+)\_([^\_]+)$/) {
 		# Activate roles for sections with two id numbers
 		# set start, end times, and the url for the class
-		my $start = ( $ENV{'form.start_'.$1.'_'.$2} ? 
-			      $ENV{'form.start_'.$1.'_'.$2} : 
+		my $start = ( $env{'form.start_'.$1.'_'.$2} ? 
+			      $env{'form.start_'.$1.'_'.$2} : 
 			      $now );
-		my $end   = ( $ENV{'form.end_'.$1.'_'.$2} ? 
-			      $ENV{'form.end_'.$1.'_'.$2} :
+		my $end   = ( $env{'form.end_'.$1.'_'.$2} ? 
+			      $env{'form.end_'.$1.'_'.$2} :
 			      0 );
 		my $url='/'.$1.'/';
                 # split multiple sections
                 my %sections = ();
-                my $num_sections = &build_roles($ENV{'form.sec_'.$1.'_'.$2},\%sections,$2);
+                my $num_sections = &build_roles($env{'form.sec_'.$1.'_'.$2},\%sections,$2);
                 if ($num_sections == 0) {
                     $r->print(&commit_standardrole($udom,$uname,$url,$2,$start,$end,$1,undef,''));
                 } else {
@@ -1248,7 +1248,7 @@
 		$r->print('<p>'.&mt('ERROR').': '.&mt('Unknown command').' <tt>'.$_.'</tt></p><br>');
             }
 	} 
-    } # End of foreach (keys(%ENV))
+    } # End of foreach (keys(%env))
 # Flush the course logs so reverse user roles immediately updated
     &Apache::lonnet::flushcourselogs();
     $r->print('</body></html>');
@@ -1374,10 +1374,10 @@
 
 sub custom_role_editor {
     my $r=shift;
-    my $rolename=$ENV{'form.rolename'};
+    my $rolename=$env{'form.rolename'};
 
     if ($rolename eq 'make new role') {
-	$rolename=$ENV{'form.newrolename'};
+	$rolename=$env{'form.newrolename'};
     }
 
     $rolename=~s/[^A-Za-z0-9]//gs;
@@ -1473,7 +1473,7 @@
 sub set_custom_role {
     my $r=shift;
 
-    my $rolename=$ENV{'form.rolename'};
+    my $rolename=$env{'form.rolename'};
 
     $rolename=~s/[^A-Za-z0-9]//gs;
 
@@ -1502,7 +1502,7 @@
     foreach (split(/\:/,$Apache::lonnet::pr{'cr:c'})) {
 	my ($priv,$restrict)=split(/\&/,$_);
         unless ($restrict) { $restrict=''; }
-        if ($ENV{'form.'.$priv.':c'}) {
+        if ($env{'form.'.$priv.':c'}) {
 	    $courole.=':'.$_;
 	}
     }
@@ -1510,7 +1510,7 @@
     foreach (split(/\:/,$Apache::lonnet::pr{'cr:d'})) {
 	my ($priv,$restrict)=split(/\&/,$_);
         unless ($restrict) { $restrict=''; }
-        if ($ENV{'form.'.$priv.':d'}) {
+        if ($env{'form.'.$priv.':d'}) {
 	    $domrole.=':'.$_;
 	}
     }
@@ -1518,21 +1518,21 @@
     foreach (split(/\:/,$Apache::lonnet::pr{'cr:s'})) {
 	my ($priv,$restrict)=split(/\&/,$_);
         unless ($restrict) { $restrict=''; }
-        if ($ENV{'form.'.$priv.':s'}) {
+        if ($env{'form.'.$priv.':s'}) {
 	    $sysrole.=':'.$_;
 	}
     }
     $r->print('<br />Defining Role: '.
 	   &Apache::lonnet::definerole($rolename,$sysrole,$domrole,$courole));
-    if ($ENV{'request.course.id'}) {
-        my $url='/'.$ENV{'request.course.id'};
+    if ($env{'request.course.id'}) {
+        my $url='/'.$env{'request.course.id'};
         $url=~s/\_/\//g;
 	$r->print('<br />'.&mt('Assigning Role to Self').': '.
-	      &Apache::lonnet::assigncustomrole($ENV{'user.domain'},
-						$ENV{'user.name'},
+	      &Apache::lonnet::assigncustomrole($env{'user.domain'},
+						$env{'user.name'},
 						$url,
-						$ENV{'user.domain'},
-						$ENV{'user.name'},
+						$env{'user.domain'},
+						$env{'user.name'},
 						$rolename));
     }
     $r->print('</body></html>');
@@ -1548,28 +1548,28 @@
        return OK;
     }
 
-    if ((&Apache::lonnet::allowed('cta',$ENV{'request.course.id'})) ||
-        (&Apache::lonnet::allowed('cin',$ENV{'request.course.id'})) || 
-        (&Apache::lonnet::allowed('ccr',$ENV{'request.course.id'})) || 
-        (&Apache::lonnet::allowed('cep',$ENV{'request.course.id'})) ||
-        (&Apache::lonnet::allowed('cca',$ENV{'request.role.domain'})) ||
-        (&Apache::lonnet::allowed('mau',$ENV{'request.role.domain'}))) {
+    if ((&Apache::lonnet::allowed('cta',$env{'request.course.id'})) ||
+        (&Apache::lonnet::allowed('cin',$env{'request.course.id'})) || 
+        (&Apache::lonnet::allowed('ccr',$env{'request.course.id'})) || 
+        (&Apache::lonnet::allowed('cep',$env{'request.course.id'})) ||
+        (&Apache::lonnet::allowed('cca',$env{'request.role.domain'})) ||
+        (&Apache::lonnet::allowed('mau',$env{'request.role.domain'}))) {
        &Apache::loncommon::content_type($r,'text/html');
        $r->send_http_header;
-       unless ($ENV{'form.phase'}) {
+       unless ($env{'form.phase'}) {
 	   &print_username_entry_form($r);
        }
-       if ($ENV{'form.phase'} eq 'get_user_info') {
+       if ($env{'form.phase'} eq 'get_user_info') {
            &print_user_modification_page($r);
-       } elsif ($ENV{'form.phase'} eq 'update_user_data') {
+       } elsif ($env{'form.phase'} eq 'update_user_data') {
            &update_user_data($r);
-       } elsif ($ENV{'form.phase'} eq 'selected_custom_edit') {
+       } elsif ($env{'form.phase'} eq 'selected_custom_edit') {
            &custom_role_editor($r);
-       } elsif ($ENV{'form.phase'} eq 'set_custom_roles') {
+       } elsif ($env{'form.phase'} eq 'set_custom_roles') {
 	   &set_custom_role($r);
        }
    } else {
-      $ENV{'user.error.msg'}=
+      $env{'user.error.msg'}=
         "/adm/createuser:mau:0:0:Cannot modify user data";
       return HTTP_NOT_ACCEPTABLE; 
    }
@@ -1610,8 +1610,8 @@
 	my ($domain,$cnum)=split(/\//,$thiscourse);
         my %sections_count = ();
         my $num_sections = 0;
-        if (defined($ENV{'request.course.id'})) {
-            if ($ENV{'request.course.id'} eq $domain.'_'.$cnum) {
+        if (defined($env{'request.course.id'})) {
+            if ($env{'request.course.id'} eq $domain.'_'.$cnum) {
                 $num_sections = &Apache::loncommon::get_sections($domain,$cnum,\%sections_count);
             }
         }
@@ -1658,8 +1658,8 @@
         foreach (sort keys %customroles) {
 	    if (&Apache::lonnet::allowed('ccr',$thiscourse)) {
 		my $plrole=$_;
-                my $customrole=$protectedcourse.'_cr_cr_'.$ENV{'user.domain'}.
-		    '_'.$ENV{'user.name'}.'_'.$plrole;
+                my $customrole=$protectedcourse.'_cr_cr_'.$env{'user.domain'}.
+		    '_'.$env{'user.name'}.'_'.$plrole;
 		$table .= <<END;
 <tr bgcolor="#$bgcol">
 <td><input type="checkbox" name="act_$customrole"></td>
@@ -1759,8 +1759,8 @@
     }
     if ( keys %customroles > 0) {
         foreach (sort keys %customroles) {
-            my $custrole='cr_cr_'.$ENV{'user.domain'}.
-                    '_'.$ENV{'user.name'}.'_'.$_;
+            my $custrole='cr_cr_'.$env{'user.domain'}.
+                    '_'.$env{'user.name'}.'_'.$_;
             $otheritems .= '  <option value="'.$custrole.'">'.$_;
         }
     }
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.173 loncom/interface/londocs.pm:1.174
--- loncom/interface/londocs.pm:1.173	Mon Apr  4 19:51:54 2005
+++ loncom/interface/londocs.pm	Thu Apr  7 02:56:23 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.173 2005/04/04 23:51:54 albertel Exp $
+# $Id: londocs.pm,v 1.174 2005/04/07 06:56:23 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -86,17 +86,17 @@
     my %outhash=();
     my $home=0;
     my $other=0;
-    foreach (keys %ENV) {
+    foreach (keys %env) {
 	if ($_=~/^user\.role\.(au|ca)\.(.+)$/) {
 	    my $role=$1;
 	    my $realm=$2;
-	    my ($start,$end)=split(/\./,$ENV{$_});
+	    my ($start,$end)=split(/\./,$env{$_});
 	    if (($start) && ($start>time)) { next; }
 	    if (($end) && (time>$end)) { next; }
 	    my $ca; my $cd;
 	    if ($1 eq 'au') {
-		$ca=$ENV{'user.name'};
-		$cd=$ENV{'user.domain'};
+		$ca=$env{'user.name'};
+		$cd=$env{'user.domain'};
 	    } else {
 		($cd,$ca)=($realm=~/^\/(\w+)\/(\w+)$/);
 	    }
@@ -147,22 +147,22 @@
 	      '<form name="dumpdoc" method="post">');
     my ($home,$other,%outhash)=&authorhosts();
     unless ($home) { return ''; }
-    my $origcrsid=$ENV{'request.course.id'};
+    my $origcrsid=$env{'request.course.id'};
     my %origcrsdata=&Apache::lonnet::coursedescription($origcrsid);
-    if (($ENV{'form.authorspace'}) && ($ENV{'form.authorfolder'}=~/\w/)) {
+    if (($env{'form.authorspace'}) && ($env{'form.authorfolder'}=~/\w/)) {
 # Do the dumping
-	unless ($outhash{'home_'.$ENV{'form.authorspace'}}) { return ''; }
-	my ($ca,$cd)=split(/\@/,$ENV{'form.authorspace'});
+	unless ($outhash{'home_'.$env{'form.authorspace'}}) { return ''; }
+	my ($ca,$cd)=split(/\@/,$env{'form.authorspace'});
 	$r->print('<h3>'.&mt('Copying Files').'</h3>');
-	my $title=$ENV{'form.authorfolder'};
+	my $title=$env{'form.authorfolder'};
 	$title=&clean($title);
 	my %replacehash=();
-	foreach (keys %ENV) {
+	foreach (keys %env) {
 	    if ($_=~/^form\.namefor\_(.+)/) {
-		$replacehash{$1}=$ENV{$_};
+		$replacehash{$1}=$env{$_};
 	    }
 	}
-	my $crs='/uploaded/'.$ENV{'request.course.id'}.'/';
+	my $crs='/uploaded/'.$env{'request.course.id'}.'/';
 	$crs=~s/\_/\//g;
 	foreach (keys %replacehash) {
 	    my $newfilename=$title.'/'.$replacehash{$_};
@@ -181,12 +181,12 @@
 	    if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) {
 		if ($_=~/\.(sequence|page|html|htm|xml|xhtml)$/) {
 		    print $fh &Apache::loncreatecourse::rewritefile(
-         &Apache::loncreatecourse::readfile($ENV{'request.course.id'},$_),
+         &Apache::loncreatecourse::readfile($env{'request.course.id'},$_),
 				     (%replacehash,$crs => '')
 								    );
 		} else {
 		    print $fh
-         &Apache::loncreatecourse::readfile($ENV{'request.course.id'},$_);
+         &Apache::loncreatecourse::readfile($env{'request.course.id'},$_);
 		       }
 		$fh->close();
 	    } else {
@@ -259,7 +259,7 @@
 sub exportcourse {
     my $r=shift;
     my %discussiontime = &Apache::lonnet::dump('discussiontimes',
-                                               $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+                                               $env{'course.'.$env{'request.course.id'}.'.domain'}, $env{'course.'.$env{'request.course.id'}.'.num'});
     my $numdisc = keys %discussiontime;
     my $navmap = Apache::lonnavmaps::navmap->new();
     my $it=$navmap->getIterator(undef,undef,undef,1,undef,undef);
@@ -268,24 +268,24 @@
 
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
                                             ['finishexport']);
-    if ($ENV{'form.finishexport'}) {
+    if ($env{'form.finishexport'}) {
         &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
                                             ['archive','discussion']);
 
         my @exportitems = ();
-        if (defined($ENV{'form.archive'})) {
-            if (ref($ENV{'form.archive'}) eq 'ARRAY') {
-                @exportitems = @{$ENV{'form.archive'}};
+        if (defined($env{'form.archive'})) {
+            if (ref($env{'form.archive'}) eq 'ARRAY') {
+                @exportitems = @{$env{'form.archive'}};
             } else {
-                $exportitems[0] = $ENV{'form.archive'};
+                $exportitems[0] = $env{'form.archive'};
             }
         }
         my @discussions = ();
-        if (defined($ENV{'form.discussion'})) {
-            if (ref($ENV{'form.discussion'}) eq 'ARRAY') {
-                @discussions = $ENV{'form.discussion'};
+        if (defined($env{'form.discussion'})) {
+            if (ref($env{'form.discussion'}) eq 'ARRAY') {
+                @discussions = $env{'form.discussion'};
             } else {
-                $discussions[0] = $ENV{'form.discussion'};
+                $discussions[0] = $env{'form.discussion'};
             }
         }
         if (@exportitems == 0 && @discussions == 0) {
@@ -304,20 +304,14 @@
 
 #Create zip file in prtspool
                 my $imszipfile = '/prtspool/'.
-                $ENV{'user.name'}.'_'.$ENV{'user.domain'}.'_'.
+                $env{'user.name'}.'_'.$env{'user.domain'}.'_'.
                    time.'_'.rand(1000000000).'.zip';
-# zip can cause an sh launch which can pass along all of %ENV
-# which can be too large for /bin/sh to handle
-                my %oldENV=%ENV;
-                undef(%ENV);
                 my $cwd = &Cwd::getcwd();
                 my $imszip = '/home/httpd/'.$imszipfile;
                 chdir $tempexport;
                 open(OUTPUT, "zip -r $imszip *  2> /dev/null |");
                 close(OUTPUT);
                 chdir $cwd;
-                %ENV=%oldENV;
-                undef(%oldENV);
                 $outcome .= 'Download the zip file from <a href="'.$imszipfile.'">IMS course archive</a><br />';
                 if ($copyresult) {
                     $outcome .= 'The following errors occurred during export - '.$copyresult;
@@ -491,7 +485,7 @@
     if (!-e $$tempexport) {
         mkdir($$tempexport,0700);
     }
-    $$tempexport .= '/'.$ENV{'user.domain'}.'_'.$ENV{'user.name'};
+    $$tempexport .= '/'.$env{'user.domain'}.'_'.$env{'user.name'};
     if (!-e $$tempexport) {
         mkdir($$tempexport,0700);
     }
@@ -508,13 +502,13 @@
 '<manifest xmlns="http://www.imsglobal.org/xsd/imscp_v1p1"'.
 ' xmlns:imsmd="http://www.imsglobal.org/xsd/imsmd_v1p2"'.
 ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'.
-' identifier="MANIFEST-'.$ENV{'request.course.id'}.'-'.$now.'"'.
+' identifier="MANIFEST-'.$env{'request.course.id'}.'-'.$now.'"'.
 '  xsi:schemaLocation="http://www.imsglobal.org/xsd/imscp_v1p1imscp_v1p1.xsd'.
 '  http://www.imsglobal.org/xsd/imsmd_v1p2 imsmd_v1p2p2.xsd">'."\n".
-'  <organizations default="ORG-'.$ENV{'request.course.id'}.'-'.$now.'">'."\n".
-'    <organization identifier="ORG-'.$ENV{'request.course.id'}.'-'.$now.'"'.
+'  <organizations default="ORG-'.$env{'request.course.id'}.'-'.$now.'">'."\n".
+'    <organization identifier="ORG-'.$env{'request.course.id'}.'-'.$now.'"'.
 ' structure="hierarchical">'."\n".
-'      <title>'.$ENV{'request.'.$ENV{'request.course.id'}.'.description'}.'</title>'
+'      <title>'.$env{'request.'.$env{'request.course.id'}.'.description'}.'</title>'
     } else {
         $$outcome .= 'An error occurred opening the IMS manifest file.<br />'
 ;
@@ -532,8 +526,8 @@
     my $lastcontainer = 0;
     my %parent = ();
     my @dependencies = ();
-    my $cnum = $ENV{'course.'.$ENV{'request.course.id'}.'.num'};
-    my $cdom = $ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
+    my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+    my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
     while ($curRes = $it->next()) {
         if (ref($curRes)) {
             $count ++;
@@ -583,7 +577,7 @@
                     $isvisible = 'false';
                 }
                 unless ($curRes->is_sequence()) {
-                    $resourceref = 'identifierref="RES-'.$ENV{'request.course.id'}.'-'.$count.'"';
+                    $resourceref = 'identifierref="RES-'.$env{'request.course.id'}.'-'.$count.'"';
                 }
                 if (($depth <= $prevdepth) && ($count > 1) && ($included)) {
                     print $ims_manifest "\n".'  </item>'."\n";
@@ -592,7 +586,7 @@
                 $prevdepth = $depth;
 
                 my $itementry =
-              '<item identifier="ITEM-'.$ENV{'request.course.id'}.'-'.$count.
+              '<item identifier="ITEM-'.$env{'request.course.id'}.'-'.$count.
               '" isvisible="'.$isvisible.'" '.$resourceref.'>'.
               '<title>'.$curRes->title().'</title>';
                 print $ims_manifest "\n".$itementry;
@@ -603,7 +597,7 @@
                     &process_content($count,$curRes,$cdom,$cnum,$symb,\$content_file,\@hrefs,$copyresult,$tempexport);
                     if ($content_file) {
                         $imsresources .= "\n".
-                     '   <resource identifier="RES-'.$ENV{'request.course.id'}.'-'.$count.
+                     '   <resource identifier="RES-'.$env{'request.course.id'}.'-'.$count.
                      '" type="webcontent" href="'.$content_file.'">'."\n".
                      '       <file href="'.$content_file.'" />'."\n";
                         foreach (@hrefs) {
@@ -717,7 +711,7 @@
         $$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'uploaded');
     } elsif ($symb =~ m-\.(sequence|page)___\d+___([^/]+)/([^/]+)-) {
         my $canedit = 0;
-        if ($2 eq $ENV{'user.domain'} && $3 eq $ENV{'user.name'})  {
+        if ($2 eq $env{'user.domain'} && $3 eq $env{'user.name'})  {
             $canedit= 1;
         }
         if ($canedit) {
@@ -859,7 +853,7 @@
                             '<link from="1" to="2" index="1"></link>'."\n".
                             '<resource id="2" src="" type="finish"></resource>'."\n".
                             '</map>';
-            $ENV{'form.output'}=$newmapstr;
+            $env{'form.output'}=$newmapstr;
             my $home=&Apache::lonnet::homeserver($coursenum,$coursedom);
             my $result=&Apache::lonnet::finishuserfileupload($coursenum,$coursedom,$home,
                                                 'output',$1.$2);
@@ -889,19 +883,19 @@
     my ($where)=@_;
     &Apache::lonhtmlcommon::clear_breadcrumbs();
     my (@folders);
-    if ($ENV{'form.pagepath'}) {
-        @folders = split('&',$ENV{'form.pagepath'});
+    if ($env{'form.pagepath'}) {
+        @folders = split('&',$env{'form.pagepath'});
     } else {
-        @folders=split('&',$ENV{'form.folderpath'});
+        @folders=split('&',$env{'form.folderpath'});
     }
     my $folderpath;
     my $cpinfo='';
-    if ($ENV{'form.markedcopy_url'}) {
-	&Apache::lonnet::logthis('Found '.$ENV{'form.markedcopy_url'});
+    if ($env{'form.markedcopy_url'}) {
+	&Apache::lonnet::logthis('Found '.$env{'form.markedcopy_url'});
        $cpinfo='&markedcopy_url='.
-               &Apache::lonnet::escape($ENV{'form.markedcopy_url'}).
+               &Apache::lonnet::escape($env{'form.markedcopy_url'}).
                '&markedcopy_title='.
-               &Apache::lonnet::escape($ENV{'form.markedcopy_title'});
+               &Apache::lonnet::escape($env{'form.markedcopy_title'});
     }
     while (@folders) {
 	my $folder=shift(@folders);
@@ -928,7 +922,7 @@
     my $errtext='';
     my $fatal=0;
     my $container='sequence';
-    if ($ENV{'form.pagepath'}) {
+    if ($env{'form.pagepath'}) {
         $container='page';
     }
     ($errtext,$fatal)=
@@ -937,11 +931,11 @@
        	$Apache::lonratedt::order[0]=1;
         $Apache::lonratedt::resources[1]='';
     }
-    if (defined($ENV{'form.markcopy'})) {
+    if (defined($env{'form.markcopy'})) {
 # Mark for copying
-	my ($title,$url)=split(':',$Apache::lonratedt::resources[$Apache::lonratedt::order[$ENV{'form.markcopy'}]]);
-	$ENV{'form.markedcopy_title'}=$title;
-	$ENV{'form.markedcopy_url'}=$url;
+	my ($title,$url)=split(':',$Apache::lonratedt::resources[$Apache::lonratedt::order[$env{'form.markcopy'}]]);
+	$env{'form.markedcopy_title'}=$title;
+	$env{'form.markedcopy_url'}=$url;
     }
     $r->print(&breadcrumbs($folder));
     if ($fatal) {
@@ -950,32 +944,32 @@
 # ------------------------------------------------------------ Process commands
 
 # ---------------- if they are for this folder and user allowed to make changes
-	if (($allowed) && ($ENV{'form.folder'} eq $folder)) {
+	if (($allowed) && ($env{'form.folder'} eq $folder)) {
 # set parameters and change order
-	    if (defined($ENV{'form.setparms'})) {
-		my $idx=$ENV{'form.setparms'};
+	    if (defined($env{'form.setparms'})) {
+		my $idx=$env{'form.setparms'};
 # set parameters
-		if ($ENV{'form.randpick_'.$idx}) {
-		    &Apache::lonratedt::storeparameter($idx,'parameter_randompick',$ENV{'form.randpick_'.$idx},'int_pos');
+		if ($env{'form.randpick_'.$idx}) {
+		    &Apache::lonratedt::storeparameter($idx,'parameter_randompick',$env{'form.randpick_'.$idx},'int_pos');
 		} else {
 		    &Apache::lonratedt::delparameter($idx,'parameter_randompick');
 		}
-		if ($ENV{'form.hidprs_'.$idx}) {
+		if ($env{'form.hidprs_'.$idx}) {
 		    &Apache::lonratedt::storeparameter($idx,'parameter_hiddenresource','yes','string_yesno');
 		} else {
 		    &Apache::lonratedt::delparameter($idx,'parameter_hiddenresource');
 		}
-		if ($ENV{'form.encprs_'.$idx}) {
+		if ($env{'form.encprs_'.$idx}) {
 		    &Apache::lonratedt::storeparameter($idx,'parameter_encrypturl','yes','string_yesno');
 		} else {
 		    &Apache::lonratedt::delparameter($idx,'parameter_encrypturl');
 		}
 
-		if ($ENV{'form.newpos'}) {
+		if ($env{'form.newpos'}) {
 # change order
 
-		    my $newpos=$ENV{'form.newpos'}-1;
-		    my $currentpos=$ENV{'form.currentpos'}-1;
+		    my $newpos=$env{'form.newpos'}-1;
+		    my $currentpos=$env{'form.currentpos'}-1;
 		    my $i;
 		    my @neworder=();
 		    if ($newpos>$currentpos) {
@@ -1014,10 +1008,10 @@
 		}
 		
 	    }
-	    if ($ENV{'form.pastemarked'}) {
+	    if ($env{'form.pastemarked'}) {
 # paste resource to end of list
-                my $url=$ENV{'form.markedcopy_url'};
-		my $title=$ENV{'form.markedcopy_title'};
+                my $url=$env{'form.markedcopy_url'};
+		my $title=$env{'form.markedcopy_title'};
 # Maps need to be copied first
 		if (($url=~/\.(page|sequence)$/) || ($url=~/^\/uploaded\//)) {
 		    $title=&mt('Copy of').' '.$title;
@@ -1027,7 +1021,7 @@
 		    my $storefn=$newurl;
                     $storefn=~s/^\/\w+\/\w+\/\w+\///;
 		    &Apache::loncreatecourse::writefile
-			($ENV{'request.course.id'},$storefn,
+			($env{'request.course.id'},$storefn,
 			 &Apache::lonnet::getfile($url));
 		    $url=$newurl;
 		}
@@ -1051,8 +1045,8 @@
 
 	    }
 # upload a file, if present
-           if (($ENV{'form.uploaddoc.filename'}) &&
-               ($ENV{'form.cmd'}=~/^upload_(\w+)/)) {
+           if (($env{'form.uploaddoc.filename'}) &&
+               ($env{'form.cmd'}=~/^upload_(\w+)/)) {
 	    if ( ($folder=~/^$1/) || ($1 eq 'default') ) {
 # this is for a course, not a user, so set coursedoc flag
 # probably the only place in the system where this should be "1"
@@ -1061,13 +1055,13 @@
               my $ext='false';
               if ($url=~/^http\:\/\//) { $ext='true'; }
               $url=~s/\:/\&colon;/g;
-	      my $comment=$ENV{'form.comment'};
+	      my $comment=$env{'form.comment'};
               $comment=~s/\</\&lt\;/g;
               $comment=~s/\>/\&gt\;/g;
               $comment=~s/\:/\&colon;/g;
               if ($folder=~/^supplemental/) {
-		  $comment=time.'___&&&___'.$ENV{'user.name'}.'___&&&___'.
-		      $ENV{'user.domain'}.'___&&&___'.$comment;
+		  $comment=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
+		      $env{'user.domain'}.'___&&&___'.$comment;
               }
               $Apache::lonratedt::resources[$newidx]=
                   $comment.':'.$url.':'.$ext.':normal:res';
@@ -1081,8 +1075,8 @@
 	      }
 	     }
             }
-	    if ($ENV{'form.cmd'}) {
-                my ($cmd,$idx)=split(/\_/,$ENV{'form.cmd'});
+	    if ($env{'form.cmd'}) {
+                my ($cmd,$idx)=split(/\_/,$env{'form.cmd'});
                 if ($cmd eq 'del') {
 		    my (undef,$url)=split(':',$Apache::lonratedt::resources[$Apache::lonratedt::order[$idx]]);
 		    if ($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) {
@@ -1120,7 +1114,7 @@
                        $Apache::lonratedt::resources[
 				       $Apache::lonratedt::order[$idx]]);
                     my $comment=
-                     &HTML::Entities::decode($ENV{'form.title'});
+                     &HTML::Entities::decode($env{'form.title'});
                     $comment=~s/\</\&lt\;/g;
                     $comment=~s/\>/\&gt\;/g;
                     $comment=~s/\:/\&colon;/g;
@@ -1139,9 +1133,9 @@
 		}
             }
 # Group import/search
-	    if ($ENV{'form.importdetail'}) {
+	    if ($env{'form.importdetail'}) {
 		my @imports;
-		foreach (split(/\&/,$ENV{'form.importdetail'})) {
+		foreach (split(/\&/,$env{'form.importdetail'})) {
 		    if (defined($_)) {
 			my ($name,$url)=split(/\=/,$_);
 			$name=&Apache::lonnet::unescape($name);
@@ -1158,8 +1152,8 @@
 		}
             }
 # Loading a complete map
-	   if (($ENV{'form.importmap'}) && ($ENV{'form.loadmap'})) {
-	       foreach (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$ENV{'form.importmap'}))) {
+	   if (($env{'form.importmap'}) && ($env{'form.loadmap'})) {
+	       foreach (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$env{'form.importmap'}))) {
                    my $idx=$#Apache::lonratedt::resources;
                    $idx++;
                    $Apache::lonratedt::resources[$idx]=$_;
@@ -1193,25 +1187,25 @@
 	    $r->print('<tr><td>'.&mt('Currently no documents.').'</td></tr>');
 	}
         $r->print("\n</table>\n");
-	if ($ENV{'form.markedcopy_url'}) {
+	if ($env{'form.markedcopy_url'}) {
 	    $r->print(<<ENDPASTE);
 <p><form name="pasteform" action="/adm/coursedocs" method="post">
-<input type="hidden" name="markedcopy_url" value="$ENV{'form.markedcopy_url'}" />
-<input type="hidden" name="markedcopy_title" value="$ENV{'form.markedcopy_title'}" />
+<input type="hidden" name="markedcopy_url" value="$env{'form.markedcopy_url'}" />
+<input type="hidden" name="markedcopy_title" value="$env{'form.markedcopy_title'}" />
 ENDPASTE
             $r->print(
 	   '<input type="submit" name="pastemarked" value="'.&mt('Paste').
 		      '" /> '.&Apache::loncommon::filedescription(
-		(split(/\./,$ENV{'form.markedcopy_url'}))[-1]).': '.
-		      $ENV{'form.markedcopy_title'});
+		(split(/\./,$env{'form.markedcopy_url'}))[-1]).': '.
+		      $env{'form.markedcopy_title'});
             if ($container eq 'page') {
 		$r->print(<<PAGEINFO);
-<input type="hidden" name="pagepath" value="$ENV{'form.pagepath'}" />
-<input type="hidden" name="pagesymb" value="$ENV{'form.pagesymb'}" />
+<input type="hidden" name="pagepath" value="$env{'form.pagepath'}" />
+<input type="hidden" name="pagesymb" value="$env{'form.pagesymb'}" />
 PAGEINFO
             } else {
 		$r->print(<<FOLDERINFO);
-<input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
+<input type="hidden" name="folderpath" value="$env{'form.folderpath'}" />
 FOLDERINFO
 	    }
 	    $r->print('</form></p>');
@@ -1242,23 +1236,23 @@
 # Edit commands
     my $container;
     my $folderpath;
-    if ($ENV{'form.folderpath'}) {
+    if ($env{'form.folderpath'}) {
         $container = 'sequence';
-	$folderpath=&Apache::lonnet::escape($ENV{'form.folderpath'});
-	# $htmlfoldername=&HTML::Entities::encode($ENV{'form.foldername'},'<>&"');
+	$folderpath=&Apache::lonnet::escape($env{'form.folderpath'});
+	# $htmlfoldername=&HTML::Entities::encode($env{'form.foldername'},'<>&"');
     }
     my ($pagepath,$pagesymb);
-    if ($ENV{'form.pagepath'}) {
+    if ($env{'form.pagepath'}) {
         $container = 'page';
-        $pagepath=&Apache::lonnet::escape($ENV{'form.pagepath'});
-        $pagesymb=&Apache::lonnet::escape($ENV{'form.pagesymb'});
+        $pagepath=&Apache::lonnet::escape($env{'form.pagepath'});
+        $pagesymb=&Apache::lonnet::escape($env{'form.pagesymb'});
     }
     my $cpinfo='';
-    if ($ENV{'form.markedcopy_url'}) {
+    if ($env{'form.markedcopy_url'}) {
        $cpinfo='&markedcopy_url='.
-               &Apache::lonnet::escape($ENV{'form.markedcopy_url'}).
+               &Apache::lonnet::escape($env{'form.markedcopy_url'}).
                '&markedcopy_title='.
-               &Apache::lonnet::escape($ENV{'form.markedcopy_title'});
+               &Apache::lonnet::escape($env{'form.markedcopy_title'});
     }
     if ($allowed) {
 	my $incindex=$index+1;
@@ -1290,13 +1284,13 @@
                 'ct' => 'Cut',
 		'rn' => 'Rename',
 		'cp' => 'Copy');
-        if ($ENV{'form.pagepath'}) {
+        if ($env{'form.pagepath'}) {
             $line.=(<<END);
 <form name="entry_$index" action="/adm/coursedocs" method="post">
-<input type="hidden" name="pagepath" value="$ENV{'form.pagepath'}" />
-<input type="hidden" name="pagesymb" value="$ENV{'form.pagesymb'}" />
-<input type="hidden" name="markedcopy_url" value="$ENV{'form.markedcopy_url'}" />
-<input type="hidden" name="markedcopy_title" value="$ENV{'form.markedcopy_title'}" />
+<input type="hidden" name="pagepath" value="$env{'form.pagepath'}" />
+<input type="hidden" name="pagesymb" value="$env{'form.pagesymb'}" />
+<input type="hidden" name="markedcopy_url" value="$env{'form.markedcopy_url'}" />
+<input type="hidden" name="markedcopy_title" value="$env{'form.markedcopy_title'}" />
 <input type="hidden" name="setparms" value="$orderidx" />
 <td><table border='0' cellspacing='2' cellpadding='0'>
 <tr><td bgcolor="#DDDDDD">
@@ -1320,9 +1314,9 @@
         } else {
             $line.=(<<END); 
 <form name="entry_$index" action="/adm/coursedocs" method="post">
-<input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
-<input type="hidden" name="markedcopy_url" value="$ENV{'form.markedcopy_url'}" />
-<input type="hidden" name="markedcopy_title" value="$ENV{'form.markedcopy_title'}" />
+<input type="hidden" name="folderpath" value="$env{'form.folderpath'}" />
+<input type="hidden" name="markedcopy_url" value="$env{'form.markedcopy_url'}" />
+<input type="hidden" name="markedcopy_title" value="$env{'form.markedcopy_title'}" />
 <input type="hidden" name="setparms" value="$orderidx" />
 <td><table border='0' cellspacing='2' cellpadding='0'>
 <tr><td bgcolor="#DDDDDD">
@@ -1375,8 +1369,8 @@
     if ((!$isfolder) && ($residx) && ($folder!~/supplemental/) && (!$ispage)) {
 	my $symb=&Apache::lonnet::symbclean(
           &Apache::lonnet::declutter('uploaded/'.
-           $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}.'/'.
-           $ENV{'course.'.$ENV{'request.course.id'}.'.num'}.'/'.$folder.
+           $env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.
+           $env{'course.'.$env{'request.course.id'}.'.num'}.'/'.$folder.
            '.sequence').
            '___'.$residx.'___'.
 	   &Apache::lonnet::declutter($url));
@@ -1397,7 +1391,7 @@
 	}
 	$url.=(($url=~/\?/)?'&':'?').'symb='.&Apache::lonnet::escape($symb);
 	if ($container eq 'page') {
-	    my $symb=$ENV{'form.pagesymb'};
+	    my $symb=$env{'form.pagesymb'};
 	    	    
 	    $url=&Apache::lonnet::clutter((&Apache::lonnet::decode_symb($symb))[2]);
 	    $url.=(($url=~/\?/)?'&':'?').'symb='.&Apache::lonnet::escape($symb);
@@ -1406,7 +1400,7 @@
     my $parameterset='&nbsp;';
     if ($isfolder) {
 	my $foldername=&Apache::lonnet::escape($foldertitle);
-	my $folderpath=$ENV{'form.folderpath'};
+	my $folderpath=$env{'form.folderpath'};
 	if ($folderpath) { $folderpath.='&' };
 	$folderpath.=$folderarg.'&'.$foldername;
 	$url.='folderpath='.&Apache::lonnet::escape($folderpath).$cpinfo;
@@ -1421,14 +1415,14 @@
     if ($ispage) {
         my $pagename=&Apache::lonnet::escape($pagetitle);
         my $pagepath;
-        my $folderpath=$ENV{'form.folderpath'};
+        my $folderpath=$env{'form.folderpath'};
         if ($folderpath) { $pagepath = $folderpath.'&' };
         $pagepath.=$pagearg.'&'.$pagename;
-	my $symb=$ENV{'form.pagesymb'};
+	my $symb=$env{'form.pagesymb'};
 	if (!$symb) {
 	    my $path='uploaded/'.
-		$ENV{'course.'.$ENV{'request.course.id'}.'.domain'}.'/'.
-		$ENV{'course.'.$ENV{'request.course.id'}.'.num'}.'/';
+		$env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.
+		$env{'course.'.$env{'request.course.id'}.'.num'}.'/';
 	    $symb=&Apache::lonnet::encode_symb($path.$folder.'.sequence',
 					       $residx,
 					       $path.$pagearg.'.page');
@@ -1464,14 +1458,14 @@
 sub tiehash {
     my ($mode)=@_;
     $hashtied=0;
-    if ($ENV{'request.course.fn'}) {
+    if ($env{'request.course.fn'}) {
 	if ($mode eq 'write') {
-	    if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.".db",
+	    if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
 		    &GDBM_WRCREAT(),0640)) {
                 $hashtied=2;
 	    }
 	} else {
-	    if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.".db",
+	    if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
 		    &GDBM_READER(),0640)) {
                 $hashtied=1;
 	    }
@@ -1606,20 +1600,20 @@
     my $starttime=0;
     my $haschanged=0;
     my %setversions=&Apache::lonnet::dump('resourceversions',
-			  $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
-			  $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+			  $env{'course.'.$env{'request.course.id'}.'.domain'},
+			  $env{'course.'.$env{'request.course.id'}.'.num'});
 
     $hashtied=0;
     &tiehash();
     my %newsetversions=();
-    if ($ENV{'form.setmostrecent'}) {
+    if ($env{'form.setmostrecent'}) {
 	$haschanged=1;
 	foreach (keys %hash) {
 	    if ($_=~/^ids\_(\/res\/.+)$/) {
 		$newsetversions{$1}='mostrecent';
 	    }
 	}
-    } elsif ($ENV{'form.setcurrent'}) {
+    } elsif ($env{'form.setcurrent'}) {
 	$haschanged=1;
 	foreach (keys %hash) {
 	    if ($_=~/^ids\_(\/res\/.+)$/) {
@@ -1629,21 +1623,21 @@
 		}
 	    }
 	}
-    } elsif ($ENV{'form.setversions'}) {
+    } elsif ($env{'form.setversions'}) {
 	$haschanged=1;
-	foreach (keys %ENV) {
+	foreach (keys %env) {
 	    if ($_=~/^form\.set_version_(.+)$/) {
 		my $src=$1;
-		if (($ENV{$_}) && ($ENV{$_} ne $setversions{$src})) {
-		    $newsetversions{$src}=$ENV{$_};
+		if (($env{$_}) && ($env{$_} ne $setversions{$src})) {
+		    $newsetversions{$src}=$env{$_};
 		}
 	    }
 	}
     }
     if ($haschanged) {
         if (&Apache::lonnet::put('resourceversions',\%newsetversions,
-			  $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
-			  $ENV{'course.'.$ENV{'request.course.id'}.'.num'}) eq 'ok') {		
+			  $env{'course.'.$env{'request.course.id'}.'.domain'},
+			  $env{'course.'.$env{'request.course.id'}.'.num'}) eq 'ok') {		
 	    $r->print('<h1>'.&mt('Your Version Settings have been Stored').'</h1>');
 	} else {
 	    $r->print('<h1><font color="red">'.&mt('An Error Occured while Attempting to Store your Version Settings').'</font></h1>');
@@ -1651,7 +1645,7 @@
 	&mark_hash_old();
     }
     &changewarning($r,'');
-    if ($ENV{'form.timerange'} eq 'all') {
+    if ($env{'form.timerange'} eq 'all') {
 # show all documents
 	$header=&mt('All Documents in Course');
 	$allsel=1;
@@ -1664,28 +1658,28 @@
     } else {
 # show documents which changed
 	%changes=&Apache::lonnet::dump
-	 ('versionupdate',$ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
-                     $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+	 ('versionupdate',$env{'course.'.$env{'request.course.id'}.'.domain'},
+                     $env{'course.'.$env{'request.course.id'}.'.num'});
 	my $firstkey=(keys %changes)[0];
 	unless ($firstkey=~/^error\:/) {
-	    unless ($ENV{'form.timerange'}) {
-		$ENV{'form.timerange'}=604800;
+	    unless ($env{'form.timerange'}) {
+		$env{'form.timerange'}=604800;
 	    }
-	    my $seltext=&mt('during the last').' '.$ENV{'form.timerange'}.' '
+	    my $seltext=&mt('during the last').' '.$env{'form.timerange'}.' '
 		.&mt('seconds');
-	    if ($ENV{'form.timerange'}==-1) {
+	    if ($env{'form.timerange'}==-1) {
 		$seltext='since start of course';
 		$startsel='selected';
-		$ENV{'form.timerange'}=time;
+		$env{'form.timerange'}=time;
 	    }
-	    $starttime=time-$ENV{'form.timerange'};
-	    if ($ENV{'form.timerange'}==2592000) {
+	    $starttime=time-$env{'form.timerange'};
+	    if ($env{'form.timerange'}==2592000) {
 		$seltext=&mt('during the last month').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
 		$monthsel='selected';
-	    } elsif ($ENV{'form.timerange'}==604800) {
+	    } elsif ($env{'form.timerange'}==604800) {
 		$seltext=&mt('during the last week').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
 		$weeksel='selected';
-	    } elsif ($ENV{'form.timerange'}==86400) {
+	    } elsif ($env{'form.timerange'}==86400) {
 		$seltext=&mt('since yesterday').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
 		$daysel='selected';
 	    }
@@ -1695,8 +1689,8 @@
 	}
     }
     %setversions=&Apache::lonnet::dump('resourceversions',
-			  $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
-			  $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+			  $env{'course.'.$env{'request.course.id'}.'.domain'},
+			  $env{'course.'.$env{'request.course.id'}.'.num'});
     my %lt=&Apache::lonlocal::texthash
 	      ('st' => 'Version changes since start of Course',
 	       'lm' => 'Version changes since last Month',
@@ -1860,11 +1854,11 @@
     my ($r,$postexec)=@_;
     if (!&is_hash_old()) { return; }
     my $pathvar='folderpath';
-    my $path=&Apache::lonnet::escape($ENV{'form.folderpath'});
-    if (defined($ENV{'form.pagepath'})) {
+    my $path=&Apache::lonnet::escape($env{'form.folderpath'});
+    if (defined($env{'form.pagepath'})) {
 	$pathvar='pagepath';
-	$path=&Apache::lonnet::escape($ENV{'form.pagepath'});
-	$path.='&amp;symb='.&Apache::lonnet::escape($ENV{'form.pagesymb'});
+	$path=&Apache::lonnet::escape($env{'form.pagepath'});
+	$path.='&amp;symb='.&Apache::lonnet::escape($env{'form.pagesymb'});
     }
     $r->print(
 '<script>function reinit(tf) { tf.submit();'.$postexec.' }</script>'. 
@@ -1874,7 +1868,7 @@
 '" /><input type="hidden" name="selectrole" value="1" /><h3><font color="red">'.
 &mt('Changes will become active for your current session after').
 ' <input type="hidden" name="'.
-$ENV{'request.role'}.'" value="1" /><input type="button" value="'.
+$env{'request.role'}.'" value="1" /><input type="button" value="'.
 &mt('re-initializing course').'" onClick="reinit(this.form)"/>'.&mt(', or the next time you log in.').
 $help{'Caching'}.'</font></h3></form>');
 }
@@ -1908,18 +1902,18 @@
 		  'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages');
     $help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
 
-  if ($ENV{'form.verify'}) {
+  if ($env{'form.verify'}) {
       &verifycontent($r);
-  } elsif ($ENV{'form.versions'}) {
+  } elsif ($env{'form.versions'}) {
       &checkversions($r);
-  } elsif ($ENV{'form.dumpcourse'}) {
+  } elsif ($env{'form.dumpcourse'}) {
       &dumpcourse($r);
-  } elsif ($ENV{'form.exportcourse'}) {
+  } elsif ($env{'form.exportcourse'}) {
       &exportcourse($r);
   } else {
 # is this a standard course?
 
-    my $standard=($ENV{'request.course.uri'}=~/^\/uploaded\//);
+    my $standard=($env{'request.course.uri'}=~/^\/uploaded\//);
     my $forcestandard = 0;
     my $forcesupplement;
     my $script='';
@@ -1930,32 +1924,32 @@
     my $uploadtag;
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
     ['folderpath','pagepath','pagesymb','markedcopy_url','markedcopy_title']);
-    if ($ENV{'form.folderpath'}) {
-	my (@folderpath)=split('&',$ENV{'form.folderpath'});
-	$ENV{'form.foldername'}=&Apache::lonnet::unescape(pop(@folderpath));
-	$ENV{'form.folder'}=pop(@folderpath);
-    }
-    if ($ENV{'form.pagepath'}) {
-        my (@pagepath)=split('&',$ENV{'form.pagepath'});
-        $ENV{'form.pagename'}=&Apache::lonnet::unescape(pop(@pagepath));
-        $ENV{'form.folder'}=pop(@pagepath);
+    if ($env{'form.folderpath'}) {
+	my (@folderpath)=split('&',$env{'form.folderpath'});
+	$env{'form.foldername'}=&Apache::lonnet::unescape(pop(@folderpath));
+	$env{'form.folder'}=pop(@folderpath);
+    }
+    if ($env{'form.pagepath'}) {
+        my (@pagepath)=split('&',$env{'form.pagepath'});
+        $env{'form.pagename'}=&Apache::lonnet::unescape(pop(@pagepath));
+        $env{'form.folder'}=pop(@pagepath);
         $containertag = '<input type="hidden" name="pagepath" value="" />'.
 	    '<input type="hidden" name="pagesymb" value="" />';
-        $uploadtag = '<input type="hidden" name="pagepath" value="'.$ENV{'form.pagepath'}.'" />'.
-	    '<input type="hidden" name="pagesymb" value="'.$ENV{'form.pagesymb'}.'" />';
+        $uploadtag = '<input type="hidden" name="pagepath" value="'.$env{'form.pagepath'}.'" />'.
+	    '<input type="hidden" name="pagesymb" value="'.$env{'form.pagesymb'}.'" />';
     }
     if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
        $showdoc='/'.$1;
     }
     unless ($showdoc) { # got called from remote
-       if (($ENV{'form.folder'}=~/^default_/) || 
-          ($ENV{'form.folder'} =~ m#^\d+/(pages|sequences)/#)) {
+       if (($env{'form.folder'}=~/^default_/) || 
+          ($env{'form.folder'} =~ m#^\d+/(pages|sequences)/#)) {
            $forcestandard = 1;
        } 
-       $forcesupplement=($ENV{'form.folder'}=~/^supplemental_/);
+       $forcesupplement=($env{'form.folder'}=~/^supplemental_/);
 
 # does this user have privileges to post, etc?
-       $allowed=&Apache::lonnet::allowed('mdc',$ENV{'request.course.id'});
+       $allowed=&Apache::lonnet::allowed('mdc',$env{'request.course.id'});
        if ($allowed) { 
          &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
          $script=&Apache::lonratedt::editscript('simple'); 
@@ -1968,13 +1962,13 @@
     }
 
 # get course data
-    my $coursenum=$ENV{'course.'.$ENV{'request.course.id'}.'.num'};
-    my $coursedom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
+    my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'};
+    my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'};
 
 # get personal data
  
-    my $uname=$ENV{'user.name'};
-    my $udom=$ENV{'user.domain'};
+    my $uname=$env{'user.name'};
+    my $udom=$env{'user.domain'};
     my $plainname=&Apache::lonnet::escape(
                      &Apache::loncommon::plainname($uname,$udom));
 
@@ -2195,15 +2189,15 @@
 					 'cv' => 'Check/Set Resource Versions',
 					  );
 
-       my $folderpath=$ENV{'form.folderpath'};
+       my $folderpath=$env{'form.folderpath'};
        if (!$folderpath) {
-	   if ($ENV{'form.folder'} eq '' ||
-	       $ENV{'form.folder'} eq 'supplemental') {
+	   if ($env{'form.folder'} eq '' ||
+	       $env{'form.folder'} eq 'supplemental') {
 	       $folderpath='default&'.
 		   &Apache::lonnet::escape(&mt('Main Course Documents'));
 	   }
        }
-       unless ($ENV{'form.pagepath'}) {
+       unless ($env{'form.pagepath'}) {
            $containertag = '<input type="hidden" name="folderpath" value="" />';
            $uploadtag = '<input type="hidden" name="folderpath" value="'.$folderpath.'" />';
        }
@@ -2239,10 +2233,10 @@
 	$r->print('<tr><td bgcolor="#BBBBBB">');
 #  '<h2>'.&mt('Main Course Documents').
 #  ($allowed?' '.$help{'Main_Course_Documents'}:'').'</h2>');
-       my $folder=$ENV{'form.folder'};
+       my $folder=$env{'form.folder'};
        if ($folder eq '' || $folder eq 'supplemental') {
            $folder='default';
-	   $ENV{'form.folderpath'}='default&'.&Apache::lonnet::escape(&mt('Main Course Documents'));
+	   $env{'form.folderpath'}='default&'.&Apache::lonnet::escape(&mt('Main Course Documents'));
        }
        my $postexec='';
        if ($folder eq 'default') {
@@ -2302,7 +2296,7 @@
 </p>
 </form>
 ENDFORM
-       unless ($ENV{'form.pagepath'}) {
+       unless ($env{'form.pagepath'}) {
 	   $r->print(<<ENDFORM);
 <hr />
 <form action="/adm/coursedocs" method="post" name="newext">
@@ -2321,10 +2315,10 @@
 ENDFORM
        }
        $r->print('</td><td bgcolor="#DDDDDD">');
-       unless ($ENV{'form.pagepath'}) {
+       unless ($env{'form.pagepath'}) {
            $r->print(<<ENDFORM);
 <form action="/adm/coursedocs" method="post" name="newfolder">
-<input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
+<input type="hidden" name="folderpath" value="$env{'form.folderpath'}" />
 <input type=hidden name="importdetail" value="">
 <nobr>
 <input name="newfolder" type="button"
@@ -2333,7 +2327,7 @@
 </nobr>
 </form>
 <form action="/adm/coursedocs" method="post" name="newpage">
-<input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
+<input type="hidden" name="folderpath" value="$env{'form.folderpath'}" />
 <input type=hidden name="importdetail" value="">
 <nobr>
 <input name="newpage" type="button"
@@ -2411,7 +2405,7 @@
 </nobr>
 ENDFORM
        }
-       if ($ENV{'form.pagepath'}) {
+       if ($env{'form.pagepath'}) {
            $r->print(<<ENDBLOCK);
 <form action="/adm/coursedocs" method="post" name="newsmpproblem">
 $uploadtag
@@ -2441,13 +2435,13 @@
        $r->print('<tr><td bgcolor="#BBBBBB">');
 # '<h2>'.&mt('Supplemental Course Documents').
 #  ($allowed?' '.$help{'Supplemental'}:'').'</h2>');
-       my $folder=$ENV{'form.folder'};
+       my $folder=$env{'form.folder'};
        unless ($folder=~/^supplemental/) {
 	   $folder='supplemental';
        }
        if ($folder =~ /^supplemental$/ &&
-	   $ENV{'form.folderpath'} =~ /^default\&/) {
-	   $ENV{'form.folderpath'}='supplemental&'.
+	   $env{'form.folderpath'} =~ /^default\&/) {
+	   $env{'form.folderpath'}='supplemental&'.
 	       &Apache::lonnet::escape(&mt('Supplemental Course Documents'));
        }
        &editor($r,$coursenum,$coursedom,$folder,$allowed);
@@ -2468,7 +2462,7 @@
 <textarea cols=50 rows=4 name='comment'>
 </textarea>
 <br />
-<input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
+<input type="hidden" name="folderpath" value="$env{'form.folderpath'}" />
 <input type="hidden" name="cmd" value="upload_supplemental">
 <nobr>
 <input type="submit" value="$lt{'upld'}">
@@ -2478,7 +2472,7 @@
 </td>
 <td bgcolor="#DDDDDD">
 <form action="/adm/coursedocs" method="post" name="supnewfolder">
-<input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
+<input type="hidden" name="folderpath" value="$env{'form.folderpath'}" />
 <input type=hidden name="importdetail" value="">
 <nobr>
 <input name="newfolder" type="button"
@@ -2487,7 +2481,7 @@
 </nobr>
 </form>
 <form action="/adm/coursedocs" method="post" name="supnewext">
-<input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
+<input type="hidden" name="folderpath" value="$env{'form.folderpath'}" />
 <input type=hidden name="importdetail" value="">
 <nobr>
 <input name="newext" type="button" 
@@ -2496,7 +2490,7 @@
 </nobr>
 </form>
 <form action="/adm/coursedocs" method="post" name="supnewsyl">
-<input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
+<input type="hidden" name="folderpath" value="$env{'form.folderpath'}" />
 <input type=hidden name="importdetail" 
 value="Syllabus=/public/$coursedom/$coursenum/syllabus">
 <nobr>
@@ -2505,7 +2499,7 @@
 </nobr>
 </form>
 <form action="/adm/coursedocs" method="post" name="subnewaboutme">
-<input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
+<input type="hidden" name="folderpath" value="$env{'form.folderpath'}" />
 <input type=hidden name="importdetail" 
 value="$plainname=/adm/$udom/$uname/aboutme">
 <nobr>
Index: loncom/interface/londropadd.pm
diff -u loncom/interface/londropadd.pm:1.126 loncom/interface/londropadd.pm:1.127
--- loncom/interface/londropadd.pm:1.126	Thu Mar 10 12:33:57 2005
+++ loncom/interface/londropadd.pm	Thu Apr  7 02:56:23 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to drop and add students in courses 
 #
-# $Id: londropadd.pm,v 1.126 2005/03/10 17:33:57 matthew Exp $
+# $Id: londropadd.pm,v 1.127 2005/04/07 06:56:23 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -32,7 +32,7 @@
 package Apache::londropadd;
 
 use strict;
-use Apache::lonnet();
+use Apache::lonnet;
 use Apache::loncommon();
 use Apache::lonhtmlcommon();
 use Apache::Constants qw(:common :http REDIRECT);
@@ -139,7 +139,7 @@
 sub print_main_menu {
     my ($r,$enrl_permission,$view_permission)=@_;
     #
-    my ($cdom,$cnum) = split/_/,$ENV{'request.course.id'};
+    my ($cdom,$cnum) = split/_/,$env{'request.course.id'};
     my @menu = 
         ( 
           { text => 'Upload a class list', 
@@ -205,17 +205,17 @@
     my ($r,$datatoken,$distotal,$krbdefdom)=@_;
     my $javascript;
     #
-    if (! exists($ENV{'form.upfile_associate'})) {
-        $ENV{'form.upfile_associate'} = 'forward';
+    if (! exists($env{'form.upfile_associate'})) {
+        $env{'form.upfile_associate'} = 'forward';
     }
-    if ($ENV{'form.associate'} eq 'Reverse Association') {
-        if ( $ENV{'form.upfile_associate'} ne 'reverse' ) {
-            $ENV{'form.upfile_associate'} = 'reverse';
+    if ($env{'form.associate'} eq 'Reverse Association') {
+        if ( $env{'form.upfile_associate'} ne 'reverse' ) {
+            $env{'form.upfile_associate'} = 'reverse';
         } else {
-            $ENV{'form.upfile_associate'} = 'forward';
+            $env{'form.upfile_associate'} = 'forward';
         }
     }
-    if ($ENV{'form.upfile_associate'} eq 'reverse') {
+    if ($env{'form.upfile_associate'} eq 'reverse') {
 	$javascript=&upload_manager_javascript_reverse_associate();
     } else {
 	$javascript=&upload_manager_javascript_forward_associate();
@@ -223,8 +223,8 @@
     #
     # Deal with restored settings
     my $password_choice = '';
-    if (exists($ENV{'form.ipwd_choice'}) &&
-        $ENV{'form.ipwd_choice'} ne '') {
+    if (exists($env{'form.ipwd_choice'}) &&
+        $env{'form.ipwd_choice'} ne '') {
         # If a column was specified for password, assume it is for an
         # internal password.  This is a bug waiting to be filed (could be
         # local or krb auth instead of internal) but I do not have the 
@@ -234,7 +234,7 @@
     #
     my $javascript_validations=&javascript_validations('auth',$krbdefdom,
                                     $password_choice);
-    my $checked=(($ENV{'form.noFirstLine'})?' checked="1"':'');
+    my $checked=(($env{'form.noFirstLine'})?' checked="1"':'');
     $r->print('<h3>'.&mt('Uploading Class List')."</h3>\n".
               "<hr>\n".
               '<h3>'.&mt('Identify fields')."</h3>\n");
@@ -247,9 +247,9 @@
               &hidden_input('state','got_file').
               &hidden_input('associate','').
               &hidden_input('datatoken',$datatoken).
-              &hidden_input('fileupload',$ENV{'form.fileupload'}).
-              &hidden_input('upfiletype',$ENV{'form.upfiletype'}).
-              &hidden_input('upfile_associate',$ENV{'form.upfile_associate'}));
+              &hidden_input('fileupload',$env{'form.fileupload'}).
+              &hidden_input('upfiletype',$env{'form.upfiletype'}).
+              &hidden_input('upfile_associate',$env{'form.upfile_associate'}));
     $r->print('<input type="button" value="Reverse Association" '.
               'name="'.&mt('Reverse Association').'" '.
               'onClick="javascript:this.form.associate.value=\'Reverse Association\';submit(this.form);" />');
@@ -591,9 +591,9 @@
                   kerb_def_dom => $krbdefdom,
                   kerb_def_auth => $krbdef
                   );
-    if (exists($ENV{'form.ipwd_choice'}) &&
-        defined($ENV{'form.ipwd_choice'}) &&
-        $ENV{'form.ipwd_choice'} ne '') {
+    if (exists($env{'form.ipwd_choice'}) &&
+        defined($env{'form.ipwd_choice'}) &&
+        $env{'form.ipwd_choice'} ne '') {
         $param{'curr_authtype'} = 'int';
     }
     my $krbform = &Apache::loncommon::authform_kerberos(%param);
@@ -639,14 +639,14 @@
 
     my $firstLine;
     my $datatoken;
-    if (!$ENV{'form.datatoken'}) {
+    if (!$env{'form.datatoken'}) {
         $datatoken=&Apache::loncommon::upfile_store($r);
     } else {
-        $datatoken=$ENV{'form.datatoken'};
+        $datatoken=$env{'form.datatoken'};
         &Apache::loncommon::load_tmp_file($r);
     }
     my @records=&Apache::loncommon::upfile_record_sep();
-    if($ENV{'form.noFirstLine'}){
+    if($env{'form.noFirstLine'}){
         $firstLine=shift(@records);
     }
     my $total=$#records;
@@ -669,7 +669,7 @@
                            });
     #
     # Determine kerberos parameters as appropriate
-    my $defdom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
+    my $defdom=$env{'course.'.$env{'request.course.id'}.'.domain'};
     my ($krbdef,$krbdefdom) =
         &Apache::loncommon::get_kerberos_defaults($defdom);
     #
@@ -678,17 +678,17 @@
     my $keyfields;
     if ($total>=0) {
         my @field=
-            (['username',&mt('Username'),     $ENV{'form.username_choice'}],
-             ['names',&mt('Last Name, First Names'),$ENV{'form.names_choice'}],
-             ['fname',&mt('First Name'),      $ENV{'form.fname_choice'}],
-             ['mname',&mt('Middle Names/Initials'),$ENV{'form.mname_choice'}],
-             ['lname',&mt('Last Name'),       $ENV{'form.lname_choice'}],
-             ['gen',  &mt('Generation'),      $ENV{'form.gen_choice'}],
-             ['id',   &mt('ID/Student Number'),$ENV{'form.id_choice'}],
-             ['sec',  &mt('Group/Section'),   $ENV{'form.sec_choice'}],
-             ['ipwd', &mt('Initial Password'),$ENV{'form.ipwd_choice'}],
-             ['email',&mt('EMail Address'),   $ENV{'form.email_choice'}]);
-	if ($ENV{'form.upfile_associate'} eq 'reverse') {	
+            (['username',&mt('Username'),     $env{'form.username_choice'}],
+             ['names',&mt('Last Name, First Names'),$env{'form.names_choice'}],
+             ['fname',&mt('First Name'),      $env{'form.fname_choice'}],
+             ['mname',&mt('Middle Names/Initials'),$env{'form.mname_choice'}],
+             ['lname',&mt('Last Name'),       $env{'form.lname_choice'}],
+             ['gen',  &mt('Generation'),      $env{'form.gen_choice'}],
+             ['id',   &mt('ID/Student Number'),$env{'form.id_choice'}],
+             ['sec',  &mt('Group/Section'),   $env{'form.sec_choice'}],
+             ['ipwd', &mt('Initial Password'),$env{'form.ipwd_choice'}],
+             ['email',&mt('EMail Address'),   $env{'form.email_choice'}]);
+	if ($env{'form.upfile_associate'} eq 'reverse') {	
 	    &Apache::loncommon::csv_print_samples($r,\@records);
 	    $i=&Apache::loncommon::csv_print_select_table($r,\@records,
                                                           \@field);
@@ -712,25 +712,25 @@
 sub enroll_single_student {
     my $r=shift;
     # Remove non alphanumeric values from section
-    $ENV{'form.csec'}=~s/\W//g;
+    $env{'form.csec'}=~s/\W//g;
     #
     # We do the dates first because the action of making them the defaul
     # in the course is entirely separate from the action of enrolling the
     # student.  Also, a failure in setting the dates as default is not fatal
     # to the process of enrolling / modifying a student.
     my ($startdate,$enddate) = &get_dates_from_form();
-    if ($ENV{'form.makedatesdefault'}) {
+    if ($env{'form.makedatesdefault'}) {
         $r->print(&make_dates_default($startdate,$enddate));
     }
 
     $r->print('<h3>'.&mt('Enrolling Student').'</h3>');
-    $r->print('<p>'.&mt('Enrolling').' '.$ENV{'form.cuname'}." \@ ".
-              $ENV{'form.lcdomain'}.'</p>');
-    if (($ENV{'form.cuname'})&&($ENV{'form.cuname'}!~/\W/)&&
-        ($ENV{'form.lcdomain'})&&($ENV{'form.lcdomain'}!~/\W/)) {
+    $r->print('<p>'.&mt('Enrolling').' '.$env{'form.cuname'}." \@ ".
+              $env{'form.lcdomain'}.'</p>');
+    if (($env{'form.cuname'})&&($env{'form.cuname'}!~/\W/)&&
+        ($env{'form.lcdomain'})&&($env{'form.lcdomain'}!~/\W/)) {
         # Deal with home server selection
-        my $domain=$ENV{'form.lcdomain'};
-        my $desiredhost = $ENV{'form.lcserver'};
+        my $domain=$env{'form.lcdomain'};
+        my $desiredhost = $env{'form.lcserver'};
         if (lc($desiredhost) eq 'default') {
             $desiredhost = undef;
         } else {
@@ -745,33 +745,33 @@
         # End of home server selection logic
 	my $amode='';
         my $genpwd='';
-        if ($ENV{'form.login'} eq 'krb') {
+        if ($env{'form.login'} eq 'krb') {
            $amode='krb';
-	   $amode.=$ENV{'form.krbver'};
-           $genpwd=$ENV{'form.krbarg'};
-        } elsif ($ENV{'form.login'} eq 'int') {
+	   $amode.=$env{'form.krbver'};
+           $genpwd=$env{'form.krbarg'};
+        } elsif ($env{'form.login'} eq 'int') {
            $amode='internal';
-           $genpwd=$ENV{'form.intarg'};
-        }  elsif ($ENV{'form.login'} eq 'loc') {
+           $genpwd=$env{'form.intarg'};
+        }  elsif ($env{'form.login'} eq 'loc') {
 	    $amode='localauth';
-	    $genpwd=$ENV{'form.locarg'};
+	    $genpwd=$env{'form.locarg'};
 	    if (!$genpwd) { $genpwd=" "; }
 	}
-        my $home = &Apache::lonnet::homeserver($ENV{'form.cuname'},
-                                                   $ENV{'form.lcdomain'});
+        my $home = &Apache::lonnet::homeserver($env{'form.cuname'},
+                                                   $env{'form.lcdomain'});
         if ((($amode) && ($genpwd)) || ($home ne 'no_host')) {
             # Clean out any old roles the student has in this class.
-            &modifystudent($ENV{'form.lcdomain'},$ENV{'form.cuname'},
-                           $ENV{'request.course.id'},$ENV{'form.csec'},
+            &modifystudent($env{'form.lcdomain'},$env{'form.cuname'},
+                           $env{'request.course.id'},$env{'form.csec'},
                             $desiredhost);
             my $login_result = &Apache::lonnet::modifystudent
-                ($ENV{'form.lcdomain'},$ENV{'form.cuname'},
-                 $ENV{'form.cstid'},$amode,$genpwd,
-                 $ENV{'form.cfirst'},$ENV{'form.cmiddle'},
-                 $ENV{'form.clast'},$ENV{'form.cgen'},
-                 $ENV{'form.csec'},$enddate,
-                 $startdate,$ENV{'form.forceid'},
-                 $desiredhost,$ENV{'form.emailaddress'});
+                ($env{'form.lcdomain'},$env{'form.cuname'},
+                 $env{'form.cstid'},$amode,$genpwd,
+                 $env{'form.cfirst'},$env{'form.cmiddle'},
+                 $env{'form.clast'},$env{'form.cgen'},
+                 $env{'form.csec'},$enddate,
+                 $startdate,$env{'form.forceid'},
+                 $desiredhost,$env{'form.emailaddress'});
             if ($login_result =~ /^ok/) {
                 $r->print($login_result);
                 $r->print("<p> ".&mt('If active, the new role will be available when the student next logs in to LON-CAPA.')."</p>");
@@ -785,7 +785,7 @@
             } else {
                 $r->print(&mt('Invalid login mode or password.').'  ');
             }
-            $r->print('<b>'.&mt('Unable to enroll').' '.$ENV{'form.cuname'}.'.</b></p>');
+            $r->print('<b>'.&mt('Unable to enroll').' '.$env{'form.cuname'}.'.</b></p>');
         }
     } else {
         $r->print(&mt('Invalid username or domain'));
@@ -797,9 +797,9 @@
     if (! defined($starttime)) {
         $starttime = time;
         unless ($mode eq 'create_enrolldates' || $mode eq 'create_defaultdates') {
-            if (exists($ENV{'course.'.$ENV{'request.course.id'}.
+            if (exists($env{'course.'.$env{'request.course.id'}.
                             '.default_enrollment_start_date'})) {
-                $starttime = $ENV{'course.'.$ENV{'request.course.id'}.
+                $starttime = $env{'course.'.$env{'request.course.id'}.
                                   '.default_enrollment_start_date'};
             }
         }
@@ -807,9 +807,9 @@
     if (! defined($endtime)) {
         $endtime = time+(6*30*24*60*60); # 6 months from now, approx
         unless ($mode eq 'createcourse') {
-            if (exists($ENV{'course.'.$ENV{'request.course.id'}.
+            if (exists($env{'course.'.$env{'request.course.id'}.
                             '.default_enrollment_end_date'})) {
-                $endtime = $ENV{'course.'.$ENV{'request.course.id'}.
+                $endtime = $env{'course.'.$env{'request.course.id'}.
                                 '.default_enrollment_end_date'};
             }
         }
@@ -842,7 +842,7 @@
 sub get_dates_from_form {
     my $startdate = &Apache::lonhtmlcommon::get_date_from_form('startdate');
     my $enddate   = &Apache::lonhtmlcommon::get_date_from_form('enddate');
-    if ($ENV{'form.no_end_date'}) {
+    if ($env{'form.no_end_date'}) {
         $enddate = 0;
     }
     return ($startdate,$enddate);
@@ -880,8 +880,8 @@
 sub make_dates_default {
     my ($startdate,$enddate) = @_;
     my $result = '';
-    my $dom = $ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
-    my $crs = $ENV{'course.'.$ENV{'request.course.id'}.'.num'};
+    my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+    my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
     my $put_result = &Apache::lonnet::put('environment',
             {'default_enrollment_start_date'=>$startdate,
              'default_enrollment_end_date'  =>$enddate},$dom,$crs);
@@ -889,7 +889,7 @@
         $result .= "Set default start and end dates for course<br />";
         #
         # Refresh the course environment
-        &Apache::lonnet::coursedescription($ENV{'request.course.id'});
+        &Apache::lonnet::coursedescription($env{'request.course.id'});
     } else {
         $result .= &mt('Unable to set default dates for course').":".$put_result.
             '<br />';
@@ -903,7 +903,7 @@
 sub get_student_username_domain_form {
     my $r = shift;
     my $domform = &Apache::loncommon::select_dom_form
-        ($ENV{'course.'.$ENV{'request.course.id'}.'.domain'},'cudomain',0);
+        ($env{'course.'.$env{'request.course.id'}.'.domain'},'cudomain',0);
     my %lt=&Apache::lonlocal::texthash(
 		    'eos'  => "Enroll One Student",
 		    'usr'  => "Username",
@@ -936,8 +936,8 @@
     my $r=shift;
     $r->print("<h3>".&mt('Enroll One Student')."</h3>");
     #
-    my $username = $ENV{'form.cuname'};
-    my $domain   = $ENV{'form.cudomain'};
+    my $username = $env{'form.cuname'};
+    my $domain   = $env{'form.cudomain'};
     $username=~s/\W//gs;
     $domain=~s/\W//gs;
     my $home = &Apache::lonnet::homeserver($username,$domain);
@@ -950,7 +950,7 @@
     my $user_data_html = '';
     my $javascript_validations = '';
     if ($new_user) {
-        my $defdom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
+        my $defdom=$env{'course.'.$env{'request.course.id'}.'.domain'};
         # Set up authentication forms
         my ($krbdef,$krbdefdom) =
             &Apache::loncommon::get_kerberos_defaults($domain);
@@ -1128,7 +1128,7 @@
 sub print_drop_menu {
     my $r=shift;
     $r->print("<h3>".&mt('Drop Students')."</h3>");
-    my $cid=$ENV{'request.course.id'};
+    my $cid=$env{'request.course.id'};
     my ($classlist,$keylist) = &Apache::loncoursedata::get_classlist();
     if (! defined($classlist)) {
         $r->print(&mt('There are no students currently enrolled.')."\n");
@@ -1142,24 +1142,24 @@
 # ============================================== view classlist
 sub print_html_classlist {
     my ($r,$mode) = @_;
-    if (! exists($ENV{'form.sortby'})) {
-        $ENV{'form.sortby'} = 'username';
+    if (! exists($env{'form.sortby'})) {
+        $env{'form.sortby'} = 'username';
     }
-    if ($ENV{'form.Status'} !~ /^(Any|Expired|Active)$/) {
-        $ENV{'form.Status'} = 'Active';
+    if ($env{'form.Status'} !~ /^(Any|Expired|Active)$/) {
+        $env{'form.Status'} = 'Active';
     }
     my $status_select = &Apache::lonhtmlcommon::StatusOptions
-        ($ENV{'form.Status'});
-    my $cid=$ENV{'request.course.id'};
-    my $cdom=$ENV{'course.'.$cid.'.domain'};
-    my $cnum=$ENV{'course.'.$cid.'.num'};
+        ($env{'form.Status'});
+    my $cid=$env{'request.course.id'};
+    my $cdom=$env{'course.'.$cid.'.domain'};
+    my $cnum=$env{'course.'.$cid.'.num'};
     #
     # List course personnel
     my %coursepersonnel=&Apache::lonnet::get_course_adv_roles($cdom.'/'.$cnum);
     #
-    if (! defined($ENV{'form.output'}) ||
-        $ENV{'form.output'} !~ /^(csv|excel|html)$/ ) {
-        $ENV{'form.output'} = 'html';
+    if (! defined($env{'form.output'}) ||
+        $env{'form.output'} !~ /^(csv|excel|html)$/ ) {
+        $env{'form.output'} = 'html';
     }
     #
     $r->print('<br /><table border="2">');
@@ -1179,16 +1179,16 @@
     #
     # Interface output
     $r->print('<input type="hidden" name="action" value="'.
-              $ENV{'form.action'}.'" />');
+              $env{'form.action'}.'" />');
     $r->print("<p>\n");
-    if ($ENV{'form.action'} ne 'modifystudent') {
+    if ($env{'form.action'} ne 'modifystudent') {
 	my %lt=&Apache::lonlocal::texthash('csv' => "CSV",
                                            'excel' => "Excel",
                                            'html'  => 'HTML');
         my $output_selector = '<select size="1" name="output" >';
         foreach my $outputformat ('html','csv','excel') {
             my $option = '<option value="'.$outputformat.'" ';
-            if ($outputformat eq $ENV{'form.output'}) {
+            if ($outputformat eq $env{'form.output'}) {
                 $option .= 'selected ';
             }
             $option .='>'.$lt{$outputformat}.'</option>';
@@ -1208,12 +1208,12 @@
         $r->print(&mt('There are no students currently enrolled.')."\n");
     } else {
         # Print out the available choices
-        if ($ENV{'form.action'} eq 'modifystudent') {
+        if ($env{'form.action'} eq 'modifystudent') {
             &show_class_list($r,'view','modify',
-                             $ENV{'form.Status'},$classlist,$keylist);
+                             $env{'form.Status'},$classlist,$keylist);
         } else {
-            &show_class_list($r,$ENV{'form.output'},'aboutme',
-                             $ENV{'form.Status'},$classlist,$keylist);
+            &show_class_list($r,$env{'form.output'},'aboutme',
+                             $env{'form.Status'},$classlist,$keylist);
         }
     }
 }
@@ -1221,7 +1221,7 @@
 # =================================================== Show student list to drop
 sub show_class_list {
     my ($r,$mode,$linkto,$statusmode,$classlist,$keylist)=@_;
-    my $cid=$ENV{'request.course.id'};
+    my $cid=$env{'request.course.id'};
     #
     # Variables for excel output
     my ($excel_workbook, $excel_sheet, $excel_filename,$row,$format);
@@ -1229,14 +1229,14 @@
     # Variables for csv output
     my ($CSVfile,$CSVfilename);
     #
-    my $sortby = $ENV{'form.sortby'};
+    my $sortby = $env{'form.sortby'};
     if ($sortby !~ /^(username|domain|section|fullname|id|start|end|type)$/) {
         $sortby = 'username';
     }
     # Print out header 
     unless ($mode eq 'autoenroll') {
         $r->print(<<END);
-<input type="hidden" name="state" value="$ENV{'form.state'}" />
+<input type="hidden" name="state" value="$env{'form.state'}" />
 END
     }
     $r->print(<<END);
@@ -1299,7 +1299,7 @@
 	#
 	# Open a file
 	$CSVfilename = '/prtspool/'.
-	    $ENV{'user.name'}.'_'.$ENV{'user.domain'}.'_'.
+	    $env{'user.name'}.'_'.$env{'user.domain'}.'_'.
             time.'_'.rand(1000000000).'.csv';
 	unless ($CSVfile = Apache::File->new('>/home/httpd'.$CSVfilename)) {
 	    $r->log_error("Couldn't open $CSVfilename for output $!");
@@ -1332,7 +1332,7 @@
         $excel_sheet = $excel_workbook->addworksheet('classlist');
         #
         my $description = 'Class List for '.
-            $ENV{'course.'.$ENV{'request.course.id'}.'.description'};
+            $env{'course.'.$env{'request.course.id'}.'.description'};
         $excel_sheet->write($row++,0,$description,$format->{'h1'});
         #
         $excel_sheet->write($row++,0,["username","domain","ID",
@@ -1495,9 +1495,9 @@
     my $r = shift();
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
                                             ['sdom','sname']);    
-    my $sname  = $ENV{'form.sname'};
-    my $sdom   = $ENV{'form.sdom'};
-    my $sortby = $ENV{'form.sortby'};
+    my $sname  = $env{'form.sname'};
+    my $sdom   = $env{'form.sdom'};
+    my $sortby = $env{'form.sortby'};
     # determine the students name information
     my %info=&Apache::lonnet::get('environment',
                                   ['firstname','middlename',
@@ -1543,9 +1543,9 @@
     }
     my $date_table = &date_setting_table($starttime,$endtime);
     #
-    if (! exists($ENV{'form.Status'}) || 
-        $ENV{'form.Status'} !~ /^(Any|Expired|Active)$/) {
-        $ENV{'form.Status'} = 'crap';
+    if (! exists($env{'form.Status'}) || 
+        $env{'form.Status'} !~ /^(Any|Expired|Active)$/) {
+        $env{'form.Status'} = 'crap';
     }
     # Make sure student is enrolled in course
     my %lt=&Apache::lonlocal::texthash(
@@ -1572,7 +1572,7 @@
 <input type="hidden" name="action"  value="modifystudent" />
 <input type="hidden" name="state"   value="done" />
 <input type="hidden" name="sortby"  value="$sortby" />
-<input type="hidden" name="Status"  value="$ENV{'form.Status'}" />
+<input type="hidden" name="Status"  value="$env{'form.Status'}" />
 <h2>$lt{'mef'} $info{'firstname'} $info{'middlename'} 
 $info{'lastname'} $info{'generation'}, $sname\@$sdom</h2>
 <p>
@@ -1608,21 +1608,21 @@
     my $r = shift;
     #
     # Remove non alphanumeric values from the section
-    $ENV{'form.section'} =~ s/\W//g;
+    $env{'form.section'} =~ s/\W//g;
     #
     # Do the date defaults first
     my ($starttime,$endtime) = &get_dates_from_form();
-    if ($ENV{'form.makedatesdefault'}) {
+    if ($env{'form.makedatesdefault'}) {
         $r->print(&make_dates_default($starttime,$endtime));
     }
     # Get the 'sortby' and 'Status' variables so the user goes back to their
     # previous screen
-    my $sortby = $ENV{'form.sortby'};
-    my $status = $ENV{'form.Status'};
+    my $sortby = $env{'form.sortby'};
+    my $status = $env{'form.Status'};
     #
     # We always need this information
-    my $slogin     = $ENV{'form.slogin'};
-    my $sdom       = $ENV{'form.sdomain'};
+    my $slogin     = $env{'form.slogin'};
+    my $sdom       = $env{'form.sdomain'};
     #
     # Get the old data
     my %old=&Apache::lonnet::get('environment',
@@ -1630,7 +1630,7 @@
                                   'lastname','generation','id'],
                                  $sdom, $slogin);
     $old{'section'} = &Apache::lonnet::getsection($sdom,$slogin,
-                                                  $ENV{'request.course.id'});
+                                                  $env{'request.course.id'});
     my ($tmp) = keys(%old);
     if ($tmp =~ /^(con_lost|error|no_such_host)/i) {
         $r->print(&mt('There was an error determining the environment values for')." $slogin \@ $sdom.");
@@ -1639,19 +1639,19 @@
     undef $tmp;
     #
     # Get the new data
-    my $firstname  = $ENV{'form.firstname'};
-    my $middlename = $ENV{'form.middlename'};
-    my $lastname   = $ENV{'form.lastname'};
-    my $generation = $ENV{'form.generation'};
-    my $section    = $ENV{'form.section'};
-    my $courseid   = $ENV{'request.course.id'};
-    my $sid        = $ENV{'form.id'};
+    my $firstname  = $env{'form.firstname'};
+    my $middlename = $env{'form.middlename'};
+    my $lastname   = $env{'form.lastname'};
+    my $generation = $env{'form.generation'};
+    my $section    = $env{'form.section'};
+    my $courseid   = $env{'request.course.id'};
+    my $sid        = $env{'form.id'};
     my $displayable_starttime = localtime($starttime);
     my $displayable_endtime   = localtime($endtime);
     # 
     # check for forceid override
     if ((defined($old{'id'})) && ($old{'id'} ne '') && 
-        ($sid ne $old{'id'}) && (! exists($ENV{'form.forceid'}))) {
+        ($sid ne $old{'id'}) && (! exists($env{'form.forceid'}))) {
         $r->print("<font color=\"ff0000\">".&mt('You changed the students id but did not disable the ID change safeguard. The students id will not be changed.')."</font>");
         $sid = $old{'id'};
     }
@@ -1718,14 +1718,14 @@
     # Send request(s) to modify data (final undef is for 'desiredhost',
     # which is a moot point because the student already has an account.
     my $modify_section_results = &modifystudent($sdom,$slogin,
-                                                $ENV{'request.course.id'},
+                                                $env{'request.course.id'},
                                                 $section,undef);
     if ($modify_section_results !~ /^ok/) {
         $r->print(&mt('An error occured during the attempt to change the section for this student.')."<br />");
     }
     my $roleresults = &Apache::lonnet::modifystudent
         ($sdom,$slogin,$sid,undef,undef,$firstname,$middlename,$lastname,
-         $generation,$section,$endtime,$starttime,$ENV{'form.forceid'});
+         $generation,$section,$endtime,$starttime,$env{'form.forceid'});
     if ($roleresults eq 'refused' ) {
         $r->print(&mt('Your request to change the role information for this student was refused. You do not appear to have sufficient authority to change student information.'));
     } elsif ($roleresults !~ /ok/) {
@@ -1734,7 +1734,7 @@
                   $roleresults);
         &Apache::lonnet::logthis("londropadd:failed attempt to modify student".
                                  " data for ".$slogin." \@ ".$sdom." by ".
-                                 $ENV{'user.name'}." \@ ".$ENV{'user.domain'}.
+                                 $env{'user.name'}." \@ ".$env{'user.domain'}.
                                  ":".$roleresults);
     } else { # everything is okay!
         $r->print(&mt('Student information updated successfully.')." <br />".
@@ -1754,7 +1754,7 @@
 
 sub get_enrollment_data {
     my ($sname,$sdomain) = @_;
-    my $courseid = $ENV{'request.course.id'};
+    my $courseid = $env{'request.course.id'};
     $courseid =~ s:_:/:g;
     my %roles = &Apache::lonnet::dump('roles',$sdomain,$sname);
     my ($tmp) = keys(%roles);
@@ -1813,12 +1813,12 @@
 #################################################
 sub show_drop_list {
     my ($r,$classlist,$keylist,$nosort)=@_;
-    my $cid=$ENV{'request.course.id'};
-    if (! exists($ENV{'form.sortby'})) {
+    my $cid=$env{'request.course.id'};
+    if (! exists($env{'form.sortby'})) {
         &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
                                                 ['sortby']);
     }
-    my $sortby = $ENV{'form.sortby'};
+    my $sortby = $env{'form.sortby'};
     if ($sortby !~ /^(username|domain|section|fullname|id|start|end)$/) {
         $sortby = 'username';
     }
@@ -1987,24 +1987,24 @@
     my $r=shift;
     &Apache::loncommon::load_tmp_file($r);
     my @studentdata=&Apache::loncommon::upfile_record_sep();
-    if($ENV{'form.noFirstLine'}){shift(@studentdata);}
-    my @keyfields = split(/\,/,$ENV{'form.keyfields'});
-    my $cid = $ENV{'request.course.id'};
+    if($env{'form.noFirstLine'}){shift(@studentdata);}
+    my @keyfields = split(/\,/,$env{'form.keyfields'});
+    my $cid = $env{'request.course.id'};
     my %fields=();
-    for (my $i=0; $i<=$ENV{'form.nfields'}; $i++) {
-        if ($ENV{'form.upfile_associate'} eq 'reverse') {
-            if ($ENV{'form.f'.$i} ne 'none') {
-                $fields{$keyfields[$i]}=$ENV{'form.f'.$i};
+    for (my $i=0; $i<=$env{'form.nfields'}; $i++) {
+        if ($env{'form.upfile_associate'} eq 'reverse') {
+            if ($env{'form.f'.$i} ne 'none') {
+                $fields{$keyfields[$i]}=$env{'form.f'.$i};
             }
         } else {
-            $fields{$ENV{'form.f'.$i}}=$keyfields[$i];
+            $fields{$env{'form.f'.$i}}=$keyfields[$i];
         }
     }
     #
     # Store the field choices away
     foreach my $field (qw/username names 
                        fname mname lname gen id sec ipwd email/) {
-        $ENV{'form.'.$field.'_choice'}=$fields{$field};
+        $env{'form.'.$field.'_choice'}=$fields{$field};
     }
     &Apache::loncommon::store_course_settings('enrollment_upload',
                                               { 'username_choice' => 'scalar',
@@ -2020,12 +2020,12 @@
 
     #
     my ($startdate,$enddate) = &get_dates_from_form();
-    if ($ENV{'form.makedatesdefault'}) {
+    if ($env{'form.makedatesdefault'}) {
         $r->print(&make_dates_default($startdate,$enddate));
     }
     # Determine domain and desired host (home server)
-    my $domain=$ENV{'form.lcdomain'};
-    my $desiredhost = $ENV{'form.lcserver'};
+    my $domain=$env{'form.lcdomain'};
+    my $desiredhost = $env{'form.lcserver'};
     if (lc($desiredhost) eq 'default') {
         $desiredhost = undef;
     } else {
@@ -2040,19 +2040,19 @@
     # Determine authentication mechanism
     my $amode  = '';
     my $genpwd = '';
-    if ($ENV{'form.login'} eq 'krb') {
+    if ($env{'form.login'} eq 'krb') {
         $amode='krb';
-	$amode.=$ENV{'form.krbver'};
-        $genpwd=$ENV{'form.krbarg'};
-    } elsif ($ENV{'form.login'} eq 'int') {
+	$amode.=$env{'form.krbver'};
+        $genpwd=$env{'form.krbarg'};
+    } elsif ($env{'form.login'} eq 'int') {
         $amode='internal';
-        if ((defined($ENV{'form.intarg'})) && ($ENV{'form.intarg'})) {
-            $genpwd=$ENV{'form.intarg'};
+        if ((defined($env{'form.intarg'})) && ($env{'form.intarg'})) {
+            $genpwd=$env{'form.intarg'};
         }
-    } elsif ($ENV{'form.login'} eq 'loc') {
+    } elsif ($env{'form.login'} eq 'loc') {
         $amode='localauth';
-        if ((defined($ENV{'form.locarg'})) && ($ENV{'form.locarg'})) {
-            $genpwd=$ENV{'form.locarg'};
+        if ((defined($env{'form.locarg'})) && ($env{'form.locarg'})) {
+            $genpwd=$env{'form.locarg'};
         }
     }
     if ($amode =~ /^krb/) {
@@ -2143,13 +2143,13 @@
                              \$lname,\$gen,\$sec) {
                         $$_ =~ s/(\s+$|^\s+)//g;
                     }
-                    if ($password || $ENV{'form.login'} eq 'loc') {
+                    if ($password || $env{'form.login'} eq 'loc') {
                         &modifystudent($domain,$username,$cid,$sec,
                                        $desiredhost);
                         my $reply=&Apache::lonnet::modifystudent
                             ($domain,$username,$id,$amode,$password,
                              $fname,$mname,$lname,$gen,$sec,$enddate,
-                             $startdate,$ENV{'form.forceid'},$desiredhost,
+                             $startdate,$env{'form.forceid'},$desiredhost,
                              $email);
                         if ($reply ne 'ok') {
                             $reply =~ s/^error://;
@@ -2180,7 +2180,7 @@
         #####################################
         #           Drop students           #
         #####################################
-        if ($ENV{'form.fullup'} eq 'yes') {
+        if ($env{'form.fullup'} eq 'yes') {
             $r->print('<h3>'.&mt('Dropping Students')."</h3>\n");
             #  Get current classlist
             my ($classlist,$keylist)=&Apache::loncoursedata::get_classlist();
@@ -2209,15 +2209,15 @@
     my $r=shift;
     my $count=0;
     my @droplist;
-    if (ref($ENV{'form.droplist'})) {
-        @droplist = @{$ENV{'form.droplist'}};
+    if (ref($env{'form.droplist'})) {
+        @droplist = @{$env{'form.droplist'}};
     } else {
-        @droplist = ($ENV{'form.droplist'});
+        @droplist = ($env{'form.droplist'});
     }
     foreach (@droplist) {
         my ($uname,$udom)=split(/\:/,$_);
         # drop student
-        my $result = &modifystudent($udom,$uname,$ENV{'request.course.id'});
+        my $result = &modifystudent($udom,$uname,$env{'request.course.id'});
         if ($result eq 'ok' || $result eq 'ok:') {
             $r->print(&mt('Dropped [_1]',$uname.'@'.$udom).'<br>');
             $count++;
@@ -2281,49 +2281,47 @@
           text=>"Enrollment Manager",
           faq=>9,bug=>'Instructor Interface',});
     #  Needs to be in a course
-    if (! ($ENV{'request.course.fn'})) {
+    if (! ($env{'request.course.fn'})) {
         # Not in a course
-        $ENV{'user.error.msg'}=
+        $env{'user.error.msg'}=
             "/adm/dropadd:cst:0:0:Cannot drop or add students";
         return HTTP_NOT_ACCEPTABLE; 
     }
     #
     my $view_permission = 
-        &Apache::lonnet::allowed('vcl',$ENV{'request.course.id'});
+        &Apache::lonnet::allowed('vcl',$env{'request.course.id'});
     my $enrl_permission = 
-        &Apache::lonnet::allowed('cst',$ENV{'request.course.id'});
+        &Apache::lonnet::allowed('cst',$env{'request.course.id'});
     if (! $view_permission && ! $enrl_permission) {
-        $ENV{'user.error.msg'}=
+        $env{'user.error.msg'}=
             "/adm/dropadd:cst:0:0:Cannot drop or add students";
         return HTTP_NOT_ACCEPTABLE;        
     }
     #
     # Only output the header information if they did not request csv format
     #
-    &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
-                                            ['state','action']);
     # Start page
     &Apache::loncommon::content_type($r,'text/html');
     $r->send_http_header;
     $r->print(&header());
     #
     # Main switch on form.action and form.state, as appropriate
-    if (! exists($ENV{'form.action'})) {
+    if (! exists($env{'form.action'})) {
         $r->print(&Apache::lonhtmlcommon::breadcrumbs
                   (undef,'Enrollment Manager'));
         &print_main_menu($r,$enrl_permission,$view_permission);
-    } elsif ($ENV{'form.action'} eq 'upload' && $enrl_permission) {
+    } elsif ($env{'form.action'} eq 'upload' && $enrl_permission) {
         &Apache::lonhtmlcommon::add_breadcrumb
             ({href=>'/adm/dropadd?action=upload&state=',
               text=>"Upload Classlist"});
         $r->print(&Apache::lonhtmlcommon::breadcrumbs
                   (undef,'Upload Classlist','Course_Create_Class_List'));
-        if (! exists($ENV{'form.state'})) {
+        if (! exists($env{'form.state'})) {
             &print_first_courselist_upload_form($r);            
-        } elsif ($ENV{'form.state'} eq 'got_file') {
+        } elsif ($env{'form.state'} eq 'got_file') {
             &print_upload_manager_form($r);
-        } elsif ($ENV{'form.state'} eq 'enrolling') {
-            if ($ENV{'form.datatoken'}) {
+        } elsif ($env{'form.state'} eq 'enrolling') {
+            if ($env{'form.datatoken'}) {
                 &upfile_drop_add($r);
             } else {
                 # Hmmm, this is an error
@@ -2331,60 +2329,60 @@
         } else {
             &print_first_courselist_upload_form($r);            
         }
-    } elsif ($ENV{'form.action'} eq 'drop' && $enrl_permission) {
+    } elsif ($env{'form.action'} eq 'drop' && $enrl_permission) {
         &Apache::lonhtmlcommon::add_breadcrumb
             ({href=>'/adm/dropadd?action=drop',
               text=>"Drop Students"});
         $r->print(&Apache::lonhtmlcommon::breadcrumbs
                   (undef,'Drop Students','Course_Drop_Student'));
-        if (! exists($ENV{'form.state'})) {
+        if (! exists($env{'form.state'})) {
             &print_drop_menu($r);
-        } elsif ($ENV{'form.state'} eq 'done') {
+        } elsif ($env{'form.state'} eq 'done') {
             &drop_student_list($r);
         } else {
             &print_drop_menu($r);
         }
-    } elsif ($ENV{'form.action'} eq 'enrollstudent' && $enrl_permission) {
+    } elsif ($env{'form.action'} eq 'enrollstudent' && $enrl_permission) {
         &Apache::lonhtmlcommon::add_breadcrumb
             ({href=>'/adm/dropadd?action=enrollstudent',
               text=>"Enroll Student"});
         $r->print(&Apache::lonhtmlcommon::breadcrumbs
                   (undef,'Enroll Student','Course_Add_Student'));
-        if (! exists($ENV{'form.state'})) {
+        if (! exists($env{'form.state'})) {
             &get_student_username_domain_form($r);
-        } elsif ($ENV{'form.state'} eq 'gotusername') {
+        } elsif ($env{'form.state'} eq 'gotusername') {
             &print_enroll_single_student_form($r);
-        } elsif ($ENV{'form.state'} eq 'enrolling') {
+        } elsif ($env{'form.state'} eq 'enrolling') {
             &enroll_single_student($r);
         } else {
             &get_student_username_domain_form($r);
         }
-    } elsif ($ENV{'form.action'} eq 'classlist' && $view_permission) {
+    } elsif ($env{'form.action'} eq 'classlist' && $view_permission) {
         &Apache::lonhtmlcommon::add_breadcrumb
             ({href=>'/adm/dropadd?action=classlist',
               text=>"View Classlist"});
         $r->print(&Apache::lonhtmlcommon::breadcrumbs
                   (undef,'View Classlist','Course_View_Class_List'));
-        if (! exists($ENV{'form.state'})) {
+        if (! exists($env{'form.state'})) {
             &print_html_classlist($r,undef);
-        } elsif ($ENV{'form.state'} eq 'csv') {
+        } elsif ($env{'form.state'} eq 'csv') {
             &print_html_classlist($r,'csv');
-        } elsif ($ENV{'form.state'} eq 'excel') {
+        } elsif ($env{'form.state'} eq 'excel') {
             &print_html_classlist($r,'excel');
         } else {
             &print_html_classlist($r,undef);
         }
-    } elsif ($ENV{'form.action'} eq 'modifystudent' && $enrl_permission) {
+    } elsif ($env{'form.action'} eq 'modifystudent' && $enrl_permission) {
         &Apache::lonhtmlcommon::add_breadcrumb
             ({href=>'/adm/dropadd?action=modifystudent',
               text=>"Modify Student Data"});
         $r->print(&Apache::lonhtmlcommon::breadcrumbs
                   (undef,'Modify Student Data','Course_Modify_Student_Data'));
-        if (! exists($ENV{'form.state'})) {
+        if (! exists($env{'form.state'})) {
             &print_html_classlist($r);
-        } elsif ($ENV{'form.state'} eq 'selected') {
+        } elsif ($env{'form.state'} eq 'selected') {
             &print_modify_student_form($r);
-        } elsif ($ENV{'form.state'} eq 'done') {
+        } elsif ($env{'form.state'} eq 'done') {
             &modify_single_student($r);
         } else {
             &print_html_classlist($r);
@@ -2392,7 +2390,7 @@
     } else {
         # We should not end up here, but I guess it is possible
         &Apache::lonnet::logthis("Undetermined state in londropadd.pm.  ".
-                                 "form.action = ".$ENV{'form.action'}.
+                                 "form.action = ".$env{'form.action'}.
                                  "Someone should fix this.");
         $r->print(&Apache::lonhtmlcommon::breadcrumbs
                   (undef,'Enrollment Manager'));
Index: loncom/interface/lonerrorhandler.pm
diff -u loncom/interface/lonerrorhandler.pm:1.6 loncom/interface/lonerrorhandler.pm:1.7
--- loncom/interface/lonerrorhandler.pm:1.6	Thu Feb 17 03:50:20 2005
+++ loncom/interface/lonerrorhandler.pm	Thu Apr  7 02:56:23 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Internal Server Error Handler
 #
-# $Id: lonerrorhandler.pm,v 1.6 2005/02/17 08:50:20 albertel Exp $
+# $Id: lonerrorhandler.pm,v 1.7 2005/04/07 06:56:23 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -31,6 +31,7 @@
 use strict;
 use Apache::Constants qw(:common);
 use Apache::loncommon;
+use Apache::lonnet;
 
 sub handler {
     my $r = shift;
@@ -42,7 +43,10 @@
      my $envkey;
      my $env='';
  
-     foreach $envkey (sort keys %ENV) {
+     foreach $envkey (sort(keys(%env))) {
+ 	$env.="$envkey: $env{$envkey}\n";
+     }
+     foreach $envkey (sort(keys(%ENV))) {
  	$env.="$envkey: $ENV{$envkey}\n";
      }
 
Index: loncom/interface/lonevaluate.pm
diff -u loncom/interface/lonevaluate.pm:1.16 loncom/interface/lonevaluate.pm:1.17
--- loncom/interface/lonevaluate.pm:1.16	Thu Feb 17 03:50:20 2005
+++ loncom/interface/lonevaluate.pm	Thu Apr  7 02:56:23 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Evaluate
 #
-# $Id: lonevaluate.pm,v 1.16 2005/02/17 08:50:20 albertel Exp $
+# $Id: lonevaluate.pm,v 1.17 2005/04/07 06:56:23 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -25,20 +25,11 @@
 #
 # http://www.lon-capa.org/
 #
-# (Internal Server Error Handler
-#
-# (Login Screen
-# 5/21/99,5/22,5/25,5/26,5/31,6/2,6/10,7/12,7/14,
-# 1/14/00,5/29,5/30,6/1,6/29,7/1,11/9 Gerd Kortemeyer)
-#
-# 3/1/1 Gerd Kortemeyer)
-#
-# 3/1,12/6,12/12,12/21,12/22 Gerd Kortemeyer
-#
+
 package Apache::lonevaluate;
 
 use strict;
-use Apache::lonnet();
+use Apache::lonnet;
 use Apache::Constants qw(:common);
 use Apache::loncommon();
 use Apache::lonenc();
@@ -50,7 +41,7 @@
     return OK if $r->header_only;
 
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['postdata']);
-    my $feedurl=$ENV{'form.postdata'};
+    my $feedurl=$env{'form.postdata'};
     $feedurl=~s/^http\:\/\///;
     $feedurl=~s/^$ENV{'SERVER_NAME'}//;
     $feedurl=~s/^$ENV{'HTTP_HOST'}//;
@@ -62,7 +53,7 @@
 
     my ($rdomain,$rauth)=($feedurl=~/^(\w+)\/(\w+)\//);
 
-    my $prefix=$ENV{'user.name'}.'@'.$ENV{'user.domain'}.'___'.
+    my $prefix=$env{'user.name'}.'@'.$env{'user.domain'}.'___'.
 	$feedurl.'___';
 
     my @items=('correct','helpful','depth','clear','technical','comments',
@@ -75,18 +66,18 @@
 
     my $already=($currenteval{$prefix.'timestamp'} ne '');
 
-    $ENV{'form.timestamp'}=time;
+    $env{'form.timestamp'}=time;
 
     my $warning='';
 
     my $bodytag=&Apache::loncommon::bodytag('Evaluate Resource');
 
-    if ($ENV{'form.submiteval'} eq 'true') {
+    if ($env{'form.submiteval'} eq 'true') {
 # ------------------------------------------------ User is submitting something
         my $complete=1;
 	foreach my $item (@items) {
-	    if ($ENV{'form.'.$item}) {
-		$currenteval{$prefix.$item}=$ENV{'form.'.$item};
+	    if ($env{'form.'.$item}) {
+		$currenteval{$prefix.$item}=$env{'form.'.$item};
             } elsif ($item ne 'comments') {
                 $complete=0;
             }
Index: loncom/interface/lonfeedback.pm
diff -u loncom/interface/lonfeedback.pm:1.156 loncom/interface/lonfeedback.pm:1.157
--- loncom/interface/lonfeedback.pm:1.156	Wed Mar 23 17:14:01 2005
+++ loncom/interface/lonfeedback.pm	Thu Apr  7 02:56:23 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Feedback
 #
-# $Id: lonfeedback.pm,v 1.156 2005/03/23 22:14:01 albertel Exp $
+# $Id: lonfeedback.pm,v 1.157 2005/04/07 06:56:23 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -35,6 +35,7 @@
 use Apache::loncommon();
 use Apache::lontexconvert();
 use Apache::lonlocal; # must not have ()
+use Apache::lonnet;
 use Apache::lonhtmlcommon();
 use Apache::lonnavmaps;
 use Apache::lonenc();
@@ -61,7 +62,7 @@
     if (not &discussion_open($status)) {
 	my $hidden=&Apache::lonnet::EXT('resource.0.discusshide');
 	if (lc($hidden) eq 'yes' or $hidden eq '' or !defined($hidden))  {
-	    if (!$ENV{'request.role.adv'}) { return 0; }
+	    if (!$env{'request.role.adv'}) { return 0; }
 	}
     }
     return 1;
@@ -69,9 +70,9 @@
 
 sub list_discussion {
     my ($mode,$status,$ressymb,$imsextras)=@_;
-    my $outputtarget=$ENV{'form.grade_target'};
-    if (defined($ENV{'form.export'})) {
-	if($ENV{'form.export'}) {
+    my $outputtarget=$env{'form.grade_target'};
+    if (defined($env{'form.export'})) {
+	if($env{'form.export'}) {
             $outputtarget = 'export';
         }
     }
@@ -84,11 +85,11 @@
     my @bgcols = ("#cccccc","#eeeeee");
     my $discussiononly=0;
     if ($mode eq 'board') { $discussiononly=1; }
-    unless ($ENV{'request.course.id'}) { return ''; }
-    my $crs='/'.$ENV{'request.course.id'};
-    my $cid=$ENV{'request.course.id'};
-    if ($ENV{'request.course.sec'}) {
-	$crs.='_'.$ENV{'request.course.sec'};
+    unless ($env{'request.course.id'}) { return ''; }
+    my $crs='/'.$env{'request.course.id'};
+    my $cid=$env{'request.course.id'};
+    if ($env{'request.course.sec'}) {
+	$crs.='_'.$env{'request.course.sec'};
     }
     $crs=~s/\_/\//g;
     unless ($ressymb) {	$ressymb=&Apache::lonnet::symbread(); }
@@ -112,7 +113,7 @@
     my $toggkey = $ressymb.'_readtoggle';
     my $readkey = $ressymb.'_read';
     $ressymb=$encsymb;
-    my %dischash = &Apache::lonnet::get('nohist_'.$ENV{'request.course.id'}.'_discuss',[$lastkey,$showkey,$markkey,$visitkey,$ondispkey,$userpickkey,$toggkey,$readkey],$ENV{'user.domain'},$ENV{'user.name'});
+    my %dischash = &Apache::lonnet::get('nohist_'.$env{'request.course.id'}.'_discuss',[$lastkey,$showkey,$markkey,$visitkey,$ondispkey,$userpickkey,$toggkey,$readkey],$env{'user.domain'},$env{'user.name'});
     my %discinfo = ();
     my $showonlyunread = 0;
     my $showunmark = 0; 
@@ -125,22 +126,22 @@
 
 # Retain identification of "NEW" posts identified in last display, if continuing 'previous' browsing of posts.
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['previous','sortposts','rolefilter','statusfilter','sectionpick','totposters']);
-    my $sortposts = $ENV{'form.sortposts'};
-    my $statusfilter = $ENV{'form.statusfilter'};
+    my $sortposts = $env{'form.sortposts'};
+    my $statusfilter = $env{'form.statusfilter'};
     my @sectionpick = ();
-    if ($ENV{'form.sectionpick'} =~ /,/) {
-        @sectionpick = split/,/,$ENV{'form.sectionpick'};
+    if ($env{'form.sectionpick'} =~ /,/) {
+        @sectionpick = split/,/,$env{'form.sectionpick'};
     } else {
-        $sectionpick[0] = $ENV{'form.sectionpick'};
+        $sectionpick[0] = $env{'form.sectionpick'};
     }
     my @rolefilter = ();
-    if ($ENV{'form.rolefilter'} =~ /,/) {
-        @rolefilter = split/,/,$ENV{'form.rolefilter'};
+    if ($env{'form.rolefilter'} =~ /,/) {
+        @rolefilter = split/,/,$env{'form.rolefilter'};
     } else {
-        $rolefilter[0] = $ENV{'form.rolefilter'};
+        $rolefilter[0] = $env{'form.rolefilter'};
     }
-    my $totposters = $ENV{'form.totposters'};
-    $previous = $ENV{'form.previous'};
+    my $totposters = $env{'form.totposters'};
+    $previous = $env{'form.previous'};
     if ($previous > 0) {
         $prevread = $previous;
     } elsif (defined($dischash{$lastkey})) {
@@ -152,8 +153,8 @@
 # Get information about students and non-students in course for filtering display of posts
     my %roleshash = ();
     my %roleinfo = ();
-    if ($ENV{'form.rolefilter'}) {
-        %roleshash = &Apache::lonnet::dump('nohist_userroles',$ENV{'course.'.$ENV{'request.course.id'}.'.domain'},$ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+    if ($env{'form.rolefilter'}) {
+        %roleshash = &Apache::lonnet::dump('nohist_userroles',$env{'course.'.$env{'request.course.id'}.'.domain'},$env{'course.'.$env{'request.course.id'}.'.num'});
         foreach (keys %roleshash) {
             my ($role,$uname,$udom,$sec) = split/:/,$_;
             if ($role =~ /^cr/) {
@@ -170,9 +171,9 @@
             }
         }
         my ($classlist) = &Apache::loncoursedata::get_classlist(
-                              $ENV{'request.course.id'},
-                              $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
-                              $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+                              $env{'request.course.id'},
+                              $env{'course.'.$env{'request.course.id'}.'.domain'},
+                              $env{'course.'.$env{'request.course.id'}.'.num'});
         my $sec_index = &Apache::loncoursedata::CL_SECTION();
         my $status_index = &Apache::loncoursedata::CL_STATUS();
         while (my ($student,$data) = each %$classlist) {
@@ -183,10 +184,10 @@
     }
 
 # Get discussion display default settings for user
-    if ($ENV{'environment.discdisplay'} eq 'unread') {
+    if ($env{'environment.discdisplay'} eq 'unread') {
         $showonlyunread = 1;
     }
-    if ($ENV{'environment.discmarkread'} eq 'ondisp') {
+    if ($env{'environment.discmarkread'} eq 'ondisp') {
         $markondisp = 1;
     }
 
@@ -236,15 +237,15 @@
     my $maxdepth=0;
 
     my $target='';
-    unless ($ENV{'browser.interface'} eq 'textual' ||
-	    $ENV{'environment.remote'} eq 'off' ) {
+    unless ($env{'browser.interface'} eq 'textual' ||
+	    $env{'environment.remote'} eq 'off' ) {
 	$target='target="LONcom"';
     }
 
     my $now = time;
     $discinfo{$visitkey} = $visit;
 
-    &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',\%discinfo,$ENV{'user.domain'},$ENV{'user.name'});
+    &Apache::lonnet::put('nohist_'.$env{'request.course.id'}.'_discuss',\%discinfo,$env{'user.domain'},$env{'user.name'});
     &build_posting_display(\%usernamesort,\%subjectsort,\%namesort,\%notshown,\%newitem,\%dischash,\%shown,\%alldiscussion,\%imsitems,\%imsfiles,\%roleinfo,\@discussionitems,\@replies,\@depth,\@posters,\$maxdepth,\$visible,\$newpostsflag,\$current,$status,$viewgrades,$seeid,$prevread,$sortposts,$encsymb,$target,$readkey,$showunmark,$showonlyunread,$totposters,\@rolefilter,\@sectionpick,$statusfilter,$toggkey,$outputtarget);
 
     my $discussion='';
@@ -256,7 +257,7 @@
 
     my $function = &Apache::loncommon::get_users_function();
     my $color = &Apache::loncommon::designparm($function.'.tabbg',
-                                                    $ENV{'user.domain'});
+                                                    $env{'user.domain'});
     my %lt = &Apache::lonlocal::texthash(
         'cuse' => 'Current discussion settings',
         'allposts' => 'All posts',
@@ -348,7 +349,7 @@
                 if (!-e $tempexport) {
                     mkdir($tempexport,0700);
                 }
-                $tempexport .= '/'.$ENV{'user.domain'}.'_'.$ENV{'user.name'};
+                $tempexport .= '/'.$env{'user.domain'}.'_'.$env{'user.name'};
             }
             if (!-e $tempexport) {
                 mkdir($tempexport,0700);
@@ -472,7 +473,7 @@
         my $currdepth = 0;
         my $firstidx = $alldiscussion{$showposts[0]};
         foreach (@showposts) {
-            unless (($sortposts eq 'thread') || (($sortposts eq '') && ($ENV{'environment.threadeddiscussion'})) || ($outputtarget eq 'export')) {
+            unless (($sortposts eq 'thread') || (($sortposts eq '') && ($env{'environment.threadeddiscussion'})) || ($outputtarget eq 'export')) {
                 $alldiscussion{$_} = $_;
             }
             unless ( ($notshown{$alldiscussion{$_}} eq '1') || ($shown{$alldiscussion{$_}} == 0) ) {
@@ -584,7 +585,7 @@
                 &sort_filter_names(\%sort_types,\%role_types,\%status_types);
 
                 $discussion .= '<td><font size="-1"><b>'.&mt('Sorted by').'</b>: '.$sort_types{$sortposts}.'<br />';
-                if (defined($ENV{'form.totposters'})) {
+                if (defined($env{'form.totposters'})) {
                     $discussion .= &mt('Posts by').':';
                     if ($totposters > 0) {
                         foreach my $poster (@posters) {
@@ -598,7 +599,7 @@
                 } else {
                     my $filterchoice ='';
                     if (@sectionpick > 0) {
-                        $filterchoice = '<i>'.&mt('sections').'</i>-&nbsp;'.$ENV{'form.sectionpick'};
+                        $filterchoice = '<i>'.&mt('sections').'</i>-&nbsp;'.$env{'form.sectionpick'};
                         $filterchoice .= '&nbsp;&nbsp;&nbsp; ';
                     }
                     if (@rolefilter > 0) {
@@ -657,20 +658,14 @@
 #Create zip file in prtspool
 
                     my $imszipfile = '/prtspool/'.
-                    $ENV{'user.name'}.'_'.$ENV{'user.domain'}.'_'.
+                    $env{'user.name'}.'_'.$env{'user.domain'}.'_'.
                          time.'_'.rand(1000000000).'.zip';
-    # zip can cause an sh launch which can pass along all of %ENV
-    # which can be too large for /bin/sh to handle
-                    my %oldENV=%ENV;
-                    undef(%ENV);
                     my $cwd = &getcwd(); 
                     my $imszip = '/home/httpd/'.$imszipfile;
                     chdir $tempexport;
                     open(OUTPUT, "zip -r $imszip *  2> /dev/null |");
                     close(OUTPUT);
                     chdir $cwd;
-                    %ENV=%oldENV;
-                    undef(%oldENV);
                     $discussion .= 'Download the zip file from <a href="'.$imszipfile.'">Discussion Posting Archive</a><br />';
                     if ($copyresult) {
                         $discussion .= 'The following errors occurred during export - <br />'.$copyresult;
@@ -690,10 +685,10 @@
         my @currdelold = ();
         my $comment = '';
         my $subject = '';
-        if ($ENV{'form.origpage'}) {
+        if ($env{'form.origpage'}) {
             &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['addnewattach','deloldattach','delnewattach','timestamp','idx','subject','comment']);
-            $subject = &Apache::lonnet::unescape($ENV{'form.subject'});
-            $comment = &Apache::lonnet::unescape($ENV{'form.comment'});
+            $subject = &Apache::lonnet::unescape($env{'form.subject'});
+            $comment = &Apache::lonnet::unescape($env{'form.comment'});
             my @keepold = ();
             &process_attachments(\@currnewattach,\@currdelold,\@keepold);
             if (@currnewattach > 0) {
@@ -714,8 +709,8 @@
 <b>Title:</b>&nbsp;<input type="text" name="subject" value="$subject" size="30" /><br /><br />
 <textarea name="comment" cols="80" rows="14" wrap="hard">$comment</textarea>
 ENDDISCUSS
-            if ($ENV{'form.origpage'}) {
-                $discussion.='<input type="hidden" name="origpage" value="'.$ENV{'form.origpage'}.'" />'."\n";
+            if ($env{'form.origpage'}) {
+                $discussion.='<input type="hidden" name="origpage" value="'.$env{'form.origpage'}.'" />'."\n";
                 foreach (@currnewattach) {
                     $discussion.='<input type="hidden" name="currnewattach" value="'.$_.'" />'."\n";
                 }
@@ -744,8 +739,8 @@
     } else {
         if (&discussion_open($status) &&
             &Apache::lonnet::allowed('pch',
-    	        $ENV{'request.course.id'}.
-	        ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) {
+    	        $env{'request.course.id'}.
+	        ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) {
 	    if ($outputtarget ne 'tex') {
 		$discussion.='<table bgcolor="#BBBBBB"><tr><td><a href="/adm/feedback?replydisc='.
 		    $ressymb.':::" '.$target.'>'.
@@ -762,9 +757,9 @@
     my @original=();
     my @index=();
     my $symb=&Apache::lonenc::check_decrypt($ressymb);
-    my %contrib=&Apache::lonnet::restore($symb,$ENV{'request.course.id'},
-			  $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
-			  $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+    my %contrib=&Apache::lonnet::restore($symb,$env{'request.course.id'},
+			  $env{'course.'.$env{'request.course.id'}.'.domain'},
+			  $env{'course.'.$env{'request.course.id'}.'.num'});
 
     if ($contrib{'version'}) {
         my $oldest = $contrib{'1:timestamp'};
@@ -788,7 +783,7 @@
 	    my $origindex='0.';
             my $numoldver=0;
 	    if ($contrib{$idx.':replyto'}) {
-                if ( (($ENV{'environment.threadeddiscussion'}) && ($sortposts eq '')) || ($sortposts eq 'thread') || ($outputtarget eq 'export')) {
+                if ( (($env{'environment.threadeddiscussion'}) && ($sortposts eq '')) || ($sortposts eq 'thread') || ($outputtarget eq 'export')) {
 # this is a follow-up message
 		    $original[$idx]=$original[$contrib{$idx.':replyto'}];
 		    $$depth[$idx]=$$depth[$contrib{$idx.':replyto'}]+1;
@@ -896,8 +891,8 @@
                             } else {
                                 @{$$namesort{$lastname}{$firstname}} = ("$idx");
                             }
-                            if ($ENV{'course.'.$ENV{'request.course.id'}.'.allow_discussion_post_editing'} =~ m/yes/i) {
-                                if (($ENV{'user.domain'} eq $contrib{$idx.':senderdomain'}) && ($ENV{'user.name'} eq $contrib{$idx.':sendername'})) {
+                            if ($env{'course.'.$env{'request.course.id'}.'.allow_discussion_post_editing'} =~ m/yes/i) {
+                                if (($env{'user.domain'} eq $contrib{$idx.':senderdomain'}) && ($env{'user.name'} eq $contrib{$idx.':sendername'})) {
                                     $sender.=' <a href="/adm/feedback?editdisc='.
                                          $ressymb.':::'.$idx;
                                     if ($newpostsflag) {
@@ -960,8 +955,8 @@
 		        }
 		        if (&discussion_open($status) &&
 			        &Apache::lonnet::allowed('pch',
-						 $ENV{'request.course.id'}.
-						 ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) {
+						 $env{'request.course.id'}.
+						 ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) {
 			    $sender.=' <a href="/adm/feedback?replydisc='.
 			            $ressymb.':::'.$idx;
                             if ($newpostsflag) {
@@ -983,7 +978,7 @@
                 }
                 if ($outputtarget eq 'export' || $message) {
 		    my $thisindex=$idx;
-		    if ( (($ENV{'environment.threadeddiscussion'}) && ($sortposts eq '')) || ($sortposts eq 'thread') || ($outputtarget eq 'export')) {
+		    if ( (($env{'environment.threadeddiscussion'}) && ($sortposts eq '')) || ($sortposts eq 'thread') || ($outputtarget eq 'export')) {
 			$thisindex=$origindex.substr('00'.$$replies[$$depth[$idx]],-2,2);
 		    }
 		    $$alldiscussion{$thisindex}=$idx;
@@ -1024,7 +1019,7 @@
                             my $uname = $contrib{$idx.':sendername'};
                             my $udom = $contrib{$idx.':senderdomain'};
                             my $poster = $uname.':'.$udom;
-                            if (defined($ENV{'form.totposters'})) {
+                            if (defined($env{'form.totposters'})) {
                                 if ($totposters == 0) {
                                     $$shown{$idx} = 0;
                                 } elsif ($totposters > 0) {
@@ -1292,7 +1287,7 @@
 
 sub mail_screen {
   my ($r,$feedurl,$options) = @_;
-  if (exists($ENV{'form.origpage'})) {
+  if (exists($env{'form.origpage'})) {
       &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['subject','comment','currnewattach','addnewattach','deloldattach','delnewattach','timestamp','idx','anondiscuss','discuss']);
   }
   my $bodytag=&Apache::loncommon::bodytag('Resource Feedback and Discussion',
@@ -1326,11 +1321,11 @@
    }
 END
   my $anonscript;
-  if (exists($ENV{'form.origpage'})) {
+  if (exists($env{'form.origpage'})) {
       $anonscript = (<<END);
   function setposttype() {
-      var anondisc = $ENV{'form.anondiscuss'};
-      var disc = $ENV{'form.discuss'};
+      var anondisc = $env{'form.anondiscuss'};
+      var disc = $env{'form.discuss'};
       if (anondisc == 1) {
           document.mailform.anondiscuss.checked = true
       }
@@ -1347,15 +1342,15 @@
   }
 END
   }
-  if (($ENV{'form.replydisc'}) || ($ENV{'form.editdisc'})) {
-      if ($ENV{'form.replydisc'}) {
-          ($symb,$idx)=split(/\:\:\:/,$ENV{'form.replydisc'});
+  if (($env{'form.replydisc'}) || ($env{'form.editdisc'})) {
+      if ($env{'form.replydisc'}) {
+          ($symb,$idx)=split(/\:\:\:/,$env{'form.replydisc'});
       } else {
-          ($symb,$idx)=split(/\:\:\:/,$ENV{'form.editdisc'});
+          ($symb,$idx)=split(/\:\:\:/,$env{'form.editdisc'});
       }
-      my %contrib=&Apache::lonnet::restore($symb,$ENV{'request.course.id'},
-					   $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
-					   $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+      my %contrib=&Apache::lonnet::restore($symb,$env{'request.course.id'},
+					   $env{'course.'.$env{'request.course.id'}.'.domain'},
+					   $env{'course.'.$env{'request.course.id'}.'.num'});
       unless (($contrib{'hidden'}=~/\.$idx\./) || ($contrib{'deleted'}=~/\.$idx\./)) {
           if ($contrib{$idx.':history'}) {
               if ($contrib{$idx.':history'} =~ /:/) {
@@ -1365,7 +1360,7 @@
                   $numoldver = 1;
               }
           }
-          if ($ENV{'form.replydisc'}) {
+          if ($env{'form.replydisc'}) {
               if ($contrib{$idx.':history'}) {
                   if ($contrib{$idx.':history'} =~ /:/) {
                       my @oldversions = split/:/,$contrib{$idx.':history'};
@@ -1401,7 +1396,7 @@
               if (defined($contrib{$idx.':replyto'})) {
                   $parentmsg = $contrib{$idx.':replyto'};
               }
-              unless (exists($ENV{'form.origpage'})) {
+              unless (exists($env{'form.origpage'})) {
                   my $anonflag = 0;
                   if ($contrib{$idx.':anonymous'}) {
                       $anonflag = 1;
@@ -1423,14 +1418,14 @@
               }
           }
       }
-      if ($ENV{'form.previous'}) {
-          $prevtag = '<input type="hidden" name="previous" value="'.$ENV{'form.previous'}.'" />';
+      if ($env{'form.previous'}) {
+          $prevtag = '<input type="hidden" name="previous" value="'.$env{'form.previous'}.'" />';
       }
   }
 
-  if ($ENV{'form.origpage'}) {
-      $subject = &Apache::lonnet::unescape($ENV{'form.subject'});
-      $comment = &Apache::lonnet::unescape($ENV{'form.comment'});
+  if ($env{'form.origpage'}) {
+      $subject = &Apache::lonnet::unescape($env{'form.subject'});
+      $comment = &Apache::lonnet::unescape($env{'form.comment'});
       &process_attachments(\@currnewattach,\@currdelold,\@keepold);
   }
   my $latexHelp=&Apache::loncommon::helpLatexCheatsheet();
@@ -1499,13 +1494,13 @@
 $prevtag
 <input type="hidden" name="postdata" value="$feedurl" />
 END
-  if ($ENV{'form.replydisc'}) {
+  if ($env{'form.replydisc'}) {
       $r->print(<<END);
-<input type="hidden" name="replydisc" value="$ENV{'form.replydisc'}" />
+<input type="hidden" name="replydisc" value="$env{'form.replydisc'}" />
 END
-  } elsif ($ENV{'form.editdisc'}) {
+  } elsif ($env{'form.editdisc'}) {
      $r->print(<<END);
-<input type="hidden" name="editdisc" value ="$ENV{'form.editdisc'}" />
+<input type="hidden" name="editdisc" value ="$env{'form.editdisc'}" />
 <input type="hidden" name="parentmsg" value ="$parentmsg" />
 END
   }
@@ -1522,8 +1517,8 @@
 </textarea></p>
 <p>
 END
-    if ( ($ENV{'form.editdisc'}) || ($ENV{'form.replydisc'}) ) {
-        if ($ENV{'form.origpage'}) {
+    if ( ($env{'form.editdisc'}) || ($env{'form.replydisc'}) ) {
+        if ($env{'form.origpage'}) {
             foreach (@currnewattach) {
                 $r->print('<input type="hidden" name="currnewattach" value="'.$_.'" />'."\n");
             }
@@ -1531,7 +1526,7 @@
                 $r->print('<input type="hidden" name="deloldattach" value="'.$_.'" />'."\n");
             }
         }
-        if ($ENV{'form.editdisc'}) {
+        if ($env{'form.editdisc'}) {
             if ($attachmenturls) {
                 &extract_attachments($attachmenturls,$idx,$numoldver,\$attachmsg,\%attachments,\%currattach,\@currdelold);
                 $attachnum = scalar(keys %currattach);
@@ -1553,11 +1548,11 @@
 </p>
 </form>
 END
-    if ($ENV{'form.editdisc'} || $ENV{'form.replydisc'}) {
+    if ($env{'form.editdisc'} || $env{'form.replydisc'}) {
         my $now = time;
         my $ressymb = $symb;
         my $postidx = '';
-        if ($ENV{'form.editdisc'}) {
+        if ($env{'form.editdisc'}) {
             $postidx = $idx;
         }
         if (@currnewattach > 0) {
@@ -1599,7 +1594,7 @@
 
     my $function = &Apache::loncommon::get_users_function();
     my $tabcolor = &Apache::loncommon::designparm($function.'.tabbg',
-                                                    $ENV{'user.domain'});
+                                                    $env{'user.domain'});
     my $bodytag=&Apache::loncommon::bodytag('Discussion options',
                                           '','');
 
@@ -1806,10 +1801,10 @@
     my $numvisible = 5;
     my %sectioncount = ();
 
-    $numsections = &Apache::loncommon::get_sections($ENV{'course.'.$ENV{'request.course.id'}.'.domain'},$ENV{'course.'.$ENV{'request.course.id'}.'.num'},\%sectioncount);
+    $numsections = &Apache::loncommon::get_sections($env{'course.'.$env{'request.course.id'}.'.domain'},$env{'course.'.$env{'request.course.id'}.'.num'},\%sectioncount);
 
-    if ($ENV{'request.course.sec'} !~ /^\s*$/) {  #Restrict section choice to current section 
-        @sections = ('all',$ENV{'request.course.sec'});
+    if ($env{'request.course.sec'} !~ /^\s*$/) {  #Restrict section choice to current section 
+        @sections = ('all',$env{'request.course.sec'});
         $numvisible = 2;
     } else {
         @sections = sort {$a cmp $b} keys(%sectioncount);
@@ -1824,7 +1819,7 @@
                                                                                    
     my $function = &Apache::loncommon::get_users_function();
     my $tabcolor = &Apache::loncommon::designparm($function.'.tabbg',
-                                                    $ENV{'user.domain'});
+                                                    $env{'user.domain'});
     my $bodytag=&Apache::loncommon::bodytag('Discussion options',
                                           '','');
     my %lt = &Apache::lonlocal::texthash(
@@ -1954,15 +1949,15 @@
     $r->send_http_header;
 
     &Apache::lonenc::check_encrypt(\$symb);
-    my $crs='/'.$ENV{'request.course.id'};
-    if ($ENV{'request.course.sec'}) {
-        $crs.='_'.$ENV{'request.course.sec'};
+    my $crs='/'.$env{'request.course.id'};
+    if ($env{'request.course.sec'}) {
+        $crs.='_'.$env{'request.course.sec'};
     }
     $crs=~s/\_/\//g;
     my $seeid=&Apache::lonnet::allowed('rin',$crs);
-    my %contrib=&Apache::lonnet::restore($symb,$ENV{'request.course.id'},
-                          $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
-                          $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+    my %contrib=&Apache::lonnet::restore($symb,$env{'request.course.id'},
+                          $env{'course.'.$env{'request.course.id'}.'.domain'},
+                          $env{'course.'.$env{'request.course.id'}.'.num'});
     my %namesort = ();
     my %postcounts = ();
     my %lt=&Apache::lonlocal::texthash(
@@ -2263,7 +2258,7 @@
     my ($feedurl,$symb) = @_;
     my $msgoptions='';
     my $discussoptions='';
-    unless (($ENV{'form.replydisc'}) || ($ENV{'form.editdisc'})) {
+    unless (($env{'form.replydisc'}) || ($env{'form.editdisc'})) {
 	if (($feedurl=~/^\/res\//) && ($feedurl!~/^\/res\/adm/)) {
 	    $msgoptions= 
 		'<p><label><input type="checkbox" name="author" /> '.
@@ -2287,13 +2282,13 @@
 		'</label></p>';
 	}
     }
-    if ($ENV{'request.course.id'}) {
+    if ($env{'request.course.id'}) {
 	if (&discussion_open(undef,$symb) &&
 	    &Apache::lonnet::allowed('pch',
-				     $ENV{'request.course.id'}.
-				     ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) {
+				     $env{'request.course.id'}.
+				     ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) {
 	    $discussoptions='<label><input type="checkbox" name="discuss" onClick="this.form.anondiscuss.checked=false;" '.
-		($ENV{'form.replydisc'}?' checked="1"':'').' /> '.
+		($env{'form.replydisc'}?' checked="1"':'').' /> '.
 		&mt('Contribution to course discussion of resource');
 	    $discussoptions.='</label><br /><label><input type="checkbox" name="anondiscuss" onClick="this.form.discuss.checked=false;" /> '.
 		&mt('Anonymous contribution to course discussion of resource').
@@ -2325,8 +2320,8 @@
 # Always allow the <m>-tag
   my %html=(M=>1);
 # Check if more is allowed
-  my $cid=$ENV{'request.course.id'};
-  if (($ENV{"course.$cid.allow_limited_html_in_feedback"} =~ m/yes/i) ||
+  my $cid=$env{'request.course.id'};
+  if (($env{"course.$cid.allow_limited_html_in_feedback"} =~ m/yes/i) ||
       ($override)) {
       # allows <B> <I> <P> <A> <LI> <OL> <UL> <EM> <BR> <TT> <STRONG> 
       # <BLOCKQUOTE> <DIV .*> <DIV> <IMG> <M> <SPAN> <H1> <H2> <H3> <H4> <SUB>
@@ -2369,7 +2364,7 @@
     my ($adr,$sections)=($rec=~/^([^\(]+)\(([^\)]+)\)/);
     if ($sections) {
 	foreach (split(/\;/,$sections)) {
-            if (($_ eq $ENV{'request.course.sec'}) ||
+            if (($_ eq $env{'request.course.sec'}) ||
                 ($defaultflag && ($_ eq '*'))) {
                 return $adr; 
             }
@@ -2384,33 +2379,33 @@
   my ($feedurl,$author,$question,$course,$policy,$defaultflag) = @_;
   my $typestyle='';
   my %to=();
-  if ($ENV{'form.author'}||$author) {
+  if ($env{'form.author'}||$author) {
     $typestyle.='Submitting as Author Feedback<br>';
     $feedurl=~/^\/res\/(\w+)\/(\w+)\//;
     $to{$2.':'.$1}=1;
   }
-  if ($ENV{'form.question'}||$question) {
+  if ($env{'form.question'}||$question) {
     $typestyle.='Submitting as Question<br>';
     foreach (split(/\,/,
-		   $ENV{'course.'.$ENV{'request.course.id'}.'.question.email'})
+		   $env{'course.'.$env{'request.course.id'}.'.question.email'})
 	     ) {
 	my $rec=&secapply($_,$defaultflag);
         if ($rec) { $to{$rec}=1; }
     } 
   }
-  if ($ENV{'form.course'}||$course) {
+  if ($env{'form.course'}||$course) {
     $typestyle.='Submitting as Comment<br />';
     foreach (split(/\,/,
-		   $ENV{'course.'.$ENV{'request.course.id'}.'.comment.email'})
+		   $env{'course.'.$env{'request.course.id'}.'.comment.email'})
 	     ) {
 	my $rec=&secapply($_,$defaultflag);
         if ($rec) { $to{$rec}=1; }
     } 
   }
-  if ($ENV{'form.policy'}||$policy) {
+  if ($env{'form.policy'}||$policy) {
     $typestyle.='Submitting as Policy Feedback<br />';
     foreach (split(/\,/,
-		   $ENV{'course.'.$ENV{'request.course.id'}.'.policy.email'})
+		   $env{'course.'.$env{'request.course.id'}.'.policy.email'})
 	     ) {
 	my $rec=&secapply($_,$defaultflag);
         if ($rec) { $to{$rec}=1; }
@@ -2470,40 +2465,40 @@
 	$realsymb=&Apache::lonnet::symbread($filename);
     }
     if (&discussion_open(undef,$realsymb) &&
-	&Apache::lonnet::allowed('pch',$ENV{'request.course.id'}.
-        ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) {
+	&Apache::lonnet::allowed('pch',$env{'request.course.id'}.
+        ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) {
 
     my %contrib=('message'      => $email,
-                 'sendername'   => $ENV{'user.name'},
-                 'senderdomain' => $ENV{'user.domain'},
-                 'screenname'   => $ENV{'environment.screenname'},
-                 'plainname'    => $ENV{'environment.firstname'}.' '.
-		                   $ENV{'environment.middlename'}.' '.
-                                   $ENV{'environment.lastname'}.' '.
-                                   $ENV{'enrironment.generation'},
+                 'sendername'   => $env{'user.name'},
+                 'senderdomain' => $env{'user.domain'},
+                 'screenname'   => $env{'environment.screenname'},
+                 'plainname'    => $env{'environment.firstname'}.' '.
+		                   $env{'environment.middlename'}.' '.
+                                   $env{'environment.lastname'}.' '.
+                                   $env{'enrironment.generation'},
                  'attachmenturl'=> $attachmenturl,
                  'subject'      => $subject);
-    if ($ENV{'form.replydisc'}) {
-	$contrib{'replyto'}=(split(/\:\:\:/,$ENV{'form.replydisc'}))[1];
+    if ($env{'form.replydisc'}) {
+	$contrib{'replyto'}=(split(/\:\:\:/,$env{'form.replydisc'}))[1];
     }
     if ($anon) {
 	$contrib{'anonymous'}='true';
     }
     if (($symb) && ($email)) {
-        if ($ENV{'form.editdisc'}) {
+        if ($env{'form.editdisc'}) {
             my %newcontrib = ();
             $contrib{'ip'}=$ENV{'REMOTE_ADDR'};
             $contrib{'host'}=$Apache::lonnet::perlvar{'lonHostID'};
             $contrib{'timestamp'} = time;
             $contrib{'history'} = '';
             my $numoldver = 0;
-            my ($oldsymb,$oldidx)=split(/\:\:\:/,$ENV{'form.editdisc'});
+            my ($oldsymb,$oldidx)=split(/\:\:\:/,$env{'form.editdisc'});
 	    &Apache::lonenc::check_decrypt(\$oldsymb);
             $oldsymb=~s|(bulletin___\d+___)adm/wrapper/|$1|;
 # get timestamp for last post and history
-            my %oldcontrib=&Apache::lonnet::restore($oldsymb,$ENV{'request.course.id'},
-                     $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
-                     $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+            my %oldcontrib=&Apache::lonnet::restore($oldsymb,$env{'request.course.id'},
+                     $env{'course.'.$env{'request.course.id'}.'.domain'},
+                     $env{'course.'.$env{'request.course.id'}.'.num'});
             if (defined($oldcontrib{$oldidx.':replyto'})) {
                 $contrib{'replyto'} = $oldcontrib{$oldidx.':replyto'};
             }
@@ -2538,22 +2533,22 @@
                 my $key = $oldidx.':'.&Apache::lonnet::escape($oldsymb).':'.$_;                                                                               
                 $newcontrib{$key} = $contrib{$_};
             }
-            my $put_reply = &Apache::lonnet::putstore($ENV{'request.course.id'},
+            my $put_reply = &Apache::lonnet::putstore($env{'request.course.id'},
                   \%newcontrib,
-                  $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
-                  $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+                  $env{'course.'.$env{'request.course.id'}.'.domain'},
+                  $env{'course.'.$env{'request.course.id'}.'.num'});
             $status='Editing class discussion'.($anon?' (anonymous)':'');
         } else {
            $status='Adding to class discussion'.($anon?' (anonymous)':'').': '.
-           &Apache::lonnet::store(\%contrib,$symb,$ENV{'request.course.id'},
-                     $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
-		     $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+           &Apache::lonnet::store(\%contrib,$symb,$env{'request.course.id'},
+                     $env{'course.'.$env{'request.course.id'}.'.domain'},
+		     $env{'course.'.$env{'request.course.id'}.'.num'});
         }
         my %storenewentry=($symb => time);
         $status.='<br />'.&mt('Updating discussion time').': '.
         &Apache::lonnet::put('discussiontimes',\%storenewentry,
-                     $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
-		     $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+                     $env{'course.'.$env{'request.course.id'}.'.domain'},
+		     $env{'course.'.$env{'request.course.id'}.'.num'});
     }
     my %record=&Apache::lonnet::restore('_discussion');
     my ($temp)=keys %record;
@@ -2576,11 +2571,11 @@
     my $r=shift;
     &Apache::loncommon::content_type($r,'text/html');
     $r->send_http_header;
-    my $message=&clear_out_html($ENV{'form.comment'});
+    my $message=&clear_out_html($env{'form.comment'});
     $message=~s/\n/\<br \/\>/g;
     $message=&Apache::lonspeller::markeduptext($message);
     $message=&Apache::lontexconvert::msgtexconverted($message);
-    my $subject=&clear_out_html($ENV{'form.subject'});
+    my $subject=&clear_out_html($env{'form.subject'});
     $subject=~s/\n/\<br \/\>/g;
     $subject=&Apache::lontexconvert::msgtexconverted($subject);
     my $html=&Apache::lonxml::xmlbegin();
@@ -2604,12 +2599,12 @@
 
 sub modify_attachments {
     my ($r,$currnewattach,$currdelold,$symb,$idx,$attachmenturls)=@_;
-    my $orig_subject = &Apache::lonnet::unescape($ENV{'form.subject'});
+    my $orig_subject = &Apache::lonnet::unescape($env{'form.subject'});
     my $subject=&clear_out_html($orig_subject);
     $subject=~s/\n/\<br \/\>/g;
     $subject=&Apache::lontexconvert::msgtexconverted($subject);
-    my $timestamp=$ENV{'form.timestamp'};
-    my $numoldver=$ENV{'form.numoldver'};
+    my $timestamp=$env{'form.timestamp'};
+    my $numoldver=$env{'form.numoldver'};
     my $bodytag=&Apache::loncommon::bodytag('Discussion Post Attachments',
                                           '','');
     my $msg = '';
@@ -2665,14 +2660,14 @@
    </td>
   </tr>
  </table>
-<input type="hidden" name="subject" value="$ENV{'form.subject'}" />
-<input type="hidden" name="comment" value="$ENV{'form.comment'}" />
-<input type="hidden" name="timestamp" value="$ENV{'form.timestamp'}" />
-<input type="hidden" name="idx" value="$ENV{'form.idx'}" />
-<input type="hidden" name="numoldver" value="$ENV{'form.numoldver'}" />
-<input type="hidden" name="origpage" value="$ENV{'form.origpage'}" />
-<input type="hidden" name="anondiscuss" value="$ENV{'form.anondiscuss'}" />
-<input type="hidden" name="discuss" value="$ENV{'form.discuss'}" />
+<input type="hidden" name="subject" value="$env{'form.subject'}" />
+<input type="hidden" name="comment" value="$env{'form.comment'}" />
+<input type="hidden" name="timestamp" value="$env{'form.timestamp'}" />
+<input type="hidden" name="idx" value="$env{'form.idx'}" />
+<input type="hidden" name="numoldver" value="$env{'form.numoldver'}" />
+<input type="hidden" name="origpage" value="$env{'form.origpage'}" />
+<input type="hidden" name="anondiscuss" value="$env{'form.anondiscuss'}" />
+<input type="hidden" name="discuss" value="$env{'form.discuss'}" />
 END
     foreach (@{$currnewattach}) {
         $r->print('<input type="hidden" name="currnewattach" value="'.$_.'" />'."\n");
@@ -2691,27 +2686,27 @@
 
 sub process_attachments {
     my ($currnewattach,$currdelold,$keepold) = @_;
-    if (exists($ENV{'form.currnewattach'})) {
-        if (ref($ENV{'form.currnewattach'}) eq 'ARRAY') {
-            @{$currnewattach} = @{$ENV{'form.currnewattach'}};
+    if (exists($env{'form.currnewattach'})) {
+        if (ref($env{'form.currnewattach'}) eq 'ARRAY') {
+            @{$currnewattach} = @{$env{'form.currnewattach'}};
         } else {
-            $$currnewattach[0] = $ENV{'form.currnewattach'};
+            $$currnewattach[0] = $env{'form.currnewattach'};
         }
     }
-    if (exists($ENV{'form.deloldattach'})) {
-        if (ref($ENV{'form.deloldattach'}) eq 'ARRAY') {
-            @{$currdelold} = @{$ENV{'form.deloldattach'}};
+    if (exists($env{'form.deloldattach'})) {
+        if (ref($env{'form.deloldattach'}) eq 'ARRAY') {
+            @{$currdelold} = @{$env{'form.deloldattach'}};
         } else {
-            $$currdelold[0] = $ENV{'form.deloldattach'};
+            $$currdelold[0] = $env{'form.deloldattach'};
         }
     }
-    if (exists($ENV{'form.delnewattach'})) {
+    if (exists($env{'form.delnewattach'})) {
         my @currdelnew = ();
         my @currnew = ();
-        if (ref($ENV{'form.delnewattach'}) eq 'ARRAY') {
-            @currdelnew = @{$ENV{'form.delnewattach'}};
+        if (ref($env{'form.delnewattach'}) eq 'ARRAY') {
+            @currdelnew = @{$env{'form.delnewattach'}};
         } else {
-            $currdelnew[0] = $ENV{'form.delnewattach'};
+            $currdelnew[0] = $env{'form.delnewattach'};
         }
         foreach my $newone (@{$currnewattach}) {
             my $delflag = 0;
@@ -2727,11 +2722,11 @@
         }
         @{$currnewattach} = @currnew;
     }
-    if (exists($ENV{'form.keepold'})) {
-        if (ref($ENV{'form.keepold'}) eq 'ARRAY') {
-            @{$keepold} = @{$ENV{'form.keepold'}};
+    if (exists($env{'form.keepold'})) {
+        if (ref($env{'form.keepold'}) eq 'ARRAY') {
+            @{$keepold} = @{$env{'form.keepold'}};
         } else {
-            $$keepold[0] = $ENV{'form.keepold'};
+            $$keepold[0] = $env{'form.keepold'};
         }
     }
 }
@@ -2833,10 +2828,10 @@
     my $newattachmenturl;
     my $startnum = 0;
     my $currver = 0;
-    if (($ENV{'form.editdisc'}) && ($idx)) {
-        my %contrib=&Apache::lonnet::restore($symb,$ENV{'request.course.id'},
-                       $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
-                       $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+    if (($env{'form.editdisc'}) && ($idx)) {
+        my %contrib=&Apache::lonnet::restore($symb,$env{'request.course.id'},
+                       $env{'course.'.$env{'request.course.id'}.'.domain'},
+                       $env{'course.'.$env{'request.course.id'}.'.num'});
         $oldattachmenturl = $contrib{$idx.':attachmenturl'};
         if ($contrib{$idx.':history'}) {
             if ($contrib{$idx.':history'} =~ /:/) {
@@ -2942,12 +2937,12 @@
   &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
          ['hide','unhide','deldisc','postdata','preview','replydisc','editdisc','cmd','symb','onlyunread','allposts','onlyunmark','previous','markread','markonread','markondisp','toggoff','toggon','modifydisp','changes','navtime','navmaps','navurl','sortposts','applysort','rolefilter','statusfilter','sectionpick','posterlist','userpick','attach','origpage','currnewattach','deloldattach','keepold','allversions','export']);
 
-  if ($ENV{'form.discsymb'}) {
-      my ($symb,$feedurl) = &get_feedurl_and_clean_symb($ENV{'form.discsymb'});
+  if ($env{'form.discsymb'}) {
+      my ($symb,$feedurl) = &get_feedurl_and_clean_symb($env{'form.discsymb'});
       my $readkey = $symb.'_read';
       my $chgcount = 0;
-      my %readinghash = &Apache::lonnet::get('nohist_'.$ENV{'request.course.id'}.'_discuss',[$readkey],$ENV{'user.domain'},$ENV{'user.name'});
-      foreach my $key (keys %ENV) {
+      my %readinghash = &Apache::lonnet::get('nohist_'.$env{'request.course.id'}.'_discuss',[$readkey],$env{'user.domain'},$env{'user.name'});
+      foreach my $key (keys %env) {
           if ($key =~ m/^form\.postunread_(\d+)/) {
               if ($readinghash{$readkey} =~ /\.$1\./) {
                   $readinghash{$readkey} =~ s/\.$1\.//;
@@ -2961,14 +2956,14 @@
           }
       }
       if ($chgcount > 0) {
-          &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',
-			  \%readinghash,$ENV{'user.domain'},$ENV{'user.name'});
+          &Apache::lonnet::put('nohist_'.$env{'request.course.id'}.'_discuss',
+			  \%readinghash,$env{'user.domain'},$env{'user.name'});
       }
       &redirect_back($r,$feedurl,&mt('Marked postings read/unread').'<br />',
-		     '0','0','',$ENV{'form.previous'},'','','',);
+		     '0','0','',$env{'form.previous'},'','','',);
       return OK;
   }
-  if ($ENV{'form.allversions'}) {
+  if ($env{'form.allversions'}) {
       &Apache::loncommon::content_type($r,'text/html');
       $r->send_http_header;
       my $html=&Apache::lonxml::xmlbegin();
@@ -2981,13 +2976,13 @@
 </head>
 $bodytag
 END
-      my $crs='/'.$ENV{'request.course.id'};
-      if ($ENV{'request.course.sec'}) {
-          $crs.='_'.$ENV{'request.course.sec'};
+      my $crs='/'.$env{'request.course.id'};
+      if ($env{'request.course.sec'}) {
+          $crs.='_'.$env{'request.course.sec'};
       }
       $crs=~s|_|/|g;
       my $seeid=&Apache::lonnet::allowed('rin',$crs);
-      my ($symb,$idx)=split(/\:\:\:/,$ENV{'form.allversions'});
+      my ($symb,$idx)=split(/\:\:\:/,$env{'form.allversions'});
       ($symb)=&get_feedurl_and_clean_symb($symb);
       if ($idx > 0) {
           my %messages = ();
@@ -2996,58 +2991,58 @@
           my %allattachments = ();
           my %imsfiles = ();
           my ($screenname,$plainname);
-          my %contrib=&Apache::lonnet::restore($symb,$ENV{'request.course.id'},
-                           $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
-                           $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+          my %contrib=&Apache::lonnet::restore($symb,$env{'request.course.id'},
+                           $env{'course.'.$env{'request.course.id'}.'.domain'},
+                           $env{'course.'.$env{'request.course.id'}.'.num'});
           $r->print(&get_post_contents(\%contrib,$idx,$seeid,'allversions',\%messages,\%subjects,\%allattachments,\%attachmsgs,\%imsfiles,\$screenname,\$plainname));
       }
       return OK;
   }
-  if ($ENV{'form.posterlist'}) {
-      my ($symb,$feedurl)=&get_feedurl_and_clean_symb($ENV{'form.applysort'});
-      &print_showposters($r,$symb,$ENV{'form.previous'},$feedurl,
-			 $ENV{'form.sortposts'});
+  if ($env{'form.posterlist'}) {
+      my ($symb,$feedurl)=&get_feedurl_and_clean_symb($env{'form.applysort'});
+      &print_showposters($r,$symb,$env{'form.previous'},$feedurl,
+			 $env{'form.sortposts'});
       return OK;
   }
-  if ($ENV{'form.userpick'}) {
+  if ($env{'form.userpick'}) {
       my @posters = &Apache::loncommon::get_env_multiple('form.stuinfo');
-      my ($symb,$feedurl)=&get_feedurl_and_clean_symb($ENV{'form.userpick'});
+      my ($symb,$feedurl)=&get_feedurl_and_clean_symb($env{'form.userpick'});
       my $numpicks = @posters;
       my %discinfo;
       $discinfo{$symb.'_userpick'} = join('&',@posters);
-      &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',
-			   \%discinfo,$ENV{'user.domain'},$ENV{'user.name'});
+      &Apache::lonnet::put('nohist_'.$env{'request.course.id'}.'_discuss',
+			   \%discinfo,$env{'user.domain'},$env{'user.name'});
       &redirect_back($r,$feedurl,&mt('Changed sort/filter').'<br />','0','0',
-		     '',$ENV{'form.previous'},$ENV{'form.sortposts'},'','','',
+		     '',$env{'form.previous'},$env{'form.sortposts'},'','','',
 		     $numpicks);
       return OK;
   }
-  if ($ENV{'form.applysort'}) {
-      my ($symb,$feedurl)=&get_feedurl_and_clean_symb($ENV{'form.applysort'});
+  if ($env{'form.applysort'}) {
+      my ($symb,$feedurl)=&get_feedurl_and_clean_symb($env{'form.applysort'});
       &redirect_back($r,$feedurl,&mt('Changed sort/filter').'<br />','0','0',
-		     '',$ENV{'form.previous'},$ENV{'form.sortposts'},
-		     $ENV{'form.rolefilter'},$ENV{'form.statusfilter'},
-		     $ENV{'form.sectionpick'});
+		     '',$env{'form.previous'},$env{'form.sortposts'},
+		     $env{'form.rolefilter'},$env{'form.statusfilter'},
+		     $env{'form.sectionpick'});
       return OK;
-  } elsif ($ENV{'form.cmd'} eq 'sortfilter') {
-      my ($symb,$feedurl)=&get_feedurl_and_clean_symb($ENV{'form.symb'});
-      &print_sortfilter_options($r,$symb,$ENV{'form.previous'},$feedurl);
+  } elsif ($env{'form.cmd'} eq 'sortfilter') {
+      my ($symb,$feedurl)=&get_feedurl_and_clean_symb($env{'form.symb'});
+      &print_sortfilter_options($r,$symb,$env{'form.previous'},$feedurl);
       return OK;
-  } elsif ($ENV{'form.navtime'}) {
+  } elsif ($env{'form.navtime'}) {
       my %discinfo = ();
       my @resources = ();
-      if (defined($ENV{'form.navmaps'})) {
-          if ($ENV{'form.navmaps'} =~ /:/) {
-              @resources = split/:/,$ENV{'form.navmaps'};
+      if (defined($env{'form.navmaps'})) {
+          if ($env{'form.navmaps'} =~ /:/) {
+              @resources = split/:/,$env{'form.navmaps'};
           } else {
-              @resources = ("$ENV{'form.navmaps'}");
+              @resources = ("$env{'form.navmaps'}");
           }
       } else {
           &has_discussion(\@resources);
       }
       my $numitems = @resources;
       my $feedurl = '/adm/navmaps';
-      if ($ENV{'form.navurl'}) { $feedurl .= '?'.$ENV{'form.navurl'}; }
+      if ($env{'form.navurl'}) { $feedurl .= '?'.$env{'form.navurl'}; }
       my %lt = &Apache::lonlocal::texthash(
           'mnpa' => 'Marked "New" posts as read in a total of',
           'robb' => 'resources/bulletin boards.',
@@ -3063,12 +3058,12 @@
               }
           }
           my $lastkey = $ressymb.'_lastread';
-          $discinfo{$lastkey} = $ENV{'form.navtime'};
+          $discinfo{$lastkey} = $env{'form.navtime'};
       }
       my $textline = "<b>$lt{'mnpa'} $numitems $lt{'robb'}</b>";
       if ($numitems > 0) {
-          &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',
-			     \%discinfo,$ENV{'user.domain'},$ENV{'user.name'});
+          &Apache::lonnet::put('nohist_'.$env{'request.course.id'}.'_discuss',
+			     \%discinfo,$env{'user.domain'},$env{'user.name'});
       } else {
           $textline = "<b>$lt{'twnp'}</b>";
       }
@@ -3093,70 +3088,70 @@
 </html>
 ENDREDIR
       return OK;
-  } elsif ($ENV{'form.modifydisp'}) {
-      my ($symb,$feedurl)=&get_feedurl_and_clean_symb($ENV{'form.modifydisp'});
+  } elsif ($env{'form.modifydisp'}) {
+      my ($symb,$feedurl)=&get_feedurl_and_clean_symb($env{'form.modifydisp'});
       my ($dispchgA,$dispchgB,$markchg,$toggchg) = 
-	  split(/_/,$ENV{'form.changes'});
-      &print_display_options($r,$symb,$ENV{'form.previous'},$dispchgA,
+	  split(/_/,$env{'form.changes'});
+      &print_display_options($r,$symb,$env{'form.previous'},$dispchgA,
 			     $dispchgB,$markchg,$toggchg,$feedurl);
       return OK;
-  } elsif ($ENV{'form.markondisp'} || $ENV{'form.markonread'} ||
-	   $ENV{'form.allposts'}   || $ENV{'form.onlyunread'} ||
-	   $ENV{'form.onlyunmark'} || $ENV{'form.toggoff'}    ||
-	   $ENV{'form.toggon'}     || $ENV{'form.markread'}) {
-      my ($symb,$feedurl)=&get_feedurl_and_clean_symb($ENV{'form.symb'});
+  } elsif ($env{'form.markondisp'} || $env{'form.markonread'} ||
+	   $env{'form.allposts'}   || $env{'form.onlyunread'} ||
+	   $env{'form.onlyunmark'} || $env{'form.toggoff'}    ||
+	   $env{'form.toggon'}     || $env{'form.markread'}) {
+      my ($symb,$feedurl)=&get_feedurl_and_clean_symb($env{'form.symb'});
       my %discinfo;
 # ------------------------ Modify setting for read/unread toggle for each post 
-      if ($ENV{'form.toggoff'}) { $discinfo{$symb.'_readtoggle'}=0; }
-      if ($ENV{'form.toggon'})  { $discinfo{$symb.'_readtoggle'}=1; }
+      if ($env{'form.toggoff'}) { $discinfo{$symb.'_readtoggle'}=0; }
+      if ($env{'form.toggon'})  { $discinfo{$symb.'_readtoggle'}=1; }
 # --------- Modify setting for identification of 'NEW' posts in this discussion
-      if ($ENV{'form.markondisp'}) {
+      if ($env{'form.markondisp'}) {
 	  $discinfo{$symb.'_lastread'} = time;
 	  $discinfo{$symb.'_markondisp'} = 1;
       }
-      if ($ENV{'form.markonread'}) {
-	  if ( $ENV{'form.previous'} > 0 ) {
-	      $discinfo{$symb.'_lastread'} = $ENV{'form.previous'};
+      if ($env{'form.markonread'}) {
+	  if ( $env{'form.previous'} > 0 ) {
+	      $discinfo{$symb.'_lastread'} = $env{'form.previous'};
 	  }
 	  $discinfo{$symb.'_markondisp'} = 0;
       }
 # --------------------------------- Modify display setting for this discussion 
-      if ($ENV{'form.allposts'}) {
+      if ($env{'form.allposts'}) {
 	  $discinfo{$symb.'_showonlyunread'} = 0;
 	  $discinfo{$symb.'_showonlyunmark'} = 0;
       }
-      if ($ENV{'form.onlyunread'}) { $discinfo{$symb.'_showonlyunread'} = 1;  }
-      if ($ENV{'form.onlyunmark'}) { $discinfo{$symb.'_showonlyunmark'} = 1;  }
+      if ($env{'form.onlyunread'}) { $discinfo{$symb.'_showonlyunread'} = 1;  }
+      if ($env{'form.onlyunmark'}) { $discinfo{$symb.'_showonlyunmark'} = 1;  }
 # ----------------------------------------------------- Mark new posts not NEW 
-      if ($ENV{'form.markread'})   { $discinfo{$symb.'_lastread'} = time; }
-      &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',
-			   \%discinfo,$ENV{'user.domain'},$ENV{'user.name'});
-      my $previous=$ENV{'form.previous'};
-      if ($ENV{'form.markondisp'}) { $previous=undef; }
+      if ($env{'form.markread'})   { $discinfo{$symb.'_lastread'} = time; }
+      &Apache::lonnet::put('nohist_'.$env{'request.course.id'}.'_discuss',
+			   \%discinfo,$env{'user.domain'},$env{'user.name'});
+      my $previous=$env{'form.previous'};
+      if ($env{'form.markondisp'}) { $previous=undef; }
       &redirect_back($r,$feedurl,&mt('Changed display status').'<br />',
 		     '0','0','',$previous);
       return OK;
-  } elsif (($ENV{'form.hide'}) || ($ENV{'form.unhide'})) {
+  } elsif (($env{'form.hide'}) || ($env{'form.unhide'})) {
 # ----------------------------------------------------------------- Hide/unhide
-      my $entry=$ENV{'form.hide'}?$ENV{'form.hide'}:$ENV{'form.unhide'};
+      my $entry=$env{'form.hide'}?$env{'form.hide'}:$env{'form.unhide'};
       my ($symb,$idx)=split(/\:\:\:/,$entry);
       ($symb,my $feedurl)=&get_feedurl_and_clean_symb($symb);
 
-      my %contrib=&Apache::lonnet::restore($symb,$ENV{'request.course.id'},
-                          $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
-		          $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+      my %contrib=&Apache::lonnet::restore($symb,$env{'request.course.id'},
+                          $env{'course.'.$env{'request.course.id'}.'.domain'},
+		          $env{'course.'.$env{'request.course.id'}.'.num'});
 
       my $currenthidden=$contrib{'hidden'};
       my $currentstudenthidden=$contrib{'studenthidden'};
 
-      my $crs='/'.$ENV{'request.course.id'};
-      if ($ENV{'request.course.sec'}) {
-	  $crs.='_'.$ENV{'request.course.sec'};
+      my $crs='/'.$env{'request.course.id'};
+      if ($env{'request.course.sec'}) {
+	  $crs.='_'.$env{'request.course.sec'};
       }
       $crs=~s/\_/\//g;
       my $seeid=&Apache::lonnet::allowed('rin',$crs);
 
-      if ($ENV{'form.hide'}) {
+      if ($env{'form.hide'}) {
 	  $currenthidden.='.'.$idx.'.';
 	  unless ($seeid) {
 	      $currentstudenthidden.='.'.$idx.'.';
@@ -3165,20 +3160,20 @@
 	  $currenthidden=~s/\.$idx\.//g;
       }
       my %newhash=('hidden' => $currenthidden);
-      if ( ($ENV{'form.hide'}) && (!$seeid) ) {
+      if ( ($env{'form.hide'}) && (!$seeid) ) {
 	  $newhash{'studenthidden'} = $currentstudenthidden;
       }
 
-      &Apache::lonnet::store(\%newhash,$symb,$ENV{'request.course.id'},
-                           $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
-			   $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+      &Apache::lonnet::store(\%newhash,$symb,$env{'request.course.id'},
+                           $env{'course.'.$env{'request.course.id'}.'.domain'},
+			   $env{'course.'.$env{'request.course.id'}.'.num'});
 
       &redirect_back($r,$feedurl,&mt('Changed discussion status').'<br />',
-		     '0','0','',$ENV{'form.previous'});
+		     '0','0','',$env{'form.previous'});
       return OK;
-  } elsif ($ENV{'form.cmd'}=~/^(threadedoff|threadedon)$/) {
-      my ($symb,$feedurl)=&get_feedurl_and_clean_symb($ENV{'form.symb'});
-      if ($ENV{'form.cmd'} eq 'threadedon') {
+  } elsif ($env{'form.cmd'}=~/^(threadedoff|threadedon)$/) {
+      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');
       } else {
@@ -3186,59 +3181,59 @@
 	  &Apache::lonnet::delenv('environment\.threadeddiscussion');
       }
       &redirect_back($r,$feedurl,&mt('Changed discussion view mode').'<br />',
-		     '0','0','',$ENV{'form.previous'});
+		     '0','0','',$env{'form.previous'});
       return OK;
-  } elsif ($ENV{'form.deldisc'}) {
+  } elsif ($env{'form.deldisc'}) {
 # --------------------------------------------------------------- Hide for good
-      my ($symb,$idx)=split(/\:\:\:/,$ENV{'form.deldisc'});
+      my ($symb,$idx)=split(/\:\:\:/,$env{'form.deldisc'});
       ($symb,my $feedurl)=&get_feedurl_and_clean_symb($symb);
-      my %contrib=&Apache::lonnet::restore($symb,$ENV{'request.course.id'},
-                          $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
-		          $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+      my %contrib=&Apache::lonnet::restore($symb,$env{'request.course.id'},
+                          $env{'course.'.$env{'request.course.id'}.'.domain'},
+		          $env{'course.'.$env{'request.course.id'}.'.num'});
       my %newhash=('deleted' => $contrib{'deleted'}.".$idx.");
-      &Apache::lonnet::store(\%newhash,$symb,$ENV{'request.course.id'},
-			   $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
-			   $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+      &Apache::lonnet::store(\%newhash,$symb,$env{'request.course.id'},
+			   $env{'course.'.$env{'request.course.id'}.'.domain'},
+			   $env{'course.'.$env{'request.course.id'}.'.num'});
       &redirect_back($r,$feedurl,&mt('Changed discussion status').'<br />',
-		     '0','0','',$ENV{'form.previous'});
+		     '0','0','',$env{'form.previous'});
       return OK;
-  } elsif ($ENV{'form.preview'}) {
+  } elsif ($env{'form.preview'}) {
 # -------------------------------------------------------- User wants a preview
       &show_preview($r);
       return OK;
-  } elsif ($ENV{'form.attach'}) {
+  } elsif ($env{'form.attach'}) {
 # -------------------------------------------------------- Work on attachments
       &Apache::loncommon::content_type($r,'text/html');
       $r->send_http_header;
       &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['subject','comment','addnewattach','delnewattach','timestamp','numoldver','idx','anondiscuss','discuss']);
       my (@currnewattach,@currdelold,@keepold);
       &process_attachments(\@currnewattach,\@currdelold,\@keepold);
-      if (exists($ENV{'form.addnewattach.filename'})) {
-          unless (length($ENV{'form.addnewattach'})>131072) {
-              my $subdir = 'feedback/'.$ENV{'form.timestamp'};
+      if (exists($env{'form.addnewattach.filename'})) {
+          unless (length($env{'form.addnewattach'})>131072) {
+              my $subdir = 'feedback/'.$env{'form.timestamp'};
               my $newattachment=&Apache::lonnet::userfileupload('addnewattach',undef,$subdir);
 	      push @currnewattach, $newattachment;
           }
       }
       my $attachmenturls;
-      my ($symb) = &get_feedurl_and_clean_symb($ENV{'form.attach'});
-      my $idx = $ENV{'form.idx'};
+      my ($symb) = &get_feedurl_and_clean_symb($env{'form.attach'});
+      my $idx = $env{'form.idx'};
       if ($idx) {
-          my %contrib=&Apache::lonnet::restore($symb,$ENV{'request.course.id'},
-                         $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
-                         $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+          my %contrib=&Apache::lonnet::restore($symb,$env{'request.course.id'},
+                         $env{'course.'.$env{'request.course.id'}.'.domain'},
+                         $env{'course.'.$env{'request.course.id'}.'.num'});
           $attachmenturls = $contrib{$idx.':attachmenturl'};
       }
       &modify_attachments($r,\@currnewattach,\@currdelold,$symb,$idx,
 			  $attachmenturls);
       return OK;
-  } elsif ($ENV{'form.export'}) {
+  } elsif ($env{'form.export'}) {
       &Apache::loncommon::content_type($r,'text/html');
       $r->send_http_header;
-      my ($symb,$feedurl) = &get_feedurl_and_clean_symb($ENV{'form.export'});
+      my ($symb,$feedurl) = &get_feedurl_and_clean_symb($env{'form.export'});
       my $mode='board';
       my $status='OPEN';
-      my $previous=$ENV{'form.previous'};
+      my $previous=$env{'form.previous'};
       if ($feedurl =~ /\.(problem|exam|quiz|assess|survey|form|library)$/) {
           $mode='problem';
           $status=$Apache::inputtags::status[-1];
@@ -3249,28 +3244,28 @@
       return OK;
   } else {
 # ------------------------------------------------------------- Normal feedback
-      my $feedurl=$ENV{'form.postdata'};
+      my $feedurl=$env{'form.postdata'};
       $feedurl=~s/^http\:\/\///;
       $feedurl=~s/^$ENV{'SERVER_NAME'}//;
       $feedurl=~s/^$ENV{'HTTP_HOST'}//;
       $feedurl=~s/\?.+$//;
 
       my $symb;
-      if ($ENV{'form.replydisc'}) {
-	  $symb=(split(/\:\:\:/,$ENV{'form.replydisc'}))[0];
+      if ($env{'form.replydisc'}) {
+	  $symb=(split(/\:\:\:/,$env{'form.replydisc'}))[0];
 	  my ($map,$id,$url)=&Apache::lonnet::decode_symb($symb);
 	  $feedurl=&Apache::lonnet::clutter($url);
-      } elsif ($ENV{'form.editdisc'}) {
-	  $symb=(split(/\:\:\:/,$ENV{'form.editdisc'}))[0];
+      } elsif ($env{'form.editdisc'}) {
+	  $symb=(split(/\:\:\:/,$env{'form.editdisc'}))[0];
 	  my ($map,$id,$url)=&Apache::lonnet::decode_symb($symb);
 	  $feedurl=&Apache::lonnet::clutter($url);
-      } elsif ($ENV{'form.origpage'}) {
+      } elsif ($env{'form.origpage'}) {
 	  $symb=""; 
       } else {
 	  $symb=&Apache::lonnet::symbread($feedurl);
       }
       unless ($symb) {
-	  $symb=$ENV{'form.symb'};
+	  $symb=$env{'form.symb'};
 	  if ($symb) {
 	      my ($map,$id,$url)=&Apache::lonnet::decode_symb($symb);
 	      $feedurl=&Apache::lonnet::clutter($url);
@@ -3296,9 +3291,9 @@
 	   ($feedurl=~m:^/res:) && ($feedurl!~m:^/res/adm:)
 	   ) 
 	  || 
-	  ($ENV{'request.course.id'} && ($feedurl!~m:^/adm:))
+	  ($env{'request.course.id'} && ($feedurl!~m:^/adm:))
 	  ||
-	  ($ENV{'request.course.id'} && ($symb=~/^bulletin\_\_\_/))
+	  ($env{'request.course.id'} && ($symb=~/^bulletin\_\_\_/))
 	  ) {
 	  &Apache::loncommon::content_type($r,'text/html');
 	  $r->send_http_header;
@@ -3306,7 +3301,7 @@
 	  &no_redirect_back($r,$feedurl);
       }
 # --------------------------------------------------- Print login screen header
-      unless ($ENV{'form.sendit'}) {
+      unless ($env{'form.sendit'}) {
 	  &Apache::loncommon::content_type($r,'text/html');
 	  $r->send_http_header;
 	  my $options=&screen_header($feedurl,$symb);
@@ -3320,8 +3315,8 @@
       
 # Get previous user input
       my $prevattempts=&Apache::loncommon::get_previous_attempt(
-                                   $symb,$ENV{'user.name'},$ENV{'user.domain'},
-				   $ENV{'request.course.id'});
+                                   $symb,$env{'user.name'},$env{'user.domain'},
+				   $env{'request.course.id'});
 
 # Get output from resource
       my $usersaw=&resource_output($feedurl);
@@ -3329,20 +3324,20 @@
 # Get resource answer (need to allow student to view grades for this to work)
       &Apache::lonnet::appenv(('allowed.vgr'=>'F'));
       my $useranswer=&Apache::loncommon::get_student_answers(
-                                   $symb,$ENV{'user.name'},$ENV{'user.domain'},
-		                   $ENV{'request.course.id'});
+                                   $symb,$env{'user.name'},$env{'user.domain'},
+		                   $env{'request.course.id'});
       &Apache::lonnet::delenv('allowed.vgr');
 # Get attachments, if any, and not too large
       my $attachmenturl='';
-      if (($ENV{'form.origpage'}) || ($ENV{'form.editdisc'}) ||
-	  ($ENV{'form.replydisc'})) {
+      if (($env{'form.origpage'}) || ($env{'form.editdisc'}) ||
+	  ($env{'form.replydisc'})) {
 	  my ($symb,$idx);
-	  if ($ENV{'form.replydisc'}) {
-	      ($symb,$idx)=split(/\:\:\:/,$ENV{'form.replydisc'});
-	  } elsif ($ENV{'form.editdisc'}) {
-	      ($symb,$idx)=split(/\:\:\:/,$ENV{'form.editdisc'});
-	  } elsif ($ENV{'form.origpage'}) {
-	      $symb = $ENV{'form.symb'};
+	  if ($env{'form.replydisc'}) {
+	      ($symb,$idx)=split(/\:\:\:/,$env{'form.replydisc'});
+	  } elsif ($env{'form.editdisc'}) {
+	      ($symb,$idx)=split(/\:\:\:/,$env{'form.editdisc'});
+	  } elsif ($env{'form.origpage'}) {
+	      $symb = $env{'form.symb'};
 	  }
 	  &Apache::lonenc::check_decrypt(\$symb);
 	  my @currnewattach = ();
@@ -3351,13 +3346,13 @@
 	  &process_attachments(\@currnewattach,\@deloldattach,\@keepold);
 	  $symb=~s|(bulletin___\d+___)adm/wrapper/|$1|;
 	  $attachmenturl=&construct_attachmenturl(\@currnewattach,\@keepold,$symb,$idx);
-      } elsif ($ENV{'form.attachment.filename'}) {
-	  unless (length($ENV{'form.attachment'})>131072) {
+      } elsif ($env{'form.attachment.filename'}) {
+	  unless (length($env{'form.attachment'})>131072) {
 	      $attachmenturl=&Apache::lonnet::userfileupload('attachment',undef,'feedback');
 	  }
       }
 # Filter HTML out of message (could be nasty)
-      my $message=&clear_out_html($ENV{'form.comment'});
+      my $message=&clear_out_html($env{'form.comment'});
 
 # Assemble email
       my ($email,$citations)=&assemble_email($feedurl,$message,$prevattempts,
@@ -3373,16 +3368,16 @@
 # Discussion? Store that.
 
       my $numpost=0;
-      if ($ENV{'form.discuss'} || $ENV{'form.anondiscuss'}) {
-	  my $subject = &clear_out_html($ENV{'form.subject'});
-	  my $anonmode=(defined($ENV{'form.anondiscuss'}));
+      if ($env{'form.discuss'} || $env{'form.anondiscuss'}) {
+	  my $subject = &clear_out_html($env{'form.subject'});
+	  my $anonmode=(defined($env{'form.anondiscuss'}));
 	  $typestyle.=&adddiscuss($symb,$message,$anonmode,$attachmenturl,
 				  $subject);
 	  $numpost++;
       }
 	  
 # Receipt screen and redirect back to where came from
-      &redirect_back($r,$feedurl,$typestyle,$numsent,$numpost,$status,$ENV{'form.previous'});
+      &redirect_back($r,$feedurl,$typestyle,$numsent,$numpost,$status,$env{'form.previous'});
   }
   return OK;
 } 
Index: loncom/interface/lonhelp.pm
diff -u loncom/interface/lonhelp.pm:1.17 loncom/interface/lonhelp.pm:1.18
--- loncom/interface/lonhelp.pm:1.17	Tue Mar 22 11:49:02 2005
+++ loncom/interface/lonhelp.pm	Thu Apr  7 02:56:23 2005
@@ -37,6 +37,7 @@
 use Apache::lontexconvert();
 use Apache::lonnavmaps; # for advancedUser
 use Apache::lonlocal;
+use Apache::lonnet;
 use tth();
 use GDBM_File();
 
@@ -180,10 +181,10 @@
 	 $tex .= join('', <$file>);
      }
 
-     if ($ENV{'browser.mathml'}) {
+     if ($env{'browser.mathml'}) {
 	 &Apache::loncommon::content_type($r,'text/xml');
 	 &tth::ttminit();
-	 if ($ENV{'browser.unicode'}) {
+	 if ($env{'browser.unicode'}) {
 	     &tth::ttmoptions('-L -u1');
 	 } else {
 	     &tth::ttmoptions('-L -u0');
@@ -191,7 +192,7 @@
      } else {
 	 &Apache::loncommon::content_type($r,"text/html");
 	 &tth::tthinit();
-	 if ($ENV{'browser.unicode'}) {
+	 if ($env{'browser.unicode'}) {
 	     &tth::tthoptions('-L -u1');
 	 } else {
 	     &tth::tthoptions('-L -u0');
Index: loncom/interface/lonhelper.pm
diff -u loncom/interface/lonhelper.pm:1.99 loncom/interface/lonhelper.pm:1.100
--- loncom/interface/lonhelper.pm:1.99	Tue Feb 22 17:56:08 2005
+++ loncom/interface/lonhelper.pm	Thu Apr  7 02:56:23 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # .helper XML handler to implement the LON-CAPA helper
 #
-# $Id: lonhelper.pm,v 1.99 2005/02/22 22:56:08 foxr Exp $
+# $Id: lonhelper.pm,v 1.100 2005/04/07 06:56:23 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -25,10 +25,6 @@
 #
 # http://www.lon-capa.org/
 #
-# (Page Handler
-#
-# (.helper handler
-#
 
 =pod
 
@@ -186,6 +182,7 @@
 use Apache::File;
 use Apache::lonxml;
 use Apache::lonlocal;
+use Apache::lonnet;
 
 # Register all the tags with the helper, so the helper can 
 # push and pop them
@@ -255,7 +252,7 @@
     my $r = shift;
     my $uri = shift;
     if (!defined($uri)) { $uri = $r->uri(); }
-    $ENV{'request.uri'} = $uri;
+    $env{'request.uri'} = $uri;
     my $filename = '/home/httpd/html' . $uri;
     my $fh = Apache::File->new($filename);
     my $file;
@@ -263,7 +260,7 @@
 
 
     # Send header, don't cache this page
-    if ($ENV{'browser.mathml'}) {
+    if ($env{'browser.mathml'}) {
 	&Apache::loncommon::content_type($r,'text/xml');
     } else {
 	&Apache::loncommon::content_type($r,'text/html');
@@ -278,7 +275,7 @@
 
     my $allowed = $helper->allowedCheck();
     if (!$allowed) {
-        $ENV{'user.error.msg'} = $ENV{'request.uri'}.':'.$helper->{REQUIRED_PRIV}.
+        $env{'user.error.msg'} = $env{'request.uri'}.':'.$helper->{REQUIRED_PRIV}.
             ":0:0:Permission denied to access this helper.";
         return HTTP_NOT_ACCEPTABLE;
     }
@@ -363,6 +360,7 @@
 use Apache::loncommon;
 use Apache::File;
 use Apache::lonlocal;
+use Apache::lonnet;
 
 sub new {
     my $proto = shift;
@@ -374,16 +372,16 @@
     
     # If there is a state from the previous form, use that. If there is no
     # state, use the start state parameter.
-    if (defined $ENV{"form.CURRENT_STATE"})
+    if (defined $env{"form.CURRENT_STATE"})
     {
-	$self->{STATE} = $ENV{"form.CURRENT_STATE"};
+	$self->{STATE} = $env{"form.CURRENT_STATE"};
     }
     else
     {
 	$self->{STATE} = "START";
     }
 
-    $self->{TOKEN} = $ENV{'form.TOKEN'};
+    $self->{TOKEN} = $env{'form.TOKEN'};
     # If a token was passed, we load that in. Otherwise, we need to create a 
     # new storage file
     # Tried to use standard Tie'd hashes, but you can't seem to take a 
@@ -416,16 +414,16 @@
             return undef;
         }
         # Must create the storage
-        $self->{TOKEN} = md5_hex($ENV{'user.name'} . $ENV{'user.domain'} .
+        $self->{TOKEN} = md5_hex($env{'user.name'} . $env{'user.domain'} .
                                  time() . rand());
         $self->{FILENAME} = $Apache::lonnet::tmpdir . md5_hex($self->{TOKEN});
     }
 
     # OK, we now have our persistent storage.
 
-    if (defined $ENV{"form.RETURN_PAGE"})
+    if (defined $env{"form.RETURN_PAGE"})
     {
-	$self->{RETURN_PAGE} = $ENV{"form.RETURN_PAGE"};
+	$self->{RETURN_PAGE} = $env{"form.RETURN_PAGE"};
     }
     else
     {
@@ -486,11 +484,11 @@
     }
 
     my $envname = 'form.' . $var . '.forminput';
-    if (defined($ENV{$envname})) {
-        if (ref($ENV{$envname})) {
-            $self->{VARS}->{$var} = join('|||', @{$ENV{$envname}});
+    if (defined($env{$envname})) {
+        if (ref($env{$envname})) {
+            $self->{VARS}->{$var} = join('|||', @{$env{$envname}});
         } else {
-            $self->{VARS}->{$var} = $ENV{$envname};
+            $self->{VARS}->{$var} = $env{$envname};
         }
     }
 }
@@ -502,7 +500,7 @@
         return 1;
     }
 
-    return Apache::lonnet::allowed($self->{REQUIRED_PRIV}, $ENV{'request.course.id'});
+    return Apache::lonnet::allowed($self->{REQUIRED_PRIV}, $env{'request.course.id'});
 }
 
 sub changeState {
@@ -524,7 +522,7 @@
     # Phase 1: Post processing for state of previous screen (which is actually
     # the "current state" in terms of the helper variables), if it wasn't the 
     # beginning state.
-    if ($self->{STATE} ne "START" || $ENV{"form.SUBMIT"} eq &mt("Next ->")) {
+    if ($self->{STATE} ne "START" || $env{"form.SUBMIT"} eq &mt("Next ->")) {
 	my $prevState = $self->{STATES}{$self->{STATE}};
         $prevState->postprocess();
     }
@@ -1115,6 +1113,7 @@
 @ISA = ("Apache::lonhelper::element");
 use strict;
 use Apache::lonlocal;
+use Apache::lonnet;
 
 BEGIN {
     &Apache::lonhelper::register('Apache::lonhelper::choices',
@@ -1293,7 +1292,7 @@
 # given, switch to it
 sub postprocess {
     my $self = shift;
-    my $chosenValue = $ENV{'form.' . $self->{'variable'} . '.forminput'};
+    my $chosenValue = $env{'form.' . $self->{'variable'} . '.forminput'};
 
     if (!defined($chosenValue) && !$self->{'allowempty'}) {
         $self->{ERROR_MSG} = 
@@ -1347,6 +1346,7 @@
 @ISA = ("Apache::lonhelper::element");
 use strict;
 use Apache::lonlocal;
+use Apache::lonnet;
 
 BEGIN {
     &Apache::lonhelper::register('Apache::lonhelper::dropdown',
@@ -1447,7 +1447,7 @@
 # given, switch to it
 sub postprocess {
     my $self = shift;
-    my $chosenValue = $ENV{'form.' . $self->{'variable'} . '.forminput'};
+    my $chosenValue = $env{'form.' . $self->{'variable'} . '.forminput'};
 
     if (!defined($chosenValue) && !$self->{'allowempty'}) {
         $self->{ERROR_MSG} = "You must choose one or more choices to" .
@@ -1506,7 +1506,7 @@
 @ISA = ("Apache::lonhelper::element");
 use strict;
 use Apache::lonlocal; # A localization nightmare
-
+use Apache::lonnet;
 use Time::localtime;
 
 BEGIN {
@@ -1650,14 +1650,14 @@
 sub postprocess {
     my $self = shift;
     my $var = $self->{'variable'};
-    my $month = $ENV{'form.' . $var . 'month'}; 
-    my $day = $ENV{'form.' . $var . 'day'}; 
-    my $year = $ENV{'form.' . $var . 'year'}; 
+    my $month = $env{'form.' . $var . 'month'}; 
+    my $day = $env{'form.' . $var . 'day'}; 
+    my $year = $env{'form.' . $var . 'year'}; 
     my $min = 0; 
     my $hour = 0;
     if ($self->{'hoursminutes'}) {
-        $min = $ENV{'form.' . $var . 'minute'};
-        $hour = $ENV{'form.' . $var . 'hour'};
+        $min = $env{'form.' . $var . 'minute'};
+        $hour = $env{'form.' . $var . 'hour'};
     }
 
     my $chosenDate;
@@ -1757,6 +1757,7 @@
 no strict;
 @ISA = ("Apache::lonhelper::element");
 use strict;
+use Apache::lonnet;
 
 BEGIN {
     &Apache::lonhelper::register('Apache::lonhelper::resource',
@@ -2075,7 +2076,7 @@
 <input type="hidden" name="${var}_part.forminput" />;
 
 RADIO
-    $ENV{'form.condition'} = !$self->{'toponly'};
+    $env{'form.condition'} = !$self->{'toponly'};
     my $cols = [$renderColFunc];
     if ($self->{'addparts'}) { push(@$cols, $renderPartsFunc); }
     push(@$cols, Apache::lonnavmaps::resource());
@@ -2155,7 +2156,7 @@
 @ISA = ("Apache::lonhelper::element");
 use strict;
 use Apache::lonlocal;
-
+use Apache::lonnet;
 
 BEGIN {
     &Apache::lonhelper::register('Apache::lonhelper::student',
@@ -2371,7 +2372,7 @@
 sub postprocess {
     my $self = shift;
 
-    my $result = $ENV{'form.' . $self->{'variable'} . '.forminput'};
+    my $result = $env{'form.' . $self->{'variable'} . '.forminput'};
     if (!$result) {
         $self->{ERROR_MSG} = 
 	    &mt('You must choose at least one student to continue.');
@@ -2441,7 +2442,7 @@
 @ISA = ("Apache::lonhelper::element");
 use strict;
 use Apache::lonlocal;
-
+use Apache::lonnet;
 use Apache::lonpubdir; # for getTitleString
 
 BEGIN {
@@ -2605,7 +2606,7 @@
         @fileList = &Apache::lonnet::dirlist($subdir, $domain, $user, '');
     } else {
         # local library server resource space
-        @fileList = &Apache::lonnet::dirlist($subdir, $ENV{'user.domain'}, $ENV{'user.name'}, '');
+        @fileList = &Apache::lonnet::dirlist($subdir, $env{'user.domain'}, $env{'user.name'}, '');
     }
 
     # Sort the fileList into order
@@ -2698,9 +2699,9 @@
     my $constructionSpaceDir = shift;
     my $file = shift;
     
-    my ($uname,$udom)=($ENV{'user.name'},$ENV{'user.domain'});
-    if ($ENV{'request.role'}=~/^ca\./) {
-	(undef,$udom,$uname)=split(/\//,$ENV{'request.role'});
+    my ($uname,$udom)=($env{'user.name'},$env{'user.domain'});
+    if ($env{'request.role'}=~/^ca\./) {
+	(undef,$udom,$uname)=split(/\//,$env{'request.role'});
     }
     my $docroot = $Apache::lonnet::perlvar{'lonDocRoot'};
     my $subdirpart = $constructionSpaceDir;
@@ -2725,7 +2726,7 @@
 
 sub postprocess {
     my $self = shift;
-    my $result = $ENV{'form.' . $self->{'variable'} . '.forminput'};
+    my $result = $env{'form.' . $self->{'variable'} . '.forminput'};
     if (!$result) {
         $self->{ERROR_MSG} = 'You must choose at least one file '.
             'to continue.';
@@ -2932,7 +2933,7 @@
 =head2 General-purpose tag: <exec>X<exec, helper tag>
 
 The contents of the exec tag are executed as Perl code, B<not> inside a 
-safe space, so the full range of $ENV and such is available. The code
+safe space, so the full range of $env and such is available. The code
 will be executed as a subroutine wrapped with the following code:
 
 "sub { my $helper = shift; my $state = shift;" and
@@ -3085,6 +3086,7 @@
 @ISA = ("Apache::lonhelper::element");
 use strict;
 use Apache::lonlocal;
+use Apache::lonnet;
 BEGIN {
     &Apache::lonhelper::register('Apache::lonhelper::final',
                                  ('final', 'exitpage'));
@@ -3182,12 +3184,12 @@
     if ($self->{'restartCourse'}) {
 	my $actionURL = '/adm/roles';
 	$targetURL = '/adm/menu';
-	if ($ENV{'course.'.$ENV{'request.course.id'}.'.url'}=~/^uploaded/) {
+	if ($env{'course.'.$env{'request.course.id'}.'.url'}=~/^uploaded/) {
 	    $targetURL = '/adm/coursedocs';
 	} else {
 	    $targetURL = '/adm/navmaps';
 	}
-	if ($ENV{'course.'.$ENV{'request.course.id'}.'.clonedfrom'}) {
+	if ($env{'course.'.$env{'request.course.id'}.'.clonedfrom'}) {
 	    $targetURL = '/adm/parmset?overview=1';
 	}
 	my $finish=&mt('Finish Course Initialization');
@@ -3199,7 +3201,7 @@
 	"<input type='button' onclick='history.go(-1)' value='$previous' />" .
 	"<input type='hidden' name='orgurl' value='$targetURL' />" .
 	"<input type='hidden' name='selectrole' value='1' />\n" .
-	"<input type='hidden' name='" . $ENV{'request.role'} . 
+	"<input type='hidden' name='" . $env{'request.role'} . 
 	"' value='1' />\n<input type='submit' value='" . $finish . "' />\n" .
 	"</form></center>";
 
Index: loncom/interface/lonhelpmenu.pm
diff -u loncom/interface/lonhelpmenu.pm:1.19 loncom/interface/lonhelpmenu.pm:1.20
--- loncom/interface/lonhelpmenu.pm:1.19	Thu Feb 17 03:29:42 2005
+++ loncom/interface/lonhelpmenu.pm	Thu Apr  7 02:56:23 2005
@@ -31,6 +31,7 @@
 use Apache::Constants qw(:common);
 use Apache::loncommon();
 use Apache::lonlocal;
+use Apache::lonnet;
 
 sub handler {
     my ($r) = @_;
@@ -41,14 +42,14 @@
     if ($r->header_only) {
         return OK;
     }
-    my $color = $ENV{'form.color'};
-    my $faq = $ENV{'form.faq'};
-    my $bug = $ENV{'form.bug'};
-    my $topic = $ENV{'form.topic'};
-    my $function = $ENV{'form.function'};
-    my $component_help = $ENV{'form.component_help'};
-    my $origurl = $ENV{'form.origurl'};
-    my $stayOnPage = $ENV{'form.stayonpage'};
+    my $color = $env{'form.color'};
+    my $faq = $env{'form.faq'};
+    my $bug = $env{'form.bug'};
+    my $topic = $env{'form.topic'};
+    my $function = $env{'form.function'};
+    my $component_help = $env{'form.component_help'};
+    my $origurl = $env{'form.origurl'};
+    my $stayOnPage = $env{'form.stayonpage'};
     my $component_url = $component_help;
     if ($component_url) {
         $component_url = '/adm/help/'.$component_url.'.hlp';
@@ -60,9 +61,9 @@
     }
     my $faqbaseurl = $Apache::lonnet::perlvar{'FAQHost'};
     my $requestmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
-    if ($ENV{'form.page'} eq 'banner') {
+    if ($env{'form.page'} eq 'banner') {
         &display_help_banner($r,$color,$function,$faq,$bug,$topic,$component_url,$origurl,$bugurl,$faqbaseurl,$requestmail,$stayOnPage);
-    } elsif ($ENV{'form.page'} eq 'body') {
+    } elsif ($env{'form.page'} eq 'body') {
         &display_help_mainpage($r,$color,$function,$faq,$bug,$topic,$component_url,$origurl,$bugurl,$faqbaseurl,$requestmail);
     }
     return OK;
@@ -176,11 +177,11 @@
 	  <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#ffffff">
            <tr bgcolor="$tablecolor">
 END
-    if (($component_url) || ($ENV{'user.adv'})) {
+    if (($component_url) || ($env{'user.adv'})) {
         if ($component_url) {
             $r->print("
             <td align=\"center\"><b><a href=\"$component_url\" target=\"bodyframe\">");
-        } elsif ($ENV{'user.adv'}) {
+        } elsif ($env{'user.adv'}) {
             $r->print('<td align="center">&nbsp;<b><a href="/adm/help/nohelptopic.html" target="bodyframe">');
         }
         $r->print('
@@ -190,14 +191,14 @@
         $r->print('
             <td align="center">&nbsp;<b><a href="javascript:gohelpdesk()"><img src="'.$location.'/lonIcons/helpdesk.gif" border="0" alt="(Ask helpdesk)" valign="middle" />&nbsp;Ask helpdesk</a></b>&nbsp;</td>');
     }
-    if ($faq && $ENV{'user.adv'}) {
+    if ($faq && $env{'user.adv'}) {
         $r->print(<<END);
             <td align="center">
              &nbsp;<b><a href="$faqbaseurl/fom/cache/$faq.html" target="bodyframe"><img src="$location/lonMisc/smallFAQ.gif" border="0" alt="(FAQ)" valign="middle" />&nbsp;FAQ</a></b>&nbsp;
             </td>
 END
     }
-    if ($ENV{'user.adv'}) {
+    if ($env{'user.adv'}) {
         $r->print(<<END);
             <td align="center">&nbsp;<b><a href="$bugurl" target="bodyframe"><img src="$location/lonMisc/smallBug.gif" border="0" alt="(Report a bug)" valign="middle" />&nbsp;Report a bug</a>&nbsp;</b></td>
 END
@@ -274,7 +275,7 @@
         $r->print(".");
     }
     if ($topic) {
-        if ( ($component_url) || ($ENV{'user.adv'}) ) {
+        if ( ($component_url) || ($env{'user.adv'}) ) {
             if ($component_url) {
                 $r->print("
           <ul>
@@ -282,7 +283,7 @@
           </ul>
           <p>$lt{'disp'}</p>
                 ");
-            } elsif ($ENV{'user.adv'}) {
+            } elsif ($env{'user.adv'}) {
                 $r->print("
               <ul>
                <li><td align=\"center\">&nbsp;<a href=\"/adm/help/nohelptopic.html\">$lt{'inhs'} $topic</a></li></ul>
@@ -296,12 +297,12 @@
            <li><a href=\"/adm/support?origurl=".&Apache::lonnet::escape($origurl)."&function=$function\">$lt{'cont'}</a></li>
           </ul>
           <p>$lt{'suhr'}");
-         unless ($ENV{'user.adv'}) {
+         unless ($env{'user.adv'}) {
              $r->print('<br /><b>'.&mt('Note').'</b>: '.$lt{'stuq'}.'. '.&mt('This can be done using the').' <a href="/adm/communicate" target="_top">'.&mt('COM').'</a> '.&mt('button, or the FDBK button when viewing a content page.'));
          }
          $r->print("</p>");
     }
-    if ($faqbaseurl && $ENV{'user.adv'}) {
+    if ($faqbaseurl && $env{'user.adv'}) {
         if (!defined($faq) ||$faq eq '') {
             $faq = '1';
         }
@@ -312,7 +313,7 @@
           <p>$lt{'tfaq'}</p>
         ");
     }
-    if ($bugurl && $ENV{'user.adv'}) {
+    if ($bugurl && $env{'user.adv'}) {
         $bugurl .= '?'.$bug;
         $r->print("
           <ul>
Index: loncom/interface/lonhtmlcommon.pm
diff -u loncom/interface/lonhtmlcommon.pm:1.103 loncom/interface/lonhtmlcommon.pm:1.104
--- loncom/interface/lonhtmlcommon.pm:1.103	Thu Feb 17 03:29:42 2005
+++ loncom/interface/lonhtmlcommon.pm	Thu Apr  7 02:56:23 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common html routines
 #
-# $Id: lonhtmlcommon.pm,v 1.103 2005/02/17 08:29:42 albertel Exp $
+# $Id: lonhtmlcommon.pm,v 1.104 2005/04/07 06:56:23 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -55,10 +55,11 @@
 
 package Apache::lonhtmlcommon;
 
+use strict;
 use Time::Local;
 use Time::HiRes;
 use Apache::lonlocal;
-use strict;
+use Apache::lonnet;
 
 ##############################################
 ##############################################
@@ -435,8 +436,8 @@
     my ($dname) = @_;
     my ($sec,$min,$hour,$day,$month,$year);
     #
-    if (defined($ENV{'form.'.$dname.'_second'})) {
-        my $tmpsec = $ENV{'form.'.$dname.'_second'};
+    if (defined($env{'form.'.$dname.'_second'})) {
+        my $tmpsec = $env{'form.'.$dname.'_second'};
         if (($tmpsec =~ /^\d+$/) && ($tmpsec >= 0) && ($tmpsec < 60)) {
             $sec = $tmpsec;
         }
@@ -444,8 +445,8 @@
     } else {
         $sec = 0;
     }
-    if (defined($ENV{'form.'.$dname.'_minute'})) {
-        my $tmpmin = $ENV{'form.'.$dname.'_minute'};
+    if (defined($env{'form.'.$dname.'_minute'})) {
+        my $tmpmin = $env{'form.'.$dname.'_minute'};
         if (($tmpmin =~ /^\d+$/) && ($tmpmin >= 0) && ($tmpmin < 60)) {
             $min = $tmpmin;
         }
@@ -453,28 +454,28 @@
     } else {
         $min = 0;
     }
-    if (defined($ENV{'form.'.$dname.'_hour'})) {
-        my $tmphour = $ENV{'form.'.$dname.'_hour'};
+    if (defined($env{'form.'.$dname.'_hour'})) {
+        my $tmphour = $env{'form.'.$dname.'_hour'};
         if (($tmphour =~ /^\d+$/) && ($tmphour >= 0) && ($tmphour < 24)) {
             $hour = $tmphour;
         }
     } else {
         $hour = 0;
     }
-    if (defined($ENV{'form.'.$dname.'_day'})) {
-        my $tmpday = $ENV{'form.'.$dname.'_day'};
+    if (defined($env{'form.'.$dname.'_day'})) {
+        my $tmpday = $env{'form.'.$dname.'_day'};
         if (($tmpday =~ /^\d+$/) && ($tmpday > 0) && ($tmpday < 32)) {
             $day = $tmpday;
         }
     }
-    if (defined($ENV{'form.'.$dname.'_month'})) {
-        my $tmpmonth = $ENV{'form.'.$dname.'_month'};
+    if (defined($env{'form.'.$dname.'_month'})) {
+        my $tmpmonth = $env{'form.'.$dname.'_month'};
         if (($tmpmonth =~ /^\d+$/) && ($tmpmonth > 0) && ($tmpmonth < 13)) {
             $month = $tmpmonth - 1;
         }
     }
-    if (defined($ENV{'form.'.$dname.'_year'})) {
-        my $tmpyear = $ENV{'form.'.$dname.'_year'};
+    if (defined($env{'form.'.$dname.'_year'})) {
+        my $tmpyear = $env{'form.'.$dname.'_year'};
         if (($tmpyear =~ /^\d+$/) && ($tmpyear > 1900)) {
             $year = $tmpyear - 1900;
         }
@@ -536,8 +537,8 @@
     my $nothing = "''";
     my $user_browser;
     my $user_os;
-    $user_browser = $ENV{'browser.type'} if (exists($ENV{'browser.type'}));
-    $user_os      = $ENV{'browser.os'}   if (exists($ENV{'browser.os'}));
+    $user_browser = $env{'browser.type'} if (exists($env{'browser.type'}));
+    $user_os      = $env{'browser.os'}   if (exists($env{'browser.os'}));
     if (! defined($user_browser) || ! defined($user_os)) {
         (undef,$user_browser,undef,undef,undef,$user_os) = 
                            &Apache::loncommon::decode_user_agent();
@@ -555,8 +556,8 @@
     my $nothing = "''";
     my $user_browser;
     my $user_os;
-    $user_browser = $ENV{'browser.type'} if (exists($ENV{'browser.type'}));
-    $user_os      = $ENV{'browser.os'}   if (exists($ENV{'browser.os'}));
+    $user_browser = $env{'browser.type'} if (exists($env{'browser.type'}));
+    $user_os      = $env{'browser.os'}   if (exists($env{'browser.os'}));
     if (! defined($user_browser) || ! defined($user_os)) {
         (undef,$user_browser,undef,undef,undef,$user_os) = 
                            &Apache::loncommon::decode_user_agent();
@@ -583,7 +584,7 @@
 Inputs:
 
 $status: the currently selected status.  If undefined the value of
-$ENV{'form.Status'} is taken.  If that is undefined, a value of 'Active'
+$env{'form.Status'} is taken.  If that is undefined, a value of 'Active'
 is used.
 
 $formname: The name of the form.  If defined the onchange attribute of
@@ -605,7 +606,7 @@
     $size = 1 if (!defined($size));
     if (! defined($status)) {
         $status = 'Active';
-        $status = $ENV{'form.Status'} if (exists($ENV{'form.Status'}));
+        $status = $env{'form.Status'} if (exists($env{'form.Status'}));
     }
 
     my $OpSel1 = '';
@@ -855,8 +856,8 @@
         $lasttime = '('.$lasttime.' '.&mt('seconds for').' '.$extraInfo.')';
     }
     #
-    my $user_browser = $ENV{'browser.type'} if (exists($ENV{'browser.type'}));
-    my $user_os      = $ENV{'browser.os'}   if (exists($ENV{'browser.os'}));
+    my $user_browser = $env{'browser.type'} if (exists($env{'browser.type'}));
+    my $user_os      = $env{'browser.os'}   if (exists($env{'browser.os'}));
     if (! defined($user_browser) || ! defined($user_os)) {
         (undef,$user_browser,undef,undef,undef,$user_os) = 
                            &Apache::loncommon::decode_user_agent();
@@ -907,7 +908,7 @@
     my $output='';
     unless ($noformat) { $output.='<br /><tt><b>'; }
     $output.='<font size="'.$size.'">'.$prefix.'/';
-    if ($ENV{'user.adv'}) {
+    if ($env{'user.adv'}) {
 	my $path=$prefix.'/';
 	foreach my $dir (split('/',$uri)) {
             if (! $dir) { next; }
@@ -1035,7 +1036,7 @@
 # --------------------------------------------------------------------- Blocked
 
 sub htmlareablocked {
-    unless ($ENV{'environment.wysiwygeditor'} eq 'on') { return 1; }
+    unless ($env{'environment.wysiwygeditor'} eq 'on') { return 1; }
     return 0;
 }
 
@@ -1117,10 +1118,10 @@
 	if (!defined($menulink)) { $menulink=1; }
         if ($menulink) {
             my $description = 'Menu';
-            if (exists($ENV{'request.course.id'}) && 
-                $ENV{'request.course.id'} ne '') {
+            if (exists($env{'request.course.id'}) && 
+                $env{'request.course.id'} ne '') {
                 $description = 
-                    $ENV{'course.'.$ENV{'request.course.id'}.'.description'};
+                    $env{'course.'.$env{'request.course.id'}.'.description'};
             }
             unshift(@Crumbs,{
                     href   =>'/adm/menu',
Index: loncom/interface/lonindexer.pm
diff -u loncom/interface/lonindexer.pm:1.132 loncom/interface/lonindexer.pm:1.133
--- loncom/interface/lonindexer.pm:1.132	Thu Mar  3 02:53:55 2005
+++ loncom/interface/lonindexer.pm	Thu Apr  7 02:56:23 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Directory Indexer
 #
-# $Id: lonindexer.pm,v 1.132 2005/03/03 07:53:55 albertel Exp $
+# $Id: lonindexer.pm,v 1.133 2005/04/07 06:56:23 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -44,7 +44,7 @@
 
 # ------------------------------------------------- modules used by this module
 use strict;
-use Apache::lonnet();
+use Apache::lonnet;
 use Apache::loncommon();
 use Apache::lonhtmlcommon();
 use Apache::lonsequence();
@@ -119,7 +119,7 @@
 
     $extrafield='';
     my $diropendb = 
-	"/home/httpd/perl/tmp/$ENV{'user.domain'}_$ENV{'user.name'}_indexer.db";
+	"/home/httpd/perl/tmp/$env{'user.domain'}_$env{'user.name'}_indexer.db";
     %hash = ();
     {
 	my %dbfile;
@@ -131,19 +131,19 @@
 	}
     }
     {
-	if ($ENV{'form.launch'} eq '1') {
+	if ($env{'form.launch'} eq '1') {
 	    &start_fresh_session();
    }
   #Hijack lonindexer to verify a title and be close down.
-   if ($ENV{'form.launch'} eq '2') {
+   if ($env{'form.launch'} eq '2') {
        &Apache::loncommon::content_type($r,'text/html');
        my $extra='';
-       if (defined($ENV{'form.titleelement'}) && 
-	   $ENV{'form.titleelement'} ne '') {
-	   my $verify_title = &Apache::lonnet::gettitle($ENV{'form.acts'});
-#	   &Apache::lonnet::logthis("Hrrm $ENV{'form.acts'} -- $verify_title");
+       if (defined($env{'form.titleelement'}) && 
+	   $env{'form.titleelement'} ne '') {
+	   my $verify_title = &Apache::lonnet::gettitle($env{'form.acts'});
+#	   &Apache::lonnet::logthis("Hrrm $env{'form.acts'} -- $verify_title");
 	   $verify_title=~s/'/\\'/g;
-	   $extra='window.opener.document.forms["'.$ENV{'form.form'}.'"].elements["'.$ENV{'form.titleelement'}.'"].value=\''.$verify_title.'\';';
+	   $extra='window.opener.document.forms["'.$env{'form.form'}.'"].elements["'.$env{'form.titleelement'}.'"].value=\''.$verify_title.'\';';
        }
        my $html=&Apache::lonxml::xmlbegin();
        $r->print(<<ENDSUBM);
@@ -152,9 +152,9 @@
 	     <head>
 	       <script type="text/javascript">
 		function load() {
-			window.opener.document.forms["$ENV{'form.form'}"]
-			    .elements["$ENV{'form.element'}"]
-			    .value='$ENV{'form.acts'}';
+			window.opener.document.forms["$env{'form.form'}"]
+			    .elements["$env{'form.element'}"]
+			    .value='$env{'form.acts'}';
 			$extra
 			window.close();
 		}
@@ -168,10 +168,10 @@
    }
     
 # -------------------- refresh environment with user database values (in %hash)
-	&setvalues(\%hash,'form.catalogmode',\%ENV,'form.catalogmode'   );
+	&setvalues(\%hash,'form.catalogmode',\%env,'form.catalogmode'   );
 
 # --------------------- define extra fields and buttons in case of special mode
-	if ($ENV{'form.catalogmode'} eq 'interactive') {
+	if ($env{'form.catalogmode'} eq 'interactive') {
 	    $extrafield='<td bgcolor="'.$fileclr.'" valign="bottom">'.
 		'<a name="$anchor"><img src="'.$iconpath.'whitespace1.gif"'.
 		' border="0" /></td>';
@@ -181,7 +181,7 @@
 <input type="button" name="close" value='$cl' onClick="self.close()" />
 END
         }
-	elsif ($ENV{'form.catalogmode'} eq 'groupimport') {
+	elsif ($env{'form.catalogmode'} eq 'groupimport') {
 	    $extrafield='<td bgcolor="'.$fileclr.'" valign="bottom">'.
 		'<a name="$anchor"><img src="'.$iconpath.'whitespace1.gif"'.
 		' border="0" /></td>';
@@ -205,33 +205,33 @@
 	# $element is the name of the element in $formname which receives
 	#       the URL.
 	#&Apache::lonxml::debug('Checking mode, form, element');
-	&setvalues(\%hash,'form.mode'        ,\%ENV,'form.mode'   );
-	&setvalues(\%hash,'form.form'        ,\%ENV,'form.form'   );
-	&setvalues(\%hash,'form.element'     ,\%ENV,'form.element');
-	&setvalues(\%hash,'form.titleelement',\%ENV,'form.titleelement');
-	&setvalues(\%hash,'form.only'        ,\%ENV,'form.only'   );
-	&setvalues(\%hash,'form.omit'        ,\%ENV,'form.omit'   );
+	&setvalues(\%hash,'form.mode'        ,\%env,'form.mode'   );
+	&setvalues(\%hash,'form.form'        ,\%env,'form.form'   );
+	&setvalues(\%hash,'form.element'     ,\%env,'form.element');
+	&setvalues(\%hash,'form.titleelement',\%env,'form.titleelement');
+	&setvalues(\%hash,'form.only'        ,\%env,'form.only'   );
+	&setvalues(\%hash,'form.omit'        ,\%env,'form.omit'   );
 
         # Deal with 'omit' and 'only' 
-        if (exists $ENV{'form.omit'}) {
-            @Omit = split(',',$ENV{'form.omit'});
+        if (exists $env{'form.omit'}) {
+            @Omit = split(',',$env{'form.omit'});
         }
-        if (exists $ENV{'form.only'}) {
-            @Only = split(',',$ENV{'form.only'});
+        if (exists $env{'form.only'}) {
+            @Only = split(',',$env{'form.only'});
         }
         
-	my $mode = $ENV{'form.mode'};
+	my $mode = $env{'form.mode'};
 	my ($form,$element,$titleelement);
 	if ($mode eq 'edit' || $mode eq 'parmset') {
-	    $form         = $ENV{'form.form'};
-	    $element      = $ENV{'form.element'};
-	    $titleelement = $ENV{'form.titleelement'};
+	    $form         = $env{'form.form'};
+	    $element      = $env{'form.element'};
+	    $titleelement = $env{'form.titleelement'};
 	}
 	#&Apache::lonxml::debug("mode=$mode form=$form element=$element titleelement=$titleelement");
 # ------ set catalogmodefunctions to have extra needed javascript functionality
 	my $catalogmodefunctions='';
-	if ($ENV{'form.catalogmode'} eq 'interactive' or
-	    $ENV{'form.catalogmode'} eq 'groupimport') {
+	if ($env{'form.catalogmode'} eq 'interactive' or
+	    $env{'form.catalogmode'} eq 'groupimport') {
 	    # The if statement below sets us up to use the old version
 	    # by default (ie. if $mode is undefined).  This is the easy
 	    # way out.  Hopefully in the future I'll find a way to get 
@@ -329,7 +329,7 @@
     eval("document.forms.dirpath"+suffix+".acts.value=val");
 }
 END
-	if ($ENV{'form.catalogmode'} eq 'groupimport') {
+	if ($env{'form.catalogmode'} eq 'groupimport') {
             $catalogmodefunctions.=<<END;
 function queue(val) {
     if (eval("document.forms."+val+".filelink.checked")) {
@@ -379,8 +379,8 @@
 $r->print(&Apache::loncommon::bodytag('Browse Resources',undef,undef,undef,
 				      $headerdom));
 # - Evaluate actions from previous page (both cumulatively and chronologically)
-        if ($ENV{'form.catalogmode'} eq 'groupimport') {
-	    my $acts=$ENV{'form.acts'};
+        if ($env{'form.catalogmode'} eq 'groupimport') {
+	    my $acts=$env{'form.acts'};
 	    my @Acts=split(/b/,$acts);
 	    my %ahash;
 	    my %achash;
@@ -421,10 +421,10 @@
 	}
 	
 # ---------------------------------- get state of file attributes to be showing
-	if ($ENV{'form.attrs'}) {
+	if ($env{'form.attrs'}) {
 	    for (my $i=0; $i<=11; $i++) {
 		delete $hash{'display_attrs_'.$i};
-		if ($ENV{'form.attr'.$i} == 1) {
+		if ($env{'form.attr'.$i} == 1) {
 		    $attrchk[$i] = 'checked';
 		    $hash{'display_attrs_'.$i} = 1;
 		}
@@ -488,15 +488,15 @@
 	$storeuri=~s/\/+/\//g;
 # ---------------------------------------------------------------- Bread crumbs
         $r->print(&Apache::lonhtmlcommon::crumbs($storeuri,'','',
-				(($ENV{'form.catalogmode'} eq 'groupimport')?
+				(($env{'form.catalogmode'} eq 'groupimport')?
 				 'document.forms.fileattr':'')).
 		  &Apache::lonhtmlcommon::select_recent('residx','resrecent',
 'window.status=this.form.resrecent.options[this.form.resrecent.selectedIndex].value;this.form.action=this.form.resrecent.options[this.form.resrecent.selectedIndex].value;this.form.submit();'));
 # -------------------------------------------------------- Resource Home Button
-	my $reshome=$ENV{'course.'.$ENV{'request.course.id'}.'.reshome'};
+	my $reshome=$env{'course.'.$env{'request.course.id'}.'.reshome'};
 	if ($reshome) {
 	    $r->print("<font size='+2'><a href='");
-	    if ($ENV{'form.catalogmode'} eq 'groupimport') {
+	    if ($env{'form.catalogmode'} eq 'groupimport') {
 		$r->print('javascript:document.forms.fileattr.action="'.$reshome.'";document.forms.fileattr.submit();');
 	    } else {
 		$r->print($reshome);
@@ -549,8 +549,8 @@
 	    }
 	}
 
-	if ($ENV{'form.openuri'}) {  # take care of review and refresh options
-	    my $uri=$ENV{'form.openuri'};
+	if ($env{'form.openuri'}) {  # take care of review and refresh options
+	    my $uri=$env{'form.openuri'};
 	    if (exists($hash{'diropen_status_'.$uri})) {
 		my $cursta = $hash{'diropen_status_'.$uri};
 		$dirs{$uri} = 'open';
@@ -569,7 +569,7 @@
 	my $indent = 0;
 	$uri = $uri.'/' if $uri !~ /.*\/$/;
 
- 	if ($ENV{'form.dirPointer'} ne 'on') {
+ 	if ($env{'form.dirPointer'} ne 'on') {
  	    $hash{'top.level'} = $uri;
  	    $toplevel = $uri;
  	} else {
@@ -670,7 +670,7 @@
     my ($r,$uri)=@_;
     my @list=();
     (my $luri = $uri) =~ s/\//_/g;
-    if ($ENV{'form.updatedisplay'}) {
+    if ($env{'form.updatedisplay'}) {
 	foreach (keys %hash) {
 	    delete $hash{$_} if ($_ =~ /^dirlist_files_/);
 	    delete $hash{$_} if ($_ =~ /^dirlist_timestamp_files_/);
@@ -842,7 +842,7 @@
 # display domain
     if ($filecom[1] eq 'domain') {
  	$r->print ('<input type="hidden" name="dirPointer" value="on" />'."\n")
- 	    if ($ENV{'form.dirPointer'} eq "on");
+ 	    if ($env{'form.dirPointer'} eq "on");
 	$r->print("<tr valign='$valign' bgcolor=$fileclr>$extrafield");
 	$r->print("<td>");
 	&begin_form ($r,$filecom[0]);
@@ -912,14 +912,14 @@
 	my $iconname = &Apache::loncommon::icon($listname);
 	$r->print("<tr valign='$valign' bgcolor=$fileclr><td nowrap='nowrap' valign='top'>");
 	
-        if ($ENV{'form.catalogmode'} eq 'interactive') {
+        if ($env{'form.catalogmode'} eq 'interactive') {
 	    my $quotable_filelink = &Apache::loncommon::escape_single($filelink);
             $r->print("<a href=\"javascript:select_data(\'",
                       $quotable_filelink,"')\">");
 	    $r->print("<img src='",$iconpath,"select.gif' border='0' /></a>".
 		      "\n");
 	    $r->print("</td><td nowrap>");
-	} elsif ($ENV{'form.catalogmode'} eq 'groupimport') {
+	} elsif ($env{'form.catalogmode'} eq 'groupimport') {
 	    $r->print("<form name='form$fnum'>\n");
 	    $r->print("<input type='checkbox' name='filelink"."' ".
 		      "value='$filelink' onClick='".
@@ -1067,7 +1067,7 @@
 	    if ($embstyle eq 'ssi') {
 		my $cache=$Apache::lonnet::perlvar{'lonDocRoot'}.$filelink.
 		    '.tmp';
-		if ((!$ENV{'form.updatedisplay'}) &&
+		if ((!$env{'form.updatedisplay'}) &&
 		    (-e $cache)) {
 		    open(FH,$cache);
 		    $output=join("\n",<FH>);
@@ -1184,9 +1184,9 @@
 	$r->print("\n<br />".$fieldnames{$item}.': '.
 		  &Apache::lonmeta::prettyprint($item,
 						$dynhash{$filelink}->{$item},
-		  (($ENV{'form.catalogmode'} ne 'groupimport')?'preview':''),
+		  (($env{'form.catalogmode'} ne 'groupimport')?'preview':''),
 		  '',
-		  (($ENV{'form.catalogmode'} eq 'groupimport')?'document.forms.fileattr':''),1));
+		  (($env{'form.catalogmode'} eq 'groupimport')?'document.forms.fileattr':''),1));
     }
 }
 
Index: loncom/interface/lonmanagekeys.pm
diff -u loncom/interface/lonmanagekeys.pm:1.16 loncom/interface/lonmanagekeys.pm:1.17
--- loncom/interface/lonmanagekeys.pm:1.16	Thu Feb 17 03:29:42 2005
+++ loncom/interface/lonmanagekeys.pm	Thu Apr  7 02:56:23 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to manage course access keys 
 #
-# $Id: lonmanagekeys.pm,v 1.16 2005/02/17 08:29:42 albertel Exp $
+# $Id: lonmanagekeys.pm,v 1.17 2005/04/07 06:56:23 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -31,7 +31,7 @@
 package Apache::lonmanagekeys;
 
 use strict;
-use Apache::lonnet();
+use Apache::lonnet;
 use Apache::loncommon();
 use Apache::lonhtmlcommon();
 use Apache::Constants qw(:common :http REDIRECT);
@@ -158,10 +158,10 @@
     my %cenv=@_;
     my %newcomment=();
     undef %newcomment;
-    foreach (keys %ENV) {
+    foreach (keys %env) {
 	if ($_=~/^form\.com\_(.+)$/) {
             my $key=$1;
-	    my $comment=$ENV{$_};
+	    my $comment=$env{$_};
             $comment=~s/^\s+//gs;
             if ($comment) {
                &Apache::lonnet::comment_access_key
@@ -182,20 +182,20 @@
     }
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
 					    ['state','cid']);
-    if (($ENV{'form.domain'}) && ($ENV{'form.course'})) {
-	$ENV{'form.cid'}=$ENV{'form.domain'}.'_'.$ENV{'form.course'};
+    if (($env{'form.domain'}) && ($env{'form.course'})) {
+	$env{'form.cid'}=$env{'form.domain'}.'_'.$env{'form.course'};
     }
 
-    unless (&Apache::lonnet::allowed('mky',$ENV{'request.role.domain'})) {
-        $ENV{'user.error.msg'}=
+    unless (&Apache::lonnet::allowed('mky',$env{'request.role.domain'})) {
+        $env{'user.error.msg'}=
             "/adm/managekeys:mky:0:0:Cannot manage access keys";
         return HTTP_NOT_ACCEPTABLE; 
     }
-    if ($ENV{'form.cid'}) {
-	my %cenv=&Apache::lonnet::coursedescription($ENV{'form.cid'});
+    if ($env{'form.cid'}) {
+	my %cenv=&Apache::lonnet::coursedescription($env{'form.cid'});
 	my $keytype='';
 	if ($cenv{'url'} eq '/res/') {
-	    ($cenv{'domain'},$cenv{'num'})=split(/\_/,$ENV{'form.cid'});
+	    ($cenv{'domain'},$cenv{'num'})=split(/\_/,$env{'form.cid'});
 	    $keytype='auth';
 	} elsif ($cenv{'keyauth'}) {
 	    ($cenv{'num'},$cenv{'domain'})=split(/\W/,$cenv{'keyauth'});
@@ -203,7 +203,7 @@
 	} else {
 	    $keytype='course';
 	}
-  	if ($ENV{'form.listkeyscsv'}) {
+  	if ($env{'form.listkeyscsv'}) {
 #
 # CSV Output
 #
@@ -212,8 +212,8 @@
 #
 # Do CSV
 #
-	    &show_key_list($r,1,$ENV{'form.listcom'},
-                          $ENV{'form.newonly'},$ENV{'form.checkonly'},%cenv);
+	    &show_key_list($r,1,$env{'form.listcom'},
+                          $env{'form.newonly'},$env{'form.checkonly'},%cenv);
 
 	} else {
 #
@@ -224,23 +224,23 @@
 	    $r->print(&header());
 	
 	    $r->print(
-	    '<input type="hidden" name="cid" value="'.$ENV{'form.cid'}.'" />');
+	    '<input type="hidden" name="cid" value="'.$env{'form.cid'}.'" />');
 # --- Actions
-	    if ($ENV{'form.toggle'}) {
+	    if ($env{'form.toggle'}) {
 		$r->print(&togglekeyaccess(%cenv).'<br />');
-		%cenv=&Apache::lonnet::coursedescription($ENV{'form.cid'});
+		%cenv=&Apache::lonnet::coursedescription($env{'form.cid'});
 	    }
             my $batchnumber='';
-	    if ($ENV{'form.genkeys'}) {
+	    if ($env{'form.genkeys'}) {
 		(my $msg,$batchnumber)=
-		    &genkeys($ENV{'form.num'},$ENV{'form.comments'},%cenv);
+		    &genkeys($env{'form.num'},$env{'form.comments'},%cenv);
                 $r->print($msg.'<br />');
 	    }
-            if ($ENV{'form.listkeys'}) {
-		&show_key_list($r,0,$ENV{'form.listcom'},
-                          $ENV{'form.newonly'},$ENV{'form.checkonly'},%cenv);
+            if ($env{'form.listkeys'}) {
+		&show_key_list($r,0,$env{'form.listcom'},
+                          $env{'form.newonly'},$env{'form.checkonly'},%cenv);
             }
-            if ($ENV{'form.addcom'}) {
+            if ($env{'form.addcom'}) {
 		&addcom(%cenv);
             }
 # --- Menu
@@ -279,7 +279,7 @@
         $r->print(
    &mt('Course ID of Key Authority').': <input input type="text" size="25" name="course" value="" />');
         $r->print(&mt('Domain').': '.&Apache::loncommon::select_dom_form(
-               $ENV{'request.role.domain'},'domain'));
+               $env{'request.role.domain'},'domain'));
         $r->print(&Apache::loncommon::selectcourse_link(
 					        'keyform','course','domain'));
         $r->print('<br /><input type="submit" value="'.&mt('Manage Access Keys').'" />');
Index: loncom/interface/lonmenu.pm
diff -u loncom/interface/lonmenu.pm:1.151 loncom/interface/lonmenu.pm:1.152
--- loncom/interface/lonmenu.pm:1.151	Thu Mar 10 10:32:03 2005
+++ loncom/interface/lonmenu.pm	Thu Apr  7 02:56:23 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines to control the menu
 #
-# $Id: lonmenu.pm,v 1.151 2005/03/10 15:32:03 www Exp $
+# $Id: lonmenu.pm,v 1.152 2005/04/07 06:56:23 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -39,7 +39,7 @@
 package Apache::lonmenu;
 
 use strict;
-use Apache::lonnet();
+use Apache::lonnet;
 use Apache::Constants qw(:common);
 use Apache::lonhtmlcommon();
 use Apache::loncommon();
@@ -60,7 +60,7 @@
     return &Apache::lonlocal::texthash('ret' => 'Return to Last Location',
 				       'nav' => 'Navigate Contents',
 				       'main' => 'Main Menu',
-                                       'roles' => ($ENV{'user.adv'}?
+                                       'roles' => ($env{'user.adv'}?
                                                     'Roles':'Courses'),
                                        'docs' => 'Course Documents',
                                        'exit' => 'Exit',
@@ -76,40 +76,40 @@
     my $titletable=shift;
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
 					    ['inhibitmenu']);
-    if (($ENV{'form.inhibitmenu'} eq 'yes') ||
+    if (($env{'form.inhibitmenu'} eq 'yes') ||
         ($ENV{'REQUEST_URI'} eq '/adm/logout')) { return ''; }
 
     my $navmaps='';
     my $reloadlink='';
     my $docs='';
-    my $escurl=&Apache::lonnet::escape(&Apache::lonenc::check_encrypt($ENV{'request.noversionuri'}));
-    my $escsymb=&Apache::lonnet::escape(&Apache::lonenc::check_encrypt($ENV{'request.symb'}));
-    if ($ENV{'request.state'} eq 'construct') {
-        if (($ENV{'request.noversionuri'} eq '') || (!defined($ENV{'request.noversionuri'}))) {
-            my $returnurl = $ENV{'request.filename'};
+    my $escurl=&Apache::lonnet::escape(&Apache::lonenc::check_encrypt($env{'request.noversionuri'}));
+    my $escsymb=&Apache::lonnet::escape(&Apache::lonenc::check_encrypt($env{'request.symb'}));
+    if ($env{'request.state'} eq 'construct') {
+        if (($env{'request.noversionuri'} eq '') || (!defined($env{'request.noversionuri'}))) {
+            my $returnurl = $env{'request.filename'};
             $returnurl =~ s:^/home/([^/]+)/public_html/(.*)$:/priv/$1/$2:;
             $escurl = &Apache::lonnet::escape($returnurl);
         }
     }
-    if ($ENV{'browser.interface'} eq 'textual') {
+    if ($env{'browser.interface'} eq 'textual') {
 # Textual display only
 	my %lt=&initlittle();
         $pgbg='#FFFFFF';
         $tabbg='#FFFFFF';
 	$font='#000000';
-        if ($ENV{'request.course.id'}) {
+        if ($env{'request.course.id'}) {
 	    $navmaps=(<<ENDNAV);
 <a href="/adm/navmaps?postdata=$escurl&postsymb=$escsymb" target="_top">$lt{'nav'}</a>
 ENDNAV
-            if (($ENV{'request.noversionuri'}=~/^\/adm\//) &&
-         ($ENV{'request.noversionuri'}!~/^\/adm\/wrapper\//) &&
-         ($ENV{'request.noversionuri'}!~/^\/adm\/.*\/(smppg|bulletinboard|aboutme)(\?|$)/)) {
+            if (($env{'request.noversionuri'}=~/^\/adm\//) &&
+         ($env{'request.noversionuri'}!~/^\/adm\/wrapper\//) &&
+         ($env{'request.noversionuri'}!~/^\/adm\/.*\/(smppg|bulletinboard|aboutme)(\?|$)/)) {
                 my $escreload=&Apache::lonnet::escape('return:');
                 $reloadlink=(<<ENDRELOAD);
 <a href="/adm/flip?postdata=$escreload" target="_top"><font color="$font">$lt{'ret'}</font></a>
 ENDRELOAD
             }
-	    if (&Apache::lonnet::allowed('mdc',$ENV{'request.course.id'})) {
+	    if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
                $docs=(<<ENDDOCS);
 <a href="/adm/coursedocs" target="_top"><font color="$font">$lt{'docs'}</font></a>
 ENDDOCS
@@ -134,19 +134,19 @@
 ENDMAINMENU
         if ($registration) { $output.=&innerregister($forcereg,$target); }
 	return $output."<hr />";
-    } elsif ($ENV{'environment.remote'} eq 'off') {
+    } elsif ($env{'environment.remote'} eq 'off') {
 # Remote Control is switched off
 # figure out colors
 	my %lt=&initlittle();
 	my $function='student';
-        if ($ENV{'request.role'}=~/^(cc|in|ta|ep)/) {
+        if ($env{'request.role'}=~/^(cc|in|ta|ep)/) {
 	    $function='coordinator';
         }
-	if ($ENV{'request.role'}=~/^(su|dc|ad|li)/) {
+	if ($env{'request.role'}=~/^(su|dc|ad|li)/) {
             $function='admin';
         }
-        if (($ENV{'request.role'}=~/^(au|ca)/) ||
-            ($ENV{'request.noversionuri'}=~/^(\/priv|\~)/)) {
+        if (($env{'request.role'}=~/^(au|ca)/) ||
+            ($env{'request.noversionuri'}=~/^(\/priv|\~)/)) {
             $function='author';
         }
         my $domain=&Apache::loncommon::determinedomain();
@@ -158,29 +158,29 @@
         my $vlink=&Apache::loncommon::designparm($function.'.vlink',$domain);
         my $sidebg=&Apache::loncommon::designparm($function.'.sidebg',$domain);
 # Do we have a NAV link?
-        if ($ENV{'request.course.id'}) {
+        if ($env{'request.course.id'}) {
 	    my $link='/adm/navmaps?postdata='.$escurl.'&amp;postsymb='.
 		$escsymb;
-	    if ($ENV{'environment.remotenavmap'} eq 'on') {
+	    if ($env{'environment.remotenavmap'} eq 'on') {
 		$link="javascript:gonav('".$link."')";
 	    }
 	    $navmaps=(<<ENDNAV);
 <td bgcolor="$tabbg">
 <a href="$link"><font color="$font">$lt{'nav'}</font></a></td>
 ENDNAV
-	    if (&Apache::lonnet::allowed('mdc',$ENV{'request.course.id'})) {
+	    if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
 		$docs=(<<ENDDOCS);
 <td bgcolor="$tabbg">
 <a href="/adm/coursedocs"><font color="$font">$lt{'docs'}</font></a></td>
 ENDDOCS
             }
 	    if (
-		($ENV{'request.noversionuri'}=~m[^/(res|public)/] &&
-		 $ENV{'request.symb'} eq '')
+		($env{'request.noversionuri'}=~m[^/(res|public)/] &&
+		 $env{'request.symb'} eq '')
 		||
-		(($ENV{'request.noversionuri'}=~/^\/adm\//) &&
-		 ($ENV{'request.noversionuri'}!~/^\/adm\/wrapper\//) &&
-		 ($ENV{'request.noversionuri'}!~
+		(($env{'request.noversionuri'}=~/^\/adm\//) &&
+		 ($env{'request.noversionuri'}!~/^\/adm\/wrapper\//) &&
+		 ($env{'request.noversionuri'}!~
 		        m[^/adm/.*/(smppg|bulletinboard|aboutme)($|\?)])
 		  )
 		 ) {
@@ -245,9 +245,9 @@
     my $forcereg=shift;
     my $target = shift;
     my $result = '';
-    if ($ENV{'request.noversionuri'} eq '/res/adm/pages/menu.html') { return ''; }
+    if ($env{'request.noversionuri'} eq '/res/adm/pages/menu.html') { return ''; }
     my $force_title='';
-    if ($ENV{'request.state'} eq 'construct') {
+    if ($env{'request.state'} eq 'construct') {
 	$force_title=&Apache::lonxml::display_title();
     }
     if ($target eq 'edit') {
@@ -256,11 +256,11 @@
             &Apache::loncommon::browser_and_searcher_javascript().
                 "\n</script>\n";
     }
-    if (($ENV{'browser.interface'} eq 'textual') ||
-        ($ENV{'environment.remote'} eq 'off') ||
-        ((($ENV{'request.publicaccess'}) || 
+    if (($env{'browser.interface'} eq 'textual') ||
+        ($env{'environment.remote'} eq 'off') ||
+        ((($env{'request.publicaccess'}) || 
          (!&Apache::lonnet::is_on_map(
-	   &Apache::lonnet::unescape($ENV{'request.noversionuri'})))) &&
+	   &Apache::lonnet::unescape($env{'request.noversionuri'})))) &&
         (!$forcereg))) {
  	return $result.
           '<script type="text/javascript">function LONCAPAreg(){;} function LONCAPAstale(){}</script>'.$force_title;
@@ -282,15 +282,15 @@
     my $titletable = shift;
     my $result = '';
     my ($uname,$thisdisfn);
-    my $const_space = ($ENV{'request.state'} eq 'construct');
+    my $const_space = ($env{'request.state'} eq 'construct');
     my $is_const_dir = 0;
 
-    if ($ENV{'request.noversionuri'} eq '/res/adm/pages/menu.html') { return ''; }
+    if ($env{'request.noversionuri'} eq '/res/adm/pages/menu.html') { return ''; }
 
     $Apache::lonxml::registered=1;
 
-    my $textinter=($ENV{'browser.interface'} eq 'textual');
-    my $noremote=($ENV{'environment.remote'} eq 'off');
+    my $textinter=($env{'browser.interface'} eq 'textual');
+    my $noremote=($env{'environment.remote'} eq 'off');
     
     my $textual=($textinter || $noremote);
 
@@ -303,9 +303,9 @@
     if ($noremote) {
 	$newmail='<font face="Arial,Helvetica,sans-serif"><table bgcolor="'.$pgbg.'" border="0" cellspacing="1" cellpadding="1" width="100%"><tr><td bgcolor="'.$tabbg.'">';
     }
-    if (($textual) && ($ENV{'request.symb'}) && ($ENV{'request.course.id'})) {
-	my ($mapurl,$rid,$resurl)=&Apache::lonnet::decode_symb($ENV{'request.symb'});
-        $newmail.=$ENV{'course.'.$ENV{'request.course.id'}.'.description'};
+    if (($textual) && ($env{'request.symb'}) && ($env{'request.course.id'})) {
+	my ($mapurl,$rid,$resurl)=&Apache::lonnet::decode_symb($env{'request.symb'});
+        $newmail.=$env{'course.'.$env{'request.course.id'}.'.description'};
         my $maptitle=&Apache::lonnet::gettitle($mapurl);
 	my $restitle=&Apache::lonnet::gettitle($resurl);
         if ($maptitle && $maptitle ne 'default.sequence') {
@@ -321,7 +321,7 @@
  '<b><a href="/adm/communicate" target="_top">You have new messages</a></b><br />':
                           'swmenu.setstatus("you have","messages");');
     }
-    if ($ENV{'request.state'} eq 'construct') {
+    if ($env{'request.state'} eq 'construct') {
         $newmail = $titletable;
     } else {
 	if ($noremote) {
@@ -333,17 +333,17 @@
     my $tableend=($noremote?'</table></font>':'').($textinter?'<a name="content" />':'');
 # =============================================================================
 # ============================ This is for URLs that actually can be registered
-    if (($ENV{'request.noversionuri'}!~m|^/(res/)*adm/|) || ($forcereg)) {
+    if (($env{'request.noversionuri'}!~m|^/(res/)*adm/|) || ($forcereg)) {
 # -- This applies to homework problems for users with grading privileges
-	my $crs='/'.$ENV{'request.course.id'};
-	if ($ENV{'request.course.sec'}) {
-	    $crs.='_'.$ENV{'request.course.sec'};
+	my $crs='/'.$env{'request.course.id'};
+	if ($env{'request.course.sec'}) {
+	    $crs.='_'.$env{'request.course.sec'};
 	}
 	$crs=~s/\_/\//g;
 
         my $hwkadd='';
-        if ($ENV{'request.symb'} ne '' &&
-	    $ENV{'request.filename'}=~/\.(problem|exam|quiz|assess|survey|form)$/) {
+        if ($env{'request.symb'} ne '' &&
+	    $env{'request.filename'}=~/\.(problem|exam|quiz|assess|survey|form)$/) {
 	    if (&Apache::lonnet::allowed('vgr',$crs)) {
 		$hwkadd.=&switch('','',7,1,'subm.gif','view sub-[_1]','missions[_1]',
                        "gocmd('/adm/grades','submission')",
@@ -355,7 +355,7 @@
                        'Modify user grades for this assessment resource');
             }
 	}
-	if ($ENV{'request.symb'} ne '' &&
+	if ($env{'request.symb'} ne '' &&
 	    &Apache::lonnet::allowed('opa',$crs)) {
 	    $hwkadd.=&switch('','',7,3,'pparm.gif','problem[_2]','parms[_2]',
 			     "gocmd('/adm/parmset','set')",
@@ -367,17 +367,17 @@
         ### resource
         ###
         my $editbutton = '';
-        if ($ENV{'user.author'}) {
-            if ($ENV{'request.role'}=~/^(ca|au)/) {
+        if ($env{'user.author'}) {
+            if ($env{'request.role'}=~/^(ca|au)/) {
                 # Set defaults for authors
                 my ($top,$bottom) = ('con-','struct');
-                my $action = "go('/priv/".$ENV{'user.name'}."');";
-                my $cadom  = $ENV{'request.role.domain'};
-                my $caname = $ENV{'user.name'};
+                my $action = "go('/priv/".$env{'user.name'}."');";
+                my $cadom  = $env{'request.role.domain'};
+                my $caname = $env{'user.name'};
                 my $desc = "Enter my resource construction space";
                 # Set defaults for co-authors
-                if ($ENV{'request.role'} =~ /^ca/) { 
-                    ($cadom,$caname)=($ENV{'request.role'}=~/(\w+)\/(\w+)$/);
+                if ($env{'request.role'} =~ /^ca/) { 
+                    ($cadom,$caname)=($env{'request.role'}=~/(\w+)\/(\w+)$/);
                     ($top,$bottom) = ('co con-','struct');
                     $action = "go('/priv/".$caname."');";
                     $desc = "Enter construction space as co-author";
@@ -397,8 +397,8 @@
             my $cfile='';
             my $cfuname='';
             my $cfudom='';
-            if ($ENV{'request.filename'}) {
-                my $file=&Apache::lonnet::declutter($ENV{'request.filename'});
+            if ($env{'request.filename'}) {
+                my $file=&Apache::lonnet::declutter($env{'request.filename'});
                 $file=~s/^(\w+)\/(\w+)/\/priv\/$2/;
                 # Check that the user has permission to edit this resource
                 ($cfuname,$cfudom)=&Apache::loncacc::constructaccess($file,$1);
@@ -427,7 +427,7 @@
         my $menuitems;
         if ($const_space) {
 	    my ($uname,$thisdisfn) =
-		($ENV{'request.filename'}=~m|^/home/([^/]+)/public_html/(.*)|);
+		($env{'request.filename'}=~m|^/home/([^/]+)/public_html/(.*)|);
             my $currdir = '/priv/'.$uname.'/'.$thisdisfn;
             if ($currdir =~ m-/$-) {
                 $is_const_dir = 1;
@@ -441,8 +441,8 @@
 s&7&2&prt.gif&prepare[_1]&printout[_1]&gocstr('/adm/printout','/~$uname/$thisdisfn')&Prepare a printable document
 ENDMENUITEMS
             }
-        } elsif (defined($ENV{'request.course.id'}) && 
-		 $ENV{'request.symb'} ne '') {
+        } elsif (defined($env{'request.course.id'}) && 
+		 $env{'request.symb'} ne '') {
 	    $menuitems=(<<ENDMENUITEMS);
 c&3&1
 s&2&1&back.gif&backward[_1]&&gopost('/adm/flip','back:'+currentURL)&Go to the previous resource in the course sequence&1
@@ -454,7 +454,7 @@
 s&9&1&sbkm.gif&set[_1]&bookmark[_2]&set_bookmark()&Set a bookmark for this resource&2
 s&9&3&anot.gif&anno-[_1]&tations[_1]&annotate()&Make notes and annotations about this resource&2
 ENDMENUITEMS
-            unless ($ENV{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme)(\?|$)/) {
+            unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme)(\?|$)/) {
 	        $menuitems.=(<<ENDREALRES);
 s&6&3&catalog.gif&catalog[_1]&info[_1]&catalog_info()&Show catalog information
 s&8&1&eval.gif&evaluate[_1]&this[_1]&gopost('/adm/evaluate',currentURL,1)&Provide my evaluation of this resource
@@ -479,7 +479,7 @@
 	    if ($addremote) {
 # Registered, textual output
 
-		if ($ENV{'browser.interface'} eq 'textual') {
+		if ($env{'browser.interface'} eq 'textual') {
 		    $inlinebuttons=
                         join('',map { (defined($_)?$_:'') } @inlineremote);
 		} else {
@@ -508,13 +508,13 @@
 ENDREGTEXT
 # Registered, graphical output
         } else {
-	    my $requri=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$ENV{'request.noversionuri'}))[0]));
+	    my $requri=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));
 	    $requri=&Apache::lonenc::check_encrypt(&Apache::lonnet::unescape($requri));
-	    my $cursymb=&Apache::lonenc::check_encrypt($ENV{'request.symb'});
+	    my $cursymb=&Apache::lonenc::check_encrypt($env{'request.symb'});
 	    my $navstatus=&get_nav_status();
 	    my $clearcstr;
 
-	    if ($ENV{'user.adv'}) { $clearcstr='clearbut(6,1)'; }
+	    if ($env{'user.adv'}) { $clearcstr='clearbut(6,1)'; }
 	    $result = (<<ENDREGTHIS);
      
 <script type="text/javascript">
@@ -602,14 +602,14 @@
 }
 
 sub loadevents() {
-    if ($ENV{'request.state'} eq 'construct' ||
-	$ENV{'request.noversionuri'} eq '/res/adm/pages/menu.html') { return ''; }
+    if ($env{'request.state'} eq 'construct' ||
+	$env{'request.noversionuri'} eq '/res/adm/pages/menu.html') { return ''; }
     return 'LONCAPAreg();';
 }
 
 sub unloadevents() {
-    if ($ENV{'request.state'} eq 'construct' ||
-	$ENV{'request.noversionuri'} eq '/res/adm/pages/menu.html') { return ''; }
+    if ($env{'request.state'} eq 'construct' ||
+	$env{'request.noversionuri'} eq '/res/adm/pages/menu.html') { return ''; }
     return 'LONCAPAstale();';
 }
 
@@ -617,8 +617,8 @@
 
 sub startupremote {
     my ($lowerurl)=@_;
-    if (($ENV{'browser.interface'} eq 'textual') ||
-        ($ENV{'environment.remote'} eq 'off')) {
+    if (($env{'browser.interface'} eq 'textual') ||
+        ($env{'environment.remote'} eq 'off')) {
      return ('<meta HTTP-EQUIV="Refresh" CONTENT="0.5; url='.$lowerurl.'" />');
     }
 #
@@ -693,8 +693,8 @@
 }
 
 sub maincall() {
-    if (($ENV{'browser.interface'} eq 'textual') ||
-        ($ENV{'environment.remote'} eq 'off')) { return ''; }
+    if (($env{'browser.interface'} eq 'textual') ||
+        ($env{'environment.remote'} eq 'off')) { return ''; }
     return(<<ENDMAINCALL);
 <script type="text/javascript">
     main();
@@ -705,8 +705,8 @@
 sub load_remote_msg {
     my ($lowerurl)=@_;
 
-    if (($ENV{'browser.interface'} eq 'textual') ||
-        ($ENV{'environment.remote'} eq 'off')) { return ''; }
+    if (($env{'browser.interface'} eq 'textual') ||
+        ($env{'environment.remote'} eq 'off')) { return ''; }
 
     my $esclowerurl=&Apache::lonnet::escape($lowerurl);
     my $link=&mt('<a href="[_1]">Continue</a> on in Inline Menu mode',
@@ -723,8 +723,8 @@
 # ================================================================= Reopen menu
 
 sub reopenmenu {
-   if (($ENV{'browser.interface'} eq 'textual') ||
-       ($ENV{'environment.remote'} eq 'off')) { return ''; }
+   if (($env{'browser.interface'} eq 'textual') ||
+       ($env{'environment.remote'} eq 'off')) { return ''; }
    my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};
    my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
    return('window.open('.$nothing.',"'.$menuname.'","",false);');
@@ -734,8 +734,8 @@
 
 sub open {
     my $returnval='';
-    if (($ENV{'browser.interface'} eq 'textual') ||
-        ($ENV{'environment.remote'} eq 'off')) { 
+    if (($env{'browser.interface'} eq 'textual') ||
+        ($env{'environment.remote'} eq 'off')) { 
 	return '<script type="text/javascript">self.name="loncapaclient";</script>';
     }
     my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};
@@ -762,8 +762,8 @@
 
 sub clear {
     my ($row,$col)=@_;
-    unless (($ENV{'browser.interface'} eq 'textual') ||
-            ($ENV{'environment.remote'} eq 'off')) {
+    unless (($env{'browser.interface'} eq 'textual') ||
+            ($env{'environment.remote'} eq 'off')) {
        return "\n".qq(window.status+='.';swmenu.clearbut($row,$col););
    } else { 
        $inlineremote[10*$row+$col]='';
@@ -783,12 +783,12 @@
     $bot=&mt($bot);
     $desc=&mt($desc);
     $img=&mt($img);
-    unless (($ENV{'browser.interface'} eq 'textual')  ||
-            ($ENV{'environment.remote'} eq 'off')) {
+    unless (($env{'browser.interface'} eq 'textual')  ||
+            ($env{'environment.remote'} eq 'off')) {
 # Remote
        return "\n".
  qq(window.status+='.';swmenu.switchbutton($row,$col,"$img","$top","$bot","$act","$desc"););
-   } elsif ($ENV{'browser.interface'} eq 'textual') {
+   } elsif ($env{'browser.interface'} eq 'textual') {
 # Accessibility
        if ($nobreak==2) { return ''; }
        my $text=$top.' '.$bot;
@@ -812,7 +812,7 @@
 	   '<img border="0" alt="'.$text.'" src="http://'.$ENV{'HTTP_HOST'}.
 	   ':'.$lonhttpdPort.'/res/adm/pages/'.$img.'" align="'.
 	   ($nobreak==3?'right':'left').'" />';
-       if (($ENV{'browser.interface'} eq 'textual') || ($ENV{'browser.interface'} eq 'faketextual')) {
+       if (($env{'browser.interface'} eq 'textual') || ($env{'browser.interface'} eq 'faketextual')) {
 # Accessibility
 	   if ($nobreak==3) {
 	       $inlineremote[10*$row+$col]="\n".
@@ -858,8 +858,8 @@
 
 sub openmenu {
     my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};
-    if (($ENV{'browser.interface'} eq 'textual') ||
-        ($ENV{'environment.remote'} eq 'off')) { return ''; }
+    if (($env{'browser.interface'} eq 'textual') ||
+        ($env{'environment.remote'} eq 'off')) { return ''; }
     my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
     return "window.open(".$nothing.",'".$menuname."');";
 }
@@ -874,30 +874,30 @@
 sub rawconfig {
     my $textualoverride=shift;
     my $output='';
-    unless (($ENV{'browser.interface'} eq 'textual') ||
-            ($ENV{'environment.remote'} eq 'off')) {
+    unless (($env{'browser.interface'} eq 'textual') ||
+            ($env{'environment.remote'} eq 'off')) {
        $output.=
  "window.status='Opening Remote Control';var swmenu=".&openmenu().
 "\nwindow.status='Configuring Remote Control ';";
     } else {
        unless ($textualoverride) { return ''; }
     }
-    my $uname=$ENV{'user.name'};
-    my $udom=$ENV{'user.domain'};
-    my $adv=$ENV{'user.adv'};
-    my $author=$ENV{'user.author'};
+    my $uname=$env{'user.name'};
+    my $udom=$env{'user.domain'};
+    my $adv=$env{'user.adv'};
+    my $author=$env{'user.author'};
     my $crs='';
-    if ($ENV{'request.course.id'}) {
-       $crs='/'.$ENV{'request.course.id'};
-       if ($ENV{'request.course.sec'}) {
-	   $crs.='_'.$ENV{'request.course.sec'};
+    if ($env{'request.course.id'}) {
+       $crs='/'.$env{'request.course.id'};
+       if ($env{'request.course.sec'}) {
+	   $crs.='_'.$env{'request.course.sec'};
        }
        $crs=~s/\_/\//g;
     }
-    my $pub=($ENV{'request.state'} eq 'published');
-    my $con=($ENV{'request.state'} eq 'construct');
-    my $rol=$ENV{'request.role'};
-    my $requested_domain = $ENV{'request.role.domain'};
+    my $pub=($env{'request.state'} eq 'published');
+    my $con=($env{'request.state'} eq 'construct');
+    my $rol=$env{'request.role'};
+    my $requested_domain = $env{'request.role.domain'};
     foreach (@desklines) {
         my ($row,$col,$pro,$prt,$img,$top,$bot,$act,$desc)=split(/\:/,$_);
         $prt=~s/\$uname/$uname/g;
@@ -924,32 +924,32 @@
                $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc);
             }
         } elsif ($pro eq 'course') {
-            if ($ENV{'request.course.fn'}) {
+            if ($env{'request.course.fn'}) {
                $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc);
 	    }
         } elsif ($pro =~ /^courseenv_(.*)$/) {
             my $key = $1;
-            if ($ENV{'course.'.$ENV{'request.course.id'}.'.'.$key}) {
+            if ($env{'course.'.$env{'request.course.id'}.'.'.$key}) {
                 $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc);
             }
         } elsif ($pro =~ /^course_(.*)$/) {
             # Check for permissions inside of a course
-            if (($ENV{'request.course.id'}) &&
-                (&Apache::lonnet::allowed($1,$ENV{'request.course.id'}.
-            ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))
+            if (($env{'request.course.id'}) &&
+                (&Apache::lonnet::allowed($1,$env{'request.course.id'}.
+            ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))
                  )) {
                 $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc);
 	    }
         } elsif ($pro eq 'author') {
             if ($author) {
-                if ((($prt eq 'rca') && ($ENV{'request.role'}=~/^ca/)) ||
-                    (($prt eq 'rau') && ($ENV{'request.role'}=~/^au/))) {
+                if ((($prt eq 'rca') && ($env{'request.role'}=~/^ca/)) ||
+                    (($prt eq 'rau') && ($env{'request.role'}=~/^au/))) {
                     # Check that we are on the correct machine
                     my $cadom=$requested_domain;
-                    my $caname=$ENV{'user.name'};
+                    my $caname=$env{'user.name'};
                     if ($prt eq 'rca') {
 		       ($cadom,$caname)=
-                               ($ENV{'request.role'}=~/(\w+)\/(\w+)$/);
+                               ($env{'request.role'}=~/(\w+)\/(\w+)$/);
                     }                       
                     $act =~ s/\$caname/$caname/g;
                     my $home = &Apache::lonnet::homeserver($caname,$cadom);
@@ -964,8 +964,8 @@
             }
         }
     }
-    unless (($ENV{'browser.interface'} eq 'textual') ||
-            ($ENV{'environment.remote'} eq 'off')) {
+    unless (($env{'browser.interface'} eq 'textual') ||
+            ($env{'environment.remote'} eq 'off')) {
        $output.="\nwindow.status='Synchronizing Time';swmenu.syncclock(1000*".time.");\nwindow.status='Remote Control Configured.';";
        if (&Apache::lonmsg::newmail()) { 
 	   $output.='swmenu.setstatus("you have","messages");';
@@ -978,8 +978,8 @@
 # ======================================================================= Close
 
 sub close {
-    if (($ENV{'browser.interface'} eq 'textual') ||
-        ($ENV{'environment.remote'} eq 'off')) { return ''; }
+    if (($env{'browser.interface'} eq 'textual') ||
+        ($env{'environment.remote'} eq 'off')) { return ''; }
     my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};
     return(<<ENDCLOSE);
 <script type="text/javascript">
@@ -1003,7 +1003,7 @@
 }
 
 sub nav_control_js {
-    my $nav=($ENV{'environment.remotenavmap'} eq 'on');
+    my $nav=($env{'environment.remotenavmap'} eq 'on');
     return (<<NAVCONTROL);
     var w_loncapanav_flag="$nav";
 
@@ -1021,12 +1021,12 @@
 
 sub utilityfunctions {
     my $caller = shift;
-    unless (($ENV{'browser.interface'} eq 'textual')  ||
-        ($ENV{'environment.remote'} eq 'off') || ($caller eq '/adm/menu')) { return ''; }
-    my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$ENV{'request.noversionuri'}))[0]));
+    unless (($env{'browser.interface'} eq 'textual')  ||
+        ($env{'environment.remote'} eq 'off') || ($caller eq '/adm/menu')) { return ''; }
+    my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));
     $currenturl=&Apache::lonenc::check_encrypt(&Apache::lonnet::unescape($currenturl));
     
-    my $currentsymb=&Apache::lonenc::check_encrypt($ENV{'request.symb'});
+    my $currentsymb=&Apache::lonenc::check_encrypt($env{'request.symb'});
     my $nav_control=&nav_control_js();
 return (<<ENDUTILITY)
 
@@ -1153,7 +1153,7 @@
 
 sub get_nav_status {
     my $navstatus="swmenu.w_loncapanav_flag=";
-    if ($ENV{'environment.remotenavmap'} eq 'on') {
+    if ($env{'environment.remotenavmap'} eq 'on') {
 	$navstatus.="1";
     } else {
 	$navstatus.="-1";
@@ -1171,20 +1171,20 @@
     return OK if $r->header_only;
 
     my $form;
-    if ($ENV{'environment.remote'} ne 'off' &&
-	$ENV{'browser.interface'} ne 'textual') {
+    if ($env{'environment.remote'} ne 'off' &&
+	$env{'browser.interface'} ne 'textual') {
 	$form=&serverform();
     }
     my $bodytag=&Apache::loncommon::bodytag('Main Menu');
     my $function='student';
-    if ($ENV{'request.role'}=~/^(cc|in|ta|ep)/) {
+    if ($env{'request.role'}=~/^(cc|in|ta|ep)/) {
 	$function='coordinator';
     }
-    if ($ENV{'request.role'}=~/^(su|dc|ad|li)/) {
+    if ($env{'request.role'}=~/^(su|dc|ad|li)/) {
 	$function='admin';
     }
-    if (($ENV{'request.role'}=~/^(au|ca)/) ||
-	($ENV{'request.noversionuri'}=~/^(\/priv|\~)/)) {
+    if (($env{'request.role'}=~/^(au|ca)/) ||
+	($env{'request.noversionuri'}=~/^(\/priv|\~)/)) {
 	$function='author';
     }
     my $domain=&Apache::loncommon::determinedomain();
@@ -1192,7 +1192,7 @@
     $tabbg=&Apache::loncommon::designparm($function.'.tabbg',$domain);
     $font=&Apache::loncommon::designparm($function.'.font',$domain);
     my $script_tag;
-    if ($ENV{'environment.remote'} ne 'off') {
+    if ($env{'environment.remote'} ne 'off') {
         my $utility=&utilityfunctions('/adm/menu');
         $script_tag=(<<ENDSCRIPT);
 <script type="text/javascript">
@@ -1201,9 +1201,9 @@
 ENDSCRIPT
     }
 # ---- Print the screen, pretend to be in text mode to generate text-based menu
-    unless ($ENV{'browser.interface'} eq 'textual') {
-	$ENV{'browser.interface'}='faketextual';
-	$ENV{'environment.remote'}='off';
+    unless ($env{'browser.interface'} eq 'textual') {
+	$env{'browser.interface'}='faketextual';
+	$env{'environment.remote'}='off';
     }
     my $html=&Apache::lonxml::xmlbegin();
     $r->print(<<ENDHEADER);
Index: loncom/interface/lonmeta.pm
diff -u loncom/interface/lonmeta.pm:1.95 loncom/interface/lonmeta.pm:1.96
--- loncom/interface/lonmeta.pm:1.95	Fri Mar 18 11:47:31 2005
+++ loncom/interface/lonmeta.pm	Thu Apr  7 02:56:23 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Metadata display handler
 #
-# $Id: lonmeta.pm,v 1.95 2005/03/18 16:47:31 albertel Exp $
+# $Id: lonmeta.pm,v 1.96 2005/04/07 06:56:23 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -31,7 +31,7 @@
 use strict;
 use LONCAPA::lonmetadata();
 use Apache::Constants qw(:common);
-use Apache::lonnet();
+use Apache::lonnet;
 use Apache::loncommon();
 use Apache::lonhtmlcommon();
 use Apache::lonmsg;
@@ -338,7 +338,7 @@
 	return &Apache::loncommon::gradeleveldescription($value);
     }
     # Only for advance users below
-    if (! $ENV{'user.adv'}) { 
+    if (! $env{'user.adv'}) { 
         return '<i>- '.&mt('not displayed').' -</i>';
     }
     # File
@@ -632,7 +632,7 @@
     # obsolete
     my $obsolete=$content{'obsolete'};
     my $obsoletewarning='';
-    if (($obsolete) && ($ENV{'user.adv'})) {
+    if (($obsolete) && ($env{'user.adv'})) {
         $obsoletewarning='<p><font color="red">'.
             &mt('This resource has been marked obsolete by the author(s)').
             '</font></p>';
@@ -681,7 +681,7 @@
 $table
 </table>
 ENDHEAD
-    if ($ENV{'user.adv'}) {
+    if ($env{'user.adv'}) {
         &print_dynamic_metadata($r,$uri,\%content);
     }
     return;
@@ -822,8 +822,8 @@
         $r->print('<h4>'.&mt('No Evaluation Data is available for this resource.').'</h4>');
     }
     $uri=~/^\/res\/(\w+)\/(\w+)\//; 
-    if ((($ENV{'user.domain'} eq $1) && ($ENV{'user.name'} eq $2))
-        || ($ENV{'user.role.ca./'.$1.'/'.$2})) {
+    if ((($env{'user.domain'} eq $1) && ($env{'user.name'} eq $2))
+        || ($env{'user.role.ca./'.$1.'/'.$2})) {
         if (exists($dynmeta{'comments'})) {
             $r->print('<h4>'.&mt('Evaluation Comments').' ('.
                       &mt('visible to author and co-authors only').
@@ -890,11 +890,11 @@
     $disuri=~s/^\/\~/\/priv\//;
     $disuri=~s/\.meta$//;
     my $target=$uri;
-    $target=~s/^\/\~/\/res\/$ENV{'request.role.domain'}\//;
+    $target=~s/^\/\~/\/res\/$env{'request.role.domain'}\//;
     $target=~s/\.meta$//;
     my $bombs=&Apache::lonmsg::retrieve_author_res_msg($target);
     if ($bombs) {
-        if ($ENV{'form.delmsg'}) {
+        if ($env{'form.delmsg'}) {
             if (&Apache::lonmsg::del_url_author_res_msg($target) eq 'ok') {
                 $bombs=&mt('Messages deleted.');
             } else {
@@ -947,9 +947,9 @@
                  'obsolete','obsoletereplacement');
         }
         foreach (@fields) {
-            if (defined($ENV{'form.new_'.$_})) {
+            if (defined($env{'form.new_'.$_})) {
                 $Apache::lonpublisher::metadatafields{$_}=
-                    $ENV{'form.new_'.$_};
+                    $env{'form.new_'.$_};
             }
             if (! $Apache::lonpublisher::metadatafields{'copyright'}) {
                 $Apache::lonpublisher::metadatafields{'copyright'}=
@@ -960,7 +960,7 @@
 				   $Apache::lonpublisher::metadatafields{$_},
 				   'new_'.$_,'defaultmeta').'</p>');
         }
-        if ($ENV{'form.store'}) {
+        if ($env{'form.store'}) {
             my $mfh;
             my $formname='store';
             my $file_content;
@@ -989,10 +989,10 @@
             if ($fn =~ /\/portfolio\//) {
                 $fn =~ /\/portfolio\/(.*)$/;
                 my $new_fn = '/'.$1;
-                $ENV{'form.'.$formname}=$file_content;
-                $ENV{'form.'.$formname.'.filename'}=$new_fn;
+                $env{'form.'.$formname}=$file_content;
+                $env{'form.'.$formname.'.filename'}=$new_fn;
                 &Apache::lonnet::userfileupload('uploaddoc','',
-	        	 'portfolio'.$ENV{'form.currentpath'});
+	        	 'portfolio'.$env{'form.currentpath'});
 	        my $status =&Apache::lonnet::userfileupload($formname,'','portfolio');
                 if (&Apache::lonnet::userfileupload($formname,'','portfolio') eq 'error: no uploaded file') {
                     $r->print('<p><font color="red">'.
Index: loncom/interface/lonmodifycourse.pm
diff -u loncom/interface/lonmodifycourse.pm:1.15 loncom/interface/lonmodifycourse.pm:1.16
--- loncom/interface/lonmodifycourse.pm:1.15	Thu Feb 17 03:29:43 2005
+++ loncom/interface/lonmodifycourse.pm	Thu Apr  7 02:56:23 2005
@@ -33,7 +33,7 @@
 
 sub print_course_selection_page {
     my ($r,$tasklongref) = @_;
-    my $dom = $ENV{'request.role.domain'};
+    my $dom = $env{'request.role.domain'};
     my %lt=&Apache::lonlocal::texthash(
                     'csae' => "Course settings for automated enrollment",
                     'unst' => "Unlike standard LON-CAPA course parameters, such as course description, feedback addresses, and top level map, which are displayed and/or modified using the 'Course Environment Parameters' screen, settings that control automated enrollment based on classlist data available from your institution's student information system are handled differently.  Automated enrollment settings fall into two groups: (a) settings that can be modified by a Course Coordinator using the Automated Enrollment Manager and (b)  settings that may only be modified by a Domain Coordinator via the 'View/Modify Course settings' menu accessed from this page.", 
@@ -132,9 +132,9 @@
     my %enrollvar = ();
     my $javascript_validations;
     my $course = '';
-    my $dom = $ENV{'request.role.domain'};
-    if ( defined($ENV{'form.course'}) ) {
-        $course = $ENV{'form.course'};
+    my $dom = $env{'request.role.domain'};
+    if ( defined($env{'form.course'}) ) {
+        $course = $env{'form.course'};
     }
     my $ok_course = 'ok';
     if ( ($course == -1) || ($course == '-2') || ($course eq '') ) {
@@ -437,8 +437,8 @@
 
 sub modify_course {
     my ($r,$tasklongref,$typeref) = @_;
-    my $dom = $ENV{'user.domain'};
-    my $crs = $ENV{'form.course'};
+    my $dom = $env{'user.domain'};
+    my $crs = $env{'form.course'};
     unless ( &check_course($dom,$crs) eq 'ok' ) {
         &print_header($r,$tasklongref);
         my $reply = "<br/>".&mt("The LON-CAPA course selected was not a valid course for this domain");
@@ -486,19 +486,19 @@
     my $description = $settings{'description'};
     my %cenv = ();
 
-    if ($ENV{'form.login'} eq 'krb') {
-        $newattr{'authtype'} = $ENV{'form.login'};
-        $newattr{'authtype'} .= $ENV{'form.krbver'};
-        $newattr{'autharg'} = $ENV{'form.krbarg'};
-    } elsif ($ENV{'form.login'} eq 'int') {
+    if ($env{'form.login'} eq 'krb') {
+        $newattr{'authtype'} = $env{'form.login'};
+        $newattr{'authtype'} .= $env{'form.krbver'};
+        $newattr{'autharg'} = $env{'form.krbarg'};
+    } elsif ($env{'form.login'} eq 'int') {
         $newattr{'authtype'} ='internal';
-        if ((defined($ENV{'form.intarg'})) && ($ENV{'form.intarg'})) {
-            $newattr{'autharg'} = $ENV{'form.intarg'};
+        if ((defined($env{'form.intarg'})) && ($env{'form.intarg'})) {
+            $newattr{'autharg'} = $env{'form.intarg'};
         }
-    } elsif ($ENV{'form.login'} eq 'loc') {
+    } elsif ($env{'form.login'} eq 'loc') {
         $newattr{'authtype'} = 'localauth';
-        if ((defined($ENV{'form.locarg'})) && ($ENV{'form.locarg'})) {
-            $newattr{'autharg'} = $ENV{'form.locarg'};
+        if ((defined($env{'form.locarg'})) && ($env{'form.locarg'})) {
+            $newattr{'autharg'} = $env{'form.locarg'};
         }
     }
     if ( $newattr{'authtype'}=~ /^krb/) {
@@ -508,21 +508,21 @@
         }
     }
 
-    if ( exists($ENV{'form.courseowner'}) ) {
-        $newattr{'courseowner'}=$ENV{'form.courseowner'};
+    if ( exists($env{'form.courseowner'}) ) {
+        $newattr{'courseowner'}=$env{'form.courseowner'};
         unless ( $newattr{'courseowner'} eq $currattr{'courseowner'} ) {
             $changeowner = 1;
         } 
     }
 													      
-    if ( exists($ENV{'form.coursecode'}) ) {
-        $newattr{'coursecode'}=$ENV{'form.coursecode'};
+    if ( exists($env{'form.coursecode'}) ) {
+        $newattr{'coursecode'}=$env{'form.coursecode'};
         unless ( $newattr{'coursecode'} eq $currattr{'coursecode'} ) {
             $changecode = 1;
         }
     }
     if ($changeowner == 1 || $changecode == 1) {
-        my $courseid_entry = &Apache::lonnet::escape($dom.'_'.$crs).'='.&Apache::lonnet::escape($description).':'.&Apache::lonnet::escape($ENV{'form.coursecode'}).':'.&Apache::lonnet::escape($ENV{'form.courseowner'});
+        my $courseid_entry = &Apache::lonnet::escape($dom.'_'.$crs).'='.&Apache::lonnet::escape($description).':'.&Apache::lonnet::escape($env{'form.coursecode'}).':'.&Apache::lonnet::escape($env{'form.courseowner'});
         &Apache::lonnet::courseidput($dom,$courseid_entry,&Apache::lonnet::homeserver($crs,$dom));
     }
 
@@ -642,8 +642,8 @@
              'comg' => 'Course Manager',
              );
     my $action = "start";
-    if ( exists($ENV{'form.action'}) ) {
-        $action = $ENV{'form.action'};
+    if ( exists($env{'form.action'}) ) {
+        $action = $env{'form.action'};
     }
     if ( ($description eq '') || (!defined($description)) ) {
         $description = $lt{'comg'};
@@ -655,7 +655,7 @@
     } else {
         $page =  '<a href="/adm/modifycourse">'.$lt{'chco'}.'</a>';
         if ( $action eq 'process' ) {
-            my $course = $ENV{'form.course'};
+            my $course = $env{'form.course'};
             $page .= "-&gt; <a href=\"/adm/modifycourse?action=display&course=$course\">".$$tasklongref{'display'}."</a> -&gt; <b>$$tasklongref{$action}</b> ";
         } else {
             $page .=  " -&gt; <b>".$$tasklongref{$action}."</b>";
@@ -722,12 +722,12 @@
         return OK;
     }
                                                                                   
-    if (&Apache::lonnet::allowed('ccc',$ENV{'request.role.domain'})) {
+    if (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) {
         &Apache::loncommon::content_type($r,'text/html');
         $r->send_http_header;
 
         &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['action','course']);
-        my $dom = $ENV{'user.domain'};
+        my $dom = $env{'user.domain'};
         my %longtype=&Apache::lonlocal::texthash(
                        'authtype' => 'Default authentication method',
                        'autharg'  => 'Default authentication parameter',
@@ -749,15 +749,15 @@
                         'process'  => 'Results of changes',
                        );
                                                                                   
-        if ($ENV{'form.action'} eq 'process') {
+        if ($env{'form.action'} eq 'process') {
             &modify_course($r,\%tasklong,\%longtype);
-        } elsif ($ENV{'form.action'} eq 'display')  {
+        } elsif ($env{'form.action'} eq 'display')  {
             &print_course_modification_page($r,\%tasklong,\%longtype);
         } else {
             &print_course_selection_page($r,\%tasklong);
         }
     } else {
-        $ENV{'user.error.msg'}=
+        $env{'user.error.msg'}=
         "/adm/modifycourse:ccc:0:0:Cannot modify course settings";
         return HTTP_NOT_ACCEPTABLE;
     }
Index: loncom/interface/lonmsg.pm
diff -u loncom/interface/lonmsg.pm:1.139 loncom/interface/lonmsg.pm:1.140
--- loncom/interface/lonmsg.pm:1.139	Mon Feb 28 22:28:14 2005
+++ loncom/interface/lonmsg.pm	Thu Apr  7 02:56:23 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines for messaging
 #
-# $Id: lonmsg.pm,v 1.139 2005/03/01 03:28:14 albertel Exp $
+# $Id: lonmsg.pm,v 1.140 2005/04/07 06:56:23 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -104,7 +104,7 @@
 =cut
 
 use strict;
-use Apache::lonnet();
+use Apache::lonnet;
 use vars qw($msgcount);
 use HTML::TokeParser();
 use Apache::Constants qw(:common);
@@ -140,24 +140,24 @@
     my $partsubj=$subject;
     $partsubj=&Apache::lonnet::escape($partsubj);
     my $msgid=&Apache::lonnet::escape(
-           $now.':'.$partsubj.':'.$ENV{'user.name'}.':'.
-           $ENV{'user.domain'}.':'.$msgcount.':'.$$);
-    my $result='<sendername>'.$ENV{'user.name'}.'</sendername>'.
-           '<senderdomain>'.$ENV{'user.domain'}.'</senderdomain>'.
+           $now.':'.$partsubj.':'.$env{'user.name'}.':'.
+           $env{'user.domain'}.':'.$msgcount.':'.$$);
+    my $result='<sendername>'.$env{'user.name'}.'</sendername>'.
+           '<senderdomain>'.$env{'user.domain'}.'</senderdomain>'.
            '<subject>'.$subject.'</subject>'.
 	   '<time>'.&Apache::lonlocal::locallocaltime($now).'</time>'.
 	   '<servername>'.$ENV{'SERVER_NAME'}.'</servername>'.
            '<host>'.$ENV{'HTTP_HOST'}.'</host>'.
 	   '<client>'.$ENV{'REMOTE_ADDR'}.'</client>'.
-	   '<browsertype>'.$ENV{'browser.type'}.'</browsertype>'.
-	   '<browseros>'.$ENV{'browser.os'}.'</browseros>'.
-	   '<browserversion>'.$ENV{'browser.version'}.'</browserversion>'.
-           '<browsermathml>'.$ENV{'browser.mathml'}.'</browsermathml>'.
+	   '<browsertype>'.$env{'browser.type'}.'</browsertype>'.
+	   '<browseros>'.$env{'browser.os'}.'</browseros>'.
+	   '<browserversion>'.$env{'browser.version'}.'</browserversion>'.
+           '<browsermathml>'.$env{'browser.mathml'}.'</browsermathml>'.
 	   '<browserraw>'.$ENV{'HTTP_USER_AGENT'}.'</browserraw>'.
-	   '<courseid>'.$ENV{'request.course.id'}.'</courseid>'.
-	   '<coursesec>'.$ENV{'request.course.sec'}.'</coursesec>'.
-	   '<role>'.$ENV{'request.role'}.'</role>'.
-	   '<resource>'.$ENV{'request.filename'}.'</resource>'.
+	   '<courseid>'.$env{'request.course.id'}.'</courseid>'.
+	   '<coursesec>'.$env{'request.course.sec'}.'</coursesec>'.
+	   '<role>'.$env{'request.role'}.'</role>'.
+	   '<resource>'.$env{'request.filename'}.'</resource>'.
            '<msgid>'.$msgid.'</msgid>'.
 	   '<recuser>'.$recuser.'</recuser>'.
 	   '<recdomain>'.$recdomain.'</recdomain>'.
@@ -226,23 +226,19 @@
     my $msg = new Mail::Send;
     $msg->to($to);
     $msg->subject('[LON-CAPA] '.$subject);
-    my %oldENV=%ENV;
-    undef(%ENV);
     if (my $fh = $msg->open()) {
 	print $fh $body;
 	$fh->close;
     }
-    %ENV=%oldENV;
-    undef(%oldENV);
 }
 
 # ==================================================== Send notification emails
 
 sub sendnotification {
     my ($to,$touname,$toudom,$subj,$crit,$text)=@_;
-    my $sender=$ENV{'environment.firstname'}.' '.$ENV{'environment.lastname'};
+    my $sender=$env{'environment.firstname'}.' '.$env{'environment.lastname'};
     unless ($sender=~/\w/) { 
-	$sender=$ENV{'user.name'}.'@'.$ENV{'user.domain'};
+	$sender=$env{'user.name'}.'@'.$env{'user.domain'};
     }
     my $critical=($crit?' critical':'');
     $text=~s/\&lt\;/\</gs;
@@ -271,7 +267,7 @@
 # ============================================================= Check for email
 
 sub newmail {
-    if ((time-$ENV{'user.mailcheck.time'})>300) {
+    if ((time-$env{'user.mailcheck.time'})>300) {
         my %what=&Apache::lonnet::get('email_status',['recnewemail']);
         &Apache::lonnet::appenv('user.mailcheck.time'=>time);
         if ($what{'recnewemail'}>0) { return 1; }
@@ -370,10 +366,10 @@
            'put:'.$domain.':'.$user.':critical:'.
            &Apache::lonnet::escape($msgid).'='.
            &Apache::lonnet::escape($message),$homeserver);
-       if ($ENV{'request.course.id'}) {
+       if ($env{'request.course.id'}) {
           &user_normal_msg_raw(
-            $ENV{'course.'.$ENV{'request.course.id'}.'.num'},
-            $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
+            $env{'course.'.$env{'request.course.id'}.'.num'},
+            $env{'course.'.$env{'request.course.id'}.'.domain'},
             'Critical ['.$user.':'.$domain.']',
 	    $message);
        }
@@ -396,8 +392,8 @@
     &Apache::lonnet::logthis(
       'Sending critical email '.$msgid.
       ', log status: '.
-      &Apache::lonnet::log($ENV{'user.domain'},$ENV{'user.name'},
-                         $ENV{'user.home'},
+      &Apache::lonnet::log($env{'user.domain'},$env{'user.name'},
+                         $env{'user.home'},
       'Sending critical '.$msgid.' to '.$user.' at '.$domain.' with status: '
       .$status));
     return $status;
@@ -440,8 +436,8 @@
     my %contents=&unpackagemsg($message{$msgid},1);
     my $status='rec: '.($contents{'sendback'}?
      &user_normal_msg($contents{'sendername'},$contents{'senderdomain'},
-                     &mt('Receipt').': '.$ENV{'user.name'}.' '.&mt('at').' '.$ENV{'user.domain'}.', '.$contents{'subject'},
-                     &mt('User').' '.$ENV{'user.name'}.' '.&mt('at').' '.$ENV{'user.domain'}.
+                     &mt('Receipt').': '.$env{'user.name'}.' '.&mt('at').' '.$env{'user.domain'}.', '.$contents{'subject'},
+                     &mt('User').' '.$env{'user.name'}.' '.&mt('at').' '.$env{'user.domain'}.
                      ' acknowledged receipt of message'."\n".'   "'.
                      $contents{'subject'}.'"'."\n".&mt('dated').' '.
                      $contents{'time'}.".\n"
@@ -451,8 +447,8 @@
      'nohist_email',{$contents{'msgid'} => $message{$msgid}});
     $status.=' del: '.
      &Apache::lonnet::del('critical',[$contents{'msgid'}]);
-    &Apache::lonnet::log($ENV{'user.domain'},$ENV{'user.name'},
-                         $ENV{'user.home'},'Received critical message '.
+    &Apache::lonnet::log($env{'user.domain'},$env{'user.name'},
+                         $env{'user.home'},'Received critical message '.
                          $contents{'msgid'}.
                          ', '.$status);
     return $status;
@@ -482,10 +478,10 @@
                          ('email_status',{'recnewemail'=>time},$domain,$user);
 # Into sent-mail folder
        $status.=' '.&Apache::lonnet::critical(
-           'put:'.$ENV{'user.domain'}.':'.$ENV{'user.name'}.
+           'put:'.$env{'user.domain'}.':'.$env{'user.name'}.
 					      ':nohist_email_sent:'.
            &Apache::lonnet::escape($msgid).'='.
-           &Apache::lonnet::escape($message),$ENV{'user.home'});
+           &Apache::lonnet::escape($message),$env{'user.home'});
     } else {
        $status='no_host';
     }
@@ -501,8 +497,8 @@
       &sendnotification($userenv{'permanentemail'},$user,$domain,$subject,0,
 			$text);
     }
-    &Apache::lonnet::log($ENV{'user.domain'},$ENV{'user.name'},
-                         $ENV{'user.home'},
+    &Apache::lonnet::log($env{'user.domain'},$env{'user.name'},
+                         $env{'user.home'},
       'Sending '.$msgid.' to '.$user.' at '.$domain.' with status: '.$status);
     return $status;
 }
@@ -559,7 +555,7 @@
 	 ($_==$interdis?' selected="selected"':'').'>'.$_.'</option>' }
 				   (10,20,50,100,200)).'</select>'.	
    '<input type="submit" value="'.&mt('View Folder').'" /><br />'.
-    '<input type="hidden" name="sortedby" value="'.$ENV{'form.sortedby'}.'" />'.
+    '<input type="hidden" name="sortedby" value="'.$env{'form.sortedby'}.'" />'.
 			      ($folder=~/^(new|critical)/?'</form>':'');
 }
 
@@ -781,34 +777,34 @@
     }
     #default sort
     @temp = sort  {$a->[0] <=> $b->[0]} @temp;    
-    if ($ENV{'form.sortedby'} eq "date"){
+    if ($env{'form.sortedby'} eq "date"){
         @temp = sort  {$a->[0] <=> $b->[0]} @temp;    
     }
-    if ($ENV{'form.sortedby'} eq "revdate"){
+    if ($env{'form.sortedby'} eq "revdate"){
     	@temp = sort  {$b->[0] <=> $a->[0]} @temp; 
     }
-    if ($ENV{'form.sortedby'} eq "user"){
+    if ($env{'form.sortedby'} eq "user"){
 	@temp = sort  {lc($a->[2]) cmp lc($b->[2])} @temp;
     }
-    if ($ENV{'form.sortedby'} eq "revuser"){
+    if ($env{'form.sortedby'} eq "revuser"){
 	@temp = sort  {lc($b->[2]) cmp lc($a->[2])} @temp;
     }
-    if ($ENV{'form.sortedby'} eq "domain"){
+    if ($env{'form.sortedby'} eq "domain"){
         @temp = sort  {$a->[3] cmp $b->[3]} @temp;
     }
-    if ($ENV{'form.sortedby'} eq "revdomain"){
+    if ($env{'form.sortedby'} eq "revdomain"){
         @temp = sort  {$b->[3] cmp $a->[3]} @temp;
     }
-    if ($ENV{'form.sortedby'} eq "subject"){
+    if ($env{'form.sortedby'} eq "subject"){
         @temp = sort  {lc($a->[1]) cmp lc($b->[1])} @temp;
     }
-    if ($ENV{'form.sortedby'} eq "revsubject"){
+    if ($env{'form.sortedby'} eq "revsubject"){
         @temp = sort  {lc($b->[1]) cmp lc($a->[1])} @temp;
     }
-    if ($ENV{'form.sortedby'} eq "status"){
+    if ($env{'form.sortedby'} eq "status"){
         @temp = sort  {$a->[4] cmp $b->[4]} @temp;
     }
-    if ($ENV{'form.sortedby'} eq "revstatus"){
+    if ($env{'form.sortedby'} eq "revstatus"){
         @temp = sort  {$b->[4] cmp $a->[4]} @temp;
     }
     return @temp;
@@ -828,9 +824,9 @@
 				       'do' => 'Domain'
 				       );
     my @msgids = sort split(/\&/,&Apache::lonnet::reply
-                            ('keys:'.$ENV{'user.domain'}.':'.
-                             $ENV{'user.name'}.':nohist_email',
-                             $ENV{'user.home'}));
+                            ('keys:'.$env{'user.domain'}.':'.
+                             $env{'user.name'}.':nohist_email',
+                             $env{'user.home'}));
     my @newmsgs;
     my %setters = ();
     my $startblock = 0;
@@ -962,31 +958,31 @@
     $r->print(&scrollbuttons($startdis,$number,$firstdis,$lastdis,$totalnumber));
     $r->print('<form method="post" name="disall" action="/adm/email">'.
 	      '<table border=2><tr><th colspan="3">&nbsp</th><th>');
-    if ($ENV{'form.sortedby'} eq "revdate") {
+    if ($env{'form.sortedby'} eq "revdate") {
 	$r->print('<a href = "?sortedby=date'.$fsqs.'">'.&mt('Date').'</a></th>');
     } else {
 	$r->print('<a href = "?sortedby=revdate'.$fsqs.'">'.&mt('Date').'</a></th>');
     }
     $r->print('<th>');
-    if ($ENV{'form.sortedby'} eq "revuser") {
+    if ($env{'form.sortedby'} eq "revuser") {
 	$r->print('<a href = "?sortedby=user'.$fsqs.'">'.&mt('Username').'</a>');
     } else {
 	$r->print('<a href = "?sortedby=revuser'.$fsqs.'">'.&mt('Username').'</a>');
     }
     $r->print('</th><th>');
-    if ($ENV{'form.sortedby'} eq "revdomain") {
+    if ($env{'form.sortedby'} eq "revdomain") {
 	$r->print('<a href = "?sortedby=domain'.$fsqs.'">'.&mt('Domain').'</a>');
     } else {
 	$r->print('<a href = "?sortedby=revdomain'.$fsqs.'">'.&mt('Domain').'</a>');
     }
     $r->print('</th><th>');
-    if ($ENV{'form.sortedby'} eq "revsubject") {
+    if ($env{'form.sortedby'} eq "revsubject") {
 	$r->print('<a href = "?sortedby=subject'.$fsqs.'">'.&mt('Subject').'</a>');
     } else {
     	$r->print('<a href = "?sortedby=revsubject'.$fsqs.'">'.&mt('Subject').'</a>');
     }
     $r->print('</th><th>');
-    if ($ENV{'form.sortedby'} eq "revstatus") {
+    if ($env{'form.sortedby'} eq "revstatus") {
 	$r->print('<a href = "?sortedby=status'.$fsqs.'">'.&mt('Status').'</a></th>');
     } else {
      	$r->print('<a href = "?sortedby=revstatus'.$fsqs.'">'.&mt('Status').'</a></th>');
@@ -1020,7 +1016,7 @@
     $r->print("</table>\n<p>".
   '<a href="javascript:checkall()">'.&mt('Check All').'</a>&nbsp;'.
   '<a href="javascript:uncheckall()">'.&mt('Uncheck All').'</a></p>'.
-  '<input type="hidden" name="sortedby" value="'.$ENV{'form.sortedby'}.'" />');
+  '<input type="hidden" name="sortedby" value="'.$env{'form.sortedby'}.'" />');
     if ($folder ne 'trash') {
 	$r->print(
 	      '<p><input type="submit" name="markeddel" value="'.&mt('Delete Checked').'" /></p>');
@@ -1033,7 +1029,7 @@
 			     ( map { $_ => $_ } @allfolders))
 	      );
     my $postedstartdis=$startdis+1;
-    $r->print('<input type="hidden" name="folder" value="'.$folder.'" /><input type="hidden" name="startdis" value="'.$postedstartdis.'" /><input type="hidden" name="interdis" value="'.$ENV{'form.interdis'}.'" /></form>');
+    $r->print('<input type="hidden" name="folder" value="'.$folder.'" /><input type="hidden" name="startdis" value="'.$postedstartdis.'" /><input type="hidden" name="interdis" value="'.$env{'form.interdis'}.'" /></form>');
     if ($numblocked > 0) {
         my $beginblock = &Apache::lonlocal::locallocaltime($startblock);
         my $finishblock = &Apache::lonlocal::locallocaltime($endblock);
@@ -1087,7 +1083,7 @@
 				       'ca' => 'Cancel',
 				       'ma' => 'Mail');
 
-    if (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) {
+    if (&Apache::lonnet::allowed('srm',$env{'request.course.id'})) {
 	 my $crithelp = Apache::loncommon::help_open_topic("Course_Critical_Message");
          $dispcrit=
  '<p><label><input type="checkbox" name="critmsg" /> '.&mt('Send as critical message').'</label> ' . $crithelp . 
@@ -1099,7 +1095,7 @@
      }
     my %message;
     my %content;
-    my $defdom=$ENV{'user.domain'};
+    my $defdom=$env{'user.domain'};
     if ($forwarding) {
 	%message=&Apache::lonnet::get('nohist_email'.$suffix,[$forwarding]);
 	%content=&unpackagemsg($message{$forwarding},$folder);
@@ -1128,7 +1124,7 @@
 	$dismsg=~s/\n+/\n\> /g;
 	if ($content{'baseurl'}) {
 	    $disbase='<input type="hidden" name="baseurl" value="'.&Apache::lonnet::escape($content{'baseurl'}).'" />';
-	    if ($ENV{'user.adv'}) {
+	    if ($env{'user.adv'}) {
 		$disbase.='<label><input type="checkbox" name="storebasecomment" />'.&mt('Store message for re-use').
 		    '</label> <a href="/adm/email?showcommentbaseurl='.
 		    &Apache::lonnet::escape($content{'baseurl'}).'" target="comments">'.
@@ -1137,7 +1133,7 @@
 	}
     }
     my $citation=&displayresource(%content);
-    if ($ENV{'form.recdom'}) { $defdom=$ENV{'form.recdom'}; }
+    if ($env{'form.recdom'}) { $defdom=$env{'form.recdom'}; }
       $r->print(
                 '<form action="/adm/email"  name="compemail" method="post"'.
                 ' enctype="multipart/form-data">'."\n".
@@ -1158,7 +1154,7 @@
 	    my $selectlink=&Apache::loncommon::selectstudent_link
 	    ('compemail','recuname','recdomain');
 	    $r->print(<<"ENDREC");
-<tr><td>$lt{'us'}:</td><td><input type="text" size="12" name="recuname" value="$ENV{'form.recname'}" /></td><td rowspan="2">$selectlink</td></tr>
+<tr><td>$lt{'us'}:</td><td><input type="text" size="12" name="recuname" value="$env{'form.recname'}" /></td><td rowspan="2">$selectlink</td></tr>
 <tr><td>$lt{'do'}:</td>
 <td>$domform</td></tr>
 ENDREC
@@ -1219,14 +1215,14 @@
 
 sub retrieve_instructor_comments {
     my ($user,$domain)=@_;
-    my $target=$ENV{'form.grade_target'};
-    if (! $ENV{'request.course.id'}) { return; }
-    if (! &Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) {
+    my $target=$env{'form.grade_target'};
+    if (! $env{'request.course.id'}) { return; }
+    if (! &Apache::lonnet::allowed('srm',$env{'request.course.id'})) {
 	return;
     }
     my %records=&Apache::lonnet::dump('nohist_email',
-			 $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
-			 $ENV{'course.'.$ENV{'request.course.id'}.'.num'},
+			 $env{'course.'.$env{'request.course.id'}.'.domain'},
+			 $env{'course.'.$env{'request.course.id'}.'.num'},
                          '%255b'.$user.'%253a'.$domain.'%255d');
     my $result='';
     foreach (sort(keys(%records))) {
@@ -1244,14 +1240,14 @@
 
 sub disfacetoface {
     my ($r,$user,$domain)=@_;
-    my $target=$ENV{'form.grade_target'};
-    unless ($ENV{'request.course.id'}) { return; }
-    unless (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) {
+    my $target=$env{'form.grade_target'};
+    unless ($env{'request.course.id'}) { return; }
+    unless (&Apache::lonnet::allowed('srm',$env{'request.course.id'})) {
 	return;
     }
     my %records=&Apache::lonnet::dump('nohist_email',
-			 $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
-			 $ENV{'course.'.$ENV{'request.course.id'}.'.num'},
+			 $env{'course.'.$env{'request.course.id'}.'.domain'},
+			 $env{'course.'.$env{'request.course.id'}.'.num'},
                          '%255b'.$user.'%253a'.$domain.'%255d');
     my $result='';
     foreach (sort keys %records) {
@@ -1294,7 +1290,7 @@
 
 sub facetoface {
     my ($r,$stage)=@_;
-    unless (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) {
+    unless (&Apache::lonnet::allowed('srm',$env{'request.course.id'})) {
 	return;
     }
     &printheader($r,
@@ -1302,12 +1298,12 @@
 		 "User Notes, Face-to-Face, Critical Messages, Broadcast Messages");
 # from query string
 
-    if ($ENV{'form.recname'}) { $ENV{'form.recuname'}=$ENV{'form.recname'}; }
-    if ($ENV{'form.recdom'}) { $ENV{'form.recdomain'}=$ENV{'form.recdom'}; }
+    if ($env{'form.recname'}) { $env{'form.recuname'}=$env{'form.recname'}; }
+    if ($env{'form.recdom'}) { $env{'form.recdomain'}=$env{'form.recdom'}; }
 
-    my $defdom=$ENV{'user.domain'};
+    my $defdom=$env{'user.domain'};
 # already filled in
-    if ($ENV{'form.recdomain'}) { $defdom=$ENV{'form.recdomain'}; }
+    if ($env{'form.recdomain'}) { $defdom=$env{'form.recdomain'}; }
 # generate output
     my $domform = &Apache::loncommon::select_dom_form($defdom,'recdomain');
     my $stdbrws = &Apache::loncommon::selectstudent_link
@@ -1323,7 +1319,7 @@
 <form method="post" action="/adm/email" name="stdselect">
 <input type="hidden" name="recordftf" value="retrieve" />
 <table>
-<tr><td>$lt{'user'}:</td><td><input type="text" size="12" name="recuname" value="$ENV{'form.recuname'}" /></td>
+<tr><td>$lt{'user'}:</td><td><input type="text" size="12" name="recuname" value="$env{'form.recuname'}" /></td>
 <td rowspan="2">
 $stdbrws
 <input type="submit" value="$lt{'subm'}" /></td>
@@ -1334,23 +1330,23 @@
 </form>
 ENDTREC
     if (($stage ne 'query') &&
-        ($ENV{'form.recdomain'}) && ($ENV{'form.recuname'})) {
-        chomp($ENV{'form.newrecord'});
-        if ($ENV{'form.newrecord'}) {
+        ($env{'form.recdomain'}) && ($env{'form.recuname'})) {
+        chomp($env{'form.newrecord'});
+        if ($env{'form.newrecord'}) {
            &user_normal_msg_raw(
-            $ENV{'course.'.$ENV{'request.course.id'}.'.num'},
-            $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
+            $env{'course.'.$env{'request.course.id'}.'.num'},
+            $env{'course.'.$env{'request.course.id'}.'.domain'},
             &mt('Record').
-	     ' ['.$ENV{'form.recuname'}.':'.$ENV{'form.recdomain'}.']',
-	    $ENV{'form.newrecord'});
+	     ' ['.$env{'form.recuname'}.':'.$env{'form.recdomain'}.']',
+	    $env{'form.newrecord'});
         }
-        $r->print('<h3>'.&Apache::loncommon::plainname($ENV{'form.recuname'},
-				     $ENV{'form.recdomain'}).'</h3>');
-        &disfacetoface($r,$ENV{'form.recuname'},$ENV{'form.recdomain'});
+        $r->print('<h3>'.&Apache::loncommon::plainname($env{'form.recuname'},
+				     $env{'form.recdomain'}).'</h3>');
+        &disfacetoface($r,$env{'form.recuname'},$env{'form.recdomain'});
 	$r->print(<<ENDRHEAD);
 <form method="post" action="/adm/email">
-<input name="recdomain" value="$ENV{'form.recdomain'}" type="hidden" />
-<input name="recuname" value="$ENV{'form.recuname'}" type="hidden" />
+<input name="recdomain" value="$env{'form.recdomain'}" type="hidden" />
+<input name="recuname" value="$env{'form.recuname'}" type="hidden" />
 ENDRHEAD
         $r->print(<<ENDBFORM);
 <hr />$lt{'newr'}<br />
@@ -1367,8 +1363,8 @@
 
 sub examblock {
     my ($r,$action) = @_;
-    unless ($ENV{'request.course.id'}) { return;}
-    unless (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) { $r->print('Not allowed'); }
+    unless ($env{'request.course.id'}) { return;}
+    unless (&Apache::lonnet::allowed('srm',$env{'request.course.id'})) { $r->print('Not allowed'); }
     my %lt=&Apache::lonlocal::texthash(
             'comb' => 'Communication Blocking',
             'cbds' => 'Communication blocking during scheduled exams',
@@ -1438,7 +1434,7 @@
     my $addtotal = 0;
     my %blocking = ();
     $r->print('<h3>'.$lt{'head'}.'</h3>');
-    foreach (keys %ENV) {
+    foreach (keys %env) {
         if ($_ =~ m/^form\.modify_(\w+)$/) {
             $adds{$1} = $1;
             $removals{$1} = $1;
@@ -1456,23 +1452,23 @@
     }
 
     foreach (keys %removals) {
-        my $hashkey = $ENV{'form.key_'.$_};
+        my $hashkey = $env{'form.key_'.$_};
         &Apache::lonnet::del('comm_block',["$hashkey"],
-                         $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
-                         $ENV{'course.'.$ENV{'request.course.id'}.'.num'}
+                         $env{'course.'.$env{'request.course.id'}.'.domain'},
+                         $env{'course.'.$env{'request.course.id'}.'.num'}
                          );
     }
     foreach (keys %adds) {
         unless ( defined($cancels{$_}) ) {
             my ($newstart,$newend) = &get_dates_from_form($_);
             my $newkey = $newstart.'____'.$newend;
-            $blocking{$newkey} = $ENV{'user.name'}.'@'.$ENV{'user.domain'}.':'.$ENV{'form.title_'.$_};
+            $blocking{$newkey} = $env{'user.name'}.'@'.$env{'user.domain'}.':'.$env{'form.title_'.$_};
         }
     }
     if ($addtotal + $modtotal > 0) {
         &Apache::lonnet::put('comm_block',\%blocking,
-                     $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
-                     $ENV{'course.'.$ENV{'request.course.id'}.'.num'}
+                     $env{'course.'.$env{'request.course.id'}.'.domain'},
+                     $env{'course.'.$env{'request.course.id'}.'.num'}
                      );
     }
     my $chgestotal = $canceltotal + $modtotal + $addtotal;
@@ -1506,8 +1502,8 @@
     my ($records,$blockcount) = @_;
     $$blockcount = 0;
     %{$records} = &Apache::lonnet::dump('comm_block',
-                         $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
-                         $ENV{'course.'.$ENV{'request.course.id'}.'.num'}
+                         $env{'course.'.$env{'request.course.id'}.'.domain'},
+                         $env{'course.'.$env{'request.course.id'}.'.num'}
                          );
     $$blockcount = keys %{$records};
                                                                                                              
@@ -1525,7 +1521,7 @@
     my @bgcols = ("#eeeeee","#dddddd");
     my $function = &Apache::loncommon::get_users_function();
     my $color = &Apache::loncommon::designparm($function.'.tabbg',
-                                                    $ENV{'user.domain'});
+                                                    $env{'user.domain'});
     my %lt = &Apache::lonlocal::texthash(
         'modi' => 'Modify',
         'canc' => 'Cancel',
@@ -1591,7 +1587,7 @@
     my $endform = &Apache::lonhtmlcommon::date_setter('blockform','enddate_'.$parmcount,$end,$onchange);
     my $function = &Apache::loncommon::get_users_function();
     my $color = &Apache::loncommon::designparm($function.'.tabbg',
-                                                    $ENV{'user.domain'});
+                                                    $env{'user.domain'});
     my %lt = &Apache::lonlocal::texthash(
         'addb' => 'Add block',
         'exam' => 'e.g., Exam 1',
@@ -1634,12 +1630,12 @@
     my @staffcses = ();
     $$startblock = 0;
     $$endblock = 0;
-    foreach (keys %ENV) {
+    foreach (keys %env) {
         if ($_ =~ m-^user\.role\.(st|cc|in)\./(.+)$-) {
             my $role = $1;
             my $cse = $2;
             $cse =~ s|/|_|;
-            if ($ENV{$_} =~ m/^(\d*)\.(\d*)$/) {
+            if ($env{$_} =~ m/^(\d*)\.(\d*)$/) {
                 unless (($2 > 0 && $2 < time) || ($1 > time)) {
                     if ($role eq 'st') {
                         push @livecses, $cse;
@@ -1651,14 +1647,14 @@
                 }
             }
         } elsif ($_ =~ m-user\.role\.cr/(\w+)/(\w+)/([^/]+)\./(.+)$- ) { 
-            my $rolepriv = $ENV{'user.role..rolesdef_'.$3};
+            my $rolepriv = $env{'user.role..rolesdef_'.$3};
         }
     }
     # Retrieve blocking times and identity of blocker for active courses for students.
     if (@livecses > 0) {
         foreach my $cse (@livecses) {
             my ($cdom,$crs) = split/_/,$cse;
-            if ( (grep/^$cse$/,@staffcses) && ($ENV{'request.role'} !~ m-^st\./$cdom/$crs$-) ) {
+            if ( (grep/^$cse$/,@staffcses) && ($env{'request.role'} !~ m-^st\./$cdom/$crs$-) ) {
                 next;
             } else {
                 %{$$setters{$cse}} = ();
@@ -1689,7 +1685,7 @@
     my ($r,$startblock,$endblock,$setters) = @_;
     my $function = &Apache::loncommon::get_users_function();
     my $color = &Apache::loncommon::designparm($function.'.tabbg',
-                                                    $ENV{'user.domain'});
+                                                    $env{'user.domain'});
     my %lt = &Apache::lonlocal::texthash(
         'cacb' => 'Currently active communication blocks',
         'cour' => 'Course',
@@ -1776,7 +1772,7 @@
 	      '<td><a href="/adm/email?markdel='.&Apache::lonnet::escape($msgid).$sqs.
 	      '"><b>Delete</b></a></td>'.
 	      '<td><a href="/adm/email?'.$sqs.
-	      ($ENV{'form.dismode'} eq 'new'?'&folder=new':'').
+	      ($env{'form.dismode'} eq 'new'?'&folder=new':'').
 	      '"><b>'.&mt('Back to Folder Display').'</b></a></td>');
     if ($counter > 0){
 	$r->print('<td><a href="/adm/email?display='.$messages[$counter-1]->[5].$sqs.
@@ -1818,7 +1814,7 @@
 # If the recipient is in the same course that the message was sent from and
 # has sufficient privileges, show "all details," else show citation
 #
-    if (($ENV{'request.course.id'} eq $content{'courseid'})
+    if (($env{'request.course.id'} eq $content{'courseid'})
      && (&Apache::lonnet::allowed('vgr',$content{'courseid'}))) {
 	my $symb=&Apache::lonnet::symbread($content{'baseurl'});
 # Could not get a symb, give up
@@ -1875,21 +1871,21 @@
 
 sub storecomment {
     my ($r)=@_;
-    my $msgtxt=&Apache::lonfeedback::clear_out_html($ENV{'form.message'});
+    my $msgtxt=&Apache::lonfeedback::clear_out_html($env{'form.message'});
     my $cleanmsgtxt='';
     foreach (split(/[\n\r]/,$msgtxt)) {
 	unless ($_=~/^\s*(\>|\&gt\;)/) {
 	    $cleanmsgtxt.=$_."\n";
 	}
     }
-    my $key=&Apache::lonnet::escape($ENV{'form.baseurl'}).'___'.time;
+    my $key=&Apache::lonnet::escape($env{'form.baseurl'}).'___'.time;
     &Apache::lonnet::put('nohist_stored_comments',{ $key => $cleanmsgtxt });
 }
 
 sub storedcommentlisting {
     my ($r)=@_;
     my %msgs=&Apache::lonnet::dump('nohist_stored_comments',undef,undef,
-       '^'.&Apache::lonnet::escape(&Apache::lonnet::escape($ENV{'form.showcommentbaseurl'})));
+       '^'.&Apache::lonnet::escape(&Apache::lonnet::escape($env{'form.showcommentbaseurl'})));
     $r->print(&Apache::lonxml::xmlbegin().'<head>'.
 	      &Apache::lonxml::fontsettings().'</head><body>');
     if ((keys %msgs)[0]=~/^error\:/) {
@@ -1912,35 +1908,35 @@
     my ($r,$folder)=@_;
     my $suffix=&foldersuffix($folder);
     my $sendstatus='';
-    if ($ENV{'form.send'}) {
+    if ($env{'form.send'}) {
 	&printheader($r,'','Messages being sent.');
 	$r->rflush();
 	my %content=();
 	undef %content;
-	if ($ENV{'form.forwid'}) {
-	    my $msgid=$ENV{'form.forwid'};
+	if ($env{'form.forwid'}) {
+	    my $msgid=$env{'form.forwid'};
 	    my %message=&Apache::lonnet::get('nohist_email'.$suffix,[$msgid]);
 	    %content=&unpackagemsg($message{$msgid},1);
 	    &statuschange($msgid,'forwarded',$folder);
-	    $ENV{'form.message'}.="\n\n-- Forwarded message --\n\n".
+	    $env{'form.message'}.="\n\n-- Forwarded message --\n\n".
 		$content{'message'};
 	}
-	if ($ENV{'form.replyid'}) {
-	    my $msgid=$ENV{'form.replyid'};
+	if ($env{'form.replyid'}) {
+	    my $msgid=$env{'form.replyid'};
 	    my %message=&Apache::lonnet::get('nohist_email'.$suffix,[$msgid]);
 	    %content=&unpackagemsg($message{$msgid},1);
 	    &statuschange($msgid,'replied',$folder);
 	}
 	my %toaddr=();
 	undef %toaddr;
-	if ($ENV{'form.sendmode'} eq 'group') {
-	    foreach (keys %ENV) {
+	if ($env{'form.sendmode'} eq 'group') {
+	    foreach (keys %env) {
 		if ($_=~/^form\.send\_to\_\&\&\&[^\&]*\&\&\&\_(.+)$/) {
 		    $toaddr{$1}='';
 		}
 	    }
-	} elsif ($ENV{'form.sendmode'} eq 'upload') {
-	    foreach (split(/[\n\r\f]+/,$ENV{'form.upfile'})) {
+	} elsif ($env{'form.sendmode'} eq 'upload') {
+	    foreach (split(/[\n\r\f]+/,$env{'form.upfile'})) {
 		my ($rec,$txt)=split(/\s*\:\s*/,$_);
 		if ($txt) {
 		    $rec=~s/\@/\:/;
@@ -1948,10 +1944,10 @@
 		}
 	    }
 	} else {
-	    $toaddr{$ENV{'form.recuname'}.':'.$ENV{'form.recdomain'}}='';
+	    $toaddr{$env{'form.recuname'}.':'.$env{'form.recdomain'}}='';
 	}
-	if ($ENV{'form.additionalrec'}) {
-	    foreach (split(/\,/,$ENV{'form.additionalrec'})) {
+	if ($env{'form.additionalrec'}) {
+	    foreach (split(/\,/,$env{'form.additionalrec'})) {
 		my ($auname,$audom)=split(/\@/,$_);
 		$toaddr{$auname.':'.$audom}='';
 	    }
@@ -1960,31 +1956,31 @@
 	foreach (keys %toaddr) {
 	    my ($recuname,$recdomain)=split(/\:/,$_);
             my $msgtxt;
-            if ((($ENV{'form.critmsg'}) || ($ENV{'form.sendbck'})) &&
-                (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) {
-                $msgtxt=&Apache::lonfeedback::clear_out_html($ENV{'form.message'},1);
+            if ((($env{'form.critmsg'}) || ($env{'form.sendbck'})) &&
+                (&Apache::lonnet::allowed('srm',$env{'request.course.id'}))) {
+                $msgtxt=&Apache::lonfeedback::clear_out_html($env{'form.message'},1);
             } else {  
-	        $msgtxt=&Apache::lonfeedback::clear_out_html($ENV{'form.message'});
+	        $msgtxt=&Apache::lonfeedback::clear_out_html($env{'form.message'});
             }
 	    if ($toaddr{$_}) { $msgtxt.='<hr />'.$toaddr{$_}; }
 	    my $thismsg;    
-	    if ((($ENV{'form.critmsg'}) || ($ENV{'form.sendbck'})) && 
-		(&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) {
+	    if ((($env{'form.critmsg'}) || ($env{'form.sendbck'})) && 
+		(&Apache::lonnet::allowed('srm',$env{'request.course.id'}))) {
 		$r->print(&mt('Sending critical message').' '.$recuname.'@'.$recdomain.': ');
 		$thismsg=&user_crit_msg($recuname,$recdomain,
-					&Apache::lonfeedback::clear_out_html($ENV{'form.subject'}),
+					&Apache::lonfeedback::clear_out_html($env{'form.subject'}),
 					$msgtxt,
-					$ENV{'form.sendbck'},$ENV{'form.permanent'});
+					$env{'form.sendbck'},$env{'form.permanent'});
 	    } else {
 		$r->print(&mt('Sending').' '.$recuname.'@'.$recdomain.': ');
 		$thismsg=&user_normal_msg($recuname,$recdomain,
-					  &Apache::lonfeedback::clear_out_html($ENV{'form.subject'}),
+					  &Apache::lonfeedback::clear_out_html($env{'form.subject'}),
 					  $msgtxt,
-					  $content{'citation'},undef,undef,$ENV{'form.permanent'});
-		if (($ENV{'request.course.id'}) && ($ENV{'form.sendmode'} eq 'group')) {
+					  $content{'citation'},undef,undef,$env{'form.permanent'});
+		if (($env{'request.course.id'}) && ($env{'form.sendmode'} eq 'group')) {
 		    &user_normal_msg_raw(
-					 $ENV{'course.'.$ENV{'request.course.id'}.'.num'},
-					 $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
+					 $env{'course.'.$env{'request.course.id'}.'.num'},
+					 $env{'course.'.$env{'request.course.id'}.'.domain'},
 					 'Broadcast ['.$recuname.':'.$recdomain.']',
 					 $msgtxt);
 		}
@@ -1997,7 +1993,7 @@
     }
     if ($sendstatus=~/^(\s*(?:ok|con_delayed)\s*)*$/) {
 	$r->print('<br /><font color="green">'.&mt('Completed.').'</font>');
-	if ($ENV{'form.displayedcrit'}) {
+	if ($env{'form.displayedcrit'}) {
 	    &discrit($r);
 	} else {
 	    &Apache::loncommunicate::menu($r);
@@ -2028,10 +2024,10 @@
          'sendreply','compose','sendmail','critical','recname','recdom',
          'recordftf','sortedby','block','folder','startdis','interdis',
 	 'showcommentbaseurl','dismode']);
-    $sqs='&sortedby='.$ENV{'form.sortedby'};
+    $sqs='&sortedby='.$env{'form.sortedby'};
 
 # ------------------------------------------------------ They checked for email
-    unless ($ENV{'form.block'}) {
+    unless ($env{'form.block'}) {
         &Apache::lonnet::put('email_status',{'recnewemail'=>0});
     }
 
@@ -2045,7 +2041,7 @@
 
 # ------------------------------------------------------------------ Get Folder
 
-    my $folder=$ENV{'form.folder'};
+    my $folder=$env{'form.folder'};
     unless ($folder) { 
 	$folder=''; 
     } else {
@@ -2054,24 +2050,24 @@
 
 # --------------------------------------------------------------------- Display
 
-    $startdis=$ENV{'form.startdis'};
+    $startdis=$env{'form.startdis'};
     $startdis--;
     unless ($startdis) { $startdis=0; }
 
-    $interdis=$ENV{'form.interdis'};
+    $interdis=$env{'form.interdis'};
     unless ($interdis) { $interdis=20; }
     $sqs.='&interdis='.$interdis;
 
-    if ($ENV{'form.firstview'}) {
+    if ($env{'form.firstview'}) {
 	$startdis=0;
     }
-    if ($ENV{'form.lastview'}) {
+    if ($env{'form.lastview'}) {
 	$startdis=-1;
     }
-    if ($ENV{'form.prevview'}) {
+    if ($env{'form.prevview'}) {
 	$startdis--;
     }
-    if ($ENV{'form.nextview'}) {
+    if ($env{'form.nextview'}) {
 	$startdis++;
     }
     my $postedstartdis=$startdis+1;
@@ -2079,13 +2075,13 @@
 
 # --------------------------------------------------------------- Render Output
 
-    if ($ENV{'form.display'}) {
-	&displaymessage($r,$ENV{'form.display'},$folder);
-    } elsif ($ENV{'form.replyto'}) {
-	&compout($r,'',$ENV{'form.replyto'},undef,undef,$folder);
-    } elsif ($ENV{'form.confirm'}) {
+    if ($env{'form.display'}) {
+	&displaymessage($r,$env{'form.display'},$folder);
+    } elsif ($env{'form.replyto'}) {
+	&compout($r,'',$env{'form.replyto'},undef,undef,$folder);
+    } elsif ($env{'form.confirm'}) {
 	&printheader($r,'','Confirmed Receipt');
-	foreach (keys %ENV) {
+	foreach (keys %env) {
 	    if ($_=~/^form\.rec\_(.*)$/) {
 		$r->print('<b>'.&mt('Confirming Receipt').':</b> '.
 			  &user_crit_received($1).'<br>');
@@ -2098,22 +2094,22 @@
 	    }
 	}
 	&discrit($r);
-    } elsif ($ENV{'form.critical'}) {
+    } elsif ($env{'form.critical'}) {
 	&printheader($r,'','Displaying Critical Messages');
 	&discrit($r);
-    } elsif ($ENV{'form.forward'}) {
-	&compout($r,$ENV{'form.forward'},undef,undef,undef,$folder);
-    } elsif ($ENV{'form.markdel'}) {
+    } elsif ($env{'form.forward'}) {
+	&compout($r,$env{'form.forward'},undef,undef,undef,$folder);
+    } elsif ($env{'form.markdel'}) {
 	&printheader($r,'','Deleted Message');
-	&statuschange($ENV{'form.markdel'},'deleted',$folder);
+	&statuschange($env{'form.markdel'},'deleted',$folder);
 	&Apache::loncommunicate::menu($r);
 	&disall($r,$folder);
-    } elsif ($ENV{'form.markedmove'}) {
+    } elsif ($env{'form.markedmove'}) {
 	my $total=0;
-	foreach (keys %ENV) {
+	foreach (keys %env) {
 	    if ($_=~/^form\.delmark_(.*)$/) {
 		&movemsg(&Apache::lonnet::unescape($1),$folder,
-			 $ENV{'form.movetofolder'});
+			 $env{'form.movetofolder'});
 		$total++;
 	    }
 	}
@@ -2121,9 +2117,9 @@
 	$r->print('Moved '.$total.' message(s)<p>');
 	&Apache::loncommunicate::menu($r);
 	&disall($r,$folder);
-    } elsif ($ENV{'form.markeddel'}) {
+    } elsif ($env{'form.markeddel'}) {
 	my $total=0;
-	foreach (keys %ENV) {
+	foreach (keys %env) {
 	    if ($_=~/^form\.delmark_(.*)$/) {
 		&statuschange(&Apache::lonnet::unescape($1),'deleted',$folder);
 		$total++;
@@ -2133,29 +2129,29 @@
 	$r->print('Deleted '.$total.' message(s)<p>');
 	&Apache::loncommunicate::menu($r);
 	&disall($r,$folder);
-    } elsif ($ENV{'form.markunread'}) {
+    } elsif ($env{'form.markunread'}) {
 	&printheader($r,'','Marked Message as Unread');
-	&statuschange($ENV{'form.markunread'},'new');
+	&statuschange($env{'form.markunread'},'new');
 	&Apache::loncommunicate::menu($r);
 	&disall($r,$folder);
-    } elsif ($ENV{'form.compose'}) {
-	&compout($r,'','',$ENV{'form.compose'});
-    } elsif ($ENV{'form.recordftf'}) {
-	&facetoface($r,$ENV{'form.recordftf'});
-    } elsif ($ENV{'form.block'}) {
-        &examblock($r,$ENV{'form.block'});
-    } elsif ($ENV{'form.sendmail'}) {
+    } elsif ($env{'form.compose'}) {
+	&compout($r,'','',$env{'form.compose'});
+    } elsif ($env{'form.recordftf'}) {
+	&facetoface($r,$env{'form.recordftf'});
+    } elsif ($env{'form.block'}) {
+        &examblock($r,$env{'form.block'});
+    } elsif ($env{'form.sendmail'}) {
 	&sendoffmail($r,$folder);
-	if ($ENV{'form.storebasecomment'}) {
+	if ($env{'form.storebasecomment'}) {
 	    &storecomment($r);
 	}
 	&disall($r,$folder);
-    } elsif ($ENV{'form.newfolder'}) {
+    } elsif ($env{'form.newfolder'}) {
 	&printheader($r,'','New Folder');
-	&makefolder($ENV{'form.newfolder'});
+	&makefolder($env{'form.newfolder'});
 	&Apache::loncommunicate::menu($r);
-	&disall($r,$ENV{'form.newfolder'});
-    } elsif ($ENV{'form.showcommentbaseurl'}) {
+	&disall($r,$env{'form.newfolder'});
+    } elsif ($env{'form.showcommentbaseurl'}) {
 	&storedcommentlisting($r);
     } else {
 	&printheader($r,'','Display All Messages');
Index: loncom/interface/lonmysql.pm
diff -u loncom/interface/lonmysql.pm:1.28 loncom/interface/lonmysql.pm:1.29
--- loncom/interface/lonmysql.pm:1.28	Mon Feb 21 13:08:19 2005
+++ loncom/interface/lonmysql.pm	Thu Apr  7 02:56:23 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # MySQL utility functions
 #
-# $Id: lonmysql.pm,v 1.28 2005/02/21 18:08:19 matthew Exp $
+# $Id: lonmysql.pm,v 1.29 2005/04/07 06:56:23 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -32,6 +32,7 @@
 use strict;
 use DBI;
 use POSIX qw(strftime mktime);
+use Apache::lonnet;
 
 my $mysqluser;
 my $mysqlpassword;
@@ -89,7 +90,7 @@
 The table id is returned by &create_table.  
 If you lose the table id, it is lost forever.
 The table names in MySQL correspond to 
-$ENV{'user.name'}.'_'.$ENV{'user.domain'}.'_'.$table_id.  If the table id 
+$env{'user.name'}.'_'.$env{'user.domain'}.'_'.$table_id.  If the table id 
 is non-numeric, it is assumed to be the full name of a table.  If you pass
 the table id in a form, you MUST ensure that what you send to lonmysql is
 numeric, otherwise you are opening up all the tables in the MySQL database.
@@ -820,7 +821,7 @@
     my $newid = 0;
     my @tables = &tables_in_db();
     foreach (@tables) {
-        if (/^$ENV{'user.name'}_$ENV{'user.domain'}_(\d+)$/) {
+        if (/^$env{'user.name'}_$env{'user.domain'}_(\d+)$/) {
             $newid = $1 if ($1 > $newid);
         }
     }
@@ -1098,7 +1099,7 @@
     # id should be a digit.  If it is not a digit we assume the given id
     # is complete and does not need to be translated.
     return $id if ($id =~ /\D/);  
-    return $ENV{'user.name'}.'_'.$ENV{'user.domain'}.'_'.$id;
+    return $env{'user.name'}.'_'.$env{'user.domain'}.'_'.$id;
 }
 
 ###########################################
Index: loncom/interface/lonnavmaps.pm
diff -u loncom/interface/lonnavmaps.pm:1.319 loncom/interface/lonnavmaps.pm:1.320
--- loncom/interface/lonnavmaps.pm:1.319	Wed Mar 23 17:16:57 2005
+++ loncom/interface/lonnavmaps.pm	Thu Apr  7 02:56:23 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Navigate Maps Handler
 #
-# $Id: lonnavmaps.pm,v 1.319 2005/03/23 22:16:57 albertel Exp $
+# $Id: lonnavmaps.pm,v 1.320 2005/04/07 06:56:23 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -110,7 +110,7 @@
 }
 
 sub close {
-    if ($ENV{'environment.remotenavmap'} ne 'on') { return ''; }
+    if ($env{'environment.remotenavmap'} ne 'on') { return ''; }
     return(<<ENDCLOSE);
 <script type="text/javascript">
 window.status='Accessing Nav Control';
@@ -124,8 +124,8 @@
 }
 
 sub update {
-    if ($ENV{'environment.remotenavmap'} ne 'on') { return ''; }
-    if (!$ENV{'request.course.id'}) { return ''; }
+    if ($env{'environment.remotenavmap'} ne 'on') { return ''; }
+    if (!$env{'request.course.id'}) { return ''; }
     if ($ENV{'REQUEST_URI'}=~m|^/adm/navmaps|) { return ''; }
     return(<<ENDUPDATE);
 <form name="navform"></form>
@@ -147,7 +147,7 @@
     #my $t0=[&gettimeofday()];
     # Handle header-only request
     if ($r->header_only) {
-        if ($ENV{'browser.mathml'}) {
+        if ($env{'browser.mathml'}) {
             &Apache::loncommon::content_type($r,'text/xml');
         } else {
             &Apache::loncommon::content_type($r,'text/html');
@@ -157,7 +157,7 @@
     }
 
     # Send header, don't cache this page
-    if ($ENV{'browser.mathml'}) {
+    if ($env{'browser.mathml'}) {
         &Apache::loncommon::content_type($r,'text/xml');
     } else {
         &Apache::loncommon::content_type($r,'text/html');
@@ -213,7 +213,7 @@
 
     if (!defined($navmap)) {
         my $requrl = $r->uri;
-        $ENV{'user.error.msg'} = "$requrl:bre:0:0:Course not initialized";
+        $env{'user.error.msg'} = "$requrl:bre:0:0:Course not initialized";
         return HTTP_NOT_ACCEPTABLE;
     }
     my $html=&Apache::lonxml::xmlbegin();
@@ -226,7 +226,7 @@
     my $addentries='';
     my $more_unload;
     my $body_only='';
-    if ($ENV{'environment.remotenavmap'} eq 'on') {
+    if ($env{'environment.remotenavmap'} eq 'on') {
 	$r->print('<script type="text/javascript">
                       function collapse() {
                          this.document.location="/adm/navmaps?collapseExternal";
@@ -236,7 +236,7 @@
 #	$more_unload="collapse()"
 	$body_only=1;
     }
-    if ($ENV{'form.register'}) {
+    if ($env{'form.register'}) {
 	$addentries=' onLoad="'.&Apache::lonmenu::loadevents().
 	    '" onUnload="'.&Apache::lonmenu::unloadevents().';'.
 	    $more_unload.'"';
@@ -249,7 +249,7 @@
     $r->print('</head>'.
               &Apache::loncommon::bodytag('Navigate Course Contents','',
 					  $addentries,$body_only,'',
-					  $ENV{'form.register'}));
+					  $env{'form.register'}));
     $r->print('<script>window.focus();</script>');
      
     $r->rflush();
@@ -280,9 +280,9 @@
         if ($sequenceCount == 1) {
             # The automatic iterator creation in the render call 
             # will pick this up. We know the condition because
-            # the defined($ENV{'form.filter'}) also ensures this
+            # the defined($env{'form.filter'}) also ensures this
             # is a fresh call.
-            $ENV{'form.filter'} = "$sequenceId";
+            $env{'form.filter'} = "$sequenceId";
         }
     }
 
@@ -297,10 +297,10 @@
           </script>');
     }
 
-    if ($ENV{'environment.remotenavmap'} ne 'on') {
+    if ($env{'environment.remotenavmap'} ne 'on') {
 	$r->print(&launch_win('link','yes',\%toplinkitems));
     } 
-    if ($ENV{'environment.remotenavmap'} eq 'on') {
+    if ($env{'environment.remotenavmap'} eq 'on') {
 	&add_linkitem(\%toplinkitems,'closenav','collapse()',
 		      "Close navigation window");
     } 
@@ -327,10 +327,10 @@
                     pop @$stack; # last resource in the stack is the problem
                                  # itself, which we don't need in the map stack
                     my @mapPcs = map {$_->map_pc()} @$stack;
-                    $ENV{'form.filter'} = join(',', @mapPcs);
+                    $env{'form.filter'} = join(',', @mapPcs);
 
                     # Mark as both "here" and "jump"
-                    $ENV{'form.postsymb'} = $curRes->symb();
+                    $env{'form.postsymb'} = $curRes->symb();
                 }
             }
         }
@@ -351,30 +351,30 @@
 
     # Display only due homework.
     my $showOnlyHomework = 0;
-    if ($ENV{'form.showOnlyHomework'} eq "1") {
+    if ($env{'form.showOnlyHomework'} eq "1") {
         $showOnlyHomework = 1;
         $suppressEmptySequences = 1;
         $filterFunc = sub { my $res = shift; 
                             return $res->completable() || $res->is_map();
                         };
 	&add_linkitem(\%toplinkitems,'everything',
-		     'location.href="navmaps?sort='.$ENV{'form.sort'}.'"',
+		     'location.href="navmaps?sort='.$env{'form.sort'}.'"',
 		      "Show Everything");
         $r->print("<p><font size='+2'>".&mt("Uncompleted Homework")."</font></p>");
-        $ENV{'form.filter'} = '';
-        $ENV{'form.condition'} = 1;
+        $env{'form.filter'} = '';
+        $env{'form.condition'} = 1;
 	$resource_no_folder_link = 1;
     } else {
 	&add_linkitem(\%toplinkitems,'uncompleted',
-		      'location.href="navmaps?sort='.$ENV{'form.sort'}.
+		      'location.href="navmaps?sort='.$env{'form.sort'}.
 		          '&showOnlyHomework=1"',
 		      "Show Only Uncompleted Homework");
     }
 
-    my %selected=($ENV{'form.sort'} => 'selected=on');
+    my %selected=($env{'form.sort'} => 'selected=on');
     my $sort_html=("<form>
                  <nobr>
-                    <input type=\"hidden\" name=\"showOnlyHomework\" value=\"".$ENV{'form.showOnlyHomework'}."\" />
+                    <input type=\"hidden\" name=\"showOnlyHomework\" value=\"".$env{'form.showOnlyHomework'}."\" />
                     <input type=\"submit\" value=\"".&mt('Sort by:')."\" />
                     <select name=\"sort\">
                        <option value=\"default\" $selected{'default'}>".&mt('Default')."</option>
@@ -386,7 +386,7 @@
                </form>");
     # renderer call
     my $renderArgs = { 'cols' => [0,1,2,3],
-		       'sort' => $ENV{'form.sort'},
+		       'sort' => $env{'form.sort'},
                        'url' => '/adm/navmaps',
                        'navmap' => $navmap,
                        'suppressNavmap' => 1,
@@ -565,10 +565,10 @@
         $res->duedate($part) > time();
 }
 
-# This puts a human-readable name on the ENV variable.
+# This puts a human-readable name on the env variable.
 
 sub advancedUser {
-    return $ENV{'request.role.adv'};
+    return $env{'request.role.adv'};
 }
 
 
@@ -871,13 +871,13 @@
 
 =over 4
 
-=item * B<iterator>: default: constructs one from %ENV
+=item * B<iterator>: default: constructs one from %env
 
 A reference to a fresh ::iterator to use from the navmaps. The
 rendering will reflect the options passed to the iterator, so you can
 use that to just render a certain part of the course, if you like. If
 one is not passed, the renderer will attempt to construct one from
-ENV{'form.filter'} and ENV{'form.condition'} information, plus the
+env{'form.filter'} and env{'form.condition'} information, plus the
 'iterator_map' parameter if any.
 
 =item * B<iterator_map>: default: not used
@@ -887,11 +887,11 @@
 the source of the map you want to process, like
 '/res/103/jerf/navmap.course.sequence'.
 
-=item * B<navmap>: default: constructs one from %ENV
+=item * B<navmap>: default: constructs one from %env
 
 A reference to a navmap, used only if an iterator is not passed in. If
 this is necessary to make an iterator but it is not passed in, a new
-one will be constructed based on ENV info. This is useful to do basic
+one will be constructed based on env info. This is useful to do basic
 error checking before passing it off to render.
 
 =item * B<r>: default: must be passed in
@@ -917,12 +917,12 @@
 all parts will always be displayed. If showParts is 0, this is
 ignored.
 
-=item * B<jumpCount>: default: determined from %ENV
+=item * B<jumpCount>: default: determined from %env
 
 A string identifying the URL to place the anchor 'curloc' at.
 It is the responsibility of the renderer user to
 ensure that the #curloc is in the URL. By default, determined through
-the use of the ENV{} 'jump' information, and should normally "just
+the use of the env{} 'jump' information, and should normally "just
 work" correctly.
 
 =item * B<here>: default: empty string
@@ -950,7 +950,7 @@
 
 Describes the currently-open row number to cause the browser to jump
 to, because the user just opened that folder. By default, pulled from
-the Jump information in the ENV{'form.*'}.
+the Jump information in the env{'form.*'}.
 
 =item * B<printKey>: default: false
 
@@ -1143,7 +1143,7 @@
     }
 
     my $target;
-    if ($ENV{'environment.remotenavmap'} eq 'on') {
+    if ($env{'environment.remotenavmap'} eq 'on') {
 	$target=' target="loncapaclient" ';
     }
     if (!$params->{'resource_nolink'} && !$resource->is_sequence() && !$resource->is_empty_sequence) {
@@ -1390,7 +1390,7 @@
     # marker
     my $filterHash = {};
     # Figure out what we're not displaying
-    foreach (split(/\,/, $ENV{"form.filter"})) {
+    foreach (split(/\,/, $env{"form.filter"})) {
         if ($_) {
             $filterHash->{$_} = "1";
         }
@@ -1410,11 +1410,11 @@
     }
 
     my $condition = 0;
-    if ($ENV{'form.condition'}) {
+    if ($env{'form.condition'}) {
         $condition = 1;
     }
 
-    if (!$ENV{'form.folderManip'} && !defined($args->{'iterator'})) {
+    if (!$env{'form.folderManip'} && !defined($args->{'iterator'})) {
         # Step 1: Check to see if we have a navmap
         if (!defined($navmap)) {
             $navmap = Apache::lonnavmaps::navmap->new();
@@ -1424,18 +1424,18 @@
         # Step two: Locate what kind of here marker is necessary
         # Determine where the "here" marker is and where the screen jumps to.
 
-        if ($ENV{'form.postsymb'}) {
-            $here = $jump = &Apache::lonnet::symbclean($ENV{'form.postsymb'});
-        } elsif ($ENV{'form.postdata'}) {
+        if ($env{'form.postsymb'}) {
+            $here = $jump = &Apache::lonnet::symbclean($env{'form.postsymb'});
+        } elsif ($env{'form.postdata'}) {
             # couldn't find a symb, is there a URL?
-            my $currenturl = $ENV{'form.postdata'};
+            my $currenturl = $env{'form.postdata'};
             #$currenturl=~s/^http\:\/\///;
             #$currenturl=~s/^[^\/]+//;
             
             $here = $jump = &Apache::lonnet::symbread($currenturl);
         } else {
 	    my $last;
-	    if (tie(my %hash,'GDBM_File',$ENV{'request.course.fn'}.'_symb.db',
+	    if (tie(my %hash,'GDBM_File',$env{'request.course.fn'}.'_symb.db',
                     &GDBM_READER(),0640)) {
 		$last=$hash{'last_known'};
 		untie(%hash);
@@ -1468,16 +1468,16 @@
         }            
     }        
 
-    if ( !defined($args->{'iterator'}) && $ENV{'form.folderManip'} ) { # we came from a user's manipulation of the nav page
+    if ( !defined($args->{'iterator'}) && $env{'form.folderManip'} ) { # we came from a user's manipulation of the nav page
         # If this is a click on a folder or something, we want to preserve the "here"
         # from the querystring, and get the new "jump" marker
-        $here = $ENV{'form.here'};
-        $jump = $ENV{'form.jump'};
+        $here = $env{'form.here'};
+        $jump = $env{'form.jump'};
     } 
     
     my $it = $args->{'iterator'};
     if (!defined($it)) {
-        # Construct a default iterator based on $ENV{'form.'} information
+        # Construct a default iterator based on $env{'form.'} information
         
         # Step 1: Check to see if we have a navmap
         if (!defined($navmap)) {
@@ -1612,14 +1612,14 @@
     if ($args->{'caller'} eq 'navmapsdisplay') {
         $result .= '<table><tr><td>'.
                    &Apache::loncommon::help_open_menu('','Navigation Screen','Navigation_Screen','',undef,'RAT').'</td>';
-	if ($ENV{'environment.remotenavmap'} ne 'on') {
+	if ($env{'environment.remotenavmap'} ne 'on') {
 	    $result .= '<td>&nbsp;</td>'; 
         } else {
 	    $result .= '</tr><tr>'; 
         }
 	$result.=&show_linkitems($args->{'linkitems'});
         if ($args->{'sort_html'}) {
-	    if ($ENV{'environment.remotenavmap'} ne 'on') {
+	    if ($env{'environment.remotenavmap'} ne 'on') {
 		$result.='<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>'.
 		    '<td align="right">'.$args->{'sort_html'}.'</td></tr>';
 	    } else {
@@ -2070,6 +2070,7 @@
 
 use strict;
 use GDBM_File;
+use Apache::lonnet;
 
 sub new {
     # magic invocation to create a class instance
@@ -2089,7 +2090,7 @@
 
     my %navmaphash;
     my %parmhash;
-    my $courseFn = $ENV{"request.course.fn"};
+    my $courseFn = $env{"request.course.fn"};
     if (!(tie(%navmaphash, 'GDBM_File', "${courseFn}.db",
               &GDBM_READER(), 0640))) {
         return undef;
@@ -2115,11 +2116,11 @@
     my $self = shift;
     if ($self->{COURSE_USER_OPT_GENERATED}) { return; }
 
-    my $uname=$ENV{'user.name'};
-    my $udom=$ENV{'user.domain'};
-    my $uhome=$ENV{'user.home'};
-    my $cid=$ENV{'request.course.id'};
-    my $chome=$ENV{'course.'.$cid.'.home'};
+    my $uname=$env{'user.name'};
+    my $udom=$env{'user.domain'};
+    my $uhome=$env{'user.home'};
+    my $cid=$env{'request.course.id'};
+    my $chome=$env{'course.'.$cid.'.home'};
     my ($cdom,$cnum)=split(/\_/,$cid);
     
     my $userprefix=$uname.'_'.$udom.'_';
@@ -2175,18 +2176,18 @@
     my $symb = shift;
     if ($self->{EMAIL_DISCUSS_GENERATED}) { return; }
 
-    my $cid=$ENV{'request.course.id'};
+    my $cid=$env{'request.course.id'};
     my ($cdom,$cnum)=split(/\_/,$cid);
     
     my %emailstatus = &Apache::lonnet::dump('email_status');
     my $logoutTime = $emailstatus{'logout'};
-    my $courseLeaveTime = $emailstatus{'logout_'.$ENV{'request.course.id'}};
+    my $courseLeaveTime = $emailstatus{'logout_'.$env{'request.course.id'}};
     $self->{LAST_CHECK} = (($courseLeaveTime > $logoutTime) ?
 			   $courseLeaveTime : $logoutTime);
     my %discussiontime = &Apache::lonnet::dump('discussiontimes', 
 					       $cdom, $cnum);
     my %lastread = &Apache::lonnet::dump('nohist_'.$cid.'_discuss',
-                                        $ENV{'user.domain'},$ENV{'user.name'},'lastread');
+                                        $env{'user.domain'},$env{'user.name'},'lastread');
     my %lastreadtime = ();
     foreach (keys %lastread) {
         my $key = $_;
@@ -2197,9 +2198,9 @@
     my %feedback=();
     my %error=();
     my $keys = &Apache::lonnet::reply('keys:'.
-				      $ENV{'user.domain'}.':'.
-				      $ENV{'user.name'}.':nohist_email',
-				      $ENV{'user.home'});
+				      $env{'user.domain'}.':'.
+				      $env{'user.name'}.':nohist_email',
+				      $env{'user.home'});
     
     foreach my $msgid (split(/\&/, $keys)) {
 	$msgid=&Apache::lonnet::unescape($msgid);
@@ -2233,9 +2234,9 @@
     if ($self->{RETRIEVED_USER_DATA}) { return; }
 
     # Retrieve performance data on problems
-    my %student_data = Apache::lonnet::currentdump($ENV{'request.course.id'},
-						   $ENV{'user.domain'},
-						   $ENV{'user.name'});
+    my %student_data = Apache::lonnet::currentdump($env{'request.course.id'},
+						   $env{'user.domain'},
+						   $env{'user.name'});
     $self->{STUDENT_DATA} = \%student_data;
 
     $self->{RETRIEVED_USER_DATA} = 1;
@@ -2260,7 +2261,7 @@
 # Checks to see if coursemap is defined, matching test in old lonnavmaps
 sub courseMapDefined {
     my $self = shift;
-    my $uri = &Apache::lonnet::clutter($ENV{'request.course.uri'});
+    my $uri = &Apache::lonnet::clutter($env{'request.course.uri'});
 
     my $firstres = $self->navhash("map_start_$uri");
     my $lastres = $self->navhash("map_finish_$uri");
@@ -2401,7 +2402,7 @@
 sub firstResource {
     my $self = shift;
     my $firstResource = $self->navhash('map_start_' .
-                     &Apache::lonnet::clutter($ENV{'request.course.uri'}));
+                     &Apache::lonnet::clutter($env{'request.course.uri'}));
     return $self->getById($firstResource);
 }
 
@@ -2417,7 +2418,7 @@
 sub finishResource {
     my $self = shift;
     my $firstResource = $self->navhash('map_finish_' .
-                     &Apache::lonnet::clutter($ENV{'request.course.uri'}));
+                     &Apache::lonnet::clutter($env{'request.course.uri'}));
     return $self->getById($firstResource);
 }
 
@@ -2444,10 +2445,10 @@
     # Make sure the {USER_OPT} and {COURSE_OPT} hashes are populated
     $self->generate_course_user_opt();
 
-    my $cid=$ENV{'request.course.id'};
-    my $csec=$ENV{'request.course.sec'};
-    my $uname=$ENV{'user.name'};
-    my $udom=$ENV{'user.domain'};
+    my $cid=$env{'request.course.id'};
+    my $csec=$env{'request.course.sec'};
+    my $uname=$env{'user.name'};
+    my $udom=$env{'user.domain'};
 
     unless ($symb) { return ''; }
     my $result='';
@@ -2662,6 +2663,8 @@
 
 package Apache::lonnavmaps::iterator;
 use WeakRef;
+use Apache::lonnet;
+
 =pod
 
 =back
@@ -3141,6 +3144,8 @@
 
 package Apache::lonnavmaps::DFSiterator;
 use WeakRef;
+use Apache::lonnet;
+
 # Not documented in the perldoc: This is a simple iterator that just walks
 #  through the nav map and presents the resources in a depth-first search
 #  fashion, ignorant of conditionals, randomized resources, etc. It presents
@@ -3531,7 +3536,7 @@
     if ($self->{ID} eq '0.0') {
 	# If this is the top-level map, return the title of the course
 	# since this map can not be titled otherwise.
-	return $ENV{'course.'.$ENV{'request.course.id'}.'.description'};
+	return $env{'course.'.$env{'request.course.id'}.'.description'};
     }
     return $self->navHash("title_", 1); }
 # considered private and undocumented
@@ -3865,9 +3870,9 @@
     my $self = shift; my $part = shift;
     if (!defined($part)) { $part = '0'; }
     return &Apache::lonnet::EXT('resource.'.$part.'.weight',
-				$self->symb(), $ENV{'user.domain'},
-				$ENV{'user.name'}, 
-				$ENV{'request.course.sec'});
+				$self->symb(), $env{'user.domain'},
+				$env{'user.name'}, 
+				$env{'request.course.sec'});
 }
 sub part_display {
     my $self= shift(); my $partID = shift();
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.189 loncom/interface/lonparmset.pm:1.190
--- loncom/interface/lonparmset.pm:1.189	Fri Mar 18 10:17:36 2005
+++ loncom/interface/lonparmset.pm	Thu Apr  7 02:56:23 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set parameters for assessments
 #
-# $Id: lonparmset.pm,v 1.189 2005/03/18 15:17:36 www Exp $
+# $Id: lonparmset.pm,v 1.190 2005/04/07 06:56:23 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -115,13 +115,13 @@
     my $symbparm=$symbp{$id}.'.'.$what;
     my $mapparm=$mapp{$id}.'___(all).'.$what;
 
-    my $seclevel=$ENV{'request.course.id'}.'.['.$csec.'].'.$what;
-    my $seclevelr=$ENV{'request.course.id'}.'.['.$csec.'].'.$symbparm;
-    my $seclevelm=$ENV{'request.course.id'}.'.['.$csec.'].'.$mapparm;
-
-    my $courselevel=$ENV{'request.course.id'}.'.'.$what;
-    my $courselevelr=$ENV{'request.course.id'}.'.'.$symbparm;
-    my $courselevelm=$ENV{'request.course.id'}.'.'.$mapparm;
+    my $seclevel=$env{'request.course.id'}.'.['.$csec.'].'.$what;
+    my $seclevelr=$env{'request.course.id'}.'.['.$csec.'].'.$symbparm;
+    my $seclevelm=$env{'request.course.id'}.'.['.$csec.'].'.$mapparm;
+
+    my $courselevel=$env{'request.course.id'}.'.'.$what;
+    my $courselevelr=$env{'request.course.id'}.'.'.$symbparm;
+    my $courselevelm=$env{'request.course.id'}.'.'.$mapparm;
 
 
 
@@ -212,13 +212,13 @@
     my $symbparm=$symbp{$sresid}.'.'.$spnam;
     my $mapparm=$mapp{$sresid}.'___(all).'.$spnam;
     
-    my $seclevel=$ENV{'request.course.id'}.'.['.$csec.'].'.$spnam;
-    my $seclevelr=$ENV{'request.course.id'}.'.['.$csec.'].'.$symbparm;
-    my $seclevelm=$ENV{'request.course.id'}.'.['.$csec.'].'.$mapparm;
+    my $seclevel=$env{'request.course.id'}.'.['.$csec.'].'.$spnam;
+    my $seclevelr=$env{'request.course.id'}.'.['.$csec.'].'.$symbparm;
+    my $seclevelm=$env{'request.course.id'}.'.['.$csec.'].'.$mapparm;
     
-    my $courselevel=$ENV{'request.course.id'}.'.'.$spnam;
-    my $courselevelr=$ENV{'request.course.id'}.'.'.$symbparm;
-    my $courselevelm=$ENV{'request.course.id'}.'.'.$mapparm;
+    my $courselevel=$env{'request.course.id'}.'.'.$spnam;
+    my $courselevelr=$env{'request.course.id'}.'.'.$symbparm;
+    my $courselevelm=$env{'request.course.id'}.'.'.$mapparm;
     
     my $storeunder='';
     if (($snum==11) || ($snum==3)) { $storeunder=$courselevel; }
@@ -249,13 +249,13 @@
 	if ($delete) {
 	    $reply=&Apache::lonnet::del
 		('resourcedata',[keys(%storecontent)],
-		 $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
-		 $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+		 $env{'course.'.$env{'request.course.id'}.'.domain'},
+		 $env{'course.'.$env{'request.course.id'}.'.num'});
 	} else {
 	    $reply=&Apache::lonnet::cput
 		('resourcedata',\%storecontent,
-		 $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
-		 $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+		 $env{'course.'.$env{'request.course.id'}.'.domain'},
+		 $env{'course.'.$env{'request.course.id'}.'.num'});
 	}
     } else {
 # ------------------------------------------------------------------ Store User
@@ -367,9 +367,9 @@
     my $winvalue=$value;
     unless ($winvalue) {
 	if ($type=~/^date/) {
-            $winvalue=$ENV{'form.recent_'.$type};
+            $winvalue=$env{'form.recent_'.$type};
         } else {
-            $winvalue=$ENV{'form.recent_'.(split(/\_/,$type))[0]};
+            $winvalue=$env{'form.recent_'.(split(/\_/,$type))[0]};
         }
     }
     return 
@@ -478,8 +478,8 @@
     my %sectionhash=();
     my $sections='';
     if (&Apache::loncommon::get_sections(
-                 $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
-                 $ENV{'course.'.$ENV{'request.course.id'}.'.num'},
+                 $env{'course.'.$env{'request.course.id'}.'.domain'},
+                 $env{'course.'.$env{'request.course.id'}.'.num'},
 					 \%sectionhash)) {
         $sections=$lt{'sg'}.': <select name="csec">';
 	foreach ('',sort keys %sectionhash) {
@@ -788,7 +788,7 @@
     my $uhome;
     my $csec;
  
-    my $coursename=$ENV{'course.'.$ENV{'request.course.id'}.'.description'};
+    my $coursename=$env{'course.'.$env{'request.course.id'}.'.description'};
 
     $alllevs{'Resource Level'}='full';
     $alllevs{'Map Level'}='map';
@@ -808,54 +808,54 @@
 
     my $message='';
 
-    $csec=$ENV{'form.csec'};
+    $csec=$env{'form.csec'};
 
-    if      ($udom=$ENV{'form.udom'}) {
-    } elsif ($udom=$ENV{'request.role.domain'}) {
-    } elsif ($udom=$ENV{'user.domain'}) {
+    if      ($udom=$env{'form.udom'}) {
+    } elsif ($udom=$env{'request.role.domain'}) {
+    } elsif ($udom=$env{'user.domain'}) {
     } else {
 	$udom=$r->dir_config('lonDefDomain');
     }
 
     my @pscat=&Apache::loncommon::get_env_multiple('form.pscat');
-    my $pschp=$ENV{'form.pschp'};
+    my $pschp=$env{'form.pschp'};
     my @psprt=&Apache::loncommon::get_env_multiple('form.psprt');
     if (!@psprt) { $psprt[0]='0'; }
-    my $showoptions=$ENV{'form.showoptions'};
+    my $showoptions=$env{'form.showoptions'};
 
     my $pssymb='';
     my $parmlev='';
     my $trimheader='';
-    my $prevvisit=$ENV{'form.prevvisit'};
+    my $prevvisit=$env{'form.prevvisit'};
  
-    unless ($ENV{'form.parmlev'}) {
+    unless ($env{'form.parmlev'}) {
         $parmlev = 'map';
     } else {
-        $parmlev = $ENV{'form.parmlev'};
+        $parmlev = $env{'form.parmlev'};
     }
 
 # ----------------------------------------------- Was this started from grades?
 
-    if (($ENV{'form.command'} eq 'set') && ($ENV{'form.url'})
-	&& (!$ENV{'form.dis'})) {
-	my $url=$ENV{'form.url'};
+    if (($env{'form.command'} eq 'set') && ($env{'form.url'})
+	&& (!$env{'form.dis'})) {
+	my $url=$env{'form.url'};
 	$url=~s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;
 	$pssymb=&Apache::lonnet::symbread($url);
 	if (!@pscat) { @pscat=('all'); }
 	$pschp='';
         $parmlev = 'full';
         $trimheader='yes';
-    } elsif ($ENV{'form.symb'}) {
-	$pssymb=$ENV{'form.symb'};
+    } elsif ($env{'form.symb'}) {
+	$pssymb=$env{'form.symb'};
 	if (!@pscat) { @pscat=('all'); }
 	$pschp='';
         $parmlev = 'full';
         $trimheader='yes';
     } else {
-	$ENV{'form.url'}='';
+	$env{'form.url'}='';
     }
 
-    my $id=$ENV{'form.id'};
+    my $id=$env{'form.id'};
     if (($id) && ($udom)) {
 	$uname=(&Apache::lonnet::idget($udom,$id))[1];
 	if ($uname) {
@@ -866,7 +866,7 @@
 		&mt('at domain')." '$udom'</font>";
 	}
     } else {
-	$uname=$ENV{'form.uname'};
+	$uname=$env{'form.uname'};
     }
     unless ($udom) { $uname=''; }
     $uhome='';
@@ -879,13 +879,13 @@
 	    $uname='';
         } else {
 	    $csec=&Apache::lonnet::getsection($udom,$uname,
-					      $ENV{'request.course.id'});
+					      $env{'request.course.id'});
 	    if ($csec eq '-1') {
 		$message="<font color=red>".
 		    &mt("User")." '$uname' ".&mt("at domain")." '$udom' ".
 		    &mt("not in this course")."</font>";
 		$uname='';
-		$csec=$ENV{'form.csec'};
+		$csec=$env{'form.csec'};
 	    } else {
 		my %name=&Apache::lonnet::userenvironment($udom,$uname,
 		      ('firstname','middlename','lastname','generation','id'));
@@ -899,18 +899,18 @@
 
     unless ($csec) { $csec=''; }
 
-    my $fcat=$ENV{'form.fcat'};
+    my $fcat=$env{'form.fcat'};
     unless ($fcat) { $fcat=''; }
 
 # ------------------------------------------------------------------- Tie hashs
-    if (!(tie(%bighash,'GDBM_File',$ENV{'request.course.fn'}.'.db',
+    if (!(tie(%bighash,'GDBM_File',$env{'request.course.fn'}.'.db',
 	      &GDBM_READER(),0640))) {
-	$r->print("Unable to access course data. (File $ENV{'request.course.fn'}.db not tieable)");
+	$r->print("Unable to access course data. (File $env{'request.course.fn'}.db not tieable)");
 	return ;
     }
     if (!(tie(%parmhash,'GDBM_File',
-	      $ENV{'request.course.fn'}.'_parms.db',&GDBM_READER(),0640))) {
-	$r->print("Unable to access parameter data. (File $ENV{'request.course.fn'}_parms.db not tieable)");
+	      $env{'request.course.fn'}.'_parms.db',&GDBM_READER(),0640))) {
+	$r->print("Unable to access parameter data. (File $env{'request.course.fn'}_parms.db not tieable)");
 	return ;
     }
 
@@ -921,24 +921,24 @@
     $symbp{'0.0'} = '';
 
 # ---------------------------------------------------------- Anything to store?
-    if ($ENV{'form.pres_marker'}) {
-	$message.=&storeparm(split(/\&/,$ENV{'form.pres_marker'}),
-			     $ENV{'form.pres_value'},
-			     $ENV{'form.pres_type'},
+    if ($env{'form.pres_marker'}) {
+	$message.=&storeparm(split(/\&/,$env{'form.pres_marker'}),
+			     $env{'form.pres_value'},
+			     $env{'form.pres_type'},
                              $uname,$udom,$csec);
 # ---------------------------------------------------------------- Done storing
 	$message.='<h3>'.&mt('Changes can take up to 10 minutes before being active for all students.').&Apache::loncommon::help_open_topic('Caching').'</h3>';
     }
 # --------------------------------------------- Devalidate cache for this child
     &Apache::lonnet::devalidatecourseresdata(
-                 $ENV{'course.'.$ENV{'request.course.id'}.'.num'},
-                 $ENV{'course.'.$ENV{'request.course.id'}.'.domain'});
+                 $env{'course.'.$env{'request.course.id'}.'.num'},
+                 $env{'course.'.$env{'request.course.id'}.'.domain'});
     &Apache::lonnet::clear_EXT_cache_status();
 # -------------------------------------------------------------- Get coursedata
     %courseopt = &Apache::lonnet::dump
         ('resourcedata',
-         $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
-         $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+         $env{'course.'.$env{'request.course.id'}.'.domain'},
+         $env{'course.'.$env{'request.course.id'}.'.num'});
 # --------------------------------------------------- Get userdata (if present)
     if ($uname) {
         %useropt=&Apache::lonnet::dump('resourcedata',$udom,$uname);
@@ -972,8 +972,8 @@
 	untie(%parmhash);
 	return '';
     }
-#    if ($ENV{'form.url'}) {
-#	$r->print('<input type="hidden" value="'.$ENV{'form.url'}.
+#    if ($env{'form.url'}) {
+#	$r->print('<input type="hidden" value="'.$env{'form.url'}.
 #		  '" name="url"><input type="hidden" name="command" value="set">');
 #    }
     $r->print('<input type="hidden" value="true" name="prevvisit">');
@@ -981,7 +981,7 @@
     foreach ('tolerance','date_default','date_start','date_end',
 	     'date_interval','int','float','string') {
 	$r->print('<input type="hidden" value="'.
-		  $ENV{'form.recent_'.$_}.'" name="recent_'.$_.'">');
+		  $env{'form.recent_'.$_}.'" name="recent_'.$_.'">');
     }
 
     $r->print('<h2>'.$message.'</h2><table>');
@@ -1147,8 +1147,8 @@
     if (($prevvisit) || ($pschp) || ($pssymb)) {
 # ----------------------------------------------------------------- Start Table
         my @catmarker=map { tr|.|_|; 'parameter_'.$_; } @pscat;
-        my $csuname=$ENV{'user.name'};
-        my $csudom=$ENV{'user.domain'};
+        my $csuname=$env{'user.name'};
+        my $csudom=$env{'user.domain'};
 
         if ($parmlev eq 'full' || $parmlev eq 'brief') {
            my $coursespan=$csec?8:5;
@@ -1509,17 +1509,17 @@
     my $setoutput='';
     my $bodytag=&Apache::loncommon::bodytag(
                              'Set Course Environment Parameters');
-    my $dom = $ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
-    my $crs = $ENV{'course.'.$ENV{'request.course.id'}.'.num'};
+    my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+    my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
 
     #
     # Go through list of changes
-    foreach (keys %ENV) {
+    foreach (keys %env) {
         next if ($_!~/^form\.(.+)\_setparmval$/);
         my $name  = $1;
-        my $value = $ENV{'form.'.$name.'_value'};
+        my $value = $env{'form.'.$name.'_value'};
         if ($name eq 'newp') {
-            $name = $ENV{'form.newp_name'};
+            $name = $env{'form.newp_name'};
         }
         if ($name eq 'url') {
             $value=~s/^\/res\///;
@@ -1595,7 +1595,7 @@
     }
 # ------------------------- Re-init course environment entries for this session
 
-    &Apache::lonnet::coursedescription($ENV{'request.course.id'});
+    &Apache::lonnet::coursedescription($env{'request.course.id'});
 
 # -------------------------------------------------------- Get parameters again
 
@@ -1791,7 +1791,7 @@
     my $Set=&mt('Set');
     my $browse_js=&Apache::loncommon::browser_and_searcher_javascript('parmset');
     my $html=&Apache::lonxml::xmlbegin();
-    $r->print(<<ENDENV);
+    $r->print(<<ENDenv);
 $html
 <head>
 <script type="text/javascript" language="Javascript" >
@@ -1811,7 +1811,7 @@
 </form>
 </body>
 </html>    
-ENDENV
+ENDenv
 }
 ##################################################
 
@@ -1840,8 +1840,8 @@
     my $r=shift;
     my $bodytag=&Apache::loncommon::bodytag(
                              'Set/Modify Course Assessment Parameters');
-    my $dom = $ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
-    my $crs = $ENV{'course.'.$ENV{'request.course.id'}.'.num'};
+    my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+    my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
     my $html=&Apache::lonxml::xmlbegin();
     $r->print(<<ENDOVER);
 $html
@@ -1858,17 +1858,17 @@
     undef %newdata;
     my @deldata=();
     undef @deldata;
-    foreach (keys %ENV) {
+    foreach (keys %env) {
 	if ($_=~/^form\.([a-z]+)\_(.+)$/) {
 	    my $cmd=$1;
 	    my $thiskey=$2;
 	    if ($cmd eq 'set') {
-		my $data=$ENV{$_};
+		my $data=$env{$_};
 		if ($olddata{$thiskey} ne $data) { $newdata{$thiskey}=$data; }
 	    } elsif ($cmd eq 'del') {
 		push (@deldata,$thiskey);
 	    } elsif ($cmd eq 'datepointer') {
-		my $data=&Apache::lonhtmlcommon::get_date_from_form($ENV{$_});
+		my $data=&Apache::lonhtmlcommon::get_date_from_form($env{$_});
 		if (defined($data) and $olddata{$thiskey} ne $data) { $newdata{$thiskey}=$data; }
 	    }
 	}
@@ -1989,8 +1989,8 @@
 sub change_clone {
     my ($clonelist,$oldcloner) = @_;
     my ($uname,$udom);
-    my $cnum = $ENV{'course.'.$ENV{'request.course.id'}.'.num'};
-    my $cdom = $ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
+    my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+    my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
     my $clone_crs = $cnum.':'.$cdom;
     
     if ($cnum && $cdom) {
@@ -2086,20 +2086,20 @@
 
 # ----------------------------------------------------- Needs to be in a course
 
-    if (($ENV{'request.course.id'}) && 
-	(&Apache::lonnet::allowed('opa',$ENV{'request.course.id'}) || 
-	 &Apache::lonnet::allowed('opa',$ENV{'request.course.id'}.'/'.
-				  $ENV{'request.course.sec'})
+    if (($env{'request.course.id'}) && 
+	(&Apache::lonnet::allowed('opa',$env{'request.course.id'}) || 
+	 &Apache::lonnet::allowed('opa',$env{'request.course.id'}.'/'.
+				  $env{'request.course.sec'})
 	 )) {
 
         &Apache::loncommon::content_type($r,'text/html');
         $r->send_http_header;
 
-	if (($ENV{'form.crsenv'}) || (!$ENV{'request.course.fn'})) {
+	if (($env{'form.crsenv'}) || (!$env{'request.course.fn'})) {
 # ---------------------------------------------- This is for course environment
 # -------------------------- also call if toplevel map coudl not be initialized
 	    &crsenv($r);
-	} elsif ($ENV{'form.overview'}) {
+	} elsif ($env{'form.overview'}) {
 # --------------------------------------------------------------- Overview mode
 	    &overview($r);
 	} else {
@@ -2108,7 +2108,7 @@
 	}
     } else {
 # ----------------------------- Not in a course, or not allowed to modify parms
-	$ENV{'user.error.msg'}=
+	$env{'user.error.msg'}=
 	    "/adm/parmset:opa:0:0:Cannot modify assessment parameters";
 	return HTTP_NOT_ACCEPTABLE;
     }
Index: loncom/interface/lonpickcode.pm
diff -u loncom/interface/lonpickcode.pm:1.5 loncom/interface/lonpickcode.pm:1.6
--- loncom/interface/lonpickcode.pm:1.5	Thu Feb 17 03:29:43 2005
+++ loncom/interface/lonpickcode.pm	Thu Apr  7 02:56:23 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Pick a CODE from the list of possible CODEs
 #
-# $Id: lonpickcode.pm,v 1.5 2005/02/17 08:29:43 albertel Exp $
+# $Id: lonpickcode.pm,v 1.6 2005/04/07 06:56:23 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -33,12 +33,13 @@
 use Apache::loncommon();
 use Apache::grades();
 use Apache::lonlocal;
+use Apache::lonnet;
 
 sub get_code_freq {
     my ($r)=@_;
     my %codes;
     my %scantron_config=
-	&Apache::grades::get_scantron_config($ENV{'form.scantron_format'});
+	&Apache::grades::get_scantron_config($env{'form.scantron_format'});
     $r->rflush();
     my ($scanlines,$scan_data)=&Apache::grades::scantron_getfile();
     for (my $i=0;$i<=$scanlines->{'count'};$i++) {
@@ -73,8 +74,8 @@
 					     'form','scantron_format',
 					     'scantron_CODElist']);
 
-    if  (!($ENV{'request.course.id'}) && 
-	 (&Apache::lonnet::allowed('usc',$ENV{'request.course.id'}))) {
+    if  (!($env{'request.course.id'}) && 
+	 (&Apache::lonnet::allowed('usc',$env{'request.course.id'}))) {
 	$r->print('<body>Access not allowed.</body>');
         return OK;
     }
@@ -83,8 +84,8 @@
     $r->print(<<ENDSCRIPT);
 <script>
 function gochoose(newcode) {
-    opener.document.$ENV{'form.form'}.scantron_CODE_selectedvalue.value=newcode;
-    var slct=opener.document.$ENV{'form.form'}.scantron_CODE_resolution;
+    opener.document.$env{'form.form'}.scantron_CODE_selectedvalue.value=newcode;
+    var slct=opener.document.$env{'form.form'}.scantron_CODE_resolution;
     var i;
     for (i=0;i<slct.length;i++) {
         if (slct[i].value=='use_found') { slct[i].checked=true; }
@@ -95,17 +96,17 @@
 ENDSCRIPT
 
 
-    $r->print("<p>The CODE on the paper is <tt><b>".$ENV{'form.curCODE'}.
+    $r->print("<p>The CODE on the paper is <tt><b>".$env{'form.curCODE'}.
 	      "</b></tt>. Please Select a new one.</p>\n".'<form>');
     my %codes=&Apache::grades::get_codes();
     my %code_freq=&get_code_freq($r);
-    my $num_matches=length($ENV{'form.curCODE'});
+    my $num_matches=length($env{'form.curCODE'});
     for (my $i=$num_matches;$i>=0;$i--) {
 	my $to_print="<p> CODEs with $i matches</p>";
 	$to_print.='<table border="1"><tr><td></td><td>CODE</td><td>exams using this CODE</td>';
 	my $print;
 	foreach my $code (sort(keys(%codes))) {
-	    if (&Apache::grades::num_matches($ENV{'form.curCODE'},$code) != $i) { next; }
+	    if (&Apache::grades::num_matches($env{'form.curCODE'},$code) != $i) { next; }
 	    $print=1;
 	    my ($count,$list);
 	    if (!ref($code_freq{$code})) {
Index: loncom/interface/lonpickcourse.pm
diff -u loncom/interface/lonpickcourse.pm:1.26 loncom/interface/lonpickcourse.pm:1.27
--- loncom/interface/lonpickcourse.pm:1.26	Thu Feb 17 03:29:43 2005
+++ loncom/interface/lonpickcourse.pm	Thu Apr  7 02:56:23 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Pick a course
 #
-# $Id: lonpickcourse.pm,v 1.26 2005/02/17 08:29:43 albertel Exp $
+# $Id: lonpickcourse.pm,v 1.27 2005/04/07 06:56:23 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -56,25 +56,25 @@
 			       'cdomelement','cnameelement','roleelement',
                                'pickedcourse','instcodefilter','ownerfilter']);
 # domain filter and selection
-    my $domainfilter=$ENV{'form.domainfilter'};
+    my $domainfilter=$env{'form.domainfilter'};
     $domainfilter=~s/\W//g;
     unless ($domainfilter) { $domainfilter=''; }
     my $domainselectform=&Apache::loncommon::select_dom_form($domainfilter,
                                                           'domainfilter',1);
 # description filter
-    my $descriptfilter=$ENV{'form.descriptfilter'};
+    my $descriptfilter=$env{'form.descriptfilter'};
     unless ($descriptfilter) { $descriptfilter=''; }
     my $listdescript=&HTML::Entities::encode($descriptfilter,'<>&"');
 # institutional code filter
-    my $instcodefilter=$ENV{'form.instcodefilter'};
+    my $instcodefilter=$env{'form.instcodefilter'};
     unless ($instcodefilter) { $instcodefilter=''; }
     my $listinstcode=&HTML::Entities::encode($instcodefilter,'<>&"');
 # course owner filter
-    my $ownerfilter=$ENV{'form.ownerfilter'};
+    my $ownerfilter=$env{'form.ownerfilter'};
     unless ($ownerfilter) { $ownerfilter=''; }
     my $listowner=&HTML::Entities::encode($ownerfilter,'<>&"');
 # last course activity filter and selection
-    my $sincefilter=$ENV{'form.sincefilter'};
+    my $sincefilter=$env{'form.sincefilter'};
     $sincefilter=~s/[^\d-]//g;
     unless ($sincefilter) { $sincefilter=-1; }
     my $sincefilterform=&Apache::loncommon::select_form($sincefilter,
@@ -91,9 +91,9 @@
 # if called from loncreateuser, report sections, then close
     my ($loaditem,$seclist);
     my $num_sections = 0;
-    if ($ENV{'form.form'} eq 'cu' && $ENV{'form.pickedcourse'}) {
+    if ($env{'form.form'} eq 'cu' && $env{'form.pickedcourse'}) {
         $loaditem = 'onLoad="setSections()"';
-        my ($cdom,$cnum) = split/_/,$ENV{'form.pickedcourse'};
+        my ($cdom,$cnum) = split/_/,$env{'form.pickedcourse'};
         my %sections_count = ();
         $num_sections = &Apache::loncommon::get_sections($cdom,$cnum,\%sections_count);
         my @sections = ();
@@ -110,20 +110,20 @@
                                        'cin' => 'Course Institutional Code',
                                        'cow' => "Course Owner's usename");
     my ($name_code,$name_input);
-    if (defined($ENV{'form.cnameelement'}) && $ENV{'form.cnameelement'} ne '') {
-	$name_code = "opener.document.$ENV{'form.form'}.$ENV{'form.cnameelement'}.value=cdesc;";
+    if (defined($env{'form.cnameelement'}) && $env{'form.cnameelement'} ne '') {
+	$name_code = "opener.document.$env{'form.form'}.$env{'form.cnameelement'}.value=cdesc;";
 	$name_input ='<input type="hidden" name="cnameelement" value="'.
-	    $ENV{'form.cnameelement'}.'" />';
+	    $env{'form.cnameelement'}.'" />';
     }
     my $submitopener = '';
     my $autosubmit = '';
     my $roleelement = '';
     my $lastaction = 'self.close()';
-    if ($ENV{'form.form'} eq 'cu') {
+    if ($env{'form.form'} eq 'cu') {
         $lastaction = 'document.courselist.pickedcourse.value = cdom+"_"+cname;'."\n".
                       'document.courselist.submit();';
     }
-    my $roledom = $ENV{'form.roleelement'};
+    my $roledom = $env{'form.roleelement'};
     if ($roledom) {
         $roleelement = '<input type="hidden" name="roleelement" value="'.$roledom.'" />';
         $submitopener = &Apache::lonroles::processpick($roledom);
@@ -133,13 +133,13 @@
 <script>
 function gochoose(cname,cdom,cdesc) {
     $name_code
-    var openerForm = "$ENV{'form.form'}";
-    opener.document.$ENV{'form.form'}.$ENV{'form.cnumelement'}.value=cname;
+    var openerForm = "$env{'form.form'}";
+    opener.document.$env{'form.form'}.$env{'form.cnumelement'}.value=cname;
     if (openerForm == 'cu' || openerForm == 'rolechoice') {
-         opener.document.$ENV{'form.form'}.$ENV{'form.cdomelement'}.value=cdom;
+         opener.document.$env{'form.form'}.$env{'form.cdomelement'}.value=cdom;
     }
     else {
-        var slct=opener.document.$ENV{'form.form'}.$ENV{'form.cdomelement'};
+        var slct=opener.document.$env{'form.form'}.$env{'form.cdomelement'};
         var i;
         for (i=0;i<slct.length;i++) {
             if (slct.options[i].value==cdom) { slct.selectedIndex=i; }
@@ -152,32 +152,32 @@
 function setSections() {
     var numSections = $num_sections
     var sectionsArray = new Array("$seclist")
-    opener.document.$ENV{"form.form"}.currsec.length = 0
+    opener.document.$env{"form.form"}.currsec.length = 0
     if (numSections == 0) {
-        opener.document.$ENV{"form.form"}.currsec.multiple=false
-        opener.document.$ENV{"form.form"}.currsec.size=1;
-        opener.document.$ENV{"form.form"}.currsec.options[0] = new Option('No existing sections','',false,false)
+        opener.document.$env{"form.form"}.currsec.multiple=false
+        opener.document.$env{"form.form"}.currsec.size=1;
+        opener.document.$env{"form.form"}.currsec.options[0] = new Option('No existing sections','',false,false)
     }
     else {
         if (numSections == 1) {
-            opener.document.$ENV{"form.form"}.currsec.multiple=false;
-            opener.document.$ENV{"form.form"}.currsec.size=1;
-            opener.document.$ENV{"form.form"}.currsec.options[0] = new Option('Select','',true,true);
-            opener.document.$ENV{"form.form"}.currsec.options[1] = new Option('No section','',false,false) 
-            opener.document.$ENV{"form.form"}.currsec.options[2] = new Option(sectionsArray[0],sectionsArray[0],false,false);
+            opener.document.$env{"form.form"}.currsec.multiple=false;
+            opener.document.$env{"form.form"}.currsec.size=1;
+            opener.document.$env{"form.form"}.currsec.options[0] = new Option('Select','',true,true);
+            opener.document.$env{"form.form"}.currsec.options[1] = new Option('No section','',false,false) 
+            opener.document.$env{"form.form"}.currsec.options[2] = new Option(sectionsArray[0],sectionsArray[0],false,false);
         }
         else {
             for (var i=0; i<numSections; i++) {
-                opener.document.$ENV{"form.form"}.currsec.options[i] = new Option(sectionsArray[i],sectionsArray[i],false,false)
+                opener.document.$env{"form.form"}.currsec.options[i] = new Option(sectionsArray[i],sectionsArray[i],false,false)
             }
-            opener.document.$ENV{"form.form"}.currsec.multiple=true
+            opener.document.$env{"form.form"}.currsec.multiple=true
             if (numSections < 3) {
-                opener.document.$ENV{"form.form"}.currsec.size=numSections;
+                opener.document.$env{"form.form"}.currsec.size=numSections;
             }
             else {
-                opener.document.$ENV{"form.form"}.currsec.size=3;
+                opener.document.$env{"form.form"}.currsec.size=3;
             }
-            opener.document.$ENV{"form.form"}.currsec.options[0].selected = false
+            opener.document.$env{"form.form"}.currsec.options[0].selected = false
         }
     }
     self.close()
@@ -185,10 +185,10 @@
 </script>
 $submitopener
 <form method="post">
-<input type="hidden" name="cnumelement" value="$ENV{'form.cnumelement'}" />
-<input type="hidden" name="cdomelement" value="$ENV{'form.cdomelement'}" />
+<input type="hidden" name="cnumelement" value="$env{'form.cnumelement'}" />
+<input type="hidden" name="cdomelement" value="$env{'form.cdomelement'}" />
 $name_input
-<input type="hidden" name="form" value="$ENV{'form.form'}" />
+<input type="hidden" name="form" value="$env{'form.form'}" />
 $roleelement
 $lt{'cac'}: $sincefilterform
 <br />
@@ -207,7 +207,7 @@
 <hr />
 ENDSCRIPT
 # ---------------------------------------------------------------- Get the data
-    if ($ENV{'form.gosearch'}) {
+    if ($env{'form.gosearch'}) {
         $r->print(&mt('Searching').' ...<br />&nbsp;<br />');
         $r->rflush();
 	unless ($descriptfilter) { $descriptfilter='.'; }
@@ -249,10 +249,10 @@
             }
 	}
 	if (!%courses) { $r->print(&mt('None found')); }
-        $r->print('<input type="hidden" name="form" value="'.$ENV{'form.form'}.'" />'."\n".
+        $r->print('<input type="hidden" name="form" value="'.$env{'form.form'}.'" />'."\n".
                    '<input type="hidden" name="pickedcourse" value="" />'."\n".
-                   '<input type="hidden" name="cnumelement" value="'.$ENV{'form.cnumelement'}.'" />'."\n".
-                   '<input type="hidden" name="cdomelement" value="'.$ENV{'form.cdomelement'}.'" />'."\n".
+                   '<input type="hidden" name="cnumelement" value="'.$env{'form.cnumelement'}.'" />'."\n".
+                   '<input type="hidden" name="cdomelement" value="'.$env{'form.cdomelement'}.'" />'."\n".
                    '</form>');
     }
     $r->print('</body></html>');
Index: loncom/interface/lonpickstudent.pm
diff -u loncom/interface/lonpickstudent.pm:1.8 loncom/interface/lonpickstudent.pm:1.9
--- loncom/interface/lonpickstudent.pm:1.8	Thu Feb 17 03:29:43 2005
+++ loncom/interface/lonpickstudent.pm	Thu Apr  7 02:56:23 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Pick a student from the classlist
 #
-# $Id: lonpickstudent.pm,v 1.8 2005/02/17 08:29:43 albertel Exp $
+# $Id: lonpickstudent.pm,v 1.9 2005/04/07 06:56:23 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -58,16 +58,16 @@
 			       'roles']);
 # Allowed?
 
-    unless (($ENV{'form.roles'}) ||
-            (($ENV{'request.course.id'}) && 
-             (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})))) {
+    unless (($env{'form.roles'}) ||
+            (($env{'request.course.id'}) && 
+             (&Apache::lonnet::allowed('srm',$env{'request.course.id'})))) {
 	$r->print('<body>No context.</body>');
         return OK;
     }
 
 # See if filter present
 
-    my $filter=$ENV{'form.filter'};
+    my $filter=$env{'form.filter'};
     $filter=~s/\W//g;
     unless ($filter) { $filter='.'; }
 
@@ -79,8 +79,8 @@
     $r->print(<<ENDSCRIPT);
 <script>
 function gochoose(uname,udom) {
-    opener.document.$ENV{'form.form'}.$ENV{'form.unameelement'}.value=uname;
-    var slct=opener.document.$ENV{'form.form'}.$ENV{'form.udomelement'};
+    opener.document.$env{'form.form'}.$env{'form.unameelement'}.value=uname;
+    var slct=opener.document.$env{'form.form'}.$env{'form.udomelement'};
     var i;
     for (i=0;i<slct.length;i++) {
         if (slct.options[i].value==udom) { slct.selectedIndex=i; }
@@ -91,10 +91,10 @@
 ENDSCRIPT
     
   $r->print('<form>');
-  if ((&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) &&
-      (!$ENV{'form.roles'})) {
+  if ((&Apache::lonnet::allowed('srm',$env{'request.course.id'})) &&
+      (!$env{'form.roles'})) {
 # -------------------------------------------------------- Get course personnel
-    $r->print('<h3>'.$ENV{'course.'.$ENV{'request.course.id'}.'.description'}.
+    $r->print('<h3>'.$env{'course.'.$env{'request.course.id'}.'.description'}.
               '</h3>');
     my %coursepersonnel=
        &Apache::lonnet::get_course_adv_roles();
@@ -140,8 +140,8 @@
     $r->print('</table></p>');
   } else {
     $r->print('<h3>'.&mt('Users with Roles Assigned by').' '.
-	      &Apache::loncommon::plainname($ENV{'user.name'},
-					    $ENV{'user.domain'}).'</h3>');
+	      &Apache::loncommon::plainname($env{'user.name'},
+					    $env{'user.domain'}).'</h3>');
     if ($filter ne '.') {
        $r->print('<br/ >'.&mt('Name starting with').' "'.$filter.'"<br />');
     }
Index: loncom/interface/lonpopulate.pm
diff -u loncom/interface/lonpopulate.pm:1.22 loncom/interface/lonpopulate.pm:1.23
--- loncom/interface/lonpopulate.pm:1.22	Thu Feb 17 03:50:20 2005
+++ loncom/interface/lonpopulate.pm	Thu Apr  7 02:56:23 2005
@@ -1,5 +1,5 @@
 # automated enrollment configuration handler
-# $Id: lonpopulate.pm,v 1.22 2005/02/17 08:50:20 albertel Exp $
+# $Id: lonpopulate.pm,v 1.23 2005/04/07 06:56:23 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -207,8 +207,8 @@
 sub print_mainbox {
     my ($r,$tasklongref,$realm,$reply) = @_;
     my $action = "information";
-    if ( exists($ENV{'form.action'}) ) {
-        $action = $ENV{'form.action'};
+    if ( exists($env{'form.action'}) ) {
+        $action = $env{'form.action'};
     }
     my $page = '';
     if ($action eq "information") {
@@ -245,8 +245,8 @@
 sub print_navmenu {
     my ($r,$tasksref,$tasklongref) = @_;
     my $action = "information";
-    if (exists($ENV{'form.action'}) ) {
-        $action = $ENV{'form.action'};
+    if (exists($env{'form.action'}) ) {
+        $action = $env{'form.action'};
     }
     $r->print(<<ENDONE);
   <td width="10" valign="top" bgcolor="#DDFFFF">&nbsp;</td>
@@ -284,8 +284,8 @@
 sub print_main_frame {
   my ($r,$realm,$dom,$crs,$tasktitleref) = @_;
   my $action = "information";
-  if (exists($ENV{'form.action'}) ) {
-      $action = $ENV{'form.action'};
+  if (exists($env{'form.action'}) ) {
+      $action = $env{'form.action'};
   }
 
 # Get course settings
@@ -584,10 +584,10 @@
               }
           }
       }
-      my $viewer = $ENV{'user.name'}.'@'.$ENV{'user.domain'};
+      my $viewer = $env{'user.name'}.'@'.$env{'user.domain'};
       unless ( (grep/^$viewer$/,@ccs) || ($viewer eq '') )  {
           push @ccs,$viewer;
-          $pname{$viewer} =  &Apache::loncommon::plainname($ENV{'user.name'},$ENV{'user.domain'});
+          $pname{$viewer} =  &Apache::loncommon::plainname($env{'user.name'},$env{'user.domain'});
           $notifystate{$viewer} = 0;
       }
 
@@ -1000,13 +1000,13 @@
                     <tr>
                      <td>
       ");
-      if (! exists($ENV{'form.sortby'})) {
-          $ENV{'form.sortby'} = 'username';
+      if (! exists($env{'form.sortby'})) {
+          $env{'form.sortby'} = 'username';
       }
-      if ($ENV{'form.Status'} !~ /^(Any|Expired|Active)$/) {
-          $ENV{'form.Status'} = 'Active';
+      if ($env{'form.Status'} !~ /^(Any|Expired|Active)$/) {
+          $env{'form.Status'} = 'Active';
       }
-      my $status_select = &Apache::lonhtmlcommon::StatusOptions($ENV{'form.Status'});
+      my $status_select = &Apache::lonhtmlcommon::StatusOptions($env{'form.Status'});
 #  Get current classlist
       my ($classlist,$keylist)=&Apache::loncoursedata::get_classlist();
       if (! defined($classlist)) {
@@ -1017,7 +1017,7 @@
           $r->print('<input type="submit" value="'.&mt('Update Display').'" />'.
               "\n</p>\n");
 
-          my ($studentcount,$autocount,$manualcount,$lockcount,$unlockcount) = &Apache::londropadd::show_class_list($r,'autoenroll','nothing',$ENV{'form.Status'},$classlist,$keylist);
+          my ($studentcount,$autocount,$manualcount,$lockcount,$unlockcount) = &Apache::londropadd::show_class_list($r,'autoenroll','nothing',$env{'form.Status'},$classlist,$keylist);
           $r->print("
                      </td>
                     </tr>
@@ -1246,11 +1246,11 @@
     my $autoadds = '';
     my $autodrops = '';
 
-    if ( exists($ENV{'form.autoadds'}) ) {
-	$autoadds=$ENV{'form.autoadds'};
+    if ( exists($env{'form.autoadds'}) ) {
+	$autoadds=$env{'form.autoadds'};
     }
-    if ( exists($ENV{'form.autodrops'}) ) {
-	$autodrops=$ENV{'form.autodrops'};
+    if ( exists($env{'form.autodrops'}) ) {
+	$autodrops=$env{'form.autodrops'};
     }
 
     my $response = "";
@@ -1524,16 +1524,16 @@
 	unless ($_ eq '') { $currcount ++; } 
     }
 
-    if ( exists($ENV{'form.notify'}) ) {
-	$notify=$ENV{'form.notify'};
+    if ( exists($env{'form.notify'}) ) {
+	$notify=$env{'form.notify'};
     }
-    if ( exists($ENV{'form.notifyshow'}) ) {
-	my $notifyshow = $ENV{'form.notifyshow'};
+    if ( exists($env{'form.notifyshow'}) ) {
+	my $notifyshow = $env{'form.notifyshow'};
 	for (my $i=0; $i<$notifyshow; $i++) {
-	    if ( exists($ENV{"form.note_$i"}) ) {
-		if ( exists($ENV{"form.notifyname_$i"}) ) {
-		    unless ( $ENV{"form.notifyname_$i"} eq '' ) {
-			push @people, $ENV{"form.notifyname_$i"};
+	    if ( exists($env{"form.note_$i"}) ) {
+		if ( exists($env{"form.notifyname_$i"}) ) {
+		    unless ( $env{"form.notifyname_$i"} eq '' ) {
+			push @people, $env{"form.notifyname_$i"};
 		    }
 		}
 	    }
@@ -1603,13 +1603,13 @@
 	for (my $i=0; $i<@currxlists; $i++) {
 	    my $xlist = "cross_".$i;
 	    my $gp = "gp_".$i;
-	    if ( exists($ENV{"form.$xlist"}) ) {
+	    if ( exists($env{"form.$xlist"}) ) {
 		my $xlistentry = '';
 		if ($currxlists[$i] =~ m/^([^:]+)/) {
 		    $xlistentry = $1.':';
 		}
-		if ( exists($ENV{"form.$gp"}) ) {
-		    $xlistentry .= $ENV{"form.$gp"};
+		if ( exists($env{"form.$gp"}) ) {
+		    $xlistentry .= $env{"form.$gp"};
 		}
 		push @xlists,$xlistentry;
 		$crosscount ++;
@@ -1641,8 +1641,8 @@
 	    $response .= "</ul><br/>\n";
 	}
     }
-    if ( exists($ENV{'form.numcross'}) ) {
-	my $numcross = $ENV{'form.numcross'};
+    if ( exists($env{'form.numcross'}) ) {
+	my $numcross = $env{'form.numcross'};
 	if ($numcross > 0) {
 	    my @bgcolors=("#eeeeee","#cccccc");
 	    $response .= qq(You indicated that you wish to add an additional $numcross crosslisting(s).  For each new crosslisting enter the insititutional course section code (e.g., fs03zol101001, for section 001 of zol101 for fs03 semester), and the LON-CAPA section/group ID you wish to assign to students who will be enrolled in your LON-CAPA class as a result of their registration in the crosslisted course section. The LON-CAPA section/group ID can be left blank, if you do not wish to tie a section/group ID to this crosslisting.  The institutional course section code should only contain letters and/or numbers, and must be consistent with the scheme adopted by your Domain Coordinator to map course codes (and section numbers) to your institution\'s student information system.<br/><br/>
@@ -1707,27 +1707,27 @@
 	unless ($xliststr eq '') { $allxlists[0] = $xliststr; }
     }
 
-    if ( exists($ENV{'form.numcross'}) ) {
-	$numcross = $ENV{'form.numcross'};
+    if ( exists($env{'form.numcross'}) ) {
+	$numcross = $env{'form.numcross'};
     }
 
     if ($numcross > 0) {
 	for (my $i=0; $i<$numcross; $i++) {
 	    my $xl = "newcross_".$i;
 	    my $gp = "newgroupid_".$i;
-	    if ( exists($ENV{"form.$xl"}) ) {
+	    if ( exists($env{"form.$xl"}) ) {
 		my $coursecheck = '';
-		$coursecheck = &Apache::lonnet::auto_validate_courseID($crs,$dom,$ENV{"form.$xl"});
+		$coursecheck = &Apache::lonnet::auto_validate_courseID($crs,$dom,$env{"form.$xl"});
 		if ($coursecheck eq 'ok') {
 		    my $addcheck = '';
-		    $addcheck = &Apache::lonnet::auto_new_course($crs,$dom,$ENV{"form.$xl"},$owner);
+		    $addcheck = &Apache::lonnet::auto_new_course($crs,$dom,$env{"form.$xl"},$owner);
 		    if ($addcheck eq 'ok') {
-			push @xlists,$ENV{"form.$xl"}.":".$ENV{"form.$gp"};
+			push @xlists,$env{"form.$xl"}.":".$env{"form.$gp"};
 		    } else {
-			push @badowner,$ENV{"form.$xl"}.":".$ENV{"form.$gp"};
+			push @badowner,$env{"form.$xl"}.":".$env{"form.$gp"};
 		    }
 		} else {
-		    push @badxlists, $ENV{"form.$xl"}.":".$ENV{"form.$gp"}.":".$coursecheck;
+		    push @badxlists, $env{"form.$xl"}.":".$env{"form.$gp"}.":".$coursecheck;
 		}
 	    }
 	}
@@ -1821,36 +1821,36 @@
 	$currsections[0] = $settings{'internal.sectionnums'};
     }
     
-    if ( exists($ENV{'form.secshow'}) ) {
-	for (my $i=0; $i<$ENV{'form.secshow'}; $i++) {
+    if ( exists($env{'form.secshow'}) ) {
+	for (my $i=0; $i<$env{'form.secshow'}; $i++) {
 	    my $gp = "loncapasec_".$i;
 	    my $secnum = "secnum_".$i;
 	    my $sec = "sec_".$i;
-	    if ( exists( $ENV{"form.$sec"} ) ) {
+	    if ( exists( $env{"form.$sec"} ) ) {
 		my $secentry;
-		if ( exists( $ENV{"form.$secnum"} ) ) { 
-		    $secentry = $ENV{"form.$secnum"}.':';
+		if ( exists( $env{"form.$secnum"} ) ) { 
+		    $secentry = $env{"form.$secnum"}.':';
 		}
-		if ( exists( $ENV{"form.$gp"} ) ) {
-		    $secentry .= $ENV{"form.$gp"};
+		if ( exists( $env{"form.$gp"} ) ) {
+		    $secentry .= $env{"form.$gp"};
 		}
-		if ( grep/^$ENV{"form.$secnum"}:/,@currsections) {
+		if ( grep/^$env{"form.$secnum"}:/,@currsections) {
 		    push @sections, $secentry;
 		    $seccount ++;
 		} else {
-		    my $newsec = $coursecode.$ENV{"form.$secnum"};
+		    my $newsec = $coursecode.$env{"form.$secnum"};
 		    my $coursecheck = &Apache::lonnet::auto_validate_courseID($crs,$dom,$newsec);
 		    if ($coursecheck eq 'ok') {
 			my $addcheck = &Apache::lonnet::auto_new_course($crs,$dom,$newsec,$owner);
 			if ($addcheck eq 'ok') {
-			    push @sections,$ENV{"form.$secnum"}.":".$ENV{"form.$gp"};
+			    push @sections,$env{"form.$secnum"}.":".$env{"form.$gp"};
 			    $seccount ++;
 			    $addcount ++;
 			} else {
-			    push @badowner,$ENV{"form.$secnum"}.":".$ENV{"form.$gp"};
+			    push @badowner,$env{"form.$secnum"}.":".$env{"form.$gp"};
 			}
 		    } else {
-			push @badsections, $ENV{"form.$secnum"}.":".$ENV{"form.$gp"}.":".$coursecheck;
+			push @badsections, $env{"form.$secnum"}.":".$env{"form.$gp"}.":".$coursecheck;
 		    }
 		}
 	    }
@@ -1869,13 +1869,13 @@
 	for (my $i=0; $i<@currsections; $i++) {
 	    my $sec = "sec_".$i;
 	    my $gp = "secgp_".$i;
-	    if ( exists($ENV{"form.$sec"}) ) {
+	    if ( exists($env{"form.$sec"}) ) {
 		my $secentry = '';
 		if ($currsections[$i] =~ m/^(\w+:)/ ) {
 		    $secentry = $1;
 		}
-		if ( exists($ENV{"form.$gp"}) ) {
-		    $secentry .= $ENV{"form.$gp"};
+		if ( exists($env{"form.$gp"}) ) {
+		    $secentry .= $env{"form.$gp"};
 		}
 		push @sections,$secentry;
 		$seccount ++;
@@ -1938,8 +1938,8 @@
 	}
     }
     
-    if ( exists($ENV{'form.numsec'}) ) {
-	my $numsec = $ENV{'form.numsec'};
+    if ( exists($env{'form.numsec'}) ) {
+	my $numsec = $env{'form.numsec'};
 	if ($numsec > 0) {
 	    my @bgcolors=("#eeeeee","#cccccc");
 	    $response .= qq(
@@ -2005,27 +2005,27 @@
 	unless ($secstr eq '') { $allsections[0] = $secstr; }
     }
     
-    if ( exists($ENV{'form.numsec'}) ) {
-	$numsec = $ENV{'form.numsec'};
+    if ( exists($env{'form.numsec'}) ) {
+	$numsec = $env{'form.numsec'};
     }
     
     if ($numsec > 0) {
 	for (my $i=0; $i<$numsec; $i++) {
 	    my $sec = "newsec_".$i;
 	    my $gp = "newsecgp_".$i;
-	    if ( exists($ENV{"form.$sec"}) ) {
-		unless ( (grep/^$ENV{"form.$sec"}:/,@allsections) || (grep/^$ENV{"form.$sec"}:/,@sections) ) {
-		    my $newsec = $coursecode.$ENV{"form.$sec"};
+	    if ( exists($env{"form.$sec"}) ) {
+		unless ( (grep/^$env{"form.$sec"}:/,@allsections) || (grep/^$env{"form.$sec"}:/,@sections) ) {
+		    my $newsec = $coursecode.$env{"form.$sec"};
 		    my $coursecheck = &Apache::lonnet::auto_validate_courseID($crs,$dom,$newsec);
 		    if ($coursecheck eq 'ok') {
 			my $addcheck = &Apache::lonnet::auto_new_course($crs,$dom,$newsec,$owner);
 			if ($addcheck eq 'ok') {
-			    push @sections,$ENV{"form.$sec"}.":".$ENV{"form.$gp"};
+			    push @sections,$env{"form.$sec"}.":".$env{"form.$gp"};
 			} else {
-			    push @badowner,$ENV{"form.$sec"}.":".$ENV{"form.$gp"};
+			    push @badowner,$env{"form.$sec"}.":".$env{"form.$gp"};
 			}
 		    } else {
-			push @badsections, $ENV{"form.$sec"}.":".$ENV{"form.$gp"}.":".$coursecheck;
+			push @badsections, $env{"form.$sec"}.":".$env{"form.$gp"}.":".$coursecheck;
 		    }
 		}
 	    }
@@ -2091,8 +2091,8 @@
     my %settings = &Apache::lonnet::get('environment',['internal.showphotos'],$dom,$crs);
     my $currphotos = $settings{'internal.showphotos'};
     my $showphotos = '';
-    if ( exists($ENV{'form.showphotos'}) ) {
-	$showphotos=$ENV{'form.showphotos'};
+    if ( exists($env{'form.showphotos'}) ) {
+	$showphotos=$env{'form.showphotos'};
     }
     
     my $response = "";
@@ -2137,11 +2137,11 @@
     my $authtype = $settings{'internal.authtype'};
     my $autharg = $settings{'internal.autharg'};
     my ($startaccess,$endaccess) = &get_dates_from_form();
-    if ( exists($ENV{'form.updateadds'}) ) {
-        $updateadds = $ENV{'form.updateadds'};
+    if ( exists($env{'form.updateadds'}) ) {
+        $updateadds = $env{'form.updateadds'};
     }
-    if ( exists($ENV{'form.updatedrops'}) ) {
-        $updatedrops = $ENV{'form.updatedrops'};
+    if ( exists($env{'form.updatedrops'}) ) {
+        $updatedrops = $env{'form.updatedrops'};
     }
     if (($startaccess eq '') || ($endaccess eq '')) {
         $response = "There was a problem processing your requested roster update because start and and access dates could not be determined. No changes have been made to the class roster.<br />"; 
@@ -2199,7 +2199,7 @@
                 &Apache::lonnet::logthis("lonpopulate:update roster".
                                          "failed to retrieve classlist".
                                  " data for ".$crs."\@".$dom." by ".
-                                 $ENV{'user.name'}." \@ ".$ENV{'user.domain'}.
+                                 $env{'user.name'}." \@ ".$env{'user.domain'}.
                                  ": ".$outcome);
             }
 	    if ($reply{$crs} > 0) {
@@ -2251,32 +2251,32 @@
     my @typechglist = ();
     my @lockchglist = ();
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['chgauto','chgmanual','lockchg','unlockchg']);
-    if ($ENV{'form.chgauto'}) {
-        if (ref($ENV{'form.chgauto'}) eq 'ARRAY') {
-            push @typechglist, @{$ENV{'form.chgauto'}};
+    if ($env{'form.chgauto'}) {
+        if (ref($env{'form.chgauto'}) eq 'ARRAY') {
+            push @typechglist, @{$env{'form.chgauto'}};
         } else {
-            push @typechglist, $ENV{'form.chgauto'};
+            push @typechglist, $env{'form.chgauto'};
         }
     }
-    if ($ENV{'form.chgmanual'}) {
-        if (ref($ENV{'form.chgmanual'}) eq 'ARRAY') {
-            push @typechglist, @{$ENV{'form.chgmanual'}};
+    if ($env{'form.chgmanual'}) {
+        if (ref($env{'form.chgmanual'}) eq 'ARRAY') {
+            push @typechglist, @{$env{'form.chgmanual'}};
         } else {
-            push @typechglist, $ENV{'form.chgmanual'};
+            push @typechglist, $env{'form.chgmanual'};
         }
     }
-    if ($ENV{'form.lockchg'}) {
-        if (ref($ENV{'form.lockchg'}) eq 'ARRAY') {
-            push @lockchglist, @{$ENV{'form.lockchg'}};
+    if ($env{'form.lockchg'}) {
+        if (ref($env{'form.lockchg'}) eq 'ARRAY') {
+            push @lockchglist, @{$env{'form.lockchg'}};
         } else {
-            push @lockchglist, $ENV{'form.lockchg'};
+            push @lockchglist, $env{'form.lockchg'};
         }
     }
-    if ($ENV{'form.unlockchg'}) {
-        if (ref($ENV{'form.unlockchg'}) eq 'ARRAY') {
-            push @lockchglist, @{$ENV{'form.unlockchg'}};
+    if ($env{'form.unlockchg'}) {
+        if (ref($env{'form.unlockchg'}) eq 'ARRAY') {
+            push @lockchglist, @{$env{'form.unlockchg'}};
         } else {
-            push @lockchglist, $ENV{'form.unlockchg'};
+            push @lockchglist, $env{'form.unlockchg'};
         }
     }
     foreach my $student (sort @typechglist) {
@@ -2496,9 +2496,9 @@
     if (! defined($starttime)) {
         $starttime = time;
         if ($action eq 'setdates') {
-            if (exists($ENV{'course.'.$ENV{'request.course.id'}.
+            if (exists($env{'course.'.$env{'request.course.id'}.
                             '.default_enrollment_start_date'})) {
-                $starttime = $ENV{'course.'.$ENV{'request.course.id'}.
+                $starttime = $env{'course.'.$env{'request.course.id'}.
                                   '.default_enrollment_start_date'};
             }
         }
@@ -2506,9 +2506,9 @@
     if (! defined($endtime)) {
         $endtime = time+(6*30*24*60*60); # 6 months from now, approx
         if ($action eq 'setdates') {
-            if (exists($ENV{'course.'.$ENV{'request.course.id'}.
+            if (exists($env{'course.'.$env{'request.course.id'}.
                             '.default_enrollment_end_date'})) {
-                $endtime = $ENV{'course.'.$ENV{'request.course.id'}.
+                $endtime = $env{'course.'.$env{'request.course.id'}.
                                 '.default_enrollment_end_date'};
             }
         }
@@ -2527,7 +2527,7 @@
     my $enddate;
     $startdate = &Apache::lonhtmlcommon::get_date_from_form('startdate');
     $enddate   = &Apache::lonhtmlcommon::get_date_from_form('enddate');
-    if ( exists ($ENV{'form.no_end_date'}) ) {
+    if ( exists ($env{'form.no_end_date'}) ) {
         $enddate = 0;
     }
     return ($startdate,$enddate);
@@ -2566,9 +2566,9 @@
     }
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['action','state']);
     #  Needs to be in a course
-    if (! (($ENV{'request.course.fn'}) &&  (&Apache::lonnet::allowed('cst',$ENV{'request.course.id'})))) {
+    if (! (($env{'request.course.fn'}) &&  (&Apache::lonnet::allowed('cst',$env{'request.course.id'})))) {
         # Not in a course, or not allowed to modify parms
-        $ENV{'user.error.msg'}="/adm/populate:cst:0:0:Cannot drop or add students";
+        $env{'user.error.msg'}="/adm/populate:cst:0:0:Cannot drop or add students";
         return HTTP_NOT_ACCEPTABLE; 
     }
     # Start page
@@ -2607,25 +2607,25 @@
     );
 
     my $realm = '';
-    if ( exists($ENV{'request.course.id'}) ) {
-        $realm= $ENV{'course.'.$ENV{'request.course.id'}.'.description'};
+    if ( exists($env{'request.course.id'}) ) {
+        $realm= $env{'course.'.$env{'request.course.id'}.'.description'};
     }
     unless ($realm) { $realm='&nbsp;'; }
-    my $dom = $ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
-    my $crs = $ENV{'course.'.$ENV{'request.course.id'}.'.num'};
+    my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+    my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
     
     #
     # Main switch on form.action and form.state, as appropriate
     #
 
     my $action = "information";
-    if ( exists($ENV{'form.action'}) ) {
-        $action = $ENV{'form.action'};
+    if ( exists($env{'form.action'}) ) {
+        $action = $env{'form.action'};
     }
     my $state = "choose";
 
-    if ( exists($ENV{'form.state'}) ) {
-        $state = $ENV{'form.state'};
+    if ( exists($env{'form.state'}) ) {
+        $state = $env{'form.state'};
     }
 
     if ($action eq "information") {
@@ -2635,8 +2635,8 @@
             $r->print(&choose_header($action));
         } else {
             if ($action eq "crosslist") {
-                if ( exists($ENV{'form.numcross'}) ) {
-                    if ( $ENV{'form.numcross'} > 0 ) {
+                if ( exists($env{'form.numcross'}) ) {
+                    if ( $env{'form.numcross'} > 0 ) {
                         $r->print(&choose_header($action));
                     } else {
                         $r->print(&header());
@@ -2645,8 +2645,8 @@
                     $r->print(&header());
                 }
             } elsif ($action eq "sections") {
-                if ( exists($ENV{'form.numsec'}) ) {
-                    if ( $ENV{'form.numsec'} > 0 ) {
+                if ( exists($env{'form.numsec'}) ) {
+                    if ( $env{'form.numsec'} > 0 ) {
                         $r->print(&choose_header($action));
                     } else {
                         $r->print(&header());
Index: loncom/interface/lonpreferences.pm
diff -u loncom/interface/lonpreferences.pm:1.58 loncom/interface/lonpreferences.pm:1.59
--- loncom/interface/lonpreferences.pm:1.58	Tue Mar 22 12:15:22 2005
+++ loncom/interface/lonpreferences.pm	Thu Apr  7 02:56:23 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Preferences
 #
-# $Id: lonpreferences.pm,v 1.58 2005/03/22 17:15:22 matthew Exp $
+# $Id: lonpreferences.pm,v 1.59 2005/04/07 06:56:23 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -40,6 +40,7 @@
 use Apache::loncommon();
 use Apache::lonhtmlcommon();
 use Apache::lonlocal;
+use Apache::lonnet;
 
 #
 # Write lonnet::passwd to do the call below.
@@ -118,7 +119,7 @@
 
 sub verify_and_change_wysiwyg {
     my $r = shift;
-    my $newsetting=$ENV{'form.wysiwyg'};
+    my $newsetting=$env{'form.wysiwyg'};
     &Apache::lonnet::put('environment',{'wysiwygeditor' => $newsetting});
     &Apache::lonnet::appenv('environment.wysiwygeditor' => $newsetting);
     $r->print('<p>'.&mt('Setting WYSIWYG editor to:').' '.&mt($newsetting).'</p>');
@@ -129,8 +130,8 @@
 ################################################################
 sub languagechanger {
     my $r = shift;
-    my $user       = $ENV{'user.name'};
-    my $domain     = $ENV{'user.domain'};
+    my $user       = $env{'user.name'};
+    my $domain     = $env{'user.domain'};
     my %userenv = &Apache::lonnet::get
         ('environment',['languages']);
     my $language=$userenv{'languages'};
@@ -156,10 +157,10 @@
 
 sub verify_and_change_languages {
     my $r = shift;
-    my $user       = $ENV{'user.name'};
-    my $domain     = $ENV{'user.domain'};
+    my $user       = $env{'user.name'};
+    my $domain     = $env{'user.domain'};
 # Screenname
-    my $newlanguage  = $ENV{'form.language'};
+    my $newlanguage  = $env{'form.language'};
     $newlanguage=~s/[^\-\w]//g;
     my $message='';
     if ($newlanguage) {
@@ -181,8 +182,8 @@
 ################################################################
 sub texenginechanger {
     my $r = shift;
-    my $user       = $ENV{'user.name'};
-    my $domain     = $ENV{'user.domain'};
+    my $user       = $env{'user.name'};
+    my $domain     = $env{'user.domain'};
     my %userenv = &Apache::lonnet::get('environment',['texengine']);
     my $texengine=$userenv{'texengine'};
 
@@ -234,7 +235,7 @@
 $jsMath_example</p>
 <p> Convert to Images <br /> $mimetex_example</p>
 ENDLSCREEN
-    if ($ENV{'environment.texengine'} ne 'jsMath') {
+    if ($env{'environment.texengine'} ne 'jsMath') {
 	$r->print('<script type="text/javascript">jsMath.Process()</script>');
     }
 }
@@ -242,15 +243,15 @@
 
 sub verify_and_change_texengine {
     my $r = shift;
-    my $user       = $ENV{'user.name'};
-    my $domain     = $ENV{'user.domain'};
+    my $user       = $env{'user.name'};
+    my $domain     = $env{'user.domain'};
 # Screenname
-    my $newtexengine  = $ENV{'form.texengine'};
+    my $newtexengine  = $env{'form.texengine'};
     $newtexengine=~s/[^\-\w]//g;
     if ($newtexengine eq 'ttm') {
 	&Apache::lonnet::appenv('browser.mathml' => 1);
     } else {
-	if ($ENV{'environment.texengine'} eq 'ttm') {
+	if ($env{'environment.texengine'} eq 'ttm') {
 	    &Apache::lonnet::appenv('browser.mathml' => 0);
 	}
     }
@@ -276,8 +277,8 @@
 ################################################################
 sub rolesprefchanger {
     my $r = shift;
-    my $user       = $ENV{'user.name'};
-    my $domain     = $ENV{'user.domain'};
+    my $user       = $env{'user.name'};
+    my $domain     = $env{'user.domain'};
     my %userenv = &Apache::lonnet::get
         ('environment',['recentroles','recentrolesn']);
     my $hotlist_flag=$userenv{'recentroles'};
@@ -318,11 +319,11 @@
 
 sub verify_and_change_rolespref {
     my $r = shift;
-    my $user       = $ENV{'user.name'};
-    my $domain     = $ENV{'user.domain'};
+    my $user       = $env{'user.name'};
+    my $domain     = $env{'user.domain'};
 # Recent Roles Hotlist Flag
-    my $hotlist_flag  = $ENV{'form.recentroles'};
-    my $hotlist_n  = $ENV{'form.recentrolesn'};
+    my $hotlist_flag  = $env{'form.recentroles'};
+    my $hotlist_n  = $env{'form.recentrolesn'};
     my $message='';
     if ($hotlist_flag) {
         &Apache::lonnet::put('environment',{'recentroles' => $hotlist_flag});
@@ -353,8 +354,8 @@
 ################################################################
 sub screennamechanger {
     my $r = shift;
-    my $user       = $ENV{'user.name'};
-    my $domain     = $ENV{'user.domain'};
+    my $user       = $env{'user.name'};
+    my $domain     = $env{'user.domain'};
     my %userenv = &Apache::lonnet::get
         ('environment',['screenname','nickname']);
     my $screenname=$userenv{'screenname'};
@@ -373,10 +374,10 @@
 
 sub verify_and_change_screenname {
     my $r = shift;
-    my $user       = $ENV{'user.name'};
-    my $domain     = $ENV{'user.domain'};
+    my $user       = $env{'user.name'};
+    my $domain     = $env{'user.domain'};
 # Screenname
-    my $newscreen  = $ENV{'form.screenname'};
+    my $newscreen  = $env{'form.screenname'};
     $newscreen=~s/[^ \w]//g;
     my $message='';
     if ($newscreen) {
@@ -390,7 +391,7 @@
     }
 # Nickname
     $message.='<br />';
-    $newscreen  = $ENV{'form.nickname'};
+    $newscreen  = $env{'form.nickname'};
     $newscreen=~s/[^ \w]//g;
     if ($newscreen) {
         &Apache::lonnet::put('environment',{'nickname' => $newscreen});
@@ -413,8 +414,8 @@
 
 sub msgforwardchanger {
     my $r = shift;
-    my $user       = $ENV{'user.name'};
-    my $domain     = $ENV{'user.domain'};
+    my $user       = $env{'user.name'};
+    my $domain     = $env{'user.domain'};
     my %userenv = &Apache::lonnet::get('environment',['msgforward','notification','critnotification']);
     my $msgforward=$userenv{'msgforward'};
     my $notification=$userenv{'notification'};
@@ -443,11 +444,11 @@
 
 sub verify_and_change_msgforward {
     my $r = shift;
-    my $user       = $ENV{'user.name'};
-    my $domain     = $ENV{'user.domain'};
+    my $user       = $env{'user.name'};
+    my $domain     = $env{'user.domain'};
     my $newscreen  = '';
     my $message='';
-    foreach (split(/\,/,$ENV{'form.msgforward'})) {
+    foreach (split(/\,/,$env{'form.msgforward'})) {
 	my ($msuser,$msdomain)=split(/[\@\:]/,$_);
         $msuser=~s/\W//g;
         $msdomain=~s/\W//g;
@@ -469,7 +470,7 @@
         &Apache::lonnet::delenv('environment\.msgforward');
         $message.='Reset message forwarding<br />';
     }
-    my $notification=$ENV{'form.notification'};
+    my $notification=$env{'form.notification'};
     $notification=~s/\s//gs;
     if ($notification) {
         &Apache::lonnet::put('environment',{'notification' => $notification});
@@ -480,7 +481,7 @@
         &Apache::lonnet::delenv('environment\.notification');
         $message.='Reset message notification<br />';
     }
-    my $critnotification=$ENV{'form.critnotification'};
+    my $critnotification=$env{'form.critnotification'};
     $critnotification=~s/\s//gs;
     if ($critnotification) {
         &Apache::lonnet::put('environment',{'critnotification' => $critnotification});
@@ -504,13 +505,13 @@
     my $r = shift;
 # figure out colors
     my $function='student';
-    if ($ENV{'request.role'}=~/^(cc|in|ta|ep)/) {
+    if ($env{'request.role'}=~/^(cc|in|ta|ep)/) {
 	$function='coordinator';
     }
-    if ($ENV{'request.role'}=~/^(su|dc|ad|li)/) {
+    if ($env{'request.role'}=~/^(su|dc|ad|li)/) {
 	$function='admin';
     }
-    if (($ENV{'request.role'}=~/^(au|ca)/) ||
+    if (($env{'request.role'}=~/^(au|ca)/) ||
 	($ENV{'REQUEST_URI'}=~/^(\/priv|\~)/)) {
 	$function='author';
     }
@@ -580,13 +581,13 @@
     my $r = shift;
 # figure out colors
     my $function='student';
-    if ($ENV{'request.role'}=~/^(cc|in|ta|ep)/) {
+    if ($env{'request.role'}=~/^(cc|in|ta|ep)/) {
 	$function='coordinator';
     }
-    if ($ENV{'request.role'}=~/^(su|dc|ad|li)/) {
+    if ($env{'request.role'}=~/^(su|dc|ad|li)/) {
 	$function='admin';
     }
-    if (($ENV{'request.role'}=~/^(au|ca)/) ||
+    if (($env{'request.role'}=~/^(au|ca)/) ||
 	($ENV{'REQUEST_URI'}=~/^(\/priv|\~)/)) {
 	$function='author';
     }
@@ -601,9 +602,9 @@
 
     my $message='';
     foreach my $item (keys %colortypes) {
-        my $color=$ENV{'form.'.$item};
+        my $color=$env{'form.'.$item};
         my $entry='color.'.$function.'.'.$item;
-	if (($color=~/^\#[0-9A-Fa-f]{6}$/) && (!$ENV{'form.resetall'})) {
+	if (($color=~/^\#[0-9A-Fa-f]{6}$/) && (!$env{'form.resetall'})) {
 	    &Apache::lonnet::put('environment',{$entry => $color});
 	    &Apache::lonnet::appenv('environment.'.$entry => $color);
 	    $message.='Set '.$colortypes{$item}.' to '.$color.'<br />';
@@ -630,9 +631,9 @@
     my $r = shift;
     my $errormessage = shift;
     $errormessage = ($errormessage || '');
-    my $user       = $ENV{'user.name'};
-    my $domain     = $ENV{'user.domain'};
-    my $homeserver = $ENV{'user.home'};
+    my $user       = $env{'user.name'};
+    my $domain     = $env{'user.domain'};
+    my $homeserver = $env{'user.home'};
     my $currentauth=&Apache::lonnet::queryauthenticate($user,$domain);
     # Check for authentication types that allow changing of the password.
     return if ($currentauth !~ /^(unix|internal):/);
@@ -732,9 +733,9 @@
 
 sub verify_and_change_password {
     my $r = shift;
-    my $user       = $ENV{'user.name'};
-    my $domain     = $ENV{'user.domain'};
-    my $homeserver = $ENV{'user.home'};
+    my $user       = $env{'user.name'};
+    my $domain     = $env{'user.domain'};
+    my $homeserver = $env{'user.home'};
     my $currentauth=&Apache::lonnet::queryauthenticate($user,$domain);
     # Check for authentication types that allow changing of the password.
     return if ($currentauth !~ /^(unix|internal):/);
@@ -747,10 +748,10 @@
 </head>
 ENDHEADER
     #
-    my $currentpass = $ENV{'form.currentpass'}; 
-    my $newpass1    = $ENV{'form.newpass_1'}; 
-    my $newpass2    = $ENV{'form.newpass_2'};
-    my $logtoken    = $ENV{'form.logtoken'};
+    my $currentpass = $env{'form.currentpass'}; 
+    my $newpass1    = $env{'form.newpass_1'}; 
+    my $newpass2    = $env{'form.newpass_2'};
+    my $logtoken    = $env{'form.logtoken'};
     # Check for empty data 
     unless (defined($currentpass) && 
 	    defined($newpass1)    && 
@@ -835,8 +836,8 @@
 ################################################################
 sub discussionchanger {
     my $r = shift;
-    my $user       = $ENV{'user.name'};
-    my $domain     = $ENV{'user.domain'};
+    my $user       = $env{'user.name'};
+    my $domain     = $env{'user.domain'};
     my %userenv = &Apache::lonnet::get
         ('environment',['discdisplay','discmarkread']);
     my $discdisp = 'allposts';
@@ -858,7 +859,7 @@
 
     my $function = &Apache::loncommon::get_users_function();
     my $color = &Apache::loncommon::designparm($function.'.tabbg',
-                                                    $ENV{'user.domain'});
+                                                    $env{'user.domain'});
     my %lt = &Apache::lonlocal::texthash(
         'pref' => 'Display Preference',
         'curr' => 'Current setting ',
@@ -940,11 +941,11 @@
                                                                                                                 
 sub verify_and_change_discussion {
     my $r = shift;
-    my $user     = $ENV{'user.name'};
-    my $domain   = $ENV{'user.domain'};
+    my $user     = $env{'user.name'};
+    my $domain   = $env{'user.domain'};
     my $message='';
-    if (defined($ENV{'form.discdisp'}) ) {
-        my $newdisp  = $ENV{'form.newdisp'};
+    if (defined($env{'form.discdisp'}) ) {
+        my $newdisp  = $env{'form.newdisp'};
         if ($newdisp eq 'unread') {
             $message .='In discussions: only new posts will be displayed.<br/>';
             &Apache::lonnet::put('environment',{'discdisplay' => $newdisp});
@@ -955,8 +956,8 @@
             &Apache::lonnet::delenv('environment\.discdisplay');
         }
     }
-    if (defined($ENV{'form.discmark'}) ) {
-        my $newmark = $ENV{'form.newmark'};
+    if (defined($env{'form.discmark'}) ) {
+        my $newmark = $env{'form.newmark'};
         if ($newmark eq 'ondisp') {
            $message.='In discussions: new posts will be cease to be identified as "new" after display.<br/>';
             &Apache::lonnet::put('environment',{'discmarkread' => $newmark});
@@ -981,8 +982,8 @@
 ################################################################
 sub handler {
     my $r = shift;
-    my $user = $ENV{'user.name'};
-    my $domain = $ENV{'user.domain'};
+    my $user = $env{'user.name'};
+    my $domain = $env{'user.domain'};
     &Apache::loncommon::content_type($r,'text/html');
     # Some pages contain DES keys and should not be cached.
     &Apache::loncommon::no_cache($r);
@@ -1051,7 +1052,7 @@
                       printmenu => 'yes',
                       subroutine => \&verify_and_change_msgforward }));
     my $aboutmeaction=
-        '/adm/'.$ENV{'user.domain'}.'/'.$ENV{'user.name'}.'/aboutme';
+        '/adm/'.$env{'user.domain'}.'/'.$env{'user.name'}.'/aboutme';
     push (@Options,{ action => 'none', 
                      linktext =>
                          q{Edit the 'About Me' Personal Information Screen},
@@ -1154,7 +1155,7 @@
                       }));
 
 
-    if ($ENV{'user.name'} =~ /^(albertel|fox|foxr|koretemey|korte|hallmat3|turtle)$/) {
+    if ($env{'user.name'} =~ /^(albertel|fox|foxr|koretemey|korte|hallmat3|turtle)$/) {
         push (@Options,({ action => 'debugtoggle',
                           printmenu => 'yes',
                           subroutine => \&toggle_debug,
@@ -1171,7 +1172,7 @@
     my $help = undef;
     my $printmenu = 'yes';
     foreach my $option (@Options) {
-        if ($option->{'action'} eq $ENV{'form.action'}) {
+        if ($option->{'action'} eq $env{'form.action'}) {
             $call = $option->{'subroutine'};
             $printmenu = $option->{'printmenu'};
             if (exists($option->{'breadcrumb'})) {
@@ -1187,15 +1188,15 @@
     if (defined($call)) {
         $call->($r);
     }
-    if (($printmenu eq 'yes') && (!$ENV{'form.returnurl'})) {
+    if (($printmenu eq 'yes') && (!$env{'form.returnurl'})) {
         my $optionlist = '<table cellpadding="5">';
-        if ($ENV{'user.name'} =~ 
+        if ($env{'user.name'} =~ 
                          /^(albertel|kortemey|fox|foxr|korte|hallmat3|turtle)$/
             ) {
             push (@Options,({ action => 'debugtoggle',
                               linktext => 'Toggle Debug Messages',
                               text => 'Current Debug status is -'.
-                                  $ENV{'user.debug'}.'-.',
+                                  $env{'user.debug'}.'-.',
                               href => '/adm/preferences',
                               printmenu => 'yes',
                               subroutine => \&toggle_debug,
@@ -1227,8 +1228,8 @@
         }
         $optionlist .= '</table>';
         $r->print($optionlist);
-    } elsif ($ENV{'form.returnurl'}) {
-	$r->print('<br /><a href="'.$ENV{'form.returnurl'}.'"><font size="+1">'.
+    } elsif ($env{'form.returnurl'}) {
+	$r->print('<br /><a href="'.$env{'form.returnurl'}.'"><font size="+1">'.
 		  &mt('Return').'</font></a>');
     }
     $r->print(&Apache::loncommon::endbodytag().'</html>');
@@ -1236,7 +1237,7 @@
 }
 
 sub toggle_debug {
-    if ($ENV{'user.debug'}) {
+    if ($env{'user.debug'}) {
         &Apache::lonnet::delenv('user\.debug');
     } else {
         &Apache::lonnet::appenv('user.debug' => 1);
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.372 loncom/interface/lonprintout.pm:1.373
--- loncom/interface/lonprintout.pm:1.372	Tue Mar 29 05:21:21 2005
+++ loncom/interface/lonprintout.pm	Thu Apr  7 02:56:23 2005
@@ -1,7 +1,7 @@
 #  The LearningOnline Network
 # Printout
 #
-# $Id: lonprintout.pm,v 1.372 2005/03/29 10:21:21 foxr Exp $
+# $Id: lonprintout.pm,v 1.373 2005/04/07 06:56:23 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -534,8 +534,8 @@
 
 sub get_name {
     my ($uname,$udom)=@_;
-    if (!defined($uname)) { $uname=$ENV{'user.name'}; }
-    if (!defined($udom)) { $udom=$ENV{'user.domain'}; }
+    if (!defined($uname)) { $uname=$env{'user.name'}; }
+    if (!defined($udom)) { $udom=$env{'user.domain'}; }
     my $plainname=&Apache::loncommon::plainname($uname,$udom);
     if ($plainname=~/^\s*$/) { $plainname=$uname.'@'.$udom; }
     $plainname=&Apache::lonxml::latex_special_symbols($plainname,'header');
@@ -544,8 +544,8 @@
 
 sub get_course {
     my $courseidinfo;
-    if (defined($ENV{'request.course.id'})) {
-	$courseidinfo = &Apache::lonxml::latex_special_symbols(&Apache::lonnet::unescape($ENV{'course.'.$ENV{'request.course.id'}.'.description'}),'header');
+    if (defined($env{'request.course.id'})) {
+	$courseidinfo = &Apache::lonxml::latex_special_symbols(&Apache::lonnet::unescape($env{'course.'.$env{'request.course.id'}.'.description'}),'header');
     }
     return $courseidinfo;
 }
@@ -607,7 +607,7 @@
 
 sub details_for_menu {
     my ($helper)=@_;
-    my $postdata=$ENV{'form.postdata'};
+    my $postdata=$env{'form.postdata'};
     if (!$postdata) { $postdata=$helper->{VARS}{'postdata'}; }
     my $name_of_resource = &Apache::lonnet::gettitle($postdata);
     my $symbolic = &Apache::lonnet::symbread($postdata);
@@ -618,9 +618,9 @@
 	$map =~ m|([^/]+)$|;
 	$name_of_sequence = $1;
     }
-    my $name_of_map = &Apache::lonnet::gettitle($ENV{'request.course.uri'});
+    my $name_of_map = &Apache::lonnet::gettitle($env{'request.course.uri'});
     if ($name_of_map =~ /^\s*$/) {
-	$ENV{'request.course.uri'} =~ m|([^/]+)$|;
+	$env{'request.course.uri'} =~ m|([^/]+)$|;
 	$name_of_map = $1;
     }
     return ($name_of_resource,$name_of_sequence,$name_of_map);
@@ -695,7 +695,7 @@
 sub print_latex_header {
     my $mode=shift;
     my $output='\documentclass[letterpaper]{article}';
-    if (($mode eq 'batchmode') || (!$ENV{'request.role.adv'})) {
+    if (($mode eq 'batchmode') || (!$env{'request.role.adv'})) {
 	$output.='\batchmode';
     }
     $output.='\newcommand{\keephidden}[1]{}\renewcommand{\deg}{$^{\circ}$}'."\n".
@@ -846,8 +846,8 @@
     # The page breaks will be pulled into the hash %page_breaks which is
     # indexed by symb and contains 1's for each break.
 
-    $ENV{'form.pagebreaks'}  = $helper->{'VARS'}->{'FINISHPAGE'};
-    $ENV{'form.lastprinttype'} = $helper->{'VARS'}->{'PRINT_TYPE'}; 
+    $env{'form.pagebreaks'}  = $helper->{'VARS'}->{'FINISHPAGE'};
+    $env{'form.lastprinttype'} = $helper->{'VARS'}->{'PRINT_TYPE'}; 
     &Apache::loncommon::store_course_settings('print',
 					      {'pagebreaks'    => 'scalar',
 					       'lastprinttype' => 'scalar'});
@@ -865,7 +865,7 @@
 	$laystyle='book';
     }
     my ($textwidth,$textheight,$oddoffset,$evenoffset) = &page_format($papersize,$laystyle,$numberofcolumns);
-    my $assignment =  $ENV{'form.assignment'};
+    my $assignment =  $env{'form.assignment'};
     my $LaTeXwidth=&recalcto_mm($textwidth); 
     my @print_array=();
     my @student_names=();
@@ -912,8 +912,8 @@
 		$moreenv{'request.filename'}=$cleanURL;
 		if ($helper->{'VARS'}->{'style_file'}=~/\w/) {
 		    $moreenv{'construct.style'}=$helper->{'VARS'}->{'style_file'};
-		    my $dom = $ENV{'user.domain'};
-		    my $user = $ENV{'user.name'};
+		    my $dom = $env{'user.domain'};
+		    my $user = $env{'user.name'};
 		    my $put_result = &Apache::lonnet::put('environment',{'construct.style'=>$helper->{'VARS'}->{'style_file'}},$dom,$user);
 		}
                 if ($helper->{'VARS'}->{'probstatus'} eq 'exam') {$form{'problemtype'}='exam';}
@@ -995,7 +995,7 @@
 			$form{'answer_output_mode'}='tex';
 			$form{'rndseed'}=$rndseed;
 			$form{'problem_split'}=$parmhash{'problem_stream_switch'};
-                        if ($urlp=~/\/res\//) {$ENV{'request.state'}='published';}
+                        if ($urlp=~/\/res\//) {$env{'request.state'}='published';}
 			my $answer=&Apache::lonnet::ssi($urlp,%form);
 			if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') {
 			    $texversion=~s/(\\keephidden{ENDOFPROBLEM})/$answer$1/;
@@ -1088,11 +1088,11 @@
 		    $flag_page_in_sequence = 'YES';
 		} 
 		my $lonidsdir=$r->dir_config('lonIDsDir');
-		my $envfile=$ENV{'user.environment'};
+		my $envfile=$env{'user.environment'};
 		$envfile=~/\/([^\/]+)\.id$/;
 		$envfile=$1;
 		&Apache::lonnet::transfer_profile_to_env($lonidsdir,$envfile);
-		my $current_counter=$ENV{'form.counter'};
+		my $current_counter=$env{'form.counter'};
 		if(($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') ||
 		   ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) {
 		    $form{'grade_target'}='answer';
@@ -1200,7 +1200,7 @@
 	 my $student_counter=-1;
 	 foreach my $person (@students) {
 
-             my $duefile="/home/httpd/prtspool/$ENV{'user.name'}_$ENV{'user.domain'}_printout.due";
+             my $duefile="/home/httpd/prtspool/$env{'user.name'}_$env{'user.domain'}_printout.due";
 	     if (-e $duefile) {
 		 my $temp_file = Apache::File->new('>>'.$duefile);
 		 print $temp_file "1969\n";
@@ -1222,8 +1222,8 @@
 	 $result .= $print_array[0].'  \end{document}';
      } elsif (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_for_anon')     ||
 	      ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'resources_for_anon')  ) { 
-	 my $cdom =$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
-	 my $cnum =$ENV{'course.'.$ENV{'request.course.id'}.'.num'};
+	 my $cdom =$env{'course.'.$env{'request.course.id'}.'.domain'};
+	 my $cnum =$env{'course.'.$env{'request.course.id'}.'.num'};
 	 my $num_todo=$helper->{'VARS'}->{'NUMBER_TO_PRINT_TOTAL'};
 	 my $code_name=$helper->{'VARS'}->{'ANON_CODE_STORAGE_NAME'};
 	 my $old_name=$helper->{'VARS'}->{'REUSE_OLD_CODES'};
@@ -1357,7 +1357,7 @@
 #-- writing .tex file in prtspool 
     my $temp_file;
     my $identifier = &Apache::loncommon::get_cgi_id();
-    my $filename = "/home/httpd/prtspool/$ENV{'user.name'}_$ENV{'user.domain'}_printout_".$identifier.".tex";
+    my $filename = "/home/httpd/prtspool/$env{'user.name'}_$env{'user.domain'}_printout_".$identifier.".tex";
     if (!($#print_array>0)) { 
 	unless ($temp_file = Apache::File->new('>'.$filename)) {
 	    $r->log_error("Couldn't open $filename for output $!");
@@ -1397,9 +1397,9 @@
 	if ($#student_names>-1) {
 	    $student_names=$student_names[0].'_ENDPERSON_';
 	} else {
-	    my $fullname = &get_name($ENV{'user.name'},$ENV{'user.domain'});
-	    $student_names=join(':',$ENV{'user.name'},$ENV{'user.domain'},
-				$ENV{'request.course.sec'},$fullname).
+	    my $fullname = &get_name($env{'user.name'},$env{'user.domain'});
+	    $student_names=join(':',$env{'user.name'},$env{'user.domain'},
+				$env{'request.course.sec'},$fullname).
 				    '_ENDPERSON_'.'_END_';
 	}
     }
@@ -1424,7 +1424,7 @@
                             'cgi.'.$identifier.'.selection' => $selectionmade,
 			    'cgi.'.$identifier.'tableofcontents' => $helper->{'VARS'}->{'TABLE_CONTENTS'},
 			    'cgi.'.$identifier.'tableofindex' => $helper->{'VARS'}->{'TABLE_INDEX'},
-			    'cgi.'.$identifier.'role' => $ENV{'request.role.adv'},
+			    'cgi.'.$identifier.'role' => $env{'request.role.adv'},
                             'cgi.'.$identifier.'numberoffiles' => $#print_array,
                             'cgi.'.$identifier.'studentnames' => $student_names,
                             'cgi.'.$identifier.'backref' => $URLback,);
@@ -1491,18 +1491,18 @@
 	    my ($map,$id,$res_url) = &Apache::lonnet::decode_symb($curresline);
 	    if (&Apache::lonnet::allowed('bre',$res_url)) {
 		if ($res_url=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)$/) {
-		    my $rendered = &Apache::loncommon::get_student_view($curresline,$username,$userdomain,$ENV{'request.course.id'},'tex',$moreenv);
+		    my $rendered = &Apache::loncommon::get_student_view($curresline,$username,$userdomain,$env{'request.course.id'},'tex',$moreenv);
 		    my $lonidsdir=$r->dir_config('lonIDsDir');
-		    my $envfile=$ENV{'user.environment'};
+		    my $envfile=$env{'user.environment'};
 		    $envfile=~/\/([^\/]+)\.id$/;
 		    $envfile=$1;
 		    &Apache::lonnet::transfer_profile_to_env($lonidsdir,$envfile);
-		    my $current_counter=$ENV{'form.counter'};
+		    my $current_counter=$env{'form.counter'};
 		    if(($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') ||
 		       ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) {
 			$moreenv->{'answer_output_mode'}='tex';
 			$moreenv->{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
-			my $ansrendered = &Apache::loncommon::get_student_answers($curresline,$username,$userdomain,$ENV{'request.course.id'},%{$moreenv});
+			my $ansrendered = &Apache::loncommon::get_student_answers($curresline,$username,$userdomain,$env{'request.course.id'},%{$moreenv});
 			&Apache::lonnet::appenv(('form.counter' => $current_counter));
 			if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') {
 			    $rendered=~s/(\\keephidden{ENDOFPROBLEM})/$ansrendered$1/;
@@ -1520,13 +1520,13 @@
 		    }
 		    $current_output .= $rendered;		    
 		} elsif ($res_url=~/\/(smppg|syllabus|aboutme|bulletinboard)$/) {
-		    my $rendered = &Apache::loncommon::get_student_view($curresline,$username,$userdomain,$ENV{'request.course.id'},'tex',$moreenv);
+		    my $rendered = &Apache::loncommon::get_student_view($curresline,$username,$userdomain,$env{'request.course.id'},'tex',$moreenv);
 		    my $lonidsdir=$r->dir_config('lonIDsDir');
-		    my $envfile=$ENV{'user.environment'};
+		    my $envfile=$env{'user.environment'};
 		    $envfile=~/\/([^\/]+)\.id$/;
 		    $envfile=$1;
 		    &Apache::lonnet::transfer_profile_to_env($lonidsdir,$envfile);
-		    my $current_counter=$ENV{'form.counter'};
+		    my $current_counter=$env{'form.counter'};
 		    if ($remove_latex_header eq 'YES') {
 			$rendered = &latex_header_footer_remove($rendered);
 		    } else {
@@ -1571,7 +1571,7 @@
 #    if ($loaderror) { return $loaderror; }
 #    $loaderror=
 #       &Apache::lonnet::overloaderror($r,
-#         $ENV{'course.'.$ENV{'request.course.id'}.'.home'});
+#         $env{'course.'.$env{'request.course.id'}.'.home'});
 #    if ($loaderror) { return $loaderror; }
 
     my $result = printHelper($r);
@@ -1584,12 +1584,12 @@
 #	foreach $key (keys %{$helper->{'VARS'}}) {
 #	    $r->print(' '.$key.'->'.$helper->{'VARS'}->{$key}.'<-<br />');
 #	}
-#	foreach $key (keys %ENV) {
-#	    $r->print(' '.$key.'->'.$ENV{$key}.'<-<br />');
+#	foreach $key (keys %env) {
+#	    $r->print(' '.$key.'->'.$env{$key}.'<-<br />');
 #	}
 #	return OK;
 
-    my %parmhash=&Apache::lonnet::coursedescription($ENV{'request.course.id'});
+    my %parmhash=&Apache::lonnet::coursedescription($env{'request.course.id'});
  
 #	my $key; 
 #	foreach $key (keys %parmhash) {
@@ -1602,7 +1602,7 @@
     # we delete it since it can only be bad (if it were good, printout.pl
     # would have deleted it the last time around.
 
-    my $conversion_queuefile = "/home/httpd/prtspool/$ENV{'user.name'}_$ENV{'user.domain'}_printout.dat";
+    my $conversion_queuefile = "/home/httpd/prtspool/$env{'user.name'}_$env{'user.domain'}_printout.dat";
     if(-e $conversion_queuefile) {
 	unlink $conversion_queuefile;
     }
@@ -1625,7 +1625,7 @@
     my $r = shift;
 
     if ($r->header_only) {
-        if ($ENV{'browser.mathml'}) {
+        if ($env{'browser.mathml'}) {
             &Apache::loncommon::content_type($r,'text/xml');
         } else {
             &Apache::loncommon::content_type($r,'text/html');
@@ -1635,7 +1635,7 @@
     }
 
     # Send header, nocache
-    if ($ENV{'browser.mathml'}) {
+    if ($env{'browser.mathml'}) {
         &Apache::loncommon::content_type($r,'text/xml');
     } else {
         &Apache::loncommon::content_type($r,'text/html');
@@ -1665,8 +1665,8 @@
 
     #  The page breaks can get loaded initially from the course environment:
 
-    if((!defined($ENV{"form.CURRENT_STATE"}))  ||
-       ($ENV{'form.CURRENT_STATE'} == "START")) {
+    if((!defined($env{"form.CURRENT_STATE"}))  ||
+       ($env{'form.CURRENT_STATE'} == "START")) {
 	$helper->{VARS}->{FINISHPAGE} = ""; # In case they did a back e.g.
     }
 
@@ -1677,33 +1677,33 @@
 					         'lastprinttype' => 'scalar'});
 
     
-    if("$helper->{VARS}->{PRINT_TYPE}" eq "$ENV{'form.lastprinttype'}") {
-	$helper->{VARS}->{FINISHPAGE} = $ENV{'form.pagebreaks'};
+    if("$helper->{VARS}->{PRINT_TYPE}" eq "$env{'form.lastprinttype'}") {
+	$helper->{VARS}->{FINISHPAGE} = $env{'form.pagebreaks'};
     }
     
     
     # This will persistently load in the data we want from the
     # very first screen.
     # Detect whether we're coming from construction space
-    if ($ENV{'form.postdata'}=~/^(?:http:\/\/[^\/]+\/|\/|)\~([^\/]+)\/(.*)$/) {
+    if ($env{'form.postdata'}=~/^(?:http:\/\/[^\/]+\/|\/|)\~([^\/]+)\/(.*)$/) {
         $helper->{VARS}->{'filename'} = "~$1/$2";
         $helper->{VARS}->{'construction'} = 1;
     } else {
-        if ($ENV{'form.postdata'}) {
-            $helper->{VARS}->{'symb'} = &Apache::lonnet::symbread($ENV{'form.postdata'});
+        if ($env{'form.postdata'}) {
+            $helper->{VARS}->{'symb'} = &Apache::lonnet::symbread($env{'form.postdata'});
         }
-        if ($ENV{'form.symb'}) {
-            $helper->{VARS}->{'symb'} = $ENV{'form.symb'};
+        if ($env{'form.symb'}) {
+            $helper->{VARS}->{'symb'} = $env{'form.symb'};
         }
-        if ($ENV{'form.url'}) {
+        if ($env{'form.url'}) {
             $helper->{VARS}->{'symb'} = &Apache::lonnet::symbread($helper->{VARS}->{'postdata'});
         }
     }
 
-    if ($ENV{'form.symb'}) {
-        $helper->{VARS}->{'symb'} = $ENV{'form.symb'};
+    if ($env{'form.symb'}) {
+        $helper->{VARS}->{'symb'} = $env{'form.symb'};
     }
-    if ($ENV{'form.url'}) {
+    if ($env{'form.url'}) {
         $helper->{VARS}->{'symb'} = &Apache::lonnet::symbread($helper->{VARS}->{'postdata'});
 
     }
@@ -1735,17 +1735,17 @@
         }
         $subdir = &Apache::lonnet::filelocation("", $url);
     }
-    if (!$helper->{VARS}->{'curseed'} && $ENV{'form.curseed'}) {
-	$helper->{VARS}->{'curseed'}=$ENV{'form.curseed'};
+    if (!$helper->{VARS}->{'curseed'} && $env{'form.curseed'}) {
+	$helper->{VARS}->{'curseed'}=$env{'form.curseed'};
     }
-    if (!$helper->{VARS}->{'probstatus'} && $ENV{'form.problemtype'}) {
-	$helper->{VARS}->{'probstatus'}=$ENV{'form.problemtype'};
+    if (!$helper->{VARS}->{'probstatus'} && $env{'form.problemtype'}) {
+	$helper->{VARS}->{'probstatus'}=$env{'form.problemtype'};
     }
 
     my $userCanSeeHidden = Apache::lonnavmaps::advancedUser();
-    my $userPriviledged = ($ENV{'request.role'}=~m/^cc\./ or
-			   $ENV{'request.role'}=~m/^in\./ or
-			   $ENV{'request.role'}=~m/^ta\./);
+    my $userPriviledged = ($env{'request.role'}=~m/^cc\./ or
+			   $env{'request.role'}=~m/^in\./ or
+			   $env{'request.role'}=~m/^ta\./);
 
     Apache::lonhelper::registerHelperTags();
 
@@ -1897,8 +1897,8 @@
   </state>
 CHOOSE_STUDENTS
 
-	my $cdom = $ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
-	my $cnum = $ENV{'course.'.$ENV{'request.course.id'}.'.num'};
+	my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+	my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
         my @names=&Apache::lonnet::getkeys('CODEs',$cdom,$cnum);
 	my $namechoice='<choice></choice>';
 	foreach my $name (sort {uc($a) cmp uc($b)} @names) {
@@ -2003,7 +2003,7 @@
     }
 
     # FIXME: That RE should come from a library somewhere.
-    if ((((&Apache::lonnet::allowed('bre',$subdir) eq 'F') and ($helper->{VARS}->{'postdata'}=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)/)) or defined $helper->{'VARS'}->{'construction'}) and $ENV{'request.role.adv'} and $subdir ne $Apache::lonnet::perlvar{'lonDocRoot'}.'/res/') {    
+    if ((((&Apache::lonnet::allowed('bre',$subdir) eq 'F') and ($helper->{VARS}->{'postdata'}=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)/)) or defined $helper->{'VARS'}->{'construction'}) and $env{'request.role.adv'} and $subdir ne $Apache::lonnet::perlvar{'lonDocRoot'}.'/res/') {    
         push @{$printChoices}, ["<b>".&mt('Problems')."</b> ".&mt('from current subdirectory')." <b><i>$subdir</i></b>", 'problems_from_directory', 'CHOOSE_FROM_SUBDIR'];
 
         my $f = '$filename';
@@ -2073,7 +2073,7 @@
     my $startedTable = 0; # have we started an HTML table yet? (need
                           # to close it later)
 
-    if (($ENV{'request.role.adv'} and &Apache::lonnet::allowed('vgr',$ENV{'request.course.id'})) or 
+    if (($env{'request.role.adv'} and &Apache::lonnet::allowed('vgr',$env{'request.course.id'})) or 
 	($helper->{VARS}->{'construction'} eq '1')) {
 	addMessage("<hr width='33%' /><table><tr><td align='right'>Print: </td><td>");
         $paramHash = Apache::lonhelper::getParamHash();
@@ -2089,7 +2089,7 @@
 	$startedTable = 1;
     }
 
-    if ($ENV{'request.role.adv'}) {
+    if ($env{'request.role.adv'}) {
 	if (!$startedTable) {
 	    addMessage("<hr width='33%' /><table><tr><td align='right'>LaTeX mode: </td><td>");
 	    $startedTable = 1;
@@ -2156,7 +2156,7 @@
 	}
 
 	if ($helper->{'VARS'}->{'construction'}) { 
-	    my $stylevalue=$ENV{'construct.style'};
+	    my $stylevalue=$env{'construct.style'};
 	    my $xmlfrag .= <<"RNDSEED";
 	    <message><tr><td align='right'>Use random seed:  </td><td></message>
 	    <string variable="curseed" size="15" maxlength="15">
@@ -2172,7 +2172,7 @@
              </choices>
 RNDSEED
             &Apache::lonxml::xmlparse($r, 'helper', $xmlfrag);
-	    $helper->{'VARS'}->{'style_file'}=$ENV{'form.style_file_value'};
+	    $helper->{'VARS'}->{'style_file'}=$env{'form.style_file_value'};
 	    
 	} 
 
@@ -2242,6 +2242,7 @@
 @ISA = ("Apache::lonhelper::element");
 use strict;
 use Apache::lonlocal;
+use Apache::lonnet;
 
 my $maxColumns = 2;
 my @paperSize = ("letter [8 1/2x11 in]", "legal [8 1/2x14 in]", 
@@ -2302,7 +2303,7 @@
     $result .= "</select></td><td>\n";
     $result .= "<select name='${var}.paper'>\n";
 
-    my %parmhash=&Apache::lonnet::coursedescription($ENV{'request.course.id'});
+    my %parmhash=&Apache::lonnet::coursedescription($env{'request.course.id'});
     my $DefaultPaperSize=$parmhash{'default_paper_size'};
     if ($DefaultPaperSize eq '') {$DefaultPaperSize='letter';}
     $i = 0;
@@ -2326,8 +2327,8 @@
     my $var = $self->{'variable'};
     my $helper = Apache::lonhelper->getHelper();
     $helper->{VARS}->{$var} = 
-        $ENV{"form.$var.layout"} . '|' . $ENV{"form.$var.cols"} . '|' .
-        $ENV{"form.$var.paper"};
+        $env{"form.$var.layout"} . '|' . $env{"form.$var.cols"} . '|' .
+        $env{"form.$var.paper"};
     return 1;
 }
 
@@ -2357,7 +2358,7 @@
 =cut
 
 use Apache::lonhelper;
-
+use Apache::lonnet;
 no strict;
 @ISA = ("Apache::lonhelper::element");
 use strict;
@@ -2455,12 +2456,12 @@
 
     my $var = $self->{'variable'};
     my $helper = Apache::lonhelper->getHelper();
-    my $width = $helper->{VARS}->{$var .'.width'} = $ENV{"form.${var}.width"}; 
-    my $height = $helper->{VARS}->{$var .'.height'} = $ENV{"form.${var}.height"}; 
-    my $lmargin = $helper->{VARS}->{$var .'.lmargin'} = $ENV{"form.${var}.lmargin"}; 
-    $helper->{VARS}->{$var .'.widthunit'} = $ENV{"form.${var}.widthunit"}; 
-    $helper->{VARS}->{$var .'.heightunit'} = $ENV{"form.${var}.heightunit"}; 
-    $helper->{VARS}->{$var .'.lmarginunit'} = $ENV{"form.${var}.lmarginunit"}; 
+    my $width = $helper->{VARS}->{$var .'.width'} = $env{"form.${var}.width"}; 
+    my $height = $helper->{VARS}->{$var .'.height'} = $env{"form.${var}.height"}; 
+    my $lmargin = $helper->{VARS}->{$var .'.lmargin'} = $env{"form.${var}.lmargin"}; 
+    $helper->{VARS}->{$var .'.widthunit'} = $env{"form.${var}.widthunit"}; 
+    $helper->{VARS}->{$var .'.heightunit'} = $env{"form.${var}.heightunit"}; 
+    $helper->{VARS}->{$var .'.lmarginunit'} = $env{"form.${var}.lmarginunit"}; 
 
     my $error = '';
 
Index: loncom/interface/lonquickgrades.pm
diff -u loncom/interface/lonquickgrades.pm:1.35 loncom/interface/lonquickgrades.pm:1.36
--- loncom/interface/lonquickgrades.pm:1.35	Mon Jan  3 09:46:41 2005
+++ loncom/interface/lonquickgrades.pm	Thu Apr  7 02:56:23 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Quick Student Grades Display
 #
-# $Id: lonquickgrades.pm,v 1.35 2005/01/03 14:46:41 albertel Exp $
+# $Id: lonquickgrades.pm,v 1.36 2005/04/07 06:56:23 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -34,6 +34,7 @@
 use POSIX;
 use Apache::loncommon;
 use Apache::lonlocal;
+use Apache::lonnet;
 
 sub handler {
     my $r = shift;
@@ -47,7 +48,7 @@
 
     # Handle header-only request
     if ($r->header_only) {
-        if ($ENV{'browser.mathml'}) {
+        if ($env{'browser.mathml'}) {
             &Apache::loncommon::content_type($r,'text/xml');
         } else {
             &Apache::loncommon::content_type($r,'text/html');
@@ -57,7 +58,7 @@
     }
 
     # Send header, don't cache this page
-    if ($ENV{'browser.mathml'}) {
+    if ($env{'browser.mathml'}) {
         &Apache::loncommon::content_type($r, 'text/xml');
     } else {
         &Apache::loncommon::content_type($r, 'text/html');
@@ -66,16 +67,16 @@
     $r->send_http_header;
 
     my $showPoints = 
-        $ENV{'course.'.$ENV{'request.course.id'}.'.grading'} eq 'standard';
+        $env{'course.'.$env{'request.course.id'}.'.grading'} eq 'standard';
     my $notshowSPRSlink = 
-        $ENV{'course.'.$ENV{'request.course.id'}.'.grading'} eq 'external';
+        $env{'course.'.$env{'request.course.id'}.'.grading'} eq 'external';
 
     # Create the nav map
     my $navmap = Apache::lonnavmaps::navmap->new();
 
     if (!defined($navmap)) {
         my $requrl = $r->uri;
-        $ENV{'user.error.msg'} = "$requrl:bre:0:0:Navamp initialization failed.";
+        $env{'user.error.msg'} = "$requrl:bre:0:0:Navamp initialization failed.";
         return HTTP_NOT_ACCEPTABLE;
     }
 
Index: loncom/interface/lonremote.pm
diff -u loncom/interface/lonremote.pm:1.17 loncom/interface/lonremote.pm:1.18
--- loncom/interface/lonremote.pm:1.17	Thu Feb 17 03:29:43 2005
+++ loncom/interface/lonremote.pm	Thu Apr  7 02:56:23 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # User Authentication Module
 #
-# $Id: lonremote.pm,v 1.17 2005/02/17 08:29:43 albertel Exp $
+# $Id: lonremote.pm,v 1.18 2005/04/07 06:56:23 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -32,7 +32,7 @@
 use strict;
 use Apache::Constants qw(:common);
 use Apache::loncommon();
-use Apache::lonnet();
+use Apache::lonnet;
 use Apache::lonmenu();
 use Apache::lonlocal;
 
@@ -41,7 +41,7 @@
     &Apache::lonnet::put('environment',{'remote' => 'on'});
     &Apache::lonnet::appenv('environment.remote' => 'on');
 # -------------------------------------------------------- Menu script and info
-    my $windowinfo=&Apache::lonmenu::open($ENV{'browser.os'});
+    my $windowinfo=&Apache::lonmenu::open($env{'browser.os'});
     my $html=&Apache::lonxml::xmlbegin();
     my $startupremote=&Apache::lonmenu::startupremote($lowerurl);
     my $remoteinfo=&Apache::lonmenu::load_remote_msg($lowerurl);
@@ -96,22 +96,22 @@
     my $r = shift;
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
                                             ['action','url']);
-    unless ($ENV{'form.action'}) {
-	if ($ENV{'environment.remote'} ne 'off') {
-	    $ENV{'form.action'}='collapse';
+    unless ($env{'form.action'}) {
+	if ($env{'environment.remote'} ne 'off') {
+	    $env{'form.action'}='collapse';
         } else {
-	    $ENV{'form.action'}='launch';
+	    $env{'form.action'}='launch';
         }
     }
 
-    my $lowerurl=$ENV{'form.url'};
+    my $lowerurl=$env{'form.url'};
     unless ($lowerurl) { $lowerurl='/adm/menu'; }
 
     &Apache::loncommon::content_type($r,'text/html');
     $r->send_http_header;
     return OK if $r->header_only;
 
-    if ($ENV{'form.action'} eq 'launch') {
+    if ($env{'form.action'} eq 'launch') {
 	&launchremote($r,$lowerurl);
     } else {
         &collapseremote($r,$lowerurl);
Index: loncom/interface/lonsearchcat.pm
diff -u loncom/interface/lonsearchcat.pm:1.242 loncom/interface/lonsearchcat.pm:1.243
--- loncom/interface/lonsearchcat.pm:1.242	Fri Apr  1 14:57:23 2005
+++ loncom/interface/lonsearchcat.pm	Thu Apr  7 02:56:23 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Search Catalog
 #
-# $Id: lonsearchcat.pm,v 1.242 2005/04/01 19:57:23 albertel Exp $
+# $Id: lonsearchcat.pm,v 1.243 2005/04/07 06:56:23 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -63,7 +63,7 @@
 
 use strict;
 use Apache::Constants qw(:common :http);
-use Apache::lonnet();
+use Apache::lonnet;
 use Apache::File();
 use CGI qw(:standard);
 use Text::Query;
@@ -144,54 +144,54 @@
     ##     printing the results.  We only need (theoretically) to do
     ##     this once, so the pause indicator is deleted
     ##
-    if (exists($ENV{'form.pause'})) {
+    if (exists($env{'form.pause'})) {
         sleep(1);
-        delete($ENV{'form.pause'});
+        delete($env{'form.pause'});
     }
     ##
     ## Initialize global variables
     ##
     my $domain  = $r->dir_config('lonDefDomain');
     $diropendb= "/home/httpd/perl/tmp/".
-        "$ENV{'user.domain'}_$ENV{'user.name'}_searchcat.db";
+        "$env{'user.domain'}_$env{'user.name'}_searchcat.db";
     #
     # set the name of the persistent database
-    #          $ENV{'form.persistent_db_id'} can only have digits in it.
-    if (! exists($ENV{'form.persistent_db_id'}) ||
-        ($ENV{'form.persistent_db_id'} =~ /\D/) ||
-        ($ENV{'form.launch'} eq '1')) {
-        $ENV{'form.persistent_db_id'} = time;
+    #          $env{'form.persistent_db_id'} can only have digits in it.
+    if (! exists($env{'form.persistent_db_id'}) ||
+        ($env{'form.persistent_db_id'} =~ /\D/) ||
+        ($env{'form.launch'} eq '1')) {
+        $env{'form.persistent_db_id'} = time;
     }
     $bodytag=&Apache::loncommon::bodytag(undef,undef,undef,1);
     my $persistent_db_file = "/home/httpd/perl/tmp/".
         &Apache::lonnet::escape($domain).
-            '_'.&Apache::lonnet::escape($ENV{'user.name'}).
-                '_'.$ENV{'form.persistent_db_id'}.'_persistent_search.db';
+            '_'.&Apache::lonnet::escape($env{'user.name'}).
+                '_'.$env{'form.persistent_db_id'}.'_persistent_search.db';
     ##
     &Apache::lonhtmlcommon::clear_breadcrumbs();
-    if (exists($ENV{'request.course.id'}) && $ENV{'request.course.id'} ne '') {
+    if (exists($env{'request.course.id'}) && $env{'request.course.id'} ne '') {
         &Apache::lonhtmlcommon::add_breadcrumb
              ({href=>'/adm/searchcat?'.
-                   'catalogmode='.$ENV{'form.catalogmode'}.
-                   '&launch='.$ENV{'form.launch'}.
-                   '&mode='.$ENV{'form.mode'},
+                   'catalogmode='.$env{'form.catalogmode'}.
+                   '&launch='.$env{'form.launch'}.
+                   '&mode='.$env{'form.mode'},
               text=>"Course and Catalog Search",
               target=>'_top',
               bug=>'Searching',});
     } else {
         &Apache::lonhtmlcommon::add_breadcrumb
              ({href=>'/adm/searchcat?'.
-                   'catalogmode='.$ENV{'form.catalogmode'}.
-                   '&launch='.$ENV{'form.launch'}.
-                   '&mode='.$ENV{'form.mode'},
+                   'catalogmode='.$env{'form.catalogmode'}.
+                   '&launch='.$env{'form.launch'}.
+                   '&mode='.$env{'form.mode'},
               text=>"Catalog Search",
               target=>'_top',
               bug=>'Searching',});
     }
     #
-    if ($ENV{'form.phase'} !~ m/(basic|adv|course)_search/) {
+    if ($env{'form.phase'} !~ m/(basic|adv|course)_search/) {
         if (! &get_persistent_form_data($persistent_db_file)) {
-            if ($ENV{'form.phase'} =~ /(run_search|results)/) {
+            if ($env{'form.phase'} =~ /(run_search|results)/) {
                 &Apache::lonnet::logthis('lonsearchcat:'.
                                          'Unable to recover data from '.
                                          $persistent_db_file);
@@ -216,13 +216,13 @@
     ## Clear out old values from groupsearch database
     ##
     untie %groupsearch_db if (tied(%groupsearch_db));
-    if (($ENV{'form.cleargroupsort'} eq '1') || 
-        (($ENV{'form.launch'} eq '1') && 
-         ($ENV{'form.catalogmode'} eq 'groupsearch'))) {
+    if (($env{'form.cleargroupsort'} eq '1') || 
+        (($env{'form.launch'} eq '1') && 
+         ($env{'form.catalogmode'} eq 'groupsearch'))) {
 	if (tie(%groupsearch_db,'GDBM_File',$diropendb,&GDBM_WRCREAT(),0640)) {
 	    &start_fresh_session();
 	    untie %groupsearch_db;
-            delete($ENV{'form.cleargroupsort'});
+            delete($env{'form.cleargroupsort'});
 	} else {
             # This is a stupid error to give to the user.  
             # It really tells them nothing.
@@ -236,36 +236,36 @@
     ## Configure hidden fields
     ##
     $hidden_fields = '<input type="hidden" name="persistent_db_id" value="'.
-        $ENV{'form.persistent_db_id'}.'" />'."\n";
-    if (exists($ENV{'form.catalogmode'})) {
+        $env{'form.persistent_db_id'}.'" />'."\n";
+    if (exists($env{'form.catalogmode'})) {
         $hidden_fields .= &hidden_field('catalogmode');
     }
-    if (exists($ENV{'form.form'})) {
+    if (exists($env{'form.form'})) {
         $hidden_fields .= &hidden_field('form');
     }
-    if (exists($ENV{'form.element'})) {
+    if (exists($env{'form.element'})) {
         $hidden_fields .= &hidden_field('element');
     }
-    if (exists($ENV{'form.titleelement'})) {
+    if (exists($env{'form.titleelement'})) {
         $hidden_fields .= &hidden_field('titleelement');
     }
-    if (exists($ENV{'form.mode'})) {
+    if (exists($env{'form.mode'})) {
         $hidden_fields .= &hidden_field('mode');
     }
     ##
     ## Configure dynamic components of interface
     ##
-    if ($ENV{'form.catalogmode'} eq 'interactive') {
+    if ($env{'form.catalogmode'} eq 'interactive') {
         $closebutton="<input type='button' name='close' value='CLOSE' ";
-        if ($ENV{'form.phase'} =~ /(results|run_search)/) {
+        if ($env{'form.phase'} =~ /(results|run_search)/) {
 	    $closebutton .="onClick='parent.close()'";
         } else {
             $closebutton .="onClick='self.close()'";
         }
         $closebutton .=">\n";
-    } elsif ($ENV{'form.catalogmode'} eq 'groupsearch') {
+    } elsif ($env{'form.catalogmode'} eq 'groupsearch') {
         $closebutton="<input type='button' name='close' value='CLOSE' ";
-        if ($ENV{'form.phase'} =~ /(results|run_search)/) {
+        if ($env{'form.phase'} =~ /(results|run_search)/) {
 	    $closebutton .="onClick='parent.close()'";
         } else {
             $closebutton .="onClick='self.close()'";
@@ -282,76 +282,76 @@
     ##
     ## Sanity checks on form elements
     ##
-    if (!defined($ENV{'form.viewselect'})) {
-        if (($ENV{'form.catalogmode'} eq 'groupsearch') ||
-            ($ENV{'form.catalogmode'} eq 'interactive')) {
-            $ENV{'form.viewselect'} ="Compact View";
+    if (!defined($env{'form.viewselect'})) {
+        if (($env{'form.catalogmode'} eq 'groupsearch') ||
+            ($env{'form.catalogmode'} eq 'interactive')) {
+            $env{'form.viewselect'} ="Compact View";
         } else {
-            $ENV{'form.viewselect'} ="Detailed Citation View";
+            $env{'form.viewselect'} ="Detailed Citation View";
         }
     }
-    $ENV{'form.phase'} = 'disp_basic' if (! exists($ENV{'form.phase'}));
-    $ENV{'form.show'} = 20 if (! exists($ENV{'form.show'}));
+    $env{'form.phase'} = 'disp_basic' if (! exists($env{'form.phase'}));
+    $env{'form.show'} = 20 if (! exists($env{'form.show'}));
     #
-    $ENV{'form.searchmode'} = 'basic' if (! exists($ENV{'form.searchmode'}));
-    if ($ENV{'form.phase'} eq 'adv_search' ||
-        $ENV{'form.phase'} eq 'disp_adv') {
-        $ENV{'form.searchmode'} = 'advanced';
-    } elsif ($ENV{'form.phase'} eq 'course_search') {
-        $ENV{'form.searchmode'} = 'course_search';
+    $env{'form.searchmode'} = 'basic' if (! exists($env{'form.searchmode'}));
+    if ($env{'form.phase'} eq 'adv_search' ||
+        $env{'form.phase'} eq 'disp_adv') {
+        $env{'form.searchmode'} = 'advanced';
+    } elsif ($env{'form.phase'} eq 'course_search') {
+        $env{'form.searchmode'} = 'course_search';
     }
     #
-    if ($ENV{'form.searchmode'} eq 'advanced') {
+    if ($env{'form.searchmode'} eq 'advanced') {
         &Apache::lonhtmlcommon::add_breadcrumb
             ({href=>'/adm/searchcat?phase=disp_adv&'.
-                  'catalogmode='.$ENV{'form.catalogmode'}.
-                  '&launch='.$ENV{'form.launch'}.
-                  '&mode='.$ENV{'form.mode'},
+                  'catalogmode='.$env{'form.catalogmode'}.
+                  '&launch='.$env{'form.launch'}.
+                  '&mode='.$env{'form.mode'},
                   text=>"Advanced Search",
                   bug=>'Searching',});
-    } elsif ($ENV{'form.searchmode'} eq 'course search') {
+    } elsif ($env{'form.searchmode'} eq 'course search') {
         &Apache::lonhtmlcommon::add_breadcrumb
             ({href=>'/adm/searchcat?phase=disp_adv&'.
-                  'catalogmode='.$ENV{'form.catalogmode'}.
-                  '&launch='.$ENV{'form.launch'}.
-                  '&mode='.$ENV{'form.mode'},
+                  'catalogmode='.$env{'form.catalogmode'}.
+                  '&launch='.$env{'form.launch'}.
+                  '&mode='.$env{'form.mode'},
                   text=>"Course Search",
                   bug=>'Searching',});
     }
     ##
     ## Switch on the phase
     ##
-    if ($ENV{'form.phase'} eq 'disp_basic') {
+    if ($env{'form.phase'} eq 'disp_basic') {
         &print_basic_search_form($r,$closebutton,$hidden_fields);
-    } elsif ($ENV{'form.phase'} eq 'disp_adv') {
+    } elsif ($env{'form.phase'} eq 'disp_adv') {
         &print_advanced_search_form($r,$closebutton,$hidden_fields);
-    } elsif ($ENV{'form.phase'} eq 'results') {
+    } elsif ($env{'form.phase'} eq 'results') {
         &display_results($r,$importbutton,$closebutton,$diropendb);
-    } elsif ($ENV{'form.phase'} =~ /^(sort|run_search)$/) {
+    } elsif ($env{'form.phase'} =~ /^(sort|run_search)$/) {
         my ($query,$customquery,$customshow,$libraries,$pretty_string) =
             &get_persistent_data($persistent_db_file,
                  ['query','customquery','customshow',
                   'libraries','pretty_string']);
-        if ($ENV{'form.phase'} eq 'sort') {
+        if ($env{'form.phase'} eq 'sort') {
             &print_sort_form($r,$pretty_string);
-        } elsif ($ENV{'form.phase'} eq 'run_search') {
+        } elsif ($env{'form.phase'} eq 'run_search') {
             &run_search($r,$query,$customquery,$customshow,
                         $libraries,$pretty_string);
         }
-    } elsif ($ENV{'form.phase'} eq 'course_search') {
+    } elsif ($env{'form.phase'} eq 'course_search') {
         &course_search($r);
-    } elsif(($ENV{'form.phase'} eq 'basic_search') ||
-            ($ENV{'form.phase'} eq 'adv_search')) {
+    } elsif(($env{'form.phase'} eq 'basic_search') ||
+            ($env{'form.phase'} eq 'adv_search')) {
         #
         # We are running a search, try to parse it
         my ($query,$customquery,$customshow,$libraries) = 
             (undef,undef,undef,undef);
         my $pretty_string;
-        if ($ENV{'form.phase'} eq 'basic_search') {
+        if ($env{'form.phase'} eq 'basic_search') {
             ($query,$pretty_string,$libraries) = 
                 &parse_basic_search($r,$closebutton,$hidden_fields);
             return OK if (! defined($query));
-            &make_persistent({ basicexp => $ENV{'form.basicexp'}},
+            &make_persistent({ basicexp => $env{'form.basicexp'}},
                              $persistent_db_file);
         } else {                      # Advanced search
             ($query,$customquery,$customshow,$libraries,$pretty_string) 
@@ -384,7 +384,7 @@
 END
             return OK;
         }
-        delete($ENV{'form.launch'});
+        delete($env{'form.launch'});
         if (! &make_form_data_persistent($r,$persistent_db_file)) {
 	    my $html=&Apache::lonxml::xmlbegin();
 	    $r->print(<<END);
@@ -415,23 +415,23 @@
 # This routine sets non existant checkbox form elements to ''.
 #
 sub clean_up_environment {
-    if ($ENV{'form.phase'} eq 'basic_search') {
-        if (! exists($ENV{'form.related'})) {
-            $ENV{'form.related'} = '';
+    if ($env{'form.phase'} eq 'basic_search') {
+        if (! exists($env{'form.related'})) {
+            $env{'form.related'} = '';
         }
-        if (! exists($ENV{'form.domains'})) {
-            $ENV{'form.domains'} = '';
+        if (! exists($env{'form.domains'})) {
+            $env{'form.domains'} = '';
         }
-    } elsif ($ENV{'form.phase'} eq 'adv_search') {
+    } elsif ($env{'form.phase'} eq 'adv_search') {
         foreach my $field ('title','keywords','notes',
                            'abstract','standards','mime') {
-            if (! exists($ENV{'form.'.$field.'_related'})) {
-                $ENV{'form.'.$field.'_related'} = '';
+            if (! exists($env{'form.'.$field.'_related'})) {
+                $env{'form.'.$field.'_related'} = '';
             }
         }
-    } elsif ($ENV{'form.phase'} eq 'course_search') {
-        if (! exists($ENV{'form.crsrelated'})) {
-            $ENV{'form.crsrelated'} = '';
+    } elsif ($env{'form.phase'} eq 'course_search') {
+        if (! exists($env{'form.crsrelated'})) {
+            $env{'form.crsrelated'} = '';
         }
     }
 }
@@ -439,7 +439,7 @@
 sub hidden_field {
     my ($name,$value) = @_;
     if (! defined($value)) {
-        $value = $ENV{'form.'.$name};
+        $value = $env{'form.'.$name};
     }
     return '<input type="hidden" name="'.$name.'" value="'.$value.'" />'.$/;
 }
@@ -470,20 +470,20 @@
 sub course_search {
     my $r=shift;
     my $bodytag=&Apache::loncommon::bodytag('Course Search');
-    my $pretty_search_string = '<b>'.$ENV{'form.courseexp'}.'</b>';
-    my $search_string = $ENV{'form.courseexp'};
+    my $pretty_search_string = '<b>'.$env{'form.courseexp'}.'</b>';
+    my $search_string = $env{'form.courseexp'};
     my @New_Words;
     undef(%alreadyseen);
-    if ($ENV{'form.crsrelated'}) {
-        ($search_string,@New_Words) = &related_version($ENV{'form.courseexp'});
+    if ($env{'form.crsrelated'}) {
+        ($search_string,@New_Words) = &related_version($env{'form.courseexp'});
         if (@New_Words) {
             $pretty_search_string .= ' '.&mt("with related words").": <b>@New_Words</b>.";
         } else {
             $pretty_search_string .= ' '.&mt('with no related words').".";
         }
     }
-    my $fulltext=$ENV{'form.crsfulltext'};
-    my $discuss=$ENV{'form.crsdiscuss'};
+    my $fulltext=$env{'form.crsfulltext'};
+    my $discuss=$env{'form.crsdiscuss'};
     my @allwords=($search_string,@New_Words);
     $totalfound=0;
     my $html=&Apache::lonxml::xmlbegin();
@@ -492,12 +492,12 @@
     $r->rflush();
 # ======================================================= Go through the course
     my $c=$r->connection;
-    if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.".db",
+    if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
             &GDBM_READER(),0640)) {
         foreach (sort(keys(%hash))) {
             if ($c->aborted()) { last; }
             if (($_=~/^src\_(.+)$/)) {
-		if ($hash{'randomout_'.$1} & !$ENV{'request.role.adv'}) {
+		if ($hash{'randomout_'.$1} & !$env{'request.role.adv'}) {
 		    next; 
 		}
 		my $symb=&make_symb($1);
@@ -518,8 +518,8 @@
         my $navmap = Apache::lonnavmaps::navmap->new();
         my @allres=$navmap->retrieveResources();
         my %discussiontime = &Apache::lonnet::dump('discussiontimes',
-                               $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
-                               $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+                               $env{'course.'.$env{'request.course.id'}.'.domain'},
+                               $env{'course.'.$env{'request.course.id'}.'.num'});
         foreach my $resource (@allres) {
             my $result = '';
             my $applies = 0;
@@ -532,9 +532,9 @@
                 }
             }
             if (defined($discussiontime{$ressymb})) { 
-                my %contrib = &Apache::lonnet::restore($ressymb,$ENV{'request.course.id'},
-                     $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
-                     $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+                my %contrib = &Apache::lonnet::restore($ressymb,$env{'request.course.id'},
+                     $env{'course.'.$env{'request.course.id'}.'.domain'},
+                     $env{'course.'.$env{'request.course.id'}.'.num'});
                 if ($contrib{'version'}) {
                     for (my $id=1;$id<=$contrib{'version'};$id++) {
                         unless (($contrib{'hidden'}=~/\.$id\./) || ($contrib{'deleted'}=~/\.$id\./)) { 
@@ -598,7 +598,7 @@
     $r->rflush();
     
     my $result=$title.' ';
-    if ($ENV{'request.role.adv'} || !$hash{'encrypted_'.$id}) {
+    if ($env{'request.role.adv'} || !$hash{'encrypted_'.$id}) {
 	$result.=&Apache::lonnet::metadata($url,'title').' '.
 	    &Apache::lonnet::metadata($url,'subject').' '.
 	    &Apache::lonnet::metadata($url,'abstract').' '.
@@ -619,7 +619,7 @@
            $r->print('&nbsp;');
        }
        my $href=$url;
-       if ($hash{'encrypted_'.$id} && !$ENV{'request.role.adv'}) {
+       if ($hash{'encrypted_'.$id} && !$env{'request.role.adv'}) {
 	   $href=&Apache::lonenc::encrypted($href)
 	       .'?symb='.&Apache::lonenc::encrypted($symb);
        } else {
@@ -688,22 +688,22 @@
 ######################################################################
 sub print_basic_search_form {
     my ($r,$closebutton,$hidden_fields) = @_;
-    my $result = ($ENV{'form.catalogmode'} ne 'groupsearch');
+    my $result = ($env{'form.catalogmode'} ne 'groupsearch');
     my $bodytag=&Apache::loncommon::bodytag('Search').
         &Apache::lonhtmlcommon::breadcrumbs(undef,'Searching','Search_Basic',
                                    undef,undef,
-                                   $ENV{'form.catalogmode'} ne 'groupsearch');
+                                   $env{'form.catalogmode'} ne 'groupsearch');
     my $scrout = &search_html_header().$bodytag;
-    if (&Apache::lonnet::allowed('bre',$ENV{'request.role.domain'})) {
+    if (&Apache::lonnet::allowed('bre',$env{'request.role.domain'})) {
         # Define interface components
         my $userelatedwords= '<label>'.
             &mt('[_1] use related words',
                 &Apache::lonhtmlcommon::checkbox
-                ('related',$ENV{'form.related'},'related')).'</label>';
+                ('related',$env{'form.related'},'related')).'</label>';
         my $onlysearchdomain='<label>'.
             &mt('[_1] only search domain [_2]',
                 &Apache::lonhtmlcommon::checkbox('domains',
-                                                 $ENV{'form.domains'},
+                                                 $env{'form.domains'},
                                                  $r->dir_config('lonDefDomain')
                                                  ),
                 $r->dir_config('lonDefDomain')
@@ -711,9 +711,9 @@
         my $adv_search_link = 
             '<a href="/adm/searchcat?'.
             'phase=disp_adv&'.
-            'catalogmode='.$ENV{'form.catalogmode'}.
-            '&launch='.$ENV{'form.launch'}.
-            '&mode='.$ENV{'form.mode'}.
+            'catalogmode='.$env{'form.catalogmode'}.
+            '&launch='.$env{'form.launch'}.
+            '&mode='.$env{'form.mode'}.
             '">'.&mt('Advanced Search').'</a>';
         #
         $scrout.='<form name="loncapa_search" method="post" '.
@@ -722,7 +722,7 @@
             $hidden_fields;
         #
         $scrout .= '<center>'.$/;
-        if ($ENV{'request.course.id'}) {
+        if ($env{'request.course.id'}) {
             $scrout .= '<h1>'.&mt('LON-CAPA Catalog Search').'</h1>';
         } else {
             # No need to tell them they are searching
@@ -732,7 +732,7 @@
             '<tr><td align="center" valign="top">'.
             &Apache::lonhtmlcommon::textbox
             ('basicexp',
-             &HTML::Entities::encode($ENV{'form.basicexp'},'<>&"'),50
+             &HTML::Entities::encode($env{'form.basicexp'},'<>&"'),50
              ).
              '<br />'.
             '<font size="-1">'.&searchhelp().'</font>'.'</td>'.
@@ -753,7 +753,7 @@
             '</td></tr>'.$/;
         $scrout .= '</table>'.$/.'</center>'.'</form>';
     }
-    if ($ENV{'request.course.id'}) {
+    if ($env{'request.course.id'}) {
 	my %lt=&Apache::lonlocal::texthash('srch' => 'Search',
                                            'header' => 'Course Search',
 	 'note' => 'Enter terms or phrases, then press "Search" below',
@@ -777,16 +777,16 @@
 ENDCOURSESEARCH
         $scrout.='&nbsp;'.
             &Apache::lonhtmlcommon::textbox('courseexp',
-                                  $ENV{'form.courseexp'},40);
+                                  $env{'form.courseexp'},40);
         my $crscheckbox = 
             &Apache::lonhtmlcommon::checkbox('crsfulltext',
-                                   $ENV{'form.crsfulltext'});
+                                   $env{'form.crsfulltext'});
         my $relcheckbox = 
             &Apache::lonhtmlcommon::checkbox('crsrelated',
-				   $ENV{'form.crsrelated'});
+				   $env{'form.crsrelated'});
         my $discheckbox = 
             &Apache::lonhtmlcommon::checkbox('crsdiscuss',
-                                   $ENV{'form.crsrelated'});
+                                   $env{'form.crsrelated'});
         $scrout.=(<<ENDENDCOURSE);
 </td></tr>
 <tr><td><label>$relcheckbox $lt{'use'}</label></td><td></td></tr>
@@ -825,7 +825,7 @@
         &Apache::lonhtmlcommon::breadcrumbs(undef,'Searching',
                                             'Search_Advanced',
                                             undef,undef,
-                                  $ENV{'form.catalogmode'} ne 'groupsearch');
+                                  $env{'form.catalogmode'} ne 'groupsearch');
     my %lt=&Apache::lonlocal::texthash('srch' => 'Search',
 				       'reset' => 'Reset',
 				       'help' => 'Help');
@@ -866,12 +866,12 @@
 	     'keywords','notes','abstract','standards','mime') {
 	$scrout.='<tr><td align="right">'.&titlefield($fields{$field}).'</td><td>'.
 	    &Apache::lonmeta::prettyinput($field,
-                                          $ENV{'form.'.$field},
+                                          $env{'form.'.$field},
                                           $field,
                                           'advsearch',
 					  $related_word_search{$field},
                                           '</td><td align="left">',
-                                          $ENV{'form.'.$field.'_related'},
+                                          $env{'form.'.$field.'_related'},
                                           50);
         if ($related_word_search{$field}) {
             $scrout .= 'related words';
@@ -885,7 +885,7 @@
             '<td align="right">'.&titlefield($fields{$field}).'</td>'.
             '<td colspan="2">'.
 	    &Apache::lonmeta::prettyinput($field,
-                                          $ENV{'form.'.$field},
+                                          $env{'form.'.$field},
                                           $field,
                                           'advsearch',
 					  0).
@@ -894,19 +894,19 @@
     $scrout.='<tr><td align="right">'.
 	&titlefield(&mt('MIME Type Category')).'</td><td colspan="2">'. 
 	    &Apache::loncommon::filecategoryselect('category',
-						   $ENV{'form.category'}).
+						   $env{'form.category'}).
 	    '</td></tr>'.$/;
     $scrout.='<tr><td align="right" valign="top">'.
 	&titlefield(&mt('Domains')).'</td><td colspan="2">'. 
 	    &Apache::loncommon::domain_select('domains',
-						   $ENV{'form.domains'},1).
+						   $env{'form.domains'},1).
 	    '</td></tr>'.$/;
     #
     # Misc metadata
     $scrout.='<tr><td align="right" valign="top">'.
 	&titlefield(&mt('Copyright/Distribution')).'</td><td colspan="2">'.
         &Apache::lonmeta::selectbox('copyright',
-                                    $ENV{'form.copyright'},
+                                    $env{'form.copyright'},
                                     \&Apache::loncommon::copyrightdescription,
                                     ( undef,
                                       &Apache::loncommon::copyrightids)
@@ -914,7 +914,7 @@
     $scrout.='<tr><td align="right" valign="top">'.
 	&titlefield(&mt('Language')).'</td><td colspan="2">'.
         &Apache::lonmeta::selectbox('language',
-                                    $ENV{'form.language'},
+                                    $env{'form.language'},
                                     \&Apache::loncommon::languagedescription,
                                     ('any',&Apache::loncommon::languageids)
                                     ).'</td></tr>';
@@ -1096,16 +1096,16 @@
 ######################################################################
 sub viewoptions {
     my $scrout;
-    if (! defined($ENV{'form.viewselect'})) { 
-        $ENV{'form.viewselect'}='detailed'; 
+    if (! defined($env{'form.viewselect'})) { 
+        $env{'form.viewselect'}='detailed'; 
     }
     $scrout.=&Apache::lonmeta::selectbox('viewselect',
-			$ENV{'form.viewselect'},
+			$env{'form.viewselect'},
 			\&viewoptiontext,
 			sort(keys(%Views)));
     $scrout.= '&nbsp;&nbsp;';
     my $countselect = &Apache::lonmeta::selectbox('show',
-                                                  $ENV{'form.show'},
+                                                  $env{'form.show'},
                                                   undef,
                                                   (10,20,50,100,1000,10000));
     $scrout .= ('&nbsp;'x2).&mt('[_1] Records per Page',$countselect).
@@ -1145,7 +1145,7 @@
 
 This function is the reverse of &make_persistent() for form data.
 Retrieve persistent data from %persistent_db.  Retrieved items will have their
-values unescaped.  If a form value already exists in $ENV, it will not be
+values unescaped.  If a form value already exists in $env, it will not be
 overwritten.  Form values that are array references may have values appended
 to them.
 
@@ -1167,20 +1167,20 @@
         next if ($name !~ /^form./);
         # Kludgification begins!
         if ($name eq 'form.domains' && 
-            $ENV{'form.searchmode'} eq 'basic' &&
-            $ENV{'form.phase'} ne 'disp_basic') {
+            $env{'form.searchmode'} eq 'basic' &&
+            $env{'form.phase'} ne 'disp_basic') {
             next;
         }
         # End kludge (hopefully)
-        next if (exists($ENV{$name}));
+        next if (exists($env{$name}));
         my @values = map { 
             &Apache::lonnet::unescape($_);
         } split(',',$persistent_db{$name});
         next if (@values <1);
         if ($arrays_allowed{$name}) {
-            $ENV{$name} = [@values];
+            $env{$name} = [@values];
         } else {
-            $ENV{$name} = $values[0] if ($values[0]);
+            $env{$name} = $values[0] if ($values[0]);
         }
     }
     untie (%persistent_db);
@@ -1285,9 +1285,9 @@
     my $r = shift;
     my $filename = shift;
     my %save;
-    foreach (keys(%ENV)) {
+    foreach (keys(%env)) {
         next if (!/^form/ || /submit/);
-        $save{$_} = $ENV{$_};
+        $save{$_} = $env{$_};
     }
     return &make_persistent(\%save,$filename);
 }
@@ -1335,36 +1335,36 @@
 		   'lastrevisiondatestart_month','lastrevisiondatestart_day',
 		   'lastrevisiondatestart_year','lastrevisiondateend_month',
 		   'lastrevisiondateend_day','lastrevisiondateend_year') {
-	$ENV{'form.'.$field}=~s/[^\w\/\s\(\)\=\-\"\']//g;
+	$env{'form.'.$field}=~s/[^\w\/\s\(\)\=\-\"\']//g;
     }
     foreach ('mode','form','element') {
 	# is this required?  Hmmm.
-	next if (! exists($ENV{'form.'.$_}));
-	$ENV{'form.'.$_}=&Apache::lonnet::unescape($ENV{'form.'.$_});
-	$ENV{'form.'.$_}=~s/[^\w\/\s\(\)\=\-\"\']//g;
+	next if (! exists($env{'form.'.$_}));
+	$env{'form.'.$_}=&Apache::lonnet::unescape($env{'form.'.$_});
+	$env{'form.'.$_}=~s/[^\w\/\s\(\)\=\-\"\']//g;
     }
     # Preprocess the category form element.
-    $ENV{'form.category'} = 'any' if (! defined($ENV{'form.category'}) ||
-                                      ref($ENV{'form.category'}));
+    $env{'form.category'} = 'any' if (! defined($env{'form.category'}) ||
+                                      ref($env{'form.category'}));
     #
     # Check to see if enough information was filled in
     foreach my $field (@BasicFields) {
-	if (&filled($ENV{'form.'.$field})) {
+	if (&filled($env{'form.'.$field})) {
 	    $fillflag++;
 	}
     }
     foreach my $field (@StatsFields,@EvalFields) {
-        if (&filled($ENV{'form.'.$field.'_max'})) {
+        if (&filled($env{'form.'.$field.'_max'})) {
             $fillflag++;
         }
-        if (&filled($ENV{'form.'.$field.'_min'})) {
+        if (&filled($env{'form.'.$field.'_min'})) {
             $fillflag++;
         }
     }
 
     for my $field ('lowestgradelevel','highestgradelevel') {
-        if ( $ENV{'form.'.$field} =~ /^\d+$/ &&
-             $ENV{'form.'.$field} > 0) {
+        if ( $env{'form.'.$field} =~ /^\d+$/ &&
+             $env{'form.'.$field} > 0) {
             $fillflag++;
         }
     }
@@ -1379,21 +1379,21 @@
     my $font = '<font color="#800000" face="helvetica">';
     # Evaluate logical expression AND/OR/NOT phrase fields.
     foreach my $field (@BasicFields) {
-	next if (!defined($ENV{'form.'.$field}) || $ENV{'form.'.$field} eq '');
+	next if (!defined($env{'form.'.$field}) || $env{'form.'.$field} eq '');
         my ($error,$SQLQuery) = 
-            &process_phrase_input($ENV{'form.'.$field},
-                                  $ENV{'form.'.$field.'_related'},$field);
+            &process_phrase_input($env{'form.'.$field},
+                                  $env{'form.'.$field.'_related'},$field);
         if (defined($error)) {
             &output_unparsed_phrase_error($r,$closebutton,'phase=disp_adv',
                                          $hidden_fields,$field);
             return;
         } else {
             $pretty_search_string .= 
-                $font.$field.'</font>: '.$ENV{'form.'.$field};
-            if ($ENV{'form.'.$field.'_related'}) {
+                $font.$field.'</font>: '.$env{'form.'.$field};
+            if ($env{'form.'.$field.'_related'}) {
                 my @Words = 
                     &Apache::loncommon::get_related_words
-                    ($ENV{'form.'.$field});
+                    ($env{'form.'.$field});
                 if (@Words) {
                     $pretty_search_string.= ' with related words: '.
                         join(', ',@Words[0..4]);
@@ -1409,11 +1409,11 @@
     # Make the 'mime' from 'form.category' and 'form.extension'
     #
     my $searchphrase;
-    if (exists($ENV{'form.category'})    && 
-        $ENV{'form.category'} !~ /^\s*$/ &&
-        $ENV{'form.category'} ne 'any')     {
+    if (exists($env{'form.category'})    && 
+        $env{'form.category'} !~ /^\s*$/ &&
+        $env{'form.category'} ne 'any')     {
         my @extensions = &Apache::loncommon::filecategorytypes
-                                                   ($ENV{'form.category'});
+                                                   ($env{'form.category'});
         if (scalar(@extensions) > 0) {
             $searchphrase = join(' OR ',@extensions);
         }
@@ -1426,45 +1426,45 @@
     }
     #
     # Evaluate option lists
-    if ($ENV{'form.lowestgradelevel'}        &&
-        $ENV{'form.lowestgradelevel'} ne '0' &&
-        $ENV{'form.lowestgradelevel'} =~ /^\d+$/) {
+    if ($env{'form.lowestgradelevel'}        &&
+        $env{'form.lowestgradelevel'} ne '0' &&
+        $env{'form.lowestgradelevel'} =~ /^\d+$/) {
 	push(@queries,
-             '(lowestgradelevel>='.$ENV{'form.lowestgradelevel'}.')');
+             '(lowestgradelevel>='.$env{'form.lowestgradelevel'}.')');
         $pretty_search_string.="lowestgradelevel>=".
-            $ENV{'form.lowestgradelevel'}."<br />\n";
+            $env{'form.lowestgradelevel'}."<br />\n";
     }
-    if ($ENV{'form.highestgradelevel'}        &&
-        $ENV{'form.highestgradelevel'} ne '0' &&
-        $ENV{'form.highestgradelevel'} =~ /^\d+$/) {
+    if ($env{'form.highestgradelevel'}        &&
+        $env{'form.highestgradelevel'} ne '0' &&
+        $env{'form.highestgradelevel'} =~ /^\d+$/) {
 	push(@queries,
-             '(highestgradelevel<='.$ENV{'form.highestgradelevel'}.')');
+             '(highestgradelevel<='.$env{'form.highestgradelevel'}.')');
         $pretty_search_string.="highestgradelevel<=".
-            $ENV{'form.highestgradelevel'}."<br />\n";
+            $env{'form.highestgradelevel'}."<br />\n";
     }
-    if ($ENV{'form.language'} and $ENV{'form.language'} ne 'any') {
-	push @queries,"(language like \"$ENV{'form.language'}\")";
+    if ($env{'form.language'} and $env{'form.language'} ne 'any') {
+	push @queries,"(language like \"$env{'form.language'}\")";
         $pretty_search_string.=$font."language</font>= ".
-            &Apache::loncommon::languagedescription($ENV{'form.language'}).
+            &Apache::loncommon::languagedescription($env{'form.language'}).
                 "<br />\n";
     }
-    if ($ENV{'form.copyright'} and $ENV{'form.copyright'} ne 'any') {
-	push @queries,"(copyright like \"$ENV{'form.copyright'}\")";
+    if ($env{'form.copyright'} and $env{'form.copyright'} ne 'any') {
+	push @queries,"(copyright like \"$env{'form.copyright'}\")";
         $pretty_search_string.=$font."copyright</font> = ".
-            &Apache::loncommon::copyrightdescription($ENV{'form.copyright'}).
+            &Apache::loncommon::copyrightdescription($env{'form.copyright'}).
                 "<br />\n";
     }
     #
     # Statistics
     foreach my $field (@StatsFields,@EvalFields) {
         my ($min,$max);
-        if (exists($ENV{'form.'.$field.'_min'}) && 
-            $ENV{'form.'.$field.'_min'} ne '') {
-            $min = $ENV{'form.'.$field.'_min'};
-        }
-        if (exists($ENV{'form.'.$field.'_max'}) &&
-            $ENV{'form.'.$field.'_max'} ne '') {
-            $max = $ENV{'form.'.$field.'_max'};
+        if (exists($env{'form.'.$field.'_min'}) && 
+            $env{'form.'.$field.'_min'} ne '') {
+            $min = $env{'form.'.$field.'_min'};
+        }
+        if (exists($env{'form.'.$field.'_max'}) &&
+            $env{'form.'.$field.'_max'} ne '') {
+            $max = $env{'form.'.$field.'_max'};
         }
         next if (! defined($max) && ! defined($min));
         if (defined($min) && defined($max)) {
@@ -1517,17 +1517,17 @@
     ## because I was unable to figureout exactly how it worked and could
     ## not imagine people actually using it.  MH
     ##
-    # if ($ENV{'form.custommetadata'}) {
+    # if ($env{'form.custommetadata'}) {
     #    $pretty_search_string .=$font."Custom Metadata Search</font>: <b>".
-    #    $ENV{'form.custommetadata'}."</b><br />\n";
+    #    $env{'form.custommetadata'}."</b><br />\n";
     #    $customquery=&build_custommetadata_query('custommetadata',
-    #                                             $ENV{'form.custommetadata'});
+    #                                             $env{'form.custommetadata'});
     # }
     my $customshow=undef;
-    # if ($ENV{'form.customshow'}) {
+    # if ($env{'form.customshow'}) {
     # $pretty_search_string .=$font."Custom Metadata Display</font>: <b>".
-    #                         $ENV{'form.customshow'}."</b><br />\n";
-    #    $customshow=$ENV{'form.customshow'};
+    #                         $env{'form.customshow'}."</b><br />\n";
+    #    $customshow=$env{'form.customshow'};
     #    $customshow=~s/[^\w\s]//g;
     #    my @fields=split(/\s+/,$customshow);
     #    $customshow=join(" ",@fields);
@@ -1552,16 +1552,16 @@
 
 sub parse_domain_restrictions {
     my $libraries_to_query = undef;
-    # $ENV{'form.domains'} can be either a scalar or an array reference.
+    # $env{'form.domains'} can be either a scalar or an array reference.
     # We need an array.
-    if (! exists($ENV{'form.domains'}) || $ENV{'form.domains'} eq '') {
+    if (! exists($env{'form.domains'}) || $env{'form.domains'} eq '') {
         return (undef,'',undef);
     }
     my @allowed_domains;
-    if (ref($ENV{'form.domains'})) {
-        @allowed_domains =  @{$ENV{'form.domains'}};
+    if (ref($env{'form.domains'})) {
+        @allowed_domains =  @{$env{'form.domains'}};
     } else {
-        @allowed_domains = ($ENV{'form.domains'});
+        @allowed_domains = ($env{'form.domains'});
     }
     #
     my %domain_hash = ();
@@ -1613,19 +1613,19 @@
     #
     # Clean up fields for safety
     for my $field ('basicexp') {
-	$ENV{"form.$field"}=~s/[^\w\s\'\"\!\(\)\-]//g;
+	$env{"form.$field"}=~s/[^\w\s\'\"\!\(\)\-]//g;
     }
     foreach ('mode','form','element') {
 	# is this required?  Hmmm.
-	next unless (exists($ENV{"form.$_"}));
-	$ENV{"form.$_"}=&Apache::lonnet::unescape($ENV{"form.$_"});
-	$ENV{"form.$_"}=~s/[^\w\/\s\(\)\=\-\"\']//g;
+	next unless (exists($env{"form.$_"}));
+	$env{"form.$_"}=&Apache::lonnet::unescape($env{"form.$_"});
+	$env{"form.$_"}=~s/[^\w\/\s\(\)\=\-\"\']//g;
     }
     my ($libraries_to_query,$pretty_domains_string,$domain_sql_restriction) = 
         &parse_domain_restrictions();
     #
     # Check to see if enough of a query is filled in
-    my $search_string = $ENV{'form.basicexp'};
+    my $search_string = $env{'form.basicexp'};
     if (! &filled($search_string)) {
 	&output_blank_field_error($r,$closebutton,'phase=disp_basic');
 	return OK;
@@ -1637,7 +1637,7 @@
                                              'notes','abstract','keywords')
                                             ).')';
     my ($error,$SQLQuery) = &process_phrase_input($search_string,
-                                                    $ENV{'form.related'},
+                                                    $env{'form.related'},
                                                     $searchfield);
     if ($error) {
         &output_unparsed_phrase_error($r,$closebutton,'phase=disp_basic',
@@ -2012,13 +2012,13 @@
                                               $Metadata->{'url'});
     # Check for priv
     if (($Metadata->{'copyright'} eq 'priv') && 
-        (($ENV{'user.name'} ne $resname) &&
-         ($ENV{'user.domain'} ne $resdom))) {
+        (($env{'user.name'} ne $resname) &&
+         ($env{'user.domain'} ne $resdom))) {
         return 0;
     }
     # Check for domain
     if (($Metadata->{'copyright'} eq 'domain') &&
-        ($ENV{'user.domain'} ne $resdom)) {
+        ($env{'user.domain'} ne $resdom)) {
         return 0;
     }
     return 1;
@@ -2099,7 +2099,7 @@
     my $bodytag=&Apache::loncommon::bodytag(undef,undef,undef,1).
         &Apache::lonhtmlcommon::breadcrumbs
         (undef,'Searching','Searching',undef,undef,
-         $ENV{'form.catalogmode'} ne 'groupsearch');
+         $env{'form.catalogmode'} ne 'groupsearch');
 
     ##
     my %SortableFields=&Apache::lonlocal::texthash( 
@@ -2118,7 +2118,7 @@
          lastrevisiondate => 'Revision Date'
      );
     ##
-    my $table = $ENV{'form.table'};
+    my $table = $env{'form.table'};
     return if (! &ensure_db_and_table($r,$table));
     ##
     ## Get the number of results 
@@ -2139,7 +2139,7 @@
 <script>
     function change_sort() {
         var newloc = "/adm/searchcat?phase=results";
-        newloc += "&persistent_db_id=$ENV{'form.persistent_db_id'}";
+        newloc += "&persistent_db_id=$env{'form.persistent_db_id'}";
         newloc += "&sortby=";
         newloc += document.forms.statusform.elements.sortby.value;
         parent.resultsframe.location= newloc;
@@ -2154,10 +2154,10 @@
 
 #<h2>Sort Results</h2>
 #Sort by: <select size="1" name="sortby" onchange="javascript:change_sort();">
-#    $ENV{'form.sortby'} = 'id' if (! defined($ENV{'form.sortby'}));
+#    $env{'form.sortby'} = 'id' if (! defined($env{'form.sortby'}));
 #    foreach (keys(%SortableFields)) {
 #        $result.="<option name=\"$_\"";
-#        if ($_ eq $ENV{'form.sortby'}) {
+#        if ($_ eq $env{'form.sortby'}) {
 #            $result.=" selected ";
 #        }
 #        $result.=" >$SortableFields{$_}</option>\n";
@@ -2208,7 +2208,7 @@
 =item &create_results_table()
 
 Creates the table of search results by calling lonmysql.  Stores the
-table id in $ENV{'form.table'}
+table id in $env{'form.table'}
 
 Inputs: none.
 
@@ -2239,7 +2239,7 @@
             FULLTEXT => [{'columns' => \@Fullindicies},],
         } );
     if (defined($table)) {
-        $ENV{'form.table'} = $table;
+        $env{'form.table'} = $table;
         return $table;
     } 
     return undef; # Error...
@@ -2340,9 +2340,9 @@
 ######################################################################
 sub revise_button {
     my $revise_phase = 'disp_basic';
-    $revise_phase = 'disp_adv' if ($ENV{'form.searchmode'} eq 'advanced');
+    $revise_phase = 'disp_adv' if ($env{'form.searchmode'} eq 'advanced');
     my $newloc = '/adm/searchcat'.
-        '?persistent_db_id='.$ENV{'form.persistent_db_id'}.
+        '?persistent_db_id='.$env{'form.persistent_db_id'}.
             '&cleargroupsort=1'.
             '&phase='.$revise_phase;
     my $result = qq{<input type="button" value="Revise search" name="revise"} .
@@ -2369,7 +2369,7 @@
     my $bodytag=&Apache::loncommon::bodytag(undef,undef,undef,1);
     $bodytag.=&Apache::lonhtmlcommon::breadcrumbs
         (undef,'Searching','Searching',undef,undef,
-         $ENV{'form.catalogmode'} ne 'groupsearch');
+         $env{'form.catalogmode'} ne 'groupsearch');
     my $connection = $r->connection;
     #
     # Print run_search header
@@ -2411,7 +2411,7 @@
     my %Server_status;
     #
     # Check on the mysql table we will use to store results.
-    my $table =$ENV{'form.table'};
+    my $table =$env{'form.table'};
     if (! defined($table) || $table eq '' || $table =~ /\D/ ) {
         $r->print("Unable to determine table id to store search results in.".
                   "The search has been aborted.</body></html>");
@@ -2421,7 +2421,7 @@
     if (! defined($table_status)) {
         $r->print("Unable to determine status of table.</body></html>");
         &Apache::lonnet::logthis("Bogus table id of $table for ".
-                                 "$ENV{'user.name'} @ $ENV{'user.domain'}");
+                                 "$env{'user.name'} @ $env{'user.domain'}");
         &Apache::lonnet::logthis("lonmysql error = ".
                                  &Apache::lonmysql::get_error());
         return;
@@ -2560,11 +2560,11 @@
     # results to get, so let the client know the top frame needs to be
     # loaded from /adm/searchcat
     $r->print("</body></html>");
-#    if ($ENV{'form.catalogmode'} ne 'groupsearch') {
+#    if ($env{'form.catalogmode'} ne 'groupsearch') {
         $r->print("<script>".
                       "window.location='/adm/searchcat?".
                       "phase=sort&".
-                      "persistent_db_id=$ENV{'form.persistent_db_id'}';".
+                      "persistent_db_id=$env{'form.persistent_db_id'}';".
                   "</script>");
 #    }
     return;
@@ -2619,7 +2619,7 @@
     ##
     ## Set viewing function
     ##
-    my $viewfunction = $Views{$ENV{'form.viewselect'}};
+    my $viewfunction = $Views{$env{'form.viewselect'}};
     if (!defined($viewfunction)) {
         $r->print("Internal Error - Bad view selected.\n");
         $r->rflush();
@@ -2635,7 +2635,7 @@
     my $action = "/adm/searchcat?phase=results";
     ##
     ## Deal with groupsearch by opening the groupsearch db file.
-    if ($ENV{'form.catalogmode'} eq 'groupsearch') {
+    if ($env{'form.catalogmode'} eq 'groupsearch') {
         if (! tie(%groupsearch_db,'GDBM_File',$diropendb,
                   &GDBM_WRCREAT(),0640)) {
             $r->print('Unable to store import results.</form></body></html>');
@@ -2645,7 +2645,7 @@
     }
     ##
     ## Prepare the table for querying
-    my $table = $ENV{'form.table'};
+    my $table = $env{'form.table'};
     return if (! &ensure_db_and_table($r,$table));
     ##
     ## Get the number of results 
@@ -2659,21 +2659,21 @@
     }
     ##
     ## Determine how many results we need to get
-    $ENV{'form.start'} = 1  if (! exists($ENV{'form.start'}));
-    $ENV{'form.show'}  = 20 if (! exists($ENV{'form.show'}));
-    if (exists($ENV{'form.prev'})) {
-        $ENV{'form.start'} -= $ENV{'form.show'};
-    } elsif (exists($ENV{'form.next'})) {
-        $ENV{'form.start'} += $ENV{'form.show'};
-    }
-    $ENV{'form.start'} = 1 if ($ENV{'form.start'}<1);
-    $ENV{'form.start'} = $total_results if ($ENV{'form.start'}>$total_results);
-    my $min = $ENV{'form.start'};
+    $env{'form.start'} = 1  if (! exists($env{'form.start'}));
+    $env{'form.show'}  = 20 if (! exists($env{'form.show'}));
+    if (exists($env{'form.prev'})) {
+        $env{'form.start'} -= $env{'form.show'};
+    } elsif (exists($env{'form.next'})) {
+        $env{'form.start'} += $env{'form.show'};
+    }
+    $env{'form.start'} = 1 if ($env{'form.start'}<1);
+    $env{'form.start'} = $total_results if ($env{'form.start'}>$total_results);
+    my $min = $env{'form.start'};
     my $max;
-    if ($ENV{'form.show'} eq 'all') {
+    if ($env{'form.show'} eq 'all') {
         $max = $total_results ;
     } else {
-        $max = $min + $ENV{'form.show'} - 1;
+        $max = $min + $env{'form.show'} - 1;
         $max = $total_results if ($max > $total_results);
     }
     ##
@@ -2685,6 +2685,66 @@
               );
     #
     # Build sorting selector
+<<<<<<< lonsearchcat.pm
+    my @field_order =  ('default',
+                        'title',
+                        'author',
+                        'subject',
+                        'url',
+                        'keywords',
+                        'version',
+                        'language',
+                        'creationdate'=>,
+                        'lastrevisiondate',
+                        'owner',
+                        'copyright',
+                        'authorspace',
+                        'lowestgradeleve',
+                        'highestgradelevel',
+                        'standards',
+                        'count',
+                        'stdno',
+                        'avetries',
+                        'difficulty',
+                        'disc',
+                        'clear',
+                        'technical',
+                        'correct',
+                        'helpful',
+                        'depth',
+                        );                                              
+    my %sort_fields = ('default'     => 'Default',
+                       'title'       => 'Title',
+                       'author'      => 'Author',
+                       'subject'     => 'Subject',
+                       'url'         => 'URL',
+                       'keywords'    => 'Keywords',
+                       'version'     => 'Version',
+                       'language'    => 'Language',
+                       'creationdate'=> 'Creation Date',
+                       'lastrevisiondate' => 'Last Revision Date',
+                       'owner'       => 'Owner',
+                       'copyright'   => 'Copyright',
+                       'authorspace' => 'Authorspace',
+                       'lowestgradeleve' => 'Lowest Grade Level',
+                       'highestgradelevel' => 'Highest Grade Level',
+                       'standards'   => 'Standards',
+                       'count'       => 'Number of Accesses',
+                       'stdno'       => 'Students Attempting',
+                       'avetries'    => 'Average Number of Tries',
+                       'difficulty'  => 'Mean Degree of Difficulty',
+                       'disc'        => 'Mean Degree of Discrimination',
+                       'clear'       => 'Evaluation: Clear',
+                       'technical'   => 'Evaluation: Technically Correct',
+                       'correct'     => 'Evaluation: Material is Correct',
+                       'helpful'     => 'Evaluation: Material is Helpful',
+                       'depth'       => 'Evaluation: Material has Depth',
+                       'select_form_order' => \@field_order,
+                       );
+
+    my $sortform = &mt('Sort by [_1]',
+                       &Apache::loncommon::select_form($env{'form.sortfield'},
+=======
     my @fields = 
         (
          {key=>'default' },
@@ -2731,6 +2791,7 @@
     $ENV{'form.sortorder'} = 'asc' if (! exists($ENV{'form.sortorder'}));
     my $sortform = &mt('Sort by [_1] [_2]',
                        &Apache::loncommon::select_form($ENV{'form.sortfield'},
+>>>>>>> 1.242
                                                       'sortfield',
                                                       %sort_fields),
                        &Apache::loncommon::select_form($ENV{'form.sortorder'},
@@ -2745,7 +2806,7 @@
         ('<table width="100%"><tr><td width="25%" align="right">'.
          '<nobr>'.$sortform.'</nobr>'.
          '</td><td width="25%" align="right">'.
-         &prev_next_buttons($min,$ENV{'form.show'},$total_results).
+         &prev_next_buttons($min,$env{'form.show'},$total_results).
          '</td><td align="right">'.
          &viewoptions().'</td></tr></table>'
          );
@@ -2763,6 +2824,12 @@
     ##
     ## Get results from MySQL table
     my $sort_command  = 'id>='.$min.' AND id<='.$max;
+<<<<<<< lonsearchcat.pm
+    if ($env{'form.sortfield'} ne 'default' && 
+        exists($sort_fields{$env{'form.sortfield'}})) {
+        $sort_command = $env{'form.sortfield'}.' IS NOT NULL '.
+            'ORDER BY '.$env{'form.sortfield'}.
+=======
     my $order;
     if (exists($ENV{'form.sortorder'})) {
         if ($ENV{'form.sortorder'} eq 'asc') {
@@ -2779,6 +2846,7 @@
         exists($sort_fields{$ENV{'form.sortfield'}})) {
         $sort_command = $ENV{'form.sortfield'}.' IS NOT NULL '.
             'ORDER BY '.$ENV{'form.sortfield'}.' '.$order.
+>>>>>>> 1.242
             '  LIMIT '.($min-1).','.($max-$min);
     }
     my @Results = &Apache::lonmysql::get_rows($table,$sort_command);
@@ -2807,11 +2875,11 @@
     } else {
         $r->print
             ('<center>'.
-             &prev_next_buttons($min,$ENV{'form.show'},$total_results,
-                                "table=".$ENV{'form.table'}.
+             &prev_next_buttons($min,$env{'form.show'},$total_results,
+                                "table=".$env{'form.table'}.
                                 "&phase=results".
                                 "&persistent_db_id=".
-                                $ENV{'form.persistent_db_id'})
+                                $env{'form.persistent_db_id'})
              ."</center>\n"
              );
     }
@@ -2829,7 +2897,7 @@
 =item &catalogmode_output($title,$url,$fnum,$checkbox_num)
 
 Returns html needed for the various catalog modes.  Gets inputs from
-$ENV{'form.catalogmode'}.  Stores data in %groupsearch_db.
+$env{'form.catalogmode'}.  Stores data in %groupsearch_db.
 
 =cut
 
@@ -2838,16 +2906,16 @@
 sub catalogmode_output {
     my $output = '';
     my ($title,$url,$fnum,$checkbox_num) = @_;
-    if ($ENV{'form.catalogmode'} eq 'interactive') {
+    if ($env{'form.catalogmode'} eq 'interactive') {
         $title=~ s/\'/\\\'/g;
-        if ($ENV{'form.catalogmode'} eq 'interactive') {
+        if ($env{'form.catalogmode'} eq 'interactive') {
             $output.=<<END 
 <font size='-1'><INPUT TYPE="button" NAME="returnvalues" VALUE="SELECT"
 onClick="javascript:select_data('$title','$url')">
 </font>
 END
         }
-    } elsif ($ENV{'form.catalogmode'} eq 'groupsearch') {
+    } elsif ($env{'form.catalogmode'} eq 'groupsearch') {
         $groupsearch_db{"pre_${fnum}_link"}=$url;
         $groupsearch_db{"pre_${fnum}_title"}=$title;
         $output.=<<END;
@@ -2937,8 +3005,8 @@
     my $customshow='';
     my $extrashow='';
     my @customfields;
-    if ($ENV{'form.customshow'}) {
-        $customshow=$ENV{'form.customshow'};
+    if ($env{'form.customshow'}) {
+        $customshow=$env{'form.customshow'};
         $customshow=~s/[^\w\s]//g;
         my @fields=map {
             "<font color=\"#008000\">$_:</font><!-- $_ -->";
@@ -2972,7 +3040,7 @@
 Output the proper html headers and javascript code to deal with different 
 calling modes.
 
-Takes most inputs directly from %ENV, except $mode.  
+Takes most inputs directly from %env, except $mode.  
 
 =over 4
 
@@ -3017,8 +3085,8 @@
     # output beginning of search page
     # conditional output of script functions dependent on the mode in
     # which the search was invoked
-    if ($ENV{'form.catalogmode'} eq 'interactive'){
-	if (! exists($ENV{'form.mode'}) || $ENV{'form.mode'} ne 'edit') {
+    if ($env{'form.catalogmode'} eq 'interactive'){
+	if (! exists($env{'form.mode'}) || $env{'form.mode'} ne 'edit') {
             $result.=<<SCRIPT;
 <script type="text/javascript">
     function select_data(title,url) {
@@ -3038,10 +3106,10 @@
     }
 </script>
 SCRIPT
-        } elsif ($ENV{'form.mode'} eq 'edit') {
-            my $form = $ENV{'form.form'};
-            my $element = $ENV{'form.element'};
-            my $titleelement = $ENV{'form.titleelement'};
+        } elsif ($env{'form.mode'} eq 'edit') {
+            my $form = $env{'form.form'};
+            my $element = $env{'form.element'};
+            my $titleelement = $env{'form.titleelement'};
 	    my $changetitle;
 	    if (!$titleelement) {
 		$changetitle='function changeTitle(val) {}';
@@ -3078,7 +3146,7 @@
 SCRIPT
         }
     }
-    $result.=<<SCRIPT if $ENV{'form.catalogmode'} eq 'groupsearch';
+    $result.=<<SCRIPT if $env{'form.catalogmode'} eq 'groupsearch';
 <script type="text/javascript">
     function queue(checkbox_num,val) {
         if (document.forms.results.returnvalues.length != "undefined" &&
@@ -3098,7 +3166,7 @@
     }
     function select_group() {
 	parent.window.location=
-    "/adm/groupsort?mode=$ENV{'form.mode'}&catalogmode=groupsearch&acts="+
+    "/adm/groupsort?mode=$env{'form.mode'}&catalogmode=groupsearch&acts="+
 	    parent.statusframe.document.forms.statusform.elements.Queue.value;
     }
 </script>
@@ -3129,8 +3197,8 @@
 }
 
 sub results_link {
-    my $basic_link   = "/adm/searchcat?"."&table=".$ENV{'form.table'}.
-        "&persistent_db_id=".$ENV{'form.persistent_db_id'};
+    my $basic_link   = "/adm/searchcat?"."&table=".$env{'form.table'}.
+        "&persistent_db_id=".$env{'form.persistent_db_id'};
     my $results_link = $basic_link."&phase=results".
         "&pause=1"."&start=1";
     return $results_link;
@@ -3140,8 +3208,8 @@
 ######################################################################
 sub print_frames_interface {
     my $r = shift;
-    my $basic_link = "/adm/searchcat?"."&table=".$ENV{'form.table'}.
-        "&persistent_db_id=".$ENV{'form.persistent_db_id'};
+    my $basic_link = "/adm/searchcat?"."&table=".$env{'form.table'}.
+        "&persistent_db_id=".$env{'form.persistent_db_id'};
     my $run_search_link = $basic_link."&phase=run_search";
     my $results_link = &results_link();
     my $html=&Apache::lonxml::xmlbegin();
@@ -3551,9 +3619,9 @@
     my ($r,$closebutton,$parms,$hidden_fields,$field)=@_;
     my $errorstring;
     if ($field eq 'basicexp') {
-        $errorstring = &mt('Unable to understand the search phrase <i>[_1]</i>.  Please modify your search.',$ENV{'form.basicexp'});
+        $errorstring = &mt('Unable to understand the search phrase <i>[_1]</i>.  Please modify your search.',$env{'form.basicexp'});
     } else {
-        $errorstring = &mt('Unable to understand the search phrase <b>[_1]</b>:<i>[_2]</i>.',$field,$ENV{'form.'.$field});
+        $errorstring = &mt('Unable to understand the search phrase <b>[_1]</b>:<i>[_2]</i>.',$field,$env{'form.'.$field});
     }
     my $bodytag = &Apache::loncommon::bodytag('Search');
     my $heading = &mt('Unparsed Field');
@@ -3575,7 +3643,7 @@
 $errorstring
 </p>
 <p>
-<a href="/adm/searchcat?$parms&persistent_db_id=$ENV{'form.persistent_db_id'}">$revise</a>
+<a href="/adm/searchcat?$parms&persistent_db_id=$env{'form.persistent_db_id'}">$revise</a>
 </p>
 </body>
 </html>
@@ -3624,7 +3692,7 @@
 $errormsg
 </p>
 <p>
-<a href="/adm/searchcat?$parms&persistent_db_id=$ENV{'form.persistent_db_id'}">$revise</a>&nbsp;
+<a href="/adm/searchcat?$parms&persistent_db_id=$env{'form.persistent_db_id'}">$revise</a>&nbsp;
 </p>
 </body>
 </html>
Index: loncom/interface/lonsimplepage.pm
diff -u loncom/interface/lonsimplepage.pm:1.24 loncom/interface/lonsimplepage.pm:1.25
--- loncom/interface/lonsimplepage.pm:1.24	Thu Feb 17 03:50:20 2005
+++ loncom/interface/lonsimplepage.pm	Thu Apr  7 02:56:23 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Simple Page Editor
 #
-# $Id: lonsimplepage.pm,v 1.24 2005/02/17 08:50:20 albertel Exp $
+# $Id: lonsimplepage.pm,v 1.25 2005/04/07 06:56:23 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -43,7 +43,7 @@
     &Apache::loncommon::content_type($r,'text/html');
     $r->send_http_header;
     return OK if $r->header_only;
-    my $target=$ENV{'form.grade_target'};
+    my $target=$env{'form.grade_target'};
 # ------------------------------------------------------------ Print the screen
     if ($target ne 'tex') {
 	my $html=&Apache::lonxml::xmlbegin();
@@ -53,11 +53,11 @@
 <title>The LearningOnline Network with CAPA</title>
 ENDDOCUMENT
     } else {
-	$r->print(&Apache::lonprintout::print_latex_header($ENV{'form.latex_type'}));
+	$r->print(&Apache::lonprintout::print_latex_header($env{'form.latex_type'}));
     } 
     my (undef,undef,undef,undef,$marker)=split(/\//,$r->uri);
 # Is this even in a course?
-    unless ($ENV{'request.course.id'}) {
+    unless ($env{'request.course.id'}) {
 	if ($target ne 'tex') {
 	    $r->print('</head><body>Not in a course</body></html>');
 	    return OK;
@@ -73,8 +73,8 @@
         return OK;
     }
 
-    my $dom = $ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
-    my $crs = $ENV{'course.'.$ENV{'request.course.id'}.'.num'};
+    my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+    my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
 
 # --------------------------------------------------------- The syllabus fields
     my %syllabusfields=&Apache::lonlocal::texthash(
@@ -88,16 +88,16 @@
                         ($ENV{'QUERY_STRING'},['forcestudent','forceedit','register']);
 # ----------------------------------------------------- Force menu registration
     my $addentries='';
-    if ($ENV{'form.register'}) {
+    if ($env{'form.register'}) {
        $addentries=' onLoad="'.&Apache::lonmenu::loadevents().
 	   '" onUnload="'.&Apache::lonmenu::unloadevents().'"';
        $r->print(&Apache::lonmenu::registerurl(1));
     }
 # --------------------------------------------------------------- Force Student
     my $forcestudent='';
-    if ($ENV{'form.forcestudent'} || $target eq 'tex' ) { $forcestudent='student'; };
+    if ($env{'form.forcestudent'} || $target eq 'tex' ) { $forcestudent='student'; };
      my $forceedit='';
-     if ($ENV{'form.forceedit'}) { $forceedit='edit'; }
+     if ($env{'form.forceedit'}) { $forceedit='edit'; }
 
 
     my %syllabus=&Apache::lonnet::dump('smppage_'.$marker,$dom,$crs);
@@ -107,10 +107,10 @@
     if ($target ne 'tex') {
 	$r->print(&Apache::lonhtmlcommon::htmlareaheaders().
 		  '</head>'.&Apache::loncommon::bodytag
-		  ("Course Page",$forcestudent,$addentries,'',$dom,$ENV{'form.register'}));
+		  ("Course Page",$forcestudent,$addentries,'',$dom,$env{'form.register'}));
     }
 
-    my $allowed=&Apache::lonnet::allowed('mdc',$ENV{'request.course.id'});
+    my $allowed=&Apache::lonnet::allowed('mdc',$env{'request.course.id'});
     my $privileged=$allowed;
     if (($syllabus{'uploaded.lastmodified'}) && (!$forceedit)) {
 	$forcestudent='student';
@@ -125,9 +125,9 @@
     } elsif ($privileged and $target ne 'tex') {
 	$r->print('<a href="'.$r->uri.'?forceedit=edit"><font size="+1">'.&mt('Edit').'</font></a>');
     } 
-    if (($ENV{'form.uploaddoc.filename'} and $target ne 'tex') &&
-	($ENV{'form.storeupl'}) && ($allowed)) {
-	if ($ENV{'form.uploaddoc.filename'}=~/\.(gif|jpg|png|jpeg)$/i) {
+    if (($env{'form.uploaddoc.filename'} and $target ne 'tex') &&
+	($env{'form.storeupl'}) && ($allowed)) {
+	if ($env{'form.uploaddoc.filename'}=~/\.(gif|jpg|png|jpeg)$/i) {
 	    if ($syllabus{'uploaded.photourl'}) {
 		&Apache::lonnet::removeuploadedurl($syllabus{'uploaded.photourl'});
 	    }
@@ -137,9 +137,9 @@
 	$syllabus{'uploaded.lastmodified'}=time;
 	&Apache::lonnet::put('smppage_'.$marker,\%syllabus,$dom,$crs);
     }
-    if (($allowed) && ($ENV{'form.storesyl'})) {
+    if (($allowed) && ($env{'form.storesyl'})) {
 	foreach (keys %syllabusfields) {
-	    my $field=$ENV{'form.'.$_};
+	    my $field=$env{'form.'.$_};
 	    chomp($field);
 	    $field=~s/\s+$//s;
 	    $field=~s/^\s+//s;
@@ -217,7 +217,7 @@
 			$r->print(&Apache::lonxml::xmlparse($r,'tex','<h1>'.$message.'</h1>'));
 		    }
 		    if ($allowed) {
-			if ($ENV{'form.grade_target'} ne 'tex') {
+			if ($env{'form.grade_target'} ne 'tex') {
 			    $r->print(
 				      '<br />Title<br /><textarea cols="80" rows="2" name="'.$_.'">'.
 				      $syllabus{$_}.
@@ -230,15 +230,15 @@
 		}
 	    }
 	}
-	if ($allowed && ($ENV{'form.grade_target'} ne 'tex')) {
+	if ($allowed && ($env{'form.grade_target'} ne 'tex')) {
 	    $r->print(&Apache::lonhtmlcommon::htmlareaselectactive
 		      ('bbb_content').'</form>');
 	}
-	if ($ENV{'form.grade_target'} ne 'tex') {$r->print('</p>');}
+	if ($env{'form.grade_target'} ne 'tex') {$r->print('</p>');}
     } else {
 	$r->print('<p>No page information provided.</p>');
     }
-    if ($ENV{'form.grade_target'} ne 'tex') {
+    if ($env{'form.grade_target'} ne 'tex') {
 	$r->print('</body></html>');
     } else {
 	$r->print('\end{document}');
Index: loncom/interface/lonsource.pm
diff -u loncom/interface/lonsource.pm:1.10 loncom/interface/lonsource.pm:1.11
--- loncom/interface/lonsource.pm:1.10	Thu Apr  7 00:46:36 2005
+++ loncom/interface/lonsource.pm	Thu Apr  7 02:56:23 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Souce Code handler
 #
-# $Id: lonsource.pm,v 1.10 2005/04/07 04:46:36 albertel Exp $
+# $Id: lonsource.pm,v 1.11 2005/04/07 06:56:23 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -31,7 +31,7 @@
 package Apache::lonsource;
 
 use strict;
-use Apache::lonnet();
+use Apache::lonnet;
 use Apache::loncommon();
 use Apache::lonhtmlcommon();
 use Apache::lonsequence();
@@ -78,12 +78,12 @@
     my $author_name;
 #Figure out if we are author or co-author
 
-    if($ENV{'request.role'} =~ m|ca.|) {
-        ($role, $domain, $author_name) = split(/\//,$ENV{'request.role'});
+    if($env{'request.role'} =~ m|ca.|) {
+        ($role, $domain, $author_name) = split(/\//,$env{'request.role'});
     } else {
         $role = "au.";
-        $domain = $ENV{'user.domain'};
-        $author_name = $ENV{'user.name'};
+        $domain = $env{'user.domain'};
+        $author_name = $env{'user.name'};
     }
 
     my $path_to_new_file = '/home/'.$author_name.'/public_html/'.$newpath.'/'.$listname;
@@ -208,28 +208,28 @@
     my $r=shift;
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
                                             ['filename','listname']);
-    my $filename = $ENV{'form.filename'};
-    my $listname = $ENV{'form.listname'};
+    my $filename = $env{'form.filename'};
+    my $listname = $env{'form.listname'};
     my $source = &Apache::lonnet::metadata($filename,'sourceavail');
     if ($source ne 'open') {
-        $ENV{'user.error.msg'}="$filename:cre:1:1:Source code not available";
+        $env{'user.error.msg'}="$filename:cre:1:1:Source code not available";
         return HTTP_NOT_ACCEPTABLE;
     } 
     if ((!&Apache::lonnet::allowed('cre',$filename)) ||
             (!&Apache::lonnet::allowed('bre',$filename))) {
-        $ENV{'user.error.msg'}="$filename:bre:1:1:Access to resource denied";
+        $env{'user.error.msg'}="$filename:bre:1:1:Access to resource denied";
         return HTTP_NOT_ACCEPTABLE;
     } 
-    if ($ENV{'form.action'} eq 'stage2') {
+    if ($env{'form.action'} eq 'stage2') {
         my $author = &Apache::lonnet::metadata($filename,'authorspace');
         ($author) = split('@',$author); #strip the domain of the author name
-        &stage_2($r, $ENV{'form.filename'}, $author, $listname);
-    } elsif($ENV{'form.action'} eq 'copy_stage') {
-        &copy_stage($r, $filename,$ENV{'form.listname'},$ENV{'form.newpath'});
-    } elsif($ENV{'form.action'} eq 'delete_confirm') {
+        &stage_2($r, $env{'form.filename'}, $author, $listname);
+    } elsif($env{'form.action'} eq 'copy_stage') {
+        &copy_stage($r, $filename,$env{'form.listname'},$env{'form.newpath'});
+    } elsif($env{'form.action'} eq 'delete_confirm') {
         &Apache::loncommon::content_type($r,'text/html');
         $r->send_http_header;
-        &delete_copy_file($r, $ENV{'form.author'}, $ENV{'form.newpath'}, $ENV{'form.filename'}, $ENV{'form.path'}, '0');
+        &delete_copy_file($r, $env{'form.author'}, $env{'form.newpath'}, $env{'form.filename'}, $env{'form.path'}, '0');
     } else {
         &Apache::loncommon::content_type($r,'text/html');
         $r->send_http_header;
@@ -241,7 +241,7 @@
                   <input type="submit" value="Copy to CSTR" />
                   </form>');
         $r->print('<hr />');
-        &print_item($r, $ENV{'form.filename'});
+        &print_item($r, $env{'form.filename'});
     }
     return OK;
 }
Index: loncom/interface/lonspeller.pm
diff -u loncom/interface/lonspeller.pm:1.10 loncom/interface/lonspeller.pm:1.11
--- loncom/interface/lonspeller.pm:1.10	Thu Feb 17 03:29:43 2005
+++ loncom/interface/lonspeller.pm	Thu Apr  7 02:56:23 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Interface routines for Aspell
 #
-# $Id: lonspeller.pm,v 1.10 2005/02/17 08:29:43 albertel Exp $
+# $Id: lonspeller.pm,v 1.11 2005/04/07 06:56:23 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -33,6 +33,7 @@
 use Apache::Constants qw(:common);
 use Text::Aspell;
 use Apache::lonlocal;
+use Apache::lonnet;
 use Apache::lontexconvert();
 use HTML::LCParser;
 use strict;
@@ -41,7 +42,7 @@
 my $insidelink;
 
 sub spellcheck_language {
-    if ($ENV{'form.lang'}) { return $ENV{'form.lang'}; }
+    if ($env{'form.lang'}) { return $env{'form.lang'}; }
     if (&mt('spellcheck_lang') ne 'spellcheck_lang') {
 	return &mt('spellcheck_lang');
     }
@@ -132,7 +133,7 @@
 	      &mt('Spell Checker').
 	      '</title></head><body bgcolor="#DDDDDD">'.
 	      &Apache::lontexconvert::msgtexconverted(
-				     &markeduptext($ENV{'form.text'})).
+				     &markeduptext($env{'form.text'})).
 	      '</body></html>');
     return OK;
 }
Index: loncom/interface/lonstatistics.pm
diff -u loncom/interface/lonstatistics.pm:1.122 loncom/interface/lonstatistics.pm:1.123
--- loncom/interface/lonstatistics.pm:1.122	Mon Mar 21 14:47:53 2005
+++ loncom/interface/lonstatistics.pm	Thu Apr  7 02:56:23 2005
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lonstatistics.pm,v 1.122 2005/03/21 19:47:53 matthew Exp $
+# $Id: lonstatistics.pm,v 1.123 2005/04/07 06:56:23 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -55,7 +55,7 @@
     @SelectedStudentData
     $enrollment_status);
 
-use Apache::lonnet();
+use Apache::lonnet;
 use Apache::lonhomework;
 use Apache::loncommon;
 use Apache::loncoursedata;
@@ -194,16 +194,16 @@
     &clear_classlist_variables();
     #
     # Retrieve the classlist
-    my $cid  = $ENV{'request.course.id'};
-    my $cdom = $ENV{'course.'.$cid.'.domain'};
-    my $cnum = $ENV{'course.'.$cid.'.num'};
+    my $cid  = $env{'request.course.id'};
+    my $cdom = $env{'course.'.$cid.'.domain'};
+    my $cnum = $env{'course.'.$cid.'.num'};
     my ($classlist,$field_names) = &Apache::loncoursedata::get_classlist($cid,
                                                                   $cdom,$cnum);
     my @selected_sections = &get_selected_sections();
     #
     # Deal with instructors with restricted section access
-    if ($ENV{'request.course.sec'} !~ /^\s*$/) {
-        @selected_sections = ($ENV{'request.course.sec'});
+    if ($env{'request.course.sec'} !~ /^\s*$/) {
+        @selected_sections = ($env{'request.course.sec'});
     }
     #
     # Set up %StudentData
@@ -217,7 +217,7 @@
     #
     # get the status requested
     $enrollment_status = 'Active';
-    $enrollment_status = $ENV{'form.Status'} if (exists($ENV{'form.Status'}));
+    $enrollment_status = $env{'form.Status'} if (exists($env{'form.Status'}));
     #
     # Process the classlist
     while (my ($student,$student_data) = each (%$classlist)) {
@@ -257,8 +257,8 @@
     }
     #
     # Put the consolidated section data in the right place
-    if ($ENV{'request.course.sec'} !~ /^\s*$/) {
-        @Sections = ($ENV{'request.course.sec'});
+    if ($env{'request.course.sec'} !~ /^\s*$/) {
+        @Sections = ($env{'request.course.sec'});
     } else {
         @Sections = sort {$a cmp $b} keys(%Sections);
         unshift(@Sections,'all'); # Put 'all' at the front of the list
@@ -266,16 +266,16 @@
     #
     # Sort the Students
     my $sortby = 'fullname';
-    $sortby = $ENV{'form.sort'} if (exists($ENV{'form.sort'}));
+    $sortby = $env{'form.sort'} if (exists($env{'form.sort'}));
     my @TmpStudents = sort { $a->{$sortby} cmp $b->{$sortby} ||
                              $a->{'fullname'} cmp $b->{'fullname'} } @Students;
     @Students = @TmpStudents;
     # 
     # Now deal with that current student thing....
     $curr_student = undef;
-    if (exists($ENV{'form.SelectedStudent'})) {
+    if (exists($env{'form.SelectedStudent'})) {
         my ($current_uname,$current_dom) = 
-            split(':',$ENV{'form.SelectedStudent'});
+            split(':',$env{'form.SelectedStudent'});
         my $i;
         for ($i = 0; $i<=$#Students; $i++) {
             next if (($Students[$i]->{'username'} ne $current_uname) || 
@@ -297,11 +297,11 @@
         }
     }
     #
-    if (exists($ENV{'form.StudentData'})) {
-        if (ref($ENV{'form.StudentData'}) eq 'ARRAY') {
-            @SelectedStudentData = @{$ENV{'form.StudentData'}};
+    if (exists($env{'form.StudentData'})) {
+        if (ref($env{'form.StudentData'}) eq 'ARRAY') {
+            @SelectedStudentData = @{$env{'form.StudentData'}};
         } else {
-            @SelectedStudentData = ($ENV{'form.StudentData'});
+            @SelectedStudentData = ($env{'form.StudentData'});
         }
     } else {
         @SelectedStudentData = ('username');
@@ -331,11 +331,11 @@
 #######################################################
 sub get_selected_sections {
     my @selected_sections;
-    if (exists($ENV{'form.Section'})) {
-        if (ref($ENV{'form.Section'})) {
-            @selected_sections = @{$ENV{'form.Section'}};
-        } elsif ($ENV{'form.Section'} !~ /^\s*$/) {
-            @selected_sections = ($ENV{'form.Section'});
+    if (exists($env{'form.Section'})) {
+        if (ref($env{'form.Section'})) {
+            @selected_sections = @{$env{'form.Section'}};
+        } elsif ($env{'form.Section'} !~ /^\s*$/) {
+            @selected_sections = ($env{'form.Section'});
         }
     }
     @selected_sections = ('all') if (! @selected_sections);
@@ -346,8 +346,8 @@
     }
     #
     # Deal with instructors with restricted section access
-    if ($ENV{'request.course.sec'} !~ /^\s*$/) {
-        @selected_sections = ($ENV{'request.course.sec'});
+    if ($env{'request.course.sec'} !~ /^\s*$/) {
+        @selected_sections = ($env{'request.course.sec'});
     }
     return @selected_sections;
 }
@@ -386,29 +386,29 @@
     if (scalar(@sections) == 1 && $sections[0] ne 'all') {
         if ($mode eq 'localized') {
             $description = &mt('Section [_1]. [_2] enrollment status.',
-                               $sections[0],$ENV{'form.Status'});
+                               $sections[0],$env{'form.Status'});
         } elsif ($mode eq 'plaintext') {
             $description = 'Section '.$sections[0].'. '.
-                $ENV{'form.Status'}.' enrollment status.';
+                $env{'form.Status'}.' enrollment status.';
         }
     } elsif (scalar(@sections) && $sections[0] eq 'all') {
         if ($mode eq 'localized') {
             $description = &mt('All sections. [_1] enrollment status.',
-                               $ENV{'form.Status'});
+                               $env{'form.Status'});
         } elsif ($mode eq 'plaintext') {
             $description = 'All sections. '.
-                $ENV{'form.Status'}.' enrollment status.';
+                $env{'form.Status'}.' enrollment status.';
         }
     } elsif (scalar(@sections)) {
         my $lastsection = pop(@sections);
         if ($mode eq 'localized') {
             $description = &mt('Sections [_1] and [_2]. [_3] enrollment status.',
                                join(', ',@sections),$lastsection,
-                               $ENV{'form.Status'});
+                               $env{'form.Status'});
         } elsif ($mode eq 'plaintext') {
             $description = 
                 'Sections '.join(', ',@sections).' and '.$lastsection.'. '.
-                $ENV{'form.Status'}.' enrollment status.';
+                $env{'form.Status'}.' enrollment status.';
         }
     }
     return $description;
@@ -570,11 +570,11 @@
 sub get_selected_maps {
     my ($elementname) = @_;
     my @selected_maps;
-    if (exists($ENV{'form.'.$elementname})) {
-        if (ref($ENV{'form.'.$elementname})) {
-            @selected_maps = @{$ENV{'form.'.$elementname}};
+    if (exists($env{'form.'.$elementname})) {
+        if (ref($env{'form.'.$elementname})) {
+            @selected_maps = @{$env{'form.'.$elementname}};
         } else {
-            @selected_maps = ($ENV{'form.'.$elementname});
+            @selected_maps = ($env{'form.'.$elementname});
         }
     } else {
         @selected_maps = ('all');
@@ -808,30 +808,30 @@
     my @selected_sections = &get_selected_sections();
     if (! @Students) {
         if ($selected_sections[0] eq 'all') { 
-            if (lc($ENV{'form.Status'}) eq 'any') {
+            if (lc($env{'form.Status'}) eq 'any') {
                 $Str .= '<h2>'.
                     &mt('There are no students in the course.').
                     '</h2>';
-            } elsif (lc($ENV{'form.Status'}) eq 'active') {
+            } elsif (lc($env{'form.Status'}) eq 'active') {
                 $Str .= '<h2>'.
                 &mt('There are no currently enrolled students in the course.').
                     '</h2>';
-            } elsif (lc($ENV{'form.Status'}) eq 'expired') {
+            } elsif (lc($env{'form.Status'}) eq 'expired') {
                 $Str .= '<h2>'.
                     &mt('There are no previously enrolled students in the course.').
                         '</h2>';
             }
         } else { 
             my $sections;
-            if (lc($ENV{'form.Status'}) eq 'any') {
+            if (lc($env{'form.Status'}) eq 'any') {
                 $Str .= '<h2>'.
                     &mt('There are no students in the selected sections.').
                     '</h2>';
-            } elsif (lc($ENV{'form.Status'}) eq 'active') {
+            } elsif (lc($env{'form.Status'}) eq 'active') {
                 $Str .= '<h2>'.
                     &mt('There are no currently enrolled students in the selected sections.').
                     '</h2>';
-            } elsif (lc($ENV{'form.Status'}) eq 'expired') {
+            } elsif (lc($env{'form.Status'}) eq 'expired') {
                 $Str .= '<h2>'.
                     &mt('There are no previously enrolled students in the selected sections.').
                     '</h2>';
@@ -872,7 +872,7 @@
             if ($field eq 'fullname' || $field eq 'username') {
                 $Str .= '<a href="/adm/statistics?reportSelected=';
                 $Str .= &Apache::lonnet::escape('student_assessment');
-                $Str .= '&sort='.&Apache::lonnet::escape($ENV{'form.sort'});
+                $Str .= '&sort='.&Apache::lonnet::escape($env{'form.sort'});
                 $Str .= '&SelectedStudent=';
                 $Str .= &Apache::lonnet::escape($sname).'">';
                 $Str .= $student->{$field}.'&nbsp';
@@ -964,16 +964,16 @@
     if ($loaderror) { return $loaderror; }
     $loaderror=
        &Apache::lonnet::overloaderror($r,
-         $ENV{'course.'.$ENV{'request.course.id'}.'.home'});
+         $env{'course.'.$env{'request.course.id'}.'.home'});
     if ($loaderror) { return $loaderror; }
     #
     # Check for access
-    if (! &Apache::lonnet::allowed('vgr',$ENV{'request.course.id'})) {
-        $ENV{'user.error.msg'}=
+    if (! &Apache::lonnet::allowed('vgr',$env{'request.course.id'})) {
+        $env{'user.error.msg'}=
             $r->uri.":vgr:0:0:Cannot view grades for complete course";
         if (! &Apache::lonnet::allowed('vgr',
-                      $ENV{'request.course.id'}.'/'.$ENV{'request.course.sec'})) {
-            $ENV{'user.error.msg'}=
+                      $env{'request.course.id'}.'/'.$env{'request.course.sec'})) {
+            $env{'user.error.msg'}=
                 $r->uri.":vgr:0:0:Cannot view grades with given role";
             return HTTP_NOT_ACCEPTABLE;
         }
@@ -1014,8 +1014,8 @@
                                             text =>'Statistics',
                                             faq=>139,
                                             bug=>'Statistics and Charts'});
-    if (! exists($ENV{'form.reportSelected'}) || 
-        $ENV{'form.reportSelected'} eq '') {
+    if (! exists($env{'form.reportSelected'}) || 
+        $env{'form.reportSelected'} eq '') {
         $r->print(&Apache::lonhtmlcommon::breadcrumbs
                   (undef,&mt('Statistics Main Page')).
                   &CreateMainMenu());
@@ -1039,8 +1039,8 @@
         }
         #
         # Clean out the caches
-        if (exists($ENV{'form.ClearCache'})) {
-            &Apache::loncoursedata::delete_caches($ENV{'requres.course.id'});
+        if (exists($env{'form.ClearCache'})) {
+            &Apache::loncoursedata::delete_caches($env{'requres.course.id'});
         }
         #
         # Begin form output
@@ -1048,7 +1048,7 @@
         $r->print('method="post" action="/adm/statistics">');
         $r->rflush();
         #
-        my $GoToPage = $ENV{'form.reportSelected'};
+        my $GoToPage = $env{'form.reportSelected'};
         #
         $r->print('<input type="hidden" name="reportSelected" value="'.
                   $GoToPage.'">');
Index: loncom/interface/lonsupportreq.pm
diff -u loncom/interface/lonsupportreq.pm:1.24 loncom/interface/lonsupportreq.pm:1.25
--- loncom/interface/lonsupportreq.pm:1.24	Wed Apr  6 23:58:02 2005
+++ loncom/interface/lonsupportreq.pm	Thu Apr  7 02:56:23 2005
@@ -1,5 +1,5 @@
 #
-# $Id: lonsupportreq.pm,v 1.24 2005/04/07 03:58:02 albertel Exp $
+# $Id: lonsupportreq.pm,v 1.25 2005/04/07 06:56:23 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -47,9 +47,9 @@
     if ($r->uri eq '/adm/helpdesk') {
         &Apache::loncommon::get_posted_cgi($r);
     }
-    my $function = $ENV{'form.function'};
-    my $origurl = &Apache::lonnet::unescape($ENV{'form.origurl'});
-    my $action = $ENV{'form.action'};
+    my $function = $env{'form.function'};
+    my $origurl = &Apache::lonnet::unescape($env{'form.origurl'});
+    my $action = $env{'form.action'};
 
     if ($action eq 'process') {
         &print_request_receipt($r,$origurl,$function);
@@ -68,16 +68,16 @@
         $tablecolor = '#EEEE99';
     }
     $ccode = '';
-    $os = $ENV{'browser.os'};
-    $browser = $ENV{'browser.type'};
-    $bversion = $ENV{'browser.version'};
-    $uhost = $ENV{'request.host'};
-    $uname = $ENV{'user.name'};
-    $udom = $ENV{'user.domain'};
-    $uhome = $ENV{'user.home'};
-    $urole = $ENV{'request.role'};
-    $usec = $ENV{'request.course.sec'};
-    $cid = $ENV{'request.course.id'};
+    $os = $env{'browser.os'};
+    $browser = $env{'browser.type'};
+    $bversion = $env{'browser.version'};
+    $uhost = $env{'request.host'};
+    $uname = $env{'user.name'};
+    $udom = $env{'user.domain'};
+    $uhome = $env{'user.home'};
+    $urole = $env{'request.role'};
+    $usec = $env{'request.course.sec'};
+    $cid = $env{'request.course.id'};
     if ($origurl =~ m-^http://-) {
         $server = $origurl;
     } else {
@@ -113,6 +113,7 @@
     }
 }
 END
+    #" stupid emacs
     if ($cid =~ m/_/) {
         ($cdom,$cnum) = split/_/,$cid;
     }
@@ -122,17 +123,17 @@
         $ccode = $csettings{'internal.coursecode'};
         $sectionlist = $csettings{'internal.sectionnums'};
     }
-    if ($ENV{'environment.critnotification'}) {
-        $email = $ENV{'environment.critnotification'};
+    if ($env{'environment.critnotification'}) {
+        $email = $env{'environment.critnotification'};
     }
-    if (!$email && $ENV{'environment.notification'}) {
-        $email = $ENV{'environment.notification'};
+    if (!$email && $env{'environment.notification'}) {
+        $email = $env{'environment.notification'};
     }
-    if ($ENV{'environment.lastname'}) {
-        $lastname = $ENV{'environment.lastname'};
+    if ($env{'environment.lastname'}) {
+        $lastname = $env{'environment.lastname'};
     }
-    if ($ENV{'environment.firstname'}) {
-        $firstname = $ENV{'environment.firstname'};
+    if ($env{'environment.firstname'}) {
+        $firstname = $env{'environment.firstname'};
     }
     my @sections = split/,/,$sectionlist;
     my %groupid = ();
@@ -142,8 +143,8 @@
     }
     my $codedom = $Apache::lonnet::perlvar{'lonDefDomain'};
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['codedom']);
-    if (exists($ENV{'form.codedom'})) {
-        $codedom = $ENV{'form.codedom'};
+    if (exists($env{'form.codedom'})) {
+        $codedom = $env{'form.codedom'};
     }
     my $details_title;
     if ($codedom) {
@@ -564,7 +565,7 @@
 	    </td>
 	   </tr>
 END
-    if (defined($ENV{'user.name'})) {
+    if (defined($env{'user.name'})) {
         $r->print(<<END);
            <tr>
             <td width="140" bgcolor="$tablecolor">
@@ -650,44 +651,44 @@
     my @formvars = ('username','email','uname','udom','sourceurl','phone','section','coursecode','title','subject','description','screenshot');
 
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},\@formvars);
-    my $coursecode = $ENV{'form.coursecode'};
+    my $coursecode = $env{'form.coursecode'};
     if ($coursecode eq '') {
-        if (defined($ENV{'form.Year'})) {
-            $coursecode .= $ENV{'form.Year'};
+        if (defined($env{'form.Year'})) {
+            $coursecode .= $env{'form.Year'};
         }
-        if (defined($ENV{'form.Semester'})) {
-            $coursecode .= $ENV{'form.Semester'};
+        if (defined($env{'form.Semester'})) {
+            $coursecode .= $env{'form.Semester'};
         }
-        if (defined($ENV{'form.Department'})) {
-            $coursecode .= $ENV{'form.Department'};
+        if (defined($env{'form.Department'})) {
+            $coursecode .= $env{'form.Department'};
         }
-        if (defined($ENV{'form.Number'})) {
-            $coursecode .= $ENV{'form.Number'};
+        if (defined($env{'form.Number'})) {
+            $coursecode .= $env{'form.Number'};
         }
     }
     my $supportmsg = qq|
-Name: $ENV{'form.username'}
-Email: $ENV{'form.email'}
-Username/domain: $ENV{'form.uname'} - $ENV{'form.udom'}
-Tel: $ENV{'form.phone'}
-Course Information: $ENV{'form.title'} - $coursecode - section: $ENV{'form.section'}
-Subject: $ENV{'form.subject'}
-Description: $ENV{'form.description'}
-URL: $ENV{'form.sourceurl'}
+Name: $env{'form.username'}
+Email: $env{'form.email'}
+Username/domain: $env{'form.uname'} - $env{'form.udom'}
+Tel: $env{'form.phone'}
+Course Information: $env{'form.title'} - $coursecode - section: $env{'form.section'}
+Subject: $env{'form.subject'}
+Description: $env{'form.description'}
+URL: $env{'form.sourceurl'}
 Date/Time: $reporttime
 
     |;
-    my $descrip = $ENV{'form.description'};
+    my $descrip = $env{'form.description'};
     $descrip =~ s#\n#<br />#g;
     my $displaymsg = qq|
-<font color="$fontcolor">Name:</font><font color="$vlinkcolor"> $ENV{'form.username'}</font><br />
-<font color="$fontcolor">Email: </font><font color="$vlinkcolor">$ENV{'form.email'}</font><br />
-<font color="$fontcolor">Username/domain: </font><font color="$vlinkcolor">$ENV{'form.uname'} - $ENV{'form.udom'}</font><br />
-<font color="$fontcolor">Tel: </font><font color="$vlinkcolor">$ENV{'form.phone'}</font><br />
-<font color="$fontcolor">Course Information: </font><font color="$vlinkcolor">$ENV{'form.title'} - $coursecode - section: $ENV{'form.section'}</font><br />
-<font color="$fontcolor">Subject: </font><font color="$vlinkcolor">$ENV{'form.subject'}</font><br />
+<font color="$fontcolor">Name:</font><font color="$vlinkcolor"> $env{'form.username'}</font><br />
+<font color="$fontcolor">Email: </font><font color="$vlinkcolor">$env{'form.email'}</font><br />
+<font color="$fontcolor">Username/domain: </font><font color="$vlinkcolor">$env{'form.uname'} - $env{'form.udom'}</font><br />
+<font color="$fontcolor">Tel: </font><font color="$vlinkcolor">$env{'form.phone'}</font><br />
+<font color="$fontcolor">Course Information: </font><font color="$vlinkcolor">$env{'form.title'} - $coursecode - section: $env{'form.section'}</font><br />
+<font color="$fontcolor">Subject: </font><font color="$vlinkcolor">$env{'form.subject'}</font><br />
 <font color="$fontcolor">Description: </font><font color="$vlinkcolor">$descrip</font><br />
-<font color="$fontcolor">URL: </font><font color="$vlinkcolor">$ENV{'form.sourceurl'}</font><br />
+<font color="$fontcolor">URL: </font><font color="$vlinkcolor">$env{'form.sourceurl'}</font><br />
 <font color="$fontcolor">Date/Time: </font><font color="$vlinkcolor">$reporttime</font><br />
     |;
     my $html=&Apache::lonxml::xmlbegin();
@@ -719,13 +720,13 @@
             $to = 'helpdesk@lon-capa.org';
         }
     }
-    if (defined($ENV{'form.email'})) {
-        if ($ENV{'form.email'} =~ m/^[^\@]+\@[^\@]+$/) {
-            $from = $ENV{'form.email'};
+    if (defined($env{'form.email'})) {
+        if ($env{'form.email'} =~ m/^[^\@]+\@[^\@]+$/) {
+            $from = $env{'form.email'};
         }
     }
 
-    my $subject = $ENV{'form.subject'};
+    my $subject = $env{'form.subject'};
     $subject =~ s#(`)#'#g;
     $subject =~ s#\$#\(\$\)#g;
     $supportmsg =~ s#(`)#'#g;
@@ -736,9 +737,9 @@
 
     my $attachmentpath = '';
     my $attachmentsize = '';
-    if (defined($ENV{'user.name'})) {
-        if ($ENV{'form.screenshot.filename'}) {
-            $attachmentsize = length($ENV{'form.screenshot'});
+    if (defined($env{'user.name'})) {
+        if ($env{'form.screenshot.filename'}) {
+            $attachmentsize = length($env{'form.screenshot'});
             if ($attachmentsize > 131072) {
                 $displaymsg .= "<br />The uploaded screenshot file ($attachmentsize bytes) included with your request exceeded the maximum allowed size - 128 KB, and has therefore been discarded.";
             } else {
@@ -749,10 +750,10 @@
 
     if ($attachmentpath =~ m-/([^/]+)$-) {
         $fname = $1;
-        $displaymsg .= "<br />An uploaded screenshot file - $fname ($attachmentsize bytes) was included in the request sent by $ENV{'user.name'} from LON-CAPA domain: $ENV{'user.domain'}";
+        $displaymsg .= "<br />An uploaded screenshot file - $fname ($attachmentsize bytes) was included in the request sent by $env{'user.name'} from LON-CAPA domain: $env{'user.domain'}";
         $supportmsg .= "\n";
         foreach (@envvars) {
-            $supportmsg .= "$_: $ENV{$_}\n";
+            $supportmsg .= "$_: $env{$_}\n";
         }
     }
  
@@ -774,23 +775,19 @@
     } else {
         my $envdata = '';
         foreach (@envvars) {
-            $envdata .= "$_: $ENV{$_}\n";
+            $envdata .= "$_: $env{$_}\n";
         }
         foreach (@loncvars) {
-            $envdata .= "$_: $ENV{$_}\n";
+            $envdata .= "$_: $env{$_}\n";
         }
         $msg->attach(Type => 'TEXT',
                      Data => $envdata);
     }
 
 ### Send it:
-    # ->send can cause an sh launch which can pass all of %ENV along
+    # ->send can cause an sh launch which can pass all of %env along
     # which can be to large for /bin/sh's little mind
-    my %oldENV=%ENV;
-    undef(%ENV);
     $msg->send('sendmail');
-    %ENV=%oldENV;
-    undef(%oldENV);
 
     if ($attachmentpath =~ m#$Apache::lonnet::perlvar{'lonDaemons'}/tmp/helprequests/(\d+)/[^/]+#) {
         unlink($attachmentpath);
@@ -844,8 +841,8 @@
                <td>
     |);
     foreach (@envvars) {
-        unless($ENV{$_} eq '') { 
-            $r->print("$_:&nbsp;<font color='$vlinkcolor'>$ENV{$_}</font>, ");
+        unless($env{$_} eq '') { 
+            $r->print("$_:&nbsp;<font color='$vlinkcolor'>$env{$_}</font>, ");
         }
     }
     $r->print("
Index: loncom/interface/lonsyllabus.pm
diff -u loncom/interface/lonsyllabus.pm:1.39 loncom/interface/lonsyllabus.pm:1.40
--- loncom/interface/lonsyllabus.pm:1.39	Thu Feb 17 03:29:43 2005
+++ loncom/interface/lonsyllabus.pm	Thu Apr  7 02:56:23 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Syllabus
 #
-# $Id: lonsyllabus.pm,v 1.39 2005/02/17 08:29:43 albertel Exp $
+# $Id: lonsyllabus.pm,v 1.40 2005/04/07 06:56:23 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -46,7 +46,7 @@
     return OK if $r->header_only;
 
 # ------------------------------------------------------------ Print the screen
-    my $target=$ENV{'form.grade_target'};
+    my $target=$env{'form.grade_target'};
     if ($target ne 'tex') {
 	my $html=&Apache::lonxml::xmlbegin();
 	$r->print(<<ENDDOCUMENT);
@@ -55,7 +55,7 @@
 <title>The LearningOnline Network with CAPA</title>
 ENDDOCUMENT
     } else {
-	$r->print(&Apache::lonprintout::print_latex_header($ENV{'form.latex_type'}));
+	$r->print(&Apache::lonprintout::print_latex_header($env{'form.latex_type'}));
     } 
     my (undef,undef,$cdom,$cnum)=split(/\//,$r->uri);
 # Is this even a course?
@@ -87,23 +87,23 @@
                         ($ENV{'QUERY_STRING'},['forcestudent','register','forceedit']);
 # ----------------------------------------------------- Force menu registration
     my $addentries='';
-    if ($ENV{'form.register'}) {
+    if ($env{'form.register'}) {
        $addentries=' onLoad="'.&Apache::lonmenu::loadevents().
 	   '" onUnload="'.&Apache::lonmenu::unloadevents().'"';
        $r->print(&Apache::lonmenu::registerurl(1));
     }
 # --------------------------------------------------------------- Force Student
     my $forcestudent='';
-    if ($ENV{'form.forcestudent'}) { $forcestudent='student'; };
+    if ($env{'form.forcestudent'}) { $forcestudent='student'; };
     my $forceedit='';
-    if ($ENV{'form.forceedit'}) { $forceedit='edit'; }
+    if ($env{'form.forceedit'}) { $forceedit='edit'; }
        
 # ------------------------------------- There is such a course, get environment
     my %courseenv=&Apache::lonnet::dump('environment',$cdom,$cnum);
     if ($target ne 'tex') {
 	$r->print(&Apache::lonhtmlcommon::htmlareaheaders().
 		  '</head>'.&Apache::loncommon::bodytag
-            ("Syllabus",$forcestudent,$addentries,'',$cdom,$ENV{'form.register'}));
+            ("Syllabus",$forcestudent,$addentries,'',$cdom,$env{'form.register'}));
 	$r->print('<h1>'.$courseenv{'description'}.'</h1><h3>'.
                  $Apache::lonnet::domaindescription{$cdom}.'</h3>');
     } else {
@@ -161,10 +161,10 @@
 
 # This handler might be called anonymously ...
 # ----------------------------------------------------- Only if not public call
-    if ($ENV{'user.environment'}) {
+    if ($env{'user.environment'}) {
 # does this user have privileges to post, etc?
-       if ($ENV{'request.course.id'}) {
-          $allowed=&Apache::lonnet::allowed('mdc',$ENV{'request.course.id'});
+       if ($env{'request.course.id'}) {
+          $allowed=&Apache::lonnet::allowed('mdc',$env{'request.course.id'});
 	  $privileged=$allowed;
 	  if (($syllabus{'uploaded.lastmodified'}) && (!$forceedit)) {
 	      $forcestudent='student';
@@ -187,9 +187,9 @@
 			&mt('Edit').'</font></a>'); 
 	  }
       }
-       if (($allowed) && ($ENV{'form.storesyl'})) {
+       if (($allowed) && ($env{'form.storesyl'})) {
 	   foreach (keys %syllabusfields) {
-               my $field=$ENV{'form.'.$_};
+               my $field=$env{'form.'.$_};
 	       chomp($field);
                $field=~s/\s+$//s;
 	       $field=~s/^\s+//s;
@@ -224,8 +224,8 @@
                   $syllabus{$_}=$field;
 	      }
            }
-           $syllabus{'uploaded.domain'}=$ENV{'user.domain'};
-           $syllabus{'uploaded.name'}=$ENV{'user.name'};
+           $syllabus{'uploaded.domain'}=$env{'user.domain'};
+           $syllabus{'uploaded.name'}=$env{'user.name'};
            $syllabus{'uploaded.lastmodified'}=time;
            &Apache::lonnet::put('syllabus',\%syllabus,$cdom,$cnum);
        }
Index: loncom/interface/lontest.pm
diff -u loncom/interface/lontest.pm:1.15 loncom/interface/lontest.pm:1.16
--- loncom/interface/lontest.pm:1.15	Tue Apr  5 16:43:27 2005
+++ loncom/interface/lontest.pm	Thu Apr  7 02:56:23 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # A debugging harness.
 #
-# $Id: lontest.pm,v 1.15 2005/04/05 20:43:27 albertel Exp $
+# $Id: lontest.pm,v 1.16 2005/04/07 06:56:23 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -39,7 +39,7 @@
 # what section the given env var is in, which is the part
 # of the env var before the first period.
 # Returns the section, or blank string for 'no section',
-# which is normal for the standard ENV vars like REQUEST_URI.
+# which is normal for the standard env vars like REQUEST_URI.
 sub section
 {
     my ($name) = @_;
@@ -101,13 +101,13 @@
     &print_hash($r,\%env);
     &print_hash($r,\%ENV);
 # ------------------------------------------------ If in a course, print hashes
-    if ($ENV{'request.course.id'}) {
+    if ($env{'request.course.id'}) {
 
 	my %parmhash;
 	my %symbhash;
 	my %hash;
 
-	my $fn=$ENV{'request.course.fn'};
+	my $fn=$env{'request.course.fn'};
 
 	if (tie(%hash,'GDBM_File',"$fn.db",&GDBM_READER(),0640)) {
 	    $r->print('<h2>Big Hash</h2>');
@@ -119,7 +119,7 @@
 	    $r->print('<h2>Count not tie big hash</h2>');
 	}
 	if (tie(%parmhash,'GDBM_File',
-		$ENV{'request.course.fn'}.'_parms.db',
+		$env{'request.course.fn'}.'_parms.db',
 		&GDBM_READER(),0640)) {
 	    $r->print('<h2>Parm Hash</h2>');
 	    foreach (sort keys %parmhash) {
Index: loncom/interface/lontrackstudent.pm
diff -u loncom/interface/lontrackstudent.pm:1.14 loncom/interface/lontrackstudent.pm:1.15
--- loncom/interface/lontrackstudent.pm:1.14	Thu Feb 17 03:29:43 2005
+++ loncom/interface/lontrackstudent.pm	Thu Apr  7 02:56:23 2005
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lontrackstudent.pm,v 1.14 2005/02/17 08:29:43 albertel Exp $
+# $Id: lontrackstudent.pm,v 1.15 2005/04/07 06:56:23 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -45,7 +45,7 @@
 use strict;
 use Apache::Constants qw(:common :http);
 use Apache::lonmysql;
-use Apache::lonnet();
+use Apache::lonnet;
 use Apache::lonlocal;
 use Time::HiRes;
 
@@ -72,7 +72,7 @@
     my $query = &build_query($mode);
     ##
     ## Send it along
-    my $home = $ENV{'course.'.$ENV{'request.course.id'}.'.home'};
+    my $home = $env{'course.'.$env{'request.course.id'}.'.home'};
     my $reply=&Apache::lonnet::metadata_query($query,undef,undef,[$home]);
     if (ref($reply) ne 'HASH') {
         $r->print('<h2>'.
@@ -112,10 +112,10 @@
 }
 
 sub table_names {
-    my $cid = $ENV{'request.course.id'};
-    my $domain = $ENV{'course.'.$cid.'.domain'};
-    my $home = $ENV{'course.'.$cid.'.home'};
-    my $course = $ENV{'course.'.$cid.'.num'};
+    my $cid = $env{'request.course.id'};
+    my $domain = $env{'course.'.$cid.'.domain'};
+    my $home = $env{'course.'.$cid.'.home'};
+    my $course = $env{'course.'.$cid.'.num'};
     my $prefix = $course.'_'.$domain.'_';
     #
     my %tables = 
@@ -132,7 +132,7 @@
     my %table = &table_names();
     my $query = qq{SELECT MAX(time) FROM $table{'activity'} };
     #
-    my $home = $ENV{'course.'.$ENV{'request.course.id'}.'.home'};
+    my $home = $env{'course.'.$env{'request.course.id'}.'.home'};
     my $reply=&Apache::lonnet::metadata_query($query,undef,undef,[$home]);
     if (ref($reply) ne 'HASH') {
         return undef;
@@ -183,10 +183,10 @@
 
 sub build_query {
     my ($mode) = @_;
-    my $cid = $ENV{'request.course.id'};
-    my $domain = $ENV{'course.'.$cid.'.domain'};
-    my $home = $ENV{'course.'.$cid.'.home'};
-    my $course = $ENV{'course.'.$cid.'.num'};
+    my $cid = $env{'request.course.id'};
+    my $domain = $env{'course.'.$cid.'.domain'};
+    my $home = $env{'course.'.$cid.'.home'};
+    my $course = $env{'course.'.$cid.'.num'};
     my $prefix = $course.'_'.$domain.'_';
     #
     my %table = &table_names();
@@ -394,10 +394,10 @@
 ###################################################################
 sub request_data_update {
     my $command = 'prepare activity log';
-    my $cid = $ENV{'request.course.id'};
-    my $domain = $ENV{'course.'.$cid.'.domain'};
-    my $home = $ENV{'course.'.$cid.'.home'};
-    my $course = $ENV{'course.'.$cid.'.num'};
+    my $cid = $env{'request.course.id'};
+    my $domain = $env{'course.'.$cid.'.domain'};
+    my $home = $env{'course.'.$cid.'.home'};
+    my $course = $env{'course.'.$cid.'.num'};
 #    &Apache::lonnet::logthis($command.' '.$course.' '.$domain.' '.$home);
     my $result = &Apache::lonnet::metadata_query($command,$course,$domain,
                                                  [$home]);
@@ -463,18 +463,18 @@
     $loaderror=
         &Apache::lonnet::overloaderror
         ($r,
-         $ENV{'course.'.$ENV{'request.course.id'}.'.home'});
+         $env{'course.'.$env{'request.course.id'}.'.home'});
     if ($loaderror) { return $loaderror; }
     #
     # Check for access
-    if (! &Apache::lonnet::allowed('vsa',$ENV{'request.course.id'})) {
-        $ENV{'user.error.msg'}=
+    if (! &Apache::lonnet::allowed('vsa',$env{'request.course.id'})) {
+        $env{'user.error.msg'}=
             $r->uri.":vsa:0:0:Cannot student activity for complete course";
         if (! 
             &Apache::lonnet::allowed('vsa',
-                                     $ENV{'request.course.id'}.'/'.
-                                     $ENV{'request.course.sec'})) {
-            $ENV{'user.error.msg'}=
+                                     $env{'request.course.id'}.'/'.
+                                     $env{'request.course.sec'})) {
+            $env{'user.error.msg'}=
                 $r->uri.":vsa:0:0:Cannot view student activity with given role";
             return HTTP_NOT_ACCEPTABLE;
         }
@@ -526,10 +526,10 @@
     #
     my $result = &request_data_update();
     #
-    if (exists($ENV{'form.selected_student'})) {
+    if (exists($env{'form.selected_student'})) {
         # For now, just show all the data, in the future allow selection of
         # a student
-        my ($sname,$sdom) = split(':',$ENV{'form.selected_student'});
+        my ($sname,$sdom) = split(':',$env{'form.selected_student'});
         if ($sname =~ /^\w*$/ && $sdom =~ /^\w*$/) {
             $r->print('<h2>'.
                       &mt('Recent activity of [_1]@[_2]',$sname,$sdom).
@@ -539,7 +539,7 @@
 It may be necessary to reload this page to get the most current information.
 END
             &get_data($r,\%prog_state,$navmap,
-                      'student:'.$ENV{'form.selected_student'});
+                      'student:'.$env{'form.selected_student'});
         } else {
             $r->print('<h2>'.&mt('Unable to process for [_1]@[_2]',
                                  $sname,$sdom).'</h2>');
Index: loncom/interface/lonviewclasslist.pm
diff -u loncom/interface/lonviewclasslist.pm:1.4 loncom/interface/lonviewclasslist.pm:1.5
--- loncom/interface/lonviewclasslist.pm:1.4	Thu Feb 17 03:29:43 2005
+++ loncom/interface/lonviewclasslist.pm	Thu Apr  7 02:56:23 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to display the classlist 
 #
-# $Id: lonviewclasslist.pm,v 1.4 2005/02/17 08:29:43 albertel Exp $
+# $Id: lonviewclasslist.pm,v 1.5 2005/04/07 06:56:23 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -36,6 +36,7 @@
 use Apache::lonhtmlcommon();
 use Apache::Constants qw(:common :http REDIRECT);
 use Apache::lonlocal;
+use Apache::lonnet;
 
 
 ###################################################################
@@ -67,8 +68,8 @@
           text=>"View Classlist",
           faq=>9,bug=>'Instructor Interface',});
     #  Needs to be in a course
-    if (! ($ENV{'request.course.fn'})) {
-        $ENV{'user.error.msg'}=
+    if (! ($env{'request.course.fn'})) {
+        $env{'user.error.msg'}=
             "/adm/viewclasslist:not in course role";
         return HTTP_NOT_ACCEPTABLE; 
     }
@@ -89,7 +90,7 @@
 ENDHEADER
     #
     # Print classlist
-    my $cid = $ENV{'request.course.id'};
+    my $cid = $env{'request.course.id'};
     my $viewpermission = 'course.'.$cid.'.student_classlist_view';
     if (&allowed_to_view_classlist()) {
         $r->print(&html_classlist());
@@ -105,12 +106,12 @@
 }
 
 sub allowed_to_view_classlist {
-    return 0 if (! exists($ENV{'request.course.id'}));
-    my $cid = $ENV{'request.course.id'};
+    return 0 if (! exists($env{'request.course.id'}));
+    my $cid = $env{'request.course.id'};
     my $viewpermission = 'course.'.$cid.'.student_classlist_view';
-    if (exists($ENV{$viewpermission}) &&
-        $ENV{$viewpermission} =~ /^(all|section)$/) {
-        return $ENV{$viewpermission};
+    if (exists($env{$viewpermission}) &&
+        $env{$viewpermission} =~ /^(all|section)$/) {
+        return $env{$viewpermission};
     } else {
         return 0;
     }
@@ -120,13 +121,13 @@
     my $limit_to_section = (&allowed_to_view_classlist()=~ /^section$/i);
     my $Str;
     if ($limit_to_section) {
-        if ($ENV{'request.course.sec'} eq '') {
+        if ($env{'request.course.sec'} eq '') {
             $Str .= '<h2>'.
                 &mt('Students with no section').'</h2>';
         } else {
             $Str.='<h2>'.
                 &mt('Students in section "[_1]"',
-                    $ENV{'request.course.sec'}).
+                    $env{'request.course.sec'}).
                     '</h2>';
         }
     }
@@ -166,7 +167,7 @@
         my $status   = $classlist->{$student}->[$statusidx];
         next if (lc($status) ne 'active');
         if ($limit_to_section) {
-            if ($section ne $ENV{'request.course.sec'}) {
+            if ($section ne $env{'request.course.sec'}) {
                 next;
             }
         }
Index: loncom/interface/lonwhatsnew.pm
diff -u loncom/interface/lonwhatsnew.pm:1.4 loncom/interface/lonwhatsnew.pm:1.5
--- loncom/interface/lonwhatsnew.pm:1.4	Thu Apr  7 00:22:03 2005
+++ loncom/interface/lonwhatsnew.pm	Thu Apr  7 02:56:23 2005
@@ -1,5 +1,5 @@
 #
-# $Id: lonwhatsnew.pm,v 1.4 2005/04/07 04:22:03 albertel Exp $
+# $Id: lonwhatsnew.pm,v 1.5 2005/04/07 06:56:23 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -47,16 +47,16 @@
     my $r = shift;
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['command']);
 
-    my $command = $ENV{'form.command'};
+    my $command = $env{'form.command'};
 
     if ($command eq '') {
         $command = "info";
     }
 
     $r->print(&display_header());
-    if (! (($ENV{'request.course.fn'}) && (&Apache::lonnet::allowed('vsa',$ENV{'request.course.id'})))) {
+    if (! (($env{'request.course.fn'}) && (&Apache::lonnet::allowed('vsa',$env{'request.course.id'})))) {
         # Not in a course, or not allowed to modify parms
-        $ENV{'user.error.msg'}="/adm/whatsnew:vsa:0:0:Cannot display student activity";
+        $env{'user.error.msg'}="/adm/whatsnew:vsa:0:0:Cannot display student activity";
         return HTTP_NOT_ACCEPTABLE;
     }
 
@@ -213,10 +213,10 @@
 
     my $domain=&Apache::loncommon::determinedomain();
     my $function;
-    if ($ENV{'request.role'}=~/^(cc|in|ta|ep)/) {
+    if ($env{'request.role'}=~/^(cc|in|ta|ep)/) {
         $function='coordinator';
     }
-    if ($ENV{'request.role'}=~/^(su|dc|ad|li)/) {
+    if ($env{'request.role'}=~/^(su|dc|ad|li)/) {
         $function='admin';
     }
 
@@ -226,7 +226,7 @@
     &getitems(\%unread,\%ungraded,\%bombed,\@newdiscussions,\@tograde,\@bombs);
     my ($msgcount,$critmsgcount) = &getmail(\@newmsgs,\@critmsgs);
 
-    unless ($ENV{'request.course.id'}) {
+    unless ($env{'request.course.id'}) {
         $r->print('<br /><b><center>You are accessing an invalid course</center></b><br /><br />');
         return;
     }
@@ -405,9 +405,9 @@
     my $navmap = Apache::lonnavmaps::navmap->new();
     my @allres=$navmap->retrieveResources();
     my %discussiontime = &Apache::lonnet::dump('discussiontimes',
-               $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
-               $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
-    my %lastread = &Apache::lonnet::dump('nohist_'.$ENV{'request.course.id'}.'_discuss',$ENV{'user.domain'},$ENV{'user.name'},'lastread');
+               $env{'course.'.$env{'request.course.id'}.'.domain'},
+               $env{'course.'.$env{'request.course.id'}.'.num'});
+    my %lastread = &Apache::lonnet::dump('nohist_'.$env{'request.course.id'}.'_discuss',$env{'user.domain'},$env{'user.name'},'lastread');
     my %lastreadtime = ();
     my @discussions = ();
     my ($classlist,$keylist) = &Apache::loncoursedata::get_classlist();
@@ -441,9 +441,9 @@
             if (defined($lastreadtime{$ressymb})) {
                 $prevread = $lastreadtime{$ressymb};
             }
-            my %contrib = &Apache::lonnet::restore($ressymb,$ENV{'request.course.id'},
-            $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
-            $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+            my %contrib = &Apache::lonnet::restore($ressymb,$env{'request.course.id'},
+            $env{'course.'.$env{'request.course.id'}.'.domain'},
+            $env{'course.'.$env{'request.course.id'}.'.num'});
             if ($contrib{'version'}) {
                 for (my $id=1;$id<=$contrib{'version'};$id++) {
                     unless (($contrib{'hidden'}=~/\.$id\./) || ($contrib{'deleted'}=~/\.$id\./)) {
@@ -510,7 +510,7 @@
 	my $msgid=&Apache::lonnet::escape($message);
         my ($sendtime,$shortsubj,$fromname,$fromdom,$fromcid,$status)=
             &Apache::lonmsg::unpackmsgid($msgid);
-        if ($fromcid eq $ENV{'request.course.id'}) {
+        if ($fromcid eq $env{'request.course.id'}) {
             if (defined($sendtime) && $sendtime!~/error/) {
                 my $numsendtime = $sendtime;
                 $sendtime = &Apache::lonlocal::locallocaltime($sendtime);
@@ -535,7 +535,7 @@
     foreach my $msgid (sort(keys(%what))) {
         my ($sendtime,$shortsubj,$fromname,$fromdom,$fromcid,$status)=
             &Apache::lonmsg::unpackmsgid($_);
-        if ($fromcid eq  $ENV{'request.course.id'}) {
+        if ($fromcid eq  $env{'request.course.id'}) {
             if (defined($sendtime) && $sendtime!~/error/) {
                 my $numsendtime = $sendtime;
                 $sendtime = &Apache::lonlocal::locallocaltime($sendtime);
Index: loncom/interface/portfolio.pm
diff -u loncom/interface/portfolio.pm:1.81 loncom/interface/portfolio.pm:1.82
--- loncom/interface/portfolio.pm:1.81	Thu Apr  7 00:46:36 2005
+++ loncom/interface/portfolio.pm	Thu Apr  7 02:56:23 2005
@@ -29,6 +29,7 @@
 use Apache::lontexconvert;
 use Apache::lonfeedback;
 use Apache::lonlocal;
+use Apache::lonnet;
 
 # receives a file name and path stub from username/userfiles/portfolio/
 # returns an anchor tag consisting encoding filename and currentpath
@@ -46,9 +47,9 @@
     my $displayOut = '<form method="post" enctype="multipart/form-data">';
     $displayOut .= '<input name="uploaddoc" type="file" />'.
         '<input type="hidden" name="currentpath" value="'.$current_path.'" />'.
-        '<input type="hidden" name="action" value="'.$ENV{"form.action"}.'" />'.
-        '<input type="hidden" name="fieldname" value="'.$ENV{"form.fieldname"}.'" />'.
-        '<input type="hidden" name="mode" value="'.$ENV{"form.mode"}.'" />'. 
+        '<input type="hidden" name="action" value="'.$env{"form.action"}.'" />'.
+        '<input type="hidden" name="fieldname" value="'.$env{"form.fieldname"}.'" />'.
+        '<input type="hidden" name="mode" value="'.$env{"form.mode"}.'" />'. 
         '<input type="submit" name="storeupl" value="Upload" />'.
         '</form>';
     $r->print($displayOut);
@@ -56,25 +57,25 @@
     $displayOut = '<form method="post">';
     $displayOut .= '<input name="newdir" type="input" />'.
         '<input type="hidden" name="currentpath" value="'.$current_path.'" />'.
-        '<input type="hidden" name="action" value="'.$ENV{"form.action"}.'" />'.
-        '<input type="hidden" name="fieldname" value="'.$ENV{"form.fieldname"}.'" />'.
-        '<input type="hidden" name="mode" value="'.$ENV{"form.mode"}.'" />'. 
+        '<input type="hidden" name="action" value="'.$env{"form.action"}.'" />'.
+        '<input type="hidden" name="fieldname" value="'.$env{"form.fieldname"}.'" />'.
+        '<input type="hidden" name="mode" value="'.$env{"form.mode"}.'" />'. 
         '<input type="submit" name="createdir" value="'.&mt("Create Directory").'" />'.
         '</form>';
     $r->print($displayOut);
     $r->print('</td></tr></table>');
     my @tree = split (/\//,$current_path);
-    $r->print('<font size="+2">'.&make_anchor('portfolio','/',$ENV{"form.mode"},$ENV{"form.fieldname"}).'/');
+    $r->print('<font size="+2">'.&make_anchor('portfolio','/',$env{"form.mode"},$env{"form.fieldname"}).'/');
     if (@tree > 1){
         my $newCurrentPath = '';
         for (my $i = 1; $i< @tree; $i++){
             $newCurrentPath .= $tree[$i].'/';
-            $r->print(&make_anchor($tree[$i],'/'.$newCurrentPath, $ENV{"form.mode"},$ENV{"form.fieldname"}).'/');
+            $r->print(&make_anchor($tree[$i],'/'.$newCurrentPath, $env{"form.mode"},$env{"form.fieldname"}).'/');
         }
     }
     $r->print('</font>');
     &Apache::lonhtmlcommon::store_recent('portfolio',$current_path,$current_path);
-    $r->print('<br /><form method=post action="/adm/portfolio?mode='.$ENV{"form.mode"}.'&fieldname='.$ENV{"form.fieldname"}.'">'.
+    $r->print('<br /><form method=post action="/adm/portfolio?mode='.$env{"form.mode"}.'&fieldname='.$env{"form.fieldname"}.'">'.
 	      &Apache::lonhtmlcommon::select_recent('portfolio','currentpath',
 						    'this.form.submit();'));
     $r->print("</form>");
@@ -85,10 +86,10 @@
     my $display_out;
     my $select_mode;
     my $checked_files;
-    my %locked_files = &Apache::lonnet::get_marked_as_readonly_hash ($ENV{'user.domain'},$ENV{'user.name'});
-    if ($ENV{"form.mode"} eq 'selectfile'){
+    my %locked_files = &Apache::lonnet::get_marked_as_readonly_hash ($env{'user.domain'},$env{'user.name'});
+    if ($env{"form.mode"} eq 'selectfile'){
 	&select_files($r);
-	$checked_files =&Apache::lonnet::files_in_path($ENV{'user.name'},$ENV{'form.currentpath'});
+	$checked_files =&Apache::lonnet::files_in_path($env{'user.name'},$env{'form.currentpath'});
 	$select_mode = 'true';
     } 
     if ($is_empty && ($current_path ne '/')) {
@@ -111,8 +112,8 @@
             '<tr><th colspan="2">Actions</th><th>&nbsp;</th><th>Name</th><th>Size</th><th>Last Modified</th></tr>');
         $r->print('<form method="post" action="/adm/portfolio">');
     }
-    my $href_location="/uploaded/$ENV{'user.domain'}/$ENV{'user.name'}/portfolio$current_path";
-    my $href_edit_location="/editupload/$ENV{'user.domain'}/$ENV{'user.name'}/portfolio$current_path";
+    my $href_location="/uploaded/$env{'user.domain'}/$env{'user.name'}/portfolio$current_path";
+    my $href_edit_location="/editupload/$env{'user.domain'}/$env{'user.name'}/portfolio$current_path";
     foreach my $line (sort 
 		      { 
 			  my ($afile)=split('&',$a,2);
@@ -131,7 +132,7 @@
                     $r->print('<tr bgcolor="#FFAA99"><td colspan="2"><img src="'.$iconpath.'folder_closed.gif"></td>');
                 }
                 $r->print('<td>Go to ...</td>');
-                $r->print('<td>'.&make_anchor($filename.'/',$current_path.$filename.'/',$ENV{'form.mode'},$ENV{"form.fieldname"}).'</td>'); 
+                $r->print('<td>'.&make_anchor($filename.'/',$current_path.$filename.'/',$env{'form.mode'},$env{"form.fieldname"}).'</td>'); 
                 $r->print('</tr>'); 
             } else {
                 $r->print('<tr bgcolor="#CCCCFF">');
@@ -163,7 +164,7 @@
     if ($select_mode eq 'true') {
         $r->print('</table>
             <input type="hidden" name="continue" value="true">
-            <input type="hidden" name="fieldname" value="'.$ENV{'form.fieldname'}.'">
+            <input type="hidden" name="fieldname" value="'.$env{'form.fieldname'}.'">
             <input type="hidden" name="mode" value="selectfile">
             <input type="submit" name="submit" value="Select checked files, and continue selecting." /><br />
             <input type="button" name="doit" onClick= "finishSelect();" value="Select checked files, and close window" />
@@ -183,14 +184,14 @@
     my @files=&Apache::loncommon::get_env_multiple('form.selectfile');
     $r->print('<form method="post" action="/adm/portfolio">');
     $r->print('<input type="hidden" name="action" value="'.
-	      $ENV{'form.action'}.'" />');
+	      $env{'form.action'}.'" />');
     $r->print('<input type="hidden" name="confirmed" value="1" />');
     foreach (@files) {
         $r->print('<input type="hidden" name="selectfile" value="'.
 	      $_.'" />');
     }
     $r->print('<input type="hidden" name="currentpath" value="'.
-	      $ENV{'form.currentpath'}.'" />');
+	      $env{'form.currentpath'}.'" />');
 }
 
 sub close_form {
@@ -200,7 +201,7 @@
     $r->print('<form action="/adm/portfolio" method="POST">
                <p>
               <input type="hidden" name="currentpath" value="'.
-	      $ENV{'form.currentpath'}.'" />
+	      $env{'form.currentpath'}.'" />
                  <input type="submit" value="'.&mt('Cancel').'" />
                </p></form>');
 
@@ -209,9 +210,9 @@
 sub display_file {
     my ($path,$filename)=@_;
     my $display_file_text;
-    if (!defined($path)) { $path=$ENV{'form.currentpath'}; }
+    if (!defined($path)) { $path=$env{'form.currentpath'}; }
     if (!defined($filename)) { 
-        $filename=$ENV{'form.selectfile'};
+        $filename=$env{'form.selectfile'};
         $display_file_text = '<tt>'.$path.$filename.'</tt>';
     } elsif (ref($filename) eq "ARRAY") {
         foreach (@$filename) {
@@ -229,19 +230,19 @@
         $message='Done';
     }
     return ('<h3><a href="/adm/portfolio?currentpath='.
-	    $ENV{'form.currentpath'}.
-	    '&fieldname='.$ENV{'form.fieldname'}.
-	    '&mode='.$ENV{'form.mode'}.
+	    $env{'form.currentpath'}.
+	    '&fieldname='.$env{'form.fieldname'}.
+	    '&mode='.$env{'form.mode'}.
 	    '">'.&mt($message).'</a></h3>');
 }
 
 sub delete {
     my ($r)=@_;
     my @check;
-    my $file_name = $ENV{'form.currentpath'}.$ENV{'form.selectfile'};
+    my $file_name = $env{'form.currentpath'}.$env{'form.selectfile'};
     my @files=&Apache::loncommon::get_env_multiple('form.selectfile');
 
-    if (&Apache::lonnet::is_locked($file_name,$ENV{'user.domain'},$ENV{'user.name'} ) eq 'true') {
+    if (&Apache::lonnet::is_locked($file_name,$env{'user.domain'},$env{'user.name'} ) eq 'true') {
         $r->print ("The file is locked and cannot be deleted.<br />");
         $r->print(&done('Back'));
     } else {
@@ -261,9 +262,9 @@
     my @files=&Apache::loncommon::get_env_multiple('form.selectfile');
     my $result;
     foreach my $delete_file (@files) {
-        $result=&Apache::lonnet::removeuserfile($ENV{'user.name'},
-					       $ENV{'user.domain'},'portfolio'.
-					       $ENV{'form.currentpath'}.
+        $result=&Apache::lonnet::removeuserfile($env{'user.name'},
+					       $env{'user.domain'},'portfolio'.
+					       $env{'form.currentpath'}.
 					       $delete_file);
         if ($result ne 'ok') {
 	$r->print('<font color="red"> An error occured ('.$result.
@@ -282,10 +283,10 @@
 
 sub delete_dir_confirmed {
     my ($r)=@_;
-    my $directory_name = $ENV{'form.currentpath'};
+    my $directory_name = $env{'form.currentpath'};
     $directory_name =~ s|/$||; # remove any trailing slash
-    my $result=&Apache::lonnet::removeuserfile($ENV{'user.name'},
-					       $ENV{'user.domain'},'portfolio'.
+    my $result=&Apache::lonnet::removeuserfile($env{'user.name'},
+					       $env{'user.domain'},'portfolio'.
 					       $directory_name);
 					       
     if ($result ne 'ok') {
@@ -302,15 +303,15 @@
         for (my $i=1; $i < (@dirs - 1); $i ++){
             $directory_name .= $dirs[$i].'/';
         }
-        $ENV{'form.currentpath'} = $directory_name;
+        $env{'form.currentpath'} = $directory_name;
     }
     $r->print(&done());
 }
 
 sub rename {
     my ($r)=@_;
-    my $file_name = $ENV{'form.currentpath'}.$ENV{'form.rename'};
-    if (&Apache::lonnet::is_locked($file_name,$ENV{'user.domain'},$ENV{'user.name'}) eq 'true') {
+    my $file_name = $env{'form.currentpath'}.$env{'form.rename'};
+    if (&Apache::lonnet::is_locked($file_name,$env{'user.domain'},$env{'user.name'}) eq 'true') {
         $r->print ("The file is locked and cannot be renamed.<br />");
         $r->print(&done());
     } else {
@@ -323,7 +324,7 @@
 
 sub rename_confirmed {
     my ($r)=@_;
-    my $filenewname=&Apache::lonnet::clean_filename($ENV{'form.filenewname'});
+    my $filenewname=&Apache::lonnet::clean_filename($env{'form.filenewname'});
     if ($filenewname eq '') {
 	$r->print('<font color="red">'.
 		  &mt("Error: no valid filename was provided to rename to.").
@@ -332,33 +333,33 @@
 	return;
     } 
     my $result=
-	&Apache::lonnet::renameuserfile($ENV{'user.name'},$ENV{'user.domain'},
-            'portfolio'.$ENV{'form.currentpath'}.$ENV{'form.selectfile'},
-            'portfolio'.$ENV{'form.currentpath'}.$filenewname);
+	&Apache::lonnet::renameuserfile($env{'user.name'},$env{'user.domain'},
+            'portfolio'.$env{'form.currentpath'}.$env{'form.selectfile'},
+            'portfolio'.$env{'form.currentpath'}.$filenewname);
     if ($result ne 'ok') {
 	$r->print('<font color="red"> An errror occured ('.$result.
 		  ') while trying to rename '.&display_file().' to '.
 		  &display_file(undef,$filenewname).'</font><br />');
     }
-    if ($filenewname ne $ENV{'form.filenewname'}) {
-        $r->print("The new file name was changed from:<br /><strong>".$ENV{'form.filenewname'}."</strong> to <strong>$filenewname </strong>");
+    if ($filenewname ne $env{'form.filenewname'}) {
+        $r->print("The new file name was changed from:<br /><strong>".$env{'form.filenewname'}."</strong> to <strong>$filenewname </strong>");
     }
     $r->print(&done());
 }
 sub select_files {
     my ($r)=@_;
-    if ($ENV{'form.continue'} eq 'true') {
+    if ($env{'form.continue'} eq 'true') {
         # here we update the selections for the currentpath
         # eventually, have to handle removing those not checked, but . . . 
         my @items=&Apache::loncommon::get_env_multiple('form.selectfile');
-        &Apache::lonnet::save_selected_files($ENV{'user.name'}, $ENV{'form.currentpath'}, @items);
+        &Apache::lonnet::save_selected_files($env{'user.name'}, $env{'form.currentpath'}, @items);
     } else {
-        if ($ENV{'form.currentpath'} eq '/') {
+        if ($env{'form.currentpath'} eq '/') {
             #empty the file for a fresh start
-            # &Apache::lonnet::clear_selected_files($ENV{'user.name'});
+            # &Apache::lonnet::clear_selected_files($env{'user.name'});
         }
     }
-    my @files = &Apache::lonnet::files_not_in_path($ENV{'user.name'}, $ENV{'form.currentpath'});
+    my @files = &Apache::lonnet::files_not_in_path($env{'user.name'}, $env{'form.currentpath'});
     my $java_files = join ",", @files;
     if ($java_files) {
         $java_files.=',';
@@ -376,7 +377,7 @@
             }
             opener.document.forms.lonhomework.
 ENDSMP
-    $javascript .= $ENV{'form.fieldname'};
+    $javascript .= $env{'form.fieldname'};
     $javascript .= (<<ENDSMP);
         .value=fileList;
             self.close();
@@ -387,35 +388,35 @@
     $r->print("<h1>Select portfolio files</h1>
                 Check as many as you wish in response to the essay problem.<br />");
     $r->print("<strong>Files selected from other directories:</strong><br />");
-    foreach (&Apache::lonnet::files_not_in_path($ENV{'user.name'}, $ENV{'form.currentpath'})) {
+    foreach (&Apache::lonnet::files_not_in_path($env{'user.name'}, $env{'form.currentpath'})) {
         $r->print($_."<br />");
     }
 }
 sub upload {
     my ($r)=@_;
-    my $fname=$ENV{'form.uploaddoc.filename'};
-    my $filesize = (length($ENV{'form.uploaddoc'})) / 1000; #express in k (1024?)
+    my $fname=$env{'form.uploaddoc.filename'};
+    my $filesize = (length($env{'form.uploaddoc'})) / 1000; #express in k (1024?)
     my $disk_quota = 20000; # expressed in k
     $fname=&Apache::lonnet::clean_filename($fname);
-    my $portfolio_root = &Apache::loncommon::propath($ENV{'user.domain'},
-						 $ENV{'user.name'}).
+    my $portfolio_root = &Apache::loncommon::propath($env{'user.domain'},
+						 $env{'user.name'}).
 						'/userfiles/portfolio';
     # Fixme --- Move the checking for existing file to LOND error return
-    my @dir_list=&Apache::lonnet::dirlist($ENV{'form.currentpath'},
-					  $ENV{'user.domain'},
-					  $ENV{'user.name'},$portfolio_root);
+    my @dir_list=&Apache::lonnet::dirlist($env{'form.currentpath'},
+					  $env{'user.domain'},
+					  $env{'user.name'},$portfolio_root);
     my $found_file = 0;
     my $locked_file = 0;
     foreach my $line (@dir_list) {
         my ($file_name)=split(/\&/,$line,2);
         if ($file_name eq $fname){
             $found_file = 1;
-            if (&Apache::lonnet::is_locked($ENV{'form.currentpath'}.$file_name,$ENV{'user.domain'},$ENV{'user.name'} ) eq 'true') {
+            if (&Apache::lonnet::is_locked($env{'form.currentpath'}.$file_name,$env{'user.domain'},$env{'user.name'} ) eq 'true') {
                 $locked_file = 1;
             } 
         }
     }
-    my $current_disk_usage = &Apache::lonnet::diskusage($ENV{'user.domain'}, $ENV{'user.name'},$portfolio_root);
+    my $current_disk_usage = &Apache::lonnet::diskusage($env{'user.domain'}, $env{'user.name'},$portfolio_root);
     if ((($current_disk_usage/1000) + $filesize) > $disk_quota){
         $r->print('<font color="red">Unable to upload <strong>'.$fname.' (size = '.$filesize.' kilobytes</strong>. Disk quota will be exceeded.'.
                   '<br />Disk quota is '.$disk_quota.' kilobytes. Your current disk usage is '.$current_disk_usage.' kilobytes.');
@@ -423,17 +424,17 @@
     } 
     elsif ($found_file){
         if ($locked_file){
-            $r->print('<font color="red">Unable to upload <strong>'.$fname.'</strong>, a <strong>locked</strong> file by that name was found in <strong>portfolio'.$ENV{'form.currentpath'}.'</strong></font>'.
+            $r->print('<font color="red">Unable to upload <strong>'.$fname.'</strong>, a <strong>locked</strong> file by that name was found in <strong>portfolio'.$env{'form.currentpath'}.'</strong></font>'.
                   '<br />You will be able to rename or delete existing '.$fname.' after a grade has been assigned.');
             $r->print(&done('Back'));      
         } else {   
-            $r->print('<font color="red">Unable to upload <strong>'.$fname.'</strong>, a file by that name was found in <strong>portfolio'.$ENV{'form.currentpath'}.'</strong></font>'.
-                  '<br />To upload, rename or delete existing '.$fname.' in portfolio'.$ENV{'form.currentpath'});
+            $r->print('<font color="red">Unable to upload <strong>'.$fname.'</strong>, a file by that name was found in <strong>portfolio'.$env{'form.currentpath'}.'</strong></font>'.
+                  '<br />To upload, rename or delete existing '.$fname.' in portfolio'.$env{'form.currentpath'});
             $r->print(&done('Back'));
         }
     } else {
         my $result=&Apache::lonnet::userfileupload('uploaddoc','',
-	        	 'portfolio'.$ENV{'form.currentpath'});
+	        	 'portfolio'.$env{'form.currentpath'});
         if ($result !~ m|^/uploaded/|) {
             $r->print('<font color="red"> An errror occured ('.$result.
 	              ') while trying to upload '.&display_file().'</font><br />');
@@ -450,7 +451,7 @@
 }
 sub createdir {
     my ($r)=@_;
-    my $newdir=&Apache::lonnet::clean_filename($ENV{'form.newdir'});
+    my $newdir=&Apache::lonnet::clean_filename($env{'form.newdir'});
     if ($newdir eq '') {
     	$r->print('<font color="red">'.
 	    	  &mt("Error: no directory name was provided.").
@@ -458,12 +459,12 @@
 	    $r->print(&done());
 	    return;
     } 
-    my $portfolio_root = &Apache::loncommon::propath($ENV{'user.domain'},
-						 $ENV{'user.name'}).
+    my $portfolio_root = &Apache::loncommon::propath($env{'user.domain'},
+						 $env{'user.name'}).
 						'/userfiles/portfolio';
-    my @dir_list=&Apache::lonnet::dirlist($ENV{'form.currentpath'},
-					  $ENV{'user.domain'},
-					  $ENV{'user.name'},$portfolio_root);
+    my @dir_list=&Apache::lonnet::dirlist($env{'form.currentpath'},
+					  $env{'user.domain'},
+					  $env{'user.name'},$portfolio_root);
     my $found_file = 0;
     foreach my $line (@dir_list) {
         my ($filename)=split(/\&/,$line,2);
@@ -475,15 +476,15 @@
     	    $r->print('<font color="red"> Unable to create a directory named <strong>'.$newdir.
     	            ' </strong>a file or directory by that name already exists.</font><br />');
     } else {
-        my $result=&Apache::lonnet::mkdiruserfile($ENV{'user.name'},
-	         $ENV{'user.domain'},'portfolio'.$ENV{'form.currentpath'}.$newdir);
+        my $result=&Apache::lonnet::mkdiruserfile($env{'user.name'},
+	         $env{'user.domain'},'portfolio'.$env{'form.currentpath'}.$newdir);
         if ($result ne 'ok') {
     	    $r->print('<font color="red"> An errror occured ('.$result.
 	    	      ') while trying to create a new directory '.&display_file().'</font><br />');
         }
     }
-    if ($newdir ne $ENV{'form.newdir'}) {
-        $r->print("The new directory name was changed from:<br /><strong>".$ENV{'form.newdir'}."</strong> to <strong>$newdir </strong>");  
+    if ($newdir ne $env{'form.newdir'}) {
+        $r->print("The new directory name was changed from:<br /><strong>".$env{'form.newdir'}."</strong> to <strong>$newdir </strong>");  
     }
     $r->print(&done());
 }
@@ -491,8 +492,8 @@
 sub handler {
     # this handles file management
     my $r = shift;
-    my $portfolio_root = &Apache::loncommon::propath($ENV{'user.domain'},
-							 $ENV{'user.name'}).
+    my $portfolio_root = &Apache::loncommon::propath($env{'user.domain'},
+							 $env{'user.name'}).
 							'/userfiles/portfolio';
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
                                             ['selectfile','currentpath','meta','lockinfo',
@@ -505,61 +506,61 @@
     $r->print($html.'<head><title>'.
               &mt('Portfolio Manager').
               "</title></head>\n");
-    if ($ENV{"form.mode"} eq 'selectfile'){
+    if ($env{"form.mode"} eq 'selectfile'){
         $r->print(&Apache::loncommon::bodytag('Portfolio Manager',undef,undef,1));
     } else {
         $r->print(&Apache::loncommon::bodytag('Portfolio Manager'));
     }
     $r->rflush();
-	if (($ENV{'form.storeupl'} eq 'Upload') & (!$ENV{'form.uploaddoc.filename'})){
+	if (($env{'form.storeupl'} eq 'Upload') & (!$env{'form.uploaddoc.filename'})){
    	    $r->print('<font color="red"> No file was selected to upload.'.
    	            'To upload a file, click <strong>Browse...</strong>'.
    	            ', select a file, then click <strong>Upload</strong>,</font>');
 	}
-    if ($ENV{'form.meta'}) {
+    if ($env{'form.meta'}) {
         &open_form($r);
-#        $r->print(&edit_meta_data($r, $ENV{'form.currentpath'}.$ENV{'form.selectfile'}));
+#        $r->print(&edit_meta_data($r, $env{'form.currentpath'}.$env{'form.selectfile'}));
         $r->print('Edit the meta data<br />');
         &close_form($r);
     }
-    if ($ENV{'form.store'}) {
+    if ($env{'form.store'}) {
     }
 
-    if ($ENV{'form.uploaddoc.filename'}) {
+    if ($env{'form.uploaddoc.filename'}) {
 	&upload($r);
-    } elsif ($ENV{'form.action'} eq 'delete' && $ENV{'form.confirmed'}) {
+    } elsif ($env{'form.action'} eq 'delete' && $env{'form.confirmed'}) {
 	&delete_confirmed($r);
-    } elsif ($ENV{'form.action'} eq 'delete') {
+    } elsif ($env{'form.action'} eq 'delete') {
 	&delete($r);
-    } elsif ($ENV{'form.action'} eq 'deletedir' && $ENV{'form.confirmed'}) {
+    } elsif ($env{'form.action'} eq 'deletedir' && $env{'form.confirmed'}) {
 	&delete_dir_confirmed($r);
-    } elsif ($ENV{'form.action'} eq 'deletedir'){
+    } elsif ($env{'form.action'} eq 'deletedir'){
 	&delete_dir($r);
-    } elsif ($ENV{'form.action'} eq 'rename' && $ENV{'form.confirmed'}) {
+    } elsif ($env{'form.action'} eq 'rename' && $env{'form.confirmed'}) {
 	&rename_confirmed($r);
-    } elsif ($ENV{'form.rename'}) {
-        $ENV{'form.selectfile'} = $ENV{'form.rename'};
-        $ENV{'form.action'} = 'rename';
+    } elsif ($env{'form.rename'}) {
+        $env{'form.selectfile'} = $env{'form.rename'};
+        $env{'form.action'} = 'rename';
 	&rename($r);
-    } elsif ($ENV{'form.createdir'}) {
+    } elsif ($env{'form.createdir'}) {
 	&createdir($r);
-    } elsif ($ENV{'form.lockinfo'}) {
+    } elsif ($env{'form.lockinfo'}) {
         &lock_info($r);
     } else {
 	my $current_path='/';
-	if ($ENV{'form.currentpath'}) {
-	    $current_path = $ENV{'form.currentpath'};
+	if ($env{'form.currentpath'}) {
+	    $current_path = $env{'form.currentpath'};
 	}
 	my @dir_list=&Apache::lonnet::dirlist($current_path,
-					    $ENV{'user.domain'},
-					    $ENV{'user.name'},$portfolio_root);
+					    $env{'user.domain'},
+					    $env{'user.name'},$portfolio_root);
 	if ($dir_list[0] eq 'no_such_dir'){
 	    # two main reasons for this:
             #    1) never been here, so directory structure not created
 	    #    2) back-button navigation after deleting a directory
 	    if ($current_path eq '/'){
-	        &Apache::lonnet::mkdiruserfile($ENV{'user.name'},
-					       $ENV{'user.domain'},'portfolio');
+	        &Apache::lonnet::mkdiruserfile($env{'user.name'},
+					       $env{'user.domain'},'portfolio');
 	    } else {
                 # some directory that snuck in get rid of the directory
                 # from the recent pulldown, just in case
@@ -569,8 +570,8 @@
 	    }
 	    # now grab the directory list again, for the first time
 	    @dir_list=&Apache::lonnet::dirlist($current_path,
-					    $ENV{'user.domain'},
-					    $ENV{'user.name'},$portfolio_root);
+					    $env{'user.domain'},
+					    $env{'user.name'},$portfolio_root);
         }
 	# need to know if directory is empty so it can be removed if desired
 	my $is_empty=(@dir_list == 2);
Index: loncom/interface/printout.pl
diff -u loncom/interface/printout.pl:1.75 loncom/interface/printout.pl:1.76
--- loncom/interface/printout.pl:1.75	Wed Mar 23 17:37:46 2005
+++ loncom/interface/printout.pl	Thu Apr  7 02:56:23 2005
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 # CGI-script to run LaTeX, dvips, ps2ps, ps2pdf etc.
 #
-# $Id: printout.pl,v 1.75 2005/03/23 22:37:46 albertel Exp $
+# $Id: printout.pl,v 1.76 2005/04/07 06:56:23 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -27,7 +27,7 @@
 #
 
 use lib '/home/httpd/lib/perl';
-use LONCAPA::loncgi();
+use LONCAPA::loncgi;
 use File::Path;
 use IO::File;
 use Image::Magick;
@@ -38,7 +38,6 @@
 
 use strict;
 $|=1;
-my %origENV=%ENV;
 if (! &LONCAPA::loncgi::check_cookie_and_load_env()) {
     print <<END;
 Content-type: text/html
@@ -58,27 +57,25 @@
  print $bodytag;
 
   my $identifier = $ENV{'QUERY_STRING'};
-  my $texfile = $ENV{'cgi.'.$identifier.'.file'};
-  my $laystyle = $ENV{'cgi.'.$identifier.'.layout'};
-  my $numberofcolumns = $ENV{'cgi.'.$identifier.'.numcol'};
-  my $paper = $ENV{'cgi.'.$identifier.'.paper'};
-  my $selectionmade = $ENV{'cgi.'.$identifier.'.selection'};
-  my $tableofcontents = $ENV{'cgi.'.$identifier.'tableofcontents'};
-  my $tableofindex = $ENV{'cgi.'.$identifier.'tableofindex'};
-  my $advanced_role = $ENV{'cgi.'.$identifier.'role'};
-  my $number_of_files = $ENV{'cgi.'.$identifier.'numberoffiles'}+1;
-  my $student_names = $ENV{'cgi.'.$identifier.'studentnames'};
-  my $backref = &Apache::lonnet::unescape($ENV{'cgi.'.$identifier.'backref'});
+  my $texfile = $env{'cgi.'.$identifier.'.file'};
+  my $laystyle = $env{'cgi.'.$identifier.'.layout'};
+  my $numberofcolumns = $env{'cgi.'.$identifier.'.numcol'};
+  my $paper = $env{'cgi.'.$identifier.'.paper'};
+  my $selectionmade = $env{'cgi.'.$identifier.'.selection'};
+  my $tableofcontents = $env{'cgi.'.$identifier.'tableofcontents'};
+  my $tableofindex = $env{'cgi.'.$identifier.'tableofindex'};
+  my $advanced_role = $env{'cgi.'.$identifier.'role'};
+  my $number_of_files = $env{'cgi.'.$identifier.'numberoffiles'}+1;
+  my $student_names = $env{'cgi.'.$identifier.'studentnames'};
+  my $backref = &Apache::lonnet::unescape($env{'cgi.'.$identifier.'backref'});
 
 
-  my $adv = $ENV{'request.role.adv'};
+  my $adv = $env{'request.role.adv'};
   
   my @names_pack=();
   if ($student_names=~/_END_/) {  
       @names_pack=split(/_ENDPERSON_/,$student_names);
   }
-  #got what we needed reset ENV in case it is to big for system
-  %ENV=%origENV;
 
   my $figfile = $texfile;
   $figfile =~ s/^([^\.]+printout)[^t]+\.tex/$1\.dat/;
Index: loncom/interface/spreadsheet/Spreadsheet.pm
diff -u loncom/interface/spreadsheet/Spreadsheet.pm:1.40 loncom/interface/spreadsheet/Spreadsheet.pm:1.41
--- loncom/interface/spreadsheet/Spreadsheet.pm:1.40	Thu Mar 10 12:33:57 2005
+++ loncom/interface/spreadsheet/Spreadsheet.pm	Thu Apr  7 02:56:23 2005
@@ -1,5 +1,5 @@
 #
-# $Id: Spreadsheet.pm,v 1.40 2005/03/10 17:33:57 matthew Exp $
+# $Id: Spreadsheet.pm,v 1.41 2005/04/07 06:56:23 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -90,10 +90,10 @@
         $usymb = $usymb->symb;
     }
     if (! defined($name) || $name eq '') {
-        $name = $ENV{'user.name'};
+        $name = $env{'user.name'};
     }
     if (! defined($domain) || $domain eq '') {
-        $domain = $ENV{'user.domain'};
+        $domain = $env{'user.domain'};
     }
     #
     my $self = {
@@ -103,12 +103,12 @@
         symb     => $usymb,
         errorlog => '',
         maxrow   => 0,
-        cid      => $ENV{'request.course.id'},
-        cnum     => $ENV{'course.'.$ENV{'request.course.id'}.'.num'},
-        cdom     => $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
-        chome    => $ENV{'course.'.$ENV{'request.course.id'}.'.home'},
-        coursedesc => $ENV{'course.'.$ENV{'request.course.id'}.'.description'},
-        coursefilename => $ENV{'request.course.fn'},
+        cid      => $env{'request.course.id'},
+        cnum     => $env{'course.'.$env{'request.course.id'}.'.num'},
+        cdom     => $env{'course.'.$env{'request.course.id'}.'.domain'},
+        chome    => $env{'course.'.$env{'request.course.id'}.'.home'},
+        coursedesc => $env{'course.'.$env{'request.course.id'}.'.description'},
+        coursefilename => $env{'request.course.fn'},
         #
         # Flags
         temporary => 0,  # true if this sheet has been modified but not saved
@@ -132,8 +132,8 @@
     #
     # Load in the spreadsheet definition
     $self->filename($filename);
-    if (exists($ENV{'form.workcopy'}) && 
-        $self->{'type'} eq $ENV{'form.workcopy'}) {
+    if (exists($env{'form.workcopy'}) && 
+        $self->{'type'} eq $env{'form.workcopy'}) {
         $self->load_tmp();
     } else {
         $self->load();
@@ -160,8 +160,8 @@
             $newfilename !~ /\w/ || $newfilename eq '') {
             my $key = 'course.'.$self->{'cid'}.'.spreadsheet_default_'.
                 $self->{'type'};
-            if (exists($ENV{$key}) && $ENV{$key} ne '') {
-                $newfilename = $ENV{$key};
+            if (exists($env{$key}) && $env{$key} ne '') {
+                $newfilename = $env{$key};
             } else {
                 $newfilename = 'default_'.$self->{'type'};
             }
@@ -259,10 +259,10 @@
 
 sub load_spreadsheet_expirationdates {
     undef %expiredates;
-    my $cid=$ENV{'request.course.id'};
+    my $cid=$env{'request.course.id'};
     my @tmp = &Apache::lonnet::dump('nohist_expirationdates',
-                                    $ENV{'course.'.$cid.'.domain'},
-                                    $ENV{'course.'.$cid.'.num'});
+                                    $env{'course.'.$cid.'.domain'},
+                                    $env{'course.'.$cid.'.num'});
     if (lc($tmp[0]) !~ /^error/){
         %expiredates = @tmp;
     }
@@ -318,7 +318,7 @@
   my $self = shift;
   my $usection = &Apache::lonnet::getsection($self->{'domain'},
                                              $self->{'name'},
-                                             $ENV{'request.course.id'});
+                                             $env{'request.course.id'});
   if (! defined($safeeval)) {
       $safeeval = new Safe(shift);
       my $safehole = new Safe::Hole;
@@ -1222,7 +1222,7 @@
     my ($r) = @_;
     my $outputmode = 'html';
     foreach ($self->output_options()) {
-        if ($ENV{'form.output_format'} eq $_->{'value'}) {
+        if ($env{'form.output_format'} eq $_->{'value'}) {
             $outputmode = $_->{'value'};
             last;
         }
@@ -1266,7 +1266,7 @@
     my $self = shift();
     my ($color) = @_;
     $color = '#CCCCFF' if (! defined($color));
-    my $allowed = &Apache::lonnet::allowed('mgr',$ENV{'request.course.id'});
+    my $allowed = &Apache::lonnet::allowed('mgr',$env{'request.course.id'});
     my $row_html;
     my @rowdata = $self->get_row(0);
     foreach my $cell (@rowdata) {
@@ -1283,7 +1283,7 @@
 
 sub html_template_row {
     my $self = shift();
-    my $allowed = &Apache::lonnet::allowed('mgr',$ENV{'request.course.id'});
+    my $allowed = &Apache::lonnet::allowed('mgr',$env{'request.course.id'});
     my ($num_uneditable,$importcolor) = @_;
     my $row_html;
     my @rowdata = $self->get_template_row();
@@ -1350,7 +1350,7 @@
 sub html_row {
     my $self = shift();
     my ($num_uneditable,$row,$exportcolor,$importcolor) = @_;
-    my $allowed = &Apache::lonnet::allowed('mgr',$ENV{'request.course.id'});
+    my $allowed = &Apache::lonnet::allowed('mgr',$env{'request.course.id'});
     my @rowdata = $self->get_row($row);
     my $num_cols_output = 0;
     my $row_html;
@@ -1374,7 +1374,7 @@
 
 sub html_header {
     my $self = shift;
-    return '' if (! $ENV{'request.role.adv'});
+    return '' if (! $env{'request.role.adv'});
     return "<table>\n".
         '<tr><th align="center">'.&mt('Output Format').'</th></tr>'."\n".
         '<tr><td>'.$self->output_selector()."</td></tr>\n".
@@ -1399,10 +1399,10 @@
     my $self = shift();
     my $output_selector = '<select name="output_format" size="3">'."\n";
     my $default = 'html';
-    if (exists($ENV{'form.output_format'})) {
-        $default = $ENV{'form.output_format'} 
+    if (exists($env{'form.output_format'})) {
+        $default = $env{'form.output_format'} 
     } else {
-        $ENV{'form.output_format'} = $default;
+        $env{'form.output_format'} = $default;
     }
     foreach  ($self->output_options()) {
         $output_selector.='<option value="'.$_->{'value'}.'"';
@@ -1504,7 +1504,7 @@
     #
     # Open the csv file
     my $filename = '/prtspool/'.
-        $ENV{'user.name'}.'_'.$ENV{'user.domain'}.'_'.
+        $env{'user.name'}.'_'.$env{'user.domain'}.'_'.
         time.'_'.rand(1000000000).'.csv';
     my $file;
     unless ($file = Apache::File->new('>'.'/home/httpd'.$filename)) {
@@ -1753,7 +1753,7 @@
         my $reply = &Apache::lonnet::put($filename,\%f,$cdom,$cnum);
         return $reply if ($reply ne 'ok');
         $reply = &Apache::lonnet::put($stype.'_spreadsheets',
-                     {$filename => $ENV{'user.name'}.'@'.$ENV{'user.domain'}},
+                     {$filename => $env{'user.name'}.'@'.$env{'user.domain'}},
                                       $cdom,$cnum);
         return $reply if ($reply ne 'ok');
         if ($makedef) { 
@@ -1779,8 +1779,8 @@
 
 sub save_tmp {
     my $self = shift;
-    my $filename=$ENV{'user.name'}.'_'.
-        $ENV{'user.domain'}.'_spreadsheet_'.$self->{'symb'}.'_'.
+    my $filename=$env{'user.name'}.'_'.
+        $env{'user.domain'}.'_spreadsheet_'.$self->{'symb'}.'_'.
            $self->{'filename'};
     $filename=~s/\W/\_/g;
     $filename=$Apache::lonnet::tmpdir.$filename.'.tmp';
@@ -1799,8 +1799,8 @@
 
 sub load_tmp {
     my $self = shift;
-    my $filename=$ENV{'user.name'}.'_'.
-        $ENV{'user.domain'}.'_spreadsheet_'.$self->{'symb'}.'_'.
+    my $filename=$env{'user.name'}.'_'.
+        $env{'user.domain'}.'_spreadsheet_'.$self->{'symb'}.'_'.
             $self->{'filename'};
     $filename=~s/\W/\_/g;
     $filename=$Apache::lonnet::tmpdir.$filename.'.tmp';
Index: loncom/interface/spreadsheet/assesscalc.pm
diff -u loncom/interface/spreadsheet/assesscalc.pm:1.38 loncom/interface/spreadsheet/assesscalc.pm:1.39
--- loncom/interface/spreadsheet/assesscalc.pm:1.38	Thu Mar 10 12:33:57 2005
+++ loncom/interface/spreadsheet/assesscalc.pm	Thu Apr  7 02:56:23 2005
@@ -1,5 +1,5 @@
 #
-# $Id: assesscalc.pm,v 1.38 2005/03/10 17:33:57 matthew Exp $
+# $Id: assesscalc.pm,v 1.39 2005/04/07 06:56:23 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -125,7 +125,7 @@
     if (defined($current_name) &&
         defined($current_domain) &&
         defined($current_course) &&
-        $current_course eq $ENV{'request.course.id'} &&
+        $current_course eq $env{'request.course.id'} &&
         %newExportrows) {
         &save_cached_export_rows($current_name,$current_domain);
     }
@@ -143,7 +143,7 @@
 sub save_cached_export_rows {
     my ($sname,$sdomain) = @_;
     my $result = &Apache::lonnet::put
-        ('nohist_calculatedsheets_'.$ENV{'request.course.id'},
+        ('nohist_calculatedsheets_'.$env{'request.course.id'},
          $newExportrows{$sname.':'.$sdomain},
          $sdomain,$sname);
     delete($newExportrows{$sname.':'.$sdomain});
@@ -180,8 +180,8 @@
     $navmap = $in_navmap;
     undef(%useropt);
     undef(%userdata);
-    if ($current_course ne $ENV{'request.course.id'}) {
-        $current_course = $ENV{'request.course.id'};
+    if ($current_course ne $env{'request.course.id'}) {
+        $current_course = $env{'request.course.id'};
         undef(%courseopt);
     }
     &load_cached_export_rows();
@@ -207,13 +207,13 @@
     #
     # Course Parameters Cache
     if (! %courseopt) {
-        $current_course = $ENV{'request.course.id'};
+        $current_course = $env{'request.course.id'};
         undef(%courseopt);
         if (! defined($current_name) || ! defined($current_domain)) {
             return;
         }
-        my $dom = $ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
-        my $id  = $ENV{'course.'.$ENV{'request.course.id'}.'.num'};
+        my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+        my $id  = $env{'course.'.$env{'request.course.id'}.'.num'};
         my %Tmp = &Apache::lonnet::dump('resourcedata',$dom,$id);
         while (my ($name,$value) = each(%Tmp)) {
             $courseopt{$name}=$value;
@@ -256,8 +256,8 @@
     ## Check for a modified parameters
     ##
     if (! defined($current_course) || 
-        $current_course ne $ENV{'request.course.id'} ) {
-        $current_course = $ENV{'request.course.id'};
+        $current_course ne $env{'request.course.id'} ) {
+        $current_course = $env{'request.course.id'};
         undef(%courseopt); 
         undef(%useropt);
         undef(%userdata);
@@ -769,7 +769,7 @@
     my %c;
     #
     # Check for blackout requirements
-    if ((!exists($ENV{'request.role.adv'}) || !$ENV{'request.role.adv'})) {
+    if ((!exists($env{'request.role.adv'}) || !$env{'request.role.adv'})) {
         while (my ($parm,$value) = each(%parameters)) {
             last if ($self->blackout());
             next if ($parm !~ /^(parameter_.*)_problemstatus$/);
@@ -875,11 +875,11 @@
 sub load_cached_export_rows {
     undef(%Exportrows);
     my @tmp = &Apache::lonnet::dump('nohist_calculatedsheets_'.
-                                    $ENV{'request.course.id'},
+                                    $env{'request.course.id'},
                                     $current_domain,$current_name,undef);
     if ($tmp[0]!~/^error/) {
         my %tmp = @tmp;
-        my $default_filename =  $ENV{'course.'.$ENV{'request.course.id'}.
+        my $default_filename =  $env{'course.'.$env{'request.course.id'}.
                                          '.spreadsheet_default_assesscalc'};
         # We only got one key, so we will access it directly.
         while (my ($key,$sheetdata) = each(%tmp)) {
@@ -921,7 +921,7 @@
     my ($r) = @_;
     my $connection = $r->connection();
     my $symb = $self->{'symb'};
-    if (! exists($ENV{'request.role.adv'}) || ! $ENV{'request.role.adv'} ||
+    if (! exists($env{'request.role.adv'}) || ! $env{'request.role.adv'} ||
         ! exists($Exportrows{$symb}) || ! defined($Exportrows{$symb})  ||
         ! $self->check_expiration_time($Exportrows{$symb}->{'time'}) ||
         ! exists($Exportrows{$symb}->{$self->{'filename'}}) ||
Index: loncom/interface/spreadsheet/classcalc.pm
diff -u loncom/interface/spreadsheet/classcalc.pm:1.22 loncom/interface/spreadsheet/classcalc.pm:1.23
--- loncom/interface/spreadsheet/classcalc.pm:1.22	Thu Mar 10 12:33:57 2005
+++ loncom/interface/spreadsheet/classcalc.pm	Thu Apr  7 02:56:23 2005
@@ -1,5 +1,5 @@
 #
-# $Id: classcalc.pm,v 1.22 2005/03/10 17:33:57 matthew Exp $
+# $Id: classcalc.pm,v 1.23 2005/04/07 06:56:23 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -307,7 +307,7 @@
     #
     # Determine if we should output expire caches links...
     my $show_expire_link = 0;
-    if (exists($ENV{'user.role.dc./'.$ENV{'request.role.domain'}.'/'})){
+    if (exists($env{'user.role.dc./'.$env{'request.role.domain'}.'/'})){
         $show_expire_link = 1;
     }
     #
Index: loncom/interface/spreadsheet/lonspreadsheet.pm
diff -u loncom/interface/spreadsheet/lonspreadsheet.pm:1.39 loncom/interface/spreadsheet/lonspreadsheet.pm:1.40
--- loncom/interface/spreadsheet/lonspreadsheet.pm:1.39	Tue Oct 12 16:51:54 2004
+++ loncom/interface/spreadsheet/lonspreadsheet.pm	Thu Apr  7 02:56:23 2005
@@ -1,5 +1,5 @@
 #
-# $Id: lonspreadsheet.pm,v 1.39 2004/10/12 20:51:54 albertel Exp $
+# $Id: lonspreadsheet.pm,v 1.40 2005/04/07 06:56:23 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -100,9 +100,9 @@
     my $message = '';
     ##
     ## Deal with saving the spreadsheet
-    if ((exists($ENV{'form.save'}) || exists($ENV{'form.makedefault'})) && 
-        exists($ENV{'form.savefilename'})) {
-        $spreadsheet->filename($ENV{'form.savefilename'});
+    if ((exists($env{'form.save'}) || exists($env{'form.makedefault'})) && 
+        exists($env{'form.savefilename'})) {
+        $spreadsheet->filename($env{'form.savefilename'});
         my $save_status = $spreadsheet->save();
         if ($save_status ne 'ok') {
             $message .= "An error occurred while saving the spreadsheet".
@@ -110,22 +110,22 @@
         } else {
             $message .= "Spreadsheet saved as ".$spreadsheet->filename();
         }
-    } elsif (exists($ENV{'form.newformula'}) && 
-             exists($ENV{'form.cell'})       && 
-             $ENV{'form.cell'} ne '' ) {
+    } elsif (exists($env{'form.newformula'}) && 
+             exists($env{'form.cell'})       && 
+             $env{'form.cell'} ne '' ) {
         ##
         ## Make any requested modifications to the spreadsheet
-        $spreadsheet->modify_cell($ENV{'form.cell'},
-                                  $ENV{'form.newformula'});
+        $spreadsheet->modify_cell($env{'form.cell'},
+                                  $env{'form.newformula'});
         $spreadsheet->save_tmp();
         # output that we are dealing with a temporary file
         $result .=&hiddenfield('workcopy',$sheettype);
-        if ($ENV{'form.newformula'} !~ /^\s*$/) {
+        if ($env{'form.newformula'} !~ /^\s*$/) {
             $message .='<table><tr>'.
-              '<td valign="top"><pre>'.&mt('Cell').' '.$ENV{'form.cell'}.' = </pre></td>'.
-              '<td><pre>'.$ENV{'form.newformula'}."</pre></td></tr></table>\n";
+              '<td valign="top"><pre>'.&mt('Cell').' '.$env{'form.cell'}.' = </pre></td>'.
+              '<td><pre>'.$env{'form.newformula'}."</pre></td></tr></table>\n";
         } else {
-            $message .= &mt('Deleted contents of cell').' '.$ENV{'form.cell'}.'.';
+            $message .= &mt('Deleted contents of cell').' '.$env{'form.cell'}.'.';
         }
     }
     ##
@@ -205,7 +205,7 @@
     if ($loaderror) { return $loaderror; }
     # Check the course homeserver
     $loaderror= &Apache::lonnet::overloaderror($r,
-                      $ENV{'course.'.$ENV{'request.course.id'}.'.home'});
+                      $env{'course.'.$env{'request.course.id'}.'.home'});
 #    if ($loaderror) { return $loaderror; } 
     #
     # HTML Header
@@ -219,20 +219,20 @@
     # Roles Checking
     #
     # Needs to be in a course
-    if (! $ENV{'request.course.fn'}) { 
+    if (! $env{'request.course.fn'}) { 
         # Not in a course, or not allowed to modify parms
-        $ENV{'user.error.msg'}=
+        $env{'user.error.msg'}=
             $r->uri.":opa:0:0:Cannot modify spreadsheet";
         return HTTP_NOT_ACCEPTABLE; 
     }
-    my $courseid = $ENV{'request.course.id'};
+    my $courseid = $env{'request.course.id'};
     #
     # Do not allow students to continue if standard or external grading is in
     # effect.
     #
-    if ($ENV{'request.role'} =~ /^st\./) {
-        if ($ENV{'course.'.$courseid.'.grading'} eq 'standard' ||
-	    $ENV{'course.'.$courseid.'.grading'} eq 'external' ) {
+    if ($env{'request.role'} =~ /^st\./) {
+        if ($env{'course.'.$courseid.'.grading'} eq 'standard' ||
+	    $env{'course.'.$courseid.'.grading'} eq 'external' ) {
             return HTTP_NOT_ACCEPTABLE;
         }
     }
@@ -245,35 +245,35 @@
     #
     # Deal with restricted student permissions 
     #
-    if ($ENV{'request.role'} =~ /^st\./) {
-        delete $ENV{'form.cell'}       if (exists($ENV{'form.cell'}));
-        delete $ENV{'form.newformula'} if (exists($ENV{'form.newformula'}));
+    if ($env{'request.role'} =~ /^st\./) {
+        delete $env{'form.cell'}       if (exists($env{'form.cell'}));
+        delete $env{'form.newformula'} if (exists($env{'form.newformula'}));
     }
     #
     # Determine basic information about the spreadsheet
     my ($sheettype) = ($r->uri=~/\/(\w+)$/);
     #
     my $symb   = undef;
-    $symb = $ENV{'form.usymb'} if (exists($ENV{'form.usymb'}));
-    my $name   = $ENV{'user.name'};
-    my $domain = $ENV{'user.domain'};
-    if (exists($ENV{'form.sname'}) && $ENV{'form.sname'} ne '') {
-        $name   = $ENV{'form.sname'};
-        $domain = $ENV{'form.sdomain'};
+    $symb = $env{'form.usymb'} if (exists($env{'form.usymb'}));
+    my $name   = $env{'user.name'};
+    my $domain = $env{'user.domain'};
+    if (exists($env{'form.sname'}) && $env{'form.sname'} ne '') {
+        $name   = $env{'form.sname'};
+        $domain = $env{'form.sdomain'};
     }
-    $ENV{'form.sname'} = $name;
-    $ENV{'form.sdomain'} = $domain;
+    $env{'form.sname'} = $name;
+    $env{'form.sdomain'} = $domain;
     ##
     ## Check permissions
     my $allowed_to_edit = &Apache::lonnet::allowed('mgr',
-                                                $ENV{'request.course.id'});
+                                                $env{'request.course.id'});
     # Only those instructors/tas/whatevers with complete access
     # (not section restricted) are able to modify spreadsheets.
     my $allowed_to_view =  &Apache::lonnet::allowed('vgr',
-                                                $ENV{'request.course.id'});
+                                                $env{'request.course.id'});
     if (! $allowed_to_view) {
         $allowed_to_view = &Apache::lonnet::allowed('vgr',
-                    $ENV{'request.course.id'}.'/'.$ENV{'request.course.sec'});
+                    $env{'request.course.id'}.'/'.$env{'request.course.sec'});
         # Those who are restricted by section are allowed to view.
         # The routines in lonstatistics which decide which students' 
         # will be shown take care of the restriction by section.
@@ -283,20 +283,20 @@
     # if they are not requesting their own.
     if ($sheettype eq 'classcalc') {
         if (! $allowed_to_view) {
-	    $ENV{'user.error.msg'}=
+	    $env{'user.error.msg'}=
 		$r->uri.":vgr:0:0:Access Permission Denied";
 	    return HTTP_NOT_ACCEPTABLE; 
 	}
     }
-    if ((($name   ne $ENV{'user.name'} ) ||
-         ($domain ne $ENV{'user.domain'})) && $sheettype ne 'classcalc') {
+    if ((($name   ne $env{'user.name'} ) ||
+         ($domain ne $env{'user.domain'})) && $sheettype ne 'classcalc') {
         # Check that the student is in their section?
-        if (exists($ENV{'request.course.sec'}) && 
-            $ENV{'request.course.sec'} ne '' ) {
+        if (exists($env{'request.course.sec'}) && 
+            $env{'request.course.sec'} ne '' ) {
             my $stu_sec = &Apache::lonnet::getsection($domain,$name,
-						    $ENV{'request.course.id'});
-            if ($stu_sec ne $ENV{'request.course.sec'}) {
-		$ENV{'user.error.msg'}=
+						    $env{'request.course.id'});
+            if ($stu_sec ne $env{'request.course.sec'}) {
+		$env{'user.error.msg'}=
 		    $r->uri.":vgr:0:0:Requested student not in your section.";
 		return HTTP_NOT_ACCEPTABLE; 
             }
@@ -378,28 +378,28 @@
     $r->print('</head>'.&Apache::loncommon::bodytag('Grades Spreadsheet').
               &Apache::lonhtmlcommon::breadcrumbs(undef,'Spreadsheet').
               '<form action="'.$r->uri.'" name="sheet" method="post">');
-    $r->print(&hiddenfield('sname'  ,$ENV{'form.sname'}).
-              &hiddenfield('sdomain',$ENV{'form.sdomain'}).
-              &hiddenfield('usymb'  ,$ENV{'form.usymb'}));
+    $r->print(&hiddenfield('sname'  ,$env{'form.sname'}).
+              &hiddenfield('sdomain',$env{'form.sdomain'}).
+              &hiddenfield('usymb'  ,$env{'form.usymb'}));
     $r->rflush();
     ##
     ## Determine the filename to use
     my $filename = undef;
     if ($allowed_to_edit) {
-        $filename = $ENV{'form.filename'} if (exists($ENV{'form.filename'}));
+        $filename = $env{'form.filename'} if (exists($env{'form.filename'}));
         #
-        if (exists($ENV{'form.load'}) && exists($ENV{'form.loadfilename'})) {
-            $filename = $ENV{'form.loadfilename'};
-            $ENV{'form.workcopy'} = 'no';
+        if (exists($env{'form.load'}) && exists($env{'form.loadfilename'})) {
+            $filename = $env{'form.loadfilename'};
+            $env{'form.workcopy'} = 'no';
         }
     }
     ##
     ## Take care of "backdoor" spreadsheet expiration / recalc stuff
-    if ($allowed_to_edit && exists($ENV{'form.recalc'})) {
-        if (exists($ENV{'form.recalc'})) {
-            &Apache::loncoursedata::delete_caches($ENV{'requres.course.id'});
+    if ($allowed_to_edit && exists($env{'form.recalc'})) {
+        if (exists($env{'form.recalc'})) {
+            &Apache::loncoursedata::delete_caches($env{'requres.course.id'});
         }
-        if ($ENV{'form.recalc'} eq 'ilovewastingtime') {
+        if ($env{'form.recalc'} eq 'ilovewastingtime') {
             &Apache::lonnet::logthis('spreadsheet expired: entire course');
             # expire ALL spreadsheets
             &Apache::lonnet::expirespread('','','studentcalc');
@@ -407,9 +407,9 @@
             $r->print('<h3>'.
                       &mt('Expired spreadsheet caches for all students').
                       '</h3>');
-        } elsif ($ENV{'form.recalc'} =~ /^symb:/) {
+        } elsif ($env{'form.recalc'} =~ /^symb:/) {
             # expire for all students on this symb
-            my ($symb) = ($ENV{'form.recalc'} =~ /^symb:(.*)$/);
+            my ($symb) = ($env{'form.recalc'} =~ /^symb:(.*)$/);
             &Apache::lonnet::logthis('spreadsheet expired: symb = '.$symb);
             &Apache::lonnet::expirespread('','','assesscalc',$symb);
             &Apache::lonnet::expirespread('','','studentcalc');
@@ -417,9 +417,9 @@
               &mt('Expired spreadsheet caches for all students for symb  [_1]',
                   $symb).
                       '</h3>');
-        } elsif ($ENV{'form.recalc'} =~ /^student:/) {
+        } elsif ($env{'form.recalc'} =~ /^student:/) {
             # expire all assessment spreadsheets for this user
-            my ($sname,$sdom) = ($ENV{'form.recalc'}=~/^student:(.*):(.*)$/);
+            my ($sname,$sdom) = ($env{'form.recalc'}=~/^student:(.*):(.*)$/);
             &Apache::lonnet::logthis('spreadsheet expired: student = '.
                                      $sname.'@'.$sdom);
             if (defined($sname) && defined($sdom)) {
@@ -458,7 +458,7 @@
     ## Editing/loading/saving
     if ($allowed_to_edit) {
         my ($html,$action_message) = &file_dialogs($spreadsheet);
-        if ($ENV{'form.makedefault'}) {
+        if ($env{'form.makedefault'}) {
             $spreadsheet->make_default();
             if ($action_message) {
                 $action_message .= '<br />';
@@ -518,7 +518,7 @@
     # Keep track of the number of times we have been called, sort of.
     $r->print(&hiddenfield('not_first_run','whatever'));
     #
-    if (exists($ENV{'form.not_first_run'}) || $sheettype ne 'classcalc') {
+    if (exists($env{'form.not_first_run'}) || $sheettype ne 'classcalc') {
         $r->print($spreadsheet->get_html_title());
         if ($allowed_to_view || $allowed_to_edit) {
             $r->print($spreadsheet->parent_link());
Index: loncom/interface/spreadsheet/studentcalc.pm
diff -u loncom/interface/spreadsheet/studentcalc.pm:1.29 loncom/interface/spreadsheet/studentcalc.pm:1.30
--- loncom/interface/spreadsheet/studentcalc.pm:1.29	Thu Mar 10 12:33:57 2005
+++ loncom/interface/spreadsheet/studentcalc.pm	Thu Apr  7 02:56:23 2005
@@ -1,5 +1,5 @@
 #
-# $Id: studentcalc.pm,v 1.29 2005/03/10 17:33:57 matthew Exp $
+# $Id: studentcalc.pm,v 1.30 2005/04/07 06:56:23 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -74,15 +74,15 @@
 }
 
 sub initialize_package {
-    $current_course = $ENV{'request.course.id'};
+    $current_course = $env{'request.course.id'};
     &initialize_sequence_cache();
     &load_cached_export_rows();
 }
 
 sub ensure_correct_sequence_data {
-    if ($current_course ne $ENV{'request.course.id'}) {
+    if ($current_course ne $env{'request.course.id'}) {
         &initialize_sequence_cache();
-        $current_course = $ENV{'request.course.id'};
+        $current_course = $env{'request.course.id'};
     }
     return;
 }
@@ -137,8 +137,8 @@
     my $self = shift;
     my ($name,$desc,$time) = $self->get_title();
     my $title = '<h1>'.$name;
-    if ($ENV{'user.name'} ne $self->{'name'} && 
-        $ENV{'user.domain'} ne $self->{'domain'}) {
+    if ($env{'user.name'} ne $self->{'name'} && 
+        $env{'user.domain'} ne $self->{'domain'}) {
         $title .= ' '.&Apache::loncommon::aboutmewrapper
                                     ($self->{'name'}.'@'.$self->{'domain'},
                                      $self->{'name'},$self->{'domain'});
@@ -173,7 +173,7 @@
     ####################################
     my @AssessFileNames = $self->othersheets('assesscalc');
     my $editing_is_allowed = &Apache::lonnet::allowed('mgr',
-                                                $ENV{'request.course.id'});
+                                                $env{'request.course.id'});
     ####################################
     # Report any calculation errors    #
     ####################################
@@ -221,7 +221,7 @@
         $r->print($tableheader);
         #
         # Print out template row
-        if (exists($ENV{'request.role.adv'}) && $ENV{'request.role.adv'}) {
+        if (exists($env{'request.role.adv'}) && $env{'request.role.adv'}) {
             $r->print('<tr><td>Template</td><td>&nbsp;</td>'.
                       $self->html_template_row($num_uneditable,
                                                $importcolor)."</tr>\n");
@@ -234,7 +234,7 @@
     $r->print("</table>\n");
     #
     # Prepare to output rows
-    if (exists($ENV{'request.role.adv'}) && $ENV{'request.role.adv'}) {
+    if (exists($env{'request.role.adv'}) && $env{'request.role.adv'}) {
         $tableheader =<<"END";
 </p><p>
 <table border="2">
@@ -319,7 +319,7 @@
     if (!defined($AssessFiles) || ! @$AssessFiles) {
         return '';
     }
-    return '' if (! &Apache::lonnet::allowed('mgr',$ENV{'request.course.id'}));
+    return '' if (! &Apache::lonnet::allowed('mgr',$env{'request.course.id'}));
     my $element_name = 'FileSelect_'.$row;
     my $load_dialog = '<select size="1" name="'.$element_name.'" '.
         'onchange="'.
@@ -499,9 +499,9 @@
     my $connection = $r->connection();
     if ($connection->aborted()) { $self->cleanup; return; }
     if (! defined($current_course) ||
-        $current_course ne $ENV{'request.course.id'} ||
+        $current_course ne $env{'request.course.id'} ||
         ! @Sequences ) {
-        $current_course = $ENV{'request.course.id'};
+        $current_course = $env{'request.course.id'};
         &clear_package();
         &initialize_sequence_cache();
     }
@@ -632,12 +632,12 @@
 sub load_cached_export_rows {
     undef(%Exportrows);
     my @tmp = &Apache::lonnet::dump('nohist_calculatedsheets',
-		     $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
-		     $ENV{'course.'.$ENV{'request.course.id'}.'.num'},undef);
+		     $env{'course.'.$env{'request.course.id'}.'.domain'},
+		     $env{'course.'.$env{'request.course.id'}.'.num'},undef);
     my %Selected_Assess_Sheet;
     if ($tmp[0] =~ /^error/) {
         &Apache::lonnet::logthis('unable to read cached student export rows '.
-                                 'for course '.$ENV{'request.course.id'});
+                                 'for course '.$env{'request.course.id'});
         return;
     }
     my %tmp = @tmp;
Index: loncom/interface/statistics/loncorrectproblemplot.pm
diff -u loncom/interface/statistics/loncorrectproblemplot.pm:1.17 loncom/interface/statistics/loncorrectproblemplot.pm:1.18
--- loncom/interface/statistics/loncorrectproblemplot.pm:1.17	Mon Mar 14 15:28:22 2005
+++ loncom/interface/statistics/loncorrectproblemplot.pm	Thu Apr  7 02:56:24 2005
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: loncorrectproblemplot.pm,v 1.17 2005/03/14 20:28:22 matthew Exp $
+# $Id: loncorrectproblemplot.pm,v 1.18 2005/04/07 06:56:24 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -28,7 +28,7 @@
 package Apache::loncorrectproblemplot;
 
 use strict;
-use Apache::lonnet();
+use Apache::lonnet;
 use Apache::loncommon();
 use Apache::lonhtmlcommon();
 use Apache::loncoursedata();
@@ -90,7 +90,7 @@
     $r->rflush();
     #
     # Determine which problem symbs we are to sum over
-    if (exists($ENV{'form.CreatePlot'})) {
+    if (exists($env{'form.CreatePlot'})) {
         my @ProblemSymbs;
         my $total_weights = 0;
         my $title = '';
Index: loncom/interface/statistics/lonproblemanalysis.pm
diff -u loncom/interface/statistics/lonproblemanalysis.pm:1.119 loncom/interface/statistics/lonproblemanalysis.pm:1.120
--- loncom/interface/statistics/lonproblemanalysis.pm:1.119	Mon Mar 14 19:51:43 2005
+++ loncom/interface/statistics/lonproblemanalysis.pm	Thu Apr  7 02:56:24 2005
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lonproblemanalysis.pm,v 1.119 2005/03/15 00:51:43 matthew Exp $
+# $Id: lonproblemanalysis.pm,v 1.120 2005/04/07 06:56:24 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -27,7 +27,7 @@
 package Apache::lonproblemanalysis;
 
 use strict;
-use Apache::lonnet();
+use Apache::lonnet;
 use Apache::loncommon();
 use Apache::lonhtmlcommon();
 use Apache::loncoursedata();
@@ -73,7 +73,7 @@
     #
     my @Students = @Apache::lonstatistics::Students;
     #
-    if (@Students < 1 && exists($ENV{'form.firstrun'})) {
+    if (@Students < 1 && exists($env{'form.firstrun'})) {
         $r->print('<h2>There are no students in the sections selected</h2>');
     }
     #
@@ -82,8 +82,8 @@
     $r->rflush();
     #
     my $problem_types = '(option|radiobutton|numerical)';
-    if (exists($ENV{'form.problemchoice'}) && 
-        ! exists($ENV{'form.SelectAnother'})) {
+    if (exists($env{'form.problemchoice'}) && 
+        ! exists($env{'form.SelectAnother'})) {
         foreach my $button (@SubmitButtons) {
             if ($button->{'name'} eq 'break') {
                 $r->print("<br />\n");
@@ -105,26 +105,26 @@
         #
         # Determine which problem we are to analyze
         my $current_problem = &Apache::lonstathelpers::get_target_from_id
-            ($ENV{'form.problemchoice'});
+            ($env{'form.problemchoice'});
         #
         my ($navmap,$prev,$curr,$next) = 
             &Apache::lonstathelpers::get_prev_curr_next($current_problem,
                                                         $problem_types,
                                                         'response',
                                                         );
-        if (exists($ENV{'form.PrevProblemAnalysis'}) && defined($prev)) {
+        if (exists($env{'form.PrevProblemAnalysis'}) && defined($prev)) {
             $current_problem = $prev;
-        } elsif (exists($ENV{'form.NextProblemAnalysis'}) && defined($next)) {
+        } elsif (exists($env{'form.NextProblemAnalysis'}) && defined($next)) {
             $current_problem = $next;
         } else {
             $current_problem = $curr;
         }
         #
         # Store the current problem choice and send it out in the form
-        $ENV{'form.problemchoice'} = 
+        $env{'form.problemchoice'} = 
             &Apache::lonstathelpers::make_target_id($current_problem);
         $r->print('<input type="hidden" name="problemchoice" value="'.
-                  $ENV{'form.problemchoice'}.'" />');
+                  $env{'form.problemchoice'}.'" />');
         #
         if (! defined($current_problem->{'resource'})) {
             $r->print('resource is undefined');
@@ -133,7 +133,7 @@
             $r->print('<h1>'.$resource->compTitle.'</h1>');
             $r->print('<h3>'.$resource->src.'</h3>');
             $r->print('<h4>'.&Apache::lonstatistics::section_and_enrollment_description().'</h4>');
-            if ($ENV{'form.show_prob'} eq 'true') {
+            if ($env{'form.show_prob'} eq 'true') {
                 $r->print(&Apache::lonstathelpers::render_resource($resource));
             }
             $r->rflush();
@@ -178,7 +178,7 @@
     my ($r,$problem,$problem_analysis,$students) = @_;
     my $c = $r->connection();
     #
-    if ($ENV{'form.AnalyzeOver'} !~ /^(tries|time)$/) {
+    if ($env{'form.AnalyzeOver'} !~ /^(tries|time)$/) {
         $r->print('Bad request');
     }
     #
@@ -207,14 +207,14 @@
         return;
     }
     my $analysis_html = '<table>';
-    for (my $plot_num = 1;$plot_num<=$ENV{'form.NumPlots'};$plot_num++) {
+    for (my $plot_num = 1;$plot_num<=$env{'form.NumPlots'};$plot_num++) {
         my $restriction_function;
         my $header_message;
         my $stats_message;
         my $post_message; # passed through &mt sooner rather than later
         my $no_data_message;
         my @extra_data;
-        if ($ENV{'form.AnalyzeOver'} eq 'tries') {
+        if ($env{'form.AnalyzeOver'} eq 'tries') {
             $restriction_function = sub {($_[0]->{'tries'} == $plot_num?1:0)};
             $header_message = 'Attempt [_1]';
             $stats_message = 
@@ -743,7 +743,7 @@
 sub radio_response_analysis {
     my ($r,$problem,$problem_analysis,$students) = @_;
     #
-    if ($ENV{'form.AnalyzeOver'} !~ /^(tries|time)$/) {
+    if ($env{'form.AnalyzeOver'} !~ /^(tries|time)$/) {
         $r->print('Bad request');
     }
     #
@@ -804,13 +804,13 @@
     }
     #
     $analysis_html.='<table>';
-    for (my $plot_num = 1;$plot_num<=$ENV{'form.NumPlots'};$plot_num++) {
+    for (my $plot_num = 1;$plot_num<=$env{'form.NumPlots'};$plot_num++) {
         # classify data ->correct foil -> selected foil
         my ($restriction_function,
             $correct_foil_title,$incorrect_foil_title,
             $pre_graph_text,$post_graph_text,
             $no_data_text,@extra_data);
-        if ($ENV{'form.AnalyzeOver'} eq 'tries') {
+        if ($env{'form.AnalyzeOver'} eq 'tries') {
             $restriction_function = sub {($_[0]->{'tries'} == $plot_num?1:0)};
             $correct_foil_title = 'Attempt '.$plot_num;
             $incorrect_foil_title = 'Attempt '.$plot_num;
@@ -818,7 +818,7 @@
                 'Attempt [_1], [_2] submissions, [_3] correct, [_4] incorrect';
             $post_graph_text = '';
             $no_data_text = 'No data exists for attempt [_1]';
-        } elsif ($ENV{'form.AnalyzeOver'} eq 'time') {
+        } elsif ($env{'form.AnalyzeOver'} eq 'time') {
             my $starttime = &Apache::lonhtmlcommon::get_date_from_form
                 ('startdate_'.$plot_num);
             my $endtime = &Apache::lonhtmlcommon::get_date_from_form
@@ -940,7 +940,7 @@
             (localtime($last - $sec_in_day*($plot_num-1)))[3..5];
         $start = &Time::Local::timelocal(0,0,0,$sday,$smon,$syear);
         $end   = $start + $sec_in_day;
-        if ($plot_num == $ENV{'form.NumPlots'}) {
+        if ($plot_num == $env{'form.NumPlots'}) {
             $start = $first;
         }
     }
@@ -1187,13 +1187,13 @@
                   '</h2>');
     }  else {
         $r->rflush();
-        if ($ENV{'form.AnalyzeOver'} eq 'tries') {
+        if ($env{'form.AnalyzeOver'} eq 'tries') {
             my $analysis_html = &OR_tries_analysis($r,
                                                    $PerformanceData,
                                                    $problem_data);
             $r->print($analysis_html);
             $r->rflush();
-        } elsif ($ENV{'form.AnalyzeOver'} eq 'time') {
+        } elsif ($env{'form.AnalyzeOver'} eq 'time') {
             my $analysis_html = &OR_time_analysis($PerformanceData,
                                                   $problem_data);
             $r->print($analysis_html);
@@ -1215,7 +1215,7 @@
 sub OR_tries_analysis {
     my ($r,$PerformanceData,$ORdata) = @_;
     my $mintries = 1;
-    my $maxtries = $ENV{'form.NumPlots'};
+    my $maxtries = $env{'form.NumPlots'};
     my ($table,$Foils,$Concepts) = &build_foil_index($ORdata);
     if (! defined($Concepts)) {
         $Concepts = [];
@@ -1425,7 +1425,7 @@
                 '</h3>'.$table;
     }
     #
-    my $num_plots = $ENV{'form.NumPlots'};
+    my $num_plots = $env{'form.NumPlots'};
     my $num_data = scalar(@$performance_data)-1;
     #
     my $current_index;
@@ -1808,8 +1808,8 @@
 sub CreateInterface {
     ##
     ## Environment variable initialization
-    if (! exists$ENV{'form.AnalyzeOver'}) {
-        $ENV{'form.AnalyzeOver'} = 'tries';
+    if (! exists($env{'form.AnalyzeOver'})) {
+        $env{'form.AnalyzeOver'} = 'tries';
     }
     ##
     ## Build the menu
@@ -1838,7 +1838,7 @@
     ##
     my $showprob_checkbox = 
         '<input type="checkbox" name="show_prob" value="true" ';
-    if ($ENV{'form.show_prob'} eq 'true') {
+    if ($env{'form.show_prob'} eq 'true') {
         $showprob_checkbox .= 'checked ';
     }
     $showprob_checkbox.= ' />';
@@ -1848,14 +1848,14 @@
     ##
     my $analyze_selector = '<select name="AnalyzeOver" >';
     $analyze_selector .= '<option value="tries" ';
-    if (! exists($ENV{'form.AnalyzeOver'}) || 
-        $ENV{'form.AnalyzeOver'} eq 'tries'){
+    if (! exists($env{'form.AnalyzeOver'}) || 
+        $env{'form.AnalyzeOver'} eq 'tries'){
         # Default to tries
         $analyze_selector .= ' selected ';
     }
     $analyze_selector .= '>'.&mt('Tries').'</option>';
     $analyze_selector .= '<option value="time" ';
-    $analyze_selector .= ' selected ' if ($ENV{'form.AnalyzeOver'} eq 'time');
+    $analyze_selector .= ' selected ' if ($env{'form.AnalyzeOver'} eq 'time');
     $analyze_selector .= '>'.&mt('Time').'</option>';
     $analyze_selector .= '</select>';
     $Str .= '<nobr><label>'.
@@ -1865,14 +1865,14 @@
             '</label></nobr><br />'.$/;
     ##
     my $numplots_selector = '<select name="NumPlots">';
-    if (! exists($ENV{'form.NumPlots'}) 
-        || $ENV{'form.NumPlots'} < 1 
-        || $ENV{'form.NumPlots'} > 20) {
-        $ENV{'form.NumPlots'} = 5;
+    if (! exists($env{'form.NumPlots'}) 
+        || $env{'form.NumPlots'} < 1 
+        || $env{'form.NumPlots'} > 20) {
+        $env{'form.NumPlots'} = 5;
     }
     foreach my $i (1,2,3,4,5,6,7,8,10,15,20) {
         $numplots_selector .= '<option value="'.$i.'" ';
-        if ($ENV{'form.NumPlots'} == $i) { $numplots_selector.=' selected '; }
+        if ($env{'form.NumPlots'} == $i) { $numplots_selector.=' selected '; }
         $numplots_selector .= '>'.$i.'</option>';
     }
     $numplots_selector .= '</select></nobr><br />';
Index: loncom/interface/statistics/lonproblemstatistics.pm
diff -u loncom/interface/statistics/lonproblemstatistics.pm:1.103 loncom/interface/statistics/lonproblemstatistics.pm:1.104
--- loncom/interface/statistics/lonproblemstatistics.pm:1.103	Sun Mar 27 00:08:03 2005
+++ loncom/interface/statistics/lonproblemstatistics.pm	Thu Apr  7 02:56:24 2005
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lonproblemstatistics.pm,v 1.103 2005/03/27 05:08:03 matthew Exp $
+# $Id: lonproblemstatistics.pm,v 1.104 2005/04/07 06:56:24 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -50,7 +50,7 @@
 package Apache::lonproblemstatistics;
 
 use strict;
-use Apache::lonnet();
+use Apache::lonnet;
 use Apache::loncommon();
 use Apache::lonhtmlcommon;
 use Apache::loncoursedata;
@@ -516,35 +516,35 @@
 sub parse_field_selection {
     #
     # Pull out the defaults
-    if (! defined($ENV{'form.fieldselections'})) {
-        $ENV{'form.fieldselections'} = [];
+    if (! defined($env{'form.fieldselections'})) {
+        $env{'form.fieldselections'} = [];
         foreach my $field (@Fields) {
             next if ($field->{'selectable'} ne 'yes');
             if ($field->{'defaultselected'} eq 'yes') {
-                push(@{$ENV{'form.fieldselections'}},$field->{'name'});
+                push(@{$env{'form.fieldselections'}},$field->{'name'});
             }
         }
     }
     #
     # Make sure the data we are plotting is there
     my %NeededFields;
-    if (exists($ENV{'form.plot'}) && $ENV{'form.plot'} ne '' &&
-        $ENV{'form.plot'} ne 'none') {
-        if ($ENV{'form.plot'} eq 'degrees') {
+    if (exists($env{'form.plot'}) && $env{'form.plot'} ne '' &&
+        $env{'form.plot'} ne 'none') {
+        if ($env{'form.plot'} eq 'degrees') {
             $NeededFields{'deg_of_diff'}++;
             $NeededFields{'deg_of_disc'}++;
-        } elsif ($ENV{'form.plot'} eq 'tries statistics') {
+        } elsif ($env{'form.plot'} eq 'tries statistics') {
             $NeededFields{'mean_tries'}++;
             $NeededFields{'std_tries'}++;
             $NeededFields{'problem_num'}++;
         } else {
-            $NeededFields{$ENV{'form.plot'}}++;
+            $NeededFields{$env{'form.plot'}}++;
         }
     }
     #
     # This should not happen, but in case it does...
-    if (ref($ENV{'form.fieldselections'}) ne 'ARRAY') {
-        $ENV{'form.fieldselections'} = [$ENV{'form.fieldselections'}];
+    if (ref($env{'form.fieldselections'}) ne 'ARRAY') {
+        $env{'form.fieldselections'} = [$env{'form.fieldselections'}];
     }
     #
     # Set the field data and the selected fields (for easier checking)
@@ -559,7 +559,7 @@
             $field->{'selected'} = 'yes';
             $SelectedFields{$field->{'name'}}++;
         }
-        foreach my $selection (@{$ENV{'form.fieldselections'}}) {
+        foreach my $selection (@{$env{'form.fieldselections'}}) {
             if ($selection eq $field->{'name'} || $selection eq 'all') {
                 $field->{'selected'} = 'yes';
                 $SelectedFields{$field->{'name'}}++;
@@ -686,7 +686,7 @@
     # Finally let the user know we are here
     my $interface = &CreateInterface($r);
     $r->print($interface);
-    $r->print('<input type="hidden" name="sortby" value="'.$ENV{'form.sortby'}.
+    $r->print('<input type="hidden" name="sortby" value="'.$env{'form.sortby'}.
               '" />');
     #
     my @CacheButtonHTML = 
@@ -697,7 +697,7 @@
     }
     #
     $r->print($Str);
-    if (! exists($ENV{'form.firstrun'})) {
+    if (! exists($env{'form.firstrun'})) {
         $r->print('<h3>'.
                   &mt('Press "Generate Statistics" when you are ready.').
                   '</h3><p>'.
@@ -720,7 +720,7 @@
                   '<h3>'.$navmap.'</h3>');
         return;
     }
-    if (exists($ENV{'form.Excel'})) {
+    if (exists($env{'form.Excel'})) {
         $r->print('<h4>'.
                   &Apache::lonstatistics::section_and_enrollment_description().
                   '</h4>');
@@ -748,9 +748,9 @@
             $r->rflush();
         }
         #
-        my $sortby = $ENV{'form.sortby'};
+        my $sortby = $env{'form.sortby'};
         $sortby = 'container' if (! defined($sortby) || $sortby =~ /^\s*$/);
-        my $plot = $ENV{'form.plot'};
+        my $plot = $env{'form.plot'};
         if ($plot eq '' || $plot eq 'none') {
             undef($plot);
         }
@@ -825,7 +825,7 @@
     my ($r)=@_;
     &compute_all_statistics($r);
     $r->print(&html_preamble());
-    &sort_data($ENV{'form.sortby'});
+    &sort_data($env{'form.sortby'});
     #
     my $count=0;
     foreach my $data (@StatsArray) {
@@ -847,7 +847,7 @@
 sub html_preamble {
     my $Str='';
     $Str .= "<h2>".
-        $ENV{'course.'.$ENV{'request.course.id'}.'.description'}.
+        $env{'course.'.$env{'request.course.id'}.'.description'}.
         "</h2>\n";
     my ($starttime,$endtime) = &Apache::lonstathelpers::get_time_limits();
     if (defined($starttime) || defined($endtime)) {
@@ -971,7 +971,7 @@
 sub make_plot {
     my ($r,$plot) = @_;
     &compute_all_statistics($r);
-    &sort_data($ENV{'form.sortby'});
+    &sort_data($env{'form.sortby'});
     if ($plot eq 'degrees') {
         &degrees_plot($r);
     } elsif ($plot eq 'tries statistics') {
@@ -1225,8 +1225,8 @@
 sub plot_dropdown {
     my $current = '';
     #
-    if (defined($ENV{'form.plot'})) {
-        $current = $ENV{'form.plot'};
+    if (defined($env{'form.plot'})) {
+        $current = $env{'form.plot'};
     }
     #
     my @Additional_Plots = (
@@ -1279,7 +1279,7 @@
     return if (! defined($excel_workbook));
     #
     # Add a worksheet
-    my $sheetname = $ENV{'course.'.$ENV{'request.course.id'}.'.description'};
+    my $sheetname = $env{'course.'.$env{'request.course.id'}.'.description'};
     if (length($sheetname) > 31) {
         $sheetname = substr($sheetname,0,31);
     }
@@ -1292,7 +1292,7 @@
     #
     # Put the course description in the header
     $excel_sheet->write($rows_output,$cols_output++,
-                   $ENV{'course.'.$ENV{'request.course.id'}.'.description'},
+                   $env{'course.'.$env{'request.course.id'}.'.description'},
                         $format->{'h1'});
     $cols_output += 3;
     #
@@ -1539,7 +1539,7 @@
     #
     my ($starttime,$endtime) = &Apache::lonstathelpers::get_time_limits();
     my $symb = $resource->symb;
-    my $courseid = $ENV{'request.course.id'};
+    my $courseid = $env{'request.course.id'};
     #
     my $data = &Apache::loncoursedata::get_problem_statistics
                         ([&Apache::lonstatistics::get_selected_sections()],
@@ -1564,7 +1564,7 @@
         my $sections = '"'.join(' ',@Sections).'"';
         $sections =~ s/&+/_/g;  # Ensure no special characters
         $data->{'sections'}=$sections;
-        $data->{'course'} = $ENV{'request.course.id'};
+        $data->{'course'} = $env{'request.course.id'};
         my $urlres=(&Apache::lonnet::decode_symb($resource->symb))[2];
         $data->{'urlres'}=$urlres;
         my %storestats = 
Index: loncom/interface/statistics/lonstathelpers.pm
diff -u loncom/interface/statistics/lonstathelpers.pm:1.45 loncom/interface/statistics/lonstathelpers.pm:1.46
--- loncom/interface/statistics/lonstathelpers.pm:1.45	Mon Mar 21 14:47:54 2005
+++ loncom/interface/statistics/lonstathelpers.pm	Thu Apr  7 02:56:24 2005
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lonstathelpers.pm,v 1.45 2005/03/21 19:47:54 matthew Exp $
+# $Id: lonstathelpers.pm,v 1.46 2005/04/07 06:56:24 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -49,7 +49,7 @@
 package Apache::lonstathelpers;
 
 use strict;
-use Apache::lonnet();
+use Apache::lonnet;
 use Apache::loncommon();
 use Apache::lonhtmlcommon();
 use Apache::loncoursedata();
@@ -154,7 +154,7 @@
                                                      respid=>$respid,
                                                      resptype=>$resptype});
                         my $checked = '';
-                        if ($ENV{'form.problemchoice'} eq $value) {
+                        if ($env{'form.problemchoice'} eq $value) {
                             $checked = 'checked ';
                         }
                         my $title = $res->compTitle;
@@ -214,7 +214,7 @@
 ####################################################
 sub MultipleProblemSelector {
     my ($navmap,$inputname,$formname)=@_;
-    my $cid = $ENV{'request.course.id'};
+    my $cid = $env{'request.course.id'};
     my $Str;
     # Massage the input as needed.
     if (! defined($navmap)) {
@@ -255,7 +255,7 @@
     my $iterator = $navmap->getIterator(undef, undef, undef, 1);
     my $sequence_string;
     my $seq_id = 0;
-    my @Accumulator = (&new_accumulator($ENV{'course.'.$cid.'.description'},
+    my @Accumulator = (&new_accumulator($env{'course.'.$cid.'.description'},
                                         '',
                                         '',
                                         $seq_id++,
@@ -339,11 +339,11 @@
     my ($inputfield) = @_;
     my $field = 'form.'.$inputfield;
     my @Symbs;
-    if (exists($ENV{$field})) {
-        if (! ref($ENV{$field})) {
-            @Symbs = (&Apache::lonnet::unescape($ENV{$field}));
+    if (exists($env{$field})) {
+        if (! ref($env{$field})) {
+            @Symbs = (&Apache::lonnet::unescape($env{$field}));
         } else {
-            @Symbs = (map {&Apache::lonnet::unescape($_);} @{$ENV{$field}});
+            @Symbs = (map {&Apache::lonnet::unescape($_);} @{$env{$field}});
         }
     }
     return @Symbs;
@@ -644,7 +644,7 @@
     my $symb = $resource->{'symb'};
     my $analysis = &get_from_analysis_cache($sname,$sdom,$symb);
     if (! defined($analysis)) {
-        my $courseid = $ENV{'request.course.id'};
+        my $courseid = $env{'request.course.id'};
         my $Answ=&Apache::lonnet::ssi($url,('grade_target' => 'analyze',
                                             'grade_domain' => $sdom,
                                             'grade_username' => $sname,
@@ -868,7 +868,7 @@
 #####################################################
 sub ensure_proper_cache {
     my ($symb) = @_;
-    my $cid = $ENV{'request.course.id'};
+    my $cid = $env{'request.course.id'};
     my $new_filename =  '/home/httpd/perl/tmp/'.
         'problemanalysis_'.$cid.'_analysis_cache.db';
     if (! defined($cache_filename) ||
@@ -1265,8 +1265,8 @@
 }
 
 sub limit_by_time {
-    if (exists($ENV{'form.limit_by_time'}) &&
-        $ENV{'form.limit_by_time'} ne '' ) {
+    if (exists($env{'form.limit_by_time'}) &&
+        $env{'form.limit_by_time'} ne '' ) {
         return 1;
     } else {
         return 0;
@@ -1306,13 +1306,13 @@
                  } sort(&Apache::lonstatistics::get_selected_sections())
              );
     my $statuskey = $Apache::lonstatistics::enrollment_status;
-    if (exists($ENV{'form.ClearCache'}) || 
-        exists($ENV{'form.updatecaches'}) || 
-        (exists($ENV{'form.firstrun'}) && $ENV{'form.firstrun'} ne 'no') ||
-        (exists($ENV{'form.prevsection'}) &&
-            $ENV{'form.prevsection'} ne $sectionkey) ||
-        (exists($ENV{'form.prevenrollstatus'}) &&
-            $ENV{'form.prevenrollstatus'} ne $statuskey)
+    if (exists($env{'form.ClearCache'}) || 
+        exists($env{'form.updatecaches'}) || 
+        (exists($env{'form.firstrun'}) && $env{'form.firstrun'} ne 'no') ||
+        (exists($env{'form.prevsection'}) &&
+            $env{'form.prevsection'} ne $sectionkey) ||
+        (exists($env{'form.prevenrollstatus'}) &&
+            $env{'form.prevenrollstatus'} ne $statuskey)
         ) {
         if (defined($update_message)) {
             $r->print($update_message);
@@ -1333,7 +1333,7 @@
          '<input type="hidden" name="prevenrollstatus" value="'.$statuskey.'" />'
          );
     #
-    if (! exists($ENV{'form.firstrun'})) {
+    if (! exists($env{'form.firstrun'})) {
         $r->print('<input type="hidden" name="firstrun" value="yes" />');
     } else {
         $r->print('<input type="hidden" name="firstrun" value="no" />');
@@ -1366,7 +1366,7 @@
         return if ($c->aborted());
         my $status = &Apache::loncoursedata::ensure_current_full_data
             ($student->{'username'},$student->{'domain'},
-             $ENV{'request.course.id'});
+             $env{'request.course.id'});
         &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,
                                                  &mt('last student'));
     }
@@ -1413,7 +1413,7 @@
     my $output_selector = $/.'<select name="output">'.$/;
     foreach ('HTML','Excel','CSV') {
         $output_selector .= '    <option value="'.lc($_).'"';
-        if ($ENV{'form.output'} eq lc($_)) {
+        if ($env{'form.output'} eq lc($_)) {
             $output_selector .= ' selected ';
         }
         $output_selector .='>'.&mt($_).'</option>'.$/;
Index: loncom/interface/statistics/lonstudentassessment.pm
diff -u loncom/interface/statistics/lonstudentassessment.pm:1.120 loncom/interface/statistics/lonstudentassessment.pm:1.121
--- loncom/interface/statistics/lonstudentassessment.pm:1.120	Mon Mar 21 14:47:54 2005
+++ loncom/interface/statistics/lonstudentassessment.pm	Thu Apr  7 02:56:24 2005
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lonstudentassessment.pm,v 1.120 2005/03/21 19:47:54 matthew Exp $
+# $Id: lonstudentassessment.pm,v 1.121 2005/04/07 06:56:24 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -153,10 +153,10 @@
     &Apache::lonstatistics::PrepareClasslist();
     #
     $single_student_mode = 0;
-    $single_student_mode = 1 if ($ENV{'form.SelectedStudent'});
+    $single_student_mode = 1 if ($env{'form.SelectedStudent'});
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
                                             ['selectstudent']);
-    if ($ENV{'form.selectstudent'}) {
+    if ($env{'form.selectstudent'}) {
         &Apache::lonstatistics::DisplayClasslist($r);
         return;
     }
@@ -167,10 +167,10 @@
     $r->print(&CreateInterface());
     $r->print('<input type="hidden" name="notfirstrun" value="true" />');
     $r->print('<input type="hidden" name="sort" value="'.
-              $ENV{'form.sort'}.'" />');
+              $env{'form.sort'}.'" />');
     $r->rflush();
     #
-    if (! exists($ENV{'form.notfirstrun'}) && ! $single_student_mode) {
+    if (! exists($env{'form.notfirstrun'}) && ! $single_student_mode) {
         return;
     }
     $r->print('<h4>'.
@@ -234,7 +234,7 @@
 sub next_and_previous_buttons {
     my $Str = '';
     $Str .= '<input type="hidden" name="SelectedStudent" value="'.
-        $ENV{'form.SelectedStudent'}.'" />';
+        $env{'form.SelectedStudent'}.'" />';
     #
     # Build the previous student link
     my $previous = &Apache::lonstatistics::previous_student();
@@ -431,11 +431,11 @@
     #
     # Format for output options is 'mode, restrictions';
     my $selected = 'html, without links';
-    if (exists($ENV{'form.'.$elementname})) {
-        if (ref($ENV{'form.'.$elementname} eq 'ARRAY')) {
-            $selected = $ENV{'form.'.$elementname}->[0];
+    if (exists($env{'form.'.$elementname})) {
+        if (ref($env{'form.'.$elementname} eq 'ARRAY')) {
+            $selected = $env{'form.'.$elementname}->[0];
         } else {
-            $selected = $ENV{'form.'.$elementname};
+            $selected = $env{'form.'.$elementname};
         }
     }
     #
@@ -552,11 +552,11 @@
     my $elementname = 'chartoutputdata';
     #
     my $selected = 'scores';
-    if (exists($ENV{'form.'.$elementname})) {
-        if (ref($ENV{'form.'.$elementname} eq 'ARRAY')) {
-            $selected = $ENV{'form.'.$elementname}->[0];
+    if (exists($env{'form.'.$elementname})) {
+        if (ref($env{'form.'.$elementname} eq 'ARRAY')) {
+            $selected = $env{'form.'.$elementname}->[0];
         } else {
-            $selected = $ENV{'form.'.$elementname};
+            $selected = $env{'form.'.$elementname};
         }
     }
     #
@@ -652,7 +652,7 @@
                   '</h3>');
     }
     #
-    $r->print("<h3>".$ENV{'course.'.$ENV{'request.course.id'}.'.description'}.
+    $r->print("<h3>".$env{'course.'.$env{'request.course.id'}.'.description'}.
               "&nbsp;&nbsp;".localtime(time)."</h3>");
     #
     if ($chosen_output->{'base'} !~ /^final table/) {
@@ -747,7 +747,7 @@
     my %StudentsData;
     my @tmp = &Apache::loncoursedata::get_current_state
         ($student->{'username'},$student->{'domain'},undef,
-         $ENV{'request.course.id'});
+         $env{'request.course.id'});
     if ((scalar @tmp > 0) && ($tmp[0] !~ /^error:/)) {
         %StudentsData = @tmp;
     }
@@ -1039,13 +1039,13 @@
     return if (! defined($excel_workbook));
     #
     # Add a worksheet
-    my $sheetname = $ENV{'course.'.$ENV{'request.course.id'}.'.description'};
+    my $sheetname = $env{'course.'.$env{'request.course.id'}.'.description'};
     $sheetname = &Apache::loncommon::clean_excel_name($sheetname);
     $excel_sheet = $excel_workbook->addworksheet($sheetname);
     #
     # Put the course description in the header
     $excel_sheet->write($header_row,$cols_output++,
-                   $ENV{'course.'.$ENV{'request.course.id'}.'.description'},
+                   $env{'course.'.$env{'request.course.id'}.'.description'},
                         $format->{'h1'});
     $cols_output += 3;
     #
@@ -1314,7 +1314,7 @@
     #
     # Let the user know what we are doing
     my $studentcount = scalar(@Apache::lonstatistics::Students); 
-    if ($ENV{'form.SelectedStudent'}) {
+    if ($env{'form.SelectedStudent'}) {
         $studentcount = '1';
     }
     if ($studentcount > 1) {
@@ -1361,7 +1361,7 @@
     my @tmp = &Apache::loncoursedata::get_current_state($student->{'username'},
                                                         $student->{'domain'},
                                                         undef,
-                                                   $ENV{'request.course.id'});
+                                                   $env{'request.course.id'});
     if ((scalar @tmp > 0) && ($tmp[0] !~ /^error:/)) {
         %StudentsData = @tmp;
     }
@@ -1549,7 +1549,7 @@
     if (! defined($outputfile)) { return ''; }
     #
     # Datestamp
-    my $description = $ENV{'course.'.$ENV{'request.course.id'}.'.description'};
+    my $description = $env{'course.'.$env{'request.course.id'}.'.description'};
     print $outputfile '"'.&Apache::loncommon::csv_translate($description).'",'.
         '"'.&Apache::loncommon::csv_translate(scalar(localtime(time))).'"'.
             "\n";
@@ -1639,7 +1639,7 @@
     my @tmp = &Apache::loncoursedata::get_current_state($student->{'username'},
                                                         $student->{'domain'},
                                                         undef,
-                                                   $ENV{'request.course.id'});
+                                                   $env{'request.course.id'});
     if ((scalar @tmp > 0) && ($tmp[0] !~ /^error:/)) {
         %StudentsData = @tmp;
     }
Index: loncom/interface/statistics/lonstudentsubmissions.pm
diff -u loncom/interface/statistics/lonstudentsubmissions.pm:1.39 loncom/interface/statistics/lonstudentsubmissions.pm:1.40
--- loncom/interface/statistics/lonstudentsubmissions.pm:1.39	Thu Mar 17 13:50:06 2005
+++ loncom/interface/statistics/lonstudentsubmissions.pm	Thu Apr  7 02:56:24 2005
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lonstudentsubmissions.pm,v 1.39 2005/03/17 18:50:06 matthew Exp $
+# $Id: lonstudentsubmissions.pm,v 1.40 2005/04/07 06:56:24 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -27,7 +27,7 @@
 package Apache::lonstudentsubmissions;
 
 use strict;
-use Apache::lonnet();
+use Apache::lonnet;
 use Apache::loncommon();
 use Apache::lonhtmlcommon();
 use Apache::loncoursedata();
@@ -71,8 +71,8 @@
                                    '<h3>'.&mt('Loading student data').'</h3>');
     $r->rflush();
     #
-    if (exists($ENV{'form.problemchoice'}) && 
-        ! exists($ENV{'form.SelectAnother'})) {
+    if (exists($env{'form.problemchoice'}) && 
+        ! exists($env{'form.SelectAnother'})) {
         foreach my $button (@SubmitButtons) {
             if ($button->{'name'} eq 'break') {
                 $r->print("<br />\n");
@@ -120,14 +120,14 @@
                 my $resource = $Problems[0];
                 $r->print('<h1>'.$resource->title.'</h1>');
                 $r->print('<h3>'.$resource->src.'</h3>');
-                if ($ENV{'form.renderprob'} eq 'true') {
+                if ($env{'form.renderprob'} eq 'true') {
                     $r->print(&Apache::lonstathelpers::render_resource($resource));
                     $r->rflush();
                 }
             }
-            if ($ENV{'form.output'} eq 'excel') {
+            if ($env{'form.output'} eq 'excel') {
                 &prepare_excel_output($r,\@Problems,\@Students);
-            } elsif ($ENV{'form.output'} eq 'csv') {
+            } elsif ($env{'form.output'} eq 'csv') {
                 &prepare_csv_output($r,\@Problems,\@Students);
             } else {
                 &prepare_html_output($r,\@Problems,\@Students);
@@ -154,10 +154,10 @@
 ##
 sub get_extra_response_headers {
     my @extra_resp_headers;
-    if ($ENV{'form.correctans'} eq 'true') {
+    if ($env{'form.correctans'} eq 'true') {
         push(@extra_resp_headers,'Correct');
     } 
-    if ($ENV{'form.prob_status'} eq 'true') {
+    if ($env{'form.prob_status'} eq 'true') {
         push(@extra_resp_headers,'Award Detail'); 
         push(@extra_resp_headers,'Time');
         push(@extra_resp_headers,'Attempt');
@@ -350,7 +350,7 @@
                         $maxrow = scalar(@$results);
                     }
                     for (my $j=scalar(@$results)-1;$j>=0;$j--) {
-                        if ($ENV{'form.all_sub'} ne 'true') {
+                        if ($env{'form.all_sub'} ne 'true') {
                             next if ($j ne scalar(@$results)-1);
                         }
                         my $response = &hashify_response($results->[$j],
@@ -430,7 +430,7 @@
 sub hashify_response {
     my ($response,$prob,$student,$partid,$respid) =@_;
     my $resp_hash = {};
-    if ($ENV{'form.correctans'} eq 'true') {
+    if ($env{'form.correctans'} eq 'true') {
         $resp_hash->{'Correct'} = 
             &Apache::lonstathelpers::get_student_answer
             ($prob,$student->{'username'},$student->{'domain'},
@@ -636,7 +636,7 @@
     # Add headers to the worksheet
     my $rows_output = 0;
     $worksheet->write($rows_output++,0,
-                    $ENV{'course.'.$ENV{'request.course.id'}.'.description'},
+                    $env{'course.'.$env{'request.course.id'}.'.description'},
                       $format->{'h1'});
     $rows_output++;
     my $cols_output = 0;
@@ -725,7 +725,7 @@
                     my $response_start_col = $start_col{$prob->symb}->{$partid}->{$respid};
                     for (my $j=scalar(@$results)-1;$j>=0;$j--) {
                         $cols_output = $response_start_col;
-                        if ($ENV{'form.all_sub'} ne 'true') {
+                        if ($env{'form.all_sub'} ne 'true') {
                             next if ($j ne scalar(@$results)-1);
                         }
                         my $response = &hashify_response($results->[$j],
@@ -878,7 +878,7 @@
     # Open a file
     my $outputfile;
     my $filename = '/prtspool/'.
-        $ENV{'user.name'}.'_'.$ENV{'user.domain'}.'_'.
+        $env{'user.name'}.'_'.$env{'user.domain'}.'_'.
             time.'_'.rand(1000000000).'.csv';
     unless ($outputfile = Apache::File->new('>/home/httpd'.$filename)) {
         $r->log_error("Couldn't open $filename for output $!");
@@ -960,7 +960,7 @@
                         $results = [];
                     }
                     for (my $j=0; $j<scalar(@$results);$j++) {
-                        if ($ENV{'form.all_sub'} ne 'true') {
+                        if ($env{'form.all_sub'} ne 'true') {
                             next if ($j != 0);
                         }
                         my $idx = scalar(@$results) - $j - 1;
@@ -1029,7 +1029,7 @@
     my $output_selector = $/.'<select name="output">'.$/;
     foreach ('HTML','Excel','CSV') {
         $output_selector .= '    <option value="'.lc($_).'"';
-        if ($ENV{'form.output'} eq lc($_)) {
+        if ($env{'form.output'} eq lc($_)) {
             $output_selector .= ' selected ';
         }
         $output_selector .='>'.&mt($_).'</option>'.$/;
@@ -1058,30 +1058,30 @@
     #
     # Render problem checkbox
     my $prob_checkbox = '<input type="checkbox" name="renderprob" ';
-    if (exists($ENV{'form.renderprob'}) && $ENV{'form.renderprob'} eq 'true') {
+    if (exists($env{'form.renderprob'}) && $env{'form.renderprob'} eq 'true') {
         $prob_checkbox .= 'checked ';
     }
     $prob_checkbox .= 'value="true" />';
     #
     # Compute correct answers checkbox
     my $ans_checkbox = '<input type="checkbox" name="correctans" ';
-    if (exists($ENV{'form.correctans'}) && $ENV{'form.correctans'} eq 'true') {
+    if (exists($env{'form.correctans'}) && $env{'form.correctans'} eq 'true') {
         $ans_checkbox .= 'checked ';
     }
     $ans_checkbox .= 'value="true" />';
     #
     # Show all submissions checkbox
     my $all_sub_checkbox = '<input type="checkbox" name="all_sub" ';
-    if (exists($ENV{'form.all_sub'}) && 
-        $ENV{'form.all_sub'} eq 'true') {
+    if (exists($env{'form.all_sub'}) && 
+        $env{'form.all_sub'} eq 'true') {
         $all_sub_checkbox .= 'checked ';
     }
     $all_sub_checkbox.= 'value="true" />';
     #
     # problem status checkbox
     my $prob_status_checkbox = '<input type="checkbox" name="prob_status" ';
-    if (exists($ENV{'form.prob_status'}) && 
-        $ENV{'form.prob_status'} eq 'true') {
+    if (exists($env{'form.prob_status'}) && 
+        $env{'form.prob_status'} eq 'true') {
         $prob_status_checkbox .= 'checked ';
     }
     $prob_status_checkbox .= 'value="true" />';
Index: loncom/interface/statistics/lonsubmissiontimeanalysis.pm
diff -u loncom/interface/statistics/lonsubmissiontimeanalysis.pm:1.22 loncom/interface/statistics/lonsubmissiontimeanalysis.pm:1.23
--- loncom/interface/statistics/lonsubmissiontimeanalysis.pm:1.22	Mon Mar 14 15:28:22 2005
+++ loncom/interface/statistics/lonsubmissiontimeanalysis.pm	Thu Apr  7 02:56:24 2005
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lonsubmissiontimeanalysis.pm,v 1.22 2005/03/14 20:28:22 matthew Exp $
+# $Id: lonsubmissiontimeanalysis.pm,v 1.23 2005/04/07 06:56:24 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -28,7 +28,7 @@
 package Apache::lonsubmissiontimeanalysis;
 
 use strict;
-use Apache::lonnet();
+use Apache::lonnet;
 use Apache::loncommon();
 use Apache::lonhtmlcommon();
 use Apache::loncoursedata();
@@ -78,8 +78,8 @@
         &Apache::lonstathelpers::manage_caches($r,'Statistics','stats_status');
     $r->rflush();
     #
-    if (! exists($ENV{'form.problemchoice'}) ||
-        exists($ENV{'form.SelectAnother'})) {
+    if (! exists($env{'form.problemchoice'}) ||
+        exists($env{'form.SelectAnother'})) {
         $r->print('<input type="submit" name="" value="'.
                   &mt('Graph Problem Submission Times').'" />');
         $r->print('&nbsp;'x5);
@@ -98,25 +98,25 @@
         #
         # Determine which problem we are to analyze
         my $current_problem = &Apache::lonstathelpers::get_target_from_id
-            ($ENV{'form.problemchoice'});
+            ($env{'form.problemchoice'});
         #
         my ($navmap,$prev,$curr,$next) = 
             &Apache::lonstathelpers::get_prev_curr_next($current_problem,
                                                         '.',
                                                         'part');
-        if (exists($ENV{'form.PrevProblemAnalysis'}) && defined($prev)) {
+        if (exists($env{'form.PrevProblemAnalysis'}) && defined($prev)) {
             $current_problem = $prev;
-        } elsif (exists($ENV{'form.NextProblemAnalysis'}) && defined($next)) {
+        } elsif (exists($env{'form.NextProblemAnalysis'}) && defined($next)) {
             $current_problem = $next;
         } else {
             $current_problem = $curr;
         }
         #
         # Store the current problem choice and send it out in the form
-        $ENV{'form.problemchoice'} = 
+        $env{'form.problemchoice'} = 
             &Apache::lonstathelpers::make_target_id($current_problem);
         $r->print('<input type="hidden" name="problemchoice" value="'.
-                  $ENV{'form.problemchoice'}.'" />');
+                  $env{'form.problemchoice'}.'" />');
         #
         $r->print('<hr />');
         $r->rflush();
@@ -388,8 +388,8 @@
 sub CreateInterface {
     ##
     ## Environment variable initialization
-    if (! exists$ENV{'form.AnalyzeOver'}) {
-        $ENV{'form.AnalyzeOver'} = 'Tries';
+    if (! exists$env{'form.AnalyzeOver'}) {
+        $env{'form.AnalyzeOver'} = 'Tries';
     }
     ##
     ## Build the menu
Index: loncom/interface/statistics/lonsurveyreports.pm
diff -u loncom/interface/statistics/lonsurveyreports.pm:1.7 loncom/interface/statistics/lonsurveyreports.pm:1.8
--- loncom/interface/statistics/lonsurveyreports.pm:1.7	Thu Mar 17 19:20:44 2005
+++ loncom/interface/statistics/lonsurveyreports.pm	Thu Apr  7 02:56:24 2005
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lonsurveyreports.pm,v 1.7 2005/03/18 00:20:44 matthew Exp $
+# $Id: lonsurveyreports.pm,v 1.8 2005/04/07 06:56:24 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -27,7 +27,7 @@
 package Apache::lonsurveyreports;
 
 use strict;
-use Apache::lonnet();
+use Apache::lonnet;
 use Apache::loncommon();
 use Apache::lonhtmlcommon();
 use Apache::loncoursedata();
@@ -77,8 +77,8 @@
         &Apache::lonstathelpers::manage_caches($r,'Statistics','stats_status');
     $r->rflush();
     #
-    if (exists($ENV{'form.problemchoice'}) && 
-        ! exists($ENV{'form.SelectAnother'})) {
+    if (exists($env{'form.problemchoice'}) && 
+        ! exists($env{'form.SelectAnother'})) {
         $r->print('&nbsp;'x3);
         foreach my $button (@SubmitButtons) {
             if ($button->{'name'} eq 'break') {
@@ -102,26 +102,26 @@
         #
         # Determine which problem we are to analyze
         my $current_problem = &Apache::lonstathelpers::get_target_from_id
-            ($ENV{'form.problemchoice'});
+            ($env{'form.problemchoice'});
         #
         my ($navmap,$prev,$curr,$next) = 
             &Apache::lonstathelpers::get_prev_curr_next($current_problem,
                                                         '.',
                                                         'part_survey',
                                                         );
-        if (exists($ENV{'form.PrevProblem'}) && defined($prev)) {
+        if (exists($env{'form.PrevProblem'}) && defined($prev)) {
             $current_problem = $prev;
-        } elsif (exists($ENV{'form.NextProblem'}) && defined($next)) {
+        } elsif (exists($env{'form.NextProblem'}) && defined($next)) {
             $current_problem = $next;
         } else {
             $current_problem = $curr;
         }
         #
         # Store the current problem choice and send it out in the form
-        $ENV{'form.problemchoice'} = 
+        $env{'form.problemchoice'} = 
             &Apache::lonstathelpers::make_target_id($current_problem);
         $r->print('<input type="hidden" name="problemchoice" value="'.
-                  $ENV{'form.problemchoice'}.'" />');
+                  $env{'form.problemchoice'}.'" />');
         #
         if (! defined($current_problem->{'resource'})) {
             $r->print('resource is undefined');
@@ -129,19 +129,19 @@
             my $resource = $current_problem->{'resource'};
             $r->print('<h1>'.$resource->compTitle.'</h1>');
             $r->print('<h3>'.$resource->src.'</h3>');
-            if ($ENV{'form.renderprob'} eq 'true') {
+            if ($env{'form.renderprob'} eq 'true') {
                 $r->print(&Apache::lonstathelpers::render_resource($resource));
             }
             $r->rflush();
             my %Data = &Apache::lonstathelpers::get_problem_data
                 ($resource->src);
             &compile_student_answers($r,$current_problem,\%Data,\@Students);
-            if ($ENV{'form.output'} eq 'HTML' || 
-                ! defined($ENV{'form.output'})) {
+            if ($env{'form.output'} eq 'HTML' || 
+                ! defined($env{'form.output'})) {
                 &make_HTML_report($r,$current_problem,\%Data,\@Students);
-            } elsif ($ENV{'form.output'} eq 'Excel') {
+            } elsif ($env{'form.output'} eq 'Excel') {
                 &make_Excel_report($r,$current_problem,\%Data,\@Students);
-            } elsif ($ENV{'form.output'} eq 'TXT') {
+            } elsif ($env{'form.output'} eq 'TXT') {
                 &make_text_report($r,$current_problem,\%Data,\@Students);
             }
         }
@@ -197,7 +197,7 @@
               respid=>undef,
               resptype=>undef});
         my $checked = '';
-        if ($ENV{'form.problemchoice'} eq $value) {
+        if ($env{'form.problemchoice'} eq $value) {
             $checked = 'checked ';
         }
         my $link = $problem->{'res'}->src.
@@ -357,7 +357,7 @@
     #
     my $rows_output=0;
     $worksheet->write($rows_output++,0,
-                    $ENV{'course.'.$ENV{'request.course.id'}.'.description'},
+                    $env{'course.'.$env{'request.course.id'}.'.description'},
                       $format->{'h1'});
     $rows_output++;
     #
@@ -591,15 +591,15 @@
     ## Environment variable initialization
     my $Str = '';
     my $output_selector = '<select name="output" size="5">'.$/;
-    if (! exists($ENV{'form.output'})) {
-        $ENV{'form.output'} = 'HTML';
+    if (! exists($env{'form.output'})) {
+        $env{'form.output'} = 'HTML';
     }
     foreach my $output_format ( {name=>'HTML',text=>&mt("HTML") },
                                 {name=>'Excel',text=>&mt("Excel") },
                                 {name=>'TXT',text=>&mt("Text (essays only)") },
                                 ) {
         $output_selector.='<option value="'.$output_format->{'name'}.'"';
-        if ($ENV{'form.output'} eq $output_format->{'name'}) {
+        if ($env{'form.output'} eq $output_format->{'name'}) {
             $output_selector.=' selected';
         }
         $output_selector.= '>'.$output_format->{'text'}.'</option>'.$/;
@@ -628,7 +628,7 @@
     #
     # Render problem checkbox
     my $prob_checkbox = '<input type="checkbox" name="renderprob" ';
-    if (exists($ENV{'form.renderprob'}) && $ENV{'form.renderprob'} eq 'true') {
+    if (exists($env{'form.renderprob'}) && $env{'form.renderprob'} eq 'true') {
         $prob_checkbox .= 'checked ';
     }
     $prob_checkbox .= 'value="true" />';
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.619 loncom/lonnet/perl/lonnet.pm:1.620
--- loncom/lonnet/perl/lonnet.pm:1.619	Tue Apr  5 16:43:27 2005
+++ loncom/lonnet/perl/lonnet.pm	Thu Apr  7 02:56:24 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.619 2005/04/05 20:43:27 albertel Exp $
+# $Id: lonnet.pm,v 1.620 2005/04/07 06:56:24 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -254,20 +254,6 @@
     return $answer;
 }
 
-#
-# -------------- Remove all key from the env that start witha lowercase letter
-#                (Which is always a lon-capa value)
-
-sub cleanenv {
-#    unless (defined(&Apache::exists_config_define("MODPERL2"))) { return; }
-#    unless (&Apache::exists_config_define("MODPERL2")) { return; }
-    foreach my $key (keys(%ENV)) {
-	if ($key =~ /^[a-z]/) {
-	    delete($ENV{$key});
-	}
-    }
-}
- 
 # ------------------------------------------- Transfer profile into environment
 
 sub transfer_profile_to_env {
@@ -316,7 +302,7 @@
     }
 
     my $lockfh;
-    unless (open($lockfh,"$ENV{'user.environment'}")) {
+    unless (open($lockfh,"$env{'user.environment'}")) {
 	return 'error: '.$!;
     }
     unless (flock($lockfh,LOCK_EX)) {
@@ -329,7 +315,7 @@
     my @oldenv;
     {
 	my $fh;
-	unless (open($fh,"$ENV{'user.environment'}")) {
+	unless (open($fh,"$env{'user.environment'}")) {
 	    return 'error: '.$!;
 	}
 	@oldenv=<$fh>;
@@ -346,7 +332,7 @@
     }
     {
 	my $fh;
-	unless (open($fh,">$ENV{'user.environment'}")) {
+	unless (open($fh,">$env{'user.environment'}")) {
 	    return 'error';
 	}
 	my $newname;
@@ -372,7 +358,7 @@
     my @oldenv;
     {
 	my $fh;
-	unless (open($fh,"$ENV{'user.environment'}")) {
+	unless (open($fh,"$env{'user.environment'}")) {
 	    return 'error';
 	}
 	unless (flock($fh,LOCK_SH)) {
@@ -386,7 +372,7 @@
     }
     {
 	my $fh;
-	unless (open($fh,">$ENV{'user.environment'}")) {
+	unless (open($fh,">$env{'user.environment'}")) {
 	    return 'error';
 	}
 	unless (flock($fh,LOCK_EX)) {
@@ -662,15 +648,15 @@
 #
     my ($ckey,$kdom,$knum,$cdom,$cnum,$udom,$uname,$logentry)=@_;
     $kdom=
-   $ENV{'course.'.$ENV{'request.course.id'}.'.domain'} unless (defined($kdom));
+   $env{'course.'.$env{'request.course.id'}.'.domain'} unless (defined($kdom));
     $knum=
-   $ENV{'course.'.$ENV{'request.course.id'}.'.num'} unless (defined($knum));
+   $env{'course.'.$env{'request.course.id'}.'.num'} unless (defined($knum));
     $cdom=
-   $ENV{'course.'.$ENV{'request.course.id'}.'.domain'} unless (defined($cdom));
+   $env{'course.'.$env{'request.course.id'}.'.domain'} unless (defined($cdom));
     $cnum=
-   $ENV{'course.'.$ENV{'request.course.id'}.'.num'} unless (defined($cnum));
-    $udom=$ENV{'user.name'} unless (defined($udom));
-    $uname=$ENV{'user.domain'} unless (defined($uname));
+   $env{'course.'.$env{'request.course.id'}.'.num'} unless (defined($cnum));
+    $udom=$env{'user.name'} unless (defined($udom));
+    $uname=$env{'user.domain'} unless (defined($uname));
     my %existing=&get('accesskeys',[$ckey],$kdom,$knum);
     if (($existing{$ckey}=~/^\#(.*)$/) || # - new key
         ($existing{$ckey}=~/^\Q$uname\E\:\Q$udom\E\#(.*)$/)) { 
@@ -712,9 +698,9 @@
 #
     my ($ckey,$cdom,$cnum,$logentry)=@_;
     $cdom=
-   $ENV{'course.'.$ENV{'request.course.id'}.'.domain'} unless (defined($cdom));
+   $env{'course.'.$env{'request.course.id'}.'.domain'} unless (defined($cdom));
     $cnum=
-   $ENV{'course.'.$ENV{'request.course.id'}.'.num'} unless (defined($cnum));
+   $env{'course.'.$env{'request.course.id'}.'.num'} unless (defined($cnum));
     my %existing=&get('accesskeys',[$ckey],$cdom,$cnum);
     if ($existing{$ckey}) {
         $existing{$ckey}.='; '.$logentry;
@@ -736,9 +722,9 @@
 sub generate_access_keys {
     my ($number,$cdom,$cnum,$logentry)=@_;
     $cdom=
-   $ENV{'course.'.$ENV{'request.course.id'}.'.domain'} unless (defined($cdom));
+   $env{'course.'.$env{'request.course.id'}.'.domain'} unless (defined($cdom));
     $cnum=
-   $ENV{'course.'.$ENV{'request.course.id'}.'.num'} unless (defined($cnum));
+   $env{'course.'.$env{'request.course.id'}.'.num'} unless (defined($cnum));
     unless (&allowed('mky',$cdom)) { return 0; }
     unless (($cdom) && ($cnum)) { return 0; }
     if ($number>10000) { return 0; }
@@ -757,14 +743,14 @@
        } else {
 	  if (&put('accesskeys',
               { $newkey => '# generated '.localtime().
-                           ' by '.$ENV{'user.name'}.'@'.$ENV{'user.domain'}.
+                           ' by '.$env{'user.name'}.'@'.$env{'user.domain'}.
                            '; '.$logentry },
 		   $cdom,$cnum) eq 'ok') {
               $total++;
 	  }
        }
     }
-    &log($ENV{'user.domain'},$ENV{'user.name'},$ENV{'user.home'},
+    &log($env{'user.domain'},$env{'user.name'},$env{'user.home'},
          'Generated '.$total.' keys for '.$cnum.' at '.$cdom);
     return $total;
 }
@@ -774,11 +760,11 @@
 sub validate_access_key {
     my ($ckey,$cdom,$cnum,$udom,$uname)=@_;
     $cdom=
-   $ENV{'course.'.$ENV{'request.course.id'}.'.domain'} unless (defined($cdom));
+   $env{'course.'.$env{'request.course.id'}.'.domain'} unless (defined($cdom));
     $cnum=
-   $ENV{'course.'.$ENV{'request.course.id'}.'.num'} unless (defined($cnum));
-    $udom=$ENV{'user.domain'} unless (defined($udom));
-    $uname=$ENV{'user.name'} unless (defined($uname));
+   $env{'course.'.$env{'request.course.id'}.'.num'} unless (defined($cnum));
+    $udom=$env{'user.domain'} unless (defined($udom));
+    $uname=$env{'user.name'} unless (defined($uname));
     my %existing=&get('accesskeys',[$ckey],$cdom,$cnum);
     return ($existing{$ckey}=~/^\Q$uname\E\:\Q$udom\E\#/);
 }
@@ -846,6 +832,7 @@
 
 sub save_cache {
     &purge_remembered();
+    undef(%env);
 }
 
 my $to_remember=-1;
@@ -958,11 +945,11 @@
 
 sub chatsend {
     my ($newentry,$anon)=@_;
-    my $cnum=$ENV{'course.'.$ENV{'request.course.id'}.'.num'};
-    my $cdom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
-    my $chome=$ENV{'course.'.$ENV{'request.course.id'}.'.home'};
+    my $cnum=$env{'course.'.$env{'request.course.id'}.'.num'};
+    my $cdom=$env{'course.'.$env{'request.course.id'}.'.domain'};
+    my $chome=$env{'course.'.$env{'request.course.id'}.'.home'};
     &reply('chatsend:'.$cdom.':'.$cnum.':'.
-	   &escape($ENV{'user.domain'}.':'.$ENV{'user.name'}.':'.$anon.':'.
+	   &escape($env{'user.domain'}.':'.$env{'user.name'}.':'.$anon.':'.
 		   &escape($newentry)),$chome);
 }
 
@@ -1162,7 +1149,7 @@
 #         course's home server.
 #
 # action = uploaddoc - /home/httpd/html/userfiles/$domain/1/2/3/$course/$file
-#         will be retrived from $ENV{form.uploaddoc} (from DOCS interface) to
+#         will be retrived from $env{form.uploaddoc} (from DOCS interface) to
 #         /home/httpd/html/userfiles/$domain/1/2/3/$course/$file
 #         and will then be copied to /home/httpd/lonUsers/1/2/3/$course/userfiles/$file
 #         in course's home server.
@@ -1202,7 +1189,7 @@
             }
         } elsif ($action eq 'uploaddoc') {
             open(my $fh,'>'.$filepath.'/'.$fname);
-            print $fh $ENV{'form.'.$source};
+            print $fh $env{'form.'.$source};
             close($fh);
             $fetchresult= &reply('fetchuserfile:'.$docudom.'/'.$docuname.'/'.$file,
                                  $docuhome);
@@ -1246,11 +1233,11 @@
 sub userfileupload {
     my ($formname,$coursedoc,$subdir)=@_;
     if (!defined($subdir)) { $subdir='unknown'; }
-    my $fname=$ENV{'form.'.$formname.'.filename'};
+    my $fname=$env{'form.'.$formname.'.filename'};
     $fname=&clean_filename($fname);
 # See if there is anything left
     unless ($fname) { return 'error: no uploaded file'; }
-    chop($ENV{'form.'.$formname});
+    chop($env{'form.'.$formname});
     if (($formname eq 'screenshot') && ($subdir eq 'helprequests')) { #files uploaded to help request form are handled differently
         my $now = time;
         my $filepath = 'tmp/helprequests/'.$now;
@@ -1263,7 +1250,7 @@
             }
         }
         open(my $fh,'>'.$fullpath.'/'.$fname);
-        print $fh $ENV{'form.'.$formname};
+        print $fh $env{'form.'.$formname};
         close($fh);
         return $fullpath.'/'.$fname; 
     }
@@ -1273,19 +1260,19 @@
     my $docuhome='';
     $fname="$subdir/$fname";
     if ($coursedoc) {
-	$docuname=$ENV{'course.'.$ENV{'request.course.id'}.'.num'};
-	$docudom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
-	$docuhome=$ENV{'course.'.$ENV{'request.course.id'}.'.home'};
-        if ($ENV{'form.folder'} =~ m/^default/) {
+	$docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
+	$docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
+	$docuhome=$env{'course.'.$env{'request.course.id'}.'.home'};
+        if ($env{'form.folder'} =~ m/^default/) {
             return &finishuserfileupload($docuname,$docudom,$docuhome,$formname,$fname);
         } else {
-            $fname=$ENV{'form.folder'}.'/'.$fname;
+            $fname=$env{'form.folder'}.'/'.$fname;
             return &process_coursefile('uploaddoc',$docuname,$docudom,$docuhome,$fname,$formname);
         }
     } else {
-        $docuname=$ENV{'user.name'};
-        $docudom=$ENV{'user.domain'};
-        $docuhome=$ENV{'user.home'};
+        $docuname=$env{'user.name'};
+        $docudom=$env{'user.domain'};
+        $docuhome=$env{'user.home'};
         return &finishuserfileupload($docuname,$docudom,$docuhome,$formname,$fname);
     }
 }
@@ -1311,7 +1298,7 @@
 # Save the file
     {
 	open(FH,'>'.$filepath.'/'.$file);
-	print FH $ENV{'form.'.$formname};
+	print FH $env{'form.'.$formname};
 	close(FH);
     }
 # Notify homeserver to grep it
@@ -1417,9 +1404,9 @@
             ($dom,$name,undef)=($entry=~m:___(\w+)/(\w+)/(.*)___count$:);
             if (! defined($dom) || $dom eq '' || 
                 ! defined($name) || $name eq '') {
-                my $cid = $ENV{'request.course.id'};
-                $dom  = $ENV{'request.'.$cid.'.domain'};
-                $name = $ENV{'request.'.$cid.'.num'};
+                my $cid = $env{'request.course.id'};
+                $dom  = $env{'request.'.$cid.'.domain'};
+                $name = $env{'request.'.$cid.'.num'};
             }
             my $value = $accesshash{$entry};
             my (undef,$url,undef) = ($entry =~ /^(.*)___(.*)___count$/);
@@ -1462,50 +1449,50 @@
 sub courselog {
     my $what=shift;
     $what=time.':'.$what;
-    unless ($ENV{'request.course.id'}) { return ''; }
-    $coursedombuf{$ENV{'request.course.id'}}=
-       $ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
-    $coursenumbuf{$ENV{'request.course.id'}}=
-       $ENV{'course.'.$ENV{'request.course.id'}.'.num'};
-    $coursehombuf{$ENV{'request.course.id'}}=
-       $ENV{'course.'.$ENV{'request.course.id'}.'.home'};
-    $coursedescrbuf{$ENV{'request.course.id'}}=
-       $ENV{'course.'.$ENV{'request.course.id'}.'.description'};
-    $courseinstcodebuf{$ENV{'request.course.id'}}=
-       $ENV{'course.'.$ENV{'request.course.id'}.'.internal.coursecode'};
-    $courseownerbuf{$ENV{'request.course.id'}}=
-       $ENV{'course.'.$ENV{'request.course.id'}.'.internal.courseowner'};
-    if (defined $courselogs{$ENV{'request.course.id'}}) {
-	$courselogs{$ENV{'request.course.id'}}.='&'.$what;
+    unless ($env{'request.course.id'}) { return ''; }
+    $coursedombuf{$env{'request.course.id'}}=
+       $env{'course.'.$env{'request.course.id'}.'.domain'};
+    $coursenumbuf{$env{'request.course.id'}}=
+       $env{'course.'.$env{'request.course.id'}.'.num'};
+    $coursehombuf{$env{'request.course.id'}}=
+       $env{'course.'.$env{'request.course.id'}.'.home'};
+    $coursedescrbuf{$env{'request.course.id'}}=
+       $env{'course.'.$env{'request.course.id'}.'.description'};
+    $courseinstcodebuf{$env{'request.course.id'}}=
+       $env{'course.'.$env{'request.course.id'}.'.internal.coursecode'};
+    $courseownerbuf{$env{'request.course.id'}}=
+       $env{'course.'.$env{'request.course.id'}.'.internal.courseowner'};
+    if (defined $courselogs{$env{'request.course.id'}}) {
+	$courselogs{$env{'request.course.id'}}.='&'.$what;
     } else {
-	$courselogs{$ENV{'request.course.id'}}.=$what;
+	$courselogs{$env{'request.course.id'}}.=$what;
     }
-    if (length($courselogs{$ENV{'request.course.id'}})>4048) {
+    if (length($courselogs{$env{'request.course.id'}})>4048) {
 	&flushcourselogs();
     }
 }
 
 sub courseacclog {
     my $fnsymb=shift;
-    unless ($ENV{'request.course.id'}) { return ''; }
-    my $what=$fnsymb.':'.$ENV{'user.name'}.':'.$ENV{'user.domain'};
+    unless ($env{'request.course.id'}) { return ''; }
+    my $what=$fnsymb.':'.$env{'user.name'}.':'.$env{'user.domain'};
     if ($fnsymb=~/(problem|exam|quiz|assess|survey|form|page)$/) {
         $what.=':POST';
         # FIXME: Probably ought to escape things....
-	foreach (keys %ENV) {
+	foreach (keys %env) {
             if ($_=~/^form\.(.*)/) {
-		$what.=':'.$1.'='.$ENV{$_};
+		$what.=':'.$1.'='.$env{$_};
             }
         }
     } elsif ($fnsymb =~ m:^/adm/searchcat:) {
         # FIXME: We should not be depending on a form parameter that someone
         # editing lonsearchcat.pm might change in the future.
-        if ($ENV{'form.phase'} eq 'course_search') {
+        if ($env{'form.phase'} eq 'course_search') {
             $what.= ':POST';
             # FIXME: Probably ought to escape things....
             foreach my $element ('courseexp','crsfulltext','crsrelated',
                                  'crsdiscuss') {
-                $what.=':'.$element.'='.$ENV{'form.'.$element};
+                $what.=':'.$element.'='.$env{'form.'.$element};
             }
         }
     }
@@ -1515,8 +1502,8 @@
 sub countacc {
     my $url=&declutter(shift);
     return if (! defined($url) || $url eq '');
-    unless ($ENV{'request.course.id'}) { return ''; }
-    $accesshash{$ENV{'request.course.id'}.'___'.$url.'___course'}=1;
+    unless ($env{'request.course.id'}) { return ''; }
+    $accesshash{$env{'request.course.id'}.'___'.$url.'___course'}=1;
     my $key=$$.$processmarker.'_'.$dumpcount.'___'.$url.'___count';
     $accesshash{$key}++;
 }
@@ -1543,7 +1530,7 @@
 
 sub get_course_adv_roles {
     my $cid=shift;
-    $cid=$ENV{'request.course.id'} unless (defined($cid));
+    $cid=$env{'request.course.id'} unless (defined($cid));
     my %coursehash=&coursedescription($cid);
     my %nothide=();
     foreach (split(/\s*\,\s*/,$coursehash{'nothideprivileged'})) {
@@ -1575,8 +1562,8 @@
 
 sub get_my_roles {
     my ($uname,$udom)=@_;
-    unless (defined($uname)) { $uname=$ENV{'user.name'}; }
-    unless (defined($udom)) { $udom=$ENV{'user.domain'}; }
+    unless (defined($uname)) { $uname=$env{'user.name'}; }
+    unless (defined($udom)) { $udom=$env{'user.domain'}; }
     my %dumphash=
             &dump('nohist_userroles',$udom,$uname);
     my %returnhash=();
@@ -1751,7 +1738,7 @@
     
     unless (&allowed('mgr',$tcrsid)) {
         &logthis('Check in '.$token.' ('.$dtoken.') unauthorized: '.
-                 $ENV{'user.name'}.' - '.$ENV{'user.domain'});
+                 $env{'user.name'}.' - '.$env{'user.domain'});
         return '';
     }
 
@@ -1775,15 +1762,15 @@
 
 sub expirespread {
     my ($uname,$udom,$stype,$usymb)=@_;
-    my $cid=$ENV{'request.course.id'}; 
+    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'}.
+       return &reply('put:'.$env{'course.'.$cid.'.domain'}.':'.
+                            $env{'course.'.$cid.'.num'}.
 	        	    ':nohist_expirationdates:'.
                             &escape($key).'='.$now,
-                            $ENV{'course.'.$cid.'.home'})
+                            $env{'course.'.$cid.'.home'})
     }
     return 'ok';
 }
@@ -1792,7 +1779,7 @@
 
 sub devalidate {
     my ($symb,$uname,$udom)=@_;
-    my $cid=$ENV{'request.course.id'}; 
+    my $cid=$env{'request.course.id'}; 
     if ($cid) {
         # delete the stored spreadsheets for
         # - the student level sheet of this user in course's homespace
@@ -1803,8 +1790,8 @@
         my $status=
 	    &del('nohist_calculatedsheets',
 		 [$key.'studentcalc:'],
-		 $ENV{'course.'.$cid.'.domain'},
-		 $ENV{'course.'.$cid.'.num'})
+		 $env{'course.'.$cid.'.domain'},
+		 $env{'course.'.$cid.'.num'})
 		.' '.
 	    &del('nohist_calculatedsheets_'.$cid,
 		 [$key.'assesscalc:'.$symb],$udom,$uname);
@@ -2014,16 +2001,16 @@
   my ($symb,$namespace,$domain,$stuname) = @_;
   if (!$symb) {
     $symb=&symbread();
-    if (!$symb) { $symb= $ENV{'request.url'}; }
+    if (!$symb) { $symb= $env{'request.url'}; }
   }
   $symb=escape($symb);
 
-  if (!$namespace) { $namespace=$ENV{'request.state'}; }
+  if (!$namespace) { $namespace=$env{'request.state'}; }
   $namespace=~s/\//\_/g;
   $namespace=~s/\W//g;
 
-  if (!$domain) { $domain=$ENV{'user.domain'}; }
-  if (!$stuname) { $stuname=$ENV{'user.name'}; }
+  if (!$domain) { $domain=$env{'user.domain'}; }
+  if (!$stuname) { $stuname=$env{'user.name'}; }
   if ($domain eq 'public' && $stuname eq 'public') {
       $stuname=$ENV{'REMOTE_ADDR'};
   }
@@ -2045,22 +2032,22 @@
 
   if (!$symb) {
     $symb=&symbread();
-    if (!$symb) { $symb= $ENV{'request.url'}; }
+    if (!$symb) { $symb= $env{'request.url'}; }
   }
   $symb=escape($symb);
 
   if (!$namespace) {
     # I don't think we would ever want to store this for a course.
     # it seems this will only be used if we don't have a course.
-    #$namespace=$ENV{'request.course.id'};
+    #$namespace=$env{'request.course.id'};
     #if (!$namespace) {
-      $namespace=$ENV{'request.state'};
+      $namespace=$env{'request.state'};
     #}
   }
   $namespace=~s/\//\_/g;
   $namespace=~s/\W//g;
-  if (!$domain) { $domain=$ENV{'user.domain'}; }
-  if (!$stuname) { $stuname=$ENV{'user.name'}; }
+  if (!$domain) { $domain=$env{'user.domain'}; }
+  if (!$stuname) { $stuname=$env{'user.name'}; }
   if ($domain eq 'public' && $stuname eq 'public') {
       $stuname=$ENV{'REMOTE_ADDR'};
   }
@@ -2097,14 +2084,14 @@
 
   if (!$symb) {
     $symb=&symbread();
-    if (!$symb) { $symb= $ENV{'request.url'}; }
+    if (!$symb) { $symb= $env{'request.url'}; }
   }
   $symb=escape($symb);
 
-  if (!$namespace) { $namespace=$ENV{'request.state'}; }
+  if (!$namespace) { $namespace=$env{'request.state'}; }
 
-  if (!$domain) { $domain=$ENV{'user.domain'}; }
-  if (!$stuname) { $stuname=$ENV{'user.name'}; }
+  if (!$domain) { $domain=$env{'user.domain'}; }
+  if (!$stuname) { $stuname=$env{'user.name'}; }
   if ($domain eq 'public' && $stuname eq 'public') {
       $stuname=$ENV{'REMOTE_ADDR'};
   }
@@ -2149,18 +2136,18 @@
     $symb=&symbclean($symb);
     if (!$symb) { unless ($symb=&symbread()) { return ''; } }
 
-    if (!$domain) { $domain=$ENV{'user.domain'}; }
-    if (!$stuname) { $stuname=$ENV{'user.name'}; }
+    if (!$domain) { $domain=$env{'user.domain'}; }
+    if (!$stuname) { $stuname=$env{'user.name'}; }
 
     &devalidate($symb,$stuname,$domain);
 
     $symb=escape($symb);
     if (!$namespace) { 
-       unless ($namespace=$ENV{'request.course.id'}) { 
+       unless ($namespace=$env{'request.course.id'}) { 
           return ''; 
        } 
     }
-    if (!$home) { $home=$ENV{'user.home'}; }
+    if (!$home) { $home=$env{'user.home'}; }
 
     $$storehash{'ip'}=$ENV{'REMOTE_ADDR'};
     $$storehash{'host'}=$perlvar{'lonHostID'};
@@ -2185,18 +2172,18 @@
     $symb=&symbclean($symb);
     if (!$symb) { unless ($symb=&symbread()) { return ''; } }
 
-    if (!$domain) { $domain=$ENV{'user.domain'}; }
-    if (!$stuname) { $stuname=$ENV{'user.name'}; }
+    if (!$domain) { $domain=$env{'user.domain'}; }
+    if (!$stuname) { $stuname=$env{'user.name'}; }
 
     &devalidate($symb,$stuname,$domain);
 
     $symb=escape($symb);
     if (!$namespace) { 
-       unless ($namespace=$ENV{'request.course.id'}) { 
+       unless ($namespace=$env{'request.course.id'}) { 
           return ''; 
        } 
     }
-    if (!$home) { $home=$ENV{'user.home'}; }
+    if (!$home) { $home=$env{'user.home'}; }
 
     $$storehash{'ip'}=$ENV{'REMOTE_ADDR'};
     $$storehash{'host'}=$perlvar{'lonHostID'};
@@ -2225,13 +2212,13 @@
       $symb=&escape(&symbclean($symb));
     }
     if (!$namespace) { 
-       unless ($namespace=$ENV{'request.course.id'}) { 
+       unless ($namespace=$env{'request.course.id'}) { 
           return ''; 
        } 
     }
-    if (!$domain) { $domain=$ENV{'user.domain'}; }
-    if (!$stuname) { $stuname=$ENV{'user.name'}; }
-    if (!$home) { $home=$ENV{'user.home'}; }
+    if (!$domain) { $domain=$env{'user.domain'}; }
+    if (!$stuname) { $stuname=$env{'user.name'}; }
+    if (!$home) { $home=$env{'user.home'}; }
     my $answer=&reply("restore:$domain:$stuname:$namespace:$symb","$home");
 
     my %returnhash=();
@@ -2273,7 +2260,7 @@
            }
            $returnhash{'url'}=&clutter($returnhash{'url'});
            $returnhash{'fn'}=$perlvar{'lonDaemons'}.'/tmp/'.
-	       $ENV{'user.name'}.'_'.$cdomain.'_'.$cnum;
+	       $env{'user.name'}.'_'.$cdomain.'_'.$cnum;
            $envhash{'course.'.$normalid.'.home'}=$chome;
            $envhash{'course.'.$normalid.'.domain'}=$cdomain;
            $envhash{'course.'.$normalid.'.num'}=$cnum;
@@ -2353,7 +2340,7 @@
         my ($author,$adv) = &set_userprivs(\$userroles,\%allroles);
         $userroles.='user.adv='.$adv."\n".
 	            'user.author='.$author."\n";
-        $ENV{'user.adv'}=$adv;
+        $env{'user.adv'}=$adv;
     }
     return $userroles;  
 }
@@ -2445,8 +2432,8 @@
        $items.=escape($_).'&';
    }
    $items=~s/\&$//;
-   if (!$udomain) { $udomain=$ENV{'user.domain'}; }
-   if (!$uname) { $uname=$ENV{'user.name'}; }
+   if (!$udomain) { $udomain=$env{'user.domain'}; }
+   if (!$uname) { $uname=$env{'user.name'}; }
    my $uhome=&homeserver($uname,$udomain);
 
    my $rep=&reply("get:$udomain:$uname:$namespace:$items",$uhome);
@@ -2472,8 +2459,8 @@
        $items.=escape($_).'&';
    }
    $items=~s/\&$//;
-   if (!$udomain) { $udomain=$ENV{'user.domain'}; }
-   if (!$uname) { $uname=$ENV{'user.name'}; }
+   if (!$udomain) { $udomain=$env{'user.domain'}; }
+   if (!$uname) { $uname=$env{'user.name'}; }
    my $uhome=&homeserver($uname,$udomain);
 
    return &reply("del:$udomain:$uname:$namespace:$items",$uhome);
@@ -2483,8 +2470,8 @@
 
 sub dump {
    my ($namespace,$udomain,$uname,$regexp)=@_;
-   if (!$udomain) { $udomain=$ENV{'user.domain'}; }
-   if (!$uname) { $uname=$ENV{'user.name'}; }
+   if (!$udomain) { $udomain=$env{'user.domain'}; }
+   if (!$uname) { $uname=$env{'user.name'}; }
    my $uhome=&homeserver($uname,$udomain);
    if ($regexp) {
        $regexp=&escape($regexp);
@@ -2505,8 +2492,8 @@
 
 sub getkeys {
    my ($namespace,$udomain,$uname)=@_;
-   if (!$udomain) { $udomain=$ENV{'user.domain'}; }
-   if (!$uname) { $uname=$ENV{'user.name'}; }
+   if (!$udomain) { $udomain=$env{'user.domain'}; }
+   if (!$uname) { $uname=$env{'user.name'}; }
    my $uhome=&homeserver($uname,$udomain);
    my $rep=reply("keys:$udomain:$uname:$namespace",$uhome);
    my @keyarray=();
@@ -2519,9 +2506,9 @@
 # --------------------------------------------------------------- currentdump
 sub currentdump {
    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));
+   $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)/);
@@ -2579,8 +2566,8 @@
 
 sub inc {
     my ($namespace,$store,$udomain,$uname) = @_;
-    if (!$udomain) { $udomain=$ENV{'user.domain'}; }
-    if (!$uname) { $uname=$ENV{'user.name'}; }
+    if (!$udomain) { $udomain=$env{'user.domain'}; }
+    if (!$uname) { $uname=$env{'user.name'}; }
     my $uhome=&homeserver($uname,$udomain);
     my $items='';
     if (! ref($store)) {
@@ -2603,8 +2590,8 @@
 
 sub put {
    my ($namespace,$storehash,$udomain,$uname)=@_;
-   if (!$udomain) { $udomain=$ENV{'user.domain'}; }
-   if (!$uname) { $uname=$ENV{'user.name'}; }
+   if (!$udomain) { $udomain=$env{'user.domain'}; }
+   if (!$uname) { $uname=$env{'user.name'}; }
    my $uhome=&homeserver($uname,$udomain);
    my $items='';
    foreach (keys %$storehash) {
@@ -2618,8 +2605,8 @@
                                                                                      
 sub putstore {
    my ($namespace,$storehash,$udomain,$uname)=@_;
-   if (!$udomain) { $udomain=$ENV{'user.domain'}; }
-   if (!$uname) { $uname=$ENV{'user.name'}; }
+   if (!$udomain) { $udomain=$env{'user.domain'}; }
+   if (!$uname) { $uname=$env{'user.name'}; }
    my $uhome=&homeserver($uname,$udomain);
    my $items='';
    my %allitems = ();
@@ -2642,8 +2629,8 @@
 
 sub cput {
    my ($namespace,$storehash,$udomain,$uname)=@_;
-   if (!$udomain) { $udomain=$ENV{'user.domain'}; }
-   if (!$uname) { $uname=$ENV{'user.name'}; }
+   if (!$udomain) { $udomain=$env{'user.domain'}; }
+   if (!$uname) { $uname=$env{'user.name'}; }
    my $uhome=&homeserver($uname,$udomain);
    my $items='';
    foreach (keys %$storehash) {
@@ -2662,8 +2649,8 @@
        $items.=escape($_).'&';
    }
    $items=~s/\&$//;
-   if (!$udomain) { $udomain=$ENV{'user.domain'}; }
-   if (!$uname) { $uname=$ENV{'user.name'}; }
+   if (!$udomain) { $udomain=$env{'user.domain'}; }
+   if (!$uname) { $uname=$env{'user.name'}; }
    my $uhome=&homeserver($uname,$udomain);
    my $rep=&reply("eget:$udomain:$uname:$namespace:$items",$uhome);
    my @pairs=split(/\&/,$rep);
@@ -2680,7 +2667,7 @@
 
 sub customaccess {
     my ($priv,$uri)=@_;
-    my ($urole,$urealm)=split(/\./,$ENV{'request.role'});
+    my ($urole,$urealm)=split(/\./,$env{'request.role'});
     $urealm=~s/^\W//;
     my ($udom,$ucrs,$usec)=split(/\//,$urealm);
     my $access=0;
@@ -2720,7 +2707,7 @@
     
     
     
-    if (defined($ENV{'allowed.'.$priv})) { return $ENV{'allowed.'.$priv}; }
+    if (defined($env{'allowed.'.$priv})) { return $env{'allowed.'.$priv}; }
 # Free bre access to adm and meta resources
     if (((($uri=~/^adm\//) && ($uri !~ m|/bulletinboard$|)) 
 	 || ($uri=~/\.meta$/)) && ($priv eq 'bre')) {
@@ -2729,8 +2716,8 @@
 
 # Free bre access to user's own portfolio contents
     my ($space,$domain,$name,$dir)=split('/',$uri);
-    if (($space=~/^(uploaded|ediupload)$/) && ($ENV{'user.name'} eq $name) && 
-	($ENV{'user.domain'} eq $domain) && ('portfolio' eq $dir)) {
+    if (($space=~/^(uploaded|ediupload)$/) && ($env{'user.name'} eq $name) && 
+	($env{'user.domain'} eq $domain) && ('portfolio' eq $dir)) {
         return 'F';
     }
 
@@ -2738,23 +2725,23 @@
 
     if ($priv eq 'bre') {
         my $copyright=&metadata($uri,'copyright');
-	if (($copyright eq 'public') && (!$ENV{'request.course.id'})) { 
+	if (($copyright eq 'public') && (!$env{'request.course.id'})) { 
            return 'F'; 
         }
         if ($copyright eq 'priv') {
             $uri=~/([^\/]+)\/([^\/]+)\//;
-	    unless (($ENV{'user.name'} eq $2) && ($ENV{'user.domain'} eq $1)) {
+	    unless (($env{'user.name'} eq $2) && ($env{'user.domain'} eq $1)) {
 		return '';
             }
         }
         if ($copyright eq 'domain') {
             $uri=~/([^\/]+)\/([^\/]+)\//;
-	    unless (($ENV{'user.domain'} eq $1) ||
-                 ($ENV{'course.'.$ENV{'request.course.id'}.'.domain'} eq $1)) {
+	    unless (($env{'user.domain'} eq $1) ||
+                 ($env{'course.'.$env{'request.course.id'}.'.domain'} eq $1)) {
 		return '';
             }
         }
-        if ($ENV{'request.role'}=~ /li\.\//) {
+        if ($env{'request.role'}=~ /li\.\//) {
             # Library role, so allow browsing of resources in this domain.
             return 'F';
         }
@@ -2763,11 +2750,11 @@
         }
     }
     # Domain coordinator is trying to create a course
-    if (($priv eq 'ccc') && ($ENV{'request.role'} =~ /^dc\./)) {
+    if (($priv eq 'ccc') && ($env{'request.role'} =~ /^dc\./)) {
         # uri is the requested domain in this case.
         # comparison to 'request.role.domain' shows if the user has selected
         # a role of dc for the domain in question. 
-        return 'F' if ($uri eq $ENV{'request.role.domain'});
+        return 'F' if ($uri eq $env{'request.role.domain'});
     }
 
     my $thisallowed='';
@@ -2776,13 +2763,13 @@
 
 # Course
 
-    if ($ENV{'user.priv.'.$ENV{'request.role'}.'./'}=~/\Q$priv\E\&([^\:]*)/) {
+    if ($env{'user.priv.'.$env{'request.role'}.'./'}=~/\Q$priv\E\&([^\:]*)/) {
        $thisallowed.=$1;
     }
 
 # Domain
 
-    if ($ENV{'user.priv.'.$ENV{'request.role'}.'./'.(split(/\//,$uri))[0].'/'}
+    if ($env{'user.priv.'.$env{'request.role'}.'./'.(split(/\//,$uri))[0].'/'}
        =~/\Q$priv\E\&([^\:]*)/) {
        $thisallowed.=$1;
     }
@@ -2792,7 +2779,7 @@
     $courseuri=~s/\_(\d)/\/$1/;
     $courseuri=~s/^([^\/])/\/$1/;
 
-    if ($ENV{'user.priv.'.$ENV{'request.role'}.'.'.$courseuri}
+    if ($env{'user.priv.'.$env{'request.role'}.'.'.$courseuri}
        =~/\Q$priv\E\&([^\:]*)/) {
        $thisallowed.=$1;
     }
@@ -2800,7 +2787,7 @@
 # URI is an uploaded document for this course
 # not allowing 'edit' access (editupload) to uploaded course docs
     if (($priv eq 'bre') && ($uri=~m|^uploaded/|)) {
-	my $refuri=$ENV{'httpref.'.$orguri};
+	my $refuri=$env{'httpref.'.$orguri};
 	if ($refuri) {
 	    if ($refuri =~ m|^/adm/|) {
 		$thisallowed='F';
@@ -2825,18 +2812,18 @@
 # Course: See if uri or referer is an individual resource that is part of 
 # the course
 
-    if ($ENV{'request.course.id'}) {
+    if ($env{'request.course.id'}) {
 
-       $courseprivid=$ENV{'request.course.id'};
-       if ($ENV{'request.course.sec'}) {
-          $courseprivid.='/'.$ENV{'request.course.sec'};
+       $courseprivid=$env{'request.course.id'};
+       if ($env{'request.course.sec'}) {
+          $courseprivid.='/'.$env{'request.course.sec'};
        }
        $courseprivid=~s/\_/\//;
        my $checkreferer=1;
        my ($match,$cond)=&is_on_map($uri);
        if ($match) {
            $statecond=$cond;
-           if ($ENV{'user.priv.'.$ENV{'request.role'}.'./'.$courseprivid}
+           if ($env{'user.priv.'.$env{'request.role'}.'./'.$courseprivid}
                =~/\Q$priv\E\&([^\:]*)/) {
                $thisallowed.=$1;
                $checkreferer=0;
@@ -2844,16 +2831,16 @@
        }
        
        if ($checkreferer) {
-	  my $refuri=$ENV{'httpref.'.$orguri};
+	  my $refuri=$env{'httpref.'.$orguri};
             unless ($refuri) {
-                foreach (keys %ENV) {
+                foreach (keys %env) {
 		    if ($_=~/^httpref\..*\*/) {
 			my $pattern=$_;
                         $pattern=~s/^httpref\.\/res\///;
                         $pattern=~s/\*/\[\^\/\]\+/g;
                         $pattern=~s/\//\\\//g;
                         if ($orguri=~/$pattern/) {
-			    $refuri=$ENV{$_};
+			    $refuri=$env{$_};
                         }
                     }
                 }
@@ -2864,7 +2851,7 @@
           my ($match,$cond)=&is_on_map($refuri);
             if ($match) {
               my $refstatecond=$cond;
-              if ($ENV{'user.priv.'.$ENV{'request.role'}.'./'.$courseprivid}
+              if ($env{'user.priv.'.$env{'request.role'}.'./'.$courseprivid}
                   =~/\Q$priv\E\&([^\:]*)/) {
                   $thisallowed.=$1;
                   $uri=$refuri;
@@ -2904,39 +2891,39 @@
 
     my $envkey;
     if ($thisallowed=~/L/) {
-        foreach $envkey (keys %ENV) {
+        foreach $envkey (keys %env) {
            if ($envkey=~/^user\.role\.(st|ta)\.([^\.]*)/) {
                my $courseid=$2;
                my $roleid=$1.'.'.$2;
                $courseid=~s/^\///;
                my $expiretime=600;
-               if ($ENV{'request.role'} eq $roleid) {
+               if ($env{'request.role'} eq $roleid) {
 		  $expiretime=120;
                }
 	       my ($cdom,$cnum,$csec)=split(/\//,$courseid);
                my $prefix='course.'.$cdom.'_'.$cnum.'.';
-               if ((time-$ENV{$prefix.'last_cache'})>$expiretime) {
+               if ((time-$env{$prefix.'last_cache'})>$expiretime) {
 		   &coursedescription($courseid);
                }
-               if (($ENV{$prefix.'res.'.$uri.'.lock.sections'}=~/\,\Q$csec\E\,/)
-                || ($ENV{$prefix.'res.'.$uri.'.lock.sections'} eq 'all')) {
-		   if ($ENV{$prefix.'res.'.$uri.'.lock.expire'}>time) {
-                       &log($ENV{'user.domain'},$ENV{'user.name'},
-                            $ENV{'user.home'},
+               if (($env{$prefix.'res.'.$uri.'.lock.sections'}=~/\,\Q$csec\E\,/)
+                || ($env{$prefix.'res.'.$uri.'.lock.sections'} eq 'all')) {
+		   if ($env{$prefix.'res.'.$uri.'.lock.expire'}>time) {
+                       &log($env{'user.domain'},$env{'user.name'},
+                            $env{'user.home'},
                             'Locked by res: '.$priv.' for '.$uri.' due to '.
                             $cdom.'/'.$cnum.'/'.$csec.' expire '.
-                            $ENV{$prefix.'priv.'.$priv.'.lock.expire'});
+                            $env{$prefix.'priv.'.$priv.'.lock.expire'});
 		       return '';
                    }
                }
-               if (($ENV{$prefix.'priv.'.$priv.'.lock.sections'}=~/\,\Q$csec\E\,/)
-                || ($ENV{$prefix.'priv.'.$priv.'.lock.sections'} eq 'all')) {
-		   if ($ENV{'priv.'.$priv.'.lock.expire'}>time) {
-                       &log($ENV{'user.domain'},$ENV{'user.name'},
-                            $ENV{'user.home'},
+               if (($env{$prefix.'priv.'.$priv.'.lock.sections'}=~/\,\Q$csec\E\,/)
+                || ($env{$prefix.'priv.'.$priv.'.lock.sections'} eq 'all')) {
+		   if ($env{'priv.'.$priv.'.lock.expire'}>time) {
+                       &log($env{'user.domain'},$env{'user.name'},
+                            $env{'user.home'},
                             'Locked by priv: '.$priv.' for '.$uri.' due to '.
                             $cdom.'/'.$cnum.'/'.$csec.' expire '.
-                            $ENV{$prefix.'priv.'.$priv.'.lock.expire'});
+                            $env{$prefix.'priv.'.$priv.'.lock.expire'});
 		       return '';
                    }
                }
@@ -2948,7 +2935,7 @@
 # Rest of the restrictions depend on selected course
 #
 
-    unless ($ENV{'request.course.id'}) {
+    unless ($env{'request.course.id'}) {
        return '1';
     }
 
@@ -2960,21 +2947,21 @@
 # Course preferences
 
    if ($thisallowed=~/C/) {
-       my $rolecode=(split(/\./,$ENV{'request.role'}))[0];
-       my $unamedom=$ENV{'user.name'}.':'.$ENV{'user.domain'};
-       if ($ENV{'course.'.$ENV{'request.course.id'}.'.'.$priv.'.roles.denied'}
+       my $rolecode=(split(/\./,$env{'request.role'}))[0];
+       my $unamedom=$env{'user.name'}.':'.$env{'user.domain'};
+       if ($env{'course.'.$env{'request.course.id'}.'.'.$priv.'.roles.denied'}
 	   =~/\Q$rolecode\E/) {
-           &log($ENV{'user.domain'},$ENV{'user.name'},$ENV{'user.host'},
+           &log($env{'user.domain'},$env{'user.name'},$env{'user.host'},
                 'Denied by role: '.$priv.' for '.$uri.' as '.$rolecode.' in '.
-                $ENV{'request.course.id'});
+                $env{'request.course.id'});
            return '';
        }
 
-       if ($ENV{'course.'.$ENV{'request.course.id'}.'.'.$priv.'.users.denied'}
+       if ($env{'course.'.$env{'request.course.id'}.'.'.$priv.'.users.denied'}
 	   =~/\Q$unamedom\E/) {
-           &log($ENV{'user.domain'},$ENV{'user.name'},$ENV{'user.host'},
+           &log($env{'user.domain'},$env{'user.name'},$env{'user.host'},
                 'Denied by user: '.$priv.' for '.$uri.' as '.$unamedom.' in '.
-                $ENV{'request.course.id'});
+                $env{'request.course.id'});
            return '';
        }
    }
@@ -2982,9 +2969,9 @@
 # Resource preferences
 
    if ($thisallowed=~/R/) {
-       my $rolecode=(split(/\./,$ENV{'request.role'}))[0];
+       my $rolecode=(split(/\./,$env{'request.role'}))[0];
        if (&metadata($uri,'roledeny')=~/\Q$rolecode\E/) {
-	  &log($ENV{'user.domain'},$ENV{'user.name'},$ENV{'user.host'},
+	  &log($env{'user.domain'},$env{'user.name'},$env{'user.host'},
                     'Denied by role: '.$priv.' for '.$uri.' as '.$rolecode);
           return '';
        }
@@ -2993,9 +2980,9 @@
 # Restricted by state or randomout?
 
    if ($thisallowed=~/X/) {
-      if ($ENV{'acc.randomout'}) {
+      if ($env{'acc.randomout'}) {
 	 if (!$symb) { $symb=&symbread($uri,1); }
-         if (($symb) && ($ENV{'acc.randomout'}=~/\&\Q$symb\E\&/)) { 
+         if (($symb) && ($env{'acc.randomout'}=~/\&\Q$symb\E\&/)) { 
             return ''; 
          }
       }
@@ -3020,7 +3007,7 @@
     $pathname=~s|/\Q$filename\E$||;
     $pathname=~s/^adm\/wrapper\///;    
     #Trying to find the conditional for the file
-    my $match=($ENV{'acc.res.'.$ENV{'request.course.id'}.'.'.$pathname}=~
+    my $match=($env{'acc.res.'.$env{'request.course.id'}.'.'.$pathname}=~
 	       /\&\Q$filename\E\:([\d\|]+)\&/);
     if ($match) {
 	return (1,$1);
@@ -3039,7 +3026,7 @@
 # Must be an alias
     my $aliassymb='';
     my %bighash;
-    if (tie(%bighash,'GDBM_File',$ENV{'request.course.fn'}.'.db',
+    if (tie(%bighash,'GDBM_File',$env{'request.course.fn'}.'.db',
                             &GDBM_READER(),0640)) {
         my $rid=$bighash{'mapalias_'.$symb};
 	if ($rid) {
@@ -3084,11 +3071,11 @@
             }
         }
     }
-    my $command="encrypt:rolesput:$ENV{'user.domain'}:$ENV{'user.name'}:".
-                "$ENV{'user.domain'}:$ENV{'user.name'}:".
+    my $command="encrypt:rolesput:$env{'user.domain'}:$env{'user.name'}:".
+                "$env{'user.domain'}:$env{'user.name'}:".
 	        "rolesdef_$rolename=".
                 escape($sysrole.'_'.$domrole.'_'.$courole);
-    return reply($command,$ENV{'user.home'});
+    return reply($command,$env{'user.home'});
   } else {
     return 'refused';
   }
@@ -3150,7 +3137,7 @@
     $cmd =~ s/%%$//;
     $cmd = &escape($cmd);
     my $query = 'fetchenrollment';
-    my $queryid=&reply("querysend:".$query.':'.$dom.':'.$ENV{'user.name'}.':'.$cmd,$homeserver);
+    my $queryid=&reply("querysend:".$query.':'.$dom.':'.$env{'user.name'}.':'.$cmd,$homeserver);
     unless ($queryid=~/^\Q$host\E\_/) { 
         &logthis('fetch_enrollment_query: invalid queryid: '.$queryid.' for host: '.$host.' and homeserver: '.$homeserver.' context: '.$context.' '.$cnum); 
         return 'error: '.$queryid;
@@ -3162,7 +3149,7 @@
         $tries ++;
     }
     if ( ($reply =~/^timeout/) || ($reply =~/^error/) ) {
-        &logthis('fetch_enrollment_query error: '.$reply.' for '.$dom.' '.$ENV{'user.name'}.' for '.$queryid.' context: '.$context.' '.$cnum.' maxtries: '.$maxtries.' tries: '.$tries);
+        &logthis('fetch_enrollment_query error: '.$reply.' for '.$dom.' '.$env{'user.name'}.' for '.$queryid.' context: '.$context.' '.$cnum.' maxtries: '.$maxtries.' tries: '.$tries);
     } else {
         my @responses = split/:/,$reply;
         if ($homeserver eq $perlvar{'lonHostID'}) {
@@ -3227,14 +3214,14 @@
 # end: timestamp
 #
     my (%filters)=@_;
-    unless ($ENV{'request.course.id'}) { return 'no_course'; }
+    unless ($env{'request.course.id'}) { return 'no_course'; }
     if ($filters{'url'}) {
 	$filters{'url'}=&symbclean(&declutter($filters{'url'}));
         $filters{'url'}=~s/\.(\w+)$/(\\.\\d+)*\\.$1/;
         $filters{'url'}=~s/\.(\w+)\_\_\_/(\\.\\d+)*\\.$1/;
     }
-    my $cname=$ENV{'course.'.$ENV{'request.course.id'}.'.num'};
-    my $cdom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
+    my $cname=$env{'course.'.$env{'request.course.id'}.'.num'};
+    my $cdom=$env{'course.'.$env{'request.course.id'}.'.domain'};
     return &log_query($cname,$cdom,'courselog',%filters);
 }
 
@@ -3302,8 +3289,8 @@
                 last;
             }
         }
-        if (($ENV{'user.name'}) && ($ENV{'user.domain'} eq $codedom)) {
-            $homeserver = &homeserver($ENV{'user.name'},$codedom);
+        if (($env{'user.name'}) && ($env{'user.domain'} eq $codedom)) {
+            $homeserver = &homeserver($env{'user.name'},$codedom);
         }
     } else {
         $homeserver = &homeserver($caller,$codedom);
@@ -3342,7 +3329,7 @@
 	unless (&allowed('ccr',$cwosec)) {
            &logthis('Refused custom assignrole: '.
              $udom.' '.$uname.' '.$url.' '.$role.' '.$end.' '.$start.' by '.
-		    $ENV{'user.name'}.' at '.$ENV{'user.domain'});
+		    $env{'user.name'}.' at '.$env{'user.domain'});
            return 'refused'; 
         }
         $mrole='cr';
@@ -3352,12 +3339,12 @@
         unless ((&allowed('c'.$role,$cwosec)) || &allowed('c'.$role,$udom)) { 
            &logthis('Refused assignrole: '.
              $udom.' '.$uname.' '.$url.' '.$role.' '.$end.' '.$start.' by '.
-		    $ENV{'user.name'}.' at '.$ENV{'user.domain'});
+		    $env{'user.name'}.' at '.$env{'user.domain'});
            return 'refused'; 
         }
         $mrole=$role;
     }
-    my $command="encrypt:rolesput:$ENV{'user.domain'}:$ENV{'user.name'}:".
+    my $command="encrypt:rolesput:$env{'user.domain'}:$env{'user.name'}:".
                 "$udom:$uname:$url".'_'."$mrole=$role";
     if ($end) { $command.='_'.$end; }
     if ($start) {
@@ -3371,9 +3358,9 @@
     if ($deleteflag) {
 	if ((&allowed('dro',$udom)) || (&allowed('dro',$url))) {
 # modify command to delete the role
-           $command="encrypt:rolesdel:$ENV{'user.domain'}:$ENV{'user.name'}:".
+           $command="encrypt:rolesdel:$env{'user.domain'}:$env{'user.name'}:".
                 "$udom:$uname:$url".'_'."$mrole";
-	   &logthis("$ENV{'user.name'} at $ENV{'user.domain'} deletes $mrole in $url for $uname at $udom"); 
+	   &logthis("$env{'user.name'} at $env{'user.domain'} deletes $mrole in $url for $uname at $udom"); 
 # set start and finish to negative values for userrolelog
            $start=-1;
            $end=-1;
@@ -3396,16 +3383,16 @@
     my $uhome=&homeserver($uname,$udom);
     unless (&allowed('mau',$udom)) { return 'refused'; }
     &logthis('Call to modify user authentication '.$udom.', '.$uname.', '.
-             $umode.' by '.$ENV{'user.name'}.' at '.$ENV{'user.domain'}.
-             ' in domain '.$ENV{'request.role.domain'});  
+             $umode.' by '.$env{'user.name'}.' at '.$env{'user.domain'}.
+             ' in domain '.$env{'request.role.domain'});  
     my $reply=&reply('encrypt:changeuserauth:'.$udom.':'.$uname.':'.$umode.':'.
 		     &escape($upass),$uhome);
-    &log($ENV{'user.domain'},$ENV{'user.name'},$ENV{'user.home'},
+    &log($env{'user.domain'},$env{'user.name'},$env{'user.home'},
         'Authentication changed for '.$udom.', '.$uname.', '.$umode.
          '(Remote '.$ENV{'REMOTE_ADDR'}.'): '.$reply);
     &log($udom,,$uname,$uhome,
-        'Authentication changed by '.$ENV{'user.domain'}.', '.
-                                     $ENV{'user.name'}.', '.$umode.
+        'Authentication changed by '.$env{'user.domain'}.', '.
+                                     $env{'user.name'}.', '.$umode.
          '(Remote '.$ENV{'REMOTE_ADDR'}.'): '.$reply);
     unless ($reply eq 'ok') {
         &logthis('Authentication mode error: '.$reply);
@@ -3428,8 +3415,8 @@
 	     $last.', '.$gene.'(forceid: '.$forceid.')'.
              (defined($desiredhome) ? ' desiredhome = '.$desiredhome :
                                      ' desiredhome not specified'). 
-             ' by '.$ENV{'user.name'}.' at '.$ENV{'user.domain'}.
-             ' in domain '.$ENV{'request.role.domain'});
+             ' by '.$env{'user.name'}.' at '.$env{'user.domain'}.
+             ' in domain '.$env{'request.role.domain'});
     my $uhome=&homeserver($uname,$udom,'true');
 # ----------------------------------------------------------------- Create User
     if (($uhome eq 'no_host') && 
@@ -3437,8 +3424,8 @@
         my $unhome='';
         if (defined($desiredhome) && $hostdom{$desiredhome} eq $udom) { 
             $unhome = $desiredhome;
-	} elsif($ENV{'course.'.$ENV{'request.course.id'}.'.domain'} eq $udom) {
-	    $unhome=$ENV{'course.'.$ENV{'request.course.id'}.'.home'};
+	} elsif($env{'course.'.$env{'request.course.id'}.'.domain'} eq $udom) {
+	    $unhome=$env{'course.'.$env{'request.course.id'}.'.home'};
         } else { # load balancing routine for determining $unhome
             my $tryserver;
             my $loadm=10000000;
@@ -3509,7 +3496,7 @@
     &logthis('Success modifying user '.$udom.', '.$uname.', '.$uid.', '.
              $umode.', '.$first.', '.$middle.', '.
 	     $last.', '.$gene.' by '.
-             $ENV{'user.name'}.' at '.$ENV{'user.domain'});
+             $env{'user.name'}.' at '.$env{'user.domain'});
     return 'ok';
 }
 
@@ -3519,7 +3506,7 @@
     my ($udom,$uname,$uid,$umode,$upass,$first,$middle,$last,$gene,$usec,
         $end,$start,$forceid,$desiredhome,$email,$type,$locktype,$cid)=@_;
     if (!$cid) {
-	unless ($cid=$ENV{'request.course.id'}) {
+	unless ($cid=$env{'request.course.id'}) {
 	    return 'not_in_class';
 	}
     }
@@ -3540,15 +3527,15 @@
     my ($udom,$uname,$uid,$first,$middle,$last,$gene,$usec,$end,$start,$type,$locktype,$cid) = @_;
     my ($cdom,$cnum,$chome);
     if (!$cid) {
-	unless ($cid=$ENV{'request.course.id'}) {
+	unless ($cid=$env{'request.course.id'}) {
 	    return 'not_in_class';
 	}
-	$cdom=$ENV{'course.'.$cid.'.domain'};
-	$cnum=$ENV{'course.'.$cid.'.num'};
+	$cdom=$env{'course.'.$cid.'.domain'};
+	$cnum=$env{'course.'.$cid.'.num'};
     } else {
 	($cdom,$cnum)=split(/_/,$cid);
     }
-    $chome=$ENV{'course.'.$cid.'.home'};
+    $chome=$env{'course.'.$cid.'.home'};
     if (!$chome) {
 	$chome=&homeserver($cnum,$cdom);
     }
@@ -3657,7 +3644,7 @@
        } 
    }
 # ------------------------------------------------ Check supplied server name
-    $course_server = $ENV{'user.homeserver'} if (! defined($course_server));
+    $course_server = $env{'user.homeserver'} if (! defined($course_server));
     if (! exists($libserv{$course_server})) {
         return 'error:bad server name '.$course_server;
     }
@@ -3680,7 +3667,7 @@
 # ------------------------------------------ For standard courses, make top url
         my $mapurl=&clutter($url);
         if ($mapurl eq '/res/') { $mapurl=''; }
-        $ENV{'form.initmap'}=(<<ENDINITMAP);
+        $env{'form.initmap'}=(<<ENDINITMAP);
 <map>
 <resource id="1" type="start"></resource>
 <resource id="2" src="$mapurl"></resource>
@@ -3739,7 +3726,7 @@
     my $is_locked;
     push @check, $file_name;
     my %locked = &get('file_permissions',\@check,
-		      $ENV{'user.domain'},$ENV{'user.name'});
+		      $env{'user.domain'},$env{'user.name'});
     my ($tmp)=keys(%locked);
     if ($tmp=~/^error:/) { undef(%locked); }
 
@@ -3773,7 +3760,7 @@
     my @other_files = &files_not_in_path($user, $path);
     open (OUT, '>'.$Apache::lonnet::perlvar{'lonDaemons'}.'/tmp/'.$filename);
     foreach my $file (@files) {
-        print (OUT $ENV{'form.currentpath'}.$file."\n");
+        print (OUT $env{'form.currentpath'}.$file."\n");
     }
     foreach my $file (@other_files) {
         print (OUT $file."\n");
@@ -4038,11 +4025,11 @@
 
 sub directcondval {
     my $number=shift;
-    if (!defined($ENV{'user.state.'.$ENV{'request.course.id'}})) {
+    if (!defined($env{'user.state.'.$env{'request.course.id'}})) {
 	&Apache::lonuserstate::evalstate();
     }
-    if ($ENV{'user.state.'.$ENV{'request.course.id'}}) {
-       return substr($ENV{'user.state.'.$ENV{'request.course.id'}},$number,1);
+    if ($env{'user.state.'.$env{'request.course.id'}}) {
+       return substr($env{'user.state.'.$env{'request.course.id'}},$number,1);
     } else {
        return 2;
     }
@@ -4053,13 +4040,13 @@
     my $result=0;
     my $allpathcond='';
     foreach (split(/\|/,$condidx)) {
-       if (defined($ENV{'acc.cond.'.$ENV{'request.course.id'}.'.'.$_})) {
+       if (defined($env{'acc.cond.'.$env{'request.course.id'}.'.'.$_})) {
 	   $allpathcond.=
-               '('.$ENV{'acc.cond.'.$ENV{'request.course.id'}.'.'.$_}.')|';
+               '('.$env{'acc.cond.'.$env{'request.course.id'}.'.'.$_}.')|';
        }
     }
     $allpathcond=~s/\|$//;
-    if ($ENV{'request.course.id'}) {
+    if ($env{'request.course.id'}) {
        if ($allpathcond) {
           my $operand='|';
 	  my @stack;
@@ -4136,7 +4123,7 @@
 sub EXT_cache_status {
     my ($target_domain,$target_user) = @_;
     my $cachename = 'cache.EXT.'.$target_user.'.'.$target_domain;
-    if (exists($ENV{$cachename}) && ($ENV{$cachename}+600) > time) {
+    if (exists($env{$cachename}) && ($env{$cachename}+600) > time) {
         # We know already the user has no data
         return 1;
     } else {
@@ -4166,7 +4153,7 @@
 	  &Apache::lonxml::whichuser($symbparm);
       if (!$symbparm) {	$symbparm=$cursymb; }
     } else {
-	$courseid=$ENV{'request.course.id'};
+	$courseid=$env{'request.course.id'};
     }
     my ($realm,$space,$qualifier,@therest)=split(/\./,$varname);
     my $rest;
@@ -4188,7 +4175,7 @@
 		return $Apache::lonhomework::history{$qualifierrest};
 	    } else {
 		my %restored;
-		if ($publicuser || $ENV{'request.state'} eq 'construct') {
+		if ($publicuser || $env{'request.state'} eq 'construct') {
 		    %restored=&tmprestore($symbparm,$courseid,$udom,$uname);
 		} else {
 		    %restored=&restore($symbparm,$courseid,$udom,$uname);
@@ -4201,9 +4188,9 @@
             return &allowed($qualifier,$rest);
 # ------------------------------------------ user.preferences, user.environment
         } elsif (($space eq 'preferences') || ($space eq 'environment')) {
-	    if (($uname eq $ENV{'user.name'}) &&
-		($udom eq $ENV{'user.domain'})) {
-		return $ENV{join('.',('environment',$qualifierrest))};
+	    if (($uname eq $env{'user.name'}) &&
+		($udom eq $env{'user.domain'})) {
+		return $env{join('.',('environment',$qualifierrest))};
 	    } else {
 		my %returnhash;
 		if (!$publicuser) {
@@ -4215,11 +4202,11 @@
 # ----------------------------------------------------------------- user.course
         } elsif ($space eq 'course') {
 	    # FIXME - not supporting calls for a specific user
-            return $ENV{join('.',('request.course',$qualifier))};
+            return $env{join('.',('request.course',$qualifier))};
 # ------------------------------------------------------------------- user.role
         } elsif ($space eq 'role') {
 	    # FIXME - not supporting calls for a specific user
-            my ($role,$where)=split(/\./,$ENV{'request.role'});
+            my ($role,$where)=split(/\./,$env{'request.role'});
             if ($qualifier eq 'value') {
 		return $role;
             } elsif ($qualifier eq 'extent') {
@@ -4243,7 +4230,7 @@
 # ---------------------------------------------- pull stuff out of query string
         &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
 						[$spacequalifierrest]);
-	return $ENV{'form.'.$spacequalifierrest}; 
+	return $env{'form.'.$spacequalifierrest}; 
    } elsif ($realm eq 'request') {
 # ------------------------------------------------------------- request.browser
         if ($space eq 'browser') {
@@ -4254,24 +4241,24 @@
 		    return 0;
 		}
 	    } else {
-		return $ENV{'browser.'.$qualifier};
+		return $env{'browser.'.$qualifier};
 	    }
 # ------------------------------------------------------------ request.filename
         } else {
-            return $ENV{'request.'.$spacequalifierrest};
+            return $env{'request.'.$spacequalifierrest};
         }
     } elsif ($realm eq 'course') {
 # ---------------------------------------------------------- course.description
-        return $ENV{'course.'.$courseid.'.'.$spacequalifierrest};
+        return $env{'course.'.$courseid.'.'.$spacequalifierrest};
     } elsif ($realm eq 'resource') {
 
 	my $section;
-	if (defined($courseid) && $courseid eq $ENV{'request.course.id'}) {
+	if (defined($courseid) && $courseid eq $env{'request.course.id'}) {
 	    if (!$symbparm) { $symbparm=&symbread(); }
 	}
 	my ($courselevelm,$courselevel);
 	if ($symbparm && defined($courseid) && 
-	    $courseid eq $ENV{'request.course.id'}) {
+	    $courseid eq $env{'request.course.id'}) {
 
 	    #print '<br>'.$space.' - '.$qualifier.' - '.$spacequalifierrest;
 
@@ -4282,9 +4269,9 @@
 	    my $symbparm=$symbp.'.'.$spacequalifierrest;
 	    my $mapparm=$mapp.'___(all).'.$spacequalifierrest;
 
-	    if (($ENV{'user.name'} eq $uname) &&
-		($ENV{'user.domain'} eq $udom)) {
-		$section=$ENV{'request.course.sec'};
+	    if (($env{'user.name'} eq $uname) &&
+		($env{'user.domain'} eq $udom)) {
+		$section=$env{'request.course.sec'};
 	    } else {
 		if (! defined($usection)) {
 		    $section=&getsection($udom,$uname,$courseid);
@@ -4336,8 +4323,8 @@
 
 # ------------------------------------------------ second, check some of course
 
-	    my $coursereply=&courseresdata($ENV{'course.'.$courseid.'.num'},
-					   $ENV{'course.'.$courseid.'.domain'},
+	    my $coursereply=&courseresdata($env{'course.'.$courseid.'.num'},
+					   $env{'course.'.$courseid.'.domain'},
 					   ($seclevelr,$seclevelm,$seclevel,
 					    $courselevelr));
 	    if (defined($coursereply)) { return $coursereply; }
@@ -4346,7 +4333,7 @@
 	    my %parmhash=();
 	    my $thisparm='';
 	    if (tie(%parmhash,'GDBM_File',
-		    $ENV{'request.course.fn'}.'_parms.db',
+		    $env{'request.course.fn'}.'_parms.db',
 		    &GDBM_READER(),0640)) {
 		$thisparm=$parmhash{$symbparm};
 		untie(%parmhash);
@@ -4361,7 +4348,7 @@
 	if ($symbparm) {
 	    $filename=(&decode_symb($symbparm))[2];
 	} else {
-	    $filename=$ENV{'request.filename'};
+	    $filename=$env{'request.filename'};
 	}
 	my $metadata=&metadata($filename,$spacequalifierrest);
 	if (defined($metadata)) { return $metadata; }
@@ -4370,9 +4357,9 @@
 
 # ---------------------------------------------- fourth, look in rest pf course
 	if ($symbparm && defined($courseid) && 
-	    $courseid eq $ENV{'request.course.id'}) {
-	    my $coursereply=&courseresdata($ENV{'course.'.$courseid.'.num'},
-					   $ENV{'course.'.$courseid.'.domain'},
+	    $courseid eq $env{'request.course.id'}) {
+	    my $coursereply=&courseresdata($env{'course.'.$courseid.'.num'},
+					   $env{'course.'.$courseid.'.domain'},
 					   ($courselevelm,$courselevel));
 	    if (defined($coursereply)) { return $coursereply; }
 	}
@@ -4393,8 +4380,8 @@
 # ---------------------------------------------------- Any other user namespace
     } elsif ($realm eq 'environment') {
 # ----------------------------------------------------------------- environment
-	if (($uname eq $ENV{'user.name'})&&($udom eq $ENV{'user.domain'})) {
-	    return $ENV{'environment.'.$spacequalifierrest};
+	if (($uname eq $env{'user.name'})&&($udom eq $env{'user.domain'})) {
+	    return $env{'environment.'.$spacequalifierrest};
 	} else {
 	    my %returnhash=&userenvironment($udom,$uname,
 					    $spacequalifierrest);
@@ -4701,7 +4688,7 @@
     my $urlsymb=shift;
     my $symb=&symbread($urlsymb);
     if ($symb) {
-	my $key=$ENV{'request.course.id'}."\0".$symb;
+	my $key=$env{'request.course.id'}."\0".$symb;
 	my ($result,$cached)=&is_cached_new('title',$key);
 	if (defined($cached)) { 
 	    return $result;
@@ -4709,7 +4696,7 @@
 	my ($map,$resid,$url)=&decode_symb($symb);
 	my $title='';
 	my %bighash;
-	if (tie(%bighash,'GDBM_File',$ENV{'request.course.fn'}.'.db',
+	if (tie(%bighash,'GDBM_File',$env{'request.course.fn'}.'.db',
 		&GDBM_READER(),0640)) {
 	    my $mapid=$bighash{'map_pc_'.&clutter($map)};
 	    $title=$bighash{'title_'.$mapid.'.'.$resid};
@@ -4730,8 +4717,8 @@
     my ($which,$cnum,$cdom)=@_;
     if (!$cnum || !$cdom) {
 	(undef,my $courseid)=&Apache::lonxml::whichuser();
-	$cdom=$ENV{'course.'.$courseid.'.domain'};
-	$cnum=$ENV{'course.'.$courseid.'.num'};
+	$cdom=$env{'course.'.$courseid.'.domain'};
+	$cnum=$env{'course.'.$courseid.'.num'};
     }
     my %slotinfo=&get('slots',[$which],$cdom,$cnum);
     &Apache::lonhomework::showhash(%slotinfo);
@@ -4748,8 +4735,8 @@
     my ($mapname,%newhash)=@_;
     $mapname=&deversion(&declutter($mapname));
     my %hash;
-    if (($ENV{'request.course.fn'}) && (%newhash)) {
-        if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.'_symb.db',
+    if (($env{'request.course.fn'}) && (%newhash)) {
+        if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.'_symb.db',
                       &GDBM_WRCREAT(),0640)) {
 	    foreach (keys %newhash) {
                 $hash{declutter($_)}=&encode_symb($mapname,$newhash{$_}->[1],
@@ -4785,7 +4772,7 @@
     my %bighash;
     my $okay=0;
 
-    if (tie(%bighash,'GDBM_File',$ENV{'request.course.fn'}.'.db',
+    if (tie(%bighash,'GDBM_File',$env{'request.course.fn'}.'.db',
                             &GDBM_READER(),0640)) {
         my $ids=$bighash{'ids_'.&clutter($thisurl)};
         unless ($ids) { 
@@ -4798,8 +4785,8 @@
                if (
   &symbclean(&declutter($bighash{'map_id_'.$mapid}).'___'.$resid.'___'.$thisfn)
    eq $symb) { 
-		   if (($ENV{'request.role.adv'}) ||
-		       $bighash{'encrypted_'.$_} eq $ENV{'request.enc'}) {
+		   if (($env{'request.role.adv'}) ||
+		       $bighash{'encrypted_'.$_} eq $env{'request.enc'}) {
 		       $okay=1; 
 		   }
 	       }
@@ -4846,12 +4833,12 @@
     if ($fn=~/^(adm|uploaded|editupload|public)/) { return $fn; }
     my %bighash;
     my $uri=&clutter($fn);
-    my $key=$ENV{'request.course.id'}.'_'.$uri;
+    my $key=$env{'request.course.id'}.'_'.$uri;
 # is this cached?
     my ($result,$cached)=&is_cached_new('courseresversion',$key);
     if (defined($cached)) { return $result; }
 # unfortunately not cached, or expired
-    if (tie(%bighash,'GDBM_File',$ENV{'request.course.fn'}.'.db',
+    if (tie(%bighash,'GDBM_File',$env{'request.course.fn'}.'.db',
 	    &GDBM_READER(),0640)) {
  	if ($bighash{'version_'.$uri}) {
  	    my $version=$bighash{'version_'.$uri};
@@ -4876,31 +4863,31 @@
 sub symbread {
     my ($thisfn,$donotrecurse)=@_;
     my $cache_str='request.symbread.cached.'.$thisfn;
-    if (defined($ENV{$cache_str})) { return $ENV{$cache_str}; }
+    if (defined($env{$cache_str})) { return $env{$cache_str}; }
 # no filename provided? try from environment
     unless ($thisfn) {
-        if ($ENV{'request.symb'}) {
-	    return $ENV{$cache_str}=&symbclean($ENV{'request.symb'});
+        if ($env{'request.symb'}) {
+	    return $env{$cache_str}=&symbclean($env{'request.symb'});
 	}
-	$thisfn=$ENV{'request.filename'};
+	$thisfn=$env{'request.filename'};
     }
     if ($thisfn=~m|^/enc/|) { $thisfn=&Apache::lonenc::unencrypted($thisfn); }
 # is that filename actually a symb? Verify, clean, and return
     if ($thisfn=~/\_\_\_\d+\_\_\_(.*)$/) {
 	if (&symbverify($thisfn,$1)) {
-	    return $ENV{$cache_str}=&symbclean($thisfn);
+	    return $env{$cache_str}=&symbclean($thisfn);
 	}
     }
     $thisfn=declutter($thisfn);
     my %hash;
     my %bighash;
     my $syval='';
-    if (($ENV{'request.course.fn'}) && ($thisfn)) {
+    if (($env{'request.course.fn'}) && ($thisfn)) {
         my $targetfn = $thisfn;
         if ( ($thisfn =~ m/^(uploaded|editupload)\//) && ($thisfn !~ m/\.(page|sequence)$/) ) {
             $targetfn = 'adm/wrapper/'.$thisfn;
         }
-        if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.'_symb.db',
+        if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.'_symb.db',
                       &GDBM_READER(),0640)) {
 	    $syval=$hash{$targetfn};
             untie(%hash);
@@ -4908,15 +4895,15 @@
 # ---------------------------------------------------------- There was an entry
         if ($syval) {
 	    #unless ($syval=~/\_\d+$/) {
-		#unless ($ENV{'form.request.prefix'}=~/\.(\d+)\_$/) {
+		#unless ($env{'form.request.prefix'}=~/\.(\d+)\_$/) {
 		    #&appenv('request.ambiguous' => $thisfn);
-		    #return $ENV{$cache_str}='';
+		    #return $env{$cache_str}='';
 		#}    
 		#$syval.=$1;
 	    #}
         } else {
 # ------------------------------------------------------- Was not in symb table
-           if (tie(%bighash,'GDBM_File',$ENV{'request.course.fn'}.'.db',
+           if (tie(%bighash,'GDBM_File',$env{'request.course.fn'}.'.db',
                             &GDBM_READER(),0640)) {
 # ---------------------------------------------- Get ID(s) for current resource
               my $ids=$bighash{'ids_'.&clutter($thisfn)};
@@ -4957,12 +4944,12 @@
            }
         }
         if ($syval) {
-	    return $ENV{$cache_str}=$syval;
-	    #return $ENV{$cache_str}=&symbclean($syval.'___'.$thisfn);
+	    return $env{$cache_str}=$syval;
+	    #return $env{$cache_str}=&symbclean($syval.'___'.$thisfn);
         }
     }
     &appenv('request.ambiguous' => $thisfn);
-    return $ENV{$cache_str}='';
+    return $env{$cache_str}='';
 }
 
 # ---------------------------------------------------------- Return random seed
@@ -5021,7 +5008,7 @@
     my ($courseid)=@_;
     if (!$courseid) { $courseid=(&Apache::lonxml::whichuser())[1]; }
     if ($courseid) {
-	return $ENV{"course.$courseid.rndseed"};
+	return $env{"course.$courseid.rndseed"};
     }
     return &latest_rnd_algorithm_id();
 }
@@ -5033,7 +5020,7 @@
 }
 
 sub getCODE {
-    if (&validCODE($ENV{'form.CODE'})) { return $ENV{'form.CODE'}; }
+    if (&validCODE($env{'form.CODE'})) { return $env{'form.CODE'}; }
     if ( (defined($Apache::lonhomework::parsing_a_problem) ||
 	  defined($Apache::lonhomework::parsing_a_task) ) &&
 	 &validCODE($Apache::lonhomework::history{'resource.CODE'})) {
@@ -5236,8 +5223,8 @@
 sub recunique {
     my $fucourseid=shift;
     my $unique;
-    if ($ENV{"course.$fucourseid.receiptalg"} eq 'receipt2') {
-	$unique=$ENV{"course.$fucourseid.internal.encseed"};
+    if ($env{"course.$fucourseid.receiptalg"} eq 'receipt2') {
+	$unique=$env{"course.$fucourseid.internal.encseed"};
     } else {
 	$unique=$perlvar{'lonReceipt'};
     }
@@ -5247,8 +5234,8 @@
 sub recprefix {
     my $fucourseid=shift;
     my $prefix;
-    if ($ENV{"course.$fucourseid.receiptalg"} eq 'receipt2') {
-	$prefix=$ENV{"course.$fucourseid.internal.encpref"};
+    if ($env{"course.$fucourseid.receiptalg"} eq 'receipt2') {
+	$prefix=$env{"course.$fucourseid.internal.encpref"};
     } else {
 	$prefix=$perlvar{'lonHostID'};
     }
@@ -5264,8 +5251,8 @@
     my $cunique=&recunique($fucourseid);
     my $cpart=unpack("%32S*",$part);
     my $return =&recprefix($fucourseid).'-';
-    if ($ENV{"course.$fucourseid.receiptalg"} eq 'receipt2' ||
-	$ENV{'request.state'} eq 'construct') {
+    if ($env{"course.$fucourseid.receiptalg"} eq 'receipt2' ||
+	$env{'request.state'} eq 'construct') {
 	&Apache::lonxml::debug("doing receipt2  using parts $cpart, uname $cuname and udom $cudom gets  ".($cpart%$cuname).
 			       " and ".($cpart%$cudom));
 			       
@@ -5378,12 +5365,12 @@
     my $uri=shift;
     $uri=~s|^http\://([^/]+)||;
     $uri=~s|^/||;
-    $ENV{'user.environment'}=~/\/([^\/]+)\.id/;
+    $env{'user.environment'}=~/\/([^\/]+)\.id/;
     my $token=$1;
     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'};
@@ -5933,14 +5920,14 @@
 X<appenv()>
 B<appenv(%hash)>: the value of %hash 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
+user makes during this session, also modifies the %env for the current
 process
 
 =item *
 X<delenv()>
 B<delenv($regexp)>: removes all items from the session
 environment file that matches the regular expression in $regexp. The
-values are also delted from the current processes %ENV.
+values are also delted from the current processes %env.
 
 =back
 
@@ -6248,7 +6235,7 @@
 a possible symb for the URL in $thisfn, and if is an encryypted
 resource that the user accessed using /enc/ returns a 1 on success, 0
 on failure, user must be in a course, as it assumes the existance of
-the course initial hash, and uses $ENV('request.course.id'}
+the course initial hash, and uses $env('request.course.id'}
 
 
 =item *
@@ -6279,7 +6266,7 @@
 
 =item *
 
-receipt() : API to ireceipt working off of ENV values; given out to users
+receipt() : API to ireceipt working off of env values; given out to users
 
 =item *
 
@@ -6313,7 +6300,7 @@
 store($storehash,$symb,$namespace,$udom,$uname) : stores hash permanently
 for this url; hashref needs to be given and should be a \%hashname; the
 remaining args aren't required and if they aren't passed or are '' they will
-be derived from the ENV
+be derived from the env
 
 =item *
 
@@ -6542,10 +6529,10 @@
 userfileupload(): main rotine for putting a file in a user or course's
                   filespace, arguments are,
 
- formname - required - this is the name of the element in $ENV where the
+ formname - required - this is the name of the element in $env where the
            filename, and the contents of the file to create/modifed exist
-           the filename is in $ENV{'form.'.$formname.'.filename'} and the
-           contents of the file is located in $ENV{'form.'.$formname}
+           the filename is in $env{'form.'.$formname.'.filename'} and the
+           contents of the file is located in $env{'form.'.$formname}
  coursedoc - if true, store the file in the course of the active role
              of the current user
  subdir - required - subdirectory to put the file in under ../userfiles/
Index: loncom/lonnet/perl/lonrep.pm
diff -u loncom/lonnet/perl/lonrep.pm:1.8 loncom/lonnet/perl/lonrep.pm:1.9
--- loncom/lonnet/perl/lonrep.pm:1.8	Wed Mar 16 16:35:17 2005
+++ loncom/lonnet/perl/lonrep.pm	Thu Apr  7 02:56:24 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Replication Manager
 #
-# $Id: lonrep.pm,v 1.8 2005/03/16 21:35:17 raeburn Exp $
+# $Id: lonrep.pm,v 1.9 2005/04/07 06:56:24 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -25,20 +25,12 @@
 #
 # http://www.lon-capa.org/
 #
-# (Access Handler for File Transfers
-# (lonacc: Cookie Based Access Handler
-# 5/21/99,5/22,5/29,5/31,6/15 Gerd Kortemeyer)
-# 6/16,6/18 Gerd Kortemeyer)
-# 6/18,6/21,6/26,6/28,6/29,6/30,
-# 7/2,7/3,7/9,7/10,7/12,
-# 01/06,01/14,10/5,
-# 06/14/01 Gerd Kortemeyer
 
 package Apache::lonrep;
 
 use strict;
 use Apache::Constants qw(:common :http);
-use Apache::lonnet();
+use Apache::lonnet;
 use Apache::File();
 use CGI::Cookie();
 
Index: loncom/lonnet/perl/lonuploadrep.pm
diff -u loncom/lonnet/perl/lonuploadrep.pm:1.6 loncom/lonnet/perl/lonuploadrep.pm:1.7
--- loncom/lonnet/perl/lonuploadrep.pm:1.6	Wed Mar 16 16:35:17 2005
+++ loncom/lonnet/perl/lonuploadrep.pm	Thu Apr  7 02:56:24 2005
@@ -28,7 +28,7 @@
 
 use strict;
 use Apache::Constants qw(:common :http);
-use Apache::lonnet();
+use Apache::lonnet;
 use CGI::Cookie();
 
 sub handler {
Index: loncom/publisher/loncfile.pm
diff -u loncom/publisher/loncfile.pm:1.66 loncom/publisher/loncfile.pm:1.67
--- loncom/publisher/loncfile.pm:1.66	Thu Apr  7 00:46:36 2005
+++ loncom/publisher/loncfile.pm	Thu Apr  7 02:56:24 2005
@@ -9,7 +9,7 @@
 #  and displays a page showing the results of the action.
 #
 #
-# $Id: loncfile.pm,v 1.66 2005/04/07 04:46:36 albertel Exp $
+# $Id: loncfile.pm,v 1.67 2005/04/07 06:56:24 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -704,7 +704,7 @@
 sub NewFile1 {
     my ($request, $user, $domain, $fn, $newfilename) = @_;
 
-    if ($ENV{'form.action'} =~ /new(.+)file/) {
+    if ($env{'form.action'} =~ /new(.+)file/) {
 	my $extension=$1;
 
         ##Informs User (name).(number).(extension) not allowed 
@@ -767,43 +767,43 @@
     my ($r,$fn,$uname,$udom)=@_;
   
     my $doingdir=0;
-    if ($ENV{'form.action'} eq 'newdir') { $doingdir=1; }
-    my $newfilename=&cleanDest($r,$ENV{'form.newfilename'},$doingdir,$fn,$uname);
+    if ($env{'form.action'} eq 'newdir') { $doingdir=1; }
+    my $newfilename=&cleanDest($r,$env{'form.newfilename'},$doingdir,$fn,$uname);
     $newfilename=&relativeDest($fn,$newfilename,$uname);
     $r->print('<form action="/adm/cfile" method="post">'.
 	      '<input type="hidden" name="qualifiedfilename" value="'.$fn.'" />'.
 	      '<input type="hidden" name="phase" value="two" />'.
-	      '<input type="hidden" name="action" value="'.$ENV{'form.action'}.'" />');
+	      '<input type="hidden" name="action" value="'.$env{'form.action'}.'" />');
   
-    if ($ENV{'form.action'} eq 'rename') {
+    if ($env{'form.action'} eq 'rename') {
 	&Rename1($r, $uname, $udom, $fn, $newfilename, 'rename');
-    } elsif ($ENV{'form.action'} eq 'move') {
+    } elsif ($env{'form.action'} eq 'move') {
 	&Rename1($r, $uname, $udom, $fn, $newfilename, 'move');
-    } elsif ($ENV{'form.action'} eq 'delete') { 
+    } elsif ($env{'form.action'} eq 'delete') { 
 	&Delete1($r, $uname, $udom, $fn);
-    } elsif ($ENV{'form.action'} eq 'decompress') {
+    } elsif ($env{'form.action'} eq 'decompress') {
 	&Decompress1($r, $uname, $udom, $fn);
-    } elsif ($ENV{'form.action'} eq 'copy') { 
+    } elsif ($env{'form.action'} eq 'copy') { 
 	if($newfilename) {
 	    &Copy1($r, $uname, $udom, $fn, $newfilename);
 	} else {
 	    $r->print('<p>'.&mt('No new filename specified.').'</p></form>');
 	}
-    } elsif ($ENV{'form.action'} eq 'newdir') {
+    } elsif ($env{'form.action'} eq 'newdir') {
 	my $mode = '';
-	if (exists($ENV{'form.callingmode'}) ) {
-	    $mode = $ENV{'form.callingmode'};
+	if (exists($env{'form.callingmode'}) ) {
+	    $mode = $env{'form.callingmode'};
 	}   
 	&NewDir1($r, $uname, $udom, $fn, $newfilename, $mode);
-    }  elsif ($ENV{'form.action'} eq 'newfile' ||
-	      $ENV{'form.action'} eq 'newhtmlfile' ||
-	      $ENV{'form.action'} eq 'newproblemfile' ||
-	      $ENV{'form.action'} eq 'newpagefile' ||
-	      $ENV{'form.action'} eq 'newsequencefile' ||
-	      $ENV{'form.action'} eq 'newrightsfile' ||
-	      $ENV{'form.action'} eq 'newstyfile' ||
-              $ENV{'form.action'} eq 'newlibraryfile' ||
-	      $ENV{'form.action'} eq 'Select Action') {
+    }  elsif ($env{'form.action'} eq 'newfile' ||
+	      $env{'form.action'} eq 'newhtmlfile' ||
+	      $env{'form.action'} eq 'newproblemfile' ||
+	      $env{'form.action'} eq 'newpagefile' ||
+	      $env{'form.action'} eq 'newsequencefile' ||
+	      $env{'form.action'} eq 'newrightsfile' ||
+	      $env{'form.action'} eq 'newstyfile' ||
+              $env{'form.action'} eq 'newlibraryfile' ||
+	      $env{'form.action'} eq 'Select Action') {
         my $empty=&mt('Type Name Here');
 	if (($newfilename!~/\/$/) && ($newfilename!~/$empty$/)) {
 	    &NewFile1($r, $uname, $udom, $fn, $newfilename);
@@ -1117,60 +1117,60 @@
     my $dest;                   # On success this is where we'll go.
     
     &Debug($r,"loncfile::phase2 dir = $dir main = $main suffix = $suffix");
-    &Debug($r,"    newfilename = ".$ENV{'form.newfilename'});
+    &Debug($r,"    newfilename = ".$env{'form.newfilename'});
 
     my $conspace=$fn;
     
     &Debug($r,"loncfile::phase2 Full construction space name: $conspace");
     
-    &Debug($r,"loncfie::phase2 action is $ENV{'form.action'}");
+    &Debug($r,"loncfie::phase2 action is $env{'form.action'}");
     
     # Select the appropriate processing sub.
-    if ($ENV{'form.action'} eq 'decompress') { 
+    if ($env{'form.action'} eq 'decompress') { 
 	$main .= '.'.$suffix;
 	if(!&decompress2($r, $uname, $dir, $main)) {
 	    return ;
 	}
 	$dest = $dir."/.";
-    } elsif ($ENV{'form.action'} eq 'rename' ||
-	     $ENV{'form.action'} eq 'move') {
-	if($ENV{'form.newfilename'}) {
+    } elsif ($env{'form.action'} eq 'rename' ||
+	     $env{'form.action'} eq 'move') {
+	if($env{'form.newfilename'}) {
 	    if (!defined($dir)) {
 		$fn=~m:^(.*)/:;
 		$dir=$1; 
 	    }
-	    if(!&Rename2($r, $uname, $dir, $fn, $ENV{'form.newfilename'})) {
+	    if(!&Rename2($r, $uname, $dir, $fn, $env{'form.newfilename'})) {
 		return;
 	    }
-	    $dest = $ENV{'form.newfilename'};
+	    $dest = $env{'form.newfilename'};
 	}
-    } elsif ($ENV{'form.action'} eq 'delete') { 
-	if(!&Delete2($r, $uname, $ENV{'form.newfilename'})) {
+    } elsif ($env{'form.action'} eq 'delete') { 
+	if(!&Delete2($r, $uname, $env{'form.newfilename'})) {
 	    return ;
 	}
 	# Once a resource is deleted, we just list the directory that
 	# previously held it.
 	#
 	$dest = $dir."/.";		# Parent dir.
-    } elsif ($ENV{'form.action'} eq 'copy') { 
-	if($ENV{'form.newfilename'}) {
-	    if(!&Copy2($r, $uname, $dir, $fn, $ENV{'form.newfilename'})) {
+    } elsif ($env{'form.action'} eq 'copy') { 
+	if($env{'form.newfilename'}) {
+	    if(!&Copy2($r, $uname, $dir, $fn, $env{'form.newfilename'})) {
 		return ;
 	    }
-	    $dest = $ENV{'form.newfilename'};
+	    $dest = $env{'form.newfilename'};
      	} else {
 	    $r->print('<p>'.&mt('No New filename specified').'</p></form>');
 	    return;
 	}
 	
-    } elsif ($ENV{'form.action'} eq 'newdir') {
-        my $newdir= $ENV{'form.newfilename'};
+    } elsif ($env{'form.action'} eq 'newdir') {
+        my $newdir= $env{'form.newfilename'};
 	if(!&NewDir2($r, $uname, $newdir)) {
 	    return;
 	}
 	$dest = $newdir."/";
     }
-    if ( ($ENV{'form.action'} eq 'newdir') && ($ENV{'form.phase'} eq 'two') && ( ($ENV{'form.callingmode'} eq 'testbank') || ($ENV{'form.callingmode'} eq 'imsimport') ) ) {
+    if ( ($env{'form.action'} eq 'newdir') && ($env{'form.phase'} eq 'two') && ( ($env{'form.callingmode'} eq 'testbank') || ($env{'form.callingmode'} eq 'imsimport') ) ) {
 	$r->print('<h3><a href="javascript:self.close()">'.&mt('Done').'</a></h3>');
     } else {
 	$r->print('<h3><a href="'.&url($dest).'">'.&mt('Done').'</a></h3>');
@@ -1184,8 +1184,8 @@
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['decompress','action','filename','newfilename']);
 
     &Debug($r, "loncfile.pm - handler entered");
-    &Debug($r, " filename: ".$ENV{'form.filename'});
-    &Debug($r, " newfilename: ".$ENV{'form.newfilename'});
+    &Debug($r, " filename: ".$env{'form.filename'});
+    &Debug($r, " newfilename: ".$env{'form.newfilename'});
 #
 # Determine the root filename
 # This could come in as "filename", which actually is a URL, or
@@ -1193,28 +1193,28 @@
 #
     my $fn;
 
-    if ($ENV{'form.filename'}) {
-	&Debug($r, "test: $ENV{'form.filename'}");
-	$fn=&Apache::lonnet::unescape($ENV{'form.filename'});
+    if ($env{'form.filename'}) {
+	&Debug($r, "test: $env{'form.filename'}");
+	$fn=&Apache::lonnet::unescape($env{'form.filename'});
 	$fn=&URLToPath($fn);
-    }  elsif($ENV{'QUERY_STRING'} && $ENV{'form.phase'} ne 'two') {  
+    }  elsif($ENV{'QUERY_STRING'} && $env{'form.phase'} ne 'two') {  
 	#Just hijack the script only the first time around to inject the
 	#correct information for further processing
-	$fn=&Apache::lonnet::unescape($ENV{'form.decompress'});
+	$fn=&Apache::lonnet::unescape($env{'form.decompress'});
 	$fn=&URLToPath($fn);
-	$ENV{'form.action'}="decompress";
-    } elsif ($ENV{'form.qualifiedfilename'}) {
-	$fn=$ENV{'form.qualifiedfilename'};
+	$env{'form.action'}="decompress";
+    } elsif ($env{'form.qualifiedfilename'}) {
+	$fn=$env{'form.qualifiedfilename'};
     } else {
 	&Debug($r, "loncfile::handler - no form.filename");
-	$r->log_reason($ENV{'user.name'}.' at '.$ENV{'user.domain'}.
+	$r->log_reason($env{'user.name'}.' at '.$env{'user.domain'}.
 		       ' unspecified filename for cfile', $r->filename); 
 	return HTTP_NOT_FOUND;
     }
 
     unless ($fn) { 
 	&Debug($r, "loncfile::handler - doctored url is empty");
-	$r->log_reason($ENV{'user.name'}.' at '.$ENV{'user.domain'}.
+	$r->log_reason($env{'user.name'}.' at '.$env{'user.domain'}.
 		       ' trying to cfile non-existing file', $r->filename); 
 	return HTTP_NOT_FOUND;
     } 
@@ -1229,7 +1229,7 @@
 	   "loncfile::handler constructaccess uname = $uname domain = $udom");
     unless (($uname) && ($udom)) {
 	$r->log_reason($uname.' at '.$udom.
-		       ' trying to manipulate file '.$ENV{'form.filename'}.
+		       ' trying to manipulate file '.$env{'form.filename'}.
 		       ' ('.$fn.') - not authorized', 
 		       $r->filename); 
 	return HTTP_NOT_ACCEPTABLE;
@@ -1239,8 +1239,8 @@
     &Apache::loncommon::content_type($r,'text/html');
     $r->send_http_header;
 
-    if ( ($ENV{'form.action'} eq 'newdir') && ($ENV{'form.phase'} eq 'two') && ( ($ENV{'form.callingmode'} eq 'testbank') || ($ENV{'form.callingmode'} eq 'imsimport') ) ) {
-	my $newdirname = $ENV{'form.newfilename'};
+    if ( ($env{'form.action'} eq 'newdir') && ($env{'form.phase'} eq 'two') && ( ($env{'form.callingmode'} eq 'testbank') || ($env{'form.callingmode'} eq 'imsimport') ) ) {
+	my $newdirname = $env{'form.newfilename'};
 	$r->print('<html><head><title>LON-CAPA Construction Space</title><script language="Javascript">');
 	$r->print(qq|
 function writeDone() {
@@ -1261,40 +1261,40 @@
   
     $r->print('<h3>'.&mt('Location').': '.&display($fn).'</h3>');
   
-    if (($uname ne $ENV{'user.name'}) || ($udom ne $ENV{'user.domain'})) {
+    if (($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) {
 	$r->print('<h3><font color="red">'.&mt('Co-Author').': '.$uname.' at '.$udom.
 		  '</font></h3>');
     }
 
 
-    &Debug($r, "loncfile::handler Form action is $ENV{'form.action'} ");
-    if ($ENV{'form.action'} eq 'delete') {
+    &Debug($r, "loncfile::handler Form action is $env{'form.action'} ");
+    if ($env{'form.action'} eq 'delete') {
       	$r->print('<h3>'.&mt('Delete').'</h3>');
-    } elsif ($ENV{'form.action'} eq 'rename') {
+    } elsif ($env{'form.action'} eq 'rename') {
 	$r->print('<h3>'.&mt('Rename').'</h3>');
-    } elsif ($ENV{'form.action'} eq 'move') {
+    } elsif ($env{'form.action'} eq 'move') {
 	$r->print('<h3>'.&mt('Move').'</h3>');
-    } elsif ($ENV{'form.action'} eq 'newdir') {
+    } elsif ($env{'form.action'} eq 'newdir') {
 	$r->print('<h3>'.&mt('New Directory').'</h3>');
-    } elsif ($ENV{'form.action'} eq 'decompress') {
+    } elsif ($env{'form.action'} eq 'decompress') {
 	$r->print('<h3>'.&mt('Decompress').'</h3>');
-    } elsif ($ENV{'form.action'} eq 'copy') {
+    } elsif ($env{'form.action'} eq 'copy') {
 	$r->print('<h3>'.&mt('Copy').'</h3>');
-    } elsif ($ENV{'form.action'} eq 'newfile' ||
-	     $ENV{'form.action'} eq 'newhtmlfile' ||
-	     $ENV{'form.action'} eq 'newproblemfile' ||
-	     $ENV{'form.action'} eq 'newpagefile' ||
-	     $ENV{'form.action'} eq 'newsequencefile' ||
-	     $ENV{'form.action'} eq 'newrightsfile' ||
-	     $ENV{'form.action'} eq 'newstyfile' ||
-             $ENV{'form.action'} eq 'newlibraryfile' ||
-	     $ENV{'form.action'} eq 'Select Action' ) {
+    } elsif ($env{'form.action'} eq 'newfile' ||
+	     $env{'form.action'} eq 'newhtmlfile' ||
+	     $env{'form.action'} eq 'newproblemfile' ||
+	     $env{'form.action'} eq 'newpagefile' ||
+	     $env{'form.action'} eq 'newsequencefile' ||
+	     $env{'form.action'} eq 'newrightsfile' ||
+	     $env{'form.action'} eq 'newstyfile' ||
+             $env{'form.action'} eq 'newlibraryfile' ||
+	     $env{'form.action'} eq 'Select Action' ) {
 	$r->print('<h3>'.&mt('New Resource').'</h3>');
     } else {
-	$r->print('<p>'.&mt('Unknown Action').' '.$ENV{'form.action'}.' </p></body></html>');
+	$r->print('<p>'.&mt('Unknown Action').' '.$env{'form.action'}.' </p></body></html>');
 	return OK;  
     }
-    if ($ENV{'form.phase'} eq 'two') {
+    if ($env{'form.phase'} eq 'two') {
 	&Debug($r, "loncfile::handler  entering phase2");
 	&phasetwo($r,$fn,$uname,$udom);
     } else {
Index: loncom/publisher/lonconstruct.pm
diff -u loncom/publisher/lonconstruct.pm:1.29 loncom/publisher/lonconstruct.pm:1.30
--- loncom/publisher/lonconstruct.pm:1.29	Mon Feb 28 03:22:09 2005
+++ loncom/publisher/lonconstruct.pm	Thu Apr  7 02:56:26 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Construction Space Page Wrapper for Construction
 #
-# $Id: lonconstruct.pm,v 1.29 2005/02/28 08:22:09 albertel Exp $
+# $Id: lonconstruct.pm,v 1.30 2005/04/07 06:56:26 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -26,16 +26,7 @@
 # http://www.lon-capa.org/
 #
 #
-# (Page Handler
-#
-# (TeX Content Handler
-#
-# 05/29/00,05/30 Gerd Kortemeyer)
-# 08/30,08/31,09/06,09/14,09/15,09/16,09/19,09/20,09/21,09/23,
-# 10/02,10/10,10/14,10/16,10/18,10/19,10/31,11/6,11/14,11/16 Gerd Kortemeyer)
-#
-# 11/22,11/23,11/28,
-# 03/30/01 Gerd Kortemeyer
+
 package Apache::lonconstruct;
 
 
@@ -109,12 +100,12 @@
 
    &Apache::loncommon::get_unprocessed_cgi
         ($ENV{'QUERY_STRING'},['forceedit']);
-   if ($ENV{'form.forceedit'}) {
+   if ($env{'form.forceedit'}) {
        $lowerframe.='?editmode=Edit&problemmode=EditXML';
    }	
    &Apache::loncommon::get_unprocessed_cgi
         ($ENV{'QUERY_STRING'},['forceColoredit']);
-   if ($ENV{'form.forceColoredit'}) {
+   if ($env{'form.forceColoredit'}) {
        $lowerframe.='?editmode=Edit&problemmode=Edit';
    }
 
@@ -123,7 +114,7 @@
 #
    my $toprows = 0;
    my $topsrc = '';
-   if ($ENV{'environment.remote'} ne 'off') {
+   if ($env{'environment.remote'} ne 'off') {
        $toprows = '110';
        $topsrc = '/adm/localize/adm/publisher.html';
    }
Index: loncom/publisher/londiff.pm
diff -u loncom/publisher/londiff.pm:1.15 loncom/publisher/londiff.pm:1.16
--- loncom/publisher/londiff.pm:1.15	Thu Mar 11 17:44:01 2004
+++ loncom/publisher/londiff.pm	Thu Apr  7 02:56:26 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to show differences between file versions
 #
-# $Id: londiff.pm,v 1.15 2004/03/11 22:44:01 albertel Exp $
+# $Id: londiff.pm,v 1.16 2005/04/07 06:56:26 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -52,7 +52,7 @@
 use Algorithm::Diff qw(diff);
 use Apache::Constants qw(:common :http :methods);
 use Apache::loncacc;
-use Apache::lonnet();
+use Apache::lonnet;
 use Apache::loncommon();
 use Apache::lonlocal;
 
@@ -93,25 +93,25 @@
                                        ['filename','versiontwo','versionone']);
 # Get the files
 
-  my $cuname=$ENV{'user.name'};
-  my $cudom=$ENV{'user.domain'};
+  my $cuname=$env{'user.name'};
+  my $cudom=$env{'user.domain'};
 
-  if ($ENV{'form.filename'}=~/^\/res\//) {
-      ($cudom,$cuname,$ENV{'form.filename'})=
-       ($ENV{'form.filename'}=~/^\/res\/(\w+)\/(\w+)\/(.*)$/);
+  if ($env{'form.filename'}=~/^\/res\//) {
+      ($cudom,$cuname,$env{'form.filename'})=
+       ($env{'form.filename'}=~/^\/res\/(\w+)\/(\w+)\/(.*)$/);
   } else {
    unless (($cuname,$cudom)=
-    &Apache::loncacc::constructaccess($ENV{'form.filename'},
+    &Apache::loncacc::constructaccess($env{'form.filename'},
                                       $r->dir_config('lonDefDomain'))) {
      $r->log_reason($cuname.' at '.$cudom.
-         ' trying to get diffs file '.$ENV{'form.filename'}.
+         ' trying to get diffs file '.$env{'form.filename'}.
          '  - not authorized', 
          $r->filename); 
      return HTTP_NOT_ACCEPTABLE;
    }
   }
 
-  my $efn=$ENV{'form.filename'};
+  my $efn=$env{'form.filename'};
 
   $efn=~s/\/\~(\w+)//g;
 
@@ -128,7 +128,7 @@
   
   $r->print('<h1>'.&mt('Compare versions of').' <tt>'.$efn.'</tt></h1>');
    
-       if (($cuname ne $ENV{'user.name'}) || ($cudom ne $ENV{'user.domain'})) {
+       if (($cuname ne $env{'user.name'}) || ($cudom ne $env{'user.domain'})) {
           $r->print('<h3><font color=red>Co-Author: '.$cuname.' at '.$cudom.
                '</font></h3>');
       }
@@ -137,17 +137,17 @@
  if (&Apache::loncommon::fileembstyle(($efn=~/\.(\w+)$/)) eq
       'ssi') {
   $r->print('<p><font color="red">');
-  if ($ENV{'form.versionone'} eq 'priv') {
+  if ($env{'form.versionone'} eq 'priv') {
       my $fn='/home/'.$cuname.'/public_html/'.$efn;
       @f1=&get_split_file($fn,'local');
       $r->print('<b>'.&mt('Construction Space Version').'</b>');
   } else {
       my $fn=
        '/home/httpd/html//res/'.$cudom.'/'.$cuname.'/';
-      if ($ENV{'form.versionone'}) {
+      if ($env{'form.versionone'}) {
          my ($main,$suffix)=($efn=~/^(.+)\.(\w+)$/);
-         $fn.=$main.'.'.$ENV{'form.versionone'}.'.'.$suffix;
-	 $r->print('<b>'.&mt('Version').' '.$ENV{'form.versionone'}.'</b>');
+         $fn.=$main.'.'.$env{'form.versionone'}.'.'.$suffix;
+	 $r->print('<b>'.&mt('Version').' '.$env{'form.versionone'}.'</b>');
       } else {
          $fn.=$efn;
 	 $r->print('<b>'.&mt('Current Version').'</b>');
@@ -157,17 +157,17 @@
 
   $r->print('</font><br />'.&mt('versus').'<br /><font color="green">');
 
-  if ($ENV{'form.versiontwo'} eq 'priv') {
+  if ($env{'form.versiontwo'} eq 'priv') {
       my $fn='/home/'.$cuname.'/public_html/'.$efn;
       @f2=&get_split_file($fn,'local');
       $r->print('<b>'.&mt('Construction Space Version').'</b>');
   } else {
       my $fn=
        '/home/httpd/html/res/'.$cudom.'/'.$cuname.'/';
-      if ($ENV{'form.versiontwo'}) {
+      if ($env{'form.versiontwo'}) {
          my ($main,$suffix)=($efn=~/^(.+)\.(\w+)$/);
-         $fn.=$main.'.'.$ENV{'form.versiontwo'}.'.'.$suffix;
-	 $r->print('<b>'.&mt('Version').' '.$ENV{'form.versiontwo'}.'</b>');
+         $fn.=$main.'.'.$env{'form.versiontwo'}.'.'.$suffix;
+	 $r->print('<b>'.&mt('Version').' '.$env{'form.versiontwo'}.'</b>');
       } else {
          $fn.=$efn;
 	 $r->print('<b>'.&mt('Current Version').'</b>');
Index: loncom/publisher/lonpubdir.pm
diff -u loncom/publisher/lonpubdir.pm:1.77 loncom/publisher/lonpubdir.pm:1.78
--- loncom/publisher/lonpubdir.pm:1.77	Mon Feb 28 03:22:09 2005
+++ loncom/publisher/lonpubdir.pm	Thu Apr  7 02:56:26 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Construction Space Directory Lister
 #
-# $Id: lonpubdir.pm,v 1.77 2005/02/28 08:22:09 albertel Exp $
+# $Id: lonpubdir.pm,v 1.78 2005/04/07 06:56:26 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -61,7 +61,7 @@
              $fn,$r->dir_config('lonDefDomain')); 
   unless (($uname) && ($udom)) {
      $r->log_reason($uname.' at '.$udom.
-         ' trying to list directory '.$ENV{'form.filename'}.
+         ' trying to list directory '.$env{'form.filename'}.
          ' ('.$fn.') - not authorized', 
          $r->filename); 
      return HTTP_NOT_ACCEPTABLE;
@@ -72,7 +72,7 @@
   $fn=~s/\/$//;
 
   unless ($fn) { 
-     $r->log_reason($ENV{'user.name'}.' at '.$ENV{'user.domain'}.
+     $r->log_reason($env{'user.name'}.' at '.$env{'user.domain'}.
          ' trying to list empty directory', $r->filename); 
      return HTTP_NOT_FOUND;
   } 
@@ -91,7 +91,7 @@
   my %bombs=&Apache::lonmsg::all_url_author_res_msg($uname,$udom);
 
   &startpage($r, $uname, $udom, $thisdisfn);   # Put out the start of page.
-  if ($ENV{'environment.remote'} eq 'off') {
+  if ($env{'environment.remote'} eq 'off') {
       &dircontrols($r,$uname,$udom,$thisdisfn);    # Put out actions for directory, 
                                                # browse/upload + new file page.
   } else {
@@ -148,8 +148,8 @@
     my $r = shift;
     my $fn;
     
-    if ($ENV{'form.filename'}) {	# If a form filename is defined.
-	$fn=$ENV{'form.filename'};
+    if ($env{'form.filename'}) {	# If a form filename is defined.
+	$fn=$env{'form.filename'};
 	#
 	#   Replace the ~username of the URL with /home/username/public_html
 	#   so that we don't have to worry about ~ expansion internally.
@@ -206,8 +206,8 @@
                  'this.form.action=this.form.recent.value;this.form.submit()').
               '</form>';
     &Apache::lonhtmlcommon::store_recent('construct',$formaction,$formaction);
-    if ($ENV{'environment.remote'} eq 'off') {
-	$ENV{'request.noversionuri'}=$currdir.'/';
+    if ($env{'environment.remote'} eq 'off') {
+	$env{'request.noversionuri'}=$currdir.'/';
 	$r->print(&Apache::loncommon::bodytag('Construction Space',undef,undef,undef,undef,undef,$pagetitle));
     } else {
 	$r->print($pagetitle);
@@ -333,8 +333,8 @@
 ENDPUBDIRSCRIPT
     $r->print($pubdirscript);
 
-    if ((($uname ne $ENV{'user.name'}) || ($udom ne $ENV{'user.domain'})) &&
-	$ENV{'environment.remote'} ne 'off') {
+    if ((($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) &&
+	$env{'environment.remote'} ne 'off') {
 	$r->print('<h3>'.&mt('Co-Author').': '.$uname.' at '.$udom.
 		  '</h3>');
     }
Index: loncom/publisher/lonpublisher.pm
diff -u loncom/publisher/lonpublisher.pm:1.191 loncom/publisher/lonpublisher.pm:1.192
--- loncom/publisher/lonpublisher.pm:1.191	Mon Apr  4 19:55:17 2005
+++ loncom/publisher/lonpublisher.pm	Thu Apr  7 02:56:27 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Publication Handler
 #
-# $Id: lonpublisher.pm,v 1.191 2005/04/04 23:55:17 albertel Exp $
+# $Id: lonpublisher.pm,v 1.192 2005/04/07 06:56:27 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -121,7 +121,7 @@
 use Apache::lonxml;
 use Apache::loncacc;
 use DBI;
-use Apache::lonnet();
+use Apache::lonnet;
 use Apache::loncommon();
 use Apache::lonmysql;
 use Apache::lonlocal;
@@ -326,7 +326,7 @@
     $value=~s/\s+$//gs;
     $value=~s/\s+/ /gs;
     $title=&mt($title);
-    $ENV{'form.'.$name}=$value;
+    $env{'form.'.$name}=$value;
     return "\n<p><font color=\"#800000\" face=\"helvetica\"><b>$title:".
            "</b></font></p><br />".
            '<input type="text" name="'.$name.'" size=80 value="'.$value.'" />';
@@ -338,7 +338,7 @@
     $value=~s/\s+$//gs;
     $value=~s/\s+/ /gs;
     $title=&mt($title);
-    $ENV{'form.'.$name}=$value;
+    $env{'form.'.$name}=$value;
     return "\n<p><font color=\"#800000\" face=\"helvetica\"><b>$title:".
            "</b></font></p><br />".
            '<input type="text" name="'.$name.'" size=80 value="'.$value.'" />'.
@@ -349,7 +349,7 @@
 
 sub hiddenfield {
     my ($name,$value)=@_;
-    $ENV{'form.'.$name}=$value;
+    $env{'form.'.$name}=$value;
     return "\n".'<input type="hidden" name="'.$name.'" value="'.$value.'" />';
 }
 
@@ -358,9 +358,9 @@
     $title=&mt($title);
     $value=(split(/\s*,\s*/,$value))[-1];
     if (defined($value)) {
-	$ENV{'form.'.$name}=$value;
+	$env{'form.'.$name}=$value;
     } else {
-	$ENV{'form.'.$name}=$idlist[0];
+	$env{'form.'.$name}=$idlist[0];
     }
     my $selout="\n<p><font color=\"#800000\" face=\"helvetica\"><b>$title:".
 	'</b></font></p><br /><select name="'.$name.'">';
@@ -376,8 +376,8 @@
 
 sub select_level_form {
     my ($value,$name)=@_;
-    $ENV{'form.'.$name}=$value;
-    if (!defined($value)) { $ENV{'form.'.$name}=0; }
+    $env{'form.'.$name}=$value;
+    if (!defined($value)) { $env{'form.'.$name}=0; }
     return  &Apache::loncommon::select_level_form($value,$name);
 }
 #########################################
@@ -928,7 +928,7 @@
 	return ('<font color="red">'.&mt('No write permission to user directory, FAIL').'</font>',1);
     }
     print $logfile 
-"\n\n================= Publish ".localtime()." Phase One  ================\n".$ENV{'user.name'}.'@'.$ENV{'user.domain'}."\n";
+"\n\n================= Publish ".localtime()." Phase One  ================\n".$env{'user.name'}.'@'.$env{'user.domain'}."\n";
 
     if (($style eq 'ssi') || ($style eq 'rat') || ($style eq 'prv')) {
 # ------------------------------------------------------- This needs processing
@@ -1016,10 +1016,10 @@
 
 # ------------------------------------------------ First, check out environment
      unless (-e $source.'.meta') {
-        $metadatafields{'author'}=$ENV{'environment.firstname'}.' '.
-	                          $ENV{'environment.middlename'}.' '.
-		                  $ENV{'environment.lastname'}.' '.
-		                  $ENV{'environment.generation'};
+        $metadatafields{'author'}=$env{'environment.firstname'}.' '.
+	                          $env{'environment.middlename'}.' '.
+		                  $env{'environment.lastname'}.' '.
+		                  $env{'environment.generation'};
         $metadatafields{'author'}=~s/\s+/ /g;
         $metadatafields{'author'}=~s/\s+$//;
         $metadatafields{'owner'}=$cuname.'@'.$cudom;
@@ -1141,14 +1141,14 @@
 # interactive mode html goes into $intr_scrout
 # batch mode throws away this HTML
 # additionally all of the field functions have a by product of setting
-#   $ENV{'from.'..} so that it can be used by the phase two handler in
+#   $env{'from.'..} so that it can be used by the phase two handler in
 #    batch mode
 
     my $intr_scrout.=
 	'<form name="pubform" action="/adm/publish" method="post">'.
 	'<p><input type="submit" value="'.&mt('Finalize Publication').'" /></p>'.
 	&hiddenfield('phase','two').
-	&hiddenfield('filename',$ENV{'form.filename'}).
+	&hiddenfield('filename',$env{'form.filename'}).
 	&hiddenfield('allmeta',&Apache::lonnet::escape($allmeta)).
 	&hiddenfield('dependencies',join(',',keys %allow)).
 	&textfield('Title','title',$metadatafields{'title'}).
@@ -1188,11 +1188,11 @@
 	if ($metadatafields{'keywords'}) {
 	    if ($metadatafields{'keywords'}=~/\Q$_\E/) {
 		$keywordout.=' checked="on"';
-		$ENV{'form.keywords'}.=$_.',';
+		$env{'form.keywords'}.=$_.',';
 	    }
 	} elsif (&Apache::loncommon::keyword($_)) {
 	    $keywordout.=' checked="on"';
-	    $ENV{'form.keywords'}.=$_.',';
+	    $env{'form.keywords'}.=$_.',';
 	}
 	$keywordout.=' />'.$_.'</label></td>';
 	if ($colcount>10) {
@@ -1201,7 +1201,7 @@
 	}
 	$colcount++;
     }
-    $ENV{'form.keywords'}=~s/\,$//;
+    $env{'form.keywords'}=~s/\,$//;
 
     $keywordout.='</tr></table>';
 
@@ -1376,44 +1376,44 @@
         return 0;
     }
     print $logfile 
-        "\n================= Publish ".localtime()." Phase Two  ================\n".$ENV{'user.name'}.'@'.$ENV{'user.domain'}."\n";
+        "\n================= Publish ".localtime()." Phase Two  ================\n".$env{'user.name'}.'@'.$env{'user.domain'}."\n";
     
     %metadatafields=();
     %metadatakeys=();
 
-    &metaeval(&Apache::lonnet::unescape($ENV{'form.allmeta'}));
+    &metaeval(&Apache::lonnet::unescape($env{'form.allmeta'}));
     
-    $metadatafields{'title'}=$ENV{'form.title'};
-    $metadatafields{'author'}=$ENV{'form.author'};
-    $metadatafields{'subject'}=$ENV{'form.subject'};
-    $metadatafields{'notes'}=$ENV{'form.notes'};
-    $metadatafields{'abstract'}=$ENV{'form.abstract'};
-    $metadatafields{'mime'}=$ENV{'form.mime'};
-    $metadatafields{'language'}=$ENV{'form.language'};
-    $metadatafields{'creationdate'}=$ENV{'form.creationdate'};
-    $metadatafields{'lastrevisiondate'}=$ENV{'form.lastrevisiondate'};
-    $metadatafields{'owner'}=$ENV{'form.owner'};
-    $metadatafields{'copyright'}=$ENV{'form.copyright'};
-    $metadatafields{'standards'}=$ENV{'form.standards'};
-    $metadatafields{'lowestgradelevel'}=$ENV{'form.lowestgradelevel'};
-    $metadatafields{'highestgradelevel'}=$ENV{'form.highestgradelevel'};
+    $metadatafields{'title'}=$env{'form.title'};
+    $metadatafields{'author'}=$env{'form.author'};
+    $metadatafields{'subject'}=$env{'form.subject'};
+    $metadatafields{'notes'}=$env{'form.notes'};
+    $metadatafields{'abstract'}=$env{'form.abstract'};
+    $metadatafields{'mime'}=$env{'form.mime'};
+    $metadatafields{'language'}=$env{'form.language'};
+    $metadatafields{'creationdate'}=$env{'form.creationdate'};
+    $metadatafields{'lastrevisiondate'}=$env{'form.lastrevisiondate'};
+    $metadatafields{'owner'}=$env{'form.owner'};
+    $metadatafields{'copyright'}=$env{'form.copyright'};
+    $metadatafields{'standards'}=$env{'form.standards'};
+    $metadatafields{'lowestgradelevel'}=$env{'form.lowestgradelevel'};
+    $metadatafields{'highestgradelevel'}=$env{'form.highestgradelevel'};
     $metadatafields{'customdistributionfile'}=
-                                 $ENV{'form.customdistributionfile'};
-    $metadatafields{'sourceavail'}=$ENV{'form.sourceavail'};
-    $metadatafields{'obsolete'}=$ENV{'form.obsolete'};
+                                 $env{'form.customdistributionfile'};
+    $metadatafields{'sourceavail'}=$env{'form.sourceavail'};
+    $metadatafields{'obsolete'}=$env{'form.obsolete'};
     $metadatafields{'obsoletereplacement'}=
-	                        $ENV{'form.obsoletereplacement'};
-    $metadatafields{'dependencies'}=$ENV{'form.dependencies'};
-    $metadatafields{'modifyinguser'}=$ENV{'user.name'}.'@'.
-	                                 $ENV{'user.domain'};
+	                        $env{'form.obsoletereplacement'};
+    $metadatafields{'dependencies'}=$env{'form.dependencies'};
+    $metadatafields{'modifyinguser'}=$env{'user.name'}.'@'.
+	                                 $env{'user.domain'};
     $metadatafields{'authorspace'}=$cuname.'@'.$cudom;
     
-    my $allkeywords=$ENV{'form.addkey'};
-    if (exists($ENV{'form.keywords'})) {
-        if (ref($ENV{'form.keywords'})) {
-            $allkeywords .= ','.join(',',@{$ENV{'form.keywords'}});
+    my $allkeywords=$env{'form.addkey'};
+    if (exists($env{'form.keywords'})) {
+        if (ref($env{'form.keywords'})) {
+            $allkeywords .= ','.join(',',@{$env{'form.keywords'}});
         } else {
-            $allkeywords .= ','.$ENV{'form.keywords'};
+            $allkeywords .= ','.$env{'form.keywords'};
         }
     }
     $allkeywords=~s/[\"\']//g;
@@ -1651,8 +1651,8 @@
 
 sub batchpublish {
     my ($r,$srcfile,$targetfile)=@_;
-    #publication pollutes %ENV with form.* values
-    my %oldENV=%ENV;
+    #publication pollutes %env with form.* values
+    my %oldenv=%env;
     $srcfile=~s/\/+/\//g;
     $targetfile=~s/\/+/\//g;
     my $thisdisfn=$srcfile;
@@ -1680,13 +1680,13 @@
     $r->print('<p>'.$outstring.'</p>');
 # phase two takes
 # my ($source,$target,$style,$distarget,batch)=@_;
-# $ENV{'form.allmeta'},$ENV{'form.title'},$ENV{'form.author'},...
+# $env{'form.allmeta'},$env{'form.title'},$env{'form.author'},...
     if (!$error) {
 	$r->print('<p>');
 	&phasetwo($r,$srcfile,$targetfile,$thisembstyle,$thisdistarget,1);
 	$r->print('</p>');
     }
-    %ENV=%oldENV;
+    %env=%oldenv;
     return '';
 }
 
@@ -1715,7 +1715,7 @@
 	my $extension='';
 	if ($filename=~/\.(\w+)$/) { $extension=$1; }
 	if ($cmode&$dirptr) {
-	    if (($filename!~/^\./) && ($ENV{'form.pubrec'})) {
+	    if (($filename!~/^\./) && ($env{'form.pubrec'})) {
 		&publishdirectory($r,$fn.'/'.$filename,$thisdisfn.'/'.$filename);
 	    }
 	} elsif ((&Apache::loncommon::fileembstyle($extension) ne 'hdn') &&
@@ -1727,7 +1727,7 @@
 		    $ruid,$rgid,$rrdev,$rsize,
 		    $ratime,$rmtime,$rctime,
 		    $rblksize,$rblocks)=stat($resdir.'/'.$filename);
-	        if (($rmtime<$cmtime) || ($ENV{'form.forcerepub'} eq 'ON')) {
+	        if (($rmtime<$cmtime) || ($env{'form.forcerepub'} eq 'ON')) {
 # previously published, modified now
 		    $publishthis=1;
                 }
@@ -1861,7 +1861,7 @@
     @{$modified_urls}=();
 # -------------------------------------------------------------- Check filename
 
-    my $fn=&Apache::lonnet::unescape($ENV{'form.filename'});
+    my $fn=&Apache::lonnet::unescape($env{'form.filename'});
 
     ($cuname,$cudom)=
 	&Apache::loncacc::constructaccess($fn,$r->dir_config('lonDefDomain'));
@@ -1880,7 +1880,7 @@
 
     unless (($cuname) && ($cudom)) {
 	$r->log_reason($cuname.' at '.$cudom.
-		       ' trying to publish file '.$ENV{'form.filename'}.
+		       ' trying to publish file '.$env{'form.filename'}.
 		       ' ('.$fn.') - not authorized', 
 		       $r->filename); 
 	return HTTP_NOT_ACCEPTABLE;
@@ -1892,7 +1892,7 @@
     foreach my $id (@ids) { if ($id eq $home) { $allowed = 1; }  }
     unless ($allowed) {
 	$r->log_reason($cuname.' at '.$cudom.
-		       ' trying to publish file '.$ENV{'form.filename'}.
+		       ' trying to publish file '.$env{'form.filename'}.
 		       ' ('.$fn.') - not homeserver ('.$home.')', 
 		       $r->filename); 
 	return HTTP_NOT_ACCEPTABLE;
@@ -1906,7 +1906,7 @@
     if ($1 ne $cuname) {
 	$r->log_reason($cuname.' at '.$cudom.
 		       ' trying to publish unowned file '.
-		       $ENV{'form.filename'}.' ('.$fn.')', 
+		       $env{'form.filename'}.' ('.$fn.')', 
 		       $r->filename); 
 	return HTTP_NOT_ACCEPTABLE;
     } else {
@@ -1917,12 +1917,12 @@
     unless (-e $fn) { 
 	$r->log_reason($cuname.' at '.$cudom.
 		       ' trying to publish non-existing file '.
-		       $ENV{'form.filename'}.' ('.$fn.')', 
+		       $env{'form.filename'}.' ('.$fn.')', 
 		       $r->filename); 
 	return HTTP_NOT_FOUND;
     } 
 
-    unless ($ENV{'form.phase'} eq 'two') {
+    unless ($env{'form.phase'} eq 'two') {
 
 # -------------------------------- File is there and owned, init lookup tables.
 
@@ -1996,7 +1996,7 @@
         $r->print('</tt></h2><b>'.&mt('Target').':</b> <tt>'.
 		  $thisdistarget.'</tt><br />');
    
-	if (($cuname ne $ENV{'user.name'})||($cudom ne $ENV{'user.domain'})) {
+	if (($cuname ne $env{'user.name'})||($cudom ne $env{'user.domain'})) {
 	    $r->print('<h3><font color="red">'.&mt('Co-Author').': '.
 		      $cuname.&mt(' at ').$cudom.'</font></h3>');
 	}
@@ -2011,7 +2011,7 @@
   
 # ------------------ Publishing from $thisfn to $thistarget with $thisembstyle.
 
-	unless ($ENV{'form.phase'} eq 'two') {
+	unless ($env{'form.phase'} eq 'two') {
 # ---------------------------------------------------------- Parse for problems
 	    my ($warningcount,$errorcount);
 	    if ($thisembstyle eq 'ssi') {
Index: loncom/publisher/lonpubmenu.pm
diff -u loncom/publisher/lonpubmenu.pm:1.2 loncom/publisher/lonpubmenu.pm:1.3
--- loncom/publisher/lonpubmenu.pm:1.2	Wed Mar  9 22:50:49 2005
+++ loncom/publisher/lonpubmenu.pm	Thu Apr  7 02:56:27 2005
@@ -27,6 +27,7 @@
 
 package Apache::lonpubmenu;
 use Apache::lonlocal;
+use Apache::lonnet;
 use Apache::loncommon;
 
 sub handler {
@@ -61,10 +62,10 @@
                                        prnt => 'Print'
                                       );
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['disp']);
-    my $disp = $ENV{'form.disp'};
+    my $disp = $env{'form.disp'};
 # set defaults for parent directory in case frameloc is unable to determine directory
-    my $defaultdir = '/priv/'.$ENV{'user.name'}.'/'; 
-    if ($ENV{'request.role'} =~ m#^ca\./[^/]+/([^/]+)#) {
+    my $defaultdir = '/priv/'.$env{'user.name'}.'/'; 
+    if ($env{'request.role'} =~ m#^ca\./[^/]+/([^/]+)#) {
         $defaultdir = '/priv/'.$1.'/';
     }
     $r->print(<<"ENDONE");
Index: loncom/publisher/lonretrieve.pm
diff -u loncom/publisher/lonretrieve.pm:1.26 loncom/publisher/lonretrieve.pm:1.27
--- loncom/publisher/lonretrieve.pm:1.26	Wed Jan  5 12:38:27 2005
+++ loncom/publisher/lonretrieve.pm	Thu Apr  7 02:56:27 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to retrieve an old version of a file
 #
-# $Id: lonretrieve.pm,v 1.26 2005/01/05 17:38:27 www Exp $
+# $Id: lonretrieve.pm,v 1.27 2005/04/07 06:56:27 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -37,6 +37,7 @@
 use Apache::loncacc;
 use Apache::loncommon();
 use Apache::lonlocal;
+use Apache::lonnet;
 
 # ------------------------------------ Interface for selecting previous version
 sub phaseone {
@@ -110,8 +111,8 @@
 # ---------------------------------- Interface for presenting specified version
 sub phasetwo {
     my ($r,$fn,$uname,$udom)=@_;
-    if ($ENV{'form.version'}) {
-        my $version=$ENV{'form.version'};
+    if ($env{'form.version'}) {
+        my $version=$env{'form.version'};
 	if ($version eq 'new') {
 	    $r->print('<h3>'.&mt('Retrieving current (most recent) version').'</h3>');
         } else {
@@ -162,17 +163,17 @@
   &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
 					  ['filename']);
 
-  if ($ENV{'form.filename'}) {
-      $fn=$ENV{'form.filename'};
+  if ($env{'form.filename'}) {
+      $fn=$env{'form.filename'};
       $fn=~s/^http\:\/\/[^\/]+//;
   } else {
-     $r->log_reason($ENV{'user.name'}.' at '.$ENV{'user.domain'}.
+     $r->log_reason($env{'user.name'}.' at '.$env{'user.domain'}.
          ' unspecified filename for retrieval', $r->filename); 
      return HTTP_NOT_FOUND;
   }
 
   unless ($fn) { 
-     $r->log_reason($ENV{'user.name'}.' at '.$ENV{'user.domain'}.
+     $r->log_reason($env{'user.name'}.' at '.$env{'user.domain'}.
          ' trying to retrieve non-existing file', $r->filename); 
      return HTTP_NOT_FOUND;
   } 
@@ -185,7 +186,7 @@
     &Apache::loncacc::constructaccess($fn,$r->dir_config('lonDefDomain'));
   unless (($uname) && ($udom)) {
      $r->log_reason($uname.' at '.$udom.
-         ' trying to publish file '.$ENV{'form.filename'}.
+         ' trying to publish file '.$env{'form.filename'}.
          ' ('.$fn.') - not authorized', 
          $r->filename); 
      return HTTP_NOT_ACCEPTABLE;
@@ -203,14 +204,14 @@
   
   $r->print('<h1>'.&mt('Retrieve previous versions of').' <tt>'.$fn.'</tt></h1>');
   
-  if (($uname ne $ENV{'user.name'}) || ($udom ne $ENV{'user.domain'})) {
+  if (($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) {
           $r->print('<h3><font color=red>'.&mt('Co-Author').': '.$uname.
 		    &mt(' at ').$udom.
                '</font></h3>');
   }
 
 
-  if ($ENV{'form.phase'} eq 'two') {
+  if ($env{'form.phase'} eq 'two') {
       &phasetwo($r,$fn,$uname,$udom);
   } else {
       &phaseone($r,$fn,$uname,$udom);
Index: loncom/publisher/lonrights.pm
diff -u loncom/publisher/lonrights.pm:1.16 loncom/publisher/lonrights.pm:1.17
--- loncom/publisher/lonrights.pm:1.16	Fri Feb 18 18:15:54 2005
+++ loncom/publisher/lonrights.pm	Thu Apr  7 02:56:27 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to show and edit custom distribution rights
 #
-# $Id: lonrights.pm,v 1.16 2005/02/18 23:15:54 albertel Exp $
+# $Id: lonrights.pm,v 1.17 2005/04/07 06:56:27 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -32,7 +32,7 @@
 
 use strict;
 use Apache::Constants qw(:common :http);
-use Apache::lonnet();
+use Apache::lonnet;
 use Apache::loncommon();
 use HTML::LCParser;
 use Apache::File;
@@ -41,11 +41,11 @@
 sub handler {
 
   my $r=shift;
-  my $target = $ENV{'form.grade_target'};
+  my $target = $env{'form.grade_target'};
   if ($target eq 'meta') {
       &Apache::loncommon::content_type($r,'text/html');
       $r->send_http_header;
-      $ENV{'request.uri'}=$r->uri;
+      $env{'request.uri'}=$r->uri;
       my $file = &Apache::lonnet::filelocation("",$r->uri);
       my $content=&Apache::lonnet::getfile($file);
       my $result=&Apache::lonxml::xmlparse(undef,'meta',$content);
@@ -69,16 +69,16 @@
 
 # ============================================================ Modify and store
   if ($constructmode) {
-      if ($ENV{'form.store'}) {
+      if ($env{'form.store'}) {
 	  my @newrules=();
           undef @newrules;
 # read rules from form
-          foreach (keys %ENV) {
+          foreach (keys %env) {
 	      if ($_=~/^form\.effect\_(\d+)$/) {
 		  my $number=$1;
                   my %rulehash=();
                   foreach ('effect','domain','course','section','role') {
-		      $rulehash{$_}=$ENV{'form.'.$_.'_'.$number};
+		      $rulehash{$_}=$env{'form.'.$_.'_'.$number};
                   }
                   if ($rulehash{'role'} eq 'au') {
 		      $rulehash{'course'}='';
@@ -95,7 +95,7 @@
                   $rulehash{'course'}=~s/\W//g;
                   $rulehash{'section'}=~s/\W//g;
                   unless ($rulehash{'domain'}) { 
-                     $rulehash{'domain'}=$ENV{'user.domain'}; 
+                     $rulehash{'domain'}=$env{'user.domain'}; 
                   }
                   my $realm='';
                   if ($number) {
@@ -112,27 +112,27 @@
               }
           }
 # edit actions?
-          foreach (keys %ENV) {
+          foreach (keys %env) {
 	      if ($_=~/^form\.action\_(\d+)$/) {
                   my $number=$1;
-		  if ($ENV{$_} eq 'delete') { $newrules[$number]=''; }
-                  if (($ENV{$_} eq 'moveup') && ($number>1)) {
+		  if ($env{$_} eq 'delete') { $newrules[$number]=''; }
+                  if (($env{$_} eq 'moveup') && ($number>1)) {
 		      my $buffer=$newrules[$number];
                       $newrules[$number]=$newrules[$number-1];
                       $newrules[$number-1]=$buffer;
                   }
-                  if (($ENV{$_} eq 'movedown') && ($number<$#newrules)) {
+                  if (($env{$_} eq 'movedown') && ($number<$#newrules)) {
 		      my $buffer=$newrules[$number];
                       $newrules[$number]=$newrules[$number+1];
                       $newrules[$number+1]=$buffer;
                   }
-                  if ($ENV{$_} eq 'insertabove') {
+                  if ($env{$_} eq 'insertabove') {
 		      for (my $i=$#newrules;$i>=$number;$i--) {
 			  $newrules[$i+1]=$newrules[$i];
                       }
                       $newrules[$number]='deny';
                   }
-                  if ($ENV{$_} eq 'insertbelow') {
+                  if ($env{$_} eq 'insertbelow') {
  		      for (my $i=$#newrules;$i>$number;$i--) {
 			  $newrules[$i+1]=$newrules[$i];
                       }
@@ -249,7 +249,7 @@
           my ($rdom,$rcourse,$rsec)=split(/[\/\_]/,$realm);
 # realm domain
           if ($constructmode) {
-              unless ($rdom) { $rdom=$ENV{'user.domain'}; }
+              unless ($rdom) { $rdom=$env{'user.domain'}; }
               $r->print(&Apache::loncommon::select_dom_form($rdom,
                                                       'domain_'.$rulecounter));
           } else {
Index: loncom/publisher/lonunauthorized.pm
diff -u loncom/publisher/lonunauthorized.pm:1.3 loncom/publisher/lonunauthorized.pm:1.4
--- loncom/publisher/lonunauthorized.pm:1.3	Wed Jan 28 19:44:43 2004
+++ loncom/publisher/lonunauthorized.pm	Thu Apr  7 02:56:27 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Unauthorized to access construction space
 #
-# $Id: lonunauthorized.pm,v 1.3 2004/01/29 00:44:43 www Exp $
+# $Id: lonunauthorized.pm,v 1.4 2005/04/07 06:56:27 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -51,7 +51,7 @@
 # Figure out who the user is and what they wanted to access
 
     my ($ownername,$ownerdomain)=
-     &Apache::loncacc::constructaccess($ENV{'request.editurl'},$r->dir_config('lonDefDomain'));
+     &Apache::loncacc::constructaccess($env{'request.editurl'},$r->dir_config('lonDefDomain'));
 # print header
     $r->print(&Apache::loncommon::bodytag
            ("Failed Access to Construction Space",'','','',$ownerdomain));
@@ -71,7 +71,7 @@
         $r->print(
             "<h1>".
 	&mt("You do not have authoring privileges for this resource")."</h1>");
-        my ($realownername)=($ENV{'request.editurl'}=~/\/(?:\~|priv\/|home\/)(\w+)/);
+        my ($realownername)=($env{'request.editurl'}=~/\/(?:\~|priv\/|home\/)(\w+)/);
         my $realownerhome=
       &Apache::lonnet::homeserver(
         $realownername,$r->dir_config('lonDefDomain'));
Index: loncom/publisher/lonupload.pm
diff -u loncom/publisher/lonupload.pm:1.28 loncom/publisher/lonupload.pm:1.29
--- loncom/publisher/lonupload.pm:1.28	Tue Dec  7 17:11:02 2004
+++ loncom/publisher/lonupload.pm	Thu Apr  7 02:56:27 2005
@@ -2,7 +2,7 @@
 # The LearningOnline Network with CAPA
 # Handler to upload files into construction space
 #
-# $Id: lonupload.pm,v 1.28 2004/12/07 22:11:02 raeburn Exp $
+# $Id: lonupload.pm,v 1.29 2005/04/07 06:56:27 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -41,6 +41,7 @@
 use Apache::lonnet;
 use HTML::Entities();
 use Apache::lonlocal;
+use Apache::lonnet;
 
 my $DEBUG=0;
 
@@ -62,17 +63,17 @@
 sub upfile_store {
     my $r=shift;
 	
-    my $fname=$ENV{'form.upfile.filename'};
+    my $fname=$env{'form.upfile.filename'};
     $fname=~s/\W//g;
     
-    chomp($ENV{'form.upfile'});
+    chomp($env{'form.upfile'});
   
-    my $datatoken=$ENV{'user.name'}.'_'.$ENV{'user.domain'}.
+    my $datatoken=$env{'user.name'}.'_'.$env{'user.domain'}.
 		  '_upload_'.$fname.'_'.time.'_'.$$;
     {
        my $fh=Apache::File->new('>'.$r->dir_config('lonDaemons').
                                    '/tmp/'.$datatoken.'.tmp');
-       print $fh $ENV{'form.upfile'};
+       print $fh $env{'form.upfile'};
     }
     return $datatoken;
 }
@@ -86,12 +87,12 @@
     } elsif ($mode eq 'imsimport') {
         $action = '/adm/imsimport';
     }
-    $ENV{'form.upfile.filename'}=~s/\\/\//g;
-    $ENV{'form.upfile.filename'}=~s/^.*\/([^\/]+)$/$1/;
-    if ($ENV{'form.upfile.filename'}) {
+    $env{'form.upfile.filename'}=~s/\\/\//g;
+    $env{'form.upfile.filename'}=~s/^.*\/([^\/]+)$/$1/;
+    if ($env{'form.upfile.filename'}) {
 	$fn=~s/\/[^\/]+$//;
 	$fn=~s/([^\/])$/$1\//;
-	$fn.=$ENV{'form.upfile.filename'};
+	$fn.=$env{'form.upfile.filename'};
 	$fn=~s/^\///;
 	$fn=~s/(\/)+/\//g;
 
@@ -168,9 +169,9 @@
 	$base    = &HTML::Entities::encode($base,'<>&"');
 	my $url  = $path."/".$base; 
 	&Debug($r, "URL is now ".$url);
-	my $datatoken=$ENV{'form.datatoken'};
+	my $datatoken=$env{'form.datatoken'};
 	if (($fn) && ($datatoken)) {
-	    if ((-e $target) && ($ENV{'form.override'} ne 'Yes')) {
+	    if ((-e $target) && ($env{'form.override'} ne 'Yes')) {
 		$r->print('<form action="'.$action.'" method="post">'.
 			  &mt('File').' <tt>'.$fn.'</tt> '.
 			  &mt('exists. Overwrite?').' '.
@@ -250,12 +251,12 @@
 #
 # phase two: re-attach user
 #
-    if ($ENV{'form.uploaduname'}) {
-	$ENV{'form.filename'}='/priv/'.$ENV{'form.uploaduname'}.'/'.
-	    $ENV{'form.filename'};
+    if ($env{'form.uploaduname'}) {
+	$env{'form.filename'}='/priv/'.$env{'form.uploaduname'}.'/'.
+	    $env{'form.filename'};
     }
 
-    unless ($ENV{'form.phase'} eq 'two') {
+    unless ($env{'form.phase'} eq 'two') {
         $javascript = qq|
 function verifyForm() {
     var mode = document.fileupload.filetype.options[document.fileupload.filetype.selectedIndex].value
@@ -294,25 +295,25 @@
 |;
     }
     ($uname,$udom)=
-	&Apache::loncacc::constructaccess($ENV{'form.filename'},
+	&Apache::loncacc::constructaccess($env{'form.filename'},
 					  $r->dir_config('lonDefDomain'));
     unless (($uname) && ($udom)) {
 	$r->log_reason($uname.' at '.$udom.
-		       ' trying to publish file '.$ENV{'form.filename'}.
+		       ' trying to publish file '.$env{'form.filename'}.
 		       ' - not authorized', 
 		       $r->filename); 
 	return HTTP_NOT_ACCEPTABLE;
     }
     
     my $fn;
-    if ($ENV{'form.filename'}) {
-	$fn=$ENV{'form.filename'};
+    if ($env{'form.filename'}) {
+	$fn=$env{'form.filename'};
 	$fn=~s/^http\:\/\/[^\/]+\///;
 	$fn=~s/^\///;
 	$fn=~s/(\~|priv\/)(\w+)//;
 	$fn=~s/\/+/\//g;
     } else {
-	$r->log_reason($ENV{'user.name'}.' at '.$ENV{'user.domain'}.
+	$r->log_reason($env{'user.name'}.' at '.$env{'user.domain'}.
 		       ' unspecified filename for upload', $r->filename); 
 	return HTTP_NOT_FOUND;
     }
@@ -327,12 +328,12 @@
 
     $r->print(&Apache::loncommon::bodytag('Upload file to Construction Space'));
   
-    if (($uname ne $ENV{'user.name'}) || ($udom ne $ENV{'user.domain'})) {
+    if (($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) {
 	$r->print('<h3><font color=red>'.&mt('Co-Author').': '.$uname.
 		  &mt(' at ').$udom.'</font></h3>');
     }
 
-    if ($ENV{'form.phase'} eq 'two') {
+    if ($env{'form.phase'} eq 'two') {
 	&phasetwo($r,$fn,$uname,$udom);
     } else {
 	&phaseone($r,$fn,$uname,$udom);
Index: loncom/publisher/testbankimport.pm
diff -u loncom/publisher/testbankimport.pm:1.5 loncom/publisher/testbankimport.pm:1.6
--- loncom/publisher/testbankimport.pm:1.5	Thu Aug  5 17:08:24 2004
+++ loncom/publisher/testbankimport.pm	Thu Apr  7 02:56:27 2005
@@ -1,5 +1,5 @@
 # Handler for parsing text upload problem descriptions into .problems
-# $Id: testbankimport.pm,v 1.5 2004/08/05 21:08:24 raeburn Exp $
+# $Id: testbankimport.pm,v 1.6 2005/04/07 06:56:27 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -40,8 +40,8 @@
 # ---------------------------------------------------------------- Display Control
 sub display_control {
 # figure out what page we're on and where we're heading.
-    my $page = $ENV{'form.page'};
-    my $command = $ENV{'form.go'};
+    my $page = $env{'form.page'};
+    my $command = $env{'form.go'};
     my $current_page = &calculate_page($page,$command);
     return $current_page;
 }
@@ -86,13 +86,13 @@
     var iter = 0
     var selParam = 0
 END_SCRIPT
-    if (exists($ENV{'form.blocks'}) ) {
+    if (exists($env{'form.blocks'}) ) {
         $$jsref .= qq|
-    document.forms.display.blocks.value = $ENV{'form.blocks'}\n|;
-    } elsif (exists($ENV{'form.qnumformat'}) ) {
+    document.forms.display.blocks.value = $env{'form.blocks'}\n|;
+    } elsif (exists($env{'form.qnumformat'}) ) {
         $$jsref .= <<"TO_HERE";
     for (iter=0; iter<document.forms.display.qnumformat.length; iter++) {
-        if(document.forms.display.qnumformat.options[iter].value == "$ENV{'form.qnumformat'}") {
+        if(document.forms.display.qnumformat.options[iter].value == "$env{'form.qnumformat'}") {
             selParam = iter
         }
     }
@@ -108,8 +108,8 @@
 sub jscript_two {
     my ($jsref,$qcount) = @_;
     my $blocks = 0;
-    if ( exists( $ENV{'form.blocks'}) ) {
-        $blocks = $ENV{'form.blocks'};
+    if ( exists( $env{'form.blocks'}) ) {
+        $blocks = $env{'form.blocks'};
     }
     $$jsref = <<"END_SCRIPT";
 function verify() {
@@ -308,7 +308,7 @@
     for (my $x=0; $x<$blocks; $x++) {
         foreach my $name (@names) {
             my $parname = $name.$x;
-            my $value = $ENV{"form.$parname"};
+            my $value = $env{"form.$parname"};
             if ($value ne "") {
                 if (($name eq "start_")  || ($name eq "end_")) {
                     $$jsref .= qq|
@@ -345,8 +345,8 @@
 sub jscript_three {
     my ($fullpath,$jsref) = @_;
     my $source = '';
-    if (exists($ENV{'form.go'}) ) {
-        $source = $ENV{'form.go'};
+    if (exists($env{'form.go'}) ) {
+        $source = $env{'form.go'};
     }
     $$jsref = <<"END_OF_ONE";
 function verify() {
@@ -398,10 +398,10 @@
     var iter = 0
     var selParam = 0
         |;
-        foreach my $item (keys %ENV) {
+        foreach my $item (keys %env) {
             if ($item =~ m/^form\.(\w+)$/) {
                 my $name = $1; 
-                my $value = $ENV{"form.$name"};
+                my $value = $env{"form.$name"};
                 unless ($value eq "") {
                     if ($name eq "newdir") {
              	        $$jsref .= qq(    document.forms.dataForm.$name.value = "$value"\n);
@@ -654,8 +654,8 @@
 
 sub display_two {
     my ($r,$uname,$fn,$page,$textref,$qcount) = @_;
-    my $blocks = $ENV{'form.blocks'};
-    my $qnumformat = $ENV{'form.qnumformat'};
+    my $blocks = $env{'form.blocks'};
+    my $qnumformat = $env{'form.qnumformat'};
     my @types = ("MC","MA","TF","Ess","FIB","Ord");
     my %typenames = (
              MC => "Multiple Choice",
@@ -867,10 +867,10 @@
 # ---------------------------------------------------------------- Display Three
 sub display_three { 
     my ($r,$uname,$fn,$page,$textref,$qcount) = @_;
-    my $qnumformat = $ENV{'form.qnumformat'};
-    my $filename = $ENV{'form.filename'};
-    my $source = $ENV{'form.go'};
-    my $blocks = $ENV{'form.blocks'};
+    my $qnumformat = $env{'form.qnumformat'};
+    my $filename = $env{'form.filename'};
+    my $source = $env{'form.go'};
+    my $blocks = $env{'form.blocks'};
     my @items = ();
     my @bgcolors = ('#ffffff','#eeeeee');
     my @types = ("MC","MA","TF","Ess","FIB","Ord");
@@ -885,18 +885,18 @@
     my %multparts = ();
     my $numitems = 0;
     for (my $i=0; $i<$blocks; $i++) {
-        if (($ENV{"form.start_$i"} ne '') && ($ENV{"form.end_$i"} ne '')) {
-            $start[$i] = $ENV{"form.start_$i"};
-            $end[$i] = $ENV{"form.end_$i"};
+        if (($env{"form.start_$i"} ne '') && ($env{"form.end_$i"} ne '')) {
+            $start[$i] = $env{"form.start_$i"};
+            $end[$i] = $env{"form.end_$i"};
             $nums[$i] = $end[$i]-$start[$i] +1;
-            $qtype[$i] = $ENV{"form.qtype_$i"};
+            $qtype[$i] = $env{"form.qtype_$i"};
             if (($qtype[$i] eq "MC") || ($qtype[$i] eq "MA") || ($qtype[$i] eq "Ord")) {
-                $foilformats[$i] = $ENV{"form.foilformat_$i"};
+                $foilformats[$i] = $env{"form.foilformat_$i"};
             } else {
                 $foilformats[$i] = '';
             } 
             if (($qtype[$i] eq "MA") || ($qtype[$i] eq "FIB") || ($qtype[$i] eq "TF") || ($qtype[$i] eq "Ord")) {
-                $ansrtypes[$i] = $ENV{"form.ansr_$i"};
+                $ansrtypes[$i] = $env{"form.ansr_$i"};
             } else {
                 $ansrtypes[$i] = '';
             }  
@@ -1094,9 +1094,9 @@
 # ---------------------------------------------------------------- Final Display
 sub final_display {
     my ($r,$uname,$fn,$page,$textref) = @_;
-    my $qnumformat = $ENV{'form.qnumformat'};
-    my $blocks = $ENV{'form.blocks'};
-    my $newdir = $ENV{'form.newdir'};
+    my $qnumformat = $env{'form.qnumformat'};
+    my $blocks = $env{'form.blocks'};
+    my $newdir = $env{'form.newdir'};
     my $linkdir = $newdir;
     if ($linkdir =~ m#^/home/$uname/public_html/(.+)$#) {
         $linkdir = '/priv/'.$uname.'/'.$1;
@@ -1113,21 +1113,21 @@
     my %multparts = ();
     my $numitems = 0;
     for (my $i=0; $i<$blocks; $i++) {
-        $start[$i] = $ENV{"form.start_$i"};
-        $end[$i] = $ENV{"form.end_$i"};
+        $start[$i] = $env{"form.start_$i"};
+        $end[$i] = $env{"form.end_$i"};
         if (($end[$i] - $start[$i]) >= 0) {
             $nums[$i] = $end[$i] - $start[$i]+1;
         } else {
             $nums[$i] = 0;
         }
-        $qtype[$i] = $ENV{"form.qtype_$i"};
+        $qtype[$i] = $env{"form.qtype_$i"};
         if (($qtype[$i] eq "MC") || ($qtype[$i] eq "MA") || ($qtype[$i] eq "Ord")) {
-            $foilformats[$i] = $ENV{"form.foilformat_$i"};
+            $foilformats[$i] = $env{"form.foilformat_$i"};
         } else {
             $foilformats[$i] = '';
         }
         if (($qtype[$i] eq "MA") || ($qtype[$i] eq "FIB") || ($qtype[$i] eq "TF") || ($qtype[$i] eq "Ord")) {
-            $ansrtypes[$i] = $ENV{"form.ansr_$i"};
+            $ansrtypes[$i] = $env{"form.ansr_$i"};
         }
         $numitems += $nums[$i];
     }
@@ -1705,16 +1705,16 @@
 #
 # phase two: re-attach user
 #
-    if ($ENV{'form.uploaduname'}) {
-        $ENV{'form.filename'}='/priv/'.$ENV{'form.uploaduname'}.'/'.
-            $ENV{'form.filename'};
+    if ($env{'form.uploaduname'}) {
+        $env{'form.filename'}='/priv/'.$env{'form.uploaduname'}.'/'.
+            $env{'form.filename'};
     }
     ($uname,$udom)=
-        &Apache::loncacc::constructaccess($ENV{'form.filename'},
+        &Apache::loncacc::constructaccess($env{'form.filename'},
                                           $r->dir_config('lonDefDomain'));
     unless (($uname) && ($udom)) {
         $r->log_reason($uname.' at '.$udom.
-                       ' trying to publish file '.$ENV{'form.filename'}.
+                       ' trying to publish file '.$env{'form.filename'}.
                        ' - not authorized',
                        $r->filename);
         return HTTP_NOT_ACCEPTABLE;
@@ -1722,14 +1722,14 @@
                                                                              
     my $fn;
     my $badfile = 0;
-    if ($ENV{'form.filename'}) {
-        $fn=$ENV{'form.filename'};
+    if ($env{'form.filename'}) {
+        $fn=$env{'form.filename'};
         $fn=~s/^http\:\/\/[^\/]+\///;
         $fn=~s/^\///;
         $fn=~s/(\~|priv\/)(\w+)//;
         $fn=~s/\/+/\//g;
     } else {
-        $r->log_reason($ENV{'user.name'}.' at '.$ENV{'user.domain'}.
+        $r->log_reason($env{'user.name'}.' at '.$env{'user.domain'}.
                        ' unspecified filename for upload', $r->filename);
         return HTTP_NOT_FOUND;
     }
@@ -1743,7 +1743,7 @@
 
     my @text = ();
     my $loadentries = '';
-    if ($ENV{'form.phase'} eq 'three') {    
+    if ($env{'form.phase'} eq 'three') {    
         if (-e "$dirpath$fn") {
             open(TESTBANK,"<$dirpath$fn");
             @text = <TESTBANK>;
@@ -1757,7 +1757,7 @@
     &Apache::loncommon::content_type($r,'text/html');
     $r->send_http_header;
 
-    if ($ENV{'form.phase'} eq 'three') {
+    if ($env{'form.phase'} eq 'three') {
         $current_page = &display_control();
         my @PAGES = ('Welcome','Blocks','Format','Target','Confirmation');
         $page_name = $PAGES[$current_page];
@@ -1766,10 +1766,10 @@
             $loadentries = 'onLoad= "setElements()"';
             &jscript_one(\$javascript);
         } elsif ($page_name eq 'Format') { 
-            $qcount = question_count($ENV{'form.qnumformat'},\@text);
+            $qcount = question_count($env{'form.qnumformat'},\@text);
  	    &jscript_two(\$javascript,$qcount);
          } elsif ($page_name eq 'Target') {
-             if ($ENV{'form.go'} eq "PreviousPage") {
+             if ($env{'form.go'} eq "PreviousPage") {
                  $loadentries =  'onLoad = "setElements()"';
  	     }
 	     &jscript_three($fullpath,\$javascript);
@@ -1782,12 +1782,12 @@
                                                                                   
     $r->print(&Apache::loncommon::bodytag('Upload testbank questions to Construction Space',undef,$loadentries));
                                                                                   
-    if (($uname ne $ENV{'user.name'}) || ($udom ne $ENV{'user.domain'})) {
+    if (($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) {
         $r->print('<h3><font color=red>'.&mt('Co-Author').': '.$uname.
                   &mt(' at ').$udom.'</font></h3>');
     }
 
-    if ($ENV{'form.phase'} eq 'three') {
+    if ($env{'form.phase'} eq 'three') {
         if ($badfile) {
             &file_error($r,$uname,$fn,$current_page);
         } else {        
@@ -1797,7 +1797,7 @@
             &display_three ($r,$uname,$fn,$current_page,\@text,$qcount) if $page_name eq 'Target';
             &final_display ($r,$uname,$fn,$current_page,\@text) if $page_name eq 'Confirmation';
         }
-    } elsif ($ENV{'form.phase'} eq 'two') {
+    } elsif ($env{'form.phase'} eq 'two') {
         my $flag = &Apache::lonupload::phasetwo($r,$fn,$uname,$udom,'testbank');
         if ($flag eq 'ok') {
             my $current_page = 0;
Index: loncom/xml/londefdef.pm
diff -u loncom/xml/londefdef.pm:1.266 loncom/xml/londefdef.pm:1.267
--- loncom/xml/londefdef.pm:1.266	Wed Apr  6 02:09:42 2005
+++ loncom/xml/londefdef.pm	Thu Apr  7 02:56:27 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Tags Default Definition Module 
 #
-# $Id: londefdef.pm,v 1.266 2005/04/06 06:09:42 albertel Exp $
+# $Id: londefdef.pm,v 1.267 2005/04/07 06:56:27 albertel Exp $
 # 
 #
 # Copyright Michigan State University Board of Trustees
@@ -39,7 +39,7 @@
 
 package Apache::londefdef; 
 
-use Apache::lonnet();
+use Apache::lonnet;
 use strict;
 use Apache::lonxml;
 use Apache::File();
@@ -132,7 +132,7 @@
     if ($target eq 'web') {
 	my $inside = &Apache::lonxml::get_all_text("/tthoption",$parser);
 	$inside=~s/^\s*//;
-	if ($ENV{'browser.mathml'}) {
+	if ($env{'browser.mathml'}) {
 	    &tth::ttmoptions($inside);
 	} else {
 	    &tth::tthoptions($inside);
@@ -151,14 +151,14 @@
 sub start_html {
     my ($target,$token) = @_;
     my $currentstring = '';
-    my $options=$ENV{'course.'.$ENV{'request.course.id'}.'.tthoptions'};
+    my $options=$env{'course.'.$env{'request.course.id'}.'.tthoptions'};
     &Apache::lontexconvert::init_tth();
     if ($target eq 'web' || $target eq 'edit') {
 	$currentstring = &Apache::lonxml::xmlbegin();
     } elsif ($target eq 'tex') {
 	$currentstring .= '\documentclass[letterpaper]{article}';
-	if (($ENV{'form.latex_type'}=~'batchmode') ||
-            (!$ENV{'request.role.adv'})) {$currentstring .='\batchmode';} 
+	if (($env{'form.latex_type'}=~'batchmode') ||
+            (!$env{'request.role.adv'})) {$currentstring .='\batchmode';} 
 	$currentstring .= '\newcommand{\keephidden}[1]{}'.
                           '\renewcommand{\deg}{$^{\circ}$}'.
                           '\usepackage{longtable}'.
@@ -201,7 +201,7 @@
 sub end_head {
     my ($target,$token) = @_;
     my $currentstring = '';
-    if ($target eq 'web' && $ENV{'request.state'} eq 'published') {
+    if ($target eq 'web' && $env{'request.state'} eq 'published') {
 	$currentstring = &Apache::lonmenu::registerurl(undef,$target).
 	    $token->[2];    
     } 
@@ -489,15 +489,15 @@
 	    return '';
 	}
 	if (!$Apache::lonxml::registered && 
-	    $ENV{'request.state'} eq 'published') {
+	    $env{'request.state'} eq 'published') {
 	    $currentstring.='<head>'.
 		&Apache::lonmenu::registerurl(undef,$target).'</head>';
 	}
 # Accessibility
-	if ($ENV{'browser.imagesuppress'} eq 'on') {
+	if ($env{'browser.imagesuppress'} eq 'on') {
 	    delete($token->[2]->{'background'});
 	}
-	if ($ENV{'browser.fontenhance'} eq 'on') {
+	if ($env{'browser.fontenhance'} eq 'on') {
 	    my $style='';
 	    foreach my $key (keys(%{$token->[2]})) {
 		if ($key =~ /^style$/i) {
@@ -507,7 +507,7 @@
 	    }
 	    $token->[2]->{'style'}=$style.'; font-size: x-large;';
 	}
-	if ($ENV{'browser.blackwhite'} eq 'on') {
+	if ($env{'browser.blackwhite'} eq 'on') {
 	    delete($token->[2]->{'font'});
 	    delete($token->[2]->{'link'});
 	    delete($token->[2]->{'alink'});
@@ -534,17 +534,17 @@
 	$token->[2]->{'onunload'}=&Apache::lonmenu::unloadevents().
 	    ';'.$onUnload;
 	
-	if ($ENV{'request.state'} ne 'construct') {
+	if ($env{'request.state'} ne 'construct') {
 	    $currentstring .= '<'.$token->[1];
 	}
 	foreach (keys %{$token->[2]}) {
 	    $currentstring.=' '.$_.'="'.$token->[2]->{$_}.'"';
 	}
-	if ($ENV{'request.state'} ne 'construct') {
+	if ($env{'request.state'} ne 'construct') {
 	    $currentstring.='>';
 	}
-	if ($ENV{'request.state'} ne 'published') {
-	    my $remote=($ENV{'environment.remote'} ne 'off');
+	if ($env{'request.state'} ne 'published') {
+	    my $remote=($env{'environment.remote'} ne 'off');
 	    $currentstring=&Apache::loncommon::bodytag(undef,undef,
 						       $currentstring,$remote);
 	    $currentstring.=(<<EDITBUTTON);
@@ -1125,9 +1125,9 @@
 	if ($align eq 'center') {
 	    $currentstring='\begin{center}\par';
 	} elsif ($align eq 'right') {
-	    $currentstring='\makebox['.$ENV{'form.textwidth'}.']{\hfill\llap{';
+	    $currentstring='\makebox['.$env{'form.textwidth'}.']{\hfill\llap{';
 	} elsif ($align eq 'left') {
-	    $currentstring='\noindent\makebox['.$ENV{'form.textwidth'}.']{\rlap{';
+	    $currentstring='\noindent\makebox['.$env{'form.textwidth'}.']{\rlap{';
 	} else {
             $currentstring='\par ';
         }
@@ -1276,8 +1276,8 @@
     if ($target eq 'web') {
 	my $face=&Apache::lonxml::get_param('face',$parstack,$safeeval);
 	if ($face!~/symbol/i) {
-	    if (($ENV{'browser.fontenhance'} eq 'on') || 
-		($ENV{'browser.blackwhite'} eq 'on')) { return ''; }
+	    if (($env{'browser.fontenhance'} eq 'on') || 
+		($env{'browser.blackwhite'} eq 'on')) { return ''; }
 	}
 	$currentstring = $token->[4];     
     }  elsif ($target eq 'tex') {
@@ -1825,7 +1825,7 @@
 	$Apache::londefdef::table[-1]{'row_number'} = -1;
         #maximum table's width (default coincides with text line length)
 	if ($#Apache::londefdef::table==0) {
-	    $textwidth=&recalc($ENV{'form.textwidth'}); #result is always in mm
+	    $textwidth=&recalc($env{'form.textwidth'}); #result is always in mm
 	    $textwidth=~/(\d+\.?\d*)/;
 	    $textwidth=0.95*$1; #accounts "internal" LaTeX space for table frame
 	} else {
@@ -2449,7 +2449,7 @@
    # Render unto browsers that which are the browser's...
 
     if ($target eq 'web') {
-	if ($ENV{'browser.imagesuppress'} ne 'on') {
+	if ($env{'browser.imagesuppress'} ne 'on') {
 	    $currentstring.=&Apache::lonenc::encrypt_ref($token,{'src'=>$src});
 	} else {
 	    my $alttag= &Apache::lonxml::get_param
@@ -2655,7 +2655,7 @@
     
     my $currentstring = '';
     if ($target eq 'web') {
-	if ($ENV{'browser.appletsuppress'} ne 'on') {
+	if ($env{'browser.appletsuppress'} ne 'on') {
 	    $currentstring = &Apache::lonenc::encrypt_ref($token,
 							  {'code'=>$code,
 							   'archive'=>$archive}
@@ -2701,7 +2701,7 @@
     $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=$src;
     my $currentstring = '';
     if ($target eq 'web') {
-	if ($ENV{'browser.embedsuppress'} ne 'on') {
+	if ($env{'browser.embedsuppress'} ne 'on') {
 	    $currentstring=&Apache::lonenc::encrypt_ref($token,{'src'=>$src});
 	} else {
 	    my $alttag=&Apache::lonxml::get_param
@@ -2797,7 +2797,7 @@
     my $currentstring = '';
     if ($target eq 'web') { 
 	if (!$Apache::lonxml::registered &&
-	    $ENV{'request.state'} eq 'published') {
+	    $env{'request.state'} eq 'published') {
 	    $currentstring.='<head>'.
 		&Apache::lonmenu::registerurl(undef,$target).'</head>';
 	}
@@ -3797,7 +3797,7 @@
     if ($TeXwidth) { 
 	my $old_width_param=$width_param;
 	if ($TeXwidth=~/(\d+)\s*\%/) {
-	    $width_param = $1*$ENV{'form.textwidth'}/100;
+	    $width_param = $1*$env{'form.textwidth'}/100;
 	} else { 
 	    $width_param = $TeXwidth;
 	}
@@ -3818,9 +3818,9 @@
 	    $height_param=$width_param/$old_width_param*$height_param;
 	}
     }
-    if ($width_param > $ENV{'form.textwidth'}) {
+    if ($width_param > $env{'form.textwidth'}) {
         my $old_width_param=$width_param;
-	$width_param =0.95*$ENV{'form.textwidth'};
+	$width_param =0.95*$env{'form.textwidth'};
 	if ($old_width_param) {
 	    $height_param=$width_param/$old_width_param*$height_param;
 	}
@@ -3862,7 +3862,7 @@
 		#if replication failed try to produce eps file dynamically
 		$src=~s/\.ps$/\.eps/;
 		my $temp_file;
-		open(FILE,">>/home/httpd/prtspool/$ENV{'user.name'}_$ENV{'user.domain'}_printout.dat");
+		open(FILE,">>/home/httpd/prtspool/$env{'user.name'}_$env{'user.domain'}_printout.dat");
 		my $newsrc=$orig_src;
 		$newsrc =~ s|(.*)/res/|/home/httpd/html/res/|;
 		&Apache::lonxml::debug("queueing $newsrc for dynamic eps production. <BR/>");
@@ -3880,7 +3880,7 @@
 
 sub eps_generation {
     my ($src,$file,$width_param) = @_;	     
-    my $filename = "/home/httpd/prtspool/$ENV{'user.name'}_$ENV{'user.domain'}_printout.dat";
+    my $filename = "/home/httpd/prtspool/$env{'user.name'}_$env{'user.domain'}_printout.dat";
     my $temp_file = Apache::File->new('>>'.$filename); 
     print $temp_file "$src\n";
     my $newsrc = $src;
Index: loncom/xml/lonplot.pm
diff -u loncom/xml/lonplot.pm:1.105 loncom/xml/lonplot.pm:1.106
--- loncom/xml/lonplot.pm:1.105	Thu Feb 24 17:01:40 2005
+++ loncom/xml/lonplot.pm	Thu Apr  7 02:56:27 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Dynamic plot
 #
-# $Id: lonplot.pm,v 1.105 2005/02/24 22:01:40 matthew Exp $
+# $Id: lonplot.pm,v 1.106 2005/04/07 06:56:27 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -35,6 +35,7 @@
 use Apache::response;
 use Apache::lonxml;
 use Apache::edit;
+use Apache::lonnet;
 
 use vars qw/$weboutputformat $versionstring/;
 
@@ -513,7 +514,7 @@
 	##
 	## Determine filename
 	my $tmpdir = '/home/httpd/perl/tmp/';
-	my $filename = $ENV{'user.name'}.'_'.$ENV{'user.domain'}.
+	my $filename = $env{'user.name'}.'_'.$env{'user.domain'}.
 	    '_'.time.'_'.$$.$randnumber.'_plot';
 	## Write the plot description to the file
 	&write_gnuplot_file($tmpdir,$filename,$target);
Index: loncom/xml/lontex.pm
diff -u loncom/xml/lontex.pm:1.6 loncom/xml/lontex.pm:1.7
--- loncom/xml/lontex.pm:1.6	Thu Feb 17 04:01:04 2005
+++ loncom/xml/lontex.pm	Thu Apr  7 02:56:27 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # TeX Content Handler
 #
-# $Id: lontex.pm,v 1.6 2005/02/17 09:01:04 albertel Exp $
+# $Id: lontex.pm,v 1.7 2005/04/07 06:56:27 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -45,6 +45,7 @@
 use Apache::File;
 use Apache::lontexconvert;
 use Apache::Constants qw(:common);
+use Apache::lonnet;
 use tth;
 
 # ================================================================ Main Handler
@@ -56,7 +57,7 @@
 
 # ----------------------------------------------------------- Set document type
 
-  if ($ENV{'browser.mathml'}) {
+  if ($env{'browser.mathml'}) {
       &Apache::loncommon::content_type($r,'text/xml');
   } else {
       &Apache::loncommon::content_type($r,'text/html');
Index: loncom/xml/lontexconvert.pm
diff -u loncom/xml/lontexconvert.pm:1.64 loncom/xml/lontexconvert.pm:1.65
--- loncom/xml/lontexconvert.pm:1.64	Mon Feb 28 22:21:05 2005
+++ loncom/xml/lontexconvert.pm	Thu Apr  7 02:56:27 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # TeX Conversion Module
 #
-# $Id: lontexconvert.pm,v 1.64 2005/03/01 03:21:05 albertel Exp $
+# $Id: lontexconvert.pm,v 1.65 2005/04/07 06:56:27 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -47,21 +47,22 @@
 use Apache::lonxml();
 use Apache::lonmenu();
 use Apache::lonlocal;
+use Apache::lonnet;
 
 # ====================================================================== Header
 
 sub init_tth {
-    my $options=$ENV{'course.'.$ENV{'request.course.id'}.'.tthoptions'};
-    if ($ENV{'browser.mathml'}) {
+    my $options=$env{'course.'.$env{'request.course.id'}.'.tthoptions'};
+    if ($env{'browser.mathml'}) {
 	&tth::ttminit();
-	if ($ENV{'browser.unicode'}) {
+	if ($env{'browser.unicode'}) {
 	    &tth::ttmoptions('-L -u1 '.$options);
 	} else {
 	    &tth::ttmoptions('-L -u0 '.$options);
 	}
     } else {
 	&tth::tthinit();
-	if ($ENV{'browser.unicode'}) {
+	if ($env{'browser.unicode'}) {
 	    &tth::tthoptions('-L -u1 '.$options);
 	} else {
 	    &tth::tthoptions('-L -u0 '.$options);
@@ -99,7 +100,7 @@
 	die &mt("TeX unconverted due to errors");
     };
     &Apache::lonxml::start_alarm();
-    if ($ENV{'browser.mathml'}) {
+    if ($env{'browser.mathml'}) {
 	$xmlstring=&tth::ttm($$texstring);
 	$xmlstring=~s/\<math\>/\<math xmlns=\"\&mathns\;\"\>/g;
 	$xmlstring=~s/\<br\>/\<br\/\>/g;
@@ -184,11 +185,11 @@
 }
 
 sub converted {
-    if ($ENV{'environment.texengine'} eq 'tth') {
+    if ($env{'environment.texengine'} eq 'tth') {
 	return &tth_converted;
-    } elsif ($ENV{'environment.texengine'} eq 'jsMath') {
+    } elsif ($env{'environment.texengine'} eq 'jsMath') {
 	return &jsMath_converted;
-    } elsif ($ENV{'environment.texengine'} eq 'mimetex') {
+    } elsif ($env{'environment.texengine'} eq 'mimetex') {
 	return &mimetex_converted;
     }
     return &tth_converted;
@@ -198,10 +199,10 @@
 
 sub footer {
   my $xmlstring='';
-  if ($ENV{'request.state'} eq 'construct') {
+  if ($env{'request.state'} eq 'construct') {
       $xmlstring.='<address>'.$errorstring.'</address>';
   } else {
-      &Apache::lonmsg::author_res_msg($ENV{'request.filename'},$errorstring);
+      &Apache::lonmsg::author_res_msg($env{'request.filename'},$errorstring);
   }
 # -------------------------------------------------------------------- End Body
   $xmlstring.=&Apache::lonxml::xmlend();
@@ -220,7 +221,7 @@
 
 sub smiley {
     my $expression=shift;
-    if ($ENV{'browser.imagesuppress'} eq 'on') { return $expression; }
+    if ($env{'browser.imagesuppress'} eq 'on') { return $expression; }
     my %smileys=('\:\-\)' => 'smiley',
 		 '8\-\)'  => 'coolsmile',
 		 '8\-(I|\|)'   => 'coolindiff',
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.371 loncom/xml/lonxml.pm:1.372
--- loncom/xml/lonxml.pm:1.371	Wed Apr  6 20:42:07 2005
+++ loncom/xml/lonxml.pm	Thu Apr  7 02:56:27 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # XML Parser Module 
 #
-# $Id: lonxml.pm,v 1.371 2005/04/07 00:42:07 albertel Exp $
+# $Id: lonxml.pm,v 1.372 2005/04/07 06:56:27 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -81,7 +81,7 @@
 use Apache::edit();
 use Apache::inputtags();
 use Apache::outputtags();
-use Apache::lonnet();
+use Apache::lonnet;
 use Apache::File();
 use Apache::loncommon();
 use Apache::lonfeedback();
@@ -152,7 +152,7 @@
     my ($style)=@_;
     my $output='';
     @htmlareafields=();
-    if ($ENV{'browser.mathml'}) {
+    if ($env{'browser.mathml'}) {
 	$output='<?xml version="1.0"?>'
             #.'<?xml-stylesheet type="text/css" href="/adm/MathML/mathml.css"?>'."\n"
 #            .'<!DOCTYPE html SYSTEM "/adm/MathML/mathml.dtd" '
@@ -181,9 +181,9 @@
     }
     my $discussion;
     &Apache::loncommon::get_unprocessed_cgi
-        ($ENV{'query_string'},['LONCAPA_INTERNAL_no_discussion']);
-    if (! exists($ENV{'form.LONCAPA_INTERNAL_no_discussion'}) ||
-        $ENV{'form.LONCAPA_INTERNAL_no_discussion'} ne 'true') {
+        ($env{'query_string'},['LONCAPA_INTERNAL_no_discussion']);
+    if (! exists($env{'form.LONCAPA_INTERNAL_no_discussion'}) ||
+        $env{'form.LONCAPA_INTERNAL_no_discussion'} ne 'true') {
         $discussion=&Apache::lonfeedback::list_discussion($mode,$status);
     }
     if ($target eq 'tex') {
@@ -250,9 +250,9 @@
 	$symb=&Apache::lonnet::symbread();
     }
     unless ($tuname) {
-	$tuname=$ENV{'user.name'};
-        $tudom=$ENV{'user.domain'};
-        $tcrsid=$ENV{'request.course.id'};
+	$tuname=$env{'user.name'};
+        $tudom=$env{'user.domain'};
+        $tcrsid=$env{'request.course.id'};
     }
 
     return &Apache::lonnet::checkout($symb,$tuname,$tudom,$tcrsid);
@@ -288,7 +288,7 @@
                '<br />'.&mt('User').': '.$tuname.' at '.$tudom.
 	       '<br />'.&mt('ID').': '.$idhash{$tuname}.
 	       '<br />'.&mt('CourseID').': '.$tcrsid.
-	       '<br />'.&mt('Course').': '.$ENV{'course.'.$tcrsid.'.description'}.
+	       '<br />'.&mt('Course').': '.$env{'course.'.$tcrsid.'.description'}.
                '<br />'.&mt('DocID').': '.$token.
                '<br />'.&mt('Time').': '.&Apache::lonlocal::locallocaltime().'<hr />';
     } else {
@@ -298,10 +298,10 @@
 
 sub fontsettings {
     my $headerstring='';
-    if (($ENV{'browser.os'} eq 'mac') && (!$ENV{'browser.mathml'})) { 
+    if (($env{'browser.os'} eq 'mac') && (!$env{'browser.mathml'})) { 
 	$headerstring.=
 	    '<meta Content-Type="text/html; charset=x-mac-roman" />';
-    } elsif (!$ENV{'browser.mathml'} && $ENV{'browser.unicode'}) {
+    } elsif (!$env{'browser.mathml'} && $env{'browser.unicode'}) {
 	$headerstring.=
 	    '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
     }
@@ -330,9 +330,9 @@
 # do we have a course style file?
 #
 
- if ($ENV{'request.course.id'} && $ENV{'request.state'} ne 'construct') {
+ if ($env{'request.course.id'} && $env{'request.state'} ne 'construct') {
      my $bodytext=
-	 $ENV{'course.'.$ENV{'request.course.id'}.'.default_xml_style'};
+	 $env{'course.'.$env{'request.course.id'}.'.default_xml_style'};
      if ($bodytext) {
 	 foreach my $file (split(',',$bodytext)) {
 	     my $location=&Apache::lonnet::filelocation('',$file);
@@ -343,8 +343,8 @@
 	     }
 	 }
      }
- } elsif ($ENV{'construct.style'} && ($ENV{'request.state'} eq 'construct')) {
-     my $location=&Apache::lonnet::filelocation('',$ENV{'construct.style'});
+ } elsif ($env{'construct.style'} && ($env{'request.state'} eq 'construct')) {
+     my $location=&Apache::lonnet::filelocation('',$env{'construct.style'});
      my $styletext=&Apache::lonnet::getfile($location);
        if ($styletext ne '-1') {
           %style_for_target = (%style_for_target,
@@ -353,7 +353,7 @@
  }
 #&printalltags();
  my @pars = ();
- my $pwd=$ENV{'request.filename'};
+ my $pwd=$env{'request.filename'};
  $pwd =~ s:/[^/]*$::;
  &newparser(\@pars,\$content_file_string,$pwd);
 
@@ -371,12 +371,12 @@
  my $finaloutput = &inner_xmlparse($target,\@stack,\@parstack,\@pars,
 				   $safeeval,\%style_for_target);
 
- if ($ENV{'request.uri'}) {
-    &writeallows($ENV{'request.uri'});
+ if ($env{'request.uri'}) {
+    &writeallows($env{'request.uri'});
  }
  &do_registered_ssi();
  if ($Apache::lonxml::counter_changed) { &store_counter() }
- if ($ENV{'form.return_only_error_and_warning_counts'}) {
+ if ($env{'form.return_only_error_and_warning_counts'}) {
      return "$errorcount:$warningcount";
  }
  return $finaloutput;
@@ -945,8 +945,8 @@
 }
 
 sub init_counter {
-    if (defined($ENV{'form.counter'})) {
-	$Apache::lonxml::counter=$ENV{'form.counter'};
+    if (defined($env{'form.counter'})) {
+	$Apache::lonxml::counter=$env{'form.counter'};
 	$Apache::lonxml::counter_changed=0;
     } else {
 	$Apache::lonxml::counter=1;
@@ -1088,8 +1088,8 @@
 sub writeallows {
     unless ($#extlinks>=0) { return; }
     my $thisurl='/res/'.&Apache::lonnet::declutter(shift);
-    if ($ENV{'httpref.'.$thisurl}) {
-	$thisurl=$ENV{'httpref.'.$thisurl};
+    if ($env{'httpref.'.$thisurl}) {
+	$thisurl=$env{'httpref.'.$thisurl};
     }
     my $thisdir=$thisurl;
     $thisdir=~s/\/[^\/]+$//;
@@ -1122,24 +1122,24 @@
     my $result=shift;
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
 					    ['highlight','anchor','link']);
-    if ($ENV{'form.highlight'}) {
-       foreach (split(/\,/,$ENV{'form.highlight'})) {
+    if ($env{'form.highlight'}) {
+       foreach (split(/\,/,$env{'form.highlight'})) {
            my $anchorname=$_;
 	   my $matchthis=$anchorname;
            $matchthis=~s/\_+/\\s\+/g;
            $result=~s/(\Q$matchthis\E)/\<font color=\"red\"\>$1\<\/font\>/gs;
        }
     }
-    if ($ENV{'form.link'}) {
-       foreach (split(/\,/,$ENV{'form.link'})) {
+    if ($env{'form.link'}) {
+       foreach (split(/\,/,$env{'form.link'})) {
            my ($anchorname,$linkurl)=split(/\>/,$_);
 	   my $matchthis=$anchorname;
            $matchthis=~s/\_+/\\s\+/g;
            $result=~s/(\Q$matchthis\E)/\<a href=\"$linkurl\"\>$1\<\/a\>/gs;
        }
     }
-    if ($ENV{'form.anchor'}) {
-        my $anchorname=$ENV{'form.anchor'};
+    if ($env{'form.anchor'}) {
+        my $anchorname=$env{'form.anchor'};
 	my $matchthis=$anchorname;
         $matchthis=~s/\_+/\\s\+/g;
         $result=~s/(\Q$matchthis\E)/\<a name=\"$anchorname\"\>$1\<\/a\>/s;
@@ -1269,24 +1269,24 @@
 }
 
 sub get_target {
-  my $viewgrades=&Apache::lonnet::allowed('vgr',$ENV{'request.course.id'});
-  if ( $ENV{'request.state'} eq 'published') {
-    if ( defined($ENV{'form.grade_target'})
+  my $viewgrades=&Apache::lonnet::allowed('vgr',$env{'request.course.id'});
+  if ( $env{'request.state'} eq 'published') {
+    if ( defined($env{'form.grade_target'})
 	 && ($viewgrades == 'F' )) {
-      return ($ENV{'form.grade_target'});
-    } elsif (defined($ENV{'form.grade_target'})) {
-      if (($ENV{'form.grade_target'} eq 'web') ||
-	  ($ENV{'form.grade_target'} eq 'tex') ) {
-	return $ENV{'form.grade_target'}
+      return ($env{'form.grade_target'});
+    } elsif (defined($env{'form.grade_target'})) {
+      if (($env{'form.grade_target'} eq 'web') ||
+	  ($env{'form.grade_target'} eq 'tex') ) {
+	return $env{'form.grade_target'}
       } else {
 	return 'web';
       }
     } else {
       return 'web';
     }
-  } elsif ($ENV{'request.state'} eq 'construct') {
-    if ( defined($ENV{'form.grade_target'})) {
-      return ($ENV{'form.grade_target'});
+  } elsif ($env{'request.state'} eq 'construct') {
+    if ( defined($env{'form.grade_target'})) {
+      return ($env{'form.grade_target'});
     } else {
       return 'web';
     }
@@ -1300,11 +1300,11 @@
     
     my $target=&get_target();
     
-    $Apache::lonxml::debug=$ENV{'user.debug'};
+    $Apache::lonxml::debug=$env{'user.debug'};
     
     &Apache::loncommon::content_type($request,'text/html');
     &Apache::loncommon::no_cache($request);
-    if ($ENV{'request.state'} eq 'published') {
+    if ($env{'request.state'} eq 'published') {
 	$request->set_last_modified(&Apache::lonnet::metadata($request->uri,
 							      'lastrevisiondate'));
     }
@@ -1323,9 +1323,9 @@
 #
 # Edit action? Save file.
 #
-    unless ($ENV{'request.state'} eq 'published') {
-	if (($ENV{'form.savethisfile'}) || ($ENV{'form.attemptclean'})) {
-	    if (&storefile($file,$ENV{'form.filecont'})) {
+    unless ($env{'request.state'} eq 'published') {
+	if (($env{'form.savethisfile'}) || ($env{'form.attemptclean'})) {
+	    if (&storefile($file,$env{'form.filecont'})) {
 		&Apache::lonxml::info("<font COLOR=\"#0000FF\">".
 				      &mt('Updated').": ".
 				      &Apache::lonlocal::locallocaltime(time).
@@ -1350,21 +1350,21 @@
 </html>
 ENDNOTFOUND
         $filecontents='';
-	if ($ENV{'request.state'} ne 'published') {
+	if ($env{'request.state'} ne 'published') {
 	    if ($filetype eq 'sty') {
 		$filecontents=&createnewsty();
 	    } else {
 		$filecontents=&createnewhtml();
 	    }
-	    $ENV{'form.editmode'}='Edit'; #force edit mode
+	    $env{'form.editmode'}='Edit'; #force edit mode
 	}
     } else {
-	unless ($ENV{'request.state'} eq 'published') {
+	unless ($env{'request.state'} eq 'published') {
 	    if ($filecontents=~/BEGIN LON-CAPA Internal/) {
 		&Apache::lonxml::error(&mt('This file appears to be a rendering of a Lon-CAPA resource. If this is correct, this resource will act very oddly and incorrectly.'));
 	    }
 
-	    if ($ENV{'form.attemptclean'}) {
+	    if ($env{'form.attemptclean'}) {
 		$filecontents=&htmlclean($filecontents,1);
 	    }
 #
@@ -1372,7 +1372,7 @@
             &Apache::loncommon::get_unprocessed_cgi
                           ($ENV{'QUERY_STRING'},['editmode']);
 	}
-	if (!$ENV{'form.editmode'} || $ENV{'form.viewmode'}) {
+	if (!$env{'form.editmode'} || $env{'form.viewmode'}) {
 	    $result = &Apache::lonxml::xmlparse($request,$target,$filecontents,
 						'',%mystyle);
 	    undef($Apache::lonhomework::parsing_a_task);
@@ -1382,12 +1382,12 @@
 #
 # Edit action? Insert editing commands
 #
-    unless ($ENV{'request.state'} eq 'published') {
-	if ($ENV{'form.editmode'} && (!($ENV{'form.viewmode'}))) {
+    unless ($env{'request.state'} eq 'published') {
+	if ($env{'form.editmode'} && (!($env{'form.viewmode'}))) {
 	    my $displayfile=$request->uri;
 	    $displayfile=~s/^\/[^\/]*//;
 	    my $bodytag='<body bgcolor="#FFFFFF">';
-	    if ($ENV{'environment.remote'} eq 'off') {
+	    if ($env{'environment.remote'} eq 'off') {
 		$bodytag=&Apache::loncommon::bodytag();
 	    }
 	    $result='<html>'.$bodytag.
@@ -1408,10 +1408,10 @@
 
 sub display_title {
     my $result;
-    if ($ENV{'request.state'} eq 'construct') {
+    if ($env{'request.state'} eq 'construct') {
 	my $title=&Apache::lonnet::gettitle();
 	if (!defined($title) || $title eq '') {
-	    $title = $ENV{'request.filename'};
+	    $title = $env{'request.filename'};
 	    $title = substr($title, rindex($title, '/') + 1);
 	}
 	$result = "<script type='text/javascript'>top.document.title = '$title - LON-CAPA Construction Space';</script>";
@@ -1430,15 +1430,15 @@
 }
 
 sub show_error_warn_msg {
-    if ($ENV{'request.filename'} eq '/home/httpd/html/res/lib/templates/simpleproblem.problem' &&
-	&Apache::lonnet::allowed('mdc',$ENV{'request.course.id'})) {
+    if ($env{'request.filename'} eq '/home/httpd/html/res/lib/templates/simpleproblem.problem' &&
+	&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
 	return 1;
     }
     return (($Apache::lonxml::debug eq 1) ||
-	    ($ENV{'request.state'} eq 'construct') ||
+	    ($env{'request.state'} eq 'construct') ||
 	    ($Apache::lonhomework::browse eq 'F'
 	     &&
-	     $ENV{'form.show_errors'} eq 'on'));
+	     $env{'form.show_errors'} eq 'on'));
 }
 
 sub error {
@@ -1457,11 +1457,11 @@
 	    $errormsg=&mt("An error occured while processing this resource. The author has been notified.");
 	} 
 	#notify author
-	&Apache::lonmsg::author_res_msg($ENV{'request.filename'},join('<br />',@_));
+	&Apache::lonmsg::author_res_msg($env{'request.filename'},join('<br />',@_));
 	#notify course
-	if ( $symb && $ENV{'request.course.id'} ) {
+	if ( $symb && $env{'request.course.id'} ) {
 	    my (undef,%users)=&Apache::lonfeedback::decide_receiver(undef,0,1,1,1);
-	    my $declutter=&Apache::lonnet::declutter($ENV{'request.filename'});
+	    my $declutter=&Apache::lonnet::declutter($env{'request.filename'});
 	    my @userlist;
 	    foreach (keys %users) {
 		my ($user,$domain) = split(/:/, $_);
@@ -1469,7 +1469,7 @@
 		&Apache::lonmsg::user_normal_msg($user,$domain,
 						 "Error [$declutter]",join('<br />',@_));
 	    }
-	    if ($ENV{'request.role.adv'}) {
+	    if ($env{'request.role.adv'}) {
 		$errormsg=&mt("An error occured while processing this resource. The course personnel ([_1]) and the author have been notified.",join(', ',@userlist));
 	    } else {
 		$errormsg=&mt("An error occured while processing this resource. The instructor has been notified.");
@@ -1482,7 +1482,7 @@
 sub warning {
     $warningcount++;
   
-    if ($ENV{'form.grade_target'} ne 'tex') {
+    if ($env{'form.grade_target'} ne 'tex') {
 	if ( &show_error_warn_msg() ) {
 	    my $request=$Apache::lonxml::request;
 	    if (!$request) { $request=Apache->request; }
@@ -1495,8 +1495,8 @@
 }
 
 sub info {
-    if ($ENV{'form.grade_target'} ne 'tex' 
-	&& $ENV{'request.state'} eq 'construct') {
+    if ($env{'form.grade_target'} ne 'tex' 
+	&& $env{'request.state'} eq 'construct') {
 	push(@Apache::lonxml::info_messages,join('<br />',@_)."<br />\n");
     }
 }
@@ -1647,15 +1647,15 @@
 sub whichuser {
   my ($passedsymb)=@_;
   my ($symb,$courseid,$domain,$name,$publicuser);
-  if (defined($ENV{'form.grade_symb'})) {
+  if (defined($env{'form.grade_symb'})) {
       my ($tmp_courseid)=
 	  &Apache::loncommon::get_env_multiple('form.grade_courseid');
       my $allowed=&Apache::lonnet::allowed('vgr',$tmp_courseid);
       if (!$allowed && 
-	  exists($ENV{'request.course.sec'}) && 
-	  $ENV{'request.course.sec'} !~ /^\s*$/) {
+	  exists($env{'request.course.sec'}) && 
+	  $env{'request.course.sec'} !~ /^\s*$/) {
 	  $allowed=&Apache::lonnet::allowed('vgr',$tmp_courseid.
-					    '/'.$ENV{'request.course.sec'});
+					    '/'.$env{'request.course.sec'});
       }
       if ($allowed) {
 	  ($symb)=&Apache::loncommon::get_env_multiple('form.grade_symb');
@@ -1670,14 +1670,14 @@
   } else {
       $symb=$passedsymb;
   }
-  $courseid=$ENV{'request.course.id'};
-  $domain=$ENV{'user.domain'};
-  $name=$ENV{'user.name'};
+  $courseid=$env{'request.course.id'};
+  $domain=$env{'user.domain'};
+  $name=$env{'user.name'};
   if ($name eq 'public' && $domain eq 'public') {
-      if (!defined($ENV{'form.username'})) {
-	  $ENV{'form.username'}.=time.rand(10000000);
+      if (!defined($env{'form.username'})) {
+	  $env{'form.username'}.=time.rand(10000000);
       }
-      $name.=$ENV{'form.username'};
+      $name.=$env{'form.username'};
   }
   return ($symb,$courseid,$domain,$name,$publicuser);
 }
Index: loncom/xml/scripttag.pm
diff -u loncom/xml/scripttag.pm:1.125 loncom/xml/scripttag.pm:1.126
--- loncom/xml/scripttag.pm:1.125	Sun Feb 27 12:26:09 2005
+++ loncom/xml/scripttag.pm	Thu Apr  7 02:56:27 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # <script> definiton
 #
-# $Id: scripttag.pm,v 1.125 2005/02/27 17:26:09 albertel Exp $
+# $Id: scripttag.pm,v 1.126 2005/04/07 06:56:27 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -113,7 +113,7 @@
 	}
 	&Apache::run::run($bodytext,$safeeval);
 	if (($target eq 'answer') &&
-	    ($ENV{'form.answer_output_mode'} ne 'tex') &&
+	    ($env{'form.answer_output_mode'} ne 'tex') &&
 	    ($Apache::lonhomework::viewgrades == 'F')) {
 	    $Apache::lonxml::evaluate--;
 	    my (undef,undef,$udom,$uname)=&Apache::lonxml::whichuser();
@@ -442,7 +442,7 @@
   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
   my $result='';
   if ($target eq 'web' ) {
-    if ( $ENV{'request.course.id'} ) {
+    if ( $env{'request.course.id'} ) {
       my $inside = &Apache::lonxml::get_all_text("/standalone",$parser);
     } else {
       $result='<table bgcolor="#E1E1E1" border="2"><tr><td>';
@@ -455,7 +455,7 @@
   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
   my $result='';
   if ($target eq 'web' ) {
-    if ( $ENV{'request.course.id'} ) {
+    if ( $env{'request.course.id'} ) {
     } else {
       $result='</td></tr></table>';
     }
Index: rat/lonambiguous.pm
diff -u rat/lonambiguous.pm:1.15 rat/lonambiguous.pm:1.16
--- rat/lonambiguous.pm:1.15	Mon Feb 28 19:22:57 2005
+++ rat/lonambiguous.pm	Thu Apr  7 02:56:27 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to resolve ambiguous file locations
 #
-# $Id: lonambiguous.pm,v 1.15 2005/03/01 00:22:57 albertel Exp $
+# $Id: lonambiguous.pm,v 1.16 2005/04/07 06:56:27 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -82,11 +82,11 @@
 
 # ---------------------------------------------------------- Is this selecting?
  
-   if ($ENV{'form.selecturl'}) {
+   if ($env{'form.selecturl'}) {
        my $envkey;
-       if (tie(%bighash,'GDBM_File',$ENV{'request.course.fn'}.'.db',
+       if (tie(%bighash,'GDBM_File',$env{'request.course.fn'}.'.db',
                     &GDBM_READER(),0640)) {
-          foreach $envkey (keys %ENV) {
+          foreach $envkey (keys %env) {
              if ($envkey=~/^form\.(\d+)\.(\d+)$/) {
 # ---------------------------------------------------- Update symb and redirect
 	         my $mapid=$1;
@@ -110,7 +110,7 @@
 # ---------------------------------------------------------- Do we have a case?
 
    my $thisfn;
-   unless (($thisfn=$ENV{'request.ambiguous'})&&($ENV{'request.course.fn'})) {
+   unless (($thisfn=$env{'request.ambiguous'})&&($env{'request.course.fn'})) {
        &getlost($r,'Could not find information on resource.');
        return OK;
    }
@@ -121,7 +121,7 @@
     my %hash;
     my $syval='';
     
-    if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.'_symb.db',
+    if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.'_symb.db',
                   &GDBM_READER(),0640)) {
        $syval=$hash{$thisfn};
        untie(%hash);
@@ -145,14 +145,14 @@
        }
     }
 # ------------------------------------Encrypted requests go straight to navmaps
-   if ($ENV{'request.enc'}) {
+   if ($env{'request.enc'}) {
        &Apache::loncommon::content_type($r,'text/html');
        $r->header_out(Location => 'http://'.$ENV{'HTTP_HOST'}.'/adm/navmaps');
        return REDIRECT;
    }
 # ------------------------------------------------ Would be standalone resource
 
-   if (tie(%bighash,'GDBM_File',$ENV{'request.course.fn'}.'.db',
+   if (tie(%bighash,'GDBM_File',$env{'request.course.fn'}.'.db',
                     &GDBM_READER(),0640)) {
 # ---------------------------------------------- Get ID(s) for current resource
       my $ids=$bighash{'ids_'.&Apache::lonnet::clutter($thisfn)};
Index: rat/lonpage.pm
diff -u rat/lonpage.pm:1.69 rat/lonpage.pm:1.70
--- rat/lonpage.pm:1.69	Mon Feb 28 19:40:05 2005
+++ rat/lonpage.pm	Thu Apr  7 02:56:27 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Page Handler
 #
-# $Id: lonpage.pm,v 1.69 2005/03/01 00:40:05 albertel Exp $
+# $Id: lonpage.pm,v 1.70 2005/04/07 06:56:27 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -31,7 +31,7 @@
 
 use strict;
 use Apache::Constants qw(:common :http);
-use Apache::lonnet();
+use Apache::lonnet;
 use Apache::loncommon();
 use Apache::lonxml();
 use Apache::lonlocal;
@@ -63,7 +63,7 @@
     my ($sofar,$rid,$beenhere)=@_;
     my $further=$sofar;
     my $randomout=0;
-    unless ($ENV{'request.role.adv'}) {
+    unless ($env{'request.role.adv'}) {
         $randomout = $hash{'randomout_'.$rid};
     }
     unless ($beenhere=~/\&$rid\&/) {
@@ -138,7 +138,7 @@
 # ------------------------------------------- Set document type for header only
 
   if ($r->header_only) {
-       if ($ENV{'browser.mathml'}) {
+       if ($env{'browser.mathml'}) {
            &Apache::loncommon::content_type($r,'text/xml');
        } else {
            &Apache::loncommon::content_type($r,'text/html'); 
@@ -151,7 +151,7 @@
                                           ['forceselect','launch']);
   my $number_of_columns = 1;
   my $requrl=$r->uri;  
-  my $target = $ENV{'form.grade_target'};
+  my $target = $env{'form.grade_target'};
 #  &Apache::lonnet::logthis("Got a target of $target");
   if ($target eq 'meta') {
       &Apache::loncommon::content_type($r,'text/html');
@@ -159,8 +159,8 @@
       return OK;
   }
 # ----------------------------------------------------------------- Tie db file
-  if (($ENV{'request.course.fn'}) && (!$ENV{'form.forceselect'})) {
-      my $fn=$ENV{'request.course.fn'};
+  if (($env{'request.course.fn'}) && (!$env{'form.forceselect'})) {
+      my $fn=$env{'request.course.fn'};
       if (-e "$fn.db") {
           if (tie(%hash,'GDBM_File',"$fn.db",&GDBM_READER(),0640)) {
 # ------------------------------------------------------------------- Hash tied
@@ -236,20 +236,20 @@
 			      my $prefix=$_.'_';
                               my %posthash=('request.prefix' => $prefix,
 					    'symb' => $symb);
-			      if ($ENV{'form.grade_target'} eq 'tex') {
-				  $posthash{'grade_target'}=$ENV{'form.grade_target'};
-				  $posthash{'textwidth'}=$ENV{'form.textwidth'};
-				  $posthash{'problem_split'}=$ENV{'form.problem_split'};
-				  $posthash{'latex_type'}=$ENV{'form.latex_type'};
-				  $posthash{'rndseed'}=$ENV{'form.rndseed'};
+			      if ($env{'form.grade_target'} eq 'tex') {
+				  $posthash{'grade_target'}=$env{'form.grade_target'};
+				  $posthash{'textwidth'}=$env{'form.textwidth'};
+				  $posthash{'problem_split'}=$env{'form.problem_split'};
+				  $posthash{'latex_type'}=$env{'form.latex_type'};
+				  $posthash{'rndseed'}=$env{'form.rndseed'};
 			      }
-                              if (($ENV{'form.'.$prefix.'submit'}) 
-                               || ($ENV{'form.all_submit'})) {
-                               foreach (keys %ENV) {
+                              if (($env{'form.'.$prefix.'submit'}) 
+                               || ($env{'form.all_submit'})) {
+                               foreach (keys %env) {
 				  if ($_=~/^form.$prefix/) {
 				      my $name=$_;
                                       $name=~s/^form.$prefix//;
-                                      $posthash{$name}=$ENV{$_};
+                                      $posthash{$name}=$env{$_};
                                   }
                                }
 			      }
@@ -442,7 +442,7 @@
                                   '</img></a>';
                               if (
  ($hash{'src_'.$rid}=~/\.(problem|exam|quiz|assess|survey|form)$/) &&
- (&Apache::lonnet::allowed('mgr',$ENV{'request.course.id'})) && 
+ (&Apache::lonnet::allowed('mgr',$env{'request.course.id'})) && 
  ($hash{'src_'.$rid} !~ m-^/uploaded/-)) {
 				  my ($mapid,$resid)=split(/\./,$rid);
                                  my $symb=
@@ -496,8 +496,8 @@
 				  unless ($target eq 'tex') {
 				      $r->print('</font>');
                                   }
-                                  if ($ENV{'course.'.
-                                      $ENV{'request.course.id'}.
+                                  if ($env{'course.'.
+                                      $env{'request.course.id'}.
                                       '.pageseparators'} eq 'yes') {
                                       unless($target eq 'tex') {
                                           $r->print('<hr />');
Index: rat/lonpageflip.pm
diff -u rat/lonpageflip.pm:1.52 rat/lonpageflip.pm:1.53
--- rat/lonpageflip.pm:1.52	Mon Feb 28 19:22:57 2005
+++ rat/lonpageflip.pm	Thu Apr  7 02:56:27 2005
@@ -2,7 +2,7 @@
 #
 # Page flip handler
 #
-# $Id: lonpageflip.pm,v 1.52 2005/03/01 00:22:57 albertel Exp $
+# $Id: lonpageflip.pm,v 1.53 2005/04/07 06:56:27 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -31,7 +31,7 @@
 
 use strict;
 use Apache::Constants qw(:common :http REDIRECT);
-use Apache::lonnet();
+use Apache::lonnet;
 use HTML::TokeParser;
 use GDBM_File;
 
@@ -63,7 +63,7 @@
 
 sub fullmove {
     my ($rid,$mapurl,$direction)=@_;
-    if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.'.db',
+    if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.'.db',
                         &GDBM_READER(),0640)) {
 	($rid,$mapurl)=&move($rid,$mapurl,$direction);
         untie(%hash);
@@ -191,8 +191,8 @@
   my $next='';
   my @possibilities=();
    &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['postdata']);
-  if (($ENV{'form.postdata'})&&($ENV{'request.course.fn'})) {
-      $ENV{'form.postdata'}=~/(\w+)\:(.*)/;
+  if (($env{'form.postdata'})&&($env{'request.course.fn'})) {
+      $env{'form.postdata'}=~/(\w+)\:(.*)/;
       my $direction=$1;
       my $currenturl=$2;
       if ($currenturl=~m|^/enc/|) {
@@ -202,13 +202,13 @@
       if ($direction eq 'return') {
 # -------------------------------------------------------- Return to last known
          my $last;
-         if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.'_symb.db',
+         if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.'_symb.db',
                     &GDBM_READER(),0640)) {
 	     $last=$hash{'last_known'};
              untie(%hash);
          }
          my $newloc;
-         if (($last) && (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.'.db',
+         if (($last) && (tie(%hash,'GDBM_File',$env{'request.course.fn'}.'.db',
                         &GDBM_READER(),0640))) {
             my ($murl,$id,$fn)=&Apache::lonnet::decode_symb($last);
 	    $id=$hash{'map_pc_'.&Apache::lonnet::clutter($murl)}.'.'.$id;
@@ -236,7 +236,7 @@
 #
       unless (&Apache::lonnet::is_on_map($currenturl)) {
 	 my $last;
-         if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.'_symb.db',
+         if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.'_symb.db',
                     &GDBM_READER(),0640)) {
 	     $last=$hash{'last_known'};
              untie(%hash);
@@ -260,7 +260,7 @@
                              [&Apache::lonnet::declutter($currenturl),$mapnum];
 
 # ============================================================ Tie the big hash
-          if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.'.db',
+          if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.'.db',
                         &GDBM_READER(),0640)) {
               my $rid=$hash{'map_pc_'.&Apache::lonnet::clutter($startoutmap)}.
                       '.'.$mapnum;
@@ -272,7 +272,7 @@
               my $safecount=0;
               while (($next) && ($next!~/\,/) && 
                      ((!$hash{'src_'.$next}) || 
-		      ((!$ENV{'request.role.adv'}) && $hash{'randomout_'.$next}))
+		      ((!$env{'request.role.adv'}) && $hash{'randomout_'.$next}))
                      && ($safecount<10000)) {
                   ($next,$endupmap)=&move($next,$endupmap,$direction);
                   $safecount++;
@@ -329,10 +329,10 @@
                      &Apache::lonnet::linklog($redirecturl,$currenturl);
 		  }
 # ------------------------------------------------- Check for critical messages
-		  if ((time-$ENV{'user.criticalcheck.time'})>300) {
+		  if ((time-$env{'user.criticalcheck.time'})>300) {
                      my @what=&Apache::lonnet::dump
-                                  ('critical',$ENV{'user.domain'},
-                                              $ENV{'user.name'});
+                                  ('critical',$env{'user.domain'},
+                                              $env{'user.name'});
                      if ($what[0]) {
 	                if (($what[0] ne 'con_lost') && 
                             ($what[0]!~/^error\:/)) {
@@ -394,7 +394,7 @@
 	     }
 	  } else {
 # ------------------------------------------------- Problem, could not tie hash
-              $ENV{'user.error.msg'}="/adm/flip:bre:0:1:Course Data Missing";
+              $env{'user.error.msg'}="/adm/flip:bre:0:1:Course Data Missing";
               return HTTP_NOT_ACCEPTABLE; 
           }
       } else {
@@ -406,7 +406,7 @@
       }
   } else {
 # -------------------------- Class was not initialized or page fliped strangely
-      $ENV{'user.error.msg'}="/adm/flip:bre:0:0:Choose Course";
+      $env{'user.error.msg'}="/adm/flip:bre:0:0:Choose Course";
       return HTTP_NOT_ACCEPTABLE; 
   } 
 }
Index: rat/lonratedt.pm
diff -u rat/lonratedt.pm:1.64 rat/lonratedt.pm:1.65
--- rat/lonratedt.pm:1.64	Wed Mar 23 17:54:18 2005
+++ rat/lonratedt.pm	Thu Apr  7 02:56:27 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Edit Handler for RAT Maps
 #
-# $Id: lonratedt.pm,v 1.64 2005/03/23 22:54:18 raeburn Exp $
+# $Id: lonratedt.pm,v 1.65 2005/04/07 06:56:27 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -394,7 +394,7 @@
 sub ratedt {
   my ($r,$url)=@_;
   my $frameset = '<frameset rows="1,70,*" border="0">';
-  if ($ENV{'environment.remote'} eq 'off') {
+  if ($env{'environment.remote'} eq 'off') {
       $frameset = '<frameset rows="1,250,*" border="0">';
   }
   $r->print(<<ENDDOCUMENT);
@@ -537,7 +537,7 @@
         }
     }
     $output=~s/http\&colon\;\/\///g;
-    $ENV{'form.output'}=$output;
+    $env{'form.output'}=$output;
     return 
      &Apache::lonratsrv::loadmap($fn,&Apache::lonratsrv::savemap($fn,''));
 }
@@ -709,7 +709,7 @@
    my $buttons=&buttons(2);
    my $tmpfn=&Apache::lonnet::filelocation('',$url).'.tmp';
    my $targetmsg='';
-   if ($ENV{'form.save'}) {
+   if ($env{'form.save'}) {
        copy($tmpfn,&Apache::lonnet::filelocation('',$url));
        unlink($tmpfn);
        my ($errtext,$fatal)=
@@ -720,7 +720,7 @@
 	   $targetmsg='<b>'.&mt('An error occured while saving.').'</b><br />';
        }
    }
-   if ($ENV{'form.revert'}) {
+   if ($env{'form.revert'}) {
        $targetmsg='<b>'.&mt('Reverted.').'</b><br />';
        unlink($tmpfn);
        my ($errtext,$fatal)=
@@ -737,30 +737,30 @@
    my @targetselect=();
    undef @importselect;
    undef @targetselect;
-   if (defined($ENV{'form.importsel'})) {
-       if (ref($ENV{'form.importsel'})) {
-	   @importselect=sort(@{$ENV{'form.importsel'}});
+   if (defined($env{'form.importsel'})) {
+       if (ref($env{'form.importsel'})) {
+	   @importselect=sort(@{$env{'form.importsel'}});
        } else {
-           @importselect=($ENV{'form.importsel'});
+           @importselect=($env{'form.importsel'});
        }
    }
-   if (defined($ENV{'form.target'})) {
-       if (ref($ENV{'form.target'})) {
-	   @targetselect=sort(@{$ENV{'form.target'}});
+   if (defined($env{'form.target'})) {
+       if (ref($env{'form.target'})) {
+	   @targetselect=sort(@{$env{'form.target'}});
        } else {
-           @targetselect=($ENV{'form.target'});
+           @targetselect=($env{'form.target'});
        }
    }
 # ============================================================ Process commands
 
-   my $targetdetail=$ENV{'form.targetdetail'};
-   my $importdetail=$ENV{'form.curimpdetail'};
+   my $targetdetail=$env{'form.targetdetail'};
+   my $importdetail=$env{'form.curimpdetail'};
 
 # ---------------------------------------------------- Importing from groupsort
-   if (($ENV{'form.importdetail'}) && (!$ENV{'form.impfortarget'})) {
+   if (($env{'form.importdetail'}) && (!$env{'form.impfortarget'})) {
 
        $importdetail='';
-       my @curimport=split(/\&/,$ENV{'form.curimpdetail'});
+       my @curimport=split(/\&/,$env{'form.curimpdetail'});
 
        my $lastsel;
 
@@ -777,7 +777,7 @@
 	   }
        }
 
-      $importdetail.='&'.$ENV{'form.importdetail'};
+      $importdetail.='&'.$env{'form.importdetail'};
 
        for (my $i=$lastsel+1;$i<=$#curimport;$i++) {
            my ($name,$url)=split(/\=/,$curimport[$i]);
@@ -789,12 +789,12 @@
        $importdetail=~s/^\&//;
 
 # ------------------------------------------------------------------- Clear all
-   } elsif ($ENV{'form.clear'}) {
+   } elsif ($env{'form.clear'}) {
        $importdetail='';
 # ------------------------------------------------------------ Discard selected
-   } elsif ($ENV{'form.discard'}) {
+   } elsif ($env{'form.discard'}) {
        $importdetail='';
-       my @curimport=split(/\&/,$ENV{'form.curimpdetail'});
+       my @curimport=split(/\&/,$env{'form.curimpdetail'});
        foreach (@importselect) {
 	   $curimport[$_]='';
        }
@@ -805,9 +805,9 @@
 	   }
        }
 # --------------------------------------------------------- Loading another map
-   } elsif ($ENV{'form.loadmap'}) {
+   } elsif ($env{'form.loadmap'}) {
        $importdetail='';
-       my @curimport=split(/\&/,$ENV{'form.curimpdetail'});
+       my @curimport=split(/\&/,$env{'form.curimpdetail'});
 
        my $lastsel;
 
@@ -825,7 +825,7 @@
        }
 
        foreach (
-    &Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$ENV{'form.importmap'}))) {
+    &Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$env{'form.importmap'}))) {
 	   my ($name,$url)=split(/\:/,$_);
            if ($url) {
               $importdetail.='&'.&Apache::lonnet::escape($name).'='.
@@ -843,19 +843,19 @@
        $importdetail=~s/^\&//;
 
 # ------------------------------------------------ Groupimport/search to target
-   } elsif ($ENV{'form.importdetail'}) {
+   } elsif ($env{'form.importdetail'}) {
        my $lastsel;
        if (defined($targetselect[-1])) {
 	   $lastsel=$targetselect[-1];
        } else {
            $lastsel=$#order+1;
        }
-       &pastetarget($lastsel,split(/\&/,$ENV{'form.importdetail'}));
+       &pastetarget($lastsel,split(/\&/,$env{'form.importdetail'}));
        &storemap(&Apache::lonnet::filelocation('',$url));
 # ------------------------------------------------------------------------- Cut
-   } elsif (($ENV{'form.cut'}) || ($ENV{'form.copy'})) {
+   } elsif (($env{'form.cut'}) || ($env{'form.copy'})) {
        $importdetail='';
-       my @curimport=split(/\&/,$ENV{'form.curimpdetail'});
+       my @curimport=split(/\&/,$env{'form.curimpdetail'});
 
        my $lastsel;
 
@@ -889,7 +889,7 @@
        $importdetail=~s/\&+/\&/g;
        $importdetail=~s/^\&//;
 
-       if ($ENV{'form.cut'}) {
+       if ($env{'form.cut'}) {
            my @neworder=();
            for (my $i=0;$i<=$#order;$i++) {
                my $include=1;
@@ -903,7 +903,7 @@
        }
 
 # ----------------------------------------------------------------------- Paste
-   } elsif ($ENV{'form.paste'}) {
+   } elsif ($env{'form.paste'}) {
        my $lastsel;
        if (defined($targetselect[-1])) {
 	   $lastsel=$targetselect[-1];
@@ -911,14 +911,14 @@
            $lastsel=$#order+1;
        }
        my @newsequence;
-       my @curimport=split(/\&/,$ENV{'form.curimpdetail'});
+       my @curimport=split(/\&/,$env{'form.curimpdetail'});
        foreach (@importselect) {
           $newsequence[$#newsequence+1]=$curimport[$_];
        }
        &pastetarget($lastsel,@newsequence);
        &storemap(&Apache::lonnet::filelocation('',$url));
 # -------------------------------------------------------------------- Move up 
-   } elsif ($ENV{'form.moveup'}) {
+   } elsif ($env{'form.moveup'}) {
        foreach (sort @targetselect) {
            if ($_-1>0) {
               my $movethis=$order[$_-1];
@@ -928,7 +928,7 @@
        }
        &storemap(&Apache::lonnet::filelocation('',$url));
 # ------------------------------------------------------------------ Move down
-   } elsif ($ENV{'form.movedown'}) {
+   } elsif ($env{'form.movedown'}) {
        foreach (reverse sort @targetselect) {
            if ($_-1<$#order) {
               my $movethis=$order[$_-1];
@@ -938,10 +938,10 @@
        }
        &storemap(&Apache::lonnet::filelocation('',$url));
 # --------------------------------------------------------------------- Rename
-   } elsif ($ENV{'form.renameres'}) {
-       my $residx=$Apache::lonratedt::order[$ENV{'form.renameidx'}-1];
+   } elsif ($env{'form.renameres'}) {
+       my $residx=$Apache::lonratedt::order[$env{'form.renameidx'}-1];
        my ($name,@resrest)=split(/\:/,$Apache::lonratedt::resources[$residx]);
-       $name=$ENV{'form.renametitle'};
+       $name=$env{'form.renametitle'};
        $name=~s/\:/\&colon\;/g;
        $Apache::lonratedt::resources[$residx]=$name.':'.join(':',@resrest);
        &storemap(&Apache::lonnet::filelocation('',$url));
@@ -982,7 +982,7 @@
 # ----------------------------------------------------- Start simple RAT screen
    my $editscript=&editscript('simple');
    my $bodytag=&Apache::loncommon::bodytag(undef,undef,undef,
-					($ENV{'environment.remote'} ne 'off')).
+					($env{'environment.remote'} ne 'off')).
        &Apache::loncommon::help_open_menu('','Sequence_Simple_Editor_Creation','Sequence_Simple_Editor_Creation','',6,'RAT');
    my %lt=&Apache::lonlocal::texthash(
 				      'sa' => 'Save',
@@ -1206,7 +1206,7 @@
   $r->send_http_header;
 
   return OK if $r->header_only;
-  my $target = $ENV{'form.grade_target'};
+  my $target = $env{'form.grade_target'};
   if ($target eq 'meta') {
       &Apache::loncommon::content_type($r,'text/html');
       $r->send_http_header;
@@ -1225,8 +1225,8 @@
 # ------------------------------------------- Determine which tools can be used
   my $adv=0;
 
-  unless ($ENV{'form.forcesmp'}) {
-     if ($ENV{'form.forceadv'}) {
+  unless ($env{'form.forcesmp'}) {
+     if ($env{'form.forceadv'}) {
         $adv=1;
      } elsif (my $fh=Apache::File->new($fn)) {
 	 my $allmap=join('',<$fh>);
@@ -1244,9 +1244,9 @@
 
 # ----------------------------------- adv==1 now means "graphical MUST be used"
 
-  if ($ENV{'form.forceadv'}) {
+  if ($env{'form.forceadv'}) {
       &ratedt($r,$url);
-  } elsif ($ENV{'form.forcesmp'}) {
+  } elsif ($env{'form.forcesmp'}) {
       &smpedt($r,$url,$errtext);
   } else {
       &viewmap($r,$url,$adv,$errtext);
Index: rat/lonratmenu.pm
diff -u rat/lonratmenu.pm:1.1 rat/lonratmenu.pm:1.2
--- rat/lonratmenu.pm:1.1	Wed Nov 17 13:39:20 2004
+++ rat/lonratmenu.pm	Thu Apr  7 02:56:27 2005
@@ -41,7 +41,7 @@
     $r->print(<$jsh>);
     my $loaditem = 'onUnload="leave();"';
     my $bodytag=&Apache::loncommon::bodytag(undef,undef,$loaditem,
-                                        ($ENV{'environment.remote'} ne 'off')).
+                                        ($env{'environment.remote'} ne 'off')).
        &Apache::loncommon::help_open_menu('','Sequence_Advanced_Editor_Creation','Sequence_Advanced_Editor_Creation','',6,'RAT');
     $r->print($bodytag);
     $r->print(&print_html());
Index: rat/lonratparms.pm
diff -u rat/lonratparms.pm:1.22 rat/lonratparms.pm:1.23
--- rat/lonratparms.pm:1.22	Sat Apr 24 10:23:27 2004
+++ rat/lonratparms.pm	Thu Apr  7 02:56:27 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Set parameters inside of the RAT
 #
-# $Id: lonratparms.pm,v 1.22 2004/04/24 14:23:27 www Exp $
+# $Id: lonratparms.pm,v 1.23 2005/04/07 06:56:27 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -32,6 +32,7 @@
 use Apache::Constants qw(:common);
 use Apache::lonhtmlcommon();
 use Apache::lonlocal;
+use Apache::lonnet;
 
 sub handler {
     my $r = shift;
@@ -46,7 +47,7 @@
 
 # ------------------------------------------------------------------- Read file
 
-  my $uri=$ENV{'form.url'}.'.meta';
+  my $uri=$env{'form.url'}.'.meta';
   
   my %content;
   my %type;
@@ -63,7 +64,7 @@
       }
   }
 
-  foreach (split(/\:/,$ENV{'form.parms'})) {
+  foreach (split(/\:/,$env{'form.parms'})) {
       my ($ptype,$pname,$pvalue)=split(/\_\_\_/,$_);
       unless ($pname) { next; }
       unless ($type{$pname}) { $type{$pname}=$ptype; }
@@ -104,10 +105,10 @@
 
 function setparms() {
 ENDHEADER
-    $r->print('var colon=""; opener.objparms['.$ENV{'form.resid'}.']="";');
+    $r->print('var colon=""; opener.objparms['.$env{'form.resid'}.']="";');
     map {
        $r->print("\nif (document.parameters.def_".$_.
-       '.checked) { opener.objparms['.$ENV{'form.resid'}.
+       '.checked) { opener.objparms['.$env{'form.resid'}.
        ']+=colon+"'.$type{$_}.
        '___'.$_.'___"+document.parameters.'.$_.'.value; colon=":"; }'); 
     } keys %content;
Index: rat/lonratsrv.pm
diff -u rat/lonratsrv.pm:1.29 rat/lonratsrv.pm:1.30
--- rat/lonratsrv.pm:1.29	Thu Feb 17 04:09:57 2005
+++ rat/lonratsrv.pm	Thu Apr  7 02:56:27 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Server for RAT Maps
 #
-# $Id: lonratsrv.pm,v 1.29 2005/02/17 09:09:57 albertel Exp $
+# $Id: lonratsrv.pm,v 1.30 2005/04/07 06:56:27 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -32,7 +32,7 @@
 use Apache::Constants qw(:common);
 use Apache::File;
 use HTML::TokeParser;
-
+use Apache::lonnet;
 
 # ------------------------------------------------------------- From RAT to XML
 
@@ -205,7 +205,7 @@
         ($fn=~/\.page(\.tmp)*$/)) {
 
 # ------------------------------------------------------------- Deal with input
-        my @tags=split(/<&>/,$ENV{'form.output'});
+        my @tags=split(/<&>/,$env{'form.output'});
         my $outstr='';
         my $graphdef=0;
         if ($tags[0] eq 'graphdef<:>yes') {
@@ -288,7 +288,7 @@
         }
         $outstr.="</map>\n";
 	if ($fn=~/^\/*uploaded\/(\w+)\/(\w+)\/(.*)$/) {
-	    $ENV{'form.output'}=$outstr;
+	    $env{'form.output'}=$outstr;
             my $home=&Apache::lonnet::homeserver($2,$1);
             my $result=&Apache::lonnet::finishuserfileupload($2,$1,$home,
 						'output',$3);
Index: rat/lonsequence.pm
diff -u rat/lonsequence.pm:1.23 rat/lonsequence.pm:1.24
--- rat/lonsequence.pm:1.23	Mon Feb 28 19:22:57 2005
+++ rat/lonsequence.pm	Thu Apr  7 02:56:27 2005
@@ -2,7 +2,7 @@
 #
 # Sequence Handler
 #
-# $Id: lonsequence.pm,v 1.23 2005/03/01 00:22:57 albertel Exp $
+# $Id: lonsequence.pm,v 1.24 2005/04/07 06:56:27 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -71,7 +71,7 @@
 sub viewmap {
     my ($r,$url)=@_;
     $r->print('<html>');
-    if ($ENV{'form.forceselect'}) { $r->print(<<ENDSCRIPT);
+    if ($env{'form.forceselect'}) { $r->print(<<ENDSCRIPT);
 <script>
 
 function select_group() {
@@ -96,7 +96,7 @@
     }
     $r->print(&Apache::loncommon::bodytag('Map Contents').'<h1>'.$url.'</h1>');
 # ------------------ This is trying to select. Provide buttons and tie %selhash
-    if ($ENV{'form.forceselect'}) { $r->print(<<ENDSELECT);
+    if ($env{'form.forceselect'}) { $r->print(<<ENDSELECT);
 <form name=fileattr><input type=hidden name=acts value=''>
 <input type="button" name="close" value='CLOSE' onClick="self.close()">
 <input type="button" name="groupimport" value='GROUP IMPORT'
@@ -104,16 +104,16 @@
 </form>   
 ENDSELECT
     my $diropendb = 
-    "/home/httpd/perl/tmp/$ENV{'user.domain'}\_$ENV{'user.name'}_groupsec.db";
+    "/home/httpd/perl/tmp/$env{'user.domain'}\_$env{'user.name'}_groupsec.db";
         if (tie(%selhash,'GDBM_File',$diropendb,&GDBM_WRCREAT(),0640)) {
-	    if ($ENV{'form.launch'} eq '1') {
+	    if ($env{'form.launch'} eq '1') {
 	       &start_fresh_session();
 	    }
             $successtied=1;
 
 # - Evaluate actions from previous page (both cumulatively and chronologically)
-        if ($ENV{'form.catalogmode'} eq 'groupimport') {
-	    my $acts=$ENV{'form.acts'};
+        if ($env{'form.catalogmode'} eq 'groupimport') {
+	    my $acts=$env{'form.acts'};
 	    my @Acts=split(/b/,$acts);
 	    my %ahash;
 	    my %achash;
@@ -242,9 +242,9 @@
   my $exitdisid = '';
   my $arrow_dir = '';
 
-  if (($ENV{'request.course.fn'}) && (!$ENV{'form.forceselect'})) {
+  if (($env{'request.course.fn'}) && (!$env{'form.forceselect'})) {
        my $last;
-       if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.'_symb.db',
+       if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.'_symb.db',
                     &GDBM_READER(),0640)) {
 	   $last=$hash{'last_direction'};
            untie(%hash);
@@ -255,7 +255,7 @@
 	   ($prevmap,undef,$direction)=&Apache::lonnet::decode_symb($last);
        }
 # ------------------------------------------------------------- Tie big db file
-       if (tie(%bighash,'GDBM_File',$ENV{'request.course.fn'}.'.db',
+       if (tie(%bighash,'GDBM_File',$env{'request.course.fn'}.'.db',
                     &GDBM_READER(),0640)) {
 	   my $disid='';
            my $randomout ='';
@@ -269,7 +269,7 @@
 	       $disurl=$bighash{'src_'.$disid};
                $dismapid=(split(/\./,$disid))[1];
                $randomout = $bighash{'randomout_'.$disid};
-           } elsif (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.'_symb.db',
+           } elsif (tie(%hash,'GDBM_File',$env{'request.course.fn'}.'_symb.db',
                     &GDBM_READER(),0640)) {
                $last=$hash{'last_known'};
                untie(%hash);
Index: rat/lonuserstate.pm
diff -u rat/lonuserstate.pm:1.88 rat/lonuserstate.pm:1.89
--- rat/lonuserstate.pm:1.88	Fri Mar 18 16:55:49 2005
+++ rat/lonuserstate.pm	Thu Apr  7 02:56:27 2005
@@ -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.88 2005/03/18 21:55:49 raeburn Exp $
+# $Id: lonuserstate.pm,v 1.89 2005/04/07 06:56:27 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -33,7 +33,7 @@
 use strict;
 use Apache::Constants qw(:common :http);
 use HTML::TokeParser;
-use Apache::lonnet();
+use Apache::lonnet;
 use Apache::loncommon();
 use GDBM_File;
 use Apache::lonmsg;
@@ -624,11 +624,11 @@
 	    untie(%parmhash);
 	}
     }
-    &Apache::lonmsg::author_res_msg($ENV{'request.course.uri'},$errtext);
+    &Apache::lonmsg::author_res_msg($env{'request.course.uri'},$errtext);
 # ------------------------------------------------- Check for critical messages
 
-    my @what=&Apache::lonnet::dump('critical',$ENV{'user.domain'},
-				   $ENV{'user.name'});
+    my @what=&Apache::lonnet::dump('critical',$env{'user.domain'},
+				   $env{'user.name'});
     if ($what[0]) {
 	if (($what[0] ne 'con_lost') && ($what[0]!~/^error\:/)) {
 	    $retfurl='/adm/email?critical=display';
@@ -640,7 +640,7 @@
 # ------------------------------------------------------- Evaluate state string
 
 sub evalstate {
-    my $fn=$ENV{'request.course.fn'}.'.state';
+    my $fn=$env{'request.course.fn'}.'.state';
     my $state='';
     if (-e $fn) {
 	my @conditions=();
@@ -672,7 +672,7 @@
 	    }
 	}
     }
-    &Apache::lonnet::appenv('user.state.'.$ENV{'request.course.id'} => $state);
+    &Apache::lonnet::appenv('user.state.'.$env{'request.course.id'} => $state);
     return $state;
 }
 
Index: rat/lonwrapper.pm
diff -u rat/lonwrapper.pm:1.17 rat/lonwrapper.pm:1.18
--- rat/lonwrapper.pm:1.17	Thu Feb 17 04:09:57 2005
+++ rat/lonwrapper.pm	Thu Apr  7 02:56:27 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Wrapper for external and binary files as standalone resources
 #
-# $Id: lonwrapper.pm,v 1.17 2005/02/17 09:09:57 albertel Exp $
+# $Id: lonwrapper.pm,v 1.18 2005/04/07 06:56:27 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -30,7 +30,7 @@
 
 use strict;
 use Apache::Constants qw(:common);
-use Apache::lonnet();
+use Apache::lonnet;
 use Apache::lonxml();
 use Apache::lonmenu;
 
@@ -52,7 +52,7 @@
   $url=~s/^\/adm\/wrapper//;
   $url=~s/^\/ext\//http\:\/\//;
   $url=~s|&colon;|:|g;
-  if ($ENV{'form.wrapperdisplay'} eq 'menu') {
+  if ($env{'form.wrapperdisplay'} eq 'menu') {
 #
 # Producing the menu buttons
 #
@@ -66,7 +66,7 @@
 #
 # This is uploaded homework
 #
-          $ENV{'request.state'}='uploaded';
+          $env{'request.state'}='uploaded';
           &Apache::lonhomework::renderpage($r,$url);
       } else {
 #
@@ -78,7 +78,7 @@
 	      '" onUnload="'.&Apache::lonmenu::unloadevents.'"';
 	  my $script=&Apache::lonmenu::registerurl(1,undef);
 
-	  if ($ENV{'browser.interface'} eq 'textual') {
+	  if ($env{'browser.interface'} eq 'textual') {
 #
 # ssi-based rendering for text-based interface
 #
@@ -87,7 +87,7 @@
 			'</head><body bgcolor="#FFFFFF">'.
 			&Apache::lonmenu::menubuttons(1).
 			&Apache::lonnet::ssi_body($url).'</body></html>');
-	  } elsif ($ENV{'environment.remote'} eq 'off') {
+	  } elsif ($env{'environment.remote'} eq 'off') {
 #
 # This is inline remote
 # 

--albertel1112856992--