[LON-CAPA-cvs] cvs: loncom /interface londropadd.pm

matthew lon-capa-cvs@mail.lon-capa.org
Tue, 16 Apr 2002 19:08:49 -0000


This is a MIME encoded message

--matthew1018984129
Content-Type: text/plain

matthew		Tue Apr 16 15:08:49 2002 EDT

  Modified files:              
    /loncom/interface	londropadd.pm 
  Log:
  Reindentation in preparation for larger changes.
  
  
--matthew1018984129
Content-Type: text/plain
Content-Disposition: attachment; filename="matthew-20020416150849.txt"

Index: loncom/interface/londropadd.pm
diff -u loncom/interface/londropadd.pm:1.24 loncom/interface/londropadd.pm:1.25
--- loncom/interface/londropadd.pm:1.24	Mon Apr 15 19:37:37 2002
+++ loncom/interface/londropadd.pm	Tue Apr 16 15:08:49 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to drop and add students in courses 
 #
-# $Id: londropadd.pm,v 1.24 2002/04/15 23:37:37 albertel Exp $
+# $Id: londropadd.pm,v 1.25 2002/04/16 19:08:49 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -77,34 +77,35 @@
 # =========== Drop student from all sections of a course, except optional $csec
 
 sub dropstudent {
-     my ($udom,$unam,$courseid,$csec)=@_;
-     $courseid=~s/\_/\//g;
-     $courseid=~s/^(\w)/\/$1/;
-     foreach (split(/\&/,
-		    &Apache::lonnet::reply('dump:'.$udom.':'.$unam.':roles',
+    my ($udom,$unam,$courseid,$csec)=@_;
+    $courseid=~s/\_/\//g;
+    $courseid=~s/^(\w)/\/$1/;
+    foreach (split(/\&/,
+                   &Apache::lonnet::reply('dump:'.$udom.':'.$unam.':roles',
 			     &Apache::lonnet::homeserver($unam,$udom)))) {
         my ($key,$value)=split(/\=/,$_);
         $key=&Apache::lonnet::unescape($key);
         if ($key=~/^$courseid(?:\/)*(\w+)*\_st$/) {
-          my $section=$1;
-          if ($key eq $courseid.'_st') { $section=''; }
-          if (((!$section) && (!$csec)) || ($section ne $csec)) {
-	    my ($dummy,$end,$start)=split(/\_/,
-                                    &Apache::lonnet::unescape($value));
-            my $now=time;
-            my $notactive=0;
-            if ($start) {
-		if ($now<$start) { $notactive=1; }
-            }
-            if ($end) {
-                if ($now>$end) { $notactive=1; }
-            } 
-            unless ($notactive) {
-                my $reply=&Apache::lonnet::modifystudent(
-                                   $udom,$unam,'','','',
-			           '','','','',$section,time);
+            my $section=$1;
+            if ($key eq $courseid.'_st') { $section=''; }
+            if (((!$section) && (!$csec)) || ($section ne $csec)) {
+                my ($dummy,$end,$start)=split(/\_/,
+                                              &Apache::lonnet::unescape
+                                              ($value));
+                my $now=time;
+                my $notactive=0;
+                if ($start) {
+                    if ($now<$start) { $notactive=1; }
+                }
+                if ($end) {
+                    if ($now>$end) { $notactive=1; }
+                } 
+                unless ($notactive) {
+                    my $reply=&Apache::lonnet::modifystudent
+                        ($udom,$unam,'','','',
+                         '','','','',$section,time);
+                }
             }
-	  }
         }
     }
 }
@@ -468,29 +469,23 @@
 
 sub menu_phase_two_upload {
     my $r=shift;
-
     my $datatoken;
     if (!$ENV{'form.datatoken'}) {
-      $datatoken=&Apache::loncommon::upfile_store($r);
+        $datatoken=&Apache::loncommon::upfile_store($r);
     } else {
-      $datatoken=$ENV{'form.datatoken'};
-      &Apache::loncommon::load_tmp_file($r);
+        $datatoken=$ENV{'form.datatoken'};
+        &Apache::loncommon::load_tmp_file($r);
     }
     my @records=&Apache::loncommon::upfile_record_sep();
     my $total=$#records;
     my $distotal=$total+1;
-
     $ENV{'SERVER_NAME'}=~/(\w+\.\w+)$/;
     my $krbdefdom=$1;
     $krbdefdom=~tr/a-z/A-Z/;
-
     my $today=time;
     my $halfyear=$today+15552000;
-
     my $defdom=$r->dir_config('lonDefDomain');
-
     &phase_two_header($r,$datatoken,$distotal,$krbdefdom);
-
     my $i;
     my $keyfields;
     if ($total>=0) {
@@ -511,8 +506,6 @@
 	    $keyfields=join(',',sort(keys(%sone)));
 	}
     }
-
-
     &phase_two_end($r,$i,$keyfields,$defdom,$today,$halfyear);
 }
 
@@ -526,46 +519,43 @@
 	my $amode='';
         my $genpwd='';
         if ($ENV{'form.login'} eq 'krb') {
-           $amode='krb4';
-           $genpwd=$ENV{'form.krbdom'};
+            $amode='krb4';
+            $genpwd=$ENV{'form.krbdom'};
         } elsif ($ENV{'form.login'} eq 'int') {
-           $amode='internal';
-           $genpwd=$ENV{'form.intpwd'};
+            $amode='internal';
+            $genpwd=$ENV{'form.intpwd'};
         }  elsif ($ENV{'form.login'} eq 'loc') {
 	    $amode='localauth';
 	    $genpwd=$ENV{'form.locarg'};
 	    if (!$genpwd) { $genpwd=" "; }
 	}
         if (($amode) && ($genpwd)) {
- 	  &dropstudent($ENV{'form.cdomain'},$ENV{'form.cuname'},
-		       $ENV{'request.course.id'},$ENV{'form.csec'});
-          $r->print(&Apache::lonnet::modifystudent(
-                      $ENV{'form.cdomain'},$ENV{'form.cuname'},
-                      $ENV{'form.cstid'},$amode,$genpwd,
- 	              $ENV{'form.cfirst'},$ENV{'form.cmiddle'},
-                      $ENV{'form.clast'},$ENV{'form.cgen'},
-                      $ENV{'form.csec'},$ENV{'form.enddate'},
-                      $ENV{'form.startdate'},$ENV{'form.forceid'}));
+            &dropstudent($ENV{'form.cdomain'},$ENV{'form.cuname'},
+                         $ENV{'request.course.id'},$ENV{'form.csec'});
+            $r->print(&Apache::lonnet::modifystudent
+                      ($ENV{'form.cdomain'},$ENV{'form.cuname'},
+                       $ENV{'form.cstid'},$amode,$genpwd,
+                       $ENV{'form.cfirst'},$ENV{'form.cmiddle'},
+                       $ENV{'form.clast'},$ENV{'form.cgen'},
+                       $ENV{'form.csec'},$ENV{'form.enddate'},
+                       $ENV{'form.startdate'},$ENV{'form.forceid'}));
 	} else {
-           $r->print('Invalid login mode or password');    
+            $r->print('Invalid login mode or password');    
         }          
     } else {
         $r->print('Invalid username or domain');
-    }    
+    }
 }
 
 # ======================================================= Menu Phase Two Enroll
 
 sub menu_phase_two_enroll {
     my $r=shift;
-    
     $ENV{'SERVER_NAME'}=~/(\w+\.\w+)$/;
     my $krbdefdom=$1;
     $krbdefdom=~tr/a-z/A-Z/;
-
     my $today=time;
     my $halfyear=$today+15552000;
-
     my $defdom=$r->dir_config('lonDefDomain');
     my $javascript_validations=&javascript_validations($krbdefdom);
     $r->print(<<ENDSENROLL);
@@ -658,30 +648,29 @@
 sub menu_phase_two_drop {
     my $r=shift;
     my $cid=$ENV{'request.course.id'};
-                 my $classlst=&Apache::lonnet::reply
-                 ('dump:'.$ENV{'course.'.$cid.'.domain'}.':'.
-	                  $ENV{'course.'.$cid.'.num'}.':classlist',
-	                  $ENV{'course.'.$cid.'.home'});
-                 my %currentlist=();
-                 my $now=time;
-                 unless ($classlst=~/^error\:/) {
-                     foreach (split(/\&/,$classlst)) {
-                        my ($name,$value)=split(/\=/,$_);
-                        my ($end,$start)=split(/\:/,
-                                            &Apache::lonnet::unescape($value));
-                        my $active=1;
-                        if (($end) && ($now>$end)) { $active=0; }
-                        if ($active) {
-		           $currentlist{&Apache::lonnet::unescape($name)}=1;
-                        }
-                     }
+    my $classlst=&Apache::lonnet::reply
+        ('dump:'.$ENV{'course.'.$cid.'.domain'}.':'.
+         $ENV{'course.'.$cid.'.num'}.':classlist',
+         $ENV{'course.'.$cid.'.home'});
+    my %currentlist=();
+    my $now=time;
+    unless ($classlst=~/^error\:/) {
+        foreach (split(/\&/,$classlst)) {
+            my ($name,$value)=split(/\=/,$_);
+            my ($end,$start)=split(/\:/,
+                                   &Apache::lonnet::unescape($value));
+            my $active=1;
+            if (($end) && ($now>$end)) { $active=0; }
+            if ($active) {
+                $currentlist{&Apache::lonnet::unescape($name)}=1;
+            }
+        }
 # ----------------------------------------------------------- Print out choices
-                     &show_drop_list($r,%currentlist);
-	         } else {
-                     $r->print(
-                  '<font color=red><h3>Could not access classlist: '.$classlst.
+        &show_drop_list($r,%currentlist);
+    } else {
+        $r->print('<font color=red><h3>Could not access classlist: '.$classlst.
                   '</h3></font>');
-                 }
+    }
 }
 
 # =================================================== Show student list to drop
@@ -691,137 +680,133 @@
     my $cid=$ENV{'request.course.id'};
 
     $r->print('<input type=hidden name=phase value=four>');
-                     $r->print('<table border=2>');
-                     foreach (sort keys %currentlist) {
-                         my ($sname,$sdom)=split(/\:/,$_);
-                         my %reply=&Apache::lonnet::idrget($sdom,$sname);
-                         my $ssec=&Apache::lonnet::usection($sdom,$sname,$cid);
-                         my @reply=split(/[\&\=]/,&Apache::lonnet::reply(
-                           'get:'.$sdom.':'.$sname.
-		      ':environment:firstname&middlename&lastname&generation',
-                           &Apache::lonnet::homeserver($sname,$sdom)));
- 			 $r->print(
-                  '<tr><td><input type=checkbox name="drop:'.$_.'"></td><td>'.
-                                   $sname.'</td><td>'.$sdom.'</td><td>'.
-                                   $reply{$sname}.'</td><td>'.
-                                   &Apache::lonnet::unescape($reply[2]).' '.
-                                   &Apache::lonnet::unescape($reply[3]).', '.
-                                   &Apache::lonnet::unescape($reply[0]).' '.
-                                   &Apache::lonnet::unescape($reply[1]).
-                                   '</td><td>'.
-                                   $ssec."</td></tr>\n");
-                     }
-                     $r->print('</table><br>');
-                     $r->print('<input type=submit value="Drop Students">');
+    $r->print('<table border=2>');
+    foreach (sort keys %currentlist) {
+        my ($sname,$sdom)=split(/\:/,$_);
+        my %reply=&Apache::lonnet::idrget($sdom,$sname);
+        my $ssec=&Apache::lonnet::usection($sdom,$sname,$cid);
+        my @reply=split(/[\&\=]/,&Apache::lonnet::reply
+                        ('get:'.$sdom.':'.$sname.
+                         ':environment:firstname&middlename&lastname&generation',
+                         &Apache::lonnet::homeserver($sname,$sdom)));
+        $r->print('<tr><td><input type=checkbox name="drop:'.$_.'"></td><td>'.
+                  $sname.'</td><td>'.$sdom.'</td><td>'.
+                  $reply{$sname}.'</td><td>'.
+                  &Apache::lonnet::unescape($reply[2]).' '.
+                  &Apache::lonnet::unescape($reply[3]).', '.
+                  &Apache::lonnet::unescape($reply[0]).' '.
+                  &Apache::lonnet::unescape($reply[1]).
+                  '</td><td>'.
+                  $ssec."</td></tr>\n");
+    }
+    $r->print('</table><br>');
+    $r->print('<input type=submit value="Drop Students">');
 }
 
 # ================================================= Drop/Add from uploaded file
 
 sub upfile_drop_add {
     my $r=shift;
-
     &Apache::loncommon::load_tmp_file($r);
     my @studentdata=&Apache::loncommon::upfile_record_sep();
-
     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};
-		     }
-		 } else {
-		     $fields{$ENV{'form.f'.$i}}=$keyfields[$i];
-		 }
-             }
-             my $startdate=$ENV{'form.startdate'};
-             my $enddate=$ENV{'form.enddate'};
-             if ($startdate=~/\D/) { $startdate=''; }
-             if ($enddate=~/\D/) { $enddate=''; }
-             my $domain=$ENV{'form.lcdomain'};
-             my $amode='';
-             my $genpwd='';
-             if ($ENV{'form.login'} eq 'krb') {
-                 $amode='krb4';
-                 $genpwd=$ENV{'form.krbdom'};
-             } elsif ($ENV{'form.login'} eq 'int') {
-                 $amode='internal';
-                 if ((defined($ENV{'form.intpwd'})) && ($ENV{'form.intpwd'})) {
-		     $genpwd=$ENV{'form.intpwd'};
-                 }
-             } elsif ($ENV{'form.login'} eq 'loc') {
-		 $amode='localauth';
-		 if ((defined($ENV{'form.locarg'})) && ($ENV{'form.locarg'})) {
-		     $genpwd=$ENV{'form.locarg'};
-                 }
-	     }
-             unless (($domain=~/\W/) || ($amode eq '')) {
-              $r->print('<h3>Enrolling Students</h3>');
-              my $count=0;
-              my $flushc=0;
-              my %student=();
+    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};
+            }
+        } else {
+            $fields{$ENV{'form.f'.$i}}=$keyfields[$i];
+        }
+    }
+    my $startdate=$ENV{'form.startdate'};
+    my $enddate=$ENV{'form.enddate'};
+    if ($startdate=~/\D/) { $startdate=''; }
+    if ($enddate=~/\D/) { $enddate=''; }
+    my $domain=$ENV{'form.lcdomain'};
+    my $amode='';
+    my $genpwd='';
+    if ($ENV{'form.login'} eq 'krb') {
+        $amode='krb4';
+        $genpwd=$ENV{'form.krbdom'};
+    } elsif ($ENV{'form.login'} eq 'int') {
+        $amode='internal';
+        if ((defined($ENV{'form.intpwd'})) && ($ENV{'form.intpwd'})) {
+            $genpwd=$ENV{'form.intpwd'};
+        }
+    } elsif ($ENV{'form.login'} eq 'loc') {
+        $amode='localauth';
+        if ((defined($ENV{'form.locarg'})) && ($ENV{'form.locarg'})) {
+            $genpwd=$ENV{'form.locarg'};
+        }
+    }
+    unless (($domain=~/\W/) || ($amode eq '')) {
+        $r->print('<h3>Enrolling Students</h3>');
+        my $count=0;
+        my $flushc=0;
+        my %student=();
 # ----------------------------------------------------------- Get new classlist
 # --------------------------------------------------------- Enroll new students
-	      foreach (@studentdata) {
-		  my %entries=&Apache::loncommon::record_sep($_);
-
-                unless (($entries{$fields{'username'}} eq '') ||
-                        (!defined($entries{$fields{'username'}}))) {
-                  my $fname=''; my $mname=''; my $lname=''; my $gen='';
-                  if (defined($fields{'names'})) {
-		      ($lname,$fname,$mname)=
-	            ($entries{$fields{'names'}}=~/([^\,]+)\,\s*(\w+)\s*(.*)$/);
-                  } else {
-                      if (defined($fields{'fname'})) {
-		         $fname=$entries{$fields{'fname'}};
-		      }
-                      if (defined($fields{'mname'})) {
-		         $mname=$entries{$fields{'mname'}};
-		      }
-                      if (defined($fields{'lname'})) {
-		         $lname=$entries{$fields{'lname'}};
-		      }
-                      if (defined($fields{'gen'})) {
-		         $gen=$entries{$fields{'gen'}};
-		      }
-                  }
-                  if ($entries{$fields{'username'}}=~/\W/) {
-                     $r->print('<p><b>Unacceptable username: '.
+        foreach (@studentdata) {
+            my %entries=&Apache::loncommon::record_sep($_);
+            unless (($entries{$fields{'username'}} eq '') ||
+                    (!defined($entries{$fields{'username'}}))) {
+                my $fname=''; my $mname=''; my $lname=''; my $gen='';
+                if (defined($fields{'names'})) {
+                    ($lname,$fname,$mname)=
+                        ($entries{$fields{'names'}}=~/([^\,]+)\,\s*(\w+)\s*(.*)$/);
+                } else {
+                    if (defined($fields{'fname'})) {
+                        $fname=$entries{$fields{'fname'}};
+                    }
+                    if (defined($fields{'mname'})) {
+                        $mname=$entries{$fields{'mname'}};
+                    }
+                    if (defined($fields{'lname'})) {
+                        $lname=$entries{$fields{'lname'}};
+                    }
+                    if (defined($fields{'gen'})) {
+                        $gen=$entries{$fields{'gen'}};
+                    }
+                }
+                if ($entries{$fields{'username'}}=~/\W/) {
+                    $r->print('<p><b>Unacceptable username: '.
                               $entries{$fields{'username'}}.' for user '.
                               $fname.' '.$mname.' '.$lname.' '.$gen.'</b><p>');
-		  } else {
-                      my $sec='';
-                      my $username=$entries{$fields{'username'}};
-                      if (defined($fields{'sec'})) {
-                         if (defined($entries{$fields{'sec'}})) {
-			     $sec=$entries{$fields{'sec'}};
-                         }
-                      }
-                      my $id='';
-                      if (defined($fields{'id'})) {
-                         if (defined($entries{$fields{'id'}})) {
-			     $id=$entries{$fields{'id'}};
-                         }
-                         $id=~tr/A-Z/a-z/;
-                      }
-                      my $password='';
-                      if ($genpwd) { 
-                         $password=$genpwd; 
-		      } else {
-                         if (defined($fields{'ipwd'})) {
-			     if ($entries{$fields{'ipwd'}}) {
-				 $password=$entries{$fields{'ipwd'}};
-                             }
-                         }
-                      }
-                      if ($password) {
-			 &dropstudent($domain,$username,$cid,$sec);
-                         my $reply=&Apache::lonnet::modifystudent(
-                          $domain,$username,$id,$amode,$password,
-			   $fname,$mname,$lname,$gen,$sec,$enddate,$startdate,
-                           $ENV{'form.forceid'});
-                         unless ($reply eq 'ok') {
+                } else {
+                    my $sec='';
+                    my $username=$entries{$fields{'username'}};
+                    if (defined($fields{'sec'})) {
+                        if (defined($entries{$fields{'sec'}})) {
+                            $sec=$entries{$fields{'sec'}};
+                        }
+                    }
+                    my $id='';
+                    if (defined($fields{'id'})) {
+                        if (defined($entries{$fields{'id'}})) {
+                            $id=$entries{$fields{'id'}};
+                        }
+                        $id=~tr/A-Z/a-z/;
+                    }
+                    my $password='';
+                    if ($genpwd) { 
+                        $password=$genpwd; 
+                    } else {
+                        if (defined($fields{'ipwd'})) {
+                            if ($entries{$fields{'ipwd'}}) {
+                                $password=$entries{$fields{'ipwd'}};
+                            }
+                        }
+                    }
+                    if ($password) {
+                        &dropstudent($domain,$username,$cid,$sec);
+                        my $reply=&Apache::lonnet::modifystudent
+                            ($domain,$username,$id,$amode,$password,
+                             $fname,$mname,$lname,$gen,$sec,$enddate,
+                             $startdate,$ENV{'form.forceid'});
+                        unless ($reply eq 'ok') {
                             $r->print(
                              "<p><b>Error enrolling $username: $reply</b><p>");
          		} else {
@@ -833,56 +818,53 @@
                                 $flushc=0;
                             }
                         }
-                     } else {
-                            $r->print(
-                             "<p><b>No password for $username</b><p>");
-                     }
-                  }
-                 }                 
-              }
-              $r->print('<p>Processed Students: '.$count);
+                    } else {
+                        $r->print("<p><b>No password for $username</b><p>");
+                    }
+                }
+            }                 
+        }
+        $r->print('<p>Processed Students: '.$count);
 # --------------------------------------------------------------- Drop students
-              if ($ENV{'form.fullup'} eq 'yes') {
-		 $r->print('<h3>Dropping Students</h3>');
+        if ($ENV{'form.fullup'} eq 'yes') {
+            $r->print('<h3>Dropping Students</h3>');
 # ------------------------------------------------------- Get current classlist
-                 my $classlst=&Apache::lonnet::reply
-                 ('dump:'.$ENV{'course.'.$cid.'.domain'}.':'.
-	                  $ENV{'course.'.$cid.'.num'}.':classlist',
-	                  $ENV{'course.'.$cid.'.home'});
-                 my %currentlist=();
-                 my $now=time;
-                 unless ($classlst=~/^error\:/) {
-                     foreach (split(/\&/,$classlst)) {
-                        my ($name,$value)=split(/\=/,$_);
-                        my ($end,$start)=split(/\:/,
-                                            &Apache::lonnet::unescape($value));
-                        my $active=1;
-                        if (($end) && ($now>$end)) { $active=0; }
-                        if ($active) {
-		           $currentlist{&Apache::lonnet::unescape($name)}=1;
-                        }
-                     }
+            my $classlst=&Apache::lonnet::reply
+                ('dump:'.$ENV{'course.'.$cid.'.domain'}.':'.
+                         $ENV{'course.'.$cid.'.num'}.':classlist',
+                         $ENV{'course.'.$cid.'.home'});
+            my %currentlist=();
+            my $now=time;
+            unless ($classlst=~/^error\:/) {
+                foreach (split(/\&/,$classlst)) {
+                    my ($name,$value)=split(/\=/,$_);
+                    my ($end,$start)=split(/\:/,
+                                           &Apache::lonnet::unescape($value));
+                    my $active=1;
+                    if (($end) && ($now>$end)) { $active=0; }
+                    if ($active) {
+                        $currentlist{&Apache::lonnet::unescape($name)}=1;
+                    }
+                }
 # ------------------------------------------------ Now got up-to-date classlist
-                     foreach (@studentdata) {
- 	                my %entries=&Apache::loncommon::record_sep($_);
-                        unless (($entries{$fields{'username'}} eq '') ||
-                          (!defined($entries{$fields{'username'}}))) {
-			   delete($currentlist{
+                foreach (@studentdata) {
+                    my %entries=&Apache::loncommon::record_sep($_);
+                    unless (($entries{$fields{'username'}} eq '') ||
+                            (!defined($entries{$fields{'username'}}))) {
+                        delete($currentlist{
                             $entries{$fields{'username'}}.':'.
-                            $domain});
-		        }
-                     }
+                                $domain});
+                    }
+                }
 # ----------------------------------------------------------- Print out choices
-                     &show_drop_list($r,%currentlist);
-	         } else {
-                     $r->print(
-                  '<font color=red><h3>Could not access classlist: '.$classlst.
-                  '</h3></font>');
-                 }
-	     }
+                &show_drop_list($r,%currentlist);
+            } else {
+                $r->print('<font color=red><h3>Could not access classlist: '.
+                          $classlst.'</h3></font>');
+            }
+        }
 # ------------------------------------------------------------------------ Done
-
-	  }
+    }
 }
 
 # ================================================================== Phase four
@@ -912,65 +894,56 @@
       $r->send_http_header;
       return OK;
    }
-
 # ----------------------------------------------------- Needs to be in a course
-
    if (($ENV{'request.course.fn'}) && 
        (&Apache::lonnet::allowed('cst',$ENV{'request.course.id'}))) {
-
 # ------------------------------------------------------------------ Start page
-      $r->content_type('text/html');
-      $r->send_http_header;
-      &header($r);
-
+       $r->content_type('text/html');
+       $r->send_http_header;
+       &header($r);
 # --------------------------------------------------- Phase one, initial screen
-      unless ($ENV{'form.phase'}) {
-	  &menu_phase_one($r);
-      }
+       unless ($ENV{'form.phase'}) {
+           &menu_phase_one($r);
+       }
 # ------------------------------------------------------------------- Phase two
-
-      if ($ENV{'form.associate'} eq 'Reverse Association') {
-	$ENV{'form.phase'} = 'two';
-	if ( $ENV{'form.upfile_associate'} ne 'reverse' ) {
-	  $ENV{'form.upfile_associate'} = 'reverse';
-	} else {
-	  $ENV{'form.upfile_associate'} = 'forward';
-	}
-      }
-      if ($ENV{'form.phase'} eq 'two') {
-	 if ($ENV{'form.fileupload'}) {
-	     &menu_phase_two_upload($r);
-         } elsif ($ENV{'form.enroll'}) {
-             &menu_phase_two_enroll($r);
-         } elsif ($ENV{'form.drop'}) {
-             &menu_phase_two_drop($r);
-         }
-      }
-
-
-
-
+       if ($ENV{'form.associate'} eq 'Reverse Association') {
+           $ENV{'form.phase'} = 'two';
+           if ( $ENV{'form.upfile_associate'} ne 'reverse' ) {
+               $ENV{'form.upfile_associate'} = 'reverse';
+           } else {
+               $ENV{'form.upfile_associate'} = 'forward';
+           }
+       }
+       if ($ENV{'form.phase'} eq 'two') {
+           if ($ENV{'form.fileupload'}) {
+               &menu_phase_two_upload($r);
+           } elsif ($ENV{'form.enroll'}) {
+               &menu_phase_two_enroll($r);
+           } elsif ($ENV{'form.drop'}) {
+               &menu_phase_two_drop($r);
+           }
+       }
 # ----------------------------------------------------------------- Phase three
-      if ($ENV{'form.phase'} eq 'three') {
-	  if ($ENV{'form.datatoken'}) {
-	      &upfile_drop_add($r);
-          }
-      }
+       if ($ENV{'form.phase'} eq 'three') {
+           if ($ENV{'form.datatoken'}) {
+               &upfile_drop_add($r);
+           }
+       }
 # ------------------------------------------------------------------ Phase four
-      if ($ENV{'form.phase'} eq 'four') {
-	  &drop_student_list($r);
-      }
+       if ($ENV{'form.phase'} eq 'four') {
+           &drop_student_list($r);
+       }
 # ------------------------------------------------------------------ Phase five
-      if ($ENV{'form.phase'} eq 'five') {
-	  &enroll_single_student($r);
-      }
+       if ($ENV{'form.phase'} eq 'five') {
+           &enroll_single_student($r);
+       }
 # ------------------------------------------------------------------------- End
-      $r->print('</form></body></html>');
+       $r->print('</form></body></html>');
    } else {
 # ----------------------------- Not in a course, or not allowed to modify parms
-      $ENV{'user.error.msg'}=
-        "/adm/dropadd:cst:0:0:Cannot drop or add students";
-      return HTTP_NOT_ACCEPTABLE; 
+       $ENV{'user.error.msg'}=
+           "/adm/dropadd:cst:0:0:Cannot drop or add students";
+       return HTTP_NOT_ACCEPTABLE; 
    }
    return OK;
 }

--matthew1018984129--