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

1.20      harris41    1: # The LearningOnline Network with CAPA
1.1       www         2: # Create a user
                      3: #
1.77    ! www         4: # $Id: loncreateuser.pm,v 1.76 2004/01/15 03:18:19 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.20      harris41   28: ###
                     29: 
1.1       www        30: package Apache::loncreateuser;
1.66      bowersj2   31: 
                     32: =pod
                     33: 
                     34: =head1 NAME
                     35: 
                     36: Apache::loncreateuser - handler to create users and custom roles
                     37: 
                     38: =head1 SYNOPSIS
                     39: 
                     40: Apache::loncreateuser provides an Apache handler for creating users,
                     41:     editing their login parameters, roles, and removing roles, and
                     42:     also creating and assigning custom roles.
                     43: 
                     44: =head1 OVERVIEW
                     45: 
                     46: =head2 Custom Roles
                     47: 
                     48: In LON-CAPA, roles are actually collections of privileges. "Teaching
                     49: Assistant", "Course Coordinator", and other such roles are really just
                     50: collection of privileges that are useful in many circumstances.
                     51: 
                     52: Creating custom roles can be done by the Domain Coordinator through
                     53: the Create User functionality. That screen will show all privileges
                     54: that can be assigned to users. For a complete list of privileges,
                     55: please see C</home/httpd/lonTabs/rolesplain.tab>.
                     56: 
                     57: Custom role definitions are stored in the C<roles.db> file of the role
                     58: author.
                     59: 
                     60: =cut
1.1       www        61: 
                     62: use strict;
                     63: use Apache::Constants qw(:common :http);
                     64: use Apache::lonnet;
1.54      bowersj2   65: use Apache::loncommon;
1.68      www        66: use Apache::lonlocal;
1.1       www        67: 
1.20      harris41   68: my $loginscript; # piece of javascript used in two separate instances
                     69: my $generalrule;
                     70: my $authformnop;
                     71: my $authformkrb;
                     72: my $authformint;
                     73: my $authformfsys;
                     74: my $authformloc;
                     75: 
1.23      harris41   76: BEGIN {
1.20      harris41   77:     $ENV{'SERVER_NAME'}=~/(\w+\.\w+)$/;
                     78:     my $krbdefdom=$1;
                     79:     $krbdefdom=~tr/a-z/A-Z/;
1.31      matthew    80:     my %param = ( formname => 'document.cu',
                     81:                   kerb_def_dom => $krbdefdom 
                     82:                   );
1.48      albertel   83: # no longer static due to configurable kerberos defaults
                     84: #    $loginscript  = &Apache::loncommon::authform_header(%param);
1.31      matthew    85:     $generalrule  = &Apache::loncommon::authform_authorwarning(%param);
                     86:     $authformnop  = &Apache::loncommon::authform_nochange(%param);
1.48      albertel   87: # no longer static due to configurable kerberos defaults
                     88: #    $authformkrb  = &Apache::loncommon::authform_kerberos(%param);
1.31      matthew    89:     $authformint  = &Apache::loncommon::authform_internal(%param);
                     90:     $authformfsys = &Apache::loncommon::authform_filesystem(%param);
                     91:     $authformloc  = &Apache::loncommon::authform_local(%param);
1.20      harris41   92: }
                     93: 
1.43      www        94: 
1.59      www        95: # ======================================================= Existing Custom Roles
                     96: 
                     97: sub my_custom_roles {
                     98:     my %returnhash=();
                     99:     my %rolehash=&Apache::lonnet::dump('roles');
                    100:     foreach (keys %rolehash) {
                    101: 	if ($_=~/^rolesdef\_(\w+)$/) {
1.61      www       102: 	    $returnhash{$1}=$1;
1.59      www       103: 	}
                    104:     }
                    105:     return %returnhash;
                    106: }
1.43      www       107: 
                    108: # ==================================================== Figure out author access
                    109: 
                    110: sub authorpriv {
                    111:     my ($auname,$audom)=@_;
                    112:     if (($auname ne $ENV{'user.name'}) ||
                    113:         (($audom ne $ENV{'user.domain'}) &&
                    114:          ($audom ne $ENV{'request.role.domain'}))) { return ''; }
                    115:     unless (&Apache::lonnet::allowed('cca',$audom)) { return ''; }
                    116:     return 1;
                    117: }
                    118: 
1.2       www       119: # =================================================================== Phase one
1.1       www       120: 
1.42      matthew   121: sub print_username_entry_form {
1.2       www       122:     my $r=shift;
1.42      matthew   123:     my $defdom=$ENV{'request.role.domain'};
1.33      matthew   124:     my @domains = &Apache::loncommon::get_domains();
                    125:     my $domform = &Apache::loncommon::select_dom_form($defdom,'ccdomain');
1.40      www       126:     my $bodytag =&Apache::loncommon::bodytag(
1.76      www       127:                                   'Create Users, Change User Privileges').
                    128: 		  &Apache::loncommon::help_open_faq(282).
                    129: 		  &Apache::loncommon::help_open_bug('Instructor Interface');
1.46      www       130:     my $selscript=&Apache::loncommon::studentbrowser_javascript();
                    131:     my $sellink=&Apache::loncommon::selectstudent_link
                    132:                                         ('crtuser','ccuname','ccdomain');
1.59      www       133:     my %existingroles=&my_custom_roles();
                    134:     my $choice=&Apache::loncommon::select_form('make new role','rolename',
                    135: 		('make new role' => 'Generate new role ...',%existingroles));
1.71      sakharuk  136:     my %lt=&Apache::lonlocal::texthash(
                    137: 		    'siur'   => "Set Individual User Roles",
                    138: 		    'usr'  => "Username",
                    139:                     'dom'  => "Domain",
                    140:                     'usrr' => "User Roles",
                    141:                     'ecrp' => "Edit Custom Role Privileges",
1.72      sakharuk  142:                     'nr'   => "Name of Role",
1.71      sakharuk  143:                     'cre'  => "Custom Role Editor"
                    144: 				       );
1.76      www       145:     my $helpsiur=&Apache::loncommon::help_open_topic('Course_Change_Privileges');
                    146:     my $helpecpr=&Apache::loncommon::help_open_topic('Course_Editing_Custom_Roles');
1.33      matthew   147:     $r->print(<<"ENDDOCUMENT");
1.1       www       148: <html>
                    149: <head>
                    150: <title>The LearningOnline Network with CAPA</title>
1.46      www       151: $selscript
1.1       www       152: </head>
1.40      www       153: $bodytag
1.46      www       154: <form action="/adm/createuser" method="post" name="crtuser">
1.42      matthew   155: <input type="hidden" name="phase" value="get_user_info">
1.76      www       156: <h2>$lt{siur}$helpsiur</h2>
1.43      www       157: <table>
1.71      sakharuk  158: <tr><td>$lt{usr}:</td><td><input type="text" size="15" name="ccuname">
1.46      www       159: </td><td rowspan="2">$sellink</td></tr><tr><td>
1.71      sakharuk  160: $lt{'dom'}:</td><td>$domform</td></tr>
1.58      www       161: </table>
1.71      sakharuk  162: <input name="userrole" type="submit" value="$lt{usrr}" />
1.2       www       163: </form>
1.58      www       164: <form action="/adm/createuser" method="post" name="docustom">
                    165: <input type="hidden" name="phase" value="selected_custom_edit">
1.76      www       166: <h2>$lt{'ecrp'}$helpecpr</h2>
1.72      sakharuk  167: $lt{'nr'}: $choice <input type="text" size="15" name="newrolename" /><br />
1.71      sakharuk  168: <input name="customeditor" type="submit" value="$lt{'cre'}" />
1.1       www       169: </body>
                    170: </html>
                    171: ENDDOCUMENT
1.2       www       172: }
                    173: 
                    174: # =================================================================== Phase two
1.42      matthew   175: sub print_user_modification_page {
1.2       www       176:     my $r=shift;
                    177:     my $ccuname=$ENV{'form.ccuname'};
                    178:     my $ccdomain=$ENV{'form.ccdomain'};
1.4       www       179: 
1.58      www       180:     $ccuname=~s/\W//gs;
                    181:     $ccdomain=~s/\W//gs;
                    182: 
                    183:     unless (($ccuname) && ($ccdomain)) {
                    184: 	&print_username_entry_form($r);
                    185:         return;
                    186:     }
                    187: 
1.48      albertel  188:     my $defdom=$ENV{'request.role.domain'};
                    189: 
                    190:     my ($krbdef,$krbdefdom) =
                    191:        &Apache::loncommon::get_kerberos_defaults($defdom);
                    192: 
1.31      matthew   193:     my %param = ( formname => 'document.cu',
1.48      albertel  194:                   kerb_def_dom => $krbdefdom,
                    195:                   kerb_def_auth => $krbdef
1.31      matthew   196:                   );
                    197:     $loginscript  = &Apache::loncommon::authform_header(%param);
1.48      albertel  198:     $authformkrb  = &Apache::loncommon::authform_kerberos(%param);
1.4       www       199: 
1.2       www       200:     $ccuname=~s/\W//g;
                    201:     $ccdomain=~s/\W//g;
1.52      matthew   202:     my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
1.25      matthew   203:     my $dochead =<<"ENDDOCHEAD";
1.2       www       204: <html>
                    205: <head>
                    206: <title>The LearningOnline Network with CAPA</title>
1.31      matthew   207: <script type="text/javascript" language="Javascript">
1.3       www       208: 
                    209:     function pclose() {
                    210:         parmwin=window.open("/adm/rat/empty.html","LONCAPAparms",
                    211:                  "height=350,width=350,scrollbars=no,menubar=no");
                    212:         parmwin.close();
                    213:     }
                    214: 
1.52      matthew   215:     $pjump_def
1.3       www       216: 
                    217:     function dateset() {
                    218:         eval("document.cu."+document.cu.pres_marker.value+
                    219:             ".value=document.cu.pres_value.value");
                    220:         pclose();
                    221:     }
                    222: 
                    223: </script>
1.2       www       224: </head>
1.25      matthew   225: ENDDOCHEAD
1.40      www       226:     $r->print(&Apache::loncommon::bodytag(
                    227:                                      'Create Users, Change User Privileges'));
1.25      matthew   228:     my $forminfo =<<"ENDFORMINFO";
                    229: <form action="/adm/createuser" method="post" name="cu">
1.42      matthew   230: <input type="hidden" name="phase"       value="update_user_data">
1.25      matthew   231: <input type="hidden" name="ccuname"     value="$ccuname">
                    232: <input type="hidden" name="ccdomain"    value="$ccdomain">
                    233: <input type="hidden" name="pres_value"  value="" >
                    234: <input type="hidden" name="pres_type"   value="" >
                    235: <input type="hidden" name="pres_marker" value="" >
                    236: ENDFORMINFO
1.2       www       237:     my $uhome=&Apache::lonnet::homeserver($ccuname,$ccdomain);
                    238:     my %incdomains; 
                    239:     my %inccourses;
1.49      albertel  240:     foreach (values(%Apache::lonnet::hostdom)) {
1.13      www       241:        $incdomains{$_}=1;
1.24      matthew   242:     }
                    243:     foreach (keys(%ENV)) {
1.2       www       244: 	if ($_=~/^user\.priv\.cm\.\/(\w+)\/(\w+)/) {
                    245: 	    $inccourses{$1.'_'.$2}=1;
                    246:         }
1.24      matthew   247:     }
1.2       www       248:     if ($uhome eq 'no_host') {
1.29      matthew   249:         my $home_server_list=
1.32      matthew   250:             '<option value="default" selected>default</option>'."\n".
                    251:                 &Apache::loncommon::home_server_option_list($ccdomain);
                    252:         
1.72      sakharuk  253:     my %lt=&Apache::lonlocal::texthash(
                    254:                     'cnu'  => "Create New User",
                    255:                     'nu'   => "New User",
                    256:                     'id'   => "in domain",
                    257:                     'pd'   => "Personal Data",
                    258:                     'fn'   => "First Name",
                    259:                     'mn'   => "Middle Name",
                    260:                     'ln'   => "Last Name",
                    261:                     'gen'  => "Generation",
                    262:                     'idsn' => "ID/Student Number",
                    263:                     'hs'   => "Home Server",
                    264:                     'lg'   => "Login Data"
                    265: 				       );
1.26      matthew   266: 	$r->print(<<ENDNEWUSER);
1.25      matthew   267: $dochead
1.72      sakharuk  268: <h1>$lt{'cnu'}</h1>
1.25      matthew   269: $forminfo
1.72      sakharuk  270: <h2>$lt{'nu'} "$ccuname" $lt{'id'} $ccdomain</h2>
1.31      matthew   271: <script type="text/javascript" language="Javascript">
1.20      harris41  272: $loginscript
1.31      matthew   273: </script>
1.20      harris41  274: <input type='hidden' name='makeuser' value='1' />
1.72      sakharuk  275: <h3>$lt{'pd'}</h3>
1.25      matthew   276: <p>
                    277: <table>
1.72      sakharuk  278: <tr><td>$lt{'fn'}  </td>
1.25      matthew   279:     <td><input type='text' name='cfirst'  size='15' /></td></tr>
1.72      sakharuk  280: <tr><td>$lt{'mn'} </td> 
1.25      matthew   281:     <td><input type='text' name='cmiddle' size='15' /></td></tr>
1.72      sakharuk  282: <tr><td>$lt{'ln'}   </td>
1.25      matthew   283:     <td><input type='text' name='clast'   size='15' /></td></tr>
1.72      sakharuk  284: <tr><td>$lt{'gen'}  </td>
1.25      matthew   285:     <td><input type='text' name='cgen'    size='5'  /></td></tr>
                    286: </table>
1.72      sakharuk  287: $lt{'idsn'} <input type='text' name='cstid'   size='15' /></p>
1.74      sakharuk  288: $lt{'hs'}: <select name="hserver" size="1"> $home_server_list </select>
1.25      matthew   289: <hr />
1.72      sakharuk  290: <h3>$lt{'lg'}</h3>
1.31      matthew   291: <p>$generalrule </p>
                    292: <p>$authformkrb </p>
                    293: <p>$authformint </p>
                    294: <p>$authformfsys</p>
                    295: <p>$authformloc </p>
1.26      matthew   296: ENDNEWUSER
1.25      matthew   297:     } else { # user already exists
1.72      sakharuk  298:     my %lt=&Apache::lonlocal::texthash(
                    299:                     'cup'  => "Change User Privileges",
                    300:                     'usr'  => "User",                    
                    301:                     'id'   => "in domain",
                    302:                     'fn'   => "first name",
                    303:                     'mn'   => "middle name",
                    304:                     'ln'   => "last name",
                    305:                     'gen'  => "generation"
                    306: 				       );
1.26      matthew   307: 	$r->print(<<ENDCHANGEUSER);
1.25      matthew   308: $dochead
1.72      sakharuk  309: <h1>$lt{'cup'}</h1>
1.25      matthew   310: $forminfo
1.72      sakharuk  311: <h2>$lt{'usr'} "$ccuname" $lt{'id'} "$ccdomain"</h2>
1.26      matthew   312: ENDCHANGEUSER
1.28      matthew   313:         # Get the users information
                    314:         my %userenv = &Apache::lonnet::get('environment',
                    315:                           ['firstname','middlename','lastname','generation'],
                    316:                           $ccdomain,$ccuname);
                    317:         my %rolesdump=&Apache::lonnet::dump('roles',$ccdomain,$ccuname);
                    318:         $r->print(<<END);
                    319: <hr />
                    320: <table border="2">
                    321: <tr>
1.72      sakharuk  322: <th>$lt{'fn'}</th><th>$lt{'mn'}</th><th>$lt{'ln'}</th><th>$lt{'gen'}</th>
1.28      matthew   323: </tr>
                    324: <tr>
                    325: END
                    326:         foreach ('firstname','middlename','lastname','generation') {
                    327:            if (&Apache::lonnet::allowed('mau',$ccdomain)) {
                    328:               $r->print(<<"END");            
1.53      www       329: <td><input type="text" name="c$_" value="$userenv{$_}" size="15" /></td>
1.28      matthew   330: END
                    331:            } else {
                    332:                $r->print('<td>'.$userenv{$_}.'</td>');
                    333:            }
                    334:         }
1.72      sakharuk  335:       $r->print(<<END);
1.28      matthew   336: </tr>
                    337: </table>
                    338: END
1.25      matthew   339:         # Build up table of user roles to allow revocation of a role.
1.28      matthew   340:         my ($tmp) = keys(%rolesdump);
                    341:         unless ($tmp =~ /^(con_lost|error)/i) {
1.2       www       342:            my $now=time;
1.72      sakharuk  343: 	   my %lt=&Apache::lonlocal::texthash(
                    344: 		    'rer'  => "Revoke Existing Roles",
                    345:                     'rev'  => "Revoke",                    
                    346:                     'del'  => "Delete",
                    347:                     'rol'  => "Role",
                    348:                     'ext'  => "Extent",
                    349:                     'sta'  => "Start",
                    350:                     'end'  => "End"
                    351: 				       );
1.37      matthew   352:            $r->print(<<END);
                    353: <hr />
1.72      sakharuk  354: <h3>$lt{'rer'}</h3>
1.37      matthew   355: <table border=2>
1.72      sakharuk  356: <tr><th>$lt{'rev'}</th><th>$lt{'del'}</th><th>$lt{'rol'}</th><th>$lt{'ext'}</th><th>$lt{'sta'}</th><th>$lt{'end'}</th>
1.37      matthew   357: END
1.67      albertel  358: 	   foreach my $area (sort { my $a1=join('_',(split('_',$a))[1,0]);
                    359: 				    my $b1=join('_',(split('_',$b))[1,0]);
                    360: 				    return $a1 cmp $b1;
                    361: 				} keys(%rolesdump)) {
1.37      matthew   362:                next if ($area =~ /^rolesdef/);
                    363:                my $role = $rolesdump{$area};
                    364:                my $thisrole=$area;
                    365:                $area =~ s/\_\w\w$//;
                    366:                my ($role_code,$role_end_time,$role_start_time) = 
                    367:                    split(/_/,$role);
1.64      www       368: # Is this a custom role? Get role owner and title.
                    369: 	       my ($croleudom,$croleuname,$croletitle)=
                    370: 	           ($role_code=~/^cr\/(\w+)\/(\w+)\/(\w+)$/);
1.37      matthew   371:                my $bgcol='ffffff';
                    372:                my $allowed=0;
1.53      www       373:                my $delallowed=0;
1.37      matthew   374:                if ($area =~ /^\/(\w+)\/(\d\w+)/ ) {
1.57      matthew   375:                    my ($coursedom,$coursedir) = ($1,$2);
                    376:                    # $1.'_'.$2 is the course id (eg. 103_12345abcef103l3).
1.37      matthew   377:                    my %coursedata=
                    378:                        &Apache::lonnet::coursedescription($1.'_'.$2);
1.51      albertel  379: 		   my $carea;
                    380: 		   if (defined($coursedata{'description'})) {
1.72      sakharuk  381: 		       $carea=&mt('Course').': '.$coursedata{'description'}.
                    382:                            '<br />'.&mt('Domain').': '.$coursedom.('&nbsp;'x8).
1.57      matthew   383:      &Apache::loncommon::syllabuswrapper('Syllabus',$coursedir,$coursedom);
1.51      albertel  384: 		   } else {
1.72      sakharuk  385: 		       $carea=&mt('Unavailable course').': '.$area;
1.51      albertel  386: 		   }
1.37      matthew   387:                    $inccourses{$1.'_'.$2}=1;
1.53      www       388:                    if ((&Apache::lonnet::allowed('c'.$role_code,$1.'/'.$2)) ||
                    389:                        (&Apache::lonnet::allowed('c'.$role_code,$ccdomain))) {
1.37      matthew   390:                        $allowed=1;
                    391:                    }
1.53      www       392:                    if ((&Apache::lonnet::allowed('dro',$1)) ||
                    393:                        (&Apache::lonnet::allowed('dro',$ccdomain))) {
                    394:                        $delallowed=1;
                    395:                    }
1.64      www       396: # - custom role. Needs more info, too
                    397: 		   if ($croletitle) {
                    398: 		       if (&Apache::lonnet::allowed('ccr',$1.'/'.$2)) {
                    399: 			   $allowed=1;
                    400: 			   $thisrole.='.'.$role_code;
                    401: 		       }
                    402: 		   }
1.37      matthew   403:                    # Compute the background color based on $area
                    404:                    $bgcol=$1.'_'.$2;
1.62      www       405:                    $bgcol=~s/[^7-9a-e]//g;
                    406:                    $bgcol=substr($bgcol.$bgcol.$bgcol.'ffffff',2,6);
1.37      matthew   407:                    if ($area=~/^\/(\w+)\/(\d\w+)\/(\w+)/) {
1.28      matthew   408:                        $carea.='<br>Section/Group: '.$3;
1.37      matthew   409:                    }
                    410:                    $area=$carea;
                    411:                } else {
                    412:                    # Determine if current user is able to revoke privileges
                    413:                    if ($area=~ /^\/(\w+)\//) {
1.53      www       414:                        if ((&Apache::lonnet::allowed('c'.$role_code,$1)) ||
                    415:                        (&Apache::lonnet::allowed('c'.$role_code,$ccdomain))) {
1.37      matthew   416:                            $allowed=1;
                    417:                        }
1.53      www       418:                        if (((&Apache::lonnet::allowed('dro',$1))  ||
                    419:                             (&Apache::lonnet::allowed('dro',$ccdomain))) &&
                    420:                            ($role_code ne 'dc')) {
                    421:                            $delallowed=1;
                    422:                        }
1.37      matthew   423:                    } else {
                    424:                        if (&Apache::lonnet::allowed('c'.$role_code,'/')) {
                    425:                            $allowed=1;
                    426:                        }
                    427:                    }
                    428:                }
1.43      www       429:                if ($role_code eq 'ca') {
                    430:                    $area=~/\/(\w+)\/(\w+)/;
                    431: 		   if (&authorpriv($2,$1)) {
                    432: 		       $allowed=1;
                    433:                    } else {
                    434:                        $allowed=0;
1.37      matthew   435:                    }
                    436:                }
                    437:                my $row = '';
1.62      www       438:                $row.='<tr bgcolor="#'.$bgcol.'"><td>';
1.37      matthew   439:                my $active=1;
                    440:                $active=0 if (($role_end_time) && ($now>$role_end_time));
                    441:                if (($active) && ($allowed)) {
                    442:                    $row.= '<input type="checkbox" name="rev:'.$thisrole.'">';
                    443:                } else {
1.56      www       444:                    if ($active) {
                    445:                       $row.='&nbsp;';
                    446: 		   } else {
1.72      sakharuk  447:                       $row.=&mt('expired or revoked');
1.56      www       448: 		   }
1.37      matthew   449:                }
1.53      www       450: 	       $row.='</td><td>';
                    451:                if ($delallowed) {
                    452:                    $row.= '<input type="checkbox" name="del:'.$thisrole.'">';
                    453:                } else {
                    454:                    $row.='&nbsp;';
                    455:                }
1.64      www       456: 	       my $plaintext='';
                    457: 	       unless ($croletitle) {
                    458: 		   $plaintext=&Apache::lonnet::plaintext($role_code);
                    459: 	       } else {
                    460: 	           $plaintext=
                    461: 		"Customrole '$croletitle' defined by $croleuname\@$croleudom";
                    462: 	       }
                    463:                $row.= '</td><td>'.$plaintext.
1.37      matthew   464:                       '</td><td>'.$area.
                    465:                       '</td><td>'.($role_start_time?localtime($role_start_time)
                    466:                                                    : '&nbsp;' ).
                    467:                       '</td><td>'.($role_end_time  ?localtime($role_end_time)
                    468:                                                    : '&nbsp;' )
                    469:                       ."</td></tr>\n";
                    470:                $r->print($row);
1.28      matthew   471:            } # end of foreach        (table building loop)
1.2       www       472: 	   $r->print('</table>');
1.28      matthew   473:         }  # End of unless
1.20      harris41  474: 	my $currentauth=&Apache::lonnet::queryauthenticate($ccuname,$ccdomain);
1.41      albertel  475: 	if ($currentauth=~/^krb(4|5):/) {
                    476: 	    $currentauth=~/^krb(4|5):(.*)/;
1.45      matthew   477: 	    my $krbdefdom=$1;
1.31      matthew   478:             my %param = ( formname => 'document.cu',
                    479:                           kerb_def_dom => $krbdefdom 
                    480:                           );
                    481:             $loginscript  = &Apache::loncommon::authform_header(%param);
1.20      harris41  482: 	}
1.26      matthew   483: 	# Check for a bad authentication type
1.41      albertel  484:         unless ($currentauth=~/^krb(4|5):/ or
1.20      harris41  485: 		$currentauth=~/^unix:/ or
                    486: 		$currentauth=~/^internal:/ or
                    487: 		$currentauth=~/^localauth:/
1.26      matthew   488: 		) { # bad authentication scheme
1.42      matthew   489: 	    if (&Apache::lonnet::allowed('mau',$ENV{'request.role.domain'})) {
1.73      sakharuk  490: 		my %lt=&Apache::lonlocal::texthash(
                    491:                                'err'   => "ERROR",
                    492: 			       'uuas'  => "This user has an unrecognized authentication scheme",
                    493:                                'sldb'  => "Please specify login data below",
                    494:                                'ld'    => "Login Data"
                    495: 						   );
1.26      matthew   496: 		$r->print(<<ENDBADAUTH);
1.21      harris41  497: <hr />
1.31      matthew   498: <script type="text/javascript" language="Javascript">
1.21      harris41  499: $loginscript
1.31      matthew   500: </script>
1.73      sakharuk  501: <font color='#ff0000'>$lt{'err'}:</font>
                    502: $lt{'uuas'} ($currentauth). $lt{'sldb'}.
                    503: <h3>$lt{'ld'}</h3>
1.31      matthew   504: <p>$generalrule</p>
                    505: <p>$authformkrb</p>
                    506: <p>$authformint</p>
                    507: <p>$authformfsys</p>
                    508: <p>$authformloc</p>
1.26      matthew   509: ENDBADAUTH
                    510:             } else { 
                    511:                 # This user is not allowed to modify the users 
                    512:                 # authentication scheme, so just notify them of the problem
1.73      sakharuk  513: 		my %lt=&Apache::lonlocal::texthash(
                    514:                                'err'   => "ERROR",
                    515: 			       'uuas'  => "This user has an unrecognized authentication scheme",
                    516:                                'adcs'  => "Please alert a domain coordinator of this situation"
                    517: 						   );
1.26      matthew   518: 		$r->print(<<ENDBADAUTH);
                    519: <hr />
1.31      matthew   520: <script type="text/javascript" language="Javascript">
1.26      matthew   521: $loginscript
1.31      matthew   522: </script>
1.73      sakharuk  523: <font color="#ff0000"> $lt{'err'}: </font>
                    524: $lt{'uuas'} ($currentauth). $lt{'adcs'}.
1.26      matthew   525: <hr />
                    526: ENDBADAUTH
                    527:             }
                    528:         } else { # Authentication type is valid
1.20      harris41  529: 	    my $authformcurrent='';
1.26      matthew   530: 	    my $authform_other='';
1.41      albertel  531: 	    if ($currentauth=~/^krb(4|5):/) {
1.20      harris41  532: 		$authformcurrent=$authformkrb;
1.31      matthew   533: 		$authform_other="<p>$authformint</p>\n".
                    534:                     "<p>$authformfsys</p><p>$authformloc</p>";
1.20      harris41  535: 	    }
                    536: 	    elsif ($currentauth=~/^internal:/) {
                    537: 		$authformcurrent=$authformint;
1.31      matthew   538: 		$authform_other="<p>$authformkrb</p>".
                    539:                     "<p>$authformfsys</p><p>$authformloc</p>";
1.20      harris41  540: 	    }
                    541: 	    elsif ($currentauth=~/^unix:/) {
                    542: 		$authformcurrent=$authformfsys;
1.31      matthew   543: 		$authform_other="<p>$authformkrb</p>".
                    544:                     "<p>$authformint</p><p>$authformloc;</p>";
1.20      harris41  545: 	    }
                    546: 	    elsif ($currentauth=~/^localauth:/) {
                    547: 		$authformcurrent=$authformloc;
1.31      matthew   548: 		$authform_other="<p>$authformkrb</p>".
                    549:                     "<p>$authformint</p><p>$authformfsys</p>";
1.20      harris41  550: 	    }
1.53      www       551:             $authformcurrent.=' <i>(will override current values)</i><br />';
1.42      matthew   552:             if (&Apache::lonnet::allowed('mau',$ENV{'request.role.domain'})) {
1.26      matthew   553: 		# Current user has login modification privileges
1.73      sakharuk  554: 		my %lt=&Apache::lonlocal::texthash(
                    555:                                'ccld'  => "Change Current Login Data",
                    556: 			       'enld'  => "Enter New Login Data"
                    557: 						   );
1.26      matthew   558: 		$r->print(<<ENDOTHERAUTHS);
1.21      harris41  559: <hr />
1.31      matthew   560: <script type="text/javascript" language="Javascript">
1.21      harris41  561: $loginscript
1.31      matthew   562: </script>
1.73      sakharuk  563: <h3>$lt{'ccld'}</h3>
1.31      matthew   564: <p>$generalrule</p>
                    565: <p>$authformnop</p>
                    566: <p>$authformcurrent</p>
1.73      sakharuk  567: <h3>$lt{'enld'}</h3>
1.26      matthew   568: $authform_other
                    569: ENDOTHERAUTHS
                    570:             }
                    571:         }  ## End of "check for bad authentication type" logic
1.25      matthew   572:     } ## End of new user/old user logic
1.72      sakharuk  573:     $r->print('<hr /><h3>'.&mt('Add Roles').'</h3>');
1.17      www       574: #
                    575: # Co-Author
                    576: # 
1.44      matthew   577:     if (&authorpriv($ENV{'user.name'},$ENV{'request.role.domain'}) &&
                    578:         ($ENV{'user.name'} ne $ccuname || $ENV{'user.domain'} ne $ccdomain)) {
                    579:         # No sense in assigning co-author role to yourself
1.17      www       580: 	my $cuname=$ENV{'user.name'};
1.42      matthew   581:         my $cudom=$ENV{'request.role.domain'};
1.72      sakharuk  582: 	   my %lt=&Apache::lonlocal::texthash(
                    583: 		    'cs'   => "Construction Space",
                    584:                     'act'  => "Activate",                    
                    585:                     'rol'  => "Role",
                    586:                     'ext'  => "Extent",
                    587:                     'sta'  => "Start",
                    588:                     'end'  => "End".
                    589:                     'cau'  => "Co-Author",
                    590:                     'ssd'  => "Set Start Date",
                    591:                     'sed'  => "Set End Date"
                    592: 				       );
1.17      www       593:        $r->print(<<ENDCOAUTH);
1.72      sakharuk  594: <h4>$lt{'cs'}</h4>
1.74      sakharuk  595: <table border=2><tr><th>$lt{'act'}</th><th>$lt{'rol'}</th><th>$lt{'ext'}</th>
1.72      sakharuk  596: <th>$lt{'sta'}</th><th>$lt{'end'}</th></tr>
1.17      www       597: <tr>
                    598: <td><input type=checkbox name="act_$cudom\_$cuname\_ca"></td>
1.72      sakharuk  599: <td>$lt{'cau'}</td>
1.17      www       600: <td>$cudom\_$cuname</td>
                    601: <td><input type=hidden name="start_$cudom\_$cuname\_ca" value=''>
                    602: <a href=
1.72      sakharuk  603: "javascript:pjump('date_start','Start Date Co-Author',document.cu.start_$cudom\_$cuname\_ca.value,'start_$cudom\_$cuname\_ca','cu.pres','dateset')">$lt{'ssd'}</a></td>
1.17      www       604: <td><input type=hidden name="end_$cudom\_$cuname\_ca" value=''>
                    605: <a href=
1.72      sakharuk  606: "javascript:pjump('date_end','End Date Co-Author',document.cu.end_$cudom\_$cuname\_ca.value,'end_$cudom\_$cuname\_ca','cu.pres','dateset')">$lt{'sed'}</a></td>
1.17      www       607: </tr>
                    608: </table>
                    609: ENDCOAUTH
                    610:     }
1.8       www       611: #
                    612: # Domain level
                    613: #
1.72      sakharuk  614:     $r->print('<h4>'.&mt('Domain Level').'</h4>'.
1.73      sakharuk  615:     '<table border=2><tr><th>'.&mt('Activate').'</th><th>'.&mt('Role').'</th><th>'.&mt('Extent').'</th>'.
                    616:     '<th>'.&mt('Start').'</th><th>'.&mt('End').'</th></tr>');
1.24      matthew   617:     foreach ( sort( keys(%incdomains))) {
1.2       www       618: 	my $thisdomain=$_;
1.69      albertel  619:         foreach ('dc','li','dg','au','sc') {
1.2       www       620:             if (&Apache::lonnet::allowed('c'.$_,$thisdomain)) {
1.8       www       621:                my $plrole=&Apache::lonnet::plaintext($_);
1.72      sakharuk  622: 	       my %lt=&Apache::lonlocal::texthash(
                    623:                     'ssd'  => "Set Start Date",
                    624:                     'sed'  => "Set End Date"
                    625: 				       );
1.8       www       626:                $r->print(<<ENDDROW);
                    627: <tr>
                    628: <td><input type=checkbox name="act_$thisdomain\_$_"></td>
                    629: <td>$plrole</td>
                    630: <td>$thisdomain</td>
                    631: <td><input type=hidden name="start_$thisdomain\_$_" value=''>
                    632: <a href=
1.72      sakharuk  633: "javascript:pjump('date_start','Start Date $plrole',document.cu.start_$thisdomain\_$_.value,'start_$thisdomain\_$_','cu.pres','dateset')">$lt{'ssd'}</a></td>
1.8       www       634: <td><input type=hidden name="end_$thisdomain\_$_" value=''>
                    635: <a href=
1.72      sakharuk  636: "javascript:pjump('date_end','End Date $plrole',document.cu.end_$thisdomain\_$_.value,'end_$thisdomain\_$_','cu.pres','dateset')">$lt{'sed'}</a></td>
1.8       www       637: </tr>
                    638: ENDDROW
1.2       www       639:             }
1.24      matthew   640:         } 
                    641:     }
1.8       www       642:     $r->print('</table>');
                    643: #
                    644: # Course level
                    645: #
1.26      matthew   646:     $r->print(&course_level_table(%inccourses));
1.72      sakharuk  647:     $r->print("<hr /><input type=submit value=\"".&mt('Modify User')."\">\n");
1.26      matthew   648:     $r->print("</form></body></html>");
1.2       www       649: }
1.1       www       650: 
1.4       www       651: # ================================================================= Phase Three
1.42      matthew   652: sub update_user_data {
1.4       www       653:     my $r=shift;
1.29      matthew   654:     my $uhome=&Apache::lonnet::homeserver($ENV{'form.ccuname'},
                    655:                                           $ENV{'form.ccdomain'});
1.27      matthew   656:     # Error messages
1.73      sakharuk  657:     my $error     = '<font color="#ff0000">'.&mt('Error').':</font>';
1.27      matthew   658:     my $end       = '</body></html>';
                    659:     # Print header
1.4       www       660:     $r->print(<<ENDTHREEHEAD);
                    661: <html>
                    662: <head>
                    663: <title>The LearningOnline Network with CAPA</title>
                    664: </head>
                    665: ENDTHREEHEAD
1.40      www       666:     my $title;
                    667:     if (exists($ENV{'form.makeuser'})) {
                    668: 	$title='Set Privileges for New User';
                    669:     } else {
                    670:         $title='Modify User Privileges';
                    671:     }
                    672:     $r->print(&Apache::loncommon::bodytag($title));
1.27      matthew   673:     # Check Inputs
1.29      matthew   674:     if (! $ENV{'form.ccuname'} ) {
1.73      sakharuk  675: 	$r->print($error.&mt('No login name specified').'.'.$end);
1.27      matthew   676: 	return;
                    677:     }
1.29      matthew   678:     if (  $ENV{'form.ccuname'}  =~/\W/) {
1.73      sakharuk  679: 	$r->print($error.&mt('Invalid login name').'.  '.
                    680: 		  &mt('Only letters, numbers, and underscores are valid').'.'.
1.27      matthew   681: 		  $end);
                    682: 	return;
                    683:     }
1.29      matthew   684:     if (! $ENV{'form.ccdomain'}       ) {
1.73      sakharuk  685: 	$r->print($error.&mt('No domain specified').'.'.$end);
1.27      matthew   686: 	return;
                    687:     }
1.29      matthew   688:     if (  $ENV{'form.ccdomain'} =~/\W/) {
1.73      sakharuk  689: 	$r->print($error.&mt ('Invalid domain name').'.  '.
                    690: 		  &mt('Only letters, numbers, and underscores are valid').'.'.
1.27      matthew   691: 		  $end);
                    692: 	return;
                    693:     }
1.29      matthew   694:     if (! exists($ENV{'form.makeuser'})) {
                    695:         # Modifying an existing user, so check the validity of the name
                    696:         if ($uhome eq 'no_host') {
1.73      sakharuk  697:             $r->print($error.&mt('Unable to determine home server for ').
                    698:                       $ENV{'form.ccuname'}.&mt(' in domain ').
1.29      matthew   699:                       $ENV{'form.ccdomain'}.'.');
                    700:             return;
                    701:         }
                    702:     }
1.27      matthew   703:     # Determine authentication method and password for the user being modified
                    704:     my $amode='';
                    705:     my $genpwd='';
                    706:     if ($ENV{'form.login'} eq 'krb') {
1.41      albertel  707: 	$amode='krb';
                    708: 	$amode.=$ENV{'form.krbver'};
1.30      matthew   709: 	$genpwd=$ENV{'form.krbarg'};
1.27      matthew   710:     } elsif ($ENV{'form.login'} eq 'int') {
                    711: 	$amode='internal';
1.30      matthew   712: 	$genpwd=$ENV{'form.intarg'};
1.27      matthew   713:     } elsif ($ENV{'form.login'} eq 'fsys') {
                    714: 	$amode='unix';
1.30      matthew   715: 	$genpwd=$ENV{'form.fsysarg'};
1.27      matthew   716:     } elsif ($ENV{'form.login'} eq 'loc') {
                    717: 	$amode='localauth';
                    718: 	$genpwd=$ENV{'form.locarg'};
                    719: 	$genpwd=" " if (!$genpwd);
1.35      matthew   720:     } elsif (($ENV{'form.login'} eq 'nochange') ||
                    721:              ($ENV{'form.login'} eq ''        )) { 
1.34      matthew   722:         # There is no need to tell the user we did not change what they
                    723:         # did not ask us to change.
1.35      matthew   724:         # If they are creating a new user but have not specified login
                    725:         # information this will be caught below.
1.30      matthew   726:     } else {
1.73      sakharuk  727: 	    $r->print($error.&mt('Invalid login mode or password').$end);    
1.30      matthew   728: 	    return;
1.27      matthew   729:     }
                    730:     if ($ENV{'form.makeuser'}) {
                    731:         # Create a new user
1.73      sakharuk  732: 	my %lt=&Apache::lonlocal::texthash(
                    733:                     'cru'  => "Creating user",                    
                    734:                     'id'   => "in domain"
                    735: 					   );
1.27      matthew   736: 	$r->print(<<ENDNEWUSERHEAD);
1.73      sakharuk  737: <h3>$lt{'cru'} "$ENV{'form.ccuname'}" $lt{'id'} "$ENV{'form.ccdomain'}"</h3>
1.27      matthew   738: ENDNEWUSERHEAD
                    739:         # Check for the authentication mode and password
                    740:         if (! $amode || ! $genpwd) {
1.73      sakharuk  741: 	    $r->print($error.&mt('Invalid login mode or password').$end);    
1.27      matthew   742: 	    return;
1.18      albertel  743: 	}
1.29      matthew   744:         # Determine desired host
                    745:         my $desiredhost = $ENV{'form.hserver'};
                    746:         if (lc($desiredhost) eq 'default') {
                    747:             $desiredhost = undef;
                    748:         } else {
1.39      matthew   749:             my %home_servers = &Apache::loncommon::get_library_servers
1.32      matthew   750:                 ($ENV{'form.ccdomain'});  
1.29      matthew   751:             if (! exists($home_servers{$desiredhost})) {
1.73      sakharuk  752:                 $r->print($error.&mt('Invalid home server specified'));
1.29      matthew   753:                 return;
                    754:             }
                    755:         }
1.27      matthew   756: 	# Call modifyuser
                    757: 	my $result = &Apache::lonnet::modifyuser
1.29      matthew   758: 	    ($ENV{'form.ccdomain'},$ENV{'form.ccuname'},$ENV{'form.cstid'},
                    759:              $amode,$genpwd,$ENV{'form.cfirst'},
                    760:              $ENV{'form.cmiddle'},$ENV{'form.clast'},$ENV{'form.cgen'},
                    761:              undef,$desiredhost
1.27      matthew   762: 	     );
1.77    ! www       763: 	$r->print(&mt('Generating user').': '.$result);
1.29      matthew   764:         my $home = &Apache::lonnet::homeserver($ENV{'form.ccuname'},
                    765:                                                $ENV{'form.ccdomain'});
1.77    ! www       766:         $r->print('<br />'.&mt('Home server').': '.$home.' '.
1.29      matthew   767:                   $Apache::lonnet::libserv{$home});
1.35      matthew   768:     } elsif (($ENV{'form.login'} ne 'nochange') &&
                    769:              ($ENV{'form.login'} ne ''        )) {
1.27      matthew   770: 	# Modify user privileges
1.73      sakharuk  771:     my %lt=&Apache::lonlocal::texthash(
                    772:                     'usr'  => "User",                    
                    773:                     'id'   => "in domain"
                    774: 				       );
1.27      matthew   775: 	$r->print(<<ENDMODIFYUSERHEAD);
1.73      sakharuk  776: <h2>$lt{'usr'} "$ENV{'form.ccuname'}" $lt{'id'} "$ENV{'form.ccdomain'}"</h2>
1.27      matthew   777: ENDMODIFYUSERHEAD
                    778:         if (! $amode || ! $genpwd) {
                    779: 	    $r->print($error.'Invalid login mode or password'.$end);    
                    780: 	    return;
1.20      harris41  781: 	}
1.27      matthew   782: 	# Only allow authentification modification if the person has authority
1.36      matthew   783: 	if (&Apache::lonnet::allowed('mau',$ENV{'form.ccdomain'})) {
1.20      harris41  784: 	    $r->print('Modifying authentication: '.
1.31      matthew   785:                       &Apache::lonnet::modifyuserauth(
1.29      matthew   786: 		       $ENV{'form.ccdomain'},$ENV{'form.ccuname'},
1.21      harris41  787:                        $amode,$genpwd));
1.73      sakharuk  788:             $r->print('<br>'.&mt('Home server').': '.&Apache::lonnet::homeserver
1.29      matthew   789: 		  ($ENV{'form.ccuname'},$ENV{'form.ccdomain'}));
1.4       www       790: 	} else {
1.27      matthew   791: 	    # Okay, this is a non-fatal error.
1.73      sakharuk  792: 	    $r->print($error.&mt('You do not have the authority to modify this users authentification information').'.');    
1.27      matthew   793: 	}
1.28      matthew   794:     }
                    795:     ##
                    796:     if (! $ENV{'form.makeuser'} ) {
                    797:         # Check for need to change
                    798:         my %userenv = &Apache::lonnet::get
                    799:             ('environment',['firstname','middlename','lastname','generation'],
1.29      matthew   800:              $ENV{'form.ccdomain'},$ENV{'form.ccuname'});
1.28      matthew   801:         my ($tmp) = keys(%userenv);
                    802:         if ($tmp =~ /^(con_lost|error)/i) { 
                    803:             %userenv = ();
                    804:         }
                    805:         # Check to see if we need to change user information
                    806:         foreach ('firstname','middlename','lastname','generation') {
                    807:             # Strip leading and trailing whitespace
                    808:             $ENV{'form.c'.$_} =~ s/(\s+$|^\s+)//g; 
                    809:         }
1.29      matthew   810:         if (&Apache::lonnet::allowed('mau',$ENV{'form.ccdomain'}) && 
1.28      matthew   811:             ($ENV{'form.cfirstname'}  ne $userenv{'firstname'}  ||
                    812:              $ENV{'form.cmiddlename'} ne $userenv{'middlename'} ||
                    813:              $ENV{'form.clastname'}   ne $userenv{'lastname'}   ||
                    814:              $ENV{'form.cgeneration'} ne $userenv{'generation'} )) {
                    815:             # Make the change
                    816:             my %changeHash;
                    817:             $changeHash{'firstname'}  = $ENV{'form.cfirstname'};
                    818:             $changeHash{'middlename'} = $ENV{'form.cmiddlename'};
                    819:             $changeHash{'lastname'}   = $ENV{'form.clastname'};
                    820:             $changeHash{'generation'} = $ENV{'form.cgeneration'};
                    821:             my $putresult = &Apache::lonnet::put
                    822:                 ('environment',\%changeHash,
1.29      matthew   823:                  $ENV{'form.ccdomain'},$ENV{'form.ccuname'});
1.28      matthew   824:             if ($putresult eq 'ok') {
                    825:             # Tell the user we changed the name
1.73      sakharuk  826: 		my %lt=&Apache::lonlocal::texthash(
                    827:                              'uic'  => "User Information Changed",             
                    828:                              'frst' => "first",
                    829:                              'mddl' => "middle",
                    830:                              'lst'  => "last",
                    831: 			     'gen'  => "generation",
                    832:                              'prvs' => "Previous",
                    833:                              'chto' => "Changed To"
                    834: 						   );
1.28      matthew   835:                 $r->print(<<"END");
                    836: <table border="2">
1.73      sakharuk  837: <caption>$lt{'uic'}</caption>
1.28      matthew   838: <tr><th>&nbsp;</th>
1.73      sakharuk  839:     <th>$lt{'frst'}</th>
                    840:     <th>$lt{'mddl'}</th>
                    841:     <th>$lt{'lst'}</th>
                    842:     <th>$lt{'gen'}</th></tr>
                    843: <tr><td>$lt{'prvs'}</td>
1.28      matthew   844:     <td>$userenv{'firstname'}  </td>
                    845:     <td>$userenv{'middlename'} </td>
                    846:     <td>$userenv{'lastname'}   </td>
                    847:     <td>$userenv{'generation'} </td></tr>
1.73      sakharuk  848: <tr><td>$lt{'chto'}</td>
1.28      matthew   849:     <td>$ENV{'form.cfirstname'}  </td>
                    850:     <td>$ENV{'form.cmiddlename'} </td>
                    851:     <td>$ENV{'form.clastname'}   </td>
                    852:     <td>$ENV{'form.cgeneration'} </td></tr>
                    853: </table>
                    854: END
                    855:             } else { # error occurred
1.73      sakharuk  856:                 $r->print("<h2>".&mt('Unable to successfully change environment for')." ".
                    857:                       $ENV{'form.ccuname'}." ".&mt('in domain')." ".
1.29      matthew   858:                       $ENV{'form.ccdomain'}."</h2>");
1.28      matthew   859:             }
                    860:         }  else { # End of if ($ENV ... ) logic
                    861:             # They did not want to change the users name but we can
                    862:             # still tell them what the name is
1.73      sakharuk  863: 	    my %lt=&Apache::lonlocal::texthash(
                    864:                            'usr'  => "User",                    
                    865:                            'id'   => "in domain",
                    866:                            'gen'  => "Generation"
                    867: 					       );
1.28      matthew   868:                 $r->print(<<"END");
1.74      sakharuk  869: <h2>$lt{'usr'} "$ENV{'form.ccuname'}" $lt{'id'} "$ENV{'form.ccdomain'}"</h2>
1.28      matthew   870: <h4>$userenv{'firstname'} $userenv{'middlename'} $userenv{'lastname'} </h4>
1.73      sakharuk  871: <h4>$lt{'gen'}: $userenv{'generation'}</h4>
1.28      matthew   872: END
                    873:         }
1.4       www       874:     }
1.27      matthew   875:     ##
1.4       www       876:     my $now=time;
1.73      sakharuk  877:     $r->print('<h3>'.&mt('Modifying Roles').'</h3>');
1.24      matthew   878:     foreach (keys (%ENV)) {
1.27      matthew   879: 	next if (! $ENV{$_});
                    880: 	# Revoke roles
                    881: 	if ($_=~/^form\.rev/) {
1.64      www       882: 	    if ($_=~/^form\.rev\:([^\_]+)\_([^\_\.]+)$/) {
                    883: # Revoke standard role
1.73      sakharuk  884: 	        $r->print(&mt('Revoking').' '.$2.' in '.$1.': <b>'.
1.65      www       885:                      &Apache::lonnet::revokerole($ENV{'form.ccdomain'},
                    886:                      $ENV{'form.ccuname'},$1,$2).'</b><br>');
1.53      www       887: 		if ($2 eq 'st') {
                    888: 		    $1=~/^\/(\w+)\/(\w+)/;
                    889: 		    my $cid=$1.'_'.$2;
1.73      sakharuk  890: 		    $r->print(&mt('Drop from classlist').': <b>'.
1.53      www       891: 			 &Apache::lonnet::critical('put:'.
                    892:                              $ENV{'course.'.$cid.'.domain'}.':'.
                    893: 	                     $ENV{'course.'.$cid.'.num'}.':classlist:'.
                    894:                          &Apache::lonnet::escape($ENV{'form.ccuname'}.':'.
                    895:                              $ENV{'form.ccdomain'}).'='.
                    896:                          &Apache::lonnet::escape($now.':'),
1.56      www       897: 	                     $ENV{'course.'.$cid.'.home'}).'</b><br>');
1.53      www       898: 		}
                    899: 	    } 
1.64      www       900: 	    if ($_=~/^form\.rev\:([^\_]+)\_cr\.cr\/(\w+)\/(\w+)\/(\w+)$/) {
                    901: # Revoke custom role
1.73      sakharuk  902: 		$r->print(&mt('Revoking custom role').
                    903:                       ' '.$4.' by '.$3.'@'.$2.' in '.$1.': <b>'.
                    904:                       &Apache::lonnet::revokecustomrole($ENV{'form.ccdomain'},
1.65      www       905: 				  $ENV{'form.ccuname'},$1,$2,$3,$4).
1.64      www       906: 		'</b><br>');
                    907: 	    }
1.53      www       908: 	} elsif ($_=~/^form\.del/) {
                    909: 	    if ($_=~/^form\.del\:([^\_]+)\_([^\_]+)$/) {
1.73      sakharuk  910: 	        $r->print(&mt('Deleting').' '.$2.' in '.$1.': '.
1.53      www       911:                      &Apache::lonnet::assignrole($ENV{'form.ccdomain'},
                    912:                      $ENV{'form.ccuname'},$1,$2,$now,0,1).'<br>');
1.27      matthew   913: 		if ($2 eq 'st') {
                    914: 		    $1=~/^\/(\w+)\/(\w+)/;
                    915: 		    my $cid=$1.'_'.$2;
1.73      sakharuk  916: 		    $r->print(&mt('Drop from classlist').': <b>'.
1.27      matthew   917: 			 &Apache::lonnet::critical('put:'.
                    918:                              $ENV{'course.'.$cid.'.domain'}.':'.
                    919: 	                     $ENV{'course.'.$cid.'.num'}.':classlist:'.
1.29      matthew   920:                          &Apache::lonnet::escape($ENV{'form.ccuname'}.':'.
                    921:                              $ENV{'form.ccdomain'}).'='.
1.27      matthew   922:                          &Apache::lonnet::escape($now.':'),
1.56      www       923: 	                     $ENV{'course.'.$cid.'.home'}).'</b><br>');
1.27      matthew   924: 		}
                    925: 	    } 
                    926: 	} elsif ($_=~/^form\.act/) {
1.65      www       927: 	    if 
                    928: ($_=~/^form\.act\_([^\_]+)\_([^\_]+)\_cr_cr_([^\_]+)_(\w+)_([^\_]+)$/) {
                    929:                 # Activate a custom role
                    930: 		my $url='/'.$1.'/'.$2;
                    931: 		my $full=$1.'_'.$2.'_cr_cr_'.$3.'_'.$4.'_'.$5;
                    932: 		if ($ENV{'form.sec_'.$full}) {
                    933: 		    $url.='/'.$ENV{'form.sec_'.$full};
                    934: 		}
                    935: 
                    936: 		my $start = ( $ENV{'form.start_'.$full} ? 
                    937: 			      $ENV{'form.start_'.$full} : 
                    938: 			      $now );
                    939: 		my $end   = ( $ENV{'form.end_'.$full} ? 
                    940: 			      $ENV{'form.end_'.$full} :
                    941: 			      0 );
                    942: 
1.73      sakharuk  943:     $r->print(&mt('Assigning custom role').' "'.$5.'" by '.$4.'@'.$3.' in '.$url.
                    944:                          ($start?', '.&mt('starting').' '.localtime($start):'').
1.65      www       945:                          ($end?', ending '.localtime($end):'').': <b>'.
                    946: 	      &Apache::lonnet::assigncustomrole(
                    947: 	$ENV{'form.ccdomain'},$ENV{'form.ccuname'},$url,$3,$4,$5,$end,$start).
                    948: 	      '</b><br>');
                    949: 	    } elsif ($_=~/^form\.act\_([^\_]+)\_([^\_]+)\_([^\_]+)$/) {
1.27      matthew   950: 		# Activate roles for sections with 3 id numbers
                    951: 		# set start, end times, and the url for the class
1.55      www       952: 
                    953: 		my $start = ( $ENV{'form.start_'.$1.'_'.$2.'_'.$3} ? 
                    954: 			      $ENV{'form.start_'.$1.'_'.$2.'_'.$3} : 
1.27      matthew   955: 			      $now );
1.55      www       956: 		my $end   = ( $ENV{'form.end_'.$1.'_'.$2.'_'.$3} ? 
                    957: 			      $ENV{'form.end_'.$1.'_'.$2.'_'.$3} :
1.27      matthew   958: 			      0 );
                    959: 		my $url='/'.$1.'/'.$2;
                    960: 		if ($ENV{'form.sec_'.$1.'_'.$2.'_'.$3}) {
                    961: 		    $url.='/'.$ENV{'form.sec_'.$1.'_'.$2.'_'.$3};
                    962: 		}
                    963: 		# Assign the role and report it
1.73      sakharuk  964: 		$r->print(&mt('Assigning').' '.$3.' in '.$url.
                    965:                          ($start?', '.&mt('starting').' '.localtime($start):'').
                    966:                          ($end?', '.&mt('ending').' '.localtime($end):'').': <b>'.
1.27      matthew   967:                           &Apache::lonnet::assignrole(
1.29      matthew   968:                               $ENV{'form.ccdomain'},$ENV{'form.ccuname'},
1.27      matthew   969:                               $url,$3,$end,$start).
1.56      www       970: 			  '</b><br>');
1.27      matthew   971: 		# Handle students differently
                    972: 		if ($3 eq 'st') {
                    973: 		    $url=~/^\/(\w+)\/(\w+)/;
                    974: 		    my $cid=$1.'_'.$2;
1.73      sakharuk  975: 		    $r->print(&mt('Add to classlist').': <b>'.
1.27      matthew   976: 			      &Apache::lonnet::critical(
                    977: 				  'put:'.$ENV{'course.'.$cid.'.domain'}.':'.
                    978: 	                           $ENV{'course.'.$cid.'.num'}.':classlist:'.
                    979:                                    &Apache::lonnet::escape(
1.29      matthew   980:                                        $ENV{'form.ccuname'}.':'.
                    981:                                        $ENV{'form.ccdomain'} ).'='.
1.27      matthew   982:                                    &Apache::lonnet::escape($end.':'.$start),
                    983: 				       $ENV{'course.'.$cid.'.home'})
1.56      www       984: 			      .'</b><br>');
1.27      matthew   985: 		}
                    986: 	    } elsif ($_=~/^form\.act\_([^\_]+)\_([^\_]+)$/) {
                    987: 		# Activate roles for sections with two id numbers
                    988: 		# set start, end times, and the url for the class
                    989: 		my $start = ( $ENV{'form.start_'.$1.'_'.$2} ? 
                    990: 			      $ENV{'form.start_'.$1.'_'.$2} : 
                    991: 			      $now );
                    992: 		my $end   = ( $ENV{'form.end_'.$1.'_'.$2} ? 
                    993: 			      $ENV{'form.end_'.$1.'_'.$2} :
                    994: 			      0 );
                    995: 		my $url='/'.$1.'/';
                    996: 		# Assign the role and report it.
1.73      sakharuk  997: 		$r->print(&mt('Assigning').' '.$2.' in '.$url.': '.
                    998:                          ($start?', '.&mt('starting').' '.localtime($start):'').
                    999:                          ($end?', '.&mt('ending').' '.localtime($end):'').': <b>'.
1.27      matthew  1000:                           &Apache::lonnet::assignrole(
1.29      matthew  1001:                               $ENV{'form.ccdomain'},$ENV{'form.ccuname'},
1.27      matthew  1002:                               $url,$2,$end,$start)
1.56      www      1003: 			  .'</b><br>');
1.64      www      1004: 	    } else {
1.73      sakharuk 1005: 		$r->print('<p>'.&mt('ERROR').': '.&mt('Unknown command').' <tt>'.$_.'</tt></p><br>');
1.64      www      1006:             }
1.27      matthew  1007: 	} 
                   1008:     } # End of foreach (keys(%ENV))
1.75      www      1009: # Flush the course logs so reverse user roles immediately updated
                   1010:     &Apache::lonnet::flushcourselogs();
1.5       www      1011:     $r->print('</body></html>');
1.4       www      1012: }
                   1013: 
1.58      www      1014: # ========================================================== Custom Role Editor
                   1015: 
                   1016: sub custom_role_editor {
                   1017:     my $r=shift;
                   1018:     my $rolename=$ENV{'form.rolename'};
                   1019: 
1.59      www      1020:     if ($rolename eq 'make new role') {
                   1021: 	$rolename=$ENV{'form.newrolename'};
                   1022:     }
                   1023: 
1.63      www      1024:     $rolename=~s/[^A-Za-z0-9]//gs;
1.58      www      1025: 
                   1026:     unless ($rolename) {
                   1027: 	&print_username_entry_form($r);
                   1028:         return;
                   1029:     }
                   1030: 
                   1031:     $r->print(&Apache::loncommon::bodytag(
1.59      www      1032:                      'Create Users, Change User Privileges').'<h2>');
1.61      www      1033:     my $syspriv='';
                   1034:     my $dompriv='';
                   1035:     my $coursepriv='';
1.59      www      1036:     my ($rdummy,$roledef)=
                   1037: 			 &Apache::lonnet::get('roles',["rolesdef_$rolename"]);
1.60      www      1038: # ------------------------------------------------------- Does this role exist?
1.59      www      1039:     if (($rdummy ne 'con_lost') && ($roledef ne '')) {
1.73      sakharuk 1040: 	$r->print(&mt('Existing Role').' "');
1.61      www      1041: # ------------------------------------------------- Get current role privileges
                   1042: 	($syspriv,$dompriv,$coursepriv)=split(/\_/,$roledef);
1.59      www      1043:     } else {
1.73      sakharuk 1044: 	$r->print(&mt('New Role').' "');
1.59      www      1045: 	$roledef='';
                   1046:     }
                   1047:     $r->print($rolename.'"</h2>');
1.60      www      1048: # ------------------------------------------------------- What can be assigned?
                   1049:     my %full=();
                   1050:     my %courselevel=();
1.61      www      1051:     my %courselevelcurrent=();
1.60      www      1052:     foreach (split(/\:/,$Apache::lonnet::pr{'cr:c'})) {
                   1053: 	my ($priv,$restrict)=split(/\&/,$_);
                   1054:         unless ($restrict) { $restrict='F'; }
                   1055:         $courselevel{$priv}=$restrict;
1.61      www      1056:         if ($coursepriv=~/\:$priv/) {
                   1057: 	    $courselevelcurrent{$priv}=1;
                   1058: 	}
1.60      www      1059: 	$full{$priv}=1;
                   1060:     }
                   1061:     my %domainlevel=();
1.61      www      1062:     my %domainlevelcurrent=();
1.60      www      1063:     foreach (split(/\:/,$Apache::lonnet::pr{'cr:d'})) {
                   1064: 	my ($priv,$restrict)=split(/\&/,$_);
                   1065:         unless ($restrict) { $restrict='F'; }
                   1066:         $domainlevel{$priv}=$restrict;
1.61      www      1067:         if ($dompriv=~/\:$priv/) {
                   1068: 	    $domainlevelcurrent{$priv}=1;
                   1069: 	}
1.60      www      1070: 	$full{$priv}=1;
                   1071:     }
1.61      www      1072:     my %systemlevel=();
                   1073:     my %systemlevelcurrent=();
                   1074:     foreach (split(/\:/,$Apache::lonnet::pr{'cr:s'})) {
                   1075: 	my ($priv,$restrict)=split(/\&/,$_);
                   1076:         unless ($restrict) { $restrict='F'; }
                   1077:         $systemlevel{$priv}=$restrict;
                   1078:         if ($syspriv=~/\:$priv/) {
                   1079: 	    $systemlevelcurrent{$priv}=1;
                   1080: 	}
                   1081: 	$full{$priv}=1;
                   1082:     }
1.73      sakharuk 1083:     my %lt=&Apache::lonlocal::texthash(
                   1084: 		    'prv'  => "Privilege",
                   1085: 		    'crl'  => "Course Level",
                   1086:                     'dml'  => "Domain Level",
                   1087:                     'ssl'  => "System Level"
                   1088: 				       );
1.61      www      1089:     $r->print(<<ENDCCF);
                   1090: <form method="post">
                   1091: <input type="hidden" name="phase" value="set_custom_roles" />
                   1092: <input type="hidden" name="rolename" value="$rolename" />
                   1093: <table border="2">
1.73      sakharuk 1094: <tr><th>$lt{'prv'}</th><th>$lt{'crl'}</th><th>$lt{'dml'}</th>
                   1095: <th>$lt{'ssl'}</th></tr>
1.61      www      1096: ENDCCF
1.60      www      1097:     foreach (sort keys %full) {
                   1098: 	$r->print('<tr><td>'.&Apache::lonnet::plaintext($_).'</td><td>'.
1.61      www      1099:     ($courselevel{$_}?'<input type="checkbox" name="'.$_.':c" '.
                   1100:     ($courselevelcurrent{$_}?'checked="1"':'').' />':'&nbsp;').
                   1101:     '</td><td>'.
                   1102:     ($domainlevel{$_}?'<input type="checkbox" name="'.$_.':d" '.
                   1103:     ($domainlevelcurrent{$_}?'checked="1"':'').' />':'&nbsp;').
                   1104:     '</td><td>'.
                   1105:     ($systemlevel{$_}?'<input type="checkbox" name="'.$_.':s" '.
                   1106:     ($systemlevelcurrent{$_}?'checked="1"':'').' />':'&nbsp;').
                   1107:     '</td></tr>');
1.60      www      1108:     }
1.61      www      1109:     $r->print(
1.73      sakharuk 1110:    '<table><input type="submit" value="'.&mt('Define Role').'" /></form></body></html>');
1.61      www      1111: }
                   1112: 
                   1113: # ---------------------------------------------------------- Call to definerole
                   1114: sub set_custom_role {
                   1115:     my $r=shift;
                   1116: 
                   1117:     my $rolename=$ENV{'form.rolename'};
                   1118: 
1.63      www      1119:     $rolename=~s/[^A-Za-z0-9]//gs;
1.61      www      1120: 
                   1121:     unless ($rolename) {
                   1122: 	&print_username_entry_form($r);
                   1123:         return;
                   1124:     }
                   1125: 
                   1126:     $r->print(&Apache::loncommon::bodytag(
                   1127:                      'Create Users, Change User Privileges').'<h2>');
                   1128:     my ($rdummy,$roledef)=
                   1129: 			 &Apache::lonnet::get('roles',["rolesdef_$rolename"]);
                   1130: # ------------------------------------------------------- Does this role exist?
                   1131:     if (($rdummy ne 'con_lost') && ($roledef ne '')) {
1.73      sakharuk 1132: 	$r->print(&mt('Existing Role').' "');
1.61      www      1133:     } else {
1.73      sakharuk 1134: 	$r->print(&mt('New Role').' "');
1.61      www      1135: 	$roledef='';
                   1136:     }
                   1137:     $r->print($rolename.'"</h2>');
                   1138: # ------------------------------------------------------- What can be assigned?
                   1139:     my $sysrole='';
                   1140:     my $domrole='';
                   1141:     my $courole='';
                   1142: 
                   1143:     foreach (split(/\:/,$Apache::lonnet::pr{'cr:c'})) {
                   1144: 	my ($priv,$restrict)=split(/\&/,$_);
                   1145:         unless ($restrict) { $restrict=''; }
                   1146:         if ($ENV{'form.'.$priv.':c'}) {
                   1147: 	    $courole.=':'.$_;
                   1148: 	}
                   1149:     }
                   1150: 
                   1151:     foreach (split(/\:/,$Apache::lonnet::pr{'cr:d'})) {
                   1152: 	my ($priv,$restrict)=split(/\&/,$_);
                   1153:         unless ($restrict) { $restrict=''; }
                   1154:         if ($ENV{'form.'.$priv.':d'}) {
                   1155: 	    $domrole.=':'.$_;
                   1156: 	}
                   1157:     }
                   1158: 
                   1159:     foreach (split(/\:/,$Apache::lonnet::pr{'cr:s'})) {
                   1160: 	my ($priv,$restrict)=split(/\&/,$_);
                   1161:         unless ($restrict) { $restrict=''; }
                   1162:         if ($ENV{'form.'.$priv.':s'}) {
                   1163: 	    $sysrole.=':'.$_;
                   1164: 	}
                   1165:     }
1.63      www      1166:     $r->print('<br />Defining Role: '.
1.61      www      1167: 	   &Apache::lonnet::definerole($rolename,$sysrole,$domrole,$courole));
1.63      www      1168:     if ($ENV{'request.course.id'}) {
                   1169:         my $url='/'.$ENV{'request.course.id'};
                   1170:         $url=~s/\_/\//g;
1.73      sakharuk 1171: 	$r->print('<br />'.&mt('Assigning Role to Self').': '.
1.63      www      1172: 	      &Apache::lonnet::assigncustomrole($ENV{'user.domain'},
                   1173: 						$ENV{'user.name'},
                   1174: 						$url,
                   1175: 						$ENV{'user.domain'},
                   1176: 						$ENV{'user.name'},
                   1177: 						$rolename));
                   1178:     }
1.61      www      1179:     $r->print('</body></html>');
1.58      www      1180: }
                   1181: 
1.2       www      1182: # ================================================================ Main Handler
                   1183: sub handler {
                   1184:     my $r = shift;
                   1185: 
                   1186:     if ($r->header_only) {
1.68      www      1187:        &Apache::loncommon::content_type($r,'text/html');
1.2       www      1188:        $r->send_http_header;
                   1189:        return OK;
                   1190:     }
                   1191: 
                   1192:     if ((&Apache::lonnet::allowed('cta',$ENV{'request.course.id'})) ||
                   1193:         (&Apache::lonnet::allowed('cin',$ENV{'request.course.id'})) || 
                   1194:         (&Apache::lonnet::allowed('ccr',$ENV{'request.course.id'})) || 
                   1195:         (&Apache::lonnet::allowed('cep',$ENV{'request.course.id'})) ||
1.42      matthew  1196:         (&Apache::lonnet::allowed('cca',$ENV{'request.role.domain'})) ||
                   1197:         (&Apache::lonnet::allowed('mau',$ENV{'request.role.domain'}))) {
1.68      www      1198:        &Apache::loncommon::content_type($r,'text/html');
1.2       www      1199:        $r->send_http_header;
                   1200:        unless ($ENV{'form.phase'}) {
1.42      matthew  1201: 	   &print_username_entry_form($r);
1.2       www      1202:        }
1.42      matthew  1203:        if ($ENV{'form.phase'} eq 'get_user_info') {
                   1204:            &print_user_modification_page($r);
                   1205:        } elsif ($ENV{'form.phase'} eq 'update_user_data') {
                   1206:            &update_user_data($r);
1.58      www      1207:        } elsif ($ENV{'form.phase'} eq 'selected_custom_edit') {
                   1208:            &custom_role_editor($r);
1.61      www      1209:        } elsif ($ENV{'form.phase'} eq 'set_custom_roles') {
                   1210: 	   &set_custom_role($r);
1.2       www      1211:        }
1.1       www      1212:    } else {
                   1213:       $ENV{'user.error.msg'}=
1.9       albertel 1214:         "/adm/createuser:mau:0:0:Cannot modify user data";
1.1       www      1215:       return HTTP_NOT_ACCEPTABLE; 
                   1216:    }
                   1217:    return OK;
                   1218: } 
1.26      matthew  1219: 
1.27      matthew  1220: #-------------------------------------------------- functions for &phase_two
1.26      matthew  1221: sub course_level_table {
                   1222:     my %inccourses = @_;
                   1223:     my $table = '';
1.62      www      1224: # Custom Roles?
                   1225: 
                   1226:     my %customroles=&my_custom_roles();
                   1227: 
1.26      matthew  1228:     foreach (sort( keys(%inccourses))) {
                   1229: 	my $thiscourse=$_;
                   1230: 	my $protectedcourse=$_;
                   1231: 	$thiscourse=~s:_:/:g;
                   1232: 	my %coursedata=&Apache::lonnet::coursedescription($thiscourse);
                   1233: 	my $area=$coursedata{'description'};
1.72      sakharuk 1234: 	if (!defined($area)) { $area=&mt('Unavailable course').': '.$_; }
1.26      matthew  1235: 	my $bgcol=$thiscourse;
1.62      www      1236: 	$bgcol=~s/[^7-9a-e]//g;
                   1237: 	$bgcol=substr($bgcol.$bgcol.$bgcol.'ffffff',2,6);
1.26      matthew  1238: 	foreach  ('st','ta','ep','ad','in','cc') {
                   1239: 	    if (&Apache::lonnet::allowed('c'.$_,$thiscourse)) {
                   1240: 		my $plrole=&Apache::lonnet::plaintext($_);
                   1241: 		$table .= <<ENDEXTENT;
                   1242: <tr bgcolor="#$bgcol">
                   1243: <td><input type="checkbox" name="act_$protectedcourse\_$_"></td>
                   1244: <td>$plrole</td>
                   1245: <td>$area</td>
                   1246: ENDEXTENT
                   1247: 	        if ($_ ne 'cc') {
                   1248: 		    $table .= <<ENDSECTION;
                   1249: <td><input type="text" size="5" name="sec_$protectedcourse\_$_"></td>
                   1250: ENDSECTION
                   1251:                 } else { 
                   1252: 		    $table .= <<ENDSECTION;
                   1253: <td>&nbsp</td> 
                   1254: ENDSECTION
                   1255:                 }
1.73      sakharuk 1256: 		my %lt=&Apache::lonlocal::texthash(
                   1257:                                'ssd'  => "Set Start Date",
                   1258:                                'sed'  => "Set End Date"
                   1259: 						   );
1.26      matthew  1260: 		$table .= <<ENDTIMEENTRY;
                   1261: <td><input type=hidden name="start_$protectedcourse\_$_" value=''>
                   1262: <a href=
1.73      sakharuk 1263: "javascript:pjump('date_start','Start Date $plrole',document.cu.start_$protectedcourse\_$_.value,'start_$protectedcourse\_$_','cu.pres','dateset')">$lt{'ssd'}</a></td>
1.26      matthew  1264: <td><input type=hidden name="end_$protectedcourse\_$_" value=''>
                   1265: <a href=
1.73      sakharuk 1266: "javascript:pjump('date_end','End Date $plrole',document.cu.end_$protectedcourse\_$_.value,'end_$protectedcourse\_$_','cu.pres','dateset')">$lt{'sed'}</a></td>
1.26      matthew  1267: ENDTIMEENTRY
                   1268:                 $table.= "</tr>\n";
                   1269:             }
                   1270:         }
1.62      www      1271:         foreach (sort keys %customroles) {
1.65      www      1272: 	    if (&Apache::lonnet::allowed('ccr',$thiscourse)) {
                   1273: 		my $plrole=$_;
                   1274:                 my $customrole=$protectedcourse.'_cr_cr_'.$ENV{'user.domain'}.
                   1275: 		    '_'.$ENV{'user.name'}.'_'.$plrole;
1.73      sakharuk 1276: 		my %lt=&Apache::lonlocal::texthash(
                   1277:                                'ssd'  => "Set Start Date",
                   1278:                                'sed'  => "Set End Date"
                   1279: 						   );
1.65      www      1280: 		$table .= <<ENDENTRY;
1.62      www      1281: <tr bgcolor="#$bgcol">
1.65      www      1282: <td><input type="checkbox" name="act_$customrole"></td>
1.62      www      1283: <td>$plrole</td>
                   1284: <td>$area</td>
1.65      www      1285: <td><input type="text" size="5" name="sec_$customrole"></td>
                   1286: <td><input type=hidden name="start_$customrole" value=''>
1.62      www      1287: <a href=
1.73      sakharuk 1288: "javascript:pjump('date_start','Start Date $plrole',document.cu.start_$customrole.value,'start_$customrole','cu.pres','dateset')">$lt{'ssd'}</a></td>
1.65      www      1289: <td><input type=hidden name="end_$customrole" value=''>
1.62      www      1290: <a href=
1.73      sakharuk 1291: "javascript:pjump('date_end','End Date $plrole',document.cu.end_$customrole.value,'end_$customrole','cu.pres','dateset')">$lt{'sed'}</a></td></tr>
1.62      www      1292: ENDENTRY
1.65      www      1293:            }
1.62      www      1294: 	}
1.26      matthew  1295:     }
                   1296:     return '' if ($table eq ''); # return nothing if there is nothing 
                   1297:                                  # in the table
1.73      sakharuk 1298:     my %lt=&Apache::lonlocal::texthash(
                   1299: 		    'crl'  => "Course Level",
                   1300:                     'act'  => "Activate",
                   1301:                     'rol'  => "Role",
                   1302:                     'ext'  => "Extent",
                   1303:                     'grs'  => "Group/Section",
                   1304:                     'sta'  => "Start",
                   1305:                     'end'  => "End"
                   1306: 				       );
1.26      matthew  1307:     my $result = <<ENDTABLE;
1.73      sakharuk 1308: <h4>$lt{'crl'}</h4>
                   1309: <table border=2><tr><th>$lt{'act'}</th><th>$lt{'rol'}</th><th>$lt{'ext'}</th>
                   1310: <th>$lt{'grs'}</th><th>$lt{'sta'}</th><th>$lt{'end'}</th></tr>
1.26      matthew  1311: $table
                   1312: </table>
                   1313: ENDTABLE
                   1314:     return $result;
                   1315: }
1.27      matthew  1316: #---------------------------------------------- end functions for &phase_two
1.29      matthew  1317: 
                   1318: #--------------------------------- functions for &phase_two and &phase_three
                   1319: 
                   1320: #--------------------------end of functions for &phase_two and &phase_three
1.1       www      1321: 
                   1322: 1;
                   1323: __END__
1.2       www      1324: 
                   1325: 

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