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

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

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