Annotation of loncom/interface/lonpopulate.pm, revision 1.20

1.4       albertel    1: # automated enrollment configuration handler
1.20    ! raeburn     2: # $Id: lonpopulate.pm,v 1.19 2004/08/23 16:53:06 raeburn Exp $
1.4       albertel    3: #
                      4: # Copyright Michigan State University Board of Trustees
                      5: #
                      6: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
                      7: #
                      8: # LON-CAPA is free software; you can redistribute it and/or modify
                      9: # it under the terms of the GNU General Public License as published by
                     10: # the Free Software Foundation; either version 2 of the License, or
                     11: # (at your option) any later version.
                     12: #
                     13: # LON-CAPA is distributed in the hope that it will be useful,
                     14: # but WITHOUT ANY WARRANTY; without even the implied warranty of
                     15: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     16: # GNU General Public License for more details.
                     17: #
                     18: # You should have received a copy of the GNU General Public License
                     19: # along with LON-CAPA; if not, write to the Free Software
                     20: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
                     21: #
                     22: # /home/httpd/html/adm/gpl.txt
                     23: #
                     24: # http://www.lon-capa.org/
                     25: #
1.1       raeburn    26: package Apache::lonpopulate;
                     27: 
                     28: use strict;
                     29: use lib qw(/home/httpd/lib/perl);
1.7       raeburn    30: use Apache::lonnet;
                     31: use Apache::loncommon;
                     32: use Apache::lonhtmlcommon;
1.3       albertel   33: use Apache::lonlocal;
1.14      raeburn    34: use Apache::loncoursedata;
1.1       raeburn    35: use Apache::Constants qw(:common :http REDIRECT);
                     36: use Time::Local;
1.7       raeburn    37: use LONCAPA::Enrollment;
1.1       raeburn    38: 
                     39: ###############################################################
                     40: sub header {
                     41:     my $bodytag=&Apache::loncommon::bodytag('Classlist Manager');
                     42:     return(<<ENDHEAD);
                     43: <html>
                     44: <head>
                     45: <title>LON-CAPA Classlist Manager</title>
                     46: </head>
                     47: $bodytag
                     48: ENDHEAD
                     49: }
                     50: 
                     51: ###############################################################
                     52: 
                     53: sub choose_header {
1.16      raeburn    54:     my $action = shift;
1.1       raeburn    55:     my $bodytag=&Apache::loncommon::bodytag('Classlist Manager');
                     56:     my $scripttag = qq|
                     57: <script language='javascript' type='text/javascript'>
                     58: <!--
1.16      raeburn    59: function process(calling,numauto,nummanual,numlock,numunlock) {
1.1       raeburn    60:  var checker = 1
                     61:  var rad1 = 0
                     62:  var rad2 = 0
                     63:  var formName = document.forms.enter
1.14      raeburn    64:  if (calling == "viewclass") {
                     65:      formName = document.forms.studentform
                     66:  }
1.1       raeburn    67:  formName.action.value = calling
                     68:  if (calling == "chgsettings") {
                     69:    for (var j=0; j<formName.autoadds.length; j++) {
                     70:        if (formName.autoadds[j].checked) {
                     71:            rad1 = 1
                     72:        }
                     73:    }
                     74:    for (var k=0; k<formName.autodrops.length; k++) {
                     75:        if (formName.autodrops[k].checked) {
                     76:            rad2 = 1
                     77:        }
                     78:    }
                     79:    if (rad1 == 0) {
1.17      raeburn    80:        alert("You must select either 'Enable' or 'Disable' for nightly additions based on classlist changes")
1.1       raeburn    81:        checker = 0
                     82:    }
                     83:    if (rad2 == 0) {
1.17      raeburn    84:        alert("You must select either 'Enable' or 'Disable' for nightly removals based on classlist changes")
1.1       raeburn    85:        checker = 0
                     86:    }
                     87:  }
                     88:  if (calling == "updatenow") {
                     89:      var enrolldis
                     90:      var unenrolldis
                     91:      for (var j=0; j<formName.updateadds.length; j++) {
                     92:          if (formName.updateadds[j].value == 0) {
                     93:              enrolldis = j
                     94:          }
                     95:          if (formName.updateadds[j].checked) {
                     96:              rad1 = 1
                     97:          }
                     98:      }
                     99:      for (var k=0; k<formName.updatedrops.length; k++) {
                    100:          if (formName.updatedrops[k].value == 0) {
                    101:              unenrolldis = k 
                    102:          }
                    103:          if (formName.updatedrops[k].checked) {
                    104:              rad2 = 1
                    105:          }
                    106:      }
                    107:      if (rad1 == 0) {
1.17      raeburn   108:          alert("You must select either 'Yes' or 'No' for immediate addition of newly registered students to the roster")
1.1       raeburn   109:          checker = 0
                    110:      }
                    111:      if (rad2 == 0) {
1.17      raeburn   112:          alert("You must select either 'Yes' or 'No' for immediate removal of unregistered students from the roster")
1.1       raeburn   113:          checker = 0
                    114:      }
                    115:      if (formName.updatedrops[unenrolldis].checked && formName.updateadds[enrolldis].checked ) {
1.17      raeburn   116:          alert("You have selected 'No' for both addition and removal of students\\n in the Registrar's classlist but not in your LON-CAPA course.  \\nHence there is no update to carry out")
1.1       raeburn   117:          checker = 0
                    118:      }
                    119:  }
1.14      raeburn   120:  if (calling == "viewclass") {
1.16      raeburn   121:      var totcheck = 0
1.20    ! raeburn   122:      var numchk = 0
1.16      raeburn   123:      if (numauto > 0) {
1.20    ! raeburn   124:          numchk = countChecked(document.studentform.chgauto);
        !           125:          totcheck = totcheck + numchk
1.16      raeburn   126:      }
                    127:      if (nummanual > 0) {
1.20    ! raeburn   128:          numchk = countChecked(document.studentform.chgmanual);
        !           129:          totcheck = totcheck + numchk
1.16      raeburn   130:      }
                    131:      if (numlock > 0) {
1.20    ! raeburn   132:          numchk = countChecked(document.studentform.lockchg);
        !           133:          totcheck = totcheck + numchk
1.16      raeburn   134:      }
                    135:      if (numunlock > 0) {
1.20    ! raeburn   136:          numchk = countChecked(document.studentform.unlockchg);
        !           137:          totcheck = totcheck + numchk
1.16      raeburn   138:      }
                    139:      if (totcheck > 0) {
1.20    ! raeburn   140:         document.forms.studentform.state.value = "process";
        !           141:      }
        !           142:      if (totcheck == 0) {
1.16      raeburn   143:         alert("You must check at least one checkbox, before proceeding to the next page")
                    144:         checker = 0
                    145:      }
1.14      raeburn   146:  } 
1.1       raeburn   147:  if (checker == 1) {  
                    148:      formName.submit();
                    149:  }
                    150: }
1.16      raeburn   151: |;
                    152:     if ($action eq 'viewclass') {
                    153:         $scripttag .= qq|
                    154: function checkAll(field) {
1.20    ! raeburn   155:     if (field.length > 0) {
        !           156:         for (i = 0; i < field.length; i++) {
        !           157:             field[i].checked = true ;
        !           158:         }
        !           159:     } else {
        !           160:         field.checked = true
        !           161:     }
1.16      raeburn   162: }
                    163: 
                    164: function uncheckAll(field) {
1.20    ! raeburn   165:     if (field.length > 0) {
        !           166:         for (i = 0; i < field.length; i++) {
        !           167:             field[i].checked = false ;
        !           168:         }
        !           169:     } else {
        !           170:         field.checked = false ;
        !           171:     }
1.16      raeburn   172: }
1.20    ! raeburn   173: 
        !           174: function countChecked(field) {
        !           175:     var count = 0;
        !           176:     if (field.length > 0) {
        !           177:         for (var i=0; i<field.length; i++) {
        !           178:             if (field[i].checked == true) {
        !           179:                 count ++
        !           180:             }
        !           181:         }
        !           182:     } else {
        !           183:         if (field.checked == true) {
        !           184:             count ++
        !           185:         }
        !           186:     }
        !           187:     return count
        !           188: }
        !           189: 
1.16      raeburn   190: |;
                    191:     }
                    192:     $scripttag .= qq|
1.1       raeburn   193: // End hiding -->
                    194: </script>
                    195: |;
                    196:     return(<<ENDHEAD);
                    197: <html>
                    198: <head>
                    199: <title>LON-CAPA Classlist Manager</title>
                    200: $scripttag
                    201: $bodytag
                    202: ENDHEAD
                    203: }
                    204: 
                    205: sub print_mainbox {
                    206:     my ($r,$tasklongref,$realm,$reply) = @_;
                    207:     my $action = "information";
                    208:     if ( exists($ENV{'form.action'}) ) {
                    209:         $action = $ENV{'form.action'};
                    210:     }
                    211:     my $page = '';
                    212:     if ($action eq "information") {
                    213:         $page = "<b>Automated Enrollment</b>";
                    214:     } else {
                    215:         $page =  '<a href="/adm/populate">Automated Enrollment</a>';
                    216:         if ($reply) {
                    217:             if ($action eq "newcross") {
                    218:                 $action = "crosslist";
                    219:             } elsif ($action eq "newsections") {
                    220:                 $action = "sections"; 
                    221:             }
                    222:             $page .= "-&gt; <a href=\"/adm/populate?action=$action\">".$$tasklongref{$action}."</a> -&gt; <b>result</b>";
                    223:         } else {
                    224:             $page .=  " -&gt; <b>".$$tasklongref{$action}."</b>"; 
                    225:         }
                    226:     }
                    227:     $r->print(<<ENDTHIS);
                    228: <table width="100%" border="0" cellpadding="0" cellspacing="0">
                    229:  <tr>
                    230:   <td bgcolor="#CCCCFF"> 
                    231:    <font size="2"><a href="/adm/menu">$realm</a> -&gt; <a href="/adm/dropadd">Enrollment Manager</a> -&gt; $page</font><br/>
                    232:   </td>
                    233:   <td align="right" bgcolor="#CCCCFF" valign="top">
                    234:    <font size="+1">Automated Enrollment Manager&nbsp;</font>
                    235:   </td>
                    236:  </tr>
                    237: </table>
                    238: <table width="100%" border="0" cellpadding="0" cellspacing="0">
                    239:  <tr>
                    240: ENDTHIS
                    241: }
                    242: 
                    243: sub print_navmenu {
                    244:     my ($r,$tasksref,$tasklongref) = @_;
                    245:     my $action = "information";
                    246:     if (exists($ENV{'form.action'}) ) {
                    247:         $action = $ENV{'form.action'};
                    248:     }
                    249:     $r->print(<<ENDONE);
                    250:   <td width="10" valign="top" bgcolor="#DDFFFF">&nbsp;</td>
                    251:   <td width="20%" valign="top" bgcolor="#DDFFFF">
                    252:    <br/>
                    253: ENDONE
                    254:     foreach my $task (@{$tasksref}) {
                    255:         if ($task eq $action) {
                    256:             $r->print(" 
                    257:    <p>
                    258:    <font color=\"#999999\">
                    259:     <b>$$tasklongref{$task}</b><br/>
                    260:    </font>
                    261:    </p>"); 
                    262:         } else {
                    263:             $r->print("
                    264:    <p>
                    265:    <font color=\"#004263\">
                    266:     <b><a href=\"/adm/populate?action=$task\">$$tasklongref{$task}</a></b><br/>
                    267:    </font> 
                    268:    </p>");
                    269: 
                    270:         }
                    271:     }
                    272:     $r->print("
                    273:   <p>&nbsp;</p>
                    274:   </td>
                    275:   <td width=\"10\" valign=\"top\" bgcolor=\"#CCCCFF\">&nbsp;</td>
                    276:   <td width=\"10\" valign=\"top\" bgcolor=\"#FFFFFF\">&nbsp;</td>
                    277:   <td bgcolor=\"#ffffff\" valign=\"top\">");
                    278: }
                    279: 
                    280: ###############################################################
                    281: 
                    282: sub print_main_frame {
1.13      raeburn   283:   my ($r,$realm,$dom,$crs,$tasktitleref) = @_;
1.1       raeburn   284:   my $action = "information";
                    285:   if (exists($ENV{'form.action'}) ) {
                    286:       $action = $ENV{'form.action'};
                    287:   }
                    288: 
                    289: # Get course settings
                    290:   my %enrollvar;
                    291:   my @bgcolors=("#eeeeee","#cccccc");
                    292:   my %settings = &Apache::lonnet::dump('environment',$dom,$crs);
                    293:   foreach my $item (keys %settings) {
                    294:       if ($item =~ m/^internal\.(.+)$/) {
                    295:           $enrollvar{$1} = $settings{$item};
1.14      raeburn   296:       } elsif ($item =~ /^default_enrollment_(start|end)_date$/) {
                    297:           $enrollvar{$item} = $settings{$item};
1.1       raeburn   298:       }
                    299:   }
                    300: 
                    301:   if ($action eq "information") {
                    302:       $r->print(<<ENDONE);
1.2       raeburn   303:           <br/><table border='0' width='100%'>
1.1       raeburn   304:             <tr>
                    305:               <td>&nbsp;</td>
                    306:               <td><b>Use the menu on the left to choose an enrollment management task.</b><br/><br/></td>
                    307:             <tr>
                    308:               <td>&nbsp;</td>
1.16      raeburn   309:               <td>Use <i>"Automated adds/drops"</i> to enable or disable automatic nightly adds or drops in your LON-CAPA course based on institutional enrollment information.</td>
1.1       raeburn   310:             </tr>
                    311:             <tr>
                    312:               <td>&nbsp;</td>
                    313:               <td>Use <i>"Change enrollment dates"</i> to change the date of first automated enrollment and/or the date of last automated enrollment for registered students.</td>
                    314:             </tr>
                    315:             <tr>
                    316:               <td>&nbsp;</td>
1.14      raeburn   317:               <td>Use <i>"Change access dates"</i> to change the default start and/or end dates for student roles created by automated enrollment.</td>
                    318:             </tr>
                    319:             <tr>
                    320:               <td>&nbsp;</td>
1.1       raeburn   321:               <td>Use <i>"Notification of changes"</i> to enable or disable notification of enrollment changes and to add or remove course coordinators from the recipient list.</td>
                    322:             </tr>
                    323:             <tr>
                    324:               <td>&nbsp;</td>
                    325:               <td>Use <i>"Change crosslisting"</i> to include or exclude enrollment from crosslisted classes.</td>
                    326:             </tr>
                    327:             <tr>
                    328:               <td>&nbsp;</td>
                    329:               <td>Use <i>"Section settings"</i> to make changes to the choice of sections included for enrollment in your LON-CAPA course.</td>
                    330:             </tr>
                    331:               <td>&nbsp;</td>
1.2       raeburn   332:               <td>Use <i>"Student photos"</i> to enable or disable automatic upload of student photos to your course.</td>
1.1       raeburn   333:             </tr>
                    334:             <tr>
                    335:               <td>&nbsp;</td>
                    336:               <td>Use <i>"Update roster now"</i> to add and/or drop students from your course based on the <b>most current</b> institutional classlist information.</td>
                    337:             </tr>
                    338:             <tr>
1.16      raeburn   339:               <td>&nbsp;</td>
                    340:               <td>Use <i>"View students and change type"</i> to display the current course roster, and (optionally) change enrollment type for selected students from 'auto' to 'manual' and vice versa.</td>
                    341:             </tr>
                    342:             <tr>
1.1       raeburn   343:              <td colspan='2'>&nbsp;</td>
                    344:             </tr>
                    345:             <tr>
                    346:              <td>&nbsp;</td>
                    347:              <td><b>Note: if automated adds and/or drops are enabled, the nightly enrollment update will ONLY occur once the first enrollment date has been reached.</b></td>
                    348:             </tr>
                    349:           </table>
                    350: ENDONE
                    351:   } elsif ($action eq "chgsettings") {
                    352:       my @autosets = ("OFF","ON");
                    353:       $r->print(<<ENDTWO);
                    354:                   <form name="enter" method="post"><br/>
                    355: 		  <table width="100%" border="0" cellpadding="2" cellspacing="2">
                    356: 		   <tr>
                    357: 		    <td align="left"><b>$$tasktitleref{$action}</b><br/>
                    358: 		       Currently: Nightly adds: <i>$autosets[$enrollvar{autoadds}]</i>, Nightly drops: <i>$autosets[$enrollvar{autodrops}]</i>
                    359: 		    </td>
                    360:                    </tr>
                    361: 		  </table>
                    362: 		  <table width="100%" border="0" cellpadding="3" cellspacing="3">
                    363: 		    <tr>
                    364: 		     <td>
                    365: 		         Additions based on classlist changes:&nbsp;&nbsp;
                    366: ENDTWO
                    367:       if ($enrollvar{autoadds}) {
                    368:           $r->print("
                    369: 			    <input type=\"radio\" name=\"autoadds\" value=\"1\" checked=\"true\" />&nbsp;Enable&nbsp;&nbsp;&nbsp;
                    370: 			    <input type=\"radio\" name=\"autoadds\" value=\"0\" />&nbsp;Disable
                    371:          ");
                    372:       } else {
                    373:           $r->print("
                    374:                             <input type=\"radio\" name=\"autoadds\" value=\"1\" />&nbsp;Enable&nbsp;&nbsp;&nbsp;
                    375:                             <input type=\"radio\" name=\"autoadds\" value=\"0\" checked=\"true\" />&nbsp;Disable
                    376:          ");
                    377:       }
                    378:       $r->print("
                    379:               </td>
                    380:              </tr>
                    381:              <tr>
                    382:               <td>
                    383:  	       Removals based on classlist changes:&nbsp;&nbsp;");
                    384:       if ($enrollvar{autodrops}) {
                    385:           $r->print("
                    386:                 <input type=\"radio\" name=\"autodrops\" value=\"1\" checked=\"true\" />&nbsp;Enable&nbsp;&nbsp;&nbsp;
                    387:                 <input type=\"radio\" name=\"autodrops\" value=\"0\" />&nbsp;Disable");
                    388:       } else {
                    389:           $r->print("
                    390:                 <input type=\"radio\" name=\"autodrops\" value=\"1\" />&nbsp;Enable&nbsp;&nbsp;&nbsp;
                    391:                 <input type=\"radio\" name=\"autodrops\" value=\"0\" checked=\"true\" />&nbsp;Disable");
                    392:       }
                    393:       $r->print("
                    394:               </td>
                    395:              </tr>
                    396:              <tr>
                    397:               <td>
                    398:                <font color=\"#888888\">
                    399: Note: Any students added manually by course coordinators using the Enrollment Manager will be unaffected by the nightly removal process if you choose to enable it.
                    400:                </font>
                    401:               </td>
                    402:              </tr>
                    403:              <tr>
                    404:               <td align=\"right\">
                    405:                <input type=\"button\" name=\"chgsettings\" value=\"Go\" onClick=\"process('chgsettings')\" />
                    406: 	      </td>
                    407:              </tr>
                    408: 	    </table>
                    409:             <input type=\"hidden\" name=\"action\" value=\"$action\">
                    410:             <input type=\"hidden\" name=\"state\" value=\"process\">
                    411:             </form>
                    412:       ");
                    413:   } elsif ($action eq "setdates") {
1.14      raeburn   414:       my ($start_table,$end_table) = &date_setting_table($enrollvar{autostart},$enrollvar{autoend},$action);
1.10      raeburn   415:       my $oldstartshow = '';
                    416:       my $oldendshow = '';
                    417:       if ( defined($enrollvar{autostart}) ) {
1.14      raeburn   418:           $oldstartshow = &Apache::lonlocal::locallocaltime($enrollvar{autostart});
1.10      raeburn   419:       }
                    420:       if ( defined($enrollvar{autoend}) ) {
1.14      raeburn   421:           $oldendshow = &Apache::lonlocal::locallocaltime($enrollvar{autoend});
1.10      raeburn   422:           if ($enrollvar{autoend} == 0) {
                    423:               $oldendshow = "No ending date";
                    424:           }
                    425:       }
                    426:       my $dateshow;
                    427:       if ( ($oldendshow eq '') && ($oldstartshow eq '') ) {
1.14      raeburn   428:          $dateshow = "<br/><font size='+1'>Warning</font>. Currently <b>NO</b> first enrollment or last enrollment dates are set. You <b>must</b> use this menu to set a start date and an end date if you plan to utilise automated adds and/or drops in this course.\n";
1.10      raeburn   429:       } else {
                    430:          $dateshow = "Currently: First enrollment: <b><i>$oldstartshow</i></b>, Last enrollment: <b><i>$oldendshow</i></b>\n";
1.1       raeburn   431:       }
                    432:       $r->print(<<ENDTWO);
                    433:                   <form name="enter" method="post"><br/>              
                    434:                   <table width="100%" border="0" cellpadding="2" cellspacing="2">
                    435: 	           <tr>
1.10      raeburn   436: 	            <td align="left"><b>$$tasktitleref{$action}</b><br/><br/>
                    437:                      $dateshow
1.1       raeburn   438: 	            </td>
                    439:                    </tr>
                    440: 	          </table>
                    441:                   <table width="100%" border="0" cellpadding="3" cellspacing="3">
                    442:                    <tr>
                    443:                     <td align="left" colspan="2">
                    444:                      <table border="0" cellspacing="0" cellpadding="2">
                    445:                       <tr>
                    446:                        <td colspan="3">
                    447:                         <i>Set date of first automated enrollment for registered students</i>
                    448:                        </td>
                    449:                       </tr>
                    450:                       <tr>
                    451:                        <td>$start_table
                    452:                        </td>
                    453:                       </tr>
                    454:                      </table>
                    455:                     </td>
                    456:                    </tr>
                    457:                    <tr>
                    458:                     <td colspan="2"><font color="#888888">If automated adds and/or drops are enabled, then your class roster will be automatically updated nightly, once the first enrollment date has been reached. Prior to this date, the class roster will only contain students you have added directly using the standard LON-CAPA enrollment tools</font></td>
                    459:                    </tr>
                    460:                    <tr>
                    461:                     <td align="left" colspan="2">
                    462:                      <table border="0' cellspacing="0" cellpadding="2">
                    463:                       <tr>
                    464:                        <td colspan="3">
                    465:                         <i>Set date of last automated enrollment for registered students</i>
                    466:                        </td>
                    467:                       </tr>
                    468:                       <tr>
                    469:                        <td>$end_table
                    470:                        </td>
                    471:                       </tr>
                    472:                      </table>
                    473:                     </td>
                    474:                    </tr>
                    475:                    <tr>
                    476:                     <td colspan="2"><font color="#888888">If automated adds and/or drops are enabled, then your class roster will be automatically updated nightly, until the last enrollment date has been reached.</font></td>
                    477:                    </tr>
                    478:                   </table>
                    479:                   <table width="100%">
                    480:                    <tr>
                    481:                     <td align="right">
                    482:                       <input type="button" name="setdates" value="Go" onClick="process('setdates')" />
                    483:                     </td>
                    484: 	           </tr>
                    485:                   </table>
1.14      raeburn   486:                   <input type="hidden" name="action" value="$action">
                    487:                   <input type="hidden" name="state" value="process">
                    488:                   </form>
                    489: ENDTWO
                    490:   } elsif ($action eq "setaccess") {
                    491:       &print_accessdate_table($r,\%enrollvar,$tasktitleref,$action);
                    492:       $r->print(<<ENDTWO);
                    493:                   <table width="100%">
                    494:                    <tr>
                    495:                     <td align="right">
                    496:                       <input type="button" name="$action" value="Go" onClick="process('$action')" />
                    497:                     </td>
                    498:                    </tr>
                    499:                   </table>
                    500:                   <input type="hidden" name="action" value="$action">
                    501:                   <input type="hidden" name="state" value="process">
1.1       raeburn   502:                   </form>
                    503: ENDTWO
                    504:   } elsif ($action eq "notify") {
                    505:       my @notified = ();
                    506:       if ($enrollvar{notifylist} =~ m/,/) {
                    507:           @notified = split/,/,$enrollvar{notifylist};
                    508:       } else {
                    509:           @notified = $enrollvar{notifylist};
                    510:       }
                    511:       my $notifycount = 0;
                    512:       foreach  (@notified) {
                    513:         unless ($_ eq '') { $notifycount ++; } 
                    514:       }
                    515:       my $noteset = '';
                    516:       if ($notifycount) {
                    517:           $noteset = "ON";
                    518:       } else {
                    519:           $noteset = "OFF";
                    520:       }
                    521:     
                    522:       $r->print("
                    523:                   <form name=\"enter\" method=\"post\"><br/>
                    524:                    <table width=\"100%\" border=\"0\" cellpadding=\"6\" cellspacing=\"0\">
                    525:                     <tr>
                    526:                      <td align=\"left\"><b>$$tasktitleref{$action}</b><br/>
                    527:                       Currently: Notification: $noteset
                    528:                      </td>
                    529:                     </tr>
                    530:                    </table>
                    531:                    <table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
                    532:                     <tr>
                    533:                      <td>
                    534:                       Notification of LON-CAPA course roster changes resulting from nightly automated enrollment process?
                    535:       ");
                    536:       if ($notifycount) {
                    537:           $r->print("
                    538:                         <input type=\"radio\" name=\"notify\" value=\"1\" checked=\"true\" />&nbsp;Yes&nbsp;&nbsp;&nbsp;
                    539:                         <input type=\"radio\" name=\"notify\" value=\"0\" />&nbsp;No
                    540:           ");
                    541:       } else {
                    542:           $r->print("
                    543:                         <input type=\"radio\" name=\"notify\" value=\"1\" />&nbsp;Yes&nbsp;&nbsp;&nbsp;
                    544:                         <input type=\"radio\" name=\"notify\" value=\"0\" checked=\"true\" />&nbsp;No
                    545:           ");
                    546:       }
                    547:       $r->print("
                    548:               </td>
                    549:              </tr>
                    550:       ");
1.7       raeburn   551:       my @coursepersonnel = &Apache::lonnet::getkeys('nohist_userroles',$dom,$crs);
                    552:       my @ccs = ();
                    553:       my @oldccs = ();
                    554:       my %pname = ();
                    555:       my %notifystate = ();
                    556:       foreach (@coursepersonnel) {
                    557:           my @roleinfo = split/:/,$_;
                    558:           if ($roleinfo[0] eq 'cc')  {
                    559:               unless (grep/^$roleinfo[1]\@$roleinfo[2]/,@ccs) {
                    560:                   my $active_cc = &LONCAPA::Enrollment::check_user_status($roleinfo[2],$roleinfo[1],$dom,$crs,'cc');
                    561:                   if ($active_cc eq 'ok') {
                    562:                       push @ccs, "$roleinfo[1]\@$roleinfo[2]";
                    563:                       $pname{"$roleinfo[1]\@$roleinfo[2]"} = &Apache::loncommon::plainname($roleinfo[1],$roleinfo[2]);
                    564:                       if (grep/^$roleinfo[1]\@$roleinfo[2]$/,@notified) {
                    565:                           $notifystate{"$roleinfo[1]\@$roleinfo[2]"} = 1;
                    566:                       } else {
                    567:                           $notifystate{"$roleinfo[1]\@$roleinfo[2]"} = 0;
                    568:                       }
1.1       raeburn   569:                   } else {
1.7       raeburn   570:                       push @oldccs, "$roleinfo[1]\@$roleinfo[2]";
1.1       raeburn   571:                   }
                    572:               }
                    573:           }
                    574:       }
1.7       raeburn   575:       if ($notifycount > 0) {
                    576:           foreach my $person (@notified) {
                    577:               unless ( (grep/^$person$/,@ccs) || ($person eq '') || (grep/^$person$/,@oldccs) ) {
                    578:                   push @ccs, $person;
                    579:                   my ($puname,$pdom) = split/\@/,$person;
                    580:                   $pname{$person} =  &Apache::loncommon::plainname($puname,$pdom);
                    581:                   $notifystate{$person} = 1;
                    582:               }
                    583:           }
                    584:       }
                    585:       my $viewer = $ENV{'user.name'}.'@'.$ENV{'user.domain'};
                    586:       unless ( (grep/^$viewer$/,@ccs) || ($viewer eq '') )  {
                    587:           push @ccs,$viewer;
                    588:           $pname{$viewer} =  &Apache::loncommon::plainname($ENV{'user.name'},$ENV{'user.domain'});
                    589:           $notifystate{$viewer} = 0;
                    590:       }
                    591: 
                    592:       my $notifyshow = @ccs;
                    593: 
                    594:       if (@ccs > 0) {
                    595:           @ccs = sort @ccs;
1.1       raeburn   596:           $r->print("
                    597:              <tr>
1.7       raeburn   598:                <td>The table below contains a list of course coordinators in this course. Uncheck the 'Notification?' checkbox for each person who is to be removed from the list of recipients who are currently informed of roster changes whenever any adds or drops occur during the nightly enrollment check. To include individuals who are not currently recipients, simply check the 'Notification?' checkbox. Click 'Go' to store your changes.
1.1       raeburn   599:               </td>
                    600:              </tr>
                    601:              <tr>
                    602:               <td>
1.7       raeburn   603:                <table border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
                    604:                 <tr bgcolor=\"#CCCCFF\">
                    605:                  <td><b>Name</b></td>
                    606:                  <td><b>username</b></td>
                    607:                  <td><b>Current status</b></td>
                    608:                  <td><b>Notification?</b></td>
                    609:                 </tr>
                    610:           ");
                    611:           for (my $i=0; $i<@ccs; $i++) {
                    612:               my $colflag = $i%2;
                    613:               $r->print("<tr bgcolor=\"$bgcolors[$colflag]\" align=\"left\">
                    614:                  <td>$pname{$ccs[$i]}</td>
                    615:                  <td><input type=\"hidden\" name=\"notifyname_$i\" value=\"$ccs[$i]\" />$ccs[$i]</td>
                    616:                  <td>
                    617:               ");
                    618:               if ($notifystate{$ccs[$i]} == 1) {
                    619:                   $r->print("Notification active");
                    620:               } else {
                    621:                   $r->print("Notification inactive");
                    622:               }
                    623:               if ($notifystate{$ccs[$i]} == 1) {
                    624:                   $r->print("</td><td><input type=\"checkbox\" name=\"note_$i\" checked=\"true\" /></td></tr>");
                    625:               } else {
                    626:                   $r->print("</td><td><input type=\"checkbox\" name=\"note_$i\" /></td></tr>");
                    627:               }
                    628:           }
                    629:           $r->print("
                    630:                </table>
                    631:                <br/>
                    632:                <table width=\"100%\" border=\"0\" cellspadding=\"2\" cellspacing=\"2\">
                    633:                 <tr>
                    634:                  <td align=\"right\">
                    635:                   <input type=\"button\" name=\"notifyset\" value=\"Go\" onClick=\"process('notify')\" />
                    636:                  </td>
                    637:                 </tr>
                    638:                </table>
                    639:               </td>
                    640:              </tr>
1.1       raeburn   641:           ");
1.7       raeburn   642:       } else {
1.1       raeburn   643:           $r->print("
1.7       raeburn   644:              <tr>
                    645:               <td>
                    646:              No course coordinators found.
1.1       raeburn   647:             </td>
1.7       raeburn   648:            </tr>");
1.1       raeburn   649:       }
                    650:       $r->print("
1.7       raeburn   651:           </table>
                    652:           <input type=\"hidden\" name=\"notifyshow\" value=\"$notifyshow\">
                    653:           <input type=\"hidden\" name=\"action\" value=\"$action\">
                    654:           <input type=\"hidden\" name=\"state\" value=\"process\">
                    655:           </form>
1.1       raeburn   656:       ");
                    657:   } elsif ($action eq "crosslist") {
                    658:       my @xlists = ();
                    659:       if ($enrollvar{crosslistings} =~ m/,/) {
                    660:           @xlists = split/,/,$enrollvar{crosslistings};
                    661:       } elsif ($enrollvar{crosslistings} ne '') {
                    662:           $xlists[0] = $enrollvar{crosslistings};
                    663:       }
                    664:       my $cross_str = @xlists;
                    665:       $r->print("
                    666:             <form name=\"enter\" method=\"post\"><br/>
                    667:             <table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\">
                    668:              <tr>
                    669:               <td align=\"left\"><b>$$tasktitleref{$action}</b><br/>
                    670:       ");
                    671:       if ($cross_str > 0) {
                    672:           $r->print("
1.7       raeburn   673:                 Currently, this LON-CAPA course is crosslisted with $cross_str course section(s).  Students enrolling in these course sections will be automatically added to the class roster for the course, if you have chosen to enable a nightly automated enrollment update.  For each crosslisting, leave the checkbox checked if you want registered students in that course to be included in the student roster for LON-CAPA course: <b>$realm ($enrollvar{coursecode})</b>; otherwise uncheck it. If you wish to change the section/group ID assigned in your LON-CAPA course for a crosslisted course, enter the new section/group ID in the appropriate textbox. The LON-CAPA section/group ID can be left (or set to) empty, if you do not wish to tie a section/group ID to this crosslisting. If you wish to add new crosslisted courses, enter the number of new courses to add in the textbox at the bottom of the page. You will provide information about each of the new crosslistings on a subsequent page.  Click 'Go' to store your changes.
1.1       raeburn   674:               </td>
                    675:              </tr>
                    676:             </table>
                    677:             <br/>
                    678:             <table border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
                    679:              <tr>
                    680:               <td>
                    681:                <table border=\"0\" width=\"100%\" cellspacing=\"3\" cellpadding=\"3\">
                    682:                 <tr bgcolor=\"#CCCCFF\" align=\"left\">
                    683:                  <td><b>Enrollment?</b></td>
                    684:                  <td><b>Crosslisted course</b></td>
                    685:                  <td><b>LON-CAPA section/groupID</b></td>
                    686:                 </tr>
                    687:           ");
                    688:           for (my $i=0; $i<@xlists; $i++) {
                    689:               my $xl = '&nbsp;';
                    690:               my $gp = '&nbsp;';
1.14      raeburn   691:               if ($xlists[$i] =~ /(\w+):?(.*)$/) {
1.1       raeburn   692:                   $xl = $1;
                    693:                   $gp = $2;
                    694:               }               
                    695:               my $colflag = $i%2;
                    696:               $r->print("
                    697:                 <tr bgcolor=\"$bgcolors[$colflag]\" align=\"left\">
                    698:                  <td><input type=\"checkbox\" name=\"cross_$i\" checked=\"true\"/></td>
                    699:                  <td>$xl</td>
                    700:                  <td><input type =\"text\" size=\"10\" name=\"gp_$i\" value=\"$gp\"></td>
                    701:                 </tr> 
                    702:               ");
                    703:           }
                    704:           $r->print("  </table>
                    705:               </td>
                    706:              </tr>
                    707:             </table>
                    708:           ");
                    709:       }
                    710:       else {
                    711:           $r->print("
                    712:                 Currently no crosslisted courses are recorded for $enrollvar{coursecode}.
                    713:               </td>
                    714:              </tr>
                    715:             </table>
                    716:           ");
                    717:       }
                    718:       $r->print("   
                    719:             <br/>
                    720:             <table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
                    721:              <tr>
                    722:               <td align=\"left\">
                    723:                <b>Add new crosslistings.</b><br/>
                    724:                Number of new crosslistings to add:&nbsp;&nbsp;<input type=\"text\" size=\"2\" name=\"numcross\" value=\"0\" />
                    725:               </td>
                    726:              </tr>
                    727:             </table>
                    728:             <br/>
                    729:             <table width=\"100%\" border=\"0\" cellspadding=\"2\" cellspacing=\"2\">
                    730:              <tr>
                    731:               <td align=\"right\">
                    732:                <input type=\"button\" name=\"crosslist\" value=\"Go\" onClick=\"process('crosslist')\" />
                    733:               </td>
                    734:              </tr>
                    735:             </table>
                    736:             <input type=\"hidden\" name=\"action\" value=\"$action\">
                    737:             <input type=\"hidden\" name=\"state\" value=\"process\">
                    738:             </form> 
                    739:       ");
                    740:   } elsif ($action eq "sections") {
1.12      raeburn   741:       my @sections = ();
1.13      raeburn   742:       @sections = &Apache::lonnet::auto_get_sections($crs,$dom,$enrollvar{coursecode});
1.1       raeburn   743:       my @storedsections = ();
                    744:       my @currsections = ();
                    745:       my %sec_id = ();
                    746:       if ($enrollvar{sectionnums} =~ m/,/) {
                    747:           @storedsections = split/,/,$enrollvar{sectionnums};
                    748:       } else {
                    749:           $storedsections[0] = $enrollvar{sectionnums};
                    750:       }
                    751:       foreach (@storedsections) {
                    752:           if ($_ =~ m/^(\w+):(\w*)$/) {
                    753:               push @currsections, $1;
                    754:               $sec_id{$1} = $2;
                    755:           }
                    756:       }
                    757:       if (@sections > 0) {
1.8       raeburn   758:           my $secshow = @sections;
                    759:           $r->print("
1.1       raeburn   760:             <form name=\"enter\" method=\"post\"><br/>
                    761:             <table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
                    762:              <tr>
                    763:               <td align=\"left\">
                    764:                <b>$$tasktitleref{$action}</b><br/>
                    765:                Your institution's course catalog includes $secshow sections for course code: $enrollvar{coursecode}.
                    766:               </td>
                    767:              </tr>
                    768:              <tr>
1.5       raeburn   769:               <td>For each section, check the checkbox if you want registered students in that section to be included in the student roster for LON-CAPA course: <b>$realm ($enrollvar{coursecode})</b>; otherwise uncheck it. If you want to change the section/group designation used for this section in LON-CAPA, delete the current value in the LON-CAPA section/group textbox and enter the new value. The LON-CAPA section/group ID can be left (or set to) empty, if you do not wish to tie a section/group ID to this section. To add a new section, check the 'Enrollment in this course?' checkbox, and enter the desired LON-CAPA section/groupID in the appropriate textbox. Click 'Go' to store
                    770: your changes.</td>
1.1       raeburn   771:              </tr>
                    772:             </table>
                    773:             <br/>
1.7       raeburn   774:             <table border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
                    775:              <tr bgcolor=\"#CCCCFF\">
                    776:               <td><b>Section</b></td>
                    777:               <td><b>Current status</b></td>              
                    778:               <td><b>LON-CAPA section/group ID</b></td>
                    779:               <td><b>Enrollment in this course?</b></td>
                    780:              </tr>
1.8       raeburn   781:           ");
                    782:           for (my $i=0; $i<@sections; $i++) {
                    783:               my $colflag = $i%2;
                    784:               my $shrflag = 0;
                    785:               $r->print("<tr bgcolor=\"$bgcolors[$colflag]\" align=\"left\">
1.5       raeburn   786:                    <td>$sections[$i]<input type=\"hidden\" name=\"secnum_$i\" value=\"$sections[$i]\" /></td>
1.1       raeburn   787:                    <td>
1.8       raeburn   788:               ");
                    789:               if (grep/^$sections[$i]$/,@currsections) {
                    790:                   $r->print("Enrollment active");
                    791:                   $shrflag = 1;
                    792:               } else {
                    793:                   $r->print("Enrollment inactive");
                    794:               }
                    795:               if ($shrflag) {
                    796:                   $r->print("</td><td><input type=\"text\" size=\"10\" name=\"loncapasec_$i\" value=\"$sec_id{$sections[$i]}\"></td><td><input type=\"checkbox\" name=\"sec_$i\" checked=\"true\" /></td></tr>"); 
                    797:               } else {
                    798:                   $r->print("</td><td><input type=\"text\" size=\"10\" name=\"loncapasec_$i\" value=\"\"><td><input type=\"checkbox\" name=\"sec_$i\" /></td></tr>");
1.1       raeburn   799:               }
1.8       raeburn   800:           }
                    801:           $r->print("
1.7       raeburn   802:             </table>
                    803:             <br/>
                    804:             <table width=\"100%\" border=\"0\" cellspacing=\"3\" cellpadding=\"3\">
                    805:              <tr> 
                    806:               <td align=\"right\">
                    807:                <input type=\"hidden\" name=\"secshow\" value=\"$secshow\" />
                    808:                <input type=\"button\" name=\"sections\" value=\"Go\" onClick=\"process('sections')\" />
                    809:               </td>
                    810:              </tr>
                    811:             </table>
                    812:             <input type=\"hidden\" name=\"action\" value=\"$action\">
                    813:             <input type=\"hidden\" name=\"state\" value=\"process\">
                    814:             </form>
1.8       raeburn   815:           ");
1.1       raeburn   816:       } else {
                    817:           $r->print("
                    818:             <form name=\"enter\" method=\"post\"><br/>
                    819:             <table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\">
                    820:              <tr>
                    821:               <td align=\"left\"><b>$$tasktitleref{$action}</b><br/>
                    822:           ");
                    823:           if (@currsections) {
                    824:               my $secshow = @currsections;
                    825:               $r->print("
1.7       raeburn   826:                 Currently, this LON-CAPA course incorporates enrollment from $secshow sections.  Students enrolling in any of these course sections will be automatically added to the class roster for the course, if you have chosen to enable a nightly automated enrollment update. For each section, uncheck the checkbox if you want registered students in that section to cease being included in the student roster for LON-CAPA course: <b>$realm ($enrollvar{coursecode})</b>; otherwise leave it checked. If you want to change the section/group designation used for this section in LON-CAPA, delete the current value in the LON-CAPA section/groupID textbox and enter the new value.  If you wish to add new course section, enter the number of new sections to add in the textbox at the bottom of the page. You will provide information about each of the new sections on a subsequent page. Click 'Go' to store your changes.
1.1       raeburn   827:               </td>
                    828:              </tr>
                    829:             </table>
                    830:             <br/>
                    831:             <table border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
                    832:              <tr>
                    833:               <td>
                    834:                <table border=\"0\" width=\"100%\" cellspacing=\"3\" cellpadding=\"3\">
                    835:                 <tr bgcolor=\"#CCCCFF\">
                    836:                  <td><b>Enrollment?</b></td>
                    837:                  <td><b>Section</b></td>
                    838:                  <td><b>LON-CAPA section/groupID</b></td>
                    839:                 </tr>
                    840:               ");
                    841:               for (my $j=0; $j<@currsections; $j++) {
                    842:                   my $colflag = $j%2;
                    843:                   $r->print("
                    844:                 <tr bgcolor=\"$bgcolors[$colflag]\" align=\"left\">
                    845:                  <td><input type=\"checkbox\" name=\"sec_$j\" checked=\"true\"/></td>
                    846:                  <td>$currsections[$j]</td>
                    847:                  <td><input type=\"text\" name=\"secgp_$j\" size=\"10\" value=\"$sec_id{$currsections[$j]}\"></td>
                    848:                 </tr> 
                    849:                   ");
                    850:               }
                    851:               $r->print("  </table>
                    852:               </td>
                    853:              </tr>
                    854:             </table>
                    855:               ");
                    856:           } else {
                    857:               $r->print("
                    858:                 Currently no sections of $realm ($enrollvar{coursecode}) are contributing enrollment to the LON-CAPA class roster.
                    859:               </td>
                    860:              </tr>
                    861:             </table>
                    862:               ");
                    863:           }
                    864:           $r->print("   
                    865:             <br/>
                    866:             <table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
                    867:              <tr>
                    868:               <td align=\"left\">
                    869:                <b>Add enrollment from additional sections.</b><br/>
                    870:                Number of new sections to add:&nbsp;&nbsp;<input type=\"text\" size=\"2\" name=\"numsec\" value=\"0\" />
                    871:               </td>
                    872:              </tr>
                    873:             </table>
                    874:             <br/>
                    875:             <table width=\"100%\" border=\"0\" cellspadding=\"2\" cellspacing=\"2\">
                    876:              <tr>
                    877:               <td align=\"right\">
                    878:                <input type=\"button\" name=\"sections\" value=\"Go\" onClick=\"process('sections')\" />
                    879:               </td>
                    880:              </tr>
                    881:             </table>
                    882:             <input type=\"hidden\" name=\"action\" value=\"$action\">
                    883:             <input type=\"hidden\" name=\"state\" value=\"process\">
                    884:             </form> 
                    885:           ");
                    886:       }
                    887:   } elsif ($action eq "photos") {
                    888:       my @photosets = ("OFF","ON");
                    889:       $r->print("
                    890:                   <form name=\"enter\" method=\"post\"><br/>
                    891:                   <table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\">
                    892:                    <tr>
                    893:                     <td align=\"left\"><b>$$tasktitleref{$action}</b><br/>
                    894:                        Currently: Student photo import:  <i>$photosets[$enrollvar{showphotos}]</i>
                    895:                     </td>
                    896:                    </tr>
                    897:                   </table>
                    898:                   <table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
                    899:                     <tr>
                    900:                      <td>
                    901:                          Automatic import of student photos from institutional data repository:&nbsp;&nbsp;
                    902: 
                    903:       ");
                    904:       if ($enrollvar{showphotos}) {
                    905:           $r->print("
                    906:                         <input type=\"radio\" name=\"showphotos\" value=\"1\" checked=\"true\" />&nbsp;Yes&nbsp;&nbsp;&nbsp;
                    907:                         <input type=\"radio\" name=\"showphotos\" value=\"0\" />&nbsp;No
                    908:           ");
                    909:       } else {
                    910:           $r->print("
                    911:                         <input type=\"radio\" name=\"showphotos\" value=\"1\" />&nbsp;Yes&nbsp;&nbsp;&nbsp;
                    912:                         <input type=\"radio\" name=\"showphotos\" value=\"0\" checked=\"true\" />&nbsp;No
                    913:           ");
                    914:       }
                    915:       $r->print("
                    916:                      </td>
                    917:                     </tr>
                    918:                     <tr>
                    919:                      <td>
                    920:                       <font color=\"#888888\">
                    921: Note: if you enable automatic import of student photos, your course will automatically have access to photos stored by your institution for all officially registered students, via a conduit established by your LON-CAPA domain coordinator.  
                    922:                       </font>
                    923:                      </td>
                    924:                     </tr>
                    925:                     <tr>
                    926:                      </td>&nbsp;</td>
                    927:                     </tr>
                    928:                     <tr>
                    929:                      <td align=\"right\">
                    930:                       <input type=\"button\" name=\"showphotos\" value=\"Go\" onClick=\"process('photos')\">
                    931:                      </td>
                    932:                     </tr>
                    933:                    </table>
                    934:                    <input type=\"hidden\" name=\"action\" value=\"$action\">
                    935:                    <input type=\"hidden\" name=\"state\" value=\"process\">
                    936:                    </form>
                    937:       ");
                    938:   } elsif ($action eq "updatenow") {
                    939:       $r->print("
                    940:                    <form name=\"enter\" method=\"post\"><br/>
                    941: 		   <table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\">
                    942: 		    <tr>
                    943: 		     <td align=\"left\"><b>$$tasktitleref{$action}</b>
                    944: 		     </td>
                    945:                     </tr>
                    946: 		   </table>
                    947: 		   <table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
                    948: 		    <tr>
                    949: 		     <td>
1.17      raeburn   950: 	              Add any students currently included in institutional classlist(s) but not enrolled in your LON-CAPA course.<br />  
                    951: 		      <input type=\"radio\" name=\"updateadds\" value=\"1\">&nbsp;Yes&nbsp;<input type=\"radio\" name=\"updateadds\" value=\"0\">&nbsp;No&nbsp;
1.1       raeburn   952:                      </td>
                    953:                     </tr>
                    954:                     <tr>
                    955:                      <td>
1.17      raeburn   956:  	              Expire students previously added by nightly enrollment process, but no longer listed in institutional  classlist(s).<br />                  
1.14      raeburn   957:                       <input type=\"radio\" name=\"updatedrops\" value=\"1\">&nbsp;Yes&nbsp;
                    958:                       <input type=\"radio\" name=\"updatedrops\" value=\"0\">&nbsp;No&nbsp;<br/>
                    959:                      </td>
                    960:                     </tr>
                    961:                     <tr>
                    962:                      <td><font color=\"#888888\">
1.1       raeburn   963: Note: Any students previously added manually by course coordinator(s) using either 'Upload classlist CSV file' or 'Enroll a single user' will be unaffected by the removal process.
1.14      raeburn   964:                       </font>
                    965:                      </td>
                    966:                     </tr>
                    967:                     <tr>
                    968:                      <td>
                    969:       ");
                    970:       &print_accessdate_table($r,\%enrollvar,$tasktitleref,$action);
                    971:       $r->print("
                    972:                      </td>
                    973:                     </tr>
                    974:                     <tr>
                    975:                      <td align=\"right\">
                    976:                       <input type=\"button\" name=\"updatenow\" value=\"Go\" onClick=\"process('updatenow')\" />
                    977:                      </td>
                    978:                     </tr>
                    979: 	           </table>
                    980:                    <input type=\"hidden\" name=\"action\" value=\"$action\" />
                    981:                    <input type=\"hidden\" name=\"state\" value=\"process\" />
                    982:                   </form>
                    983:       ");
                    984:   } elsif ($action eq 'viewclass') {
                    985:       $r->print("
                    986:                    <form name=\"studentform\" method=\"post\"><br/>
                    987:                    <table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\">
                    988:                     <tr>
                    989:                      <td align=\"left\"><b>$$tasktitleref{$action}</b>
                    990:                      </td>
                    991:                     </tr>
1.16      raeburn   992:                     <tr>
                    993:                      <td>Section changes, name changes, and class drops that can be set to occur either automatically or when using the <b>'Update roster now'</b> feature, will affect only those students with an enroll type of <b>'auto'</b>. Students with an enroll type of <b>'manual'</b>, will be converted automatically to the 'auto' type, when they first appear in the institutional classlist for the course - as long as nightly adds are enabled and active, or the update roster utility is used.  Use the 'Lock' checkbox for any manually enrolled students for whom you wish to prevent type conversion. Use the 'Change' checkbox to switch the enroll type from auto to manual, and vice versa. Use the 'Unlock' checkbox for any maually enrolled students for whom you no longer wish to lock the enroll type.  Click the 'Go' button at the end of the page to process your desired changes.</td>
                    994:                     </tr>
                    995:                     <tr><td>&nbsp;</td></tr> 
1.14      raeburn   996:                    </table>
                    997:                    <table>
                    998:                     <tr>
                    999:                      <td>
1.1       raeburn  1000:       ");
1.14      raeburn  1001:       if (! exists($ENV{'form.sortby'})) {
                   1002:           $ENV{'form.sortby'} = 'username';
                   1003:       }
                   1004:       if ($ENV{'form.Status'} !~ /^(Any|Expired|Active)$/) {
                   1005:           $ENV{'form.Status'} = 'Active';
                   1006:       }
                   1007:       my $status_select = &Apache::lonhtmlcommon::StatusOptions($ENV{'form.Status'});
                   1008: #  Get current classlist
                   1009:       my ($classlist,$keylist)=&Apache::loncoursedata::get_classlist();
                   1010:       if (! defined($classlist)) {
                   1011:           $r->print(&mt('There are no students either currently or previously enrolled.').
                   1012:                       "\n");
                   1013:       } else {
                   1014:           $r->print(&mt('Student Status: [_1]',$status_select)."\n");
                   1015:           $r->print('<input type="submit" value="'.&mt('Update Display').'" />'.
                   1016:               "\n</p>\n");
                   1017: 
1.16      raeburn  1018:           my ($studentcount,$autocount,$manualcount,$lockcount,$unlockcount) = &Apache::londropadd::show_class_list($r,'autoenroll','nothing',$ENV{'form.Status'},$classlist,$keylist);
1.14      raeburn  1019:           $r->print("
                   1020:                      </td>
                   1021:                     </tr>
                   1022:           ");
                   1023:           if ($studentcount > 0) {
                   1024:               $r->print("
1.16      raeburn  1025:                     <tr><td><table border=\"0\" cellpadding=\"5\"><tr>
                   1026:               ");
                   1027:               my $cellcount = 0;
                   1028:               if ($autocount > 0) {
                   1029:                   $cellcount ++;
                   1030:                   $r->print(<<END);
                   1031:                        <td><fieldset><legend>&nbsp;<b>Change auto</b></legend><input type="button" value="check all" onclick="javascript:checkAll(document.studentform.chgauto)" />&nbsp;&nbsp;
                   1032:                        <input type="button" value="uncheck all" onclick="javascript:uncheckAll(document.studentform.chgauto)" /></fieldset></td>
                   1033: END
                   1034:               }
                   1035:               if ($manualcount > 0) {
                   1036:                   $cellcount ++;
                   1037:                   $r->print(<<END);
                   1038:                        <td><fieldset><legend>&nbsp;<b>Change manual</b></legend><input type="button" value="check all" onclick="javascript:checkAll(document.studentform.chgmanual)" />&nbsp;&nbsp;
                   1039:                        <input type="button" value="uncheck all" onclick="javascript:uncheckAll(document.studentform.chgmanual)" /></fieldset></td>
                   1040: END
                   1041:               }
                   1042:               if ($lockcount > 0) {
                   1043:                   if ($cellcount == 2) {
                   1044:                       $r->print("</tr><tr>");
                   1045:                   }
                   1046:                   $cellcount ++;
                   1047:                   $r->print(<<END);
                   1048:                        <td><fieldset><legend>&nbsp;<b>Lock manual</b></legend><input type="button" value="check all" onclick="javascript:checkAll(document.studentform.lockchg)" />&nbsp;&nbsp;
                   1049:                        <input type="button" value="uncheck all" onclick="javascript:uncheckAll(document.studentform.lockchg)" /></fieldset></td>
                   1050: END
                   1051:               }
                   1052:               if ($unlockcount > 0) {
                   1053:                   if ($cellcount == 2) {
                   1054:                       $r->print("</tr><tr>");
                   1055:                   }
                   1056:                   $cellcount ++;
                   1057:                   $r->print(<<END);
                   1058:                        <td><fieldset><legend>&nbsp;<b>Unlock manual</b></legend><input type="button" value="check all" onclick="javascript:checkAll(document.studentform.unlockchg)" />&nbsp;&nbsp;
                   1059:                        <input type="button" value="uncheck all" onclick="javascript:uncheckAll(document.studentform.unlockchg)" /></fieldset></td>
                   1060: END
                   1061:               }
                   1062:               $r->print("
                   1063:                        </tr>
                   1064:                       </table>
1.14      raeburn  1065:                      <td>&nbsp;</td>
                   1066:                     </tr>
                   1067:                     <tr>
                   1068:                      <td align=\"right\">
1.16      raeburn  1069:                       <input type=\"button\" name=\"viewclass\" value=\"Go\" onClick=\"process('viewclass','$autocount','$manualcount','$lockcount','$unlockcount')\" />
1.14      raeburn  1070:                      </td>
                   1071:                     </tr>
                   1072:               ");
                   1073:           }
                   1074:           $r->print("
                   1075:                    </table>
                   1076:                    <input type=\"hidden\" name=\"action\" value=\"$action\" />
                   1077:                    <input type=\"hidden\" name=\"state\" value=\"choose\" />
                   1078:                   </form>
                   1079:           ");
                   1080:       }
1.1       raeburn  1081:   }
                   1082: }
                   1083: 
1.14      raeburn  1084: sub print_accessdate_table {
                   1085:     my ($r,$enrollvar,$tasktitleref,$action) = @_;
                   1086:     my ($start_table,$end_table) = &date_setting_table($$enrollvar{'default_enrollment_start_date'},$$enrollvar{'default_enrollment_end_date'},$action);
                   1087:     my $oldstartshow = '';
                   1088:     my $oldendshow = '';
                   1089:     if ( defined($$enrollvar{'default_enrollment_start_date'}) ) {
                   1090:         $oldstartshow = &Apache::lonlocal::locallocaltime($$enrollvar{'default_enrollment_start_date'});
                   1091:     }
                   1092:     if ( defined($$enrollvar{'default_enrollment_end_date'}) ) {
                   1093:         $oldendshow = &Apache::lonlocal::locallocaltime($$enrollvar{default_enrollment_end_date});
                   1094:         if ($$enrollvar{'default_enrollment_end_date'} eq '0') {
                   1095:             $oldendshow = "No ending date";
                   1096:         }
                   1097:     }
                   1098:     my %lt =&Apache::lonlocal::texthash(
                   1099:          'cuno' => 'Currently NO default first access or last access dates are set.',
                   1100:          'ifyo' => 'If you do not set a start date and an end date, then student roles for students added by the automated enrollment process will start immediately when the student is added and will never become inactive.',
                   1101:          'ifyd' => 'If you do not set an access start date and an end date, then student roles for new students added when you click "Go" will become active immediately and will never become inactive.',
                   1102:          'setf' => 'Set date of first access',
                   1103:          'setl' => 'Set date of last access',
                   1104:          'freg' => 'for registered students added via automated enrollment',
                   1105:          'fnew' => 'for new students added when you update the class roster',
1.16      raeburn  1106:          'ifad'  => 'If automated adds are enabled, then when students are added their student roles will become active on the date set here for first access, and their roles will become inactive on the date set here for last access.  These default access dates will be overridden for specific students if the institutional classlist data supplied to the automatic enrollment process includes entries for the startdate and enddate fields for those students.',
                   1107:          'ncds'  => 'changing default start and end access dates will affect future enrollments and ALSO currently inactive students (i.e., those for whom access will begin in the future).  To change access dates for currently active students, you should change the access dates via this screen, then use Enrollment manager -> Drop Students to drop the students, and then use Automated Enrollment Manager -> Update roster now to re-enroll them with the new access dates.'
                   1108: 
1.14      raeburn  1109:     );
                   1110:     my $dateshow;
                   1111:     if ( ($oldendshow eq '') && ($oldstartshow eq '') ) {
                   1112:        $dateshow = "<br/><font size='+1'>".&mt('Warning')."</font>.&nbsp;".$lt{'cuno'}." ";
                   1113:        if ($action eq 'setaccess') {
                   1114:            $dateshow .= $lt{'ifyo'}."\n";
                   1115:        } elsif ($action eq 'updatenow') {
                   1116:            $dateshow .= $lt{'ifyd'}."\n";
                   1117:        }
                   1118:     } else {
                   1119:         $dateshow = &mt('Currently: default first access').": <b><i>$oldstartshow</i></b>, ".&mt('default last access').": <b><i>$oldendshow</i></b>\n";
                   1120:     }
                   1121:     if ($action eq 'setaccess') {
                   1122:         $r->print(<<ENDONE);
                   1123:                 <form name="enter" method="post"><br/>
                   1124:                 <table width="100%" border="0" cellpadding="2" cellspacing="2">
                   1125:                  <tr>
                   1126:                   <td align="left"><b>$$tasktitleref{$action}</b>
                   1127:                   <br /><br />
                   1128:                    $dateshow
                   1129:                   </td>
                   1130:                  </tr>
                   1131:                 </table>
                   1132: ENDONE
                   1133:     } elsif ($action eq 'updatenow') {
                   1134:         $r->print("
                   1135:                 <br /><br />$dateshow\n");
                   1136:     }
                   1137:     $r->print(<<ENDTWO);
                   1138:                 <table width="100%" border="0" cellpadding="3" cellspacing="3">
                   1139:                  <tr>
                   1140:                   <td align="left" colspan="2">
                   1141:                    <table border="0" cellspacing="0" cellpadding="2">
                   1142:                     <tr>
                   1143:                      <td colspan="3">
                   1144: ENDTWO
                   1145:       if ($action eq 'setaccess') {
                   1146:           $r->print("<i>$lt{'setf'} $lt{'freg'}</i>");
                   1147:       } elsif ($action eq 'updatenow') {
                   1148:           $r->print("<i>$lt{'setf'} $lt{'fnew'}</i>");
                   1149:       }
                   1150:       $r->print(<<ENDTHREE); 
                   1151:                        </td>
                   1152:                       </tr>
                   1153:                       <tr>
                   1154:                        <td>$start_table
                   1155:                        </td>
                   1156:                       </tr>
                   1157:                      </table>
                   1158:                     </td>
                   1159:                    </tr>
                   1160:                    <tr>
                   1161:                     <td align="left" colspan="2">
1.15      albertel 1162:                      <table border="0" cellspacing="0" cellpadding="2">
1.14      raeburn  1163:                       <tr>
                   1164:                        <td colspan="3">
                   1165: ENDTHREE
                   1166:     if ($action eq 'setaccess') {
                   1167:         $r->print("<i>$lt{'setl'} $lt{'freg'}</i>");
                   1168:     } elsif ($action eq 'updatenow') {
                   1169:         $r->print("<i>$lt{'setl'} $lt{'fnew'}</i>");
                   1170:     }
                   1171:     $r->print(<<ENDFOUR); 
                   1172:                        </td>
                   1173:                       </tr>
                   1174:                       <tr>
                   1175:                        <td>$end_table
                   1176:                        </td>
                   1177:                       </tr>
                   1178:                      </table>
                   1179:                     </td>
                   1180:                    </tr>
                   1181: ENDFOUR
                   1182:     if ($action eq 'setaccess') {
                   1183:         $r->print("
                   1184:                    <tr>
                   1185:                     <td colspan=\"2\"><font color=\"#888888\">$lt{'ifad'}</font></td>
                   1186:                    </tr>
1.16      raeburn  1187:                    <tr>
                   1188:                     <td colspan=\"2\">&nbsp;</td>
                   1189:                    </tr>
                   1190:                    <tr>
                   1191:                     <td colspan=\"2\"><b>".&mt('Note').":</b> ".$lt{'ncds'}."</td>
                   1192:                    </tr>
1.14      raeburn  1193:                   </table>
                   1194:         ");
                   1195:     } elsif ($action eq 'updatenow') {
                   1196:         $r->print("
                   1197:                    </tr>
                   1198:                   </table>
                   1199:         ");
                   1200:     }
                   1201: }
                   1202: 
1.1       raeburn  1203: ###############################################################
                   1204: sub print_doc_base {
1.15      albertel 1205:     my $r = shift;
                   1206:     $r->print(<<ENDBASE);
1.1       raeburn  1207:   </td>
                   1208:  </tr>
                   1209: </table>
                   1210: <br/>
                   1211: </body>
                   1212: </html> 
                   1213: ENDBASE
                   1214: }
                   1215:  
                   1216: ###################################################################
                   1217: sub print_chgsettings_response {
1.15      albertel 1218:     my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
                   1219:     my %settings = &Apache::lonnet::get('environment',['internal.sectionnums','internal.crosslistings','internal.autostart','internal.autoend','internal.autoadds','internal.autodrops'],$dom,$crs);
                   1220:     my $currend = '';
                   1221:     my $currstart = '';
                   1222:     my $currsecs = '';
                   1223:     my $currxlists = '';
                   1224:     my $curradds = '';
                   1225:     my $currdrops = '';
                   1226:     if ( defined($settings{'internal.autoadds'}) ) {
                   1227: 	$curradds = $settings{'internal.autoadds'};
                   1228:     }
                   1229:     if ( defined($settings{'internal.autodrops'}) ) {
                   1230: 	$currdrops = $settings{'internal.autodrops'};
                   1231:     }
                   1232:     if ( defined($settings{'internal.autostart'}) ) {
                   1233: 	$currstart = $settings{'internal.autostart'};
                   1234:     }
                   1235:     if ( defined($settings{'internal.autoend'}) ) {
                   1236: 	$currend = $settings{'internal.autoend'};
                   1237:     }
                   1238:     if ( defined($settings{'internal.sectionnums'}) ) {
                   1239: 	$currsecs = $settings{'internal.sectionnums'};
                   1240:     }
                   1241:     if ( defined($settings{'internal.crosslistings'}) ) {
                   1242: 	$currxlists = $settings{'internal.crosslistings'}
                   1243:     }
                   1244:     my $autoadds = '';
                   1245:     my $autodrops = '';
1.1       raeburn  1246: 
1.15      albertel 1247:     if ( exists($ENV{'form.autoadds'}) ) {
                   1248: 	$autoadds=$ENV{'form.autoadds'};
                   1249:     }
                   1250:     if ( exists($ENV{'form.autodrops'}) ) {
                   1251: 	$autodrops=$ENV{'form.autodrops'};
                   1252:     }
                   1253: 
                   1254:     my $response = "";
                   1255:     my $warning = "";
                   1256:     my $warn_prefix = "";
                   1257:     my $warn_suffix = "";
                   1258:     my $warnfiller = "";
                   1259:     my %cenv = ('internal.autoadds' => $autoadds,
                   1260: 		'internal.autodrops' => $autodrops);
                   1261:     my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
                   1262:     if ($reply !~ /^ok$/) {
                   1263: 	$response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged.<br/>";
                   1264:     } else {
                   1265: 	if ($autoadds) {
                   1266: 	    if ($curradds) {
                   1267: 		$response = "Nightly additions based on classlist changes still <b>enabled</b><br/>";
                   1268: 	    } else {
                   1269: 		$response = "Nightly additions based on classlist changes now <b>enabled</b><br/>";
                   1270: 	    }
                   1271: 	} else {
                   1272: 	    if ($curradds) {
                   1273: 		$response = "Nightly additions based on classlist changes now <b>disabled</b><br/>";
                   1274: 	    } else {
                   1275: 		$response = "Nightly additions based on classlist changes still <b>disabled</b><br/>";
                   1276: 	    }
                   1277: 	}
                   1278: 	if ($autodrops) {
                   1279: 	    if ($currdrops) {
                   1280: 		$response .= "Nightly removals based on classlist changes still <b>enabled</b><br>";
                   1281: 	    } else {
                   1282: 		$response .= "Nightly removals based on classlist changes now <b>enabled</b><br/>";
                   1283: 	    }
                   1284: 	} else {
                   1285: 	    if ($currdrops) {
                   1286: 		$response .= "Nightly removals based on classlist changes now <b>disabled</b><br>";
                   1287: 	    } else {
                   1288: 		$response .= "Nightly removals based on classlist changes still <b>disabled</b>";
                   1289: 	    }
                   1290: 	}
                   1291: 	if ($autoadds || $autodrops) {
                   1292: 	    $warning = &warning_message($dom,$crs,$action);
                   1293: 	    $warn_prefix = "<br/><font size ='+1'><b>Warning</b></font>. Although you indicated that nightly ";
                   1294: 	    $warn_suffix = " should be enabled, additional action is required.<br/>";
                   1295: 	}
                   1296: 	if ($autoadds) {
                   1297: 	    if ($autodrops) {
                   1298: 		$warnfiller = "adds and drops";
                   1299: 	    } else {
                   1300: 		$warnfiller = "adds";
                   1301: 	    }
                   1302: 	} else {
                   1303: 	    if ($autodrops) {
                   1304: 		$warnfiller = "drops";
                   1305: 	    }
                   1306: 	}
                   1307: 	unless ($warning eq '') {
                   1308: 	    $response = $warn_prefix.$warnfiller.$warn_suffix.$warning;
                   1309: 	}
                   1310:     }
                   1311:     &print_reply($r,$response,$$tasktitleref{$action});
                   1312:     return;
1.1       raeburn  1313: }
                   1314: 
                   1315: sub print_setdates_response {
1.15      albertel 1316:     my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
                   1317:     my %settings = &Apache::lonnet::get('environment',['internal.autostart','internal.autoend'],$dom,$crs);
                   1318:     my $currstart = $settings{'internal.autostart'};
                   1319:     my $currend = $settings{'internal.autoend'};
                   1320:     my $response = '';
1.19      raeburn  1321:     my $showstart = '';
1.15      albertel 1322:     my $showend = '';
                   1323:     my $warning = '';
                   1324:     my $warn_prefix = '';
1.19      raeburn  1325:     my ($autostart,$autoend) = &get_dates_from_form();
                   1326:     if ( ($autostart eq '') || ($autoend eq '') ) {
                   1327:         $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged.<br/>";
                   1328:     } elsif (($autoend > 0) && ($autoend <= $autostart)) {
                   1329:         $response = 'The date/time selected for starting auto-enrollment was the same or later than the date/time selected for ending auto-enrollment. As this means auto-enrollment will never be active, your requested changes have not been processed, and the existing values remain in effect. Please <a href="javascript:history.go(-1)">go back</a> to the previous page to try your changes again.'."\n";
                   1330:     } else {       
                   1331:         $showstart = &Apache::lonlocal::locallocaltime($autostart);
                   1332:         if ($autoend) {
                   1333: 	    $showend = &Apache::lonlocal::locallocaltime($autoend);
                   1334:         } else {
                   1335: 	    $showend = "'No end date'";
                   1336:         } 
1.15      albertel 1337: 
1.19      raeburn  1338:         my %cenv = ('internal.autostart' => $autostart,
                   1339:   		    'internal.autoend' => $autoend);
                   1340:         my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
                   1341:         if ($reply !~ /^ok$/) {
                   1342: 	    $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged.<br/>";
                   1343:         } else {
                   1344: 	    if ($currstart == $autostart) {
                   1345: 	        $response = "The first date for automated enrollment has been left unchanged as $showstart.<br/>";
                   1346: 	    } else {
                   1347: 	        $response = "The first date for automated enrollment has been changed to $showstart.<br/>";
                   1348: 	    } 
                   1349: 	    if ($currend == $autoend) {
                   1350: 	        $response .= "The last date for automated enrollment has been left unchanged as $showend.<br/>";
                   1351: 	    } else {
                   1352: 	        $response .= "The last date for automated enrollment has been changed to $showend.<br/>";
                   1353: 	    }
1.1       raeburn  1354:  
1.14      raeburn  1355: # Generate message in case where old first enrollment date was later than today, but new first enrollment date is now today or earlier.
1.1       raeburn  1356: 
1.19      raeburn  1357: 	    my $rosterupdated = 0;
                   1358: 	    my $firstaccess = "";
                   1359: 	    my $nextupdate = "";
                   1360: 	    my $lastupdate = "";
                   1361: 
                   1362: 	    my $nowstamp = time;
                   1363: 	    my @date_list=localtime(time);
                   1364: 	    my $cur_year = $date_list[5];
                   1365: 	    my $curday = $date_list[3];
                   1366: 	    my $curmonth = $date_list[4];
                   1367: 	    my $lastmidnt = timelocal(0,0,0,$date_list[3],$date_list[4],$date_list[5]);
                   1368: 	    my $nextmidnt = 86400 + $lastmidnt;
                   1369: 
                   1370: 	    my $todayupdate = timelocal(0,30,1,$date_list[3],$date_list[4],$date_list[5]);
                   1371: 	    my $lastupdate = $todayupdate - 86400;
                   1372: 	    if ($nowstamp < $todayupdate) {
                   1373: 	      $nextupdate = "today";
1.15      albertel 1374: 	    } else {
1.19      raeburn  1375: 	      $nextupdate = "tomorrow";
1.15      albertel 1376: 	    }
1.19      raeburn  1377: 	    if ($currstart < $lastupdate) {
                   1378: 	        $rosterupdated = 1;
1.15      albertel 1379: 	    }
1.19      raeburn  1380: 	    if ($autostart < $nextmidnt ) {
                   1381: 	        if ( $autostart >= $lastmidnt) {
                   1382: 		    $firstaccess = "today";
                   1383: 	        } else {
                   1384: 	  	    $firstaccess = "a date prior to today";
                   1385: 	        }
                   1386: 	        if (($nowstamp >= $autostart) && ($rosterupdated == 0)) {
                   1387: 		    $response .= qq|<br>Although you have now set the first enrollment date to $firstaccess, automatic enrollment will <b>not</b> occur until the next automatic enrollment update occurs for all LON-CAPA courses at 1.30 am $nextupdate. If you wish to immediately enroll registered students included in the institutional classlist for this class, please visit the <a href="/adm/populate?action=updatenow">roster update page</a>.<br>|;
                   1388: 	        }
                   1389: 	    }
                   1390: 	    $warning = &warning_message($dom,$crs,$action);
                   1391: 	    $warn_prefix = "<br/><font size ='+1'><b>Warning</b></font>. Although you set a start and end date for auto-enrollment, additional action is required.<br/>";
                   1392: 	    unless ($warning eq '') {
                   1393: 	        $response .= $warn_prefix.$warning;
                   1394: 	    }
                   1395:         }
1.15      albertel 1396:     }
                   1397:     &print_reply($r,$response,$$tasktitleref{$action});
                   1398:     return;
1.1       raeburn  1399: }
                   1400: 
1.14      raeburn  1401: sub print_setaccess_response {
1.15      albertel 1402:     my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
                   1403:     my %settings = &Apache::lonnet::get('environment',['default_enrollment_start_date','default_enrollment_end_date','internal.autostart'],$dom,$crs);
                   1404:     my $currstart = $settings{'default_enrollment_start_date'};
                   1405:     my $currend = $settings{'default_enrollment_end_date'};
                   1406:     my $autostart = $settings{'internal.autostart'};
                   1407:     my $response = '';
                   1408:     my ($startaccess,$endaccess) = &get_dates_from_form();
1.19      raeburn  1409:     if (($startaccess eq '') || ($endaccess eq '')) {
                   1410:         $response = "There was a problem processing your requested changes. The default
                   1411: start and end access dates for this course have been left unchanged.<br/>";
                   1412:     } elsif (($endaccess > 0) && ($endaccess <= $startaccess)) {
                   1413:         $response = 'The default start access date/time you chose was the same or later than the default end access date/time. As this means that roles will never be active, your requested changes have not been processed, and the existing values remain in effect. Please <a href="javascript:history.go(-1)">go back</a> to the previous page to try your changes again.'."\n"; 
1.15      albertel 1414:     } else {
1.19      raeburn  1415:         my $showstart = &Apache::lonlocal::locallocaltime($startaccess);
                   1416:         my $showend = '';
                   1417:         my $warning = '';
                   1418:         my $warn_prefix = '';
                   1419:         if ($endaccess) {
                   1420: 	    $showend = &Apache::lonlocal::locallocaltime($endaccess);
                   1421:         } else {
                   1422: 	    $showend = "'No end date'";
                   1423:         }
1.15      albertel 1424: 
1.19      raeburn  1425:         my %cenv = ('default_enrollment_start_date' => $startaccess,
1.15      albertel 1426: 		'default_enrollment_end_date' => $endaccess);
1.19      raeburn  1427:         my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
                   1428:         if ($reply !~ /^ok$/) {
                   1429: 	    $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged.<br/>";
                   1430:         } else {
                   1431: 	    if ($currstart == $startaccess) {
                   1432: 	        $response = "The first access date for students added via automated enrollment has been left unchanged as $showstart.<br/>";
                   1433: 	    } else {
                   1434: 	        $response = "The first access date for students added via automated enrollment has been changed to
1.14      raeburn  1435: $showstart.<br/>";
1.19      raeburn  1436: 	    }
                   1437: 	    if ($currend == $endaccess) {
                   1438: 	        $response .= "The last access date for students added via automated enrollment has been left unchanged as $showend.<br/>";
                   1439: 	    } else {
                   1440: 	        $response .= "The last access date for students automated enrollment has been changed to
1.14      raeburn  1441: $showend.<br/>";
1.19      raeburn  1442: 	    }
1.15      albertel 1443: 	
1.14      raeburn  1444: # Generate message in case where old first access date was later than today, but new first access date is now today or earlier.
1.15      albertel 1445: 	
1.19      raeburn  1446: 	    my $accessgiven= 0;
                   1447: 	    my $firstaccess = "";
                   1448: 	    my $nextupdate = "";
                   1449: 	    my $lastupdate = "";
                   1450: 
                   1451: 	    my $nowstamp = time;
                   1452: 	    my @date_list=localtime(time);
                   1453: 	    my $cur_year = $date_list[5];
                   1454: 	    my $curday = $date_list[3];
                   1455: 	    my $curmonth = $date_list[4];
                   1456: 	    my $lastmidnt = timelocal(0,0,0,$date_list[3],$date_list[4],$date_list[5]);
                   1457: 	    my $nextmidnt = 86400 + $lastmidnt;
                   1458: 
                   1459: 	    my $todayupdate = timelocal(0,30,1,$date_list[3],$date_list[4],$date_list[5]);
                   1460: 	    my $tomorrowupdate = $todayupdate + 86400;
                   1461: 	    my $lastupdate = $todayupdate - 86400;
                   1462: 
                   1463: 	    if ($autostart < $nextmidnt) {
                   1464: 	        if ($nowstamp < $todayupdate) {
                   1465: 		    $nextupdate = "at 1.30 am today";
                   1466: 	        } else {
                   1467: 		    $nextupdate = "at 1.30 am tomorrow";
                   1468: 	        }
1.15      albertel 1469: 	    } else {
1.19      raeburn  1470: 	        my @enrollstart = localtime($autostart);
                   1471: 	        $nextupdate = timelocal(0,30,1,$enrollstart[3],$enrollstart[4],$enrollstart[5]);
                   1472: 	        unless (($enrollstart[2] < 1) || ($enrollstart[2] == 1 && $enrollstart[1] <=30))  {
                   1473: 		    $nextupdate += 86400; 
                   1474: 	        }
                   1475: 	        $nextupdate = &Apache::lonlocal::locallocaltime($nextupdate);
                   1476: 	    }
                   1477: 	    if (($currstart < $lastupdate) && ($autostart < $lastupdate)) {
                   1478: 	        $accessgiven = 1;
                   1479: 	    }
                   1480: 	    if ($startaccess < $nextmidnt ) {
                   1481: 	        if ( $startaccess >= $lastmidnt) {
                   1482: 	    	    $firstaccess = "today";
                   1483: 	        } else {
                   1484: 		    $firstaccess = "a date prior to today";
                   1485: 	        }
                   1486: 	        if (($nowstamp >= $startaccess) && ($accessgiven == 0)) {
                   1487: 		    $response .= qq|<br>Although you have now set the first access date to $firstaccess, automatic enrollment will <b>not</b> occur until the next automatic enrollment update occurs for all LON-CAPA courses $nextupdate. If you wish to grant immediate course access for registered students included in the institutional classlist for this class, please visit the <a href="/adm/populate?action=updatenow">roster update page</a>.<br>|;
                   1488: 	        }
1.15      albertel 1489: 	    }
1.19      raeburn  1490: 	    $warning = &warning_message($dom,$crs,$action);
                   1491: 	    $warn_prefix = "<br/><font size ='+1'><b>Warning</b></font>. Although you have set default first and last access dates for students who are added via automatic enrollment, additional action is required.<br/>";
                   1492: 	    unless ($warning eq '') {
                   1493: 	        $response .= $warn_prefix.$warning;
1.15      albertel 1494: 	    }
1.19      raeburn  1495:         }
1.15      albertel 1496:     }
                   1497:     &print_reply($r,$response,$$tasktitleref{$action});
                   1498:     return;
1.14      raeburn  1499: }
                   1500: 
1.1       raeburn  1501: sub print_notify_response {
1.15      albertel 1502:     my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
1.1       raeburn  1503: 
                   1504: # Get current settings
1.15      albertel 1505:     my %settings = &Apache::lonnet::get('environment',['internal.notifylist','internal.coursecode'],$dom,$crs);
                   1506:     my $notifylist = $settings{'internal.notifylist'};
                   1507:     my $coursecode = $settings{'internal.coursecode'};
                   1508:     my @currpeople = ();
                   1509:     my $notify = 0;
                   1510:     my @people = ();
                   1511:     my $peoplestr = "";
                   1512:     my $response = "";
                   1513:     my $noprocess = 0;
1.1       raeburn  1514: 
1.15      albertel 1515:     if ($notifylist =~ m/,/) {
                   1516: 	@currpeople = split/,/,$notifylist;
                   1517:     } else {
                   1518: 	$currpeople[0] = $notifylist;
                   1519:     }
                   1520:     my $currcount = 0;
                   1521:     foreach  (@currpeople) {
                   1522: 	unless ($_ eq '') { $currcount ++; } 
                   1523:     }
                   1524: 
                   1525:     if ( exists($ENV{'form.notify'}) ) {
                   1526: 	$notify=$ENV{'form.notify'};
                   1527:     }
                   1528:     if ( exists($ENV{'form.notifyshow'}) ) {
                   1529: 	my $notifyshow = $ENV{'form.notifyshow'};
                   1530: 	for (my $i=0; $i<$notifyshow; $i++) {
                   1531: 	    if ( exists($ENV{"form.note_$i"}) ) {
                   1532: 		if ( exists($ENV{"form.notifyname_$i"}) ) {
                   1533: 		    unless ( $ENV{"form.notifyname_$i"} eq '' ) {
                   1534: 			push @people, $ENV{"form.notifyname_$i"};
                   1535: 		    }
                   1536: 		}
                   1537: 	    }
                   1538: 	}
                   1539: 	if ($notify) { $peoplestr = join(",",@people); }
                   1540:     } else {
                   1541: 	if ($notify) {
                   1542: 	    if ($currcount) {
                   1543: 		$response = "There was a problem retrieving the updated list of recipients of notification messages. The notification settings for this course have been left unchanged.<br/>.";
                   1544: 		$peoplestr = $notifylist;
                   1545: 		@people = @currpeople;
                   1546: 		$noprocess = 1;
                   1547: 	    }
                   1548: 	}
                   1549:     }
                   1550:     unless ($noprocess == 1) {
                   1551: 	my %cenv = ('internal.notifylist' => $peoplestr);
                   1552: 	my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
                   1553: 	if ($reply !~ /^ok$/) {
                   1554: 	    $response = "There was a problem processing your requested changes. The notification settings for this course have been left unchanged.<br/>";
                   1555: 	} else {
                   1556: 	    if ($notify) {
                   1557: 		if (@people) {
                   1558: 		    if ($currcount) {
                   1559: 			$response .= "Notification of enrollment changes still <b>enabled</b><br/>";
                   1560: 		    } else {
                   1561: 			$response .= "Notification of enrollment changes now <b>enabled</b><br/>";
                   1562: 		    }
                   1563: 		    $response .= "<br/>The following will receive notification if there are any changes in enrollment in LON-CAPA course: $realm ($coursecode) as a result of the nightly enrollment check: <br/><ul>\n";
                   1564: 		    foreach my $person (@people) {
                   1565: 			$response .= "<li>$person</li>\n";
                   1566: 		    }
                   1567: 		    $response .= "</ul>\n";
                   1568: 		} else {
                   1569: 		    $response = "Notification of enrollment changes was <b> not enabled</b> as no course coordinators were selected as recipients.<br/>";
                   1570: 		}
                   1571: 	    } else {
                   1572: 		if ($currcount) {
                   1573: 		    $response = "Notification of enrollment changes now <b>disabled</b><br/>";
                   1574: 		} else {
                   1575: 		    $response = "Notification of enrollment changes still <b>disabled</b><br/>";
                   1576: 		}
                   1577: 	    }
                   1578: 	}
                   1579:     }
                   1580:     &print_reply($r,$response,$$tasktitleref{$action});
                   1581:     return;
1.1       raeburn  1582: }
                   1583: 
                   1584: sub print_crosslistings_menu () {
1.15      albertel 1585:     my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
                   1586:     my %settings = &Apache::lonnet::get('environment',['internal.crosslistings','internal.coursecode'],$dom,$crs);
                   1587:     my @currxlists = ();
                   1588:     my @xlists = ();
                   1589:     my $crosscount = 0;
                   1590:     my $removecount = 0;
                   1591:     my $xliststr = '';
                   1592:     my $response = '';
                   1593:     my $coursecode = $settings{'internal.coursecode'};
                   1594:     if ($settings{'internal.crosslistings'} =~ m/,/) {
                   1595: 	@currxlists = split/,/,$settings{'internal.crosslistings'};
                   1596:     } elsif ($settings{'internal.crosslistings'} ne '') {
                   1597: 	$currxlists[0] = $settings{'internal.crosslistings'};
                   1598:     }
                   1599: 
                   1600:     if (@currxlists > 0) {
                   1601: 	for (my $i=0; $i<@currxlists; $i++) {
                   1602: 	    my $xlist = "cross_".$i;
                   1603: 	    my $gp = "gp_".$i;
                   1604: 	    if ( exists($ENV{"form.$xlist"}) ) {
                   1605: 		my $xlistentry = '';
                   1606: 		if ($currxlists[$i] =~ m/^([^:]+)/) {
                   1607: 		    $xlistentry = $1.':';
                   1608: 		}
                   1609: 		if ( exists($ENV{"form.$gp"}) ) {
                   1610: 		    $xlistentry .= $ENV{"form.$gp"};
                   1611: 		}
                   1612: 		push @xlists,$xlistentry;
                   1613: 		$crosscount ++;
                   1614: 	    } else {
                   1615: 		$removecount ++;
                   1616: 	    }
                   1617: 	}
                   1618:     }
1.1       raeburn  1619: 
1.15      albertel 1620:     if ($crosscount > 1) {
                   1621: 	$xliststr = join(",",@xlists);
                   1622:     } else {
                   1623: 	$xliststr = $xlists[0];
                   1624:     }
                   1625:     my %cenv = ('internal.crosslistings' => $xliststr);
                   1626:     my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
                   1627:     if ($reply !~ /^ok$/) {
                   1628: 	$response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged.<br/>";
                   1629:     } else {
                   1630: 	if ($removecount > 0) {
                   1631: 	    $response = "A total of $removecount courses are no longer crosslisted with LON-CAPA course: $realm ($coursecode).<br/><br/>";
                   1632: 	}
                   1633: 	if ($crosscount > 0) {
                   1634: 	    $response .=  "The $crosscount courses listed below remain crosslisted with this LON-CAPA course, and students enrolling in these course sections will be automatically added to the class roster for the course, if you have chosen to enable a nightly automated enrollment update.<br/><ul>\n";
                   1635: 	    foreach (@xlists) {
                   1636: 		my ($xlist,$gp) = split/:/,$_;
                   1637: 		$response .= "<li>$xlist - ID: $gp</li>\n";
                   1638: 	    }
                   1639: 	    $response .= "</ul><br/>\n";
                   1640: 	}
                   1641:     }
                   1642:     if ( exists($ENV{'form.numcross'}) ) {
                   1643: 	my $numcross = $ENV{'form.numcross'};
                   1644: 	if ($numcross > 0) {
                   1645: 	    my @bgcolors=("#eeeeee","#cccccc");
                   1646: 	    $response .= qq(You indicated that you wish to add an additional $numcross crosslisting(s).  For each new crosslisting enter the insititutional course section code (e.g., fs03zol101001, for section 001 of zol101 for fs03 semester), and the LON-CAPA section/group ID you wish to assign to students who will be enrolled in your LON-CAPA class as a result of their registration in the crosslisted course section. The LON-CAPA section/group ID can be left blank, if you do not wish to tie a section/group ID to this crosslisting.  The institutional course section code should only contain letters and/or numbers, and must be consistent with the scheme adopted by your Domain Coordinator to map course codes (and section numbers) to your institution\'s student information system.<br/><br/>
1.1       raeburn  1647:            <form name="enter" method="post">
                   1648:            <table border="0" cellpadding="2" cellspacing="2" width="100%">
                   1649:              <tr>
                   1650:               <td>
                   1651:                <table border="0" cellspacing="3" cellpadding="3">
                   1652:                 <tr bgcolor="#CCCCFF" align="left">
                   1653:                  <td><b>Crosslisting</b></td>
                   1654:                  <td><b>LON-CAPA section/groupID</b></td>
                   1655:                 </tr>
1.15      albertel 1656: 			    );
                   1657: 	    for (my $i=0; $i<$numcross; $i++) {
                   1658: 		my $colflag = $i%2;
                   1659: 		$response .= qq(
1.1       raeburn  1660:                 <tr bgcolor="$bgcolors[$colflag]" align="left">
                   1661:                  <td><input type="text" size="15" name="newcross_$i" /></td>
                   1662:                  <td><input type="text" size="10" name="newgroupid_$i" /></td>
                   1663:                 </tr>
1.15      albertel 1664: 				);
                   1665: 	    }
                   1666: 	    $response .= qq(  </table>
1.1       raeburn  1667:               </td>
                   1668:              </tr>
                   1669:              <tr>
                   1670:               <td align="right">
                   1671:                <input type="button" name="newcross" value="Go" onClick="process('newcross')" />
                   1672:               </td>
                   1673:              </tr>
                   1674:             </table>
                   1675:             <input type=\"hidden\" name=\"numcross\" value=\"$numcross\">
                   1676:             <input type=\"hidden\" name=\"action\" value=\"newcross\">
                   1677:             <input type=\"hidden\" name=\"state\" value=\"process\">
                   1678:             </form>
1.15      albertel 1679: 			      );
                   1680:         }
                   1681:     }
                   1682:     &print_reply($r,$response,$$tasktitleref{$action});
                   1683:     return;
1.1       raeburn  1684: }
                   1685: 
                   1686: sub print_crosslistings_response () {
1.15      albertel 1687:     my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
                   1688:     my %settings = &Apache::lonnet::get('environment',['internal.crosslistings','internal.coursecode','internal.courseowner'],$dom,$crs);
                   1689:     my @currxlists = ();
                   1690:     my @xlists = ();
                   1691:     my @allxlists = ();
                   1692:     my @badxlists = ();
                   1693:     my @badowner = ();
                   1694:     my $numcross = 0;
                   1695:     my $xliststr =  $settings{'internal.crosslistings'};
                   1696:     my $coursecode = $settings{'internal.coursecode'};
                   1697:     my $owner = $settings{'internal.courseowner'};
                   1698:     my $response = '';
                   1699:     my $warning = '';
                   1700:     my $warn_prefix = '';
1.1       raeburn  1701: 
1.15      albertel 1702:     if ($xliststr =~ m/,/) {
                   1703: 	@allxlists = split/,/,$xliststr;
                   1704:     } else {
                   1705: 	unless ($xliststr eq '') { $allxlists[0] = $xliststr; }
                   1706:     }
1.1       raeburn  1707: 
1.15      albertel 1708:     if ( exists($ENV{'form.numcross'}) ) {
                   1709: 	$numcross = $ENV{'form.numcross'};
                   1710:     }
1.1       raeburn  1711: 
1.15      albertel 1712:     if ($numcross > 0) {
                   1713: 	for (my $i=0; $i<$numcross; $i++) {
                   1714: 	    my $xl = "newcross_".$i;
                   1715: 	    my $gp = "newgroupid_".$i;
                   1716: 	    if ( exists($ENV{"form.$xl"}) ) {
                   1717: 		my $coursecheck = '';
                   1718: 		$coursecheck = &Apache::lonnet::auto_validate_courseID($crs,$dom,$ENV{"form.$xl"});
                   1719: 		if ($coursecheck eq 'ok') {
                   1720: 		    my $addcheck = '';
                   1721: 		    $addcheck = &Apache::lonnet::auto_new_course($crs,$dom,$ENV{"form.$xl"},$owner);
                   1722: 		    if ($addcheck eq 'ok') {
                   1723: 			push @xlists,$ENV{"form.$xl"}.":".$ENV{"form.$gp"};
                   1724: 		    } else {
                   1725: 			push @badowner,$ENV{"form.$xl"}.":".$ENV{"form.$gp"};
                   1726: 		    }
                   1727: 		} else {
                   1728: 		    push @badxlists, $ENV{"form.$xl"}.":".$ENV{"form.$gp"}.":".$coursecheck;
                   1729: 		}
                   1730: 	    }
                   1731: 	}
                   1732: 	push @allxlists, @xlists;
                   1733:     }
                   1734:     
                   1735:     if (@xlists > 0 ) {
                   1736: 	unless ($xliststr eq '') { $xliststr .= ","; }
                   1737: 	if (@xlists > 1) {
                   1738: 	    $xliststr .= join(",",@xlists);
                   1739: 	} else {
                   1740: 	    $xliststr .= $xlists[0];
                   1741: 	}
                   1742: 	my %cenv = ('internal.crosslistings' => $xliststr);
                   1743: 	my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
                   1744: 	if ($reply !~ /^ok$/) {
                   1745: 	    $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged.<br/><br/>";
                   1746: 	} else {
                   1747: 	    $response = "The courses listed below are now crosslisted with this LON-CAPA course, and students enrolling in these course sections will be automatically added to the class roster for the course, if you have chosen to enable a nightly automated enrollment update.<br/><ul>\n";
                   1748: 	    foreach (@allxlists) {
                   1749: 		my ($xlist,$gp) = split/:/,$_;
                   1750: 		$response .= "<li>$xlist - ID: $gp</li>\n";
                   1751: 	    }
                   1752: 	    $response .= "</ul><br/><br/>\n";
                   1753: 	}
                   1754:     } else {
                   1755: 	if ($xliststr =~ m/:/) {
                   1756: 	    my @oldxlists = ();
                   1757: 	    if ($xliststr =~ m/,/) {
                   1758: 		@oldxlists = split/,/,$xliststr;
                   1759: 	    } else {
                   1760: 		$oldxlists[0] = $xliststr;
                   1761: 	    }
                   1762: 	    $response .= "Although no new crosslistings were added, the courses listed below continue to be crosslisted with your LON-CAPA course.<br/><ul>\n";
                   1763: 	    foreach (@oldxlists) {
                   1764: 		my ($xlist,$gp) = split/:/,$_;
                   1765: 		$response .= "<li>$xlist - ID: $gp</li>\n";
                   1766: 	    }
                   1767: 	    $response .= "</ul><br/><br/>\n";
                   1768: 	}
                   1769:     }
                   1770:     if (@badxlists > 0) {
                   1771: 	$response .= "The courses listed below could not be included in the crosslistings for this LON-CAPA course, because they are not valid courses according to your institution's official schedule of classes and sections.<br/><ul>\n";
                   1772: 	foreach (@badxlists) {
                   1773: 	    my ($xlist,$gp,$prob) = split/:/,$_;
                   1774: 	    $response .= "<li>$xlist - ID: $gp - Error: $prob</li>\n";
                   1775: 	}
                   1776: 	$response .= "</ul><br/><br/>\n";
                   1777:     }
                   1778:     
                   1779:     if (@badowner > 0) {
                   1780: 	$response .= "The courses listed below could not be included in the crosslistings for this LON-CAPA course, because the owner of this course - $owner - does not have rights to view enrollment in those classes as determined by your instititution's policies on access to official classlists.<br/><ul>\n";
                   1781: 	foreach (@badowner) {
                   1782: 	    my ($xlist,$gp) = split/:/,$_;
                   1783: 	    $response .= "<li>$xlist - ID: $gp</li>\n";
                   1784: 	}
                   1785: 	$response .= "</ul><br/><br/>\n";
                   1786:     }
1.5       raeburn  1787: 
1.15      albertel 1788:     if (@allxlists > 0) {
                   1789: 	$warning = &warning_message($dom,$crs,$action);
                   1790: 	$warn_prefix = "<br/><font size ='+1'><b>Warning</b></font>. Although you have selected crosslisted courses to contribute enrollment to this course, additional action is required.<br/>";
                   1791: 	unless ($warning eq '') {
                   1792: 	    $response .= $warn_prefix.$warning;
                   1793: 	}
                   1794:     }
1.1       raeburn  1795: 
1.15      albertel 1796:     &print_reply($r,$response,$$tasktitleref{$action});
                   1797:     return;
1.1       raeburn  1798: }
                   1799: 
                   1800: sub print_sections_menu () {
1.15      albertel 1801:     my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
                   1802:     my %settings = &Apache::lonnet::get('environment',['internal.sectionnums','internal.coursecode','internal.courseowner'],$dom,$crs);
                   1803:     my @currsections = ();
                   1804:     my @sections = ();
                   1805:     my @badowner = ();
                   1806:     my @badsections = ();
                   1807:     my $seccount = 0;
                   1808:     my $removecount = 0;
                   1809:     my $addcount = 0;
                   1810:     my $secstr = '';
                   1811:     my $response = '';
                   1812:     my $warning = "";
                   1813:     my $warn_prefix = "";
                   1814:     my $coursecode = $settings{'internal.coursecode'};
                   1815:     my $owner = $settings{'internal.courseowner'};
                   1816:     if ($settings{'internal.sectionnums'} =~ m/,/) {
                   1817: 	@currsections = split/,/,$settings{'internal.sectionnums'};
                   1818:     } elsif ($settings{'internal.sectionnums'} ne '') {
                   1819: 	$currsections[0] = $settings{'internal.sectionnums'};
                   1820:     }
                   1821:     
                   1822:     if ( exists($ENV{'form.secshow'}) ) {
                   1823: 	for (my $i=0; $i<$ENV{'form.secshow'}; $i++) {
                   1824: 	    my $gp = "loncapasec_".$i;
                   1825: 	    my $secnum = "secnum_".$i;
                   1826: 	    my $sec = "sec_".$i;
                   1827: 	    if ( exists( $ENV{"form.$sec"} ) ) {
                   1828: 		my $secentry;
                   1829: 		if ( exists( $ENV{"form.$secnum"} ) ) { 
                   1830: 		    $secentry = $ENV{"form.$secnum"}.':';
                   1831: 		}
                   1832: 		if ( exists( $ENV{"form.$gp"} ) ) {
                   1833: 		    $secentry .= $ENV{"form.$gp"};
                   1834: 		}
                   1835: 		if ( grep/^$ENV{"form.$secnum"}:/,@currsections) {
                   1836: 		    push @sections, $secentry;
                   1837: 		    $seccount ++;
                   1838: 		} else {
                   1839: 		    my $newsec = $coursecode.$ENV{"form.$secnum"};
                   1840: 		    my $coursecheck = &Apache::lonnet::auto_validate_courseID($crs,$dom,$newsec);
                   1841: 		    if ($coursecheck eq 'ok') {
                   1842: 			my $addcheck = &Apache::lonnet::auto_new_course($crs,$dom,$newsec,$owner);
                   1843: 			if ($addcheck eq 'ok') {
                   1844: 			    push @sections,$ENV{"form.$secnum"}.":".$ENV{"form.$gp"};
                   1845: 			    $seccount ++;
                   1846: 			    $addcount ++;
                   1847: 			} else {
                   1848: 			    push @badowner,$ENV{"form.$secnum"}.":".$ENV{"form.$gp"};
                   1849: 			}
                   1850: 		    } else {
                   1851: 			push @badsections, $ENV{"form.$secnum"}.":".$ENV{"form.$gp"}.":".$coursecheck;
                   1852: 		    }
                   1853: 		}
                   1854: 	    }
                   1855: 	}
                   1856: 	if (@currsections > 0) {
                   1857: 	    for (my $i=0; $i<@currsections; $i++) {
                   1858: 		if ($currsections[$i] =~ m/^(\w+:)/ ) {
                   1859: 		    my $oldsec  = $1;
                   1860: 		    unless (grep/^$oldsec/,@sections) {
                   1861: 			$removecount ++;
                   1862: 		    }
                   1863: 		}
                   1864: 	    }
                   1865: 	}
                   1866:     } elsif (@currsections > 0) {
                   1867: 	for (my $i=0; $i<@currsections; $i++) {
                   1868: 	    my $sec = "sec_".$i;
                   1869: 	    my $gp = "secgp_".$i;
                   1870: 	    if ( exists($ENV{"form.$sec"}) ) {
                   1871: 		my $secentry = '';
                   1872: 		if ($currsections[$i] =~ m/^(\w+:)/ ) {
                   1873: 		    $secentry = $1;
                   1874: 		}
                   1875: 		if ( exists($ENV{"form.$gp"}) ) {
                   1876: 		    $secentry .= $ENV{"form.$gp"};
                   1877: 		}
                   1878: 		push @sections,$secentry;
                   1879: 		$seccount ++;
                   1880: 	    } else {
                   1881: 		$removecount ++;
                   1882: 	    }
                   1883: 	}
                   1884:     }
                   1885:     
                   1886:     if ($seccount > 1) {
                   1887: 	$secstr = join(",",@sections);
                   1888:     } else {
                   1889: 	$secstr = $sections[0];
                   1890:     }
                   1891:     my %cenv = ('internal.sectionnums' => $secstr);
                   1892:     my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
                   1893:     if ($reply !~ /^ok$/) {
                   1894: 	$response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged.<br/>";
                   1895:     } else {
                   1896: 	if ($removecount > 0) {
                   1897: 	    $response = "A total of $removecount sections have been removed from the list of sections which contribute to enrollment in LON-CAPA course: $realm ($coursecode).<br/><br/>";
                   1898: 	}
                   1899: 	if ($addcount > 0) {
                   1900: 	    $response .= "A total of $addcount sections have been added to the list of
1.6       raeburn  1901: sections which contribute to enrollment in LON-CAPA course: $realm ($coursecode).<br/><br/>";
1.15      albertel 1902: 	}
                   1903: 	if ($seccount > 0) { 
                   1904: 	    $response .= "Students enrolling in the $seccount section(s) listed below will be automatically added to the class roster for the course, if you have chosen to enable a nightly automated enrollment update.<br/><ul>\n";
                   1905: 	    foreach (@sections) {
                   1906: 		my ($sec,$gp) = split/:/,$_;
                   1907: 		$response .= "<li>$sec  - ID: $gp</li>\n";
                   1908: 	    }
                   1909: 	    $response .= "</ul><br/>\n";
                   1910: 	}
                   1911:     }
                   1912:     
                   1913:     if (@badsections > 0) {
                   1914: 	$response .= "The sections listed below could not be included in the sections for this LON-CAPA course, because they are not valid section numbers according to your institution's official schedule of classes and sections.<br/><ul>\n";
                   1915: 	foreach (@badsections) {
                   1916: 	    my ($secnum,$gp,$prob) = split/:/,$_;
                   1917: 	    $response .= "<li>$secnum - ID: $gp - Error: $prob</li>\n";
                   1918: 	}
                   1919: 	$response .= "</ul><br/><br/>\n";
                   1920:     }
                   1921:     
                   1922:     if (@badowner > 0) {
                   1923: 	$response .= "The sections listed below could not be included in the sections for this LON-CAPA course, because the owner of this course - $owner - does not have rights to view enrollment in those classes as determined by your instititution's policies on access to official classlists.<br/><ul>\n";
                   1924: 	foreach (@badowner) {
                   1925: 	    my ($secnum,$gp) = split/:/,$_;
                   1926: 	    $response .= "<li>$secnum - ID: $gp</li>\n";
                   1927: 	}
                   1928: 	$response .= "</ul><br/><br/>\n";
                   1929:     }
                   1930:     
                   1931:     if ($seccount > 0) {
                   1932: 	$warning = &warning_message($dom,$crs,$action);
                   1933: 	$warn_prefix = "<br/><font size ='+1'><b>Warning</b></font>. Although you have selected sections to contribute enrollment to this course, additional action is required.<br/>";
                   1934: 	unless ($warning eq '') {
                   1935: 	    $response .= $warn_prefix.$warning;
                   1936: 	}
                   1937:     }
                   1938:     
                   1939:     if ( exists($ENV{'form.numsec'}) ) {
                   1940: 	my $numsec = $ENV{'form.numsec'};
                   1941: 	if ($numsec > 0) {
                   1942: 	    my @bgcolors=("#eeeeee","#cccccc");
                   1943: 	    $response .= qq(
                   1944: 			    You indicated that you wish to incorporate student enrollment in your LON-CAPA course from an additional $numsec section(s).  For each new section enter the insititutional section code (e.g., 004), and the LON-CAPA section/group ID you wish to assign to students who will be enrolled in your LON-CAPA class as a result of their registration in this particular section. The LON-CAPA section/group ID can be left blank, if you do not wish to designate a section/group ID for this course section.  The institutional section code should only contain letters and/or numbers, and must be consistent with the scheme adopted by your Domain Coordinator to map course section numbers to your institution\'s student information system.<br/><br/> 
1.1       raeburn  1945:            <form name="enter" method="post">
                   1946:            <table border="0" cellpadding="2" cellspacing="2" width="100%">
                   1947:              <tr>
                   1948:               <td>
                   1949:                <table border="0" cellspacing="3" cellpadding="3">
                   1950:                 <tr bgcolor="#CCCCFF" align="left">
                   1951:                  <td><b>Section number</b></td>
                   1952:                  <td><b>LON-CAPA section/groupID</b></td>
                   1953:                 </tr>
1.15      albertel 1954: 			    );
                   1955: 	    for (my $i=0; $i<$numsec; $i++) {
                   1956: 		my $colflag = $i%2;
                   1957: 		$response .= qq(
1.1       raeburn  1958:                 <tr bgcolor="$bgcolors[$colflag]" align="left">
                   1959:                  <td><input type="text" size="15" name="newsec_$i" /></td>
                   1960:                  <td><input type="text" size="10" name="newsecgp_$i" /></td>
                   1961:                 </tr>
1.15      albertel 1962: 				);
                   1963: 	    }
                   1964: 	    $response .= qq(  </table>
1.1       raeburn  1965:               </td>
                   1966:              </tr>
                   1967:              <tr>
                   1968:               <td align="right">
                   1969:                <input type="button" name="newsections" value="Go" onClick="process('newsections')" />
                   1970:               </td>
                   1971:              </tr>
                   1972:             </table>
                   1973:             <input type=\"hidden\" name=\"numsec\" value=\"$numsec\">
                   1974:             <input type=\"hidden\" name=\"action\" value=\"newsections\">
                   1975:             <input type=\"hidden\" name=\"state\" value=\"process\">
                   1976:             </form>
1.15      albertel 1977: 			      );
                   1978: 	}
                   1979:     }
                   1980:     &print_reply($r,$response,$$tasktitleref{$action});
                   1981:     return;
1.1       raeburn  1982: }
                   1983: 
                   1984: sub print_sections_response () {
1.15      albertel 1985:     my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
                   1986:     my %settings = &Apache::lonnet::get('environment',['internal.sectionnums','internal.coursecode','internal.courseowner'],$dom,$crs);
                   1987:     my @currsections = ();
                   1988:     my @sections = ();
                   1989:     my @allsections = ();
                   1990:     my @badowner = ();
                   1991:     my @badsections = ();
                   1992:     my $numsec = 0;
                   1993:     my $secstr =  $settings{'internal.sectionnums'};
                   1994:     my $coursecode = $settings{'internal.coursecode'};
                   1995:     my $owner = $settings{'internal.courseowner'};
                   1996:     my $response = '';
                   1997:     my $putreply = '';
                   1998:     my $warning = '';
                   1999:     my $warn_prefix = '';
                   2000:     if ($secstr =~ m/,/) {
                   2001: 	@allsections = split/,/,$secstr;
                   2002:     } else {
                   2003: 	unless ($secstr eq '') { $allsections[0] = $secstr; }
                   2004:     }
                   2005:     
                   2006:     if ( exists($ENV{'form.numsec'}) ) {
                   2007: 	$numsec = $ENV{'form.numsec'};
                   2008:     }
                   2009:     
                   2010:     if ($numsec > 0) {
                   2011: 	for (my $i=0; $i<$numsec; $i++) {
                   2012: 	    my $sec = "newsec_".$i;
                   2013: 	    my $gp = "newsecgp_".$i;
                   2014: 	    if ( exists($ENV{"form.$sec"}) ) {
                   2015: 		unless ( (grep/^$ENV{"form.$sec"}:/,@allsections) || (grep/^$ENV{"form.$sec"}:/,@sections) ) {
                   2016: 		    my $newsec = $coursecode.$ENV{"form.$sec"};
                   2017: 		    my $coursecheck = &Apache::lonnet::auto_validate_courseID($crs,$dom,$newsec);
                   2018: 		    if ($coursecheck eq 'ok') {
                   2019: 			my $addcheck = &Apache::lonnet::auto_new_course($crs,$dom,$newsec,$owner);
                   2020: 			if ($addcheck eq 'ok') {
                   2021: 			    push @sections,$ENV{"form.$sec"}.":".$ENV{"form.$gp"};
                   2022: 			} else {
                   2023: 			    push @badowner,$ENV{"form.$sec"}.":".$ENV{"form.$gp"};
                   2024: 			}
                   2025: 		    } else {
                   2026: 			push @badsections, $ENV{"form.$sec"}.":".$ENV{"form.$gp"}.":".$coursecheck;
                   2027: 		    }
                   2028: 		}
                   2029: 	    }
                   2030: 	}
                   2031: 	push @allsections, @sections;
                   2032:     }
                   2033:     
                   2034:     if (@sections > 0 ) {
                   2035: 	unless ($secstr eq '') { $secstr .= ","; } 
                   2036: 	if (@sections > 1) {
                   2037: 	    $secstr .= join(",",@sections);
                   2038: 	} else {
                   2039: 	    $secstr .= $sections[0];
                   2040: 	}
                   2041: 	my %cenv = ('internal.sectionnums' => $secstr);
                   2042: 	$putreply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
                   2043: 	if ($putreply !~ /^ok$/) {
                   2044: 	    $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged.<br/><br/>";
                   2045: 	}
                   2046:     }
                   2047: 
                   2048:     if ($putreply =~ /^ok/) {
                   2049: 	$response = "Students enrolling in the sections listed below will be automatically added to the class roster for LON-CAPA course $realm ($coursecode), if you have chosen to enable a nightly automated enrollment update.<br/><ul>\n";
                   2050: 	foreach (@allsections) {
                   2051: 	    my ($sec,$gp) = split/:/,$_;
                   2052: 	    $response .= "<li>$sec - ID: $gp</li>\n";
                   2053: 	}
                   2054: 	$response .= "</ul><br/><br/>\n";
                   2055:     }
                   2056: 
                   2057:     if (@badsections > 0) {
                   2058: 	$response .= "The sections listed below could not be included in the sections for this LON-CAPA course, because they are not valid section numbers according to your institution's official schedule of classes and sections.<br/><ul>\n";
                   2059: 	foreach (@badsections) {
                   2060: 	    my ($secnum,$gp,$prob) = split/:/,$_;
                   2061: 	    $response .= "<li>$secnum - ID: $gp - Error: $prob</li>\n";
                   2062: 	}
                   2063: 	$response .= "</ul><br/><br/>\n";
                   2064:     }
                   2065: 
                   2066:     if (@badowner > 0) {
                   2067: 	$response .= "The sections listed below could not be included in the sections for this LON-CAPA course, because the owner of this course - $owner - does not have rights to view enrollment in those classes as determined by your instititution's policies on access to official classlists.<br/><ul>\n";
                   2068: 	foreach (@badowner) {
                   2069: 	    my ($secnum,$gp) = split/:/,$_;
                   2070: 	    $response .= "<li>$secnum - ID: $gp</li>\n";
                   2071: 	}
                   2072: 	$response .= "</ul><br/><br/>\n";
                   2073:     }
                   2074: 
                   2075:     if (@allsections > 0) {
                   2076: 	$warning = &warning_message($dom,$crs,$action);
                   2077: 	$warn_prefix = "<br/><font size ='+1'><b>Warning</b></font>. Although you have selected sections to contribute enrollment to this course, additional action is required.<br/>";
                   2078: 	unless ($warning eq '') {
                   2079: 	    $response .= $warn_prefix.$warning;
                   2080: 	}
                   2081:     }
1.1       raeburn  2082: 
1.15      albertel 2083:     &print_reply($r,$response,$$tasktitleref{$action});
                   2084:     return;
1.1       raeburn  2085: }
                   2086: 
                   2087: sub print_photos_response () {
1.15      albertel 2088:     my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
                   2089:     my %settings = &Apache::lonnet::get('environment',['internal.showphotos'],$dom,$crs);
                   2090:     my $currphotos = $settings{'internal.showphotos'};
                   2091:     my $showphotos = '';
                   2092:     if ( exists($ENV{'form.showphotos'}) ) {
                   2093: 	$showphotos=$ENV{'form.showphotos'};
                   2094:     }
                   2095:     
                   2096:     my $response = "";
                   2097:     my %cenv = ('internal.showphotos' => $showphotos);
                   2098:     my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
                   2099:     if ($reply !~ /^ok$/) {
                   2100: 	$response = "There was a problem processing your requested change. The student photo import setting for this course has been left unchanged.<br/>";
                   2101:     } else {
                   2102: 	if ($showphotos) {
                   2103: 	    if ($currphotos) {
                   2104: 		$response = "Retrieval of student photos is still <b>enabled</b><br/>";
                   2105: 	    } else {
                   2106: 		$response = "Retrieval of student photos in now <b>enabled</b><br/>";
                   2107: 	    }
                   2108: 	} else {
                   2109: 	    if ($currphotos) {
                   2110: 		$response = "Retrieval of student photos is now <b>disabled</b><br/>";
                   2111: 	    } else {
                   2112: 		$response = "Retrieval of student photos is still <b>disabled</b><br/>";
                   2113: 	    }
                   2114: 	}
                   2115:     }
                   2116:     &print_reply($r,$response,$$tasktitleref{$action});
                   2117:     return;
1.1       raeburn  2118: }
                   2119: 
                   2120: sub print_update_result () {
1.15      albertel 2121:     my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
                   2122:     my $response = '';
                   2123:     my $updateadds = 0;
                   2124:     my $updatedrops = 0;
                   2125:     my $changecount = 0;
                   2126:     my %affiliates = ();
                   2127:     my %reply = ();
                   2128:     my @allcourses = ();
                   2129:     my %LC_code = ();
                   2130:     my $logmsg = '';
                   2131:     my $newusermsg = '';
                   2132: 
                   2133:     my %settings = &Apache::lonnet::get('environment',['internal.coursecode','internal.sectionnums','internal.crosslistings','internal.authtype','internal.autharg'],$dom,$crs);
                   2134:     my $coursecode = $settings{'internal.coursecode'};
                   2135:     my $authtype = $settings{'internal.authtype'};
                   2136:     my $autharg = $settings{'internal.autharg'};
                   2137:     my ($startaccess,$endaccess) = &get_dates_from_form();
                   2138:     if ( exists($ENV{'form.updateadds'}) ) {
1.19      raeburn  2139:         $updateadds = $ENV{'form.updateadds'};
1.15      albertel 2140:     }
                   2141:     if ( exists($ENV{'form.updatedrops'}) ) {
1.19      raeburn  2142:         $updatedrops = $ENV{'form.updatedrops'};
1.15      albertel 2143:     }
1.19      raeburn  2144:     if (($startaccess eq '') || ($endaccess eq '')) {
                   2145:         $response = "There was a problem processing your requested roster update because start and and access dates could not be determined. No changes have been made to the class roster.<br />"; 
                   2146:     } elsif ($updateadds && (($endaccess > 0) && ($endaccess <= $startaccess))) {
                   2147:         $response = 'The start access date/time is the same or later than the end access date/time. As this means that new roles will never be active, your requested roster update has not been carried out, and the roster remains unchanged. Please <a href="javascript:history.go(-1)">go back</a> to the previous page to try your changes again.'."\n";
                   2148:     } elsif (!$updateadds && !$updatedrops) {
1.15      albertel 2149: 	$response = "An update of the class roster has not been carried out because you indicated that you wanted to neither add new students, nor expire dropped students based on a comparison between the institutional class lists for the course sections and crosslisted courses that contribure enrollment to this LON-CAPA course.";
                   2150:     } elsif ($coursecode eq '') {
                   2151: 	$response = "There was a problem retrieving the course code for this LON-CAPA course.  An update of the class roster has not been carried out, and enrollment remains unchanged";
                   2152:     } else {
1.1       raeburn  2153: # Get complete list of course sections to update
1.15      albertel 2154: 	my @currsections = ();
                   2155: 	my @currxlists = ();
                   2156: 	
                   2157: 	if ($settings{'internal.sectionnums'} =~ m/,/) {
                   2158: 	    @currsections = split/,/,$settings{'internal.sectionnums'};
                   2159: 	} elsif ($settings{'internal.sectionnums'} ne '') {
                   2160: 	    $currsections[0] = $settings{'internal.sectionnums'};
                   2161: 	}
                   2162: 	
                   2163: 	if ($settings{'internal.crosslistings'} =~ m/,/) {
                   2164: 	    @currxlists = split/,/,$settings{'internal.crosslistings'};
                   2165: 	} elsif ($settings{'internal.crosslistings'} ne '') {
                   2166: 	    $currxlists[0] = $settings{'internal.crosslistings'};
                   2167: 	}
                   2168: 	
                   2169: 	if (@currxlists > 0) {
                   2170: 	    foreach (@currxlists) {
                   2171: 		if (m/^(\w+):(\w*)$/) {
                   2172: 		    unless (grep/^$1$/,@allcourses) { 
                   2173: 			push @allcourses,$1;
                   2174: 			$LC_code{$1} = $2; 
                   2175: 		    }
                   2176: 		}
                   2177: 	    }
                   2178: 	}
                   2179: 	
                   2180: 	if (@currsections > 0) {
                   2181: 	    foreach (@currsections) {
                   2182: 		if (m/^(\w+):(\w*)$/) {
                   2183: 		    my $sec = $coursecode.$1;
                   2184: 		    my $gp = $2;
                   2185: 		    unless (grep/^$sec$/,@allcourses) { 
                   2186: 			push @allcourses,$sec;
                   2187: 			$LC_code{$sec} = $gp; 
                   2188: 		    }
                   2189: 		}
                   2190: 	    }
                   2191: 	}
                   2192: 
                   2193: 	if (@allcourses > 0) {
                   2194: 	    @{$affiliates{$crs}} = @allcourses;
                   2195: 	    my $outcome = &Apache::lonnet::fetch_enrollment_query('updatenow',\%affiliates,\%reply,$dom,$crs);
1.19      raeburn  2196:             unless ($outcome eq 'ok') {
                   2197:                 &Apache::lonnet::logthis("lonpopulate:update roster".
                   2198:                                          "failed to retrieve classlist".
                   2199:                                  " data for ".$crs."\@".$dom." by ".
                   2200:                                  $ENV{'user.name'}." \@ ".$ENV{'user.domain'}.
                   2201:                                  ": ".$outcome);
                   2202:             }
1.15      albertel 2203: 	    if ($reply{$crs} > 0) {
                   2204: 		($changecount,$response) = &LONCAPA::Enrollment::update_LC($dom,$crs,$updateadds,$updatedrops,$startaccess,$endaccess,$authtype,$autharg,\@allcourses,\%LC_code,\$logmsg,\$newusermsg,"updatenow");
                   2205: 	    } else {
                   2206: 		$response = "There was a problem retrieving institutional class list data for the course sections and crosslisted courses which contribute enrollment to this course. No updates have been carried out, and the roster remains unchanged.";
                   2207: 	    }  
                   2208: 	} else {
                   2209: 	    $response = "There are currently no course sections or crosslisted courses designated as contributors to enrollment in this LON-CAPA course. As a result a student roster update has not been carried out for $realm ($coursecode)";
                   2210: 	}
                   2211:     }
                   2212:     unless ($logmsg eq '') {
                   2213: 	my $loglength = length($logmsg);
                   2214: 	$logmsg = substr($logmsg,0,$loglength-4);
                   2215: 	$logmsg = "<br/><br/>The following messages were generated by the roster update process: <br/><ul><li>".$logmsg."</ul><br/>";
                   2216:     }
                   2217:     unless ($newusermsg eq '') {
                   2218: 	$newusermsg = substr( $newusermsg,0,rindex($newusermsg,'<li>') );
1.19      raeburn  2219: 	$newusermsg = "<br/><br/>The following new system user(s) who was/were created will be using local or internal authentication with an initial randomly generated password. A valid e-mail address was not available for this/these user(s) so LON-CAPA account credentials could not be sent via e-mail.<br/><ul><li>".$newusermsg."</ul><br/>";
1.15      albertel 2220:     }
                   2221:     $response .= $logmsg.$newusermsg;
                   2222:     &print_reply($r,$response,$$tasktitleref{$action});
                   2223:     return;
1.10      raeburn  2224: }
                   2225: 
1.14      raeburn  2226: sub print_viewclass_response {
                   2227:     my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
                   2228:     my $response;
                   2229:     my $chgtotal = 0;
                   2230:     my $chgok = 0;
                   2231:     my $chgfail = 0;
                   2232:     my $othdom = 0;
1.16      raeburn  2233:     my $locktotal = 0;
                   2234:     my $lockok = 0;
                   2235:     my $lockfail = 0;
1.14      raeburn  2236:     my $cid = $dom."_".$crs;
                   2237:     my %chg = ();
                   2238:     my %nochg = ();
                   2239:     my %otherdom = ();
1.16      raeburn  2240:     my %lockchg = ();
                   2241:     my %nolockchg = ();
1.14      raeburn  2242:     my $classlist = &Apache::loncoursedata::get_classlist($cid,$dom,$crs);
                   2243:     my $endidx = &Apache::loncoursedata::CL_END;
                   2244:     my $startidx = &Apache::loncoursedata::CL_START;
                   2245:     my $ididx=&Apache::loncoursedata::CL_ID;
                   2246:     my $secidx=&Apache::loncoursedata::CL_SECTION;
                   2247:     my $typeidx=&Apache::loncoursedata::CL_TYPE;
1.16      raeburn  2248:     my $lockedidx=&Apache::loncoursedata::CL_LOCKEDTYPE;
                   2249:     my @typechglist = ();
                   2250:     my @lockchglist = ();
                   2251:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['chgauto','chgmanual','lockchg','unlockchg']);
                   2252:     if ($ENV{'form.chgauto'}) {
                   2253:         if (ref($ENV{'form.chgauto'}) eq 'ARRAY') {
                   2254:             push @typechglist, @{$ENV{'form.chgauto'}};
                   2255:         } else {
                   2256:             push @typechglist, $ENV{'form.chgauto'};
                   2257:         }
                   2258:     }
                   2259:     if ($ENV{'form.chgmanual'}) {
                   2260:         if (ref($ENV{'form.chgmanual'}) eq 'ARRAY') {
                   2261:             push @typechglist, @{$ENV{'form.chgmanual'}};
                   2262:         } else {
                   2263:             push @typechglist, $ENV{'form.chgmanual'};
                   2264:         }
                   2265:     }
                   2266:     if ($ENV{'form.lockchg'}) {
                   2267:         if (ref($ENV{'form.lockchg'}) eq 'ARRAY') {
                   2268:             push @lockchglist, @{$ENV{'form.lockchg'}};
                   2269:         } else {
                   2270:             push @lockchglist, $ENV{'form.lockchg'};
                   2271:         }
                   2272:     }
                   2273:     if ($ENV{'form.unlockchg'}) {
                   2274:         if (ref($ENV{'form.unlockchg'}) eq 'ARRAY') {
                   2275:             push @lockchglist, @{$ENV{'form.unlockchg'}};
                   2276:         } else {
                   2277:             push @lockchglist, $ENV{'form.unlockchg'};
                   2278:         }
                   2279:     }
                   2280:     foreach my $student (sort @typechglist) {
                   2281:         my ($uname,$udom) = split/:/,$student;
                   2282:         my $sdata    = $classlist->{$student};
                   2283:         my $section  = $sdata->[$secidx];
                   2284:         my $uid       = $sdata->[$ididx];
                   2285:         my $start    = $sdata->[$startidx];
                   2286:         my $end      = $sdata->[$endidx];
                   2287:         my $type     = $sdata->[$typeidx];
                   2288:         my $lock   = $sdata->[$lockedidx];
                   2289:         my $newlock = $lock;
                   2290:         $chgtotal ++;
                   2291:         my $newtype = 'auto';
                   2292:         my $change = 'auto';
                   2293:         my $oldtype = 'manual';
                   2294:         if ($type eq 'auto') { 
                   2295:             $oldtype = 'auto';
                   2296:             $newtype = '';
                   2297:             $change = 'manual';
                   2298:         }
                   2299:         if ($udom eq $dom) {
                   2300:             if ($newtype eq 'auto') {
                   2301:                 $newlock = '';
                   2302:             } elsif ($newtype eq '') {
                   2303:                 $newlock = '1';
1.14      raeburn  2304:             }
1.16      raeburn  2305:             my $modreply = &Apache::lonnet::modify_student_enrollment($udom,$uname,$uid,'','','','',$section,$end,$start,$newtype,$newlock,$cid);
                   2306:             if ($modreply eq 'ok') {
                   2307:                 $chgok ++;
                   2308:                 $chg{$student} = "Changed to $change";
                   2309:             } else {
                   2310:                 $chgfail ++;
                   2311:                 $nochg{$student} = "Still set to $oldtype";
                   2312:             } 
                   2313:         } else {
                   2314:             $othdom ++;
                   2315:             $otherdom{$student} = "Still set to $oldtype"; 
                   2316:         }
                   2317:     }
                   2318:     foreach my $student (@lockchglist) {
                   2319:         my ($uname,$udom) = split/:/,$student;
                   2320:         my $sdata    = $classlist->{$student};
                   2321:         my $section  = $sdata->[$secidx];
                   2322:         my $uid       = $sdata->[$ididx];
                   2323:         my $start    = $sdata->[$startidx];
                   2324:         my $end      = $sdata->[$endidx];
                   2325:         my $type     = $sdata->[$typeidx];
                   2326:         my $lock   = $sdata->[$lockedidx];
                   2327:         my $newlock = 1;
                   2328:         my $oldlockname = &mt('unlocked');
                   2329:         my $newlockname = &mt('locked');
                   2330:         $locktotal++;
                   2331:         unless ($type eq 'auto') {
                   2332:             if ($lock) {
                   2333:                 $newlock = '';
                   2334:                 $newlockname = &mt('unlocked');
                   2335:                 $oldlockname = &mt('locked'); 
                   2336:             }
                   2337:             my $lockreply = &Apache::lonnet::modify_student_enrollment($udom,$uname,$uid,'','','','',$section,$end,$start,$type,$newlock,$cid);
                   2338:             if ($lockreply eq 'ok') {
                   2339:                 $lockok ++;
                   2340:                 $lockchg{$student} = 'Changed to '.$newlockname;
1.14      raeburn  2341:             } else {
1.16      raeburn  2342:                 $lockfail ++;
                   2343:                 $nolockchg{$student} = 'Still set to '.$oldlockname;
1.14      raeburn  2344:             }
                   2345:         }
                   2346:     }
                   2347:     if ($chgtotal > 0) {
                   2348:         $response = "You requested a change in enrollment type for $chgtotal students.<br /><br />\n";
                   2349:         $classlist = &Apache::loncoursedata::get_classlist($cid,$dom,$crs);
                   2350:         if ($chgok > 0) {
                   2351:             $response .= "The following $chgok changes were successful:<br />";
                   2352:             $response .= &enrolltype_result(\%chg,$classlist,$endidx,$startidx,$ididx,$secidx,$typeidx);
                   2353:         }
                   2354:         if ($chgfail > 0) {
                   2355:             $response .= "The following $chgfail students were not modified successfully:&nbsp;<br />";
                   2356:             $response .= &enrolltype_result(\%nochg,$classlist,$endidx,$startidx,$ididx,$secidx,$typeidx);
                   2357:         }
                   2358:         if ($othdom > 0) {
                   2359:             $response .= "The following $othdom students were not modified because students must be in the same LON-CAPA domain as the course, in order to be set to an enrollment type of 'auto':<br />"; 
                   2360:             $response .= &enrolltype_result(\%otherdom,$classlist,$endidx,$startidx,$ididx,$secidx,$typeidx);
                   2361:         }
1.16      raeburn  2362:         $response .= "<br /><br />";
                   2363:     }
                   2364:     if ($locktotal > 0) {
                   2365:         $response .= "You requested locking/unlocking for $locktotal manually enrolled students.<br /><br />\n";
                   2366:         $classlist = &Apache::loncoursedata::get_classlist($cid,$dom,$crs);
                   2367:         if ($lockok > 0) {
                   2368:             $response .= "The following $lockok changes were successful:<br />";
                   2369:             $response .= &enrolltype_result(\%lockchg,$classlist,$endidx,$startidx,$ididx,$secidx,$typeidx,$lockedidx);
                   2370:         }
                   2371:         if ($lockfail > 0) {
                   2372:             $response .= "The following $lockfail students were not modified successfully:&nbsp;<br />";
                   2373:             $response .= &enrolltype_result(\%nolockchg,$classlist,$endidx,$startidx,$ididx,$secidx,$typeidx,$lockedidx);
                   2374:         }
1.14      raeburn  2375:     }
                   2376:     &print_reply($r,$response,$$tasktitleref{$action});
                   2377:     return;
                   2378: }
                   2379: 
                   2380: sub enrolltype_result {
1.16      raeburn  2381:     my ($changes,$classlist,$endidx,$startidx,$ididx,$secidx,$typeidx,$lockedidx) = @_;
1.14      raeburn  2382:     my $reply = "
                   2383:             <table border='2'>
                   2384:              <tr>
                   2385:               <th>username</th>
                   2386:               <th>domain</th>
                   2387:               <th>ID</th>
                   2388:               <th>student name</th>
                   2389:               <th>section</th>
                   2390:               <th>start date</th>
                   2391:               <th>end date</th>
                   2392:               <th>enrollment change</th>
                   2393:              </tr>";
                   2394:     foreach (sort keys %{$changes}) {
                   2395:         my $sdata  = $classlist->{$_};
                   2396:         my ($uname,$udom) = split/:/,$_;
                   2397:         my $section  = $sdata->[$secidx];
                   2398:         my $uid      = $sdata->[$ididx];
                   2399:         my $start    = $sdata->[$startidx];
                   2400:         my $end      = $sdata->[$endidx];
                   2401:         my $type     = $sdata->[$typeidx];
                   2402:         if (! defined($start) || $start == 0) {
                   2403:             $start = &mt('none');
                   2404:         } else {
                   2405:             $start = &Apache::lonlocal::locallocaltime($start);
                   2406:         }
                   2407:         if (! defined($end) || $end == 0) {
                   2408:             $end = &mt('none');
                   2409:         } else {
                   2410:             $end = &Apache::lonlocal::locallocaltime($end);
                   2411:         }
                   2412:         if (!defined($section) || ($section eq '')) {
                   2413:             $section eq '&nbsp;';
                   2414:         }
                   2415:         if (!defined($uid) || ($uid eq '')) {
                   2416:             $uid = '&nbsp';
                   2417:         }
                   2418:         $reply .= "
                   2419:              <tr>
                   2420:               <td>$uname</td>
                   2421:               <td>$udom</td>
                   2422:               <td>$uid</td>
                   2423:               <td>".&Apache::loncommon::plainname($uname,$udom)."</td>
                   2424:               <td>$section</td>
                   2425:               <td>$start</td>
                   2426:               <td>$end</td>
                   2427:               <td>$$changes{$_}</td>
                   2428:              </tr>";
                   2429:     }
                   2430:     $reply .= "</table>";
                   2431:     return $reply;
                   2432: }
                   2433: 
1.10      raeburn  2434: sub warning_message {
                   2435:     my ($dom,$crs,$caller) = @_;
                   2436:     my %settings = &Apache::lonnet::get('environment',['internal.autoadds','internal.autodrops','internal.sectionnums','internal.crosslistings','internal.autostart','internal.autoend'],$dom,$crs);
                   2437:     my $currend = '';
                   2438:     my $currstart = '';
                   2439:     my $currsecs = '';
                   2440:     my $currxlists = '';
                   2441:     my $warning = '';
                   2442:     my $curradds = '';
                   2443:     my $currdrops = '';
                   2444:     if ( defined($settings{'internal.autoadds'}) ) {
                   2445:         $curradds = $settings{'internal.autoadds'};
                   2446:     }
                   2447:     if (defined($settings{'internal.autodrops'}) ) {
                   2448:         $currdrops = $settings{'internal.autodrops'};
                   2449:     }
                   2450:     if ( defined($settings{'internal.autostart'}) ) {
                   2451:         $currstart = $settings{'internal.autostart'};
                   2452:     }
                   2453:     if ( defined($settings{'internal.autoend'}) ) {
                   2454:         $currend = $settings{'internal.autoend'};
                   2455:     }
                   2456:     if ( defined($settings{'internal.sectionnums'}) ) {
                   2457:         $currsecs = $settings{'internal.sectionnums'};
                   2458:     }
                   2459:     if ( defined($settings{'internal.crosslistings'}) ) {
                   2460:         $currxlists = $settings{'internal.crosslistings'}
                   2461:     }
                   2462:     unless ($caller eq 'setdates') {
                   2463:         if ( ($currstart eq '') && ($currend eq '') )  {
                   2464:             $warning = "You <b>must</b> now use <a href='/adm/populate?action=setdates'>Change enrollment dates</a> to set a start date <i>and</i> an end date for the enrollment (or check the 'No end date' checkbox) for the nightly adds process to actually occur.</br></br>";
                   2465:         }
                   2466:     }
                   2467:     unless ( ($caller eq 'sections') || ($caller eq 'crosslist') ) {
                   2468:         if ( ($currsecs eq '') && ($currxlists eq '') ) {
                   2469:             $warning .= "You <b>must</b> now use <a href='/adm/populate?action=sections'>Section settings</a> and/or <a href='/adm/populate?action=crosslist'>Change crosslistings</a> to choose at least one section of the course, or at least one crosslisted course which will contribute enrollment to this LON-CAPA course.  At present there are <b>NO</b> sections or crosslisted courses that are affiliated with this course that are set to contribute to the automated enrollment process.<br/><br/>";
                   2470:         }
                   2471:     }
                   2472:     unless ( $caller eq 'chgsettings') {
                   2473:         if ( (!$curradds) && (!$currdrops) ) {
                   2474:             $warning .= "You <b>must</b> now use <a href='/adm/populate?action=chgsettings'>Automated adds/drops</a> to enable automated adds and/or drops if you want automatic enrollment updates to occur in this course.<br/><br/>.";
                   2475:         }
                   2476:     }
                   2477:     return $warning;
1.1       raeburn  2478: }
                   2479: 
                   2480: sub print_reply () {
                   2481:   my ($r,$response,$caller) = @_;
                   2482:   $r->print("
                   2483:             <br/><table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\">
                   2484:              <tr>
1.14      raeburn  2485:               <td align=\"left\"><b>$caller</b> - result<br/><br/>$response</td>
1.1       raeburn  2486:              </tr>
                   2487:             </table>
                   2488:   ");
                   2489:   return;
                   2490: }
                   2491: 
                   2492: sub setup_date_selectors {
1.14      raeburn  2493:     my ($starttime,$endtime,$action) = @_;
1.1       raeburn  2494:     if (! defined($starttime)) {
                   2495:         $starttime = time;
1.14      raeburn  2496:         if ($action eq 'setdates') {
                   2497:             if (exists($ENV{'course.'.$ENV{'request.course.id'}.
1.1       raeburn  2498:                             '.default_enrollment_start_date'})) {
1.14      raeburn  2499:                 $starttime = $ENV{'course.'.$ENV{'request.course.id'}.
1.1       raeburn  2500:                                   '.default_enrollment_start_date'};
1.14      raeburn  2501:             }
1.1       raeburn  2502:         }
                   2503:     }
                   2504:     if (! defined($endtime)) {
                   2505:         $endtime = time+(6*30*24*60*60); # 6 months from now, approx
1.14      raeburn  2506:         if ($action eq 'setdates') {
                   2507:             if (exists($ENV{'course.'.$ENV{'request.course.id'}.
1.1       raeburn  2508:                             '.default_enrollment_end_date'})) {
1.14      raeburn  2509:                 $endtime = $ENV{'course.'.$ENV{'request.course.id'}.
1.1       raeburn  2510:                                 '.default_enrollment_end_date'};
1.14      raeburn  2511:             }
1.1       raeburn  2512:         }
                   2513:     }
                   2514:     my $startdateform = &Apache::lonhtmlcommon::date_setter('enter',
                   2515:                                                             'startdate',
                   2516:                                                             $starttime);
                   2517:     my $enddateform = &Apache::lonhtmlcommon::date_setter('enter',
                   2518:                                                           'enddate',
                   2519:                                                           $endtime);
                   2520:     return ($startdateform,$enddateform);
                   2521: }
                   2522: 
                   2523: sub get_dates_from_form {
1.14      raeburn  2524:     my $startdate;
                   2525:     my $enddate;
                   2526:     $startdate = &Apache::lonhtmlcommon::get_date_from_form('startdate');
                   2527:     $enddate   = &Apache::lonhtmlcommon::get_date_from_form('enddate');
1.1       raeburn  2528:     if ( exists ($ENV{'form.no_end_date'}) ) {
                   2529:         $enddate = 0;
                   2530:     }
                   2531:     return ($startdate,$enddate);
                   2532: }
                   2533: 
                   2534: sub date_setting_table {
1.14      raeburn  2535:     my ($starttime,$endtime,$action) = @_;
                   2536:     my ($startform,$endform) = &setup_date_selectors($starttime,$endtime,$action);
1.1       raeburn  2537:     my $perpetual = '<nobr><input type="checkbox" name="no_end_date"';
1.14      raeburn  2538:     if (($action eq 'setdates' && defined($endtime) && $endtime == 0) || (($action eq 'setaccess' || $action eq 'updatenow') && ($endtime eq '' || $endtime == 0)) ) {
1.1       raeburn  2539:         $perpetual .= ' checked';
                   2540:     }
                   2541:     $perpetual.= ' />'.' no ending date</nobr>';
                   2542:     my $start_table = '';
                   2543:     $start_table .= "<table>\n";
                   2544:     $start_table .= '<tr><td align="right">Starting Date</td>'.
                   2545:         '<td>'.$startform.'</td>'.
                   2546:         '<td>&nbsp;</td>'."</tr>\n";
                   2547:     $start_table .= "</table>";
                   2548:     my $end_table = '';
                   2549:     $end_table .= "<table>\n";
                   2550:     $end_table .= '<tr><td align="right">Ending Date</td>'.
                   2551:         '<td>'.$endform.'</td>'.
                   2552:         '<td>'.$perpetual.'</td>'."</tr>\n";
                   2553:     $end_table .= "</table>\n";
                   2554:     return ($start_table, $end_table);
                   2555: }
                   2556: 
                   2557: ###################################################################
                   2558: sub handler {
                   2559:     my $r = shift;
                   2560:     if ($r->header_only) {
                   2561:         $r->content_type('text/html');
                   2562:         $r->send_http_header;
                   2563:         return OK;
                   2564:     }
                   2565:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['action','state']);
                   2566:     #  Needs to be in a course
                   2567:     if (! (($ENV{'request.course.fn'}) &&  (&Apache::lonnet::allowed('cst',$ENV{'request.course.id'})))) {
                   2568:         # Not in a course, or not allowed to modify parms
                   2569:         $ENV{'user.error.msg'}="/adm/populate:cst:0:0:Cannot drop or add students";
                   2570:         return HTTP_NOT_ACCEPTABLE; 
                   2571:     }
                   2572:     # Start page
                   2573:     $r->content_type('text/html');
                   2574:     $r->send_http_header;
                   2575: 
1.14      raeburn  2576:     my @tasks = ("information","chgsettings","setdates","setaccess","notify","crosslist","sections","photos","updatenow","viewclass");
1.1       raeburn  2577:                                                                                  
                   2578:     my %tasklong = (
                   2579:                information => "Task information",
                   2580:                chgsettings => "Automated adds/drops",
                   2581:                setdates => "Change enrollment dates",
1.14      raeburn  2582:                setaccess => "Change access dates",
1.1       raeburn  2583:                notify => "Notification of changes",
                   2584:                crosslist => "Change crosslistings",
                   2585:                sections => "Section settings",
                   2586:                photos => "Student photos",
                   2587:                updatenow => "Update roster now",
                   2588:                newcross => "Add crosslistings",
1.14      raeburn  2589:                newsections => "Add sections",
1.16      raeburn  2590:                viewclass => "View students and change type",
1.1       raeburn  2591:     );
                   2592:                                                                                  
                   2593:     my %tasktitle = (
                   2594:                chgsettings => "Changes to nightly automated enrollments",
                   2595:                setdates => "Changes to first and/or last automated enrollment dates",
1.14      raeburn  2596:                setaccess => "Changes to default start and/or end dates for student access",
1.1       raeburn  2597:                notify => "Notification of enrollment changes",
                   2598:                crosslist => "Changes to crosslistings",
                   2599:                sections => "Changes to section settings",
                   2600:                photos => "Automatic import of student photos",
                   2601:                updatenow => "Immediate course roster update",
                   2602:                newcross => "Adding new crosslisted courses",
1.14      raeburn  2603:                newsections => "Adding new course sections",
                   2604:                viewclass => "Viewing class roster and enrollment type"
1.1       raeburn  2605:     );
                   2606: 
                   2607:     my $realm = '';
                   2608:     if ( exists($ENV{'request.course.id'}) ) {
                   2609:         $realm= $ENV{'course.'.$ENV{'request.course.id'}.'.description'};
                   2610:     }
                   2611:     unless ($realm) { $realm='&nbsp;'; }
                   2612:     my $dom = $ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
                   2613:     my $crs = $ENV{'course.'.$ENV{'request.course.id'}.'.num'};
                   2614:     
                   2615:     #
                   2616:     # Main switch on form.action and form.state, as appropriate
                   2617:     #
                   2618: 
                   2619:     my $action = "information";
                   2620:     if ( exists($ENV{'form.action'}) ) {
                   2621:         $action = $ENV{'form.action'};
                   2622:     }
                   2623:     my $state = "choose";
                   2624: 
                   2625:     if ( exists($ENV{'form.state'}) ) {
                   2626:         $state = $ENV{'form.state'};
                   2627:     }
                   2628: 
                   2629:     if ($action eq "information") {
                   2630:         $r->print(&header()); 
                   2631:     } else {
                   2632:         if ($state eq "choose") {
1.16      raeburn  2633:             $r->print(&choose_header($action));
1.1       raeburn  2634:         } else {
                   2635:             if ($action eq "crosslist") {
                   2636:                 if ( exists($ENV{'form.numcross'}) ) {
                   2637:                     if ( $ENV{'form.numcross'} > 0 ) {
1.16      raeburn  2638:                         $r->print(&choose_header($action));
1.1       raeburn  2639:                     } else {
                   2640:                         $r->print(&header());
                   2641:                     }
                   2642:                 } else {
                   2643:                     $r->print(&header());
                   2644:                 }
                   2645:             } elsif ($action eq "sections") {
                   2646:                 if ( exists($ENV{'form.numsec'}) ) {
                   2647:                     if ( $ENV{'form.numsec'} > 0 ) {
1.16      raeburn  2648:                         $r->print(&choose_header($action));
1.1       raeburn  2649:                     } else {
                   2650:                         $r->print(&header());
                   2651:                     }
                   2652:                 } else {
                   2653:                     $r->print(&header());
                   2654:                 }
                   2655:             } else {
                   2656:                 $r->print(&header());
                   2657:             }
                   2658:         }
                   2659:     }
1.12      raeburn  2660: 
1.1       raeburn  2661:     my $reply = 0;
                   2662:     unless ($state eq "choose") { $reply = 1; }
                   2663: 
                   2664:     &print_mainbox($r,\%tasklong,$realm,$reply);
                   2665:     &print_navmenu($r,\@tasks,\%tasklong);
                   2666:     
                   2667:     if (($state eq "choose") || ($action eq "information")) {
1.13      raeburn  2668:         &print_main_frame($r,$realm,$dom,$crs,\%tasktitle);
1.1       raeburn  2669:     } elsif ($action eq "chgsettings") {
                   2670:         &print_chgsettings_response($r,$realm,$dom,$crs,$action,\%tasktitle);
                   2671:     } elsif ($action eq "setdates") {
                   2672:         &print_setdates_response($r,$realm,$dom,$crs,$action,\%tasktitle);
1.14      raeburn  2673:     } elsif ($action eq "setaccess") {
                   2674:         &print_setaccess_response($r,$realm,$dom,$crs,$action,\%tasktitle);
1.1       raeburn  2675:     } elsif ($action eq "notify") {
                   2676:         &print_notify_response($r,$realm,$dom,$crs,$action,\%tasktitle);
                   2677:     } elsif ($action eq "sections") {
1.13      raeburn  2678:         &print_sections_menu($r,$realm,$dom,$crs,$action,\%tasktitle);
1.1       raeburn  2679:     } elsif ($action eq "crosslist") {
1.13      raeburn  2680:         &print_crosslistings_menu($r,$realm,$dom,$crs,$action,\%tasktitle);
1.1       raeburn  2681:     } elsif ($action eq "updatenow") {
1.13      raeburn  2682:         &print_update_result($r,$realm,$dom,$crs,$action,\%tasktitle);
1.1       raeburn  2683:     } elsif ($action eq "photos") {
                   2684:         &print_photos_response($r,$realm,$dom,$crs,$action,\%tasktitle);
                   2685:     } elsif ($action eq "newcross") {
1.13      raeburn  2686:         &print_crosslistings_response($r,$realm,$dom,$crs,$action,\%tasktitle);    
1.1       raeburn  2687:     } elsif ($action eq "newsections") {
1.13      raeburn  2688:         &print_sections_response($r,$realm,$dom,$crs,$action,\%tasktitle);
1.14      raeburn  2689:     } elsif ($action eq "viewclass") {
                   2690:         &print_viewclass_response($r,$realm,$dom,$crs,$action,\%tasktitle);
1.1       raeburn  2691:     }
                   2692:     &print_doc_base($r);  
                   2693:     return OK;
                   2694: }
                   2695: ###################################################################
                   2696: 1;

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