File:  [LON-CAPA] / loncom / interface / Attic / londropadd.pm
Revision 1.60: download - view: text, annotated - select for diffs
Fri Nov 8 20:51:48 2002 UTC (21 years, 8 months ago) by matthew
Branches: MAIN
CVS tags: HEAD
Added excel spreadsheet as format for viewing classlist.

    1: # The LearningOnline Network with CAPA
    2: # Handler to drop and add students in courses 
    3: #
    4: # $Id: londropadd.pm,v 1.60 2002/11/08 20:51:48 matthew Exp $
    5: #
    6: # Copyright Michigan State University Board of Trustees
    7: #
    8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
    9: #
   10: # LON-CAPA is free software; you can redistribute it and/or modify
   11: # it under the terms of the GNU General Public License as published by
   12: # the Free Software Foundation; either version 2 of the License, or
   13: # (at your option) any later version.
   14: #
   15: # LON-CAPA is distributed in the hope that it will be useful,
   16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   18: # GNU General Public License for more details.
   19: #
   20: # You should have received a copy of the GNU General Public License
   21: # along with LON-CAPA; if not, write to the Free Software
   22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   23: #
   24: # /home/httpd/html/adm/gpl.txt
   25: #
   26: # http://www.lon-capa.org/
   27: #
   28: # (Handler to set parameters for assessments
   29: #
   30: # (Handler to resolve ambiguous file locations
   31: #
   32: # (TeX Content Handler
   33: #
   34: ###############################################################
   35: ###############################################################
   36: 
   37: package Apache::londropadd;
   38: 
   39: use strict;
   40: use Apache::lonnet();
   41: use Apache::loncommon();
   42: use Apache::lonhtmlcommon();
   43: use Apache::Constants qw(:common :http REDIRECT);
   44: use Spreadsheet::WriteExcel;
   45: 
   46: ###############################################################
   47: ###############################################################
   48: sub header {
   49:     my $bodytag=&Apache::loncommon::bodytag('Enrollment Manager');
   50:     return(<<ENDHEAD);
   51: <html>
   52: <head>
   53: <title>LON-CAPA Enrollment Manager</title>
   54: </head>
   55: $bodytag
   56: <form method="post" enctype="multipart/form-data"  
   57:       action="/adm/dropadd" name="studentform">
   58: ENDHEAD
   59: }
   60: 
   61: ###############################################################
   62: ###############################################################
   63: # Drop student from all sections of a course, except optional $csec
   64: sub modifystudent {
   65:     my ($udom,$unam,$courseid,$csec,$desiredhost)=@_;
   66:     # if $csec is undefined, drop the student from all the courses matching
   67:     # this one.  If $csec is defined, drop them from all other sections of 
   68:     # this course and add them to section $csec
   69:     $courseid=~s/\_/\//g;
   70:     $courseid=~s/^(\w)/\/$1/;
   71:     my %roles = &Apache::lonnet::dump('roles',$udom,$unam);
   72:     my ($tmp) = keys(%roles);
   73:     # Bail out if we were unable to get the students roles
   74:     return "$1" if ($tmp =~ /^(con_lost|error|no_such_host)/i);
   75:     # Go through the roles looking for enrollment in this course
   76:     my $result = '';
   77:     foreach my $course (keys(%roles)) {
   78:         if ($course=~/^$courseid(?:\/)*(?:\s+)*(\w+)*\_st$/) {
   79:             # We are in this course
   80:             my $section=$1;
   81:             $section='' if ($course eq $courseid.'_st');
   82:             if ( ((!$section) && (!$csec)) || ($section ne $csec) ) {
   83:                 my (undef,$end,$start)=split(/\_/,$roles{$course});
   84:                 my $now=time;
   85:                 # if this is an active role 
   86:                 if (!($start && ($now<$start)) || !($end && ($now>$end))) {
   87:                     my $reply=&Apache::lonnet::modifystudent
   88:                         ($udom,$unam,'','','','','','','',
   89:                          $section,time,undef,undef,$desiredhost);
   90:                     $result .= $reply.':';
   91:                 }
   92:             }
   93:         }
   94:     }
   95:     if ($result eq '') {
   96:         $result eq 'Unable to find section for this student';
   97:     } else {
   98:         $result =~ s/(ok:)+/ok/g;
   99:     }
  100:     return $result;
  101: }
  102: 
  103: ###############################################################
  104: ###############################################################
  105: # build a domain and server selection form
  106: sub domain_form {
  107:     my ($defdom) = @_;
  108:     # Set up domain and server selection forms
  109:     #
  110:     # Get the domains
  111:     my @domains = &Apache::loncommon::get_domains();
  112:     # build up the menu information to be passed to 
  113:     # &Apache::loncommon::linked_select_forms
  114:     my %select_menus;
  115:     foreach my $dom (@domains) {
  116:         # set up the text for this domain
  117:         $select_menus{$dom}->{'text'}= $dom;
  118:         # we want a choice of 'default' as the default in the second menu
  119:         $select_menus{$dom}->{'default'}= 'default';
  120:         $select_menus{$dom}->{'select2'}->{'default'} = 'default';
  121:         # Now build up the other items in the second menu
  122:         my %servers = &Apache::loncommon::get_library_servers($dom);
  123:         foreach my $server (keys(%servers)) {
  124:             $select_menus{$dom}->{'select2'}->{$server} 
  125:                                             = "$server $servers{$server}";
  126:         }
  127:     }
  128:     my $result  = &Apache::loncommon::linked_select_forms
  129:         ('studentform',' with home server ',$defdom,
  130:          'lcdomain','lcserver',\%select_menus);
  131:     return $result;
  132: }
  133: 
  134: ###############################################################
  135: ###############################################################
  136: #  Menu Phase One
  137: sub print_main_menu {
  138:     my $r=shift;
  139:     $r->print(<<END);
  140: <p>
  141: <font size="+1">
  142:     <a href="/adm/dropadd?action=upload">Upload a course list</a>
  143: </font>
  144: </p><p>
  145: <font size="+1">
  146:     <a href="/adm/dropadd?action=enrollstudent">Enroll a single student</a>
  147: </font>
  148: </p><p>
  149: <font size="+1">
  150:     <a href="/adm/dropadd?action=modifystudent">Modify student data</a>
  151: </font>
  152: </p><p>
  153: <font size="+1">
  154:     <a href="/adm/dropadd?action=classlist">View Classlist</a>
  155: </font>
  156: </p><p>
  157: <font size="+1">
  158:     <a href="/adm/dropadd?action=drop">Drop Students</a>
  159: </font>
  160: </p>
  161: END
  162: }
  163: 
  164: ###############################################################
  165: ###############################################################
  166: sub print_upload_manager_header {
  167:     my ($r,$datatoken,$distotal,$krbdefdom)=@_;
  168:     my $javascript;
  169:     if (! exists($ENV{'form.upfile_associate'})) {
  170:         $ENV{'form.upfile_associate'} = 'forward';
  171:     }
  172:     if ($ENV{'form.associate'} eq 'Reverse Association') {
  173:         if ( $ENV{'form.upfile_associate'} ne 'reverse' ) {
  174:             $ENV{'form.upfile_associate'} = 'reverse';
  175:         } else {
  176:             $ENV{'form.upfile_associate'} = 'forward';
  177:         }
  178:     }
  179:     if ($ENV{'form.upfile_associate'} eq 'reverse') {
  180: 	$javascript=&upload_manager_javascript_reverse_associate();
  181:     } else {
  182: 	$javascript=&upload_manager_javascript_forward_associate();
  183:     }
  184:     my $javascript_validations=&javascript_validations($krbdefdom);
  185:     $r->print(<<ENDPICK);
  186: <h3>Uploading Class List</h3>
  187: <hr>
  188: <h3>Identify fields</h3>
  189: Total number of records found in file: $distotal <hr />
  190: Enter as many fields as you can. The system will inform you and bring you back
  191: to this page if the data selected is insufficient to run your class.<hr />
  192: <input type="button" value="Reverse Association" onClick="javascript:this.form.associate.value='Reverse Association';submit(this.form);" />
  193: <input type="hidden" name="action"     value="upload" />
  194: <input type="hidden" name="state"      value="got_file" />
  195: <input type="hidden" name="associate"  value="" />
  196: <input type="hidden" name="datatoken"  value="$datatoken" />
  197: <input type="hidden" name="fileupload" value="$ENV{'form.fileupload'}" />
  198: <input type="hidden" name="upfiletype" value="$ENV{'form.upfiletype'}" />
  199: <input type="hidden" name="upfile_associate" 
  200:                                        value="$ENV{'form.upfile_associate'}" />
  201: <hr />
  202: <script type="text/javascript" language="Javascript">
  203: $javascript
  204: $javascript_validations
  205: </script>
  206: ENDPICK
  207: }
  208: 
  209: ###############################################################
  210: ###############################################################
  211: sub javascript_validations {
  212:     my ($krbdefdom)=@_;
  213:     my %param = ( formname => 'studentform',
  214:                   kerb_def_dom => $krbdefdom );
  215:     my $authheader = &Apache::loncommon::authform_header(%param);
  216:     return (<<ENDPICK);
  217: function verify_message (vf,founduname,foundpwd,foundname,foundid,foundsec) {
  218:     var foundatype=0;
  219:     var message='';
  220:     if (founduname==0) {
  221: 	alert('You need to specify the username field');
  222:         return;
  223:     }
  224:     if (current.radiovalue == null || current.radiovalue == 'nochange') {
  225:         // They did not check any of the login radiobuttons.
  226:         alert('You must choose an authentication type');
  227:         return;
  228:     }
  229:     foundatype=1;
  230:     if (current.argfield == null || current.argfield == '') {
  231:         var alertmsg = '';
  232:         switch (current.value) {
  233:             case 'krb': 
  234:                 alertmsg = 'You need to specify the Kerberos domain';
  235:                 break;
  236:             case 'loc':
  237:             case 'fsys':
  238:                 alertmsg = 'You need to specify the initial password';
  239:                 break;
  240:             case 'fsys':
  241:                 alertmsg = '';
  242:                 break;
  243:             default: 
  244:                 alertmsg = '';
  245:         }
  246:         if (alertmsg != '') {
  247:             alert(alertmsg);
  248:             return;
  249:         }
  250:     }
  251: 
  252:     if (foundname==0) { message='No name fields specified. '; }
  253:     if (foundid==0) { message+='No ID or student number field specified. '; }
  254:     if (foundsec==0) { message+='No section or group field specified. '; }
  255:     if (vf.startdate.value=='') {
  256: 	message+='No starting date set. ';
  257:     }
  258:     if (vf.enddate.value=='') {
  259:         message+='No ending date set. ';
  260:     }
  261:     if ((vf.enddate.value!='') && (vf.startdate.value!='')) {
  262:        if (Math.round(vf.enddate.value)<Math.round(vf.startdate.value)) {
  263:           alert('Ending date is before starting date');
  264:           return;
  265:        }
  266:     }
  267:     if (message!='') {
  268:        message+='Continue enrollment?';
  269:        if (confirm(message)) {
  270: 	  pclose();
  271:           vf.state.value='enrolling';
  272: 	  vf.submit();
  273:        }
  274:     } else {
  275:       pclose();
  276:       vf.state.value='enrolling';
  277:       vf.submit();
  278:     }
  279: }
  280: 
  281: 
  282:     function pclose() {
  283:         parmwin=window.open("/adm/rat/empty.html","LONCAPAparms",
  284:                  "height=350,width=350,scrollbars=no,menubar=no");
  285:         parmwin.close();
  286:     }
  287: 
  288:     function pjump(type,dis,value,marker,ret,call) {
  289:         parmwin=window.open("/adm/rat/parameter.html?type="+escape(type)
  290:                  +"&value="+escape(value)+"&marker="+escape(marker)
  291:                  +"&return="+escape(ret)
  292:                  +"&call="+escape(call)+"&name="+escape(dis),"LONCAPAparms",
  293:                  "height=350,width=350,scrollbars=no,menubar=no");
  294: 
  295:     }
  296: 
  297:     function dateset() {
  298:         if (document.studentform.pres_marker.value=='end') {
  299:            document.studentform.enddate.value=
  300: 	       document.studentform.pres_value.value;
  301:         }
  302:         if (document.studentform.pres_marker.value=='start') {
  303:            document.studentform.startdate.value=
  304: 	       document.studentform.pres_value.value;
  305:         }
  306:         pclose();
  307:     }
  308: 
  309: $authheader
  310: ENDPICK
  311: 
  312: }
  313: 
  314: ###############################################################
  315: ###############################################################
  316: sub upload_manager_javascript_forward_associate {
  317:     return(<<ENDPICK);
  318: function verify(vf) {
  319:     var founduname=0;
  320:     var foundpwd=0;
  321:     var foundname=0;
  322:     var foundid=0;
  323:     var foundsec=0;
  324:     var tw;
  325:     for (i=0;i<=vf.nfields.value;i++) {
  326:         tw=eval('vf.f'+i+'.selectedIndex');
  327:         if (tw==1) { founduname=1; }
  328:         if ((tw>=2) && (tw<=6)) { foundname=1; }
  329:         if (tw==7) { foundid=1; }
  330:         if (tw==8) { foundsec=1; }
  331:         if (tw==9) { foundpwd=1; }
  332:     }
  333:     verify_message(vf,founduname,foundpwd,foundname,foundid,foundsec);
  334: }
  335: 
  336: //
  337: // vf = this.form
  338: // tf = column number
  339: //
  340: // values of nw
  341: //
  342: // 0 = none
  343: // 1 = username
  344: // 2 = names (lastname, firstnames)
  345: // 3 = fname (firstname)
  346: // 4 = mname (middlename)
  347: // 5 = lname (lastname)
  348: // 6 = gen   (generation)
  349: // 7 = id
  350: // 8 = section
  351: // 9 = ipwd  (password)
  352: //
  353: function flip(vf,tf) {
  354:    var nw=eval('vf.f'+tf+'.selectedIndex');
  355:    var i;
  356:    // make sure no other columns are labeled the same as this one
  357:    for (i=0;i<=vf.nfields.value;i++) {
  358:       if ((i!=tf) && (eval('vf.f'+i+'.selectedIndex')==nw)) {
  359:           eval('vf.f'+i+'.selectedIndex=0;')
  360:       }
  361:    }
  362:    // If we set this to 'lastname, firstnames', clear out all the ones
  363:    // set to 'fname','mname','lname','gen' (3,4,5,6) currently.
  364:    if (nw==2) {
  365:       for (i=0;i<=vf.nfields.value;i++) {
  366:          if ((eval('vf.f'+i+'.selectedIndex')>=3) &&
  367:              (eval('vf.f'+i+'.selectedIndex')<=6)) {
  368:              eval('vf.f'+i+'.selectedIndex=0;')
  369:          }
  370:       }
  371:    }
  372:    // If we set this to one of 'fname','mname','lname','gen' (3,4,5,6),
  373:    // clear out any that are set to 'lastname, firstnames' (2)
  374:    if ((nw>=3) && (nw<=6)) {
  375:       for (i=0;i<=vf.nfields.value;i++) {
  376:          if (eval('vf.f'+i+'.selectedIndex')==2) {
  377:              eval('vf.f'+i+'.selectedIndex=0;')
  378:          }
  379:       }
  380:    }
  381:    // If we set the password, make the password form below correspond to 
  382:    // the new value.
  383:    if (nw==9) {
  384:        changed_radio('int',document.studentform);
  385:        set_auth_radio_buttons('int',document.studentform);
  386:        vf.intarg.value='';
  387:        vf.krbarg.value='';
  388:        vf.locarg.value='';
  389:    }
  390: }
  391: 
  392: function clearpwd(vf) {
  393:     var i;
  394:     for (i=0;i<=vf.nfields.value;i++) {
  395:         if (eval('vf.f'+i+'.selectedIndex')==9) {
  396:             eval('vf.f'+i+'.selectedIndex=0;')
  397:         }
  398:     }
  399: }
  400: 
  401: ENDPICK
  402: }
  403: 
  404: ###############################################################
  405: ###############################################################
  406: sub upload_manager_javascript_reverse_associate {
  407:     return(<<ENDPICK);
  408: function verify(vf) {
  409:     var founduname=0;
  410:     var foundpwd=0;
  411:     var foundname=0;
  412:     var foundid=0;
  413:     var foundsec=0;
  414:     var tw;
  415:     for (i=0;i<=vf.nfields.value;i++) {
  416:         tw=eval('vf.f'+i+'.selectedIndex');
  417:         if (i==0 && tw!=0) { founduname=1; }
  418:         if (((i>=1) && (i<=5)) && tw!=0 ) { foundname=1; }
  419:         if (i==6 && tw!=0) { foundid=1; }
  420:         if (i==7 && tw!=0) { foundsec=1; }
  421:         if (i==8 && tw!=0) { foundpwd=1; }
  422:     }
  423:     verify_message(vf,founduname,foundpwd,foundname,foundid,foundsec);
  424: }
  425: 
  426: function flip(vf,tf) {
  427:    var nw=eval('vf.f'+tf+'.selectedIndex');
  428:    var i;
  429:    // picked the all one one name field, reset the other name ones to blank
  430:    if (tf==1 && nw!=0) {
  431:       for (i=2;i<=5;i++) {
  432:          eval('vf.f'+i+'.selectedIndex=0;')
  433:       }
  434:    }
  435:    //picked one of the piecewise name fields, reset the all in
  436:    //one field to blank
  437:    if ((tf>=2) && (tf<=5) && (nw!=0)) {
  438:       eval('vf.f1.selectedIndex=0;')
  439:    }
  440:    // intial password specified, pick internal authentication
  441:    if (tf==8 && nw!=0) {
  442:        changed_radio('int',document.studentform);
  443:        set_auth_radio_buttons('int',document.studentform);
  444:        vf.krbarg.value='';
  445:        vf.intarg.value='';
  446:        vf.locarg.value='';
  447:    }
  448: }
  449: 
  450: function clearpwd(vf) {
  451:     var i;
  452:     if (eval('vf.f8.selectedIndex')!=0) {
  453:         eval('vf.f8.selectedIndex=0;')
  454:     }
  455: }
  456: ENDPICK
  457: }
  458: 
  459: ###############################################################
  460: ###############################################################
  461: sub print_upload_manager_footer {
  462:     my ($r,$i,$keyfields,$defdom,$today,$halfyear)=@_;
  463:     my %param = ( formname => 'document.studentform');
  464:     my $krbform = &Apache::loncommon::authform_kerberos(%param);
  465:     my $intform = &Apache::loncommon::authform_internal(%param);
  466:     my $locform = &Apache::loncommon::authform_local(%param);
  467:     my $domform = &domain_form($defdom);
  468:     $r->print(<<ENDPICK);
  469: </table>
  470: <input type=hidden name=nfields value=$i>
  471: <input type=hidden name=keyfields value="$keyfields">
  472: <h3>Login Type</h3>
  473: <p>Note: this will not take effect if the user already exists</p>
  474: <p>
  475: $krbform
  476: </p>
  477: <p>
  478: $intform
  479: </p>
  480: <p>
  481: $locform
  482: </p>
  483: <h3>LON-CAPA Domain for Students</h3>
  484: LON-CAPA domain: $domform <p>
  485: <h3>Starting and Ending Dates</h3>
  486: <input type="hidden" value=''          name="pres_value"  >
  487: <input type="hidden" value=''          name="pres_type"   >
  488: <input type="hidden" value=''          name="pres_marker" >
  489: <input type="hidden" value='$today'    name="startdate"   >
  490: <input type="hidden" value='$halfyear' name="enddate"     >
  491: <a 
  492:  href="javascript:pjump('date_start','Enrollment Starting Date',document.studentform.startdate.value,'start','studentform.pres','dateset');"
  493: >Set Starting Date</a><p>
  494: 
  495: <a 
  496:  href="javascript:pjump('date_end','Enrollment Ending Date',document.studentform.enddate.value,'end','studentform.pres','dateset');"
  497: >Set Ending Date</a><p>
  498: <h3>Full Update</h3>
  499: <input type=checkbox name=fullup value=yes> Full update 
  500: (also print list of users not enrolled anymore)<p>
  501: <h3>ID/Student Number</h3>
  502: <input type=checkbox name=forceid value=yes> 
  503: Disable ID/Student Number Safeguard and Force Change of Conflicting IDs
  504: (only do if you know what you are doing)<p>
  505: <input type="button" onClick="javascript:verify(this.form)" value="Update Courselist" /><br />
  506: Note: for large courses, this operation may be time consuming.
  507: ENDPICK
  508: }
  509: 
  510: # ======================================================= Menu Phase Two Upload
  511: sub print_upload_manager_form {
  512:     my $r=shift;
  513: 
  514:     my $datatoken;
  515:     if (!$ENV{'form.datatoken'}) {
  516:       $datatoken=&Apache::loncommon::upfile_store($r);
  517:     } else {
  518:       $datatoken=$ENV{'form.datatoken'};
  519:       &Apache::loncommon::load_tmp_file($r);
  520:     }
  521:     my @records=&Apache::loncommon::upfile_record_sep();
  522:     my $total=$#records;
  523:     my $distotal=$total+1;
  524:     $ENV{'SERVER_NAME'}=~/(\w+\.\w+)$/;
  525:     my $krbdefdom=$1;
  526:     $krbdefdom=~tr/a-z/A-Z/;
  527:     my $today=time;
  528:     my $halfyear=$today+15552000;
  529:     my $defdom=$r->dir_config('lonDefDomain');
  530:     &print_upload_manager_header($r,$datatoken,$distotal,$krbdefdom);
  531:     my $i;
  532:     my $keyfields;
  533:     if ($total>=0) {
  534: 	my @d=(['username','Username'],
  535:                ['names','Last Name, First Names'],
  536: 	       ['fname','First Name'],
  537:                ['mname','Middle Names/Initials'],
  538: 	       ['lname','Last Name'],
  539:                ['gen','Generation'],
  540: 	       ['id','ID/Student Number'],
  541:                ['sec','Group/Section'],
  542: 	       ['ipwd','Initial Password']);
  543: 	if ($ENV{'form.upfile_associate'} eq 'reverse') {	
  544: 	    &Apache::loncommon::csv_print_samples($r,\@records);
  545: 	    $i=&Apache::loncommon::csv_print_select_table($r,\@records,\@d);
  546: 	    foreach (@d) { $keyfields.=$_->[0].','; }
  547: 	    chop($keyfields);
  548: 	} else {
  549: 	    unshift(@d,['none','']);
  550: 	    $i=&Apache::loncommon::csv_samples_select_table($r,\@records,\@d);
  551: 	    my %sone=&Apache::loncommon::record_sep($records[0]);
  552: 	    $keyfields=join(',',sort(keys(%sone)));
  553: 	}
  554:     }
  555:     &print_upload_manager_footer($r,$i,$keyfields,$defdom,$today,$halfyear);
  556: }
  557: 
  558: # ======================================================= Enroll single student
  559: sub enroll_single_student {
  560:     my $r=shift;
  561:     $r->print('<h3>Enrolling Student</h3>');
  562:     $r->print('<p>Enrolling '.$ENV{'form.cuname'}." \@ ".
  563:               $ENV{'form.lcdomain'}.'</p>');
  564:     if (($ENV{'form.cuname'})&&($ENV{'form.cuname'}!~/\W/)&&
  565:         ($ENV{'form.lcdomain'})&&($ENV{'form.lcdomain'}!~/\W/)) {
  566:         # Deal with home server selection
  567:         my $domain=$ENV{'form.lcdomain'};
  568:         my $desiredhost = $ENV{'form.lcserver'};
  569:         if (lc($desiredhost) eq 'default') {
  570:             $desiredhost = undef;
  571:         } else {
  572:             my %home_servers =&Apache::loncommon::get_library_servers($domain);
  573:             if (! exists($home_servers{$desiredhost})) {
  574:                 $r->print('<font color="#ff0000">Error:</font>'.
  575:                           'Invalid home server specified');
  576:                 return;
  577:             }
  578:         }
  579:         $r->print(" with server $desiredhost :") if (defined($desiredhost));
  580:         # End of home server selection logic
  581: 	my $amode='';
  582:         my $genpwd='';
  583:         if ($ENV{'form.login'} eq 'krb') {
  584:            $amode='krb';
  585: 	   $amode.=$ENV{'form.krbver'};
  586:            $genpwd=$ENV{'form.krbarg'};
  587:         } elsif ($ENV{'form.login'} eq 'int') {
  588:            $amode='internal';
  589:            $genpwd=$ENV{'form.intarg'};
  590:         }  elsif ($ENV{'form.login'} eq 'loc') {
  591: 	    $amode='localauth';
  592: 	    $genpwd=$ENV{'form.locarg'};
  593: 	    if (!$genpwd) { $genpwd=" "; }
  594: 	}
  595:         my $home = &Apache::lonnet::homeserver($ENV{'form.cuname'},
  596:                                                    $ENV{'form.lcdomain'});
  597:         if ((($amode) && ($genpwd)) || ($home ne 'no_host')) {
  598:             # Clean out any old roles the student has in this class.
  599:             &modifystudent($ENV{'form.lcdomain'},$ENV{'form.cuname'},
  600:                            $ENV{'request.course.id'},$ENV{'form.csec'},
  601:                             $desiredhost);
  602:             my $login_result = &Apache::lonnet::modifystudent
  603:                 ($ENV{'form.lcdomain'},$ENV{'form.cuname'},
  604:                  $ENV{'form.cstid'},$amode,$genpwd,
  605:                  $ENV{'form.cfirst'},$ENV{'form.cmiddle'},
  606:                  $ENV{'form.clast'},$ENV{'form.cgen'},
  607:                  $ENV{'form.csec'},$ENV{'form.enddate'},
  608:                  $ENV{'form.startdate'},$ENV{'form.forceid'},
  609:                  $desiredhost);
  610:             if ($login_result =~ /^ok/) {
  611:                 $r->print($login_result);
  612:                 $r->print("<p> If active, the new role will be available ".
  613:                           "when the student next logs in to LON-CAPA.</p>");
  614:             } else {
  615:                 $r->print("unable to enroll: ".$login_result);
  616:             }
  617: 	} else {
  618:             $r->print('<p><font color="#ff0000">ERROR</font>&nbsp;'.
  619:                       'Invalid login mode or password.  '.
  620:                       'Unable to enroll '.$ENV{'form.cuname'}.'.</p>');
  621:         }          
  622:     } else {
  623:         $r->print('Invalid username or domain');
  624:     }    
  625: }
  626: 
  627: # ======================================================= Menu Phase Two Enroll
  628: sub print_enroll_single_student_form {
  629:     my $r=shift;
  630:     $r->print("<h3>Enroll One Student</h3>");
  631:     my ($krbdefdom) = $ENV{'SERVER_NAME'}=~/(\w+\.\w+)$/;
  632:     $krbdefdom=~tr/a-z/A-Z/;
  633:     my $today    = time;
  634:     my $halfyear = $today+15552000;
  635:     my $defdom=$r->dir_config('lonDefDomain');
  636:     my $javascript_validations=&javascript_validations($krbdefdom);
  637:     # Set up authentication forms
  638:     my %param = ( formname => 'document.studentform');
  639:     my $krbform = &Apache::loncommon::authform_kerberos(%param);
  640:     my $intform = &Apache::loncommon::authform_internal(%param);
  641:     my $locform = &Apache::loncommon::authform_local(%param);
  642:     # Set up domain selection form
  643:     my $domform = &domain_form($defdom);
  644:     # Print it all out
  645:     $r->print(<<END);
  646: <input type="hidden" name="action" value="enrollstudent">
  647: <input type="hidden" name="state"  value="done">
  648: 
  649: <script type="text/javascript" language="Javascript">
  650: function verify(vf) {
  651:     var founduname=0;
  652:     var foundpwd=0;
  653:     var foundname=0;
  654:     var foundid=0;
  655:     var foundsec=0;
  656:     var tw;
  657:     if ((typeof(vf.cuname.value) !="undefined") && (vf.cuname.value!='') && 
  658: 	(typeof(vf.lcdomain.value)!="undefined") && (vf.lcdomain.value!='')) {
  659:         founduname=1;
  660:     }
  661:     if ((typeof(vf.cfirst.value)!="undefined") && (vf.cfirst.value!='') &&
  662: 	(typeof(vf.clast.value) !="undefined") && (vf.clast.value!='')) {
  663:         foundname=1;
  664:     }
  665:     if ((typeof(vf.csec.value)!="undefined") && (vf.csec.value!='')) {
  666:         foundsec=1;
  667:     }
  668:     if ((typeof(vf.cstid.value)!="undefined") && (vf.cstid.value!='')) {
  669: 	foundid=1;
  670:     }
  671:     if (founduname==0) {
  672: 	alert('You need to specify at least the username and domain fields');
  673:         return;
  674:     }
  675:     verify_message(vf,founduname,foundpwd,foundname,foundid,foundsec);
  676: }
  677: 
  678: $javascript_validations
  679: 
  680: function clearpwd(vf) {
  681:     //nothing else needs clearing
  682: }
  683: 
  684: </script>
  685: <h3>Personal Data</h3>
  686: <table>
  687: <tr><td>First Name:</td><td> <input type="text" name="cfirst"  size="15"></td></tr>
  688: <tr><td>Middle Name:</td><td> <input type="text" name="cmiddle" size="15"></td></tr>
  689: <tr><td>Last Name: </td><td><input type="text" name="clast"   size="15"></td></tr>
  690: <tr><td>Generation: </td><td><input type="text" name="cgen"    size="5"> </td></tr>
  691: </table>
  692: 
  693: <h3>Login Data</h3>
  694: <p>Username: <input type="text" name="cuname"  size="15"></p>
  695: <p>Domain:   $domform</p>
  696: <p>Note: login settings below  will not take effect if the user already exists
  697: </p><p>
  698: $krbform
  699: </p><p>
  700: $intform
  701: </p><p>
  702: $locform
  703: </p><p>
  704: 
  705: <h3>Course Data</h3>
  706: 
  707: <p>Group/Section: <input type="text" name="csec" size="5" />
  708: <p>
  709: <!-- Date setting form elements -->
  710: <input type="hidden" name="pres_value"  value='' />
  711: <input type="hidden" name="pres_type"   value='' />
  712: <input type="hidden" name="pres_marker" value='' />
  713: <input type="hidden" name="startdate"   value='$today'    />
  714: <input type="hidden" name="enddate"     value='$halfyear' />
  715: </p><p>
  716: <a 
  717:  href="javascript:pjump('date_start','Enrollment Starting Date',document.studentform.startdate.value,'start','studentform.pres','dateset');"
  718: >Set Starting Date</a>
  719: </p><p>
  720: <a 
  721:  href="javascript:pjump('date_end','Enrollment Ending Date',document.studentform.enddate.value,'end','studentform.pres','dateset');"
  722: >Set Ending Date</a>
  723: </p>
  724: <h3>ID/Student Number</h3>
  725: <p>
  726: ID/Student Number: <input type="text" name="cstid" size="10">
  727: </p><p>
  728: <input type="checkbox" name="forceid" value="yes"> 
  729: Disable ID/Student Number Safeguard and Force Change of Conflicting IDs
  730: (only do if you know what you are doing)
  731: </p><p>
  732: <input type="button" onClick="verify(this.form)" value="Enroll as student">
  733: </p>
  734: END
  735:     return;
  736: }
  737: 
  738: # ========================================================= Menu Phase Two Drop
  739: sub print_drop_menu {
  740:     my $r=shift;
  741:     $r->print("<h3>Drop Students</h3>");
  742:     my $cid=$ENV{'request.course.id'};
  743:     my ($classlist,$keylist) = &Apache::loncoursedata::get_classlist();
  744:     if (! defined($classlist)) {
  745:         $r->print("There are no students currently enrolled.\n");
  746:         return;
  747:     }
  748:     # Print out the available choices
  749:     &show_drop_list($r,$classlist,$keylist);
  750:     return;
  751: }
  752: 
  753: # ============================================== view classlist
  754: sub print_html_classlist {
  755:     my $r=shift;
  756:     if (! exists($ENV{'form.sortby'})) {
  757:         $ENV{'form.sortby'} = 'username';
  758:     }
  759:     if ($ENV{'form.Status'} !~ /^(Any|Expired|Active)$/) {
  760:         $ENV{'form.Status'} = 'Active';
  761:     }
  762:     my $status_select = &Apache::lonhtmlcommon::StatusOptions
  763:         ($ENV{'form.Status'},'studentform');
  764:     $r->print(<<END);
  765: <input type="hidden" name="action" value="$ENV{'form.action'}" />
  766: <input type="hidden" name="state"  value="" />
  767: <p>
  768: <font size="+1">Current Classlist</font>
  769: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  770: END
  771:     if ($ENV{'form.action'} ne 'modifystudent') {
  772:         $r->print(<<END);
  773: <font size="+1">
  774: <a href="javascript:document.studentform.state.value='csv';document.studentform.submit();">CSV format</a>
  775: <a href="javascript:document.studentform.state.value='excel';document.studentform.submit();">Excel format</a>
  776: </font>
  777: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  778: END
  779:     }
  780:     $r->print($status_select."</p>\n");
  781:     my $cid=$ENV{'request.course.id'};
  782:     my ($classlist,$keylist)=&Apache::loncoursedata::get_classlist();
  783:     if (! defined($classlist)) {
  784:         $r->print("There are no students currently enrolled.\n");
  785:     } else {
  786:         # Print out the available choices
  787:         if ($ENV{'form.action'} eq 'modifystudent') {
  788:             &show_class_list($r,'view','modify','modifystudent',
  789:                              $ENV{'form.Status'},$classlist,$keylist);
  790:         } else {
  791:             &show_class_list($r,'view','aboutme','classlist',
  792:                              $ENV{'form.Status'},$classlist,$keylist);
  793:         }
  794:     }
  795: }
  796: 
  797: # ============================================== view classlist
  798: sub print_formatted_classlist {
  799:     my $r=shift;
  800:     my $mode = shift;
  801:     my $cid=$ENV{'request.course.id'};
  802:     my ($classlist,$keylist)=&Apache::loncoursedata::get_classlist();
  803:     if (! defined($classlist)) {
  804:         $r->print("There are no students currently enrolled.\n");
  805:     } else {
  806:         &show_class_list($r,$mode,'nolink','csv',
  807:                          $ENV{'form.Status'},$classlist,$keylist);
  808:     }
  809: }
  810: 
  811: # =================================================== Show student list to drop
  812: sub show_class_list {
  813:     my ($r,$mode,$linkto,$action,$statusmode,$classlist,$keylist)=@_;
  814:     my $cid=$ENV{'request.course.id'};
  815:     #
  816:     # Variables for excel output
  817:     my ($excel_workbook, $excel_sheet, $excel_filename,$row);
  818:     #
  819:     my $sortby = $ENV{'form.sortby'};
  820:     if ($sortby !~ /^(username|domain|section|fullname|id)$/) {
  821:         $sortby = 'username';
  822:     }
  823:     # Print out header 
  824:     if ($mode eq 'view') {
  825:         if ($linkto eq 'aboutme') {
  826:             $r->print('Select a user name to view the users personal page.');
  827:         } elsif ($linkto eq 'modify') {
  828:             $r->print('Select a user name to modify the students information');
  829:         }
  830:         $r->print(<<END);
  831: 
  832: <input type="hidden" name="sortby" value="$sortby" />
  833: <input type="hidden" name="sname"  value="" />
  834: <input type="hidden" name="sdom"   value="" />
  835: <p>
  836: <table border=2>
  837: <tr><th>
  838:        <a href="javascript:document.studentform.sortby.value='username';document.studentform.submit();">username</a>
  839:     </th><th>
  840:        <a href="javascript:document.studentform.sortby.value='domain';document.studentform.submit();">domain</a>
  841:     </th><th>
  842:        <a href="javascript:document.studentform.sortby.value='id';document.studentform.submit();">ID</a>
  843:     </th><th>
  844:        <a href="javascript:document.studentform.sortby.value='fullname';document.studentform.submit();">student name</a>
  845:     </th><th>
  846:        <a href="javascript:document.studentform.sortby.value='section';document.studentform.submit();">section</a>
  847:     </th>
  848: </tr>
  849: END
  850:     } elsif ($mode eq 'csv') {
  851:         if($statusmode eq 'Expired') {
  852:             $r->print('"Students with expired roles"');
  853:         }
  854:         if ($statusmode eq 'Any') {
  855:             $r->print('"'.join('","',("username","domain","ID","student name",
  856:                                       "section","status")).'"'."\n");
  857:         } else {
  858:             $r->print('"'.join('","',("username","domain","ID","student name",
  859:                                       "section")).'"'."\n");
  860:         }
  861:     } elsif ($mode eq 'excel') {
  862:         # Create the excel spreadsheet
  863:         $excel_filename = '/prtspool/'.
  864:             $ENV{'user.name'}.'_'.$ENV{'user.domain'}.'_'.
  865:                 time.'_'.rand(1000000000).'.xls';
  866:         $excel_workbook = Spreadsheet::WriteExcel->new('/home/httpd'.
  867:                                                        $excel_filename);
  868:         $excel_workbook->set_tempdir('/home/httpd/perl/tmp');
  869:         $excel_sheet = $excel_workbook->addworksheet('classlist');
  870:         #
  871:         my $description = 'Classlist for '.
  872:             $ENV{'course.'.$ENV{'request.course.id'}.'.description'};
  873:         $excel_sheet->write($row++,0,$description);
  874:         #
  875:         $excel_sheet->write($row++,0,["username","domain","ID",
  876:                                       "student name","section","status"]);
  877:     }
  878:     #
  879:     # Sort the students
  880:     my %index;
  881:     my $i;
  882:     foreach (@$keylist) {
  883:         $index{$_} = $i++;
  884:     }
  885:     my $index  = $index{$sortby};
  886:     my $second = $index{'username'};
  887:     my $third  = $index{'domain'};
  888:     my @Sorted_Students = sort {
  889:         lc($classlist->{$a}->[$index])  cmp lc($classlist->{$b}->[$index])
  890:             ||
  891:         lc($classlist->{$a}->[$second]) cmp lc($classlist->{$b}->[$second])
  892:             ||
  893:         lc($classlist->{$a}->[$third]) cmp lc($classlist->{$b}->[$third])
  894:         } (keys(%$classlist));
  895:     foreach my $student (@Sorted_Students) {
  896:         my $username = $classlist->{$student}->[$index{'username'}];
  897:         my $domain   = $classlist->{$student}->[$index{'domain'}];
  898:         my $section  = $classlist->{$student}->[$index{'section'}];
  899:         my $name     = $classlist->{$student}->[$index{'fullname'}];
  900:         my $id       = $classlist->{$student}->[$index{'id'}];
  901:         my $status   = $classlist->{$student}->[$index{'status'}];
  902:         next if (($statusmode ne 'Any') && ($status ne $statusmode));
  903:         if ($mode eq 'view') {
  904:             $r->print("<tr>\n    <td>\n        ");
  905:             if ($linkto eq 'nothing') {
  906:                 $r->print($username);
  907:             } elsif ($linkto eq 'aboutme') {
  908:                 $r->print(&Apache::loncommon::aboutmewrapper($username,
  909:                                                              $username,
  910:                                                              $domain));
  911:             } elsif ($linkto eq 'modify') {
  912:                 $r->print('<a href="'.
  913:                           "javascript:document.studentform.sname.value='".
  914:                           $username.
  915:                           "';document.studentform.sdom.value='".$domain.
  916:                           "';document.studentform.state.value='selected".
  917:                           "';document.studentform.submit();".'">'.
  918:                           $username."</a>\n");
  919:             }
  920:             $r->print(<<"END");
  921:     </td>
  922:     <td>$domain</td>
  923:     <td>$id</td>
  924:     <td>$name</td>
  925:     <td>$section</td>
  926: </tr>
  927: END
  928:         } elsif ($mode eq 'csv') {
  929:             # no need to bother with $linkto
  930:             my @line = ();
  931:             foreach ($username,$domain,$id,$name,$section) {
  932:                 push @line,&Apache::loncommon::csv_translate($_);
  933:             }
  934:             if ($statusmode eq 'Any') {
  935:                 push @line,&Apache::loncommon::csv_translate($status);
  936:             }
  937:             my $tmp = $";
  938:             $" = '","';
  939:             $r->print("\"@line\"\n");
  940:             $" = $tmp;
  941:         } elsif ($mode eq 'excel') {
  942:             $excel_sheet->write($row++,0,[$username,$domain,$id,
  943:                                           $name,$section,$status]);
  944:         }
  945:     }
  946:     if ($mode eq 'view') {
  947:         $r->print('</table><br>');
  948:     } elsif ($mode eq 'excel') {
  949:         $excel_workbook->close();
  950:         $r->print('<p><a href="'.$excel_filename.'">'.
  951:                   'Your Excel spreadsheet</a> is ready for download.</p>'."\n");
  952:     }
  953: }
  954: 
  955: 
  956: #
  957: # print out form for modification of a single students data
  958: #
  959: sub print_modify_student_form {
  960:     my $r = shift();
  961:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
  962:                                             ['sdom','sname']);    
  963:     my $sname  = $ENV{'form.sname'};
  964:     my $sdom   = $ENV{'form.sdom'};
  965:     my $sortby = $ENV{'form.sortby'};
  966:     # determine the students name information
  967:     my %info=&Apache::lonnet::get('environment',
  968:                                   ['firstname','middlename',
  969:                                    'lastname','generation','id'],
  970:                                   $sdom, $sname);
  971:     my ($tmp) = keys(%info);
  972:     if ($tmp =~ /^(con_lost|error|no_such_host)/i) {
  973:         $r->print('<font color="#ff0000" size="+2">Error</font>'.
  974:                   '<p>'.
  975:                   'Unable to retrieve environment data for '.$sname.
  976:                   'in domain '.$sdom.'</p><p>'.
  977:                   'Please contact your LON-CAPA administrator '.
  978:                   'regarding this situation.</p></body></html>');
  979:         return;
  980:     }
  981:     # determine the students starting and ending times and section
  982:     my ($starttime,$endtime,$section) = &get_enrollment_data($sname,$sdom);
  983:     # Deal with date forms
  984:     my $startdateform = &Apache::lonhtmlcommon::date_setter('studentform',
  985:                                                             'startdate',
  986:                                                             $starttime);
  987:     my $enddateform = &Apache::lonhtmlcommon::date_setter('studentform',
  988:                                                           'enddate',
  989:                                                           $endtime);
  990:     #
  991:     if (! exists($ENV{'form.Status'}) || 
  992:         $ENV{'form.Status'} !~ /^(Any|Expired|Active)$/) {
  993:         $ENV{'form.Status'} = 'crap';
  994:     }
  995:     # Make sure student is enrolled in course    
  996:     $r->print(<<END);
  997: <p>
  998: <font size="+1">
  999: Only domain coordinators can change a users password.
 1000: </font>
 1001: </p>
 1002: <input type="hidden" name="slogin"  value="$sname"  />
 1003: <input type="hidden" name="sdomain" value="$sdom" />
 1004: <input type="hidden" name="action"  value="modifystudent" />
 1005: <input type="hidden" name="state"   value="done" />
 1006: <input type="hidden" name="sortby"  value="$sortby" />
 1007: <input type="hidden" name="Status"  value="$ENV{'form.Status'}" />
 1008: 
 1009: <h2>Modify Enrollment for $info{'firstname'} $info{'middlename'} 
 1010: $info{'lastname'} $info{'generation'}, $sname\@$sdom</h2>
 1011: <p>
 1012: <b>Student Name</b>
 1013: <table>
 1014: <tr><th>First</th><th>Middle</th><th>Last</th><th>Generation</th></tr>
 1015: <tr><td>
 1016: <input type="text" name="firstname"  value="$info{'firstname'}"  /></td><td>
 1017: <input type="text" name="middlename" value="$info{'middlename'}" /></td><td>
 1018: <input type="text" name="lastname"   value="$info{'lastname'}"   /></td><td>
 1019: <input type="text" name="generation" value="$info{'generation'}" /></td></tr>
 1020: </table>
 1021: </p><p>
 1022: <b>Student ID</b>: <input type="text" name="id" value="$info{'id'}" size="12"/>
 1023: </p><p>
 1024: <input type="checkbox" name="forceid" > 
 1025: Disable ID/Student Number Safeguard and Force Change of Conflicting IDs
 1026: (only do if you know what you are doing)
 1027: </p><p>
 1028: <b>Section</b>: <input type="text" name="section" value="$section" size="4"/>
 1029: </p><p>
 1030: <table>
 1031: <tr><td align="right"><b>Starting Date:</b></td><td>$startdateform</td></tr>
 1032: <tr><td align="right"><b>Ending Date:</b></td><td>$enddateform</td></tr>
 1033: </table>
 1034: </p>
 1035: <input type="submit" value="Submit Modifications" />
 1036: </body></html>
 1037: END
 1038:     return;
 1039: }
 1040: 
 1041: #
 1042: # modify a single students section 
 1043: #
 1044: sub modify_single_student {
 1045:     my $r = shift;
 1046:     # Get the 'sortby' and 'Status' variables so the user goes back to their
 1047:     # previous screen
 1048:     my $sortby = $ENV{'form.sortby'};
 1049:     my $status = $ENV{'form.Status'};
 1050:     #
 1051:     # We always need this information
 1052:     my $slogin     = $ENV{'form.slogin'};
 1053:     my $sdom       = $ENV{'form.sdomain'};
 1054:     #
 1055:     # Get the old data
 1056:     my %old=&Apache::lonnet::get('environment',
 1057:                                  ['firstname','middlename',
 1058:                                   'lastname','generation','id'],
 1059:                                  $sdom, $slogin);
 1060:     $old{'section'} = &Apache::lonnet::getsection($sdom,$slogin,
 1061:                                                   $ENV{'request.course.id'});
 1062:     my ($tmp) = keys(%old);
 1063:     if ($tmp =~ /^(con_lost|error|no_such_host)/i) {
 1064:         $r->print("There was an error determining the environment values ".
 1065:                   " for $slogin \@ $sdom.");
 1066:         return;
 1067:     }
 1068:     undef $tmp;
 1069:     #
 1070:     # Get the new data
 1071:     my $firstname  = $ENV{'form.firstname'};
 1072:     my $middlename = $ENV{'form.middlename'};
 1073:     my $lastname   = $ENV{'form.lastname'};
 1074:     my $generation = $ENV{'form.generation'};
 1075:     my $section    = $ENV{'form.section'};
 1076:     my $courseid   = $ENV{'request.course.id'};
 1077:     my $sid        = $ENV{'form.id'};
 1078:     my $starttime = &Apache::lonhtmlcommon::get_date_from_form('startdate',
 1079:                                                                time);
 1080:     my $endtime   = &Apache::lonhtmlcommon::get_date_from_form('enddate',
 1081:                                                                time);
 1082:     my $displayable_starttime = localtime($starttime);
 1083:     my $displayable_endtime   = localtime($endtime);
 1084:     # 
 1085:     # check for forceid override
 1086:     if (($sid ne $old{'id'}) && (! exists($ENV{'form.forceid'}))) {
 1087:         $r->print("<font color=\"ff0000\">You changed the students id ".
 1088:                   " but did not disable the ID change safeguard.".
 1089:                   "  The students id will not be changed.</font>");
 1090:         $sid = $old{'id'};
 1091:     }
 1092:     #
 1093:     # talk to the user about what we are going to do
 1094:     $r->print(<<END);
 1095:     <h2>Modifying data for user $slogin \@ $sdom </h2>
 1096: <h3>Student Information</h3>
 1097: <table rules="rows" border="1" cellpadding="3" >
 1098: <tr>
 1099:     <th> Field </th>
 1100:     <th> Old Value </th>
 1101:     <th> New Value </th>
 1102: </tr>
 1103: <tr>
 1104:     <td> <b>First name</b> </td>
 1105:     <td> $old{'firstname'} </td>
 1106:     <td> $firstname </td>
 1107: </tr><tr>
 1108:     <td> <b>Middle name</b> </td>
 1109:     <td> $old{'middlename'} </td>
 1110:     <td> $middlename </td>
 1111: </tr><tr>
 1112:     <td> <b>Last name</b> </td>
 1113:     <td> $old{'lastname'} </td>
 1114:     <td> $lastname </td>
 1115: </tr><tr>
 1116:     <td> <b>Generation</b> </td>
 1117:     <td> $old{'generation'} </td>
 1118:     <td> $generation </td>
 1119: </tr><tr>
 1120:     <td> <b>ID</b> </td>
 1121:     <td> $old{'id'} </td>
 1122:     <td> $sid </td>
 1123: </tr><tr>
 1124:     <td> <b>Section</b> </td>
 1125:     <td> $old{'section'} </td>
 1126:     <td> $section</td>
 1127: </tr>
 1128: </table>
 1129: <h3>Role Information</h3>
 1130: <table>
 1131: <tr><td>Start Time  </td><td> $displayable_starttime </td></tr>
 1132: <tr><td>End Time    </td><td> $displayable_endtime   </td></tr>
 1133: </table>
 1134: <p>
 1135: END
 1136:     #
 1137:     # Send request(s) to modify data
 1138:     my $roleresults = &Apache::lonnet::modifystudent
 1139:         ($sdom,$slogin,$sid,undef,undef,$firstname,$middlename,$lastname,
 1140:          $generation,$section,$endtime,$starttime,$ENV{'form.forceid'});
 1141:     if ($roleresults eq 'refused' ) {
 1142:         $r->print("Your request to change the role information for this ".
 1143:                   "student was refused.  You do not appear to have ".
 1144:                   "sufficient authority to change student information.");
 1145:     } elsif ($roleresults !~ /ok/) {
 1146:         $r->print("An error occurred during the attempt to change the role".
 1147:                   " information for this student.  <br />".
 1148:                   "The error reported was ".
 1149:                   $roleresults);
 1150:         &Apache::lonnet::logthis("londropadd:failed attempt to modify student".
 1151:                                  " data for ".$slogin." \@ ".$sdom." by ".
 1152:                                  $ENV{'user.name'}." \@ ".$ENV{'user.domain'}.
 1153:                                  ":".$roleresults);
 1154:     } else { # everything is okay!
 1155:         $r->print("Student information updated successfully. <br />".
 1156:                   "The student must log out and log in again to see ".
 1157:                   "these changes.");
 1158:     }
 1159:     $r->print(<<END);
 1160: </p><p>
 1161: <input type="hidden" name="action" value="modifystudent" />
 1162: <input type="hidden" name="sortby" value="$sortby" />
 1163: <input type="hidden" name="Status" value="$status" />
 1164: <a href="javascript:document.studentform.submit();">Modify another students data</a>
 1165: </body></html>
 1166: END
 1167:     return;
 1168: }
 1169: 
 1170: sub get_enrollment_data {
 1171:     my ($sname,$sdomain) = @_;
 1172:     my $courseid = $ENV{'request.course.id'};
 1173:     $courseid =~ s:_:/:g;
 1174:     my %roles = &Apache::lonnet::dump('roles',$sdomain,$sname);
 1175:     my ($tmp) = keys(%roles);
 1176:     # Bail out if we were unable to get the students roles
 1177:     return "666" if ($tmp =~ /^(con_lost|error|no_such_host)/i);
 1178:     # Go through the roles looking for enrollment in this course
 1179:     my ($end,$start) = (undef,undef);
 1180:     my $section = '';
 1181:     my $count = scalar(keys(%roles));
 1182:     while (my ($course,$role) = each(%roles)) {
 1183:         &Apache::lonnet::logthis('course = '.$course.' role = '.$role);
 1184:         if ($course=~ /^\/$courseid\/*\s*(\w+)*_st$/ ) {
 1185:             #
 1186:             # Get active role
 1187:             $section=$1;
 1188:             (undef,$end,$start)=split(/\_/,$role);
 1189:             my $now=time;
 1190:             my $notactive=0;
 1191:             if ($start) {
 1192:                 if ($now<$start) { $notactive=1; }
 1193:             }
 1194:             if ($end) {
 1195:                 if ($now>$end) { $notactive=1; }
 1196:             } 
 1197:             unless ($notactive) { return ($start,$end,$section); }
 1198:         }
 1199:     }
 1200:     return ($start,$end,$section);
 1201: }
 1202: 
 1203: #################################################
 1204: #################################################
 1205: 
 1206: =pod
 1207: 
 1208: =item show_drop_list
 1209: 
 1210: Display a list of students to drop
 1211: Inputs: 
 1212: 
 1213: =over 4
 1214: 
 1215: =item $r, Apache request
 1216: 
 1217: =item $classlist, hash pointer returned from loncoursedata::get_classlist();
 1218: 
 1219: =item $keylist, array pointer returned from loncoursedata::get_classlist() 
 1220: which describes the order elements are stored in the %$classlist values.
 1221: 
 1222: =item $nosort, if true, sorting links are omitted.
 1223: 
 1224: =back
 1225: 
 1226: =cut
 1227: 
 1228: #################################################
 1229: #################################################
 1230: sub show_drop_list {
 1231:     my ($r,$classlist,$keylist,$nosort)=@_;
 1232:     my $cid=$ENV{'request.course.id'};
 1233:     if (! exists($ENV{'form.sortby'})) {
 1234:         &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
 1235:                                                 ['sortby']);
 1236:     }
 1237:     my $sortby = $ENV{'form.sortby'};
 1238:     if ($sortby !~ /^(username|domain|section|fullname|id)$/) {
 1239:         $sortby = 'username';
 1240:     }
 1241:     #
 1242:     my $action = "drop";
 1243:     $r->print(<<END);
 1244: <input type="hidden" name="sortby" value="$sortby" />
 1245: <input type="hidden" name="action" value="$action" />
 1246: <input type="hidden" name="state"  value="done" />
 1247: <script>
 1248: function checkAll(field) {
 1249:     for (i = 0; i < field.length; i++)
 1250:         field[i].checked = true ;
 1251: }
 1252: 
 1253: function uncheckAll(field) {
 1254:     for (i = 0; i < field.length; i++)
 1255:         field[i].checked = false ;
 1256: }
 1257: </script>
 1258: <p>
 1259: <input type="hidden" name="phase" value="four">
 1260: END
 1261: 
 1262:     if ($nosort) {
 1263:         $r->print(<<END);
 1264: <table border=2>
 1265: <tr>
 1266:     <th>&nbsp;</th>
 1267:     <th>username</th>
 1268:     <th>domain</th>
 1269:     <th>ID</th>
 1270:     <th>student name</th>
 1271:     <th>section</th>
 1272: </tr>
 1273: END
 1274: 
 1275:     } else  {
 1276:         $r->print(<<END);
 1277: <table border=2>
 1278: <tr><th>&nbsp;</th>
 1279:     <th>
 1280:        <a href="/adm/dropadd?action=$action&sortby=username">username</a>
 1281:     </th><th>
 1282:        <a href="/adm/dropadd?action=$action&sortby=domain">domain</a>
 1283:     </th><th>
 1284:        <a href="/adm/dropadd?action=$action&sortby=id">ID</a>
 1285:     </th><th>
 1286:        <a href="/adm/dropadd?action=$action&sortby=fullname">student name</a>
 1287:     </th><th>
 1288:        <a href="/adm/dropadd?action=$action&sortby=section">section</a>
 1289:     </th>
 1290: </tr>
 1291: END
 1292:     }
 1293:     #
 1294:     # Sort the students
 1295:     my %index;
 1296:     my $i;
 1297:     foreach (@$keylist) {
 1298:         $index{$_} = $i++;
 1299:     }
 1300:     my $index  = $index{$sortby};
 1301:     my $second = $index{'username'};
 1302:     my $third  = $index{'domain'};
 1303:     my @Sorted_Students = sort {
 1304:         lc($classlist->{$a}->[$index])  cmp lc($classlist->{$b}->[$index])
 1305:             ||
 1306:         lc($classlist->{$a}->[$second]) cmp lc($classlist->{$b}->[$second])
 1307:             ||
 1308:         lc($classlist->{$a}->[$third]) cmp lc($classlist->{$b}->[$third])
 1309:         } (keys(%$classlist));
 1310:     foreach my $student (@Sorted_Students) {
 1311:         my $error;
 1312:         my $username = $classlist->{$student}->[$index{'username'}];
 1313:         my $domain   = $classlist->{$student}->[$index{'domain'}];
 1314:         my $section  = $classlist->{$student}->[$index{'section'}];
 1315:         my $name     = $classlist->{$student}->[$index{'fullname'}];
 1316:         my $id       = $classlist->{$student}->[$index{'id'}];
 1317:         my $status   = $classlist->{$student}->[$index{'status'}];
 1318:         next if ($status ne 'Active');
 1319:         #
 1320:         $r->print(<<"END");
 1321: <tr>
 1322:     <td><input type="checkbox" name="droplist" value="$student"></td>
 1323:     <td>$username</td>
 1324:     <td>$domain</td>
 1325:     <td>$id</td>
 1326:     <td>$name</td>
 1327:     <td>$section</td>
 1328: </tr>
 1329: END
 1330:     }
 1331:     $r->print('</table><br>');
 1332:     $r->print(<<"END");
 1333: </p><p>
 1334: <input type="button" value="check all" onclick="javascript:checkAll(document.studentform.droplist)"> &nbsp;
 1335: <input type="button" value="uncheck all" onclick="javascript:uncheckAll(document.studentform.droplist)"> 
 1336: <p><input type=submit value="Drop Students"></p>
 1337: END
 1338:     return;
 1339: }
 1340: 
 1341: #
 1342: # Print out the initial form to get the courselist file
 1343: #
 1344: sub print_first_courselist_upload_form {
 1345:     my $r=shift;
 1346:     my $upfile_select=&Apache::loncommon::upfile_select_html();
 1347:     my $create_classlist_help = 
 1348: 	&Apache::loncommon::help_open_topic("Course_Create_Class_List",
 1349:            "How do I create a class list from a spreadsheet");
 1350:     my $create_csv_help =
 1351: 	&Apache::loncommon::help_open_topic("Course_Convert_To_CSV",
 1352:            "How do I create a CSV file from a spreadsheet");
 1353:     $r->print(<<ENDUPFORM);
 1354: <input type=hidden name=phase value=two>
 1355: <h3>Upload a courselist</h3>
 1356: $upfile_select
 1357: <p>
 1358: <input type=submit name="fileupload" value="Upload Courselist">
 1359: <input type="hidden" name="action" value="upload" />
 1360: <input type="hidden" name="state"  value="got_file" />
 1361: </p>
 1362: $create_classlist_help <br />
 1363: $create_csv_help
 1364: </body></html>
 1365: ENDUPFORM
 1366:     return;
 1367: }
 1368: 
 1369: # ================================================= Drop/Add from uploaded file
 1370: sub upfile_drop_add {
 1371:     my $r=shift;
 1372:     &Apache::loncommon::load_tmp_file($r);
 1373:     my @studentdata=&Apache::loncommon::upfile_record_sep();
 1374:     my @keyfields = split(/\,/,$ENV{'form.keyfields'});
 1375:     my $cid = $ENV{'request.course.id'};
 1376:     my %fields=();
 1377:     for (my $i=0; $i<=$ENV{'form.nfields'}; $i++) {
 1378:         if ($ENV{'form.upfile_associate'} eq 'reverse') {
 1379:             if ($ENV{'form.f'.$i} ne 'none') {
 1380:                 $fields{$keyfields[$i]}=$ENV{'form.f'.$i};
 1381:             }
 1382:         } else {
 1383:             $fields{$ENV{'form.f'.$i}}=$keyfields[$i];
 1384:         }
 1385:     }
 1386:     #
 1387:     my $startdate = $ENV{'form.startdate'};
 1388:     my $enddate   = $ENV{'form.enddate'};
 1389:     if ($startdate=~/\D/) { $startdate=''; }
 1390:     if ($enddate=~/\D/)   { $enddate=''; }
 1391:     # Determine domain and desired host (home server)
 1392:     my $domain=$ENV{'form.lcdomain'};
 1393:     my $desiredhost = $ENV{'form.lcserver'};
 1394:     if (lc($desiredhost) eq 'default') {
 1395:         $desiredhost = undef;
 1396:     } else {
 1397:         my %home_servers = &Apache::loncommon::get_library_servers($domain);
 1398:         if (! exists($home_servers{$desiredhost})) {
 1399:             $r->print('<font color="#ff0000">Error:</font>'.
 1400:                       'Invalid home server specified');
 1401:             return;
 1402:         }
 1403:     }
 1404:     # Determine authentication mechanism
 1405:     my $amode  = '';
 1406:     my $genpwd = '';
 1407:     if ($ENV{'form.login'} eq 'krb') {
 1408:         $amode='krb';
 1409: 	$amode.=$ENV{'form.krbver'};
 1410:         $genpwd=$ENV{'form.krbarg'};
 1411:     } elsif ($ENV{'form.login'} eq 'int') {
 1412:         $amode='internal';
 1413:         if ((defined($ENV{'form.intarg'})) && ($ENV{'form.intarg'})) {
 1414:             $genpwd=$ENV{'form.intarg'};
 1415:         }
 1416:     } elsif ($ENV{'form.login'} eq 'loc') {
 1417:         $amode='localauth';
 1418:         if ((defined($ENV{'form.locarg'})) && ($ENV{'form.locarg'})) {
 1419:             $genpwd=$ENV{'form.locarg'};
 1420:         }
 1421:     }
 1422:     unless (($domain=~/\W/) || ($amode eq '')) {
 1423:         #######################################
 1424:         ##         Enroll Students           ##
 1425:         #######################################
 1426:         $r->print('<h3>Enrolling Students</h3>');
 1427:         my $count=0;
 1428:         my $flushc=0;
 1429:         my %student=();
 1430:         # Get new classlist
 1431:         foreach (@studentdata) {
 1432:             my %entries=&Apache::loncommon::record_sep($_);
 1433:             # Determine student name
 1434:             unless (($entries{$fields{'username'}} eq '') ||
 1435:                     (!defined($entries{$fields{'username'}}))) {
 1436:                 my ($fname, $mname, $lname,$gen) = ('','','','');
 1437:                 if (defined($fields{'names'})) {
 1438:                     ($lname,$fname,$mname)=($entries{$fields{'names'}}=~
 1439:                                             /([^\,]+)\,\s*(\w+)\s*(.*)$/);
 1440:                 } else {
 1441:                     if (defined($fields{'fname'})) {
 1442:                         $fname=$entries{$fields{'fname'}};
 1443:                     }
 1444:                     if (defined($fields{'mname'})) {
 1445:                         $mname=$entries{$fields{'mname'}};
 1446:                     }
 1447:                     if (defined($fields{'lname'})) {
 1448:                         $lname=$entries{$fields{'lname'}};
 1449:                     }
 1450:                     if (defined($fields{'gen'})) {
 1451:                         $gen=$entries{$fields{'gen'}};
 1452:                     }
 1453:                 }
 1454:                 if ($entries{$fields{'username'}}=~/\W/) {
 1455:                     $r->print('<p><b>Unacceptable username: '.
 1456:                               $entries{$fields{'username'}}.' for user '.
 1457:                               $fname.' '.$mname.' '.$lname.' '.$gen.'</b><p>');
 1458:                 } else {
 1459:                     # determine section number
 1460:                     my $sec='';
 1461:                     my $username=$entries{$fields{'username'}};
 1462:                     if (defined($fields{'sec'})) {
 1463:                         if (defined($entries{$fields{'sec'}})) {
 1464:                             $sec=$entries{$fields{'sec'}};
 1465:                         }
 1466:                     }
 1467:                     # determine student id number
 1468:                     my $id='';
 1469:                     if (defined($fields{'id'})) {
 1470:                         if (defined($entries{$fields{'id'}})) {
 1471:                             $id=$entries{$fields{'id'}};
 1472:                         }
 1473:                         $id=~tr/A-Z/a-z/;
 1474:                     }
 1475:                     # determine student password
 1476:                     my $password='';
 1477:                     if ($genpwd) { 
 1478:                         $password=$genpwd; 
 1479:                     } else {
 1480:                         if (defined($fields{'ipwd'})) {
 1481:                             if ($entries{$fields{'ipwd'}}) {
 1482:                                 $password=$entries{$fields{'ipwd'}};
 1483:                             }
 1484:                         }
 1485:                     }
 1486:                     # Clean up whitespace
 1487:                     foreach (\$domain,\$username,\$id,\$fname,\$mname,
 1488:                              \$lname,\$gen,\$sec) {
 1489:                         $$_ =~ s/(\s+$|^\s+)//g;
 1490:                     }
 1491:                     if ($password) {
 1492:                         &modifystudent($domain,$username,$cid,$sec,
 1493:                                        $desiredhost);
 1494:                         my $reply=&Apache::lonnet::modifystudent
 1495:                             ($domain,$username,$id,$amode,$password,
 1496:                              $fname,$mname,$lname,$gen,$sec,$enddate,
 1497:                              $startdate,$ENV{'form.forceid'},$desiredhost);
 1498:                         if ($reply ne 'ok') {
 1499:                             $r->print('<p><b>'.
 1500:                                       'Error enrolling '.$username.': '.
 1501:                                       $reply.'</b></p>');
 1502:          		} else {
 1503:                             $count++; $flushc++;
 1504:                             $student{$username}=1;
 1505:                             $r->print('. ');
 1506:                             if ($flushc>15) {
 1507: 				$r->rflush;
 1508:                                 $flushc=0;
 1509:                             }
 1510:                         }
 1511:                     } else {
 1512:                         $r->print("<p><b>No password for $username</b><p>");
 1513:                     }
 1514:                 }
 1515:             }
 1516:         } # end of foreach (@studentdata)
 1517:         $r->print('<p>Processed Students: '.$count.'</p>');
 1518:         $r->print("<p>If active, the new role will be available when the ".
 1519:                   "students next log in to LON-CAPA.</p>");
 1520:         #####################################
 1521:         #           Drop students           #
 1522:         #####################################
 1523:         if ($ENV{'form.fullup'} eq 'yes') {
 1524:             $r->print('<h3>Dropping Students</h3>');
 1525:             #  Get current classlist
 1526:             my ($classlist,$keylist)=&Apache::loncoursedata::get_classlist();
 1527:             if (! defined($classlist)) {
 1528:                 $r->print("There are no students currently enrolled.\n");
 1529:             } else {
 1530:                 # Remove the students we just added from the list of students.
 1531:                 foreach (@studentdata) {
 1532:                     my %entries=&Apache::loncommon::record_sep($_);
 1533:                     unless (($entries{$fields{'username'}} eq '') ||
 1534:                             (!defined($entries{$fields{'username'}}))) {
 1535:                         delete($classlist->{$entries{$fields{'username'}}.
 1536:                                                 ':'.$domain});
 1537:                     }
 1538:                 }
 1539:                 # Print out list of dropped students.
 1540:                 &show_drop_list($r,$classlist,$keylist,'nosort');
 1541:             }
 1542:         }
 1543:     } # end of unless
 1544: }
 1545: 
 1546: # ================================================================== Phase four
 1547: sub drop_student_list {
 1548:     my $r=shift;
 1549:     my $count=0;
 1550:     my @droplist;
 1551:     if (ref($ENV{'form.droplist'})) {
 1552:         @droplist = @{$ENV{'form.droplist'}};
 1553:     } else {
 1554:         @droplist = ($ENV{'form.droplist'});
 1555:     }
 1556:     foreach (@droplist) {
 1557:         my ($uname,$udom)=split(/\:/,$_);
 1558:         # drop student
 1559:         my $result = &modifystudent($udom,$uname,$ENV{'request.course.id'});
 1560:         if ($result eq 'ok' || $result eq 'ok:') {
 1561:             $r->print('Dropped '.$uname.' @ '.$udom.'<br>');
 1562:             $count++;
 1563:         } else {
 1564:             $r->print('Error dropping '.$uname.' @ '.$udom.': '.$result.
 1565:                       '<br />');
 1566:         }
 1567:     }
 1568:     $r->print('<p><b>Dropped '.$count.' student(s).</b>');
 1569:     $r->print('<p>Re-enrollment will re-activate data.') if ($count);
 1570: }
 1571: 
 1572: ###################################################################
 1573: ###################################################################
 1574: 
 1575: =pod
 1576: 
 1577: =item &handler
 1578: 
 1579: The typical handler you see in all these modules.  Takes $r, the
 1580: http request, as an argument.  
 1581: 
 1582: The response to the request is governed by two form variables
 1583: 
 1584:  form.action      form.state     response
 1585:  ---------------------------------------------------
 1586:  undefined        undefined      print main menu
 1587:  upload           undefined      print courselist upload menu
 1588:  upload           got_file       deal with uploaded file,
 1589:                                  print the upload managing menu
 1590:  upload           enrolling      enroll students based on upload
 1591:  drop             undefined      print the classlist ready to drop
 1592:  drop             done           drop the selected students
 1593:  enrollstudent    undefined      print single student enroll menu
 1594:  enrollstudent    enrolling      enroll student
 1595:  classlist        undefined      print html classlist
 1596:  classlist        csv            print csv classlist
 1597:  modifystudent    undefined      print classlist to select student to modify
 1598:  modifystudent    selected       print modify student menu
 1599:  modifystudent    done           make modifications to student record
 1600: 
 1601: =cut
 1602: 
 1603: ###################################################################
 1604: ###################################################################
 1605: sub handler {
 1606:     my $r=shift;
 1607:     if ($r->header_only) {
 1608:         $r->content_type('text/html');
 1609:         $r->send_http_header;
 1610:         return OK;
 1611:     }
 1612:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
 1613:                                             ['action','state']);
 1614:     #  Needs to be in a course
 1615:     if (! (($ENV{'request.course.fn'}) &&
 1616:           (&Apache::lonnet::allowed('cst',$ENV{'request.course.id'})))) {
 1617:         # Not in a course, or not allowed to modify parms
 1618:         $ENV{'user.error.msg'}=
 1619:             "/adm/dropadd:cst:0:0:Cannot drop or add students";
 1620:         return HTTP_NOT_ACCEPTABLE; 
 1621:     }
 1622:     #
 1623:     # Only output the header information if they did not request csv format
 1624:     #
 1625:     if (exists($ENV{'form.state'}) && ($ENV{'form.state'} eq 'csv')) {
 1626:         $r->content_type('text/csv');
 1627:     } else {
 1628:         # Start page
 1629:         $r->content_type('text/html');
 1630:         $r->send_http_header;
 1631:         $r->print(&header());
 1632:     }
 1633:     #
 1634:     # Main switch on form.action and form.state, as appropriate
 1635:     if (! exists($ENV{'form.action'})) {
 1636:         &print_main_menu($r);
 1637:     } elsif ($ENV{'form.action'} eq 'upload') {
 1638:         if (! exists($ENV{'form.state'})) {
 1639:             &print_first_courselist_upload_form($r);            
 1640:         } elsif ($ENV{'form.state'} eq 'got_file') {
 1641:             &print_upload_manager_form($r);
 1642:         } elsif ($ENV{'form.state'} eq 'enrolling') {
 1643:             if ($ENV{'form.datatoken'}) {
 1644:                 &upfile_drop_add($r);
 1645:             } else {
 1646:                 # Hmmm, this is an error
 1647:             }
 1648:         } else {
 1649:             &print_first_courselist_upload_form($r);            
 1650:         }
 1651:     } elsif ($ENV{'form.action'} eq 'drop') {
 1652:         if (! exists($ENV{'form.state'})) {
 1653:             &print_drop_menu($r);
 1654:         } elsif ($ENV{'form.state'} eq 'done') {
 1655:             &drop_student_list($r);
 1656:         } else {
 1657:             &print_drop_menu($r);
 1658:         }
 1659:     } elsif ($ENV{'form.action'} eq 'enrollstudent') {
 1660:         if (! exists($ENV{'form.state'})) {
 1661:             &print_enroll_single_student_form($r);
 1662:         } elsif ($ENV{'form.state'} eq 'enrolling') {
 1663:             &enroll_single_student($r);
 1664:         } else {
 1665:             &print_enroll_single_student_form($r);
 1666:         }
 1667:     } elsif ($ENV{'form.action'} eq 'classlist') {
 1668:         if (! exists($ENV{'form.state'})) {
 1669:             &print_html_classlist($r);
 1670:         } elsif ($ENV{'form.state'} eq 'csv') {
 1671:             &print_formatted_classlist($r,'csv');
 1672:         } elsif ($ENV{'form.state'} eq 'excel') {
 1673:             &print_formatted_classlist($r,'excel');
 1674:         } else {
 1675:             &print_html_classlist($r);
 1676:         }
 1677:     } elsif ($ENV{'form.action'} eq 'modifystudent') {
 1678:         if (! exists($ENV{'form.state'})) {
 1679:             &print_html_classlist($r);
 1680:         } elsif ($ENV{'form.state'} eq 'selected') {
 1681:             &print_modify_student_form($r);
 1682:         } elsif ($ENV{'form.state'} eq 'done') {
 1683:             &modify_single_student($r);
 1684:         } else {
 1685:             &print_html_classlist($r);
 1686:         }        
 1687:     } else {
 1688:         # We should not end up here, but I guess it is possible
 1689:         &Apache::lonnet::logthis("Undetermined state in londropadd.pm.  ".
 1690:                                  "form.action = ".$ENV{'form.action'}.
 1691:                                  "Someone should fix this.");
 1692:         &print_main_menu($r);
 1693:     }
 1694:     #
 1695:     # Finish up
 1696:     if (exists($ENV{'form.state'}) && ($ENV{'form.state'} eq 'csv')) {
 1697:         $r->print("\n");
 1698:     } else {
 1699:         $r->print('</form></body></html>');
 1700:     }
 1701:     return OK;
 1702: }
 1703: 
 1704: ###################################################################
 1705: ###################################################################
 1706: 
 1707: 1;
 1708: __END__
 1709: 
 1710: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>