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

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

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