Annotation of loncom/interface/londropadd.pm, revision 1.52

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

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