Annotation of loncom/interface/loncreateuser.pm, revision 1.57

1.20      harris41    1: # The LearningOnline Network with CAPA
1.1       www         2: # Create a user
                      3: #
1.57    ! matthew     4: # $Id: loncreateuser.pm,v 1.56 2003/06/20 14:37:26 www Exp $
1.22      albertel    5: #
                      6: # Copyright Michigan State University Board of Trustees
                      7: #
                      8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
                      9: #
                     10: # LON-CAPA is free software; you can redistribute it and/or modify
                     11: # it under the terms of the GNU General Public License as published by
                     12: # the Free Software Foundation; either version 2 of the License, or
                     13: # (at your option) any later version.
                     14: #
                     15: # LON-CAPA is distributed in the hope that it will be useful,
                     16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
                     17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     18: # GNU General Public License for more details.
                     19: #
                     20: # You should have received a copy of the GNU General Public License
                     21: # along with LON-CAPA; if not, write to the Free Software
                     22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
                     23: #
                     24: # /home/httpd/html/adm/gpl.txt
                     25: #
                     26: # http://www.lon-capa.org/
                     27: #
1.1       www        28: # (Create a course
                     29: # (My Desk
                     30: #
                     31: # (Internal Server Error Handler
                     32: #
                     33: # (Login Screen
                     34: # 5/21/99,5/22,5/25,5/26,5/31,6/2,6/10,7/12,7/14,
                     35: # 1/14/00,5/29,5/30,6/1,6/29,7/1,11/9 Gerd Kortemeyer)
                     36: #
1.20      harris41   37: # YEAR=2001
1.1       www        38: # 3/1/1 Gerd Kortemeyer)
                     39: #
                     40: # 3/1 Gerd Kortemeyer)
                     41: #
                     42: # 2/14 Gerd Kortemeyer)
                     43: #
1.12      www        44: # 2/14,2/17,2/19,2/20,2/21,2/22,2/23,3/2,3/17,3/24,04/12 Gerd Kortemeyer
1.17      www        45: # April Guy Albertelli
1.19      www        46: # 05/10,10/16 Gerd Kortemeyer 
1.25      matthew    47: # 02/11/02 Matthew Hall
1.1       www        48: #
1.57    ! matthew    49: # $Id: loncreateuser.pm,v 1.56 2003/06/20 14:37:26 www Exp $
1.20      harris41   50: ###
                     51: 
1.1       www        52: package Apache::loncreateuser;
                     53: 
                     54: use strict;
                     55: use Apache::Constants qw(:common :http);
                     56: use Apache::lonnet;
1.54      bowersj2   57: use Apache::loncommon;
1.1       www        58: 
1.20      harris41   59: my $loginscript; # piece of javascript used in two separate instances
                     60: my $generalrule;
                     61: my $authformnop;
                     62: my $authformkrb;
                     63: my $authformint;
                     64: my $authformfsys;
                     65: my $authformloc;
                     66: 
1.23      harris41   67: BEGIN {
1.20      harris41   68:     $ENV{'SERVER_NAME'}=~/(\w+\.\w+)$/;
                     69:     my $krbdefdom=$1;
                     70:     $krbdefdom=~tr/a-z/A-Z/;
1.31      matthew    71:     my %param = ( formname => 'document.cu',
                     72:                   kerb_def_dom => $krbdefdom 
                     73:                   );
1.48      albertel   74: # no longer static due to configurable kerberos defaults
                     75: #    $loginscript  = &Apache::loncommon::authform_header(%param);
1.31      matthew    76:     $generalrule  = &Apache::loncommon::authform_authorwarning(%param);
                     77:     $authformnop  = &Apache::loncommon::authform_nochange(%param);
1.48      albertel   78: # no longer static due to configurable kerberos defaults
                     79: #    $authformkrb  = &Apache::loncommon::authform_kerberos(%param);
1.31      matthew    80:     $authformint  = &Apache::loncommon::authform_internal(%param);
                     81:     $authformfsys = &Apache::loncommon::authform_filesystem(%param);
                     82:     $authformloc  = &Apache::loncommon::authform_local(%param);
1.20      harris41   83: }
                     84: 
1.43      www        85: 
                     86: 
                     87: # ==================================================== Figure out author access
                     88: 
                     89: sub authorpriv {
                     90:     my ($auname,$audom)=@_;
                     91:     if (($auname ne $ENV{'user.name'}) ||
                     92:         (($audom ne $ENV{'user.domain'}) &&
                     93:          ($audom ne $ENV{'request.role.domain'}))) { return ''; }
                     94:     unless (&Apache::lonnet::allowed('cca',$audom)) { return ''; }
                     95:     return 1;
                     96: }
                     97: 
1.2       www        98: # =================================================================== Phase one
1.1       www        99: 
1.42      matthew   100: sub print_username_entry_form {
1.2       www       101:     my $r=shift;
1.42      matthew   102:     my $defdom=$ENV{'request.role.domain'};
1.33      matthew   103:     my @domains = &Apache::loncommon::get_domains();
                    104:     my $domform = &Apache::loncommon::select_dom_form($defdom,'ccdomain');
1.40      www       105:     my $bodytag =&Apache::loncommon::bodytag(
                    106:                                   'Create Users, Change User Privileges');
1.46      www       107:     my $selscript=&Apache::loncommon::studentbrowser_javascript();
                    108:     my $sellink=&Apache::loncommon::selectstudent_link
                    109:                                         ('crtuser','ccuname','ccdomain');
1.33      matthew   110:     $r->print(<<"ENDDOCUMENT");
1.1       www       111: <html>
                    112: <head>
                    113: <title>The LearningOnline Network with CAPA</title>
1.46      www       114: $selscript
1.1       www       115: </head>
1.40      www       116: $bodytag
1.46      www       117: <form action="/adm/createuser" method="post" name="crtuser">
1.42      matthew   118: <input type="hidden" name="phase" value="get_user_info">
1.33      matthew   119: <p>
1.43      www       120: <table>
                    121: <tr><td>Username:</td><td><input type="text" size="15" name="ccuname">
1.46      www       122: </td><td rowspan="2">$sellink</td></tr><tr><td>
1.43      www       123: Domain:</td><td>$domform</td></tr>
                    124: </table> 
1.33      matthew   125: </p>
1.42      matthew   126: <input type="submit" value="Continue">
1.2       www       127: </form>
1.1       www       128: </body>
                    129: </html>
                    130: ENDDOCUMENT
1.2       www       131: }
                    132: 
                    133: # =================================================================== Phase two
1.42      matthew   134: sub print_user_modification_page {
1.2       www       135:     my $r=shift;
                    136:     my $ccuname=$ENV{'form.ccuname'};
                    137:     my $ccdomain=$ENV{'form.ccdomain'};
1.4       www       138: 
1.48      albertel  139:     my $defdom=$ENV{'request.role.domain'};
                    140: 
                    141:     my ($krbdef,$krbdefdom) =
                    142:        &Apache::loncommon::get_kerberos_defaults($defdom);
                    143: 
1.31      matthew   144:     my %param = ( formname => 'document.cu',
1.48      albertel  145:                   kerb_def_dom => $krbdefdom,
                    146:                   kerb_def_auth => $krbdef
1.31      matthew   147:                   );
                    148:     $loginscript  = &Apache::loncommon::authform_header(%param);
1.48      albertel  149:     $authformkrb  = &Apache::loncommon::authform_kerberos(%param);
1.4       www       150: 
1.2       www       151:     $ccuname=~s/\W//g;
                    152:     $ccdomain=~s/\W//g;
1.52      matthew   153:     my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
1.25      matthew   154:     my $dochead =<<"ENDDOCHEAD";
1.2       www       155: <html>
                    156: <head>
                    157: <title>The LearningOnline Network with CAPA</title>
1.31      matthew   158: <script type="text/javascript" language="Javascript">
1.3       www       159: 
                    160:     function pclose() {
                    161:         parmwin=window.open("/adm/rat/empty.html","LONCAPAparms",
                    162:                  "height=350,width=350,scrollbars=no,menubar=no");
                    163:         parmwin.close();
                    164:     }
                    165: 
1.52      matthew   166:     $pjump_def
1.3       www       167: 
                    168:     function dateset() {
                    169:         eval("document.cu."+document.cu.pres_marker.value+
                    170:             ".value=document.cu.pres_value.value");
                    171:         pclose();
                    172:     }
                    173: 
                    174: </script>
1.2       www       175: </head>
1.25      matthew   176: ENDDOCHEAD
1.40      www       177:     $r->print(&Apache::loncommon::bodytag(
                    178:                                      'Create Users, Change User Privileges'));
1.25      matthew   179:     my $forminfo =<<"ENDFORMINFO";
                    180: <form action="/adm/createuser" method="post" name="cu">
1.42      matthew   181: <input type="hidden" name="phase"       value="update_user_data">
1.25      matthew   182: <input type="hidden" name="ccuname"     value="$ccuname">
                    183: <input type="hidden" name="ccdomain"    value="$ccdomain">
                    184: <input type="hidden" name="pres_value"  value="" >
                    185: <input type="hidden" name="pres_type"   value="" >
                    186: <input type="hidden" name="pres_marker" value="" >
                    187: ENDFORMINFO
1.2       www       188:     my $uhome=&Apache::lonnet::homeserver($ccuname,$ccdomain);
                    189:     my %incdomains; 
                    190:     my %inccourses;
1.49      albertel  191:     foreach (values(%Apache::lonnet::hostdom)) {
1.13      www       192:        $incdomains{$_}=1;
1.24      matthew   193:     }
                    194:     foreach (keys(%ENV)) {
1.2       www       195: 	if ($_=~/^user\.priv\.cm\.\/(\w+)\/(\w+)/) {
                    196: 	    $inccourses{$1.'_'.$2}=1;
                    197:         }
1.24      matthew   198:     }
1.2       www       199:     if ($uhome eq 'no_host') {
1.29      matthew   200:         my $home_server_list=
1.32      matthew   201:             '<option value="default" selected>default</option>'."\n".
                    202:                 &Apache::loncommon::home_server_option_list($ccdomain);
                    203:         
1.26      matthew   204: 	$r->print(<<ENDNEWUSER);
1.25      matthew   205: $dochead
                    206: <h1>Create New User</h1>
                    207: $forminfo
                    208: <h2>New user "$ccuname" in domain $ccdomain</h2>
1.31      matthew   209: <script type="text/javascript" language="Javascript">
1.20      harris41  210: $loginscript
1.31      matthew   211: </script>
1.20      harris41  212: <input type='hidden' name='makeuser' value='1' />
1.4       www       213: <h3>Personal Data</h3>
1.25      matthew   214: <p>
                    215: <table>
                    216: <tr><td>First Name  </td>
                    217:     <td><input type='text' name='cfirst'  size='15' /></td></tr>
                    218: <tr><td>Middle Name </td> 
                    219:     <td><input type='text' name='cmiddle' size='15' /></td></tr>
                    220: <tr><td>Last Name   </td>
                    221:     <td><input type='text' name='clast'   size='15' /></td></tr>
                    222: <tr><td>Generation  </td>
                    223:     <td><input type='text' name='cgen'    size='5'  /></td></tr>
                    224: </table>
                    225: ID/Student Number <input type='text' name='cstid'   size='15' /></p>
1.29      matthew   226: Home Server: <select name="hserver" size="1"> $home_server_list </select>
1.25      matthew   227: <hr />
1.4       www       228: <h3>Login Data</h3>
1.31      matthew   229: <p>$generalrule </p>
                    230: <p>$authformkrb </p>
                    231: <p>$authformint </p>
                    232: <p>$authformfsys</p>
                    233: <p>$authformloc </p>
1.26      matthew   234: ENDNEWUSER
1.25      matthew   235:     } else { # user already exists
1.26      matthew   236: 	$r->print(<<ENDCHANGEUSER);
1.25      matthew   237: $dochead
                    238: <h1>Change User Privileges</h1>
                    239: $forminfo
                    240: <h2>User "$ccuname" in domain $ccdomain </h2>
1.26      matthew   241: ENDCHANGEUSER
1.28      matthew   242:         # Get the users information
                    243:         my %userenv = &Apache::lonnet::get('environment',
                    244:                           ['firstname','middlename','lastname','generation'],
                    245:                           $ccdomain,$ccuname);
                    246:         my %rolesdump=&Apache::lonnet::dump('roles',$ccdomain,$ccuname);
                    247:         $r->print(<<END);
                    248: <hr />
                    249: <table border="2">
                    250: <tr>
                    251: <th>first name</th><th>middle name</th><th>last name</th><th>generation</th>
                    252: </tr>
                    253: <tr>
                    254: END
                    255:         foreach ('firstname','middlename','lastname','generation') {
                    256:            if (&Apache::lonnet::allowed('mau',$ccdomain)) {
                    257:               $r->print(<<"END");            
1.53      www       258: <td><input type="text" name="c$_" value="$userenv{$_}" size="15" /></td>
1.28      matthew   259: END
                    260:            } else {
                    261:                $r->print('<td>'.$userenv{$_}.'</td>');
                    262:            }
                    263:         }
                    264:         $r->print(<<END);
                    265: </tr>
                    266: </table>
                    267: END
1.25      matthew   268:         # Build up table of user roles to allow revocation of a role.
1.28      matthew   269:         my ($tmp) = keys(%rolesdump);
                    270:         unless ($tmp =~ /^(con_lost|error)/i) {
1.2       www       271:            my $now=time;
1.37      matthew   272:            $r->print(<<END);
                    273: <hr />
                    274: <h3>Revoke Existing Roles</h3>
                    275: <table border=2>
1.53      www       276: <tr><th>Revoke</th><th>Delete</th><th>Role</th><th>Extent</th><th>Start</th><th>End</th>
1.37      matthew   277: END
1.28      matthew   278: 	   foreach my $area (keys(%rolesdump)) {
1.37      matthew   279:                next if ($area =~ /^rolesdef/);
                    280:                my $role = $rolesdump{$area};
                    281:                my $thisrole=$area;
                    282:                $area =~ s/\_\w\w$//;
                    283:                my ($role_code,$role_end_time,$role_start_time) = 
                    284:                    split(/_/,$role);
                    285:                my $bgcol='ffffff';
                    286:                my $allowed=0;
1.53      www       287:                my $delallowed=0;
1.37      matthew   288:                if ($area =~ /^\/(\w+)\/(\d\w+)/ ) {
1.57    ! matthew   289:                    my ($coursedom,$coursedir) = ($1,$2);
        !           290:                    # $1.'_'.$2 is the course id (eg. 103_12345abcef103l3).
1.37      matthew   291:                    my %coursedata=
                    292:                        &Apache::lonnet::coursedescription($1.'_'.$2);
1.51      albertel  293: 		   my $carea;
                    294: 		   if (defined($coursedata{'description'})) {
1.53      www       295: 		       $carea='Course: '.$coursedata{'description'}.
1.57    ! matthew   296:                            '<br />Domain: '.$coursedom.('&nbsp;'x8).
        !           297:      &Apache::loncommon::syllabuswrapper('Syllabus',$coursedir,$coursedom);
1.51      albertel  298: 		   } else {
                    299: 		       $carea='Unavailable course: '.$area;
                    300: 		   }
1.37      matthew   301:                    $inccourses{$1.'_'.$2}=1;
1.53      www       302:                    if ((&Apache::lonnet::allowed('c'.$role_code,$1.'/'.$2)) ||
                    303:                        (&Apache::lonnet::allowed('c'.$role_code,$ccdomain))) {
1.37      matthew   304:                        $allowed=1;
                    305:                    }
1.53      www       306:                    if ((&Apache::lonnet::allowed('dro',$1)) ||
                    307:                        (&Apache::lonnet::allowed('dro',$ccdomain))) {
                    308:                        $delallowed=1;
                    309:                    }
1.37      matthew   310:                    # Compute the background color based on $area
                    311:                    $bgcol=$1.'_'.$2;
                    312:                    $bgcol=~s/[^8-9b-e]//g;
                    313:                    $bgcol=substr($bgcol.$bgcol.$bgcol.'ffffff',0,6);
                    314:                    if ($area=~/^\/(\w+)\/(\d\w+)\/(\w+)/) {
1.28      matthew   315:                        $carea.='<br>Section/Group: '.$3;
1.37      matthew   316:                    }
                    317:                    $area=$carea;
                    318:                } else {
                    319:                    # Determine if current user is able to revoke privileges
                    320:                    if ($area=~ /^\/(\w+)\//) {
1.53      www       321:                        if ((&Apache::lonnet::allowed('c'.$role_code,$1)) ||
                    322:                        (&Apache::lonnet::allowed('c'.$role_code,$ccdomain))) {
1.37      matthew   323:                            $allowed=1;
                    324:                        }
1.53      www       325:                        if (((&Apache::lonnet::allowed('dro',$1))  ||
                    326:                             (&Apache::lonnet::allowed('dro',$ccdomain))) &&
                    327:                            ($role_code ne 'dc')) {
                    328:                            $delallowed=1;
                    329:                        }
1.37      matthew   330:                    } else {
                    331:                        if (&Apache::lonnet::allowed('c'.$role_code,'/')) {
                    332:                            $allowed=1;
                    333:                        }
                    334:                    }
                    335:                }
1.43      www       336:                if ($role_code eq 'ca') {
                    337:                    $area=~/\/(\w+)\/(\w+)/;
                    338: 		   if (&authorpriv($2,$1)) {
                    339: 		       $allowed=1;
                    340:                    } else {
                    341:                        $allowed=0;
1.37      matthew   342:                    }
                    343:                }
                    344:                my $row = '';
                    345:                $row.='<tr bgcolor=#"'.$bgcol.'"><td>';
                    346:                my $active=1;
                    347:                $active=0 if (($role_end_time) && ($now>$role_end_time));
                    348:                if (($active) && ($allowed)) {
                    349:                    $row.= '<input type="checkbox" name="rev:'.$thisrole.'">';
                    350:                } else {
1.56      www       351:                    if ($active) {
                    352:                       $row.='&nbsp;';
                    353: 		   } else {
                    354:                       $row.='expired or revoked';
                    355: 		   }
1.37      matthew   356:                }
1.53      www       357: 	       $row.='</td><td>';
                    358:                if ($delallowed) {
                    359:                    $row.= '<input type="checkbox" name="del:'.$thisrole.'">';
                    360:                } else {
                    361:                    $row.='&nbsp;';
                    362:                }
1.37      matthew   363:                $row.= '</td><td>'.&Apache::lonnet::plaintext($role_code).
                    364:                       '</td><td>'.$area.
                    365:                       '</td><td>'.($role_start_time?localtime($role_start_time)
                    366:                                                    : '&nbsp;' ).
                    367:                       '</td><td>'.($role_end_time  ?localtime($role_end_time)
                    368:                                                    : '&nbsp;' )
                    369:                       ."</td></tr>\n";
                    370:                $r->print($row);
1.28      matthew   371:            } # end of foreach        (table building loop)
1.2       www       372: 	   $r->print('</table>');
1.28      matthew   373:         }  # End of unless
1.20      harris41  374: 	my $currentauth=&Apache::lonnet::queryauthenticate($ccuname,$ccdomain);
1.41      albertel  375: 	if ($currentauth=~/^krb(4|5):/) {
                    376: 	    $currentauth=~/^krb(4|5):(.*)/;
1.45      matthew   377: 	    my $krbdefdom=$1;
1.31      matthew   378:             my %param = ( formname => 'document.cu',
                    379:                           kerb_def_dom => $krbdefdom 
                    380:                           );
                    381:             $loginscript  = &Apache::loncommon::authform_header(%param);
1.20      harris41  382: 	}
1.26      matthew   383: 	# Check for a bad authentication type
1.41      albertel  384:         unless ($currentauth=~/^krb(4|5):/ or
1.20      harris41  385: 		$currentauth=~/^unix:/ or
                    386: 		$currentauth=~/^internal:/ or
                    387: 		$currentauth=~/^localauth:/
1.26      matthew   388: 		) { # bad authentication scheme
1.42      matthew   389: 	    if (&Apache::lonnet::allowed('mau',$ENV{'request.role.domain'})) {
1.26      matthew   390: 		$r->print(<<ENDBADAUTH);
1.21      harris41  391: <hr />
1.31      matthew   392: <script type="text/javascript" language="Javascript">
1.21      harris41  393: $loginscript
1.31      matthew   394: </script>
1.20      harris41  395: <font color='#ff0000'>ERROR:</font>
                    396: This user has an unrecognized authentication scheme ($currentauth).
                    397: Please specify login data below.
                    398: <h3>Login Data</h3>
1.31      matthew   399: <p>$generalrule</p>
                    400: <p>$authformkrb</p>
                    401: <p>$authformint</p>
                    402: <p>$authformfsys</p>
                    403: <p>$authformloc</p>
1.26      matthew   404: ENDBADAUTH
                    405:             } else { 
                    406:                 # This user is not allowed to modify the users 
                    407:                 # authentication scheme, so just notify them of the problem
                    408: 		$r->print(<<ENDBADAUTH);
                    409: <hr />
1.31      matthew   410: <script type="text/javascript" language="Javascript">
1.26      matthew   411: $loginscript
1.31      matthew   412: </script>
1.26      matthew   413: <font color="#ff0000"> ERROR: </font>
                    414: This user has an unrecognized authentication scheme ($currentauth).
                    415: Please alert a domain coordinator of this situation.
                    416: <hr />
                    417: ENDBADAUTH
                    418:             }
                    419:         } else { # Authentication type is valid
1.20      harris41  420: 	    my $authformcurrent='';
1.26      matthew   421: 	    my $authform_other='';
1.41      albertel  422: 	    if ($currentauth=~/^krb(4|5):/) {
1.20      harris41  423: 		$authformcurrent=$authformkrb;
1.31      matthew   424: 		$authform_other="<p>$authformint</p>\n".
                    425:                     "<p>$authformfsys</p><p>$authformloc</p>";
1.20      harris41  426: 	    }
                    427: 	    elsif ($currentauth=~/^internal:/) {
                    428: 		$authformcurrent=$authformint;
1.31      matthew   429: 		$authform_other="<p>$authformkrb</p>".
                    430:                     "<p>$authformfsys</p><p>$authformloc</p>";
1.20      harris41  431: 	    }
                    432: 	    elsif ($currentauth=~/^unix:/) {
                    433: 		$authformcurrent=$authformfsys;
1.31      matthew   434: 		$authform_other="<p>$authformkrb</p>".
                    435:                     "<p>$authformint</p><p>$authformloc;</p>";
1.20      harris41  436: 	    }
                    437: 	    elsif ($currentauth=~/^localauth:/) {
                    438: 		$authformcurrent=$authformloc;
1.31      matthew   439: 		$authform_other="<p>$authformkrb</p>".
                    440:                     "<p>$authformint</p><p>$authformfsys</p>";
1.20      harris41  441: 	    }
1.53      www       442:             $authformcurrent.=' <i>(will override current values)</i><br />';
1.42      matthew   443:             if (&Apache::lonnet::allowed('mau',$ENV{'request.role.domain'})) {
1.26      matthew   444: 		# Current user has login modification privileges
                    445: 		$r->print(<<ENDOTHERAUTHS);
1.21      harris41  446: <hr />
1.31      matthew   447: <script type="text/javascript" language="Javascript">
1.21      harris41  448: $loginscript
1.31      matthew   449: </script>
1.20      harris41  450: <h3>Change Current Login Data</h3>
1.31      matthew   451: <p>$generalrule</p>
                    452: <p>$authformnop</p>
                    453: <p>$authformcurrent</p>
1.20      harris41  454: <h3>Enter New Login Data</h3>
1.26      matthew   455: $authform_other
                    456: ENDOTHERAUTHS
                    457:             }
                    458:         }  ## End of "check for bad authentication type" logic
1.25      matthew   459:     } ## End of new user/old user logic
1.20      harris41  460:     $r->print('<hr /><h3>Add Roles</h3>');
1.17      www       461: #
                    462: # Co-Author
                    463: # 
1.44      matthew   464:     if (&authorpriv($ENV{'user.name'},$ENV{'request.role.domain'}) &&
                    465:         ($ENV{'user.name'} ne $ccuname || $ENV{'user.domain'} ne $ccdomain)) {
                    466:         # No sense in assigning co-author role to yourself
1.17      www       467: 	my $cuname=$ENV{'user.name'};
1.42      matthew   468:         my $cudom=$ENV{'request.role.domain'};
1.17      www       469:        $r->print(<<ENDCOAUTH);
                    470: <h4>Construction Space</h4>
                    471: <table border=2><tr><th>Activate</th><th>Role</th><th>Extent</th>
                    472: <th>Start</th><th>End</th></tr>
                    473: <tr>
                    474: <td><input type=checkbox name="act_$cudom\_$cuname\_ca"></td>
                    475: <td>Co-Author</td>
                    476: <td>$cudom\_$cuname</td>
                    477: <td><input type=hidden name="start_$cudom\_$cuname\_ca" value=''>
                    478: <a href=
                    479: "javascript:pjump('date_start','Start Date Co-Author',document.cu.start_$cudom\_$cuname\_ca.value,'start_$cudom\_$cuname\_ca','cu.pres','dateset')">Set Start Date</a></td>
                    480: <td><input type=hidden name="end_$cudom\_$cuname\_ca" value=''>
                    481: <a href=
                    482: "javascript:pjump('date_end','End Date Co-Author',document.cu.end_$cudom\_$cuname\_ca.value,'end_$cudom\_$cuname\_ca','cu.pres','dateset')">Set End Date</a></td>
                    483: </tr>
                    484: </table>
                    485: ENDCOAUTH
                    486:     }
1.8       www       487: #
                    488: # Domain level
                    489: #
                    490:     $r->print('<h4>Domain Level</h4>'.
                    491:     '<table border=2><tr><th>Activate</th><th>Role</th><th>Extent</th>'.
                    492:     '<th>Start</th><th>End</th></tr>');
1.24      matthew   493:     foreach ( sort( keys(%incdomains))) {
1.2       www       494: 	my $thisdomain=$_;
1.24      matthew   495:         foreach ('dc','li','dg','au') {
1.2       www       496:             if (&Apache::lonnet::allowed('c'.$_,$thisdomain)) {
1.8       www       497:                my $plrole=&Apache::lonnet::plaintext($_);
                    498:                $r->print(<<ENDDROW);
                    499: <tr>
                    500: <td><input type=checkbox name="act_$thisdomain\_$_"></td>
                    501: <td>$plrole</td>
                    502: <td>$thisdomain</td>
                    503: <td><input type=hidden name="start_$thisdomain\_$_" value=''>
                    504: <a href=
                    505: "javascript:pjump('date_start','Start Date $plrole',document.cu.start_$thisdomain\_$_.value,'start_$thisdomain\_$_','cu.pres','dateset')">Set Start Date</a></td>
                    506: <td><input type=hidden name="end_$thisdomain\_$_" value=''>
                    507: <a href=
                    508: "javascript:pjump('date_end','End Date $plrole',document.cu.end_$thisdomain\_$_.value,'end_$thisdomain\_$_','cu.pres','dateset')">Set End Date</a></td>
                    509: </tr>
                    510: ENDDROW
1.2       www       511:             }
1.24      matthew   512:         } 
                    513:     }
1.8       www       514:     $r->print('</table>');
                    515: #
                    516: # Course level
                    517: #
1.26      matthew   518:     $r->print(&course_level_table(%inccourses));
                    519:     $r->print("<hr /><input type=submit value=\"Modify User\">\n");
                    520:     $r->print("</form></body></html>");
1.2       www       521: }
1.1       www       522: 
1.4       www       523: # ================================================================= Phase Three
1.42      matthew   524: sub update_user_data {
1.4       www       525:     my $r=shift;
1.29      matthew   526:     my $uhome=&Apache::lonnet::homeserver($ENV{'form.ccuname'},
                    527:                                           $ENV{'form.ccdomain'});
1.27      matthew   528:     # Error messages
                    529:     my $error     = '<font color="#ff0000">Error:</font>';
                    530:     my $end       = '</body></html>';
                    531:     # Print header
1.4       www       532:     $r->print(<<ENDTHREEHEAD);
                    533: <html>
                    534: <head>
                    535: <title>The LearningOnline Network with CAPA</title>
                    536: </head>
                    537: ENDTHREEHEAD
1.40      www       538:     my $title;
                    539:     if (exists($ENV{'form.makeuser'})) {
                    540: 	$title='Set Privileges for New User';
                    541:     } else {
                    542:         $title='Modify User Privileges';
                    543:     }
                    544:     $r->print(&Apache::loncommon::bodytag($title));
1.27      matthew   545:     # Check Inputs
1.29      matthew   546:     if (! $ENV{'form.ccuname'} ) {
1.27      matthew   547: 	$r->print($error.'No login name specified.'.$end);
                    548: 	return;
                    549:     }
1.29      matthew   550:     if (  $ENV{'form.ccuname'}  =~/\W/) {
1.27      matthew   551: 	$r->print($error.'Invalid login name.  '.
                    552: 		  'Only letters, numbers, and underscores are valid.'.
                    553: 		  $end);
                    554: 	return;
                    555:     }
1.29      matthew   556:     if (! $ENV{'form.ccdomain'}       ) {
1.27      matthew   557: 	$r->print($error.'No domain specified.'.$end);
                    558: 	return;
                    559:     }
1.29      matthew   560:     if (  $ENV{'form.ccdomain'} =~/\W/) {
1.27      matthew   561: 	$r->print($error.'Invalid domain name.  '.
                    562: 		  'Only letters, numbers, and underscores are valid.'.
                    563: 		  $end);
                    564: 	return;
                    565:     }
1.29      matthew   566:     if (! exists($ENV{'form.makeuser'})) {
                    567:         # Modifying an existing user, so check the validity of the name
                    568:         if ($uhome eq 'no_host') {
                    569:             $r->print($error.'Unable to determine home server for '.
                    570:                       $ENV{'form.ccuname'}.' in domain '.
                    571:                       $ENV{'form.ccdomain'}.'.');
                    572:             return;
                    573:         }
                    574:     }
1.27      matthew   575:     # Determine authentication method and password for the user being modified
                    576:     my $amode='';
                    577:     my $genpwd='';
                    578:     if ($ENV{'form.login'} eq 'krb') {
1.41      albertel  579: 	$amode='krb';
                    580: 	$amode.=$ENV{'form.krbver'};
1.30      matthew   581: 	$genpwd=$ENV{'form.krbarg'};
1.27      matthew   582:     } elsif ($ENV{'form.login'} eq 'int') {
                    583: 	$amode='internal';
1.30      matthew   584: 	$genpwd=$ENV{'form.intarg'};
1.27      matthew   585:     } elsif ($ENV{'form.login'} eq 'fsys') {
                    586: 	$amode='unix';
1.30      matthew   587: 	$genpwd=$ENV{'form.fsysarg'};
1.27      matthew   588:     } elsif ($ENV{'form.login'} eq 'loc') {
                    589: 	$amode='localauth';
                    590: 	$genpwd=$ENV{'form.locarg'};
                    591: 	$genpwd=" " if (!$genpwd);
1.35      matthew   592:     } elsif (($ENV{'form.login'} eq 'nochange') ||
                    593:              ($ENV{'form.login'} eq ''        )) { 
1.34      matthew   594:         # There is no need to tell the user we did not change what they
                    595:         # did not ask us to change.
1.35      matthew   596:         # If they are creating a new user but have not specified login
                    597:         # information this will be caught below.
1.30      matthew   598:     } else {
                    599: 	    $r->print($error.'Invalid login mode or password'.$end);    
                    600: 	    return;
1.27      matthew   601:     }
                    602:     if ($ENV{'form.makeuser'}) {
                    603:         # Create a new user
                    604: 	$r->print(<<ENDNEWUSERHEAD);
1.29      matthew   605: <h3>Creating user "$ENV{'form.ccuname'}" in domain "$ENV{'form.ccdomain'}"</h2>
1.27      matthew   606: ENDNEWUSERHEAD
                    607:         # Check for the authentication mode and password
                    608:         if (! $amode || ! $genpwd) {
                    609: 	    $r->print($error.'Invalid login mode or password'.$end);    
                    610: 	    return;
1.18      albertel  611: 	}
1.29      matthew   612:         # Determine desired host
                    613:         my $desiredhost = $ENV{'form.hserver'};
                    614:         if (lc($desiredhost) eq 'default') {
                    615:             $desiredhost = undef;
                    616:         } else {
1.39      matthew   617:             my %home_servers = &Apache::loncommon::get_library_servers
1.32      matthew   618:                 ($ENV{'form.ccdomain'});  
1.29      matthew   619:             if (! exists($home_servers{$desiredhost})) {
                    620:                 $r->print($error.'Invalid home server specified');
                    621:                 return;
                    622:             }
                    623:         }
1.27      matthew   624: 	# Call modifyuser
                    625: 	my $result = &Apache::lonnet::modifyuser
1.29      matthew   626: 	    ($ENV{'form.ccdomain'},$ENV{'form.ccuname'},$ENV{'form.cstid'},
                    627:              $amode,$genpwd,$ENV{'form.cfirst'},
                    628:              $ENV{'form.cmiddle'},$ENV{'form.clast'},$ENV{'form.cgen'},
                    629:              undef,$desiredhost
1.27      matthew   630: 	     );
                    631: 	$r->print('Generating user: '.$result);
1.29      matthew   632:         my $home = &Apache::lonnet::homeserver($ENV{'form.ccuname'},
                    633:                                                $ENV{'form.ccdomain'});
                    634:         $r->print('<br>Home server: '.$home.' '.
                    635:                   $Apache::lonnet::libserv{$home});
1.35      matthew   636:     } elsif (($ENV{'form.login'} ne 'nochange') &&
                    637:              ($ENV{'form.login'} ne ''        )) {
1.27      matthew   638: 	# Modify user privileges
                    639: 	$r->print(<<ENDMODIFYUSERHEAD);
1.29      matthew   640: <h2>User "$ENV{'form.ccuname'}" in domain "$ENV{'form.ccdomain'}"</h2>
1.27      matthew   641: ENDMODIFYUSERHEAD
                    642:         if (! $amode || ! $genpwd) {
                    643: 	    $r->print($error.'Invalid login mode or password'.$end);    
                    644: 	    return;
1.20      harris41  645: 	}
1.27      matthew   646: 	# Only allow authentification modification if the person has authority
1.36      matthew   647: 	if (&Apache::lonnet::allowed('mau',$ENV{'form.ccdomain'})) {
1.20      harris41  648: 	    $r->print('Modifying authentication: '.
1.31      matthew   649:                       &Apache::lonnet::modifyuserauth(
1.29      matthew   650: 		       $ENV{'form.ccdomain'},$ENV{'form.ccuname'},
1.21      harris41  651:                        $amode,$genpwd));
1.20      harris41  652:             $r->print('<br>Home server: '.&Apache::lonnet::homeserver
1.29      matthew   653: 		  ($ENV{'form.ccuname'},$ENV{'form.ccdomain'}));
1.4       www       654: 	} else {
1.27      matthew   655: 	    # Okay, this is a non-fatal error.
                    656: 	    $r->print($error.'You do not have the authority to modify '.
                    657: 		      'this users authentification information.');    
                    658: 	}
1.28      matthew   659:     }
                    660:     ##
                    661:     if (! $ENV{'form.makeuser'} ) {
                    662:         # Check for need to change
                    663:         my %userenv = &Apache::lonnet::get
                    664:             ('environment',['firstname','middlename','lastname','generation'],
1.29      matthew   665:              $ENV{'form.ccdomain'},$ENV{'form.ccuname'});
1.28      matthew   666:         my ($tmp) = keys(%userenv);
                    667:         if ($tmp =~ /^(con_lost|error)/i) { 
                    668:             %userenv = ();
                    669:         }
                    670:         # Check to see if we need to change user information
                    671:         foreach ('firstname','middlename','lastname','generation') {
                    672:             # Strip leading and trailing whitespace
                    673:             $ENV{'form.c'.$_} =~ s/(\s+$|^\s+)//g; 
                    674:         }
1.29      matthew   675:         if (&Apache::lonnet::allowed('mau',$ENV{'form.ccdomain'}) && 
1.28      matthew   676:             ($ENV{'form.cfirstname'}  ne $userenv{'firstname'}  ||
                    677:              $ENV{'form.cmiddlename'} ne $userenv{'middlename'} ||
                    678:              $ENV{'form.clastname'}   ne $userenv{'lastname'}   ||
                    679:              $ENV{'form.cgeneration'} ne $userenv{'generation'} )) {
                    680:             # Make the change
                    681:             my %changeHash;
                    682:             $changeHash{'firstname'}  = $ENV{'form.cfirstname'};
                    683:             $changeHash{'middlename'} = $ENV{'form.cmiddlename'};
                    684:             $changeHash{'lastname'}   = $ENV{'form.clastname'};
                    685:             $changeHash{'generation'} = $ENV{'form.cgeneration'};
                    686:             my $putresult = &Apache::lonnet::put
                    687:                 ('environment',\%changeHash,
1.29      matthew   688:                  $ENV{'form.ccdomain'},$ENV{'form.ccuname'});
1.28      matthew   689:             if ($putresult eq 'ok') {
                    690:             # Tell the user we changed the name
                    691:                 $r->print(<<"END");
                    692: <table border="2">
                    693: <caption>User Information Changed</caption>
                    694: <tr><th>&nbsp;</th>
                    695:     <th>first</th>
                    696:     <th>middle</th>
                    697:     <th>last</th>
                    698:     <th>generation</th></tr>
                    699: <tr><td>Previous</td>
                    700:     <td>$userenv{'firstname'}  </td>
                    701:     <td>$userenv{'middlename'} </td>
                    702:     <td>$userenv{'lastname'}   </td>
                    703:     <td>$userenv{'generation'} </td></tr>
                    704: <tr><td>Changed To</td>
                    705:     <td>$ENV{'form.cfirstname'}  </td>
                    706:     <td>$ENV{'form.cmiddlename'} </td>
                    707:     <td>$ENV{'form.clastname'}   </td>
                    708:     <td>$ENV{'form.cgeneration'} </td></tr>
                    709: </table>
                    710: END
                    711:             } else { # error occurred
                    712:                 $r->print("<h2>Unable to successfully change environment for ".
1.29      matthew   713:                       $ENV{'form.ccuname'}." in domain ".
                    714:                       $ENV{'form.ccdomain'}."</h2>");
1.28      matthew   715:             }
                    716:         }  else { # End of if ($ENV ... ) logic
                    717:             # They did not want to change the users name but we can
                    718:             # still tell them what the name is
                    719:                 $r->print(<<"END");
1.29      matthew   720: <h2>User "$ENV{'form.ccuname'}" in domain "$ENV{'form.ccdomain'}"</h2>
1.28      matthew   721: <h4>$userenv{'firstname'} $userenv{'middlename'} $userenv{'lastname'} </h4>
                    722: <h4>Generation: $userenv{'generation'}</h4>
                    723: END
                    724:         }
1.4       www       725:     }
1.27      matthew   726:     ##
1.4       www       727:     my $now=time;
1.6       www       728:     $r->print('<h3>Modifying Roles</h3>');
1.24      matthew   729:     foreach (keys (%ENV)) {
1.27      matthew   730: 	next if (! $ENV{$_});
                    731: 	# Revoke roles
                    732: 	if ($_=~/^form\.rev/) {
                    733: 	    if ($_=~/^form\.rev\:([^\_]+)\_([^\_]+)$/) {
1.56      www       734: 	        $r->print('Revoking '.$2.' in '.$1.': <b>'.
1.29      matthew   735:                      &Apache::lonnet::assignrole($ENV{'form.ccdomain'},
1.56      www       736:                      $ENV{'form.ccuname'},$1,$2,$now).'</b><br>');
1.53      www       737: 		if ($2 eq 'st') {
                    738: 		    $1=~/^\/(\w+)\/(\w+)/;
                    739: 		    my $cid=$1.'_'.$2;
1.56      www       740: 		    $r->print('Drop from classlist: <b>'.
1.53      www       741: 			 &Apache::lonnet::critical('put:'.
                    742:                              $ENV{'course.'.$cid.'.domain'}.':'.
                    743: 	                     $ENV{'course.'.$cid.'.num'}.':classlist:'.
                    744:                          &Apache::lonnet::escape($ENV{'form.ccuname'}.':'.
                    745:                              $ENV{'form.ccdomain'}).'='.
                    746:                          &Apache::lonnet::escape($now.':'),
1.56      www       747: 	                     $ENV{'course.'.$cid.'.home'}).'</b><br>');
1.53      www       748: 		}
                    749: 	    } 
                    750: 	} elsif ($_=~/^form\.del/) {
                    751: 	    if ($_=~/^form\.del\:([^\_]+)\_([^\_]+)$/) {
                    752: 	        $r->print('Deleting '.$2.' in '.$1.': '.
                    753:                      &Apache::lonnet::assignrole($ENV{'form.ccdomain'},
                    754:                      $ENV{'form.ccuname'},$1,$2,$now,0,1).'<br>');
1.27      matthew   755: 		if ($2 eq 'st') {
                    756: 		    $1=~/^\/(\w+)\/(\w+)/;
                    757: 		    my $cid=$1.'_'.$2;
1.56      www       758: 		    $r->print('Drop from classlist: <b>'.
1.27      matthew   759: 			 &Apache::lonnet::critical('put:'.
                    760:                              $ENV{'course.'.$cid.'.domain'}.':'.
                    761: 	                     $ENV{'course.'.$cid.'.num'}.':classlist:'.
1.29      matthew   762:                          &Apache::lonnet::escape($ENV{'form.ccuname'}.':'.
                    763:                              $ENV{'form.ccdomain'}).'='.
1.27      matthew   764:                          &Apache::lonnet::escape($now.':'),
1.56      www       765: 	                     $ENV{'course.'.$cid.'.home'}).'</b><br>');
1.27      matthew   766: 		}
                    767: 	    } 
                    768: 	} elsif ($_=~/^form\.act/) {
                    769: 	    if ($_=~/^form\.act\_([^\_]+)\_([^\_]+)\_([^\_]+)$/) {
                    770: 		# Activate roles for sections with 3 id numbers
                    771: 		# set start, end times, and the url for the class
1.55      www       772: 
                    773: 		my $start = ( $ENV{'form.start_'.$1.'_'.$2.'_'.$3} ? 
                    774: 			      $ENV{'form.start_'.$1.'_'.$2.'_'.$3} : 
1.27      matthew   775: 			      $now );
1.55      www       776: 		my $end   = ( $ENV{'form.end_'.$1.'_'.$2.'_'.$3} ? 
                    777: 			      $ENV{'form.end_'.$1.'_'.$2.'_'.$3} :
1.27      matthew   778: 			      0 );
                    779: 		my $url='/'.$1.'/'.$2;
                    780: 		if ($ENV{'form.sec_'.$1.'_'.$2.'_'.$3}) {
                    781: 		    $url.='/'.$ENV{'form.sec_'.$1.'_'.$2.'_'.$3};
                    782: 		}
                    783: 		# Assign the role and report it
1.55      www       784: 		$r->print('Assigning: '.$3.' in '.$url.
                    785:                          ($start?', starting '.localtime($start):'').
1.56      www       786:                          ($end?', ending '.localtime($end):'').': <b>'.
1.27      matthew   787:                           &Apache::lonnet::assignrole(
1.29      matthew   788:                               $ENV{'form.ccdomain'},$ENV{'form.ccuname'},
1.27      matthew   789:                               $url,$3,$end,$start).
1.56      www       790: 			  '</b><br>');
1.27      matthew   791: 		# Handle students differently
                    792: 		if ($3 eq 'st') {
                    793: 		    $url=~/^\/(\w+)\/(\w+)/;
                    794: 		    my $cid=$1.'_'.$2;
1.56      www       795: 		    $r->print('Add to classlist: <b>'.
1.27      matthew   796: 			      &Apache::lonnet::critical(
                    797: 				  'put:'.$ENV{'course.'.$cid.'.domain'}.':'.
                    798: 	                           $ENV{'course.'.$cid.'.num'}.':classlist:'.
                    799:                                    &Apache::lonnet::escape(
1.29      matthew   800:                                        $ENV{'form.ccuname'}.':'.
                    801:                                        $ENV{'form.ccdomain'} ).'='.
1.27      matthew   802:                                    &Apache::lonnet::escape($end.':'.$start),
                    803: 				       $ENV{'course.'.$cid.'.home'})
1.56      www       804: 			      .'</b><br>');
1.27      matthew   805: 		}
                    806: 	    } elsif ($_=~/^form\.act\_([^\_]+)\_([^\_]+)$/) {
                    807: 		# Activate roles for sections with two id numbers
                    808: 		# set start, end times, and the url for the class
                    809: 		my $start = ( $ENV{'form.start_'.$1.'_'.$2} ? 
                    810: 			      $ENV{'form.start_'.$1.'_'.$2} : 
                    811: 			      $now );
                    812: 		my $end   = ( $ENV{'form.end_'.$1.'_'.$2} ? 
                    813: 			      $ENV{'form.end_'.$1.'_'.$2} :
                    814: 			      0 );
                    815: 		my $url='/'.$1.'/';
                    816: 		# Assign the role and report it.
                    817: 		$r->print('Assigning: '.$2.' in '.$url.': '.
1.56      www       818:                          ($start?', starting '.localtime($start):'').
                    819:                          ($end?', ending '.localtime($end):'').': <b>'.
1.27      matthew   820:                           &Apache::lonnet::assignrole(
1.29      matthew   821:                               $ENV{'form.ccdomain'},$ENV{'form.ccuname'},
1.27      matthew   822:                               $url,$2,$end,$start)
1.56      www       823: 			  .'</b><br>');
1.10      www       824: 	    }
1.27      matthew   825: 	} 
                    826:     } # End of foreach (keys(%ENV))
1.5       www       827:     $r->print('</body></html>');
1.4       www       828: }
                    829: 
1.2       www       830: # ================================================================ Main Handler
                    831: sub handler {
                    832:     my $r = shift;
                    833: 
                    834:     if ($r->header_only) {
                    835:        $r->content_type('text/html');
                    836:        $r->send_http_header;
                    837:        return OK;
                    838:     }
                    839: 
                    840:     if ((&Apache::lonnet::allowed('cta',$ENV{'request.course.id'})) ||
                    841:         (&Apache::lonnet::allowed('cin',$ENV{'request.course.id'})) || 
                    842:         (&Apache::lonnet::allowed('ccr',$ENV{'request.course.id'})) || 
                    843:         (&Apache::lonnet::allowed('cep',$ENV{'request.course.id'})) ||
1.42      matthew   844:         (&Apache::lonnet::allowed('cca',$ENV{'request.role.domain'})) ||
                    845:         (&Apache::lonnet::allowed('mau',$ENV{'request.role.domain'}))) {
1.2       www       846:        $r->content_type('text/html');
                    847:        $r->send_http_header;
                    848:        unless ($ENV{'form.phase'}) {
1.42      matthew   849: 	   &print_username_entry_form($r);
1.2       www       850:        }
1.42      matthew   851:        if ($ENV{'form.phase'} eq 'get_user_info') {
                    852:            &print_user_modification_page($r);
                    853:        } elsif ($ENV{'form.phase'} eq 'update_user_data') {
                    854:            &update_user_data($r);
1.2       www       855:        }
1.1       www       856:    } else {
                    857:       $ENV{'user.error.msg'}=
1.9       albertel  858:         "/adm/createuser:mau:0:0:Cannot modify user data";
1.1       www       859:       return HTTP_NOT_ACCEPTABLE; 
                    860:    }
                    861:    return OK;
                    862: } 
1.26      matthew   863: 
1.27      matthew   864: #-------------------------------------------------- functions for &phase_two
1.26      matthew   865: sub course_level_table {
                    866:     my %inccourses = @_;
                    867:     my $table = '';
                    868:     foreach (sort( keys(%inccourses))) {
                    869: 	my $thiscourse=$_;
                    870: 	my $protectedcourse=$_;
                    871: 	$thiscourse=~s:_:/:g;
                    872: 	my %coursedata=&Apache::lonnet::coursedescription($thiscourse);
                    873: 	my $area=$coursedata{'description'};
1.50      albertel  874: 	if (!defined($area)) { $area='Unavailable course: '.$_; }
1.26      matthew   875: 	my $bgcol=$thiscourse;
                    876: 	$bgcol=~s/[^8-9b-e]//g;
                    877: 	$bgcol=substr($bgcol.$bgcol.$bgcol.'ffffff',0,6);
                    878: 	foreach  ('st','ta','ep','ad','in','cc') {
                    879: 	    if (&Apache::lonnet::allowed('c'.$_,$thiscourse)) {
                    880: 		my $plrole=&Apache::lonnet::plaintext($_);
                    881: 		$table .= <<ENDEXTENT;
                    882: <tr bgcolor="#$bgcol">
                    883: <td><input type="checkbox" name="act_$protectedcourse\_$_"></td>
                    884: <td>$plrole</td>
                    885: <td>$area</td>
                    886: ENDEXTENT
                    887: 	        if ($_ ne 'cc') {
                    888: 		    $table .= <<ENDSECTION;
                    889: <td><input type="text" size="5" name="sec_$protectedcourse\_$_"></td>
                    890: ENDSECTION
                    891:                 } else { 
                    892: 		    $table .= <<ENDSECTION;
                    893: <td>&nbsp</td> 
                    894: ENDSECTION
                    895:                 }
                    896: 		$table .= <<ENDTIMEENTRY;
                    897: <td><input type=hidden name="start_$protectedcourse\_$_" value=''>
                    898: <a href=
                    899: "javascript:pjump('date_start','Start Date $plrole',document.cu.start_$protectedcourse\_$_.value,'start_$protectedcourse\_$_','cu.pres','dateset')">Set Start Date</a></td>
                    900: <td><input type=hidden name="end_$protectedcourse\_$_" value=''>
                    901: <a href=
                    902: "javascript:pjump('date_end','End Date $plrole',document.cu.end_$protectedcourse\_$_.value,'end_$protectedcourse\_$_','cu.pres','dateset')">Set End Date</a></td>
                    903: ENDTIMEENTRY
                    904:                 $table.= "</tr>\n";
                    905:             }
                    906:         }
                    907:     }
                    908:     return '' if ($table eq ''); # return nothing if there is nothing 
                    909:                                  # in the table
                    910:     my $result = <<ENDTABLE;
                    911: <h4>Course Level</h4>
                    912: <table border=2><tr><th>Activate</th><th>Role</th><th>Extent</th>
                    913: <th>Group/Section</th><th>Start</th><th>End</th></tr>
                    914: $table
                    915: </table>
                    916: ENDTABLE
                    917:     return $result;
                    918: }
1.27      matthew   919: #---------------------------------------------- end functions for &phase_two
1.29      matthew   920: 
                    921: #--------------------------------- functions for &phase_two and &phase_three
                    922: 
                    923: #--------------------------end of functions for &phase_two and &phase_three
1.1       www       924: 
                    925: 1;
                    926: __END__
1.2       www       927: 
                    928: 

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