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

1.20      harris41    1: # The LearningOnline Network with CAPA
1.1       www         2: # Create a user
                      3: #
1.73    ! sakharuk    4: # $Id: loncreateuser.pm,v 1.72 2003/12/10 20:38:09 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>
                    284: ${'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>
                    591: <table border=2><tr><th>${'act'}</th><th>${'rol'}</th><th>${'ext'}</th>
                    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.73    ! sakharuk  865: <h2>$lt{'usr'} "$ENV{'form.ccuname'}" ${'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.5       www      1005:     $r->print('</body></html>');
1.4       www      1006: }
                   1007: 
1.58      www      1008: # ========================================================== Custom Role Editor
                   1009: 
                   1010: sub custom_role_editor {
                   1011:     my $r=shift;
                   1012:     my $rolename=$ENV{'form.rolename'};
                   1013: 
1.59      www      1014:     if ($rolename eq 'make new role') {
                   1015: 	$rolename=$ENV{'form.newrolename'};
                   1016:     }
                   1017: 
1.63      www      1018:     $rolename=~s/[^A-Za-z0-9]//gs;
1.58      www      1019: 
                   1020:     unless ($rolename) {
                   1021: 	&print_username_entry_form($r);
                   1022:         return;
                   1023:     }
                   1024: 
                   1025:     $r->print(&Apache::loncommon::bodytag(
1.59      www      1026:                      'Create Users, Change User Privileges').'<h2>');
1.61      www      1027:     my $syspriv='';
                   1028:     my $dompriv='';
                   1029:     my $coursepriv='';
1.59      www      1030:     my ($rdummy,$roledef)=
                   1031: 			 &Apache::lonnet::get('roles',["rolesdef_$rolename"]);
1.60      www      1032: # ------------------------------------------------------- Does this role exist?
1.59      www      1033:     if (($rdummy ne 'con_lost') && ($roledef ne '')) {
1.73    ! sakharuk 1034: 	$r->print(&mt('Existing Role').' "');
1.61      www      1035: # ------------------------------------------------- Get current role privileges
                   1036: 	($syspriv,$dompriv,$coursepriv)=split(/\_/,$roledef);
1.59      www      1037:     } else {
1.73    ! sakharuk 1038: 	$r->print(&mt('New Role').' "');
1.59      www      1039: 	$roledef='';
                   1040:     }
                   1041:     $r->print($rolename.'"</h2>');
1.60      www      1042: # ------------------------------------------------------- What can be assigned?
                   1043:     my %full=();
                   1044:     my %courselevel=();
1.61      www      1045:     my %courselevelcurrent=();
1.60      www      1046:     foreach (split(/\:/,$Apache::lonnet::pr{'cr:c'})) {
                   1047: 	my ($priv,$restrict)=split(/\&/,$_);
                   1048:         unless ($restrict) { $restrict='F'; }
                   1049:         $courselevel{$priv}=$restrict;
1.61      www      1050:         if ($coursepriv=~/\:$priv/) {
                   1051: 	    $courselevelcurrent{$priv}=1;
                   1052: 	}
1.60      www      1053: 	$full{$priv}=1;
                   1054:     }
                   1055:     my %domainlevel=();
1.61      www      1056:     my %domainlevelcurrent=();
1.60      www      1057:     foreach (split(/\:/,$Apache::lonnet::pr{'cr:d'})) {
                   1058: 	my ($priv,$restrict)=split(/\&/,$_);
                   1059:         unless ($restrict) { $restrict='F'; }
                   1060:         $domainlevel{$priv}=$restrict;
1.61      www      1061:         if ($dompriv=~/\:$priv/) {
                   1062: 	    $domainlevelcurrent{$priv}=1;
                   1063: 	}
1.60      www      1064: 	$full{$priv}=1;
                   1065:     }
1.61      www      1066:     my %systemlevel=();
                   1067:     my %systemlevelcurrent=();
                   1068:     foreach (split(/\:/,$Apache::lonnet::pr{'cr:s'})) {
                   1069: 	my ($priv,$restrict)=split(/\&/,$_);
                   1070:         unless ($restrict) { $restrict='F'; }
                   1071:         $systemlevel{$priv}=$restrict;
                   1072:         if ($syspriv=~/\:$priv/) {
                   1073: 	    $systemlevelcurrent{$priv}=1;
                   1074: 	}
                   1075: 	$full{$priv}=1;
                   1076:     }
1.73    ! sakharuk 1077:     my %lt=&Apache::lonlocal::texthash(
        !          1078: 		    'prv'  => "Privilege",
        !          1079: 		    'crl'  => "Course Level",
        !          1080:                     'dml'  => "Domain Level",
        !          1081:                     'ssl'  => "System Level"
        !          1082: 				       );
1.61      www      1083:     $r->print(<<ENDCCF);
                   1084: <form method="post">
                   1085: <input type="hidden" name="phase" value="set_custom_roles" />
                   1086: <input type="hidden" name="rolename" value="$rolename" />
                   1087: <table border="2">
1.73    ! sakharuk 1088: <tr><th>$lt{'prv'}</th><th>$lt{'crl'}</th><th>$lt{'dml'}</th>
        !          1089: <th>$lt{'ssl'}</th></tr>
1.61      www      1090: ENDCCF
1.60      www      1091:     foreach (sort keys %full) {
                   1092: 	$r->print('<tr><td>'.&Apache::lonnet::plaintext($_).'</td><td>'.
1.61      www      1093:     ($courselevel{$_}?'<input type="checkbox" name="'.$_.':c" '.
                   1094:     ($courselevelcurrent{$_}?'checked="1"':'').' />':'&nbsp;').
                   1095:     '</td><td>'.
                   1096:     ($domainlevel{$_}?'<input type="checkbox" name="'.$_.':d" '.
                   1097:     ($domainlevelcurrent{$_}?'checked="1"':'').' />':'&nbsp;').
                   1098:     '</td><td>'.
                   1099:     ($systemlevel{$_}?'<input type="checkbox" name="'.$_.':s" '.
                   1100:     ($systemlevelcurrent{$_}?'checked="1"':'').' />':'&nbsp;').
                   1101:     '</td></tr>');
1.60      www      1102:     }
1.61      www      1103:     $r->print(
1.73    ! sakharuk 1104:    '<table><input type="submit" value="'.&mt('Define Role').'" /></form></body></html>');
1.61      www      1105: }
                   1106: 
                   1107: # ---------------------------------------------------------- Call to definerole
                   1108: sub set_custom_role {
                   1109:     my $r=shift;
                   1110: 
                   1111:     my $rolename=$ENV{'form.rolename'};
                   1112: 
1.63      www      1113:     $rolename=~s/[^A-Za-z0-9]//gs;
1.61      www      1114: 
                   1115:     unless ($rolename) {
                   1116: 	&print_username_entry_form($r);
                   1117:         return;
                   1118:     }
                   1119: 
                   1120:     $r->print(&Apache::loncommon::bodytag(
                   1121:                      'Create Users, Change User Privileges').'<h2>');
                   1122:     my ($rdummy,$roledef)=
                   1123: 			 &Apache::lonnet::get('roles',["rolesdef_$rolename"]);
                   1124: # ------------------------------------------------------- Does this role exist?
                   1125:     if (($rdummy ne 'con_lost') && ($roledef ne '')) {
1.73    ! sakharuk 1126: 	$r->print(&mt('Existing Role').' "');
1.61      www      1127:     } else {
1.73    ! sakharuk 1128: 	$r->print(&mt('New Role').' "');
1.61      www      1129: 	$roledef='';
                   1130:     }
                   1131:     $r->print($rolename.'"</h2>');
                   1132: # ------------------------------------------------------- What can be assigned?
                   1133:     my $sysrole='';
                   1134:     my $domrole='';
                   1135:     my $courole='';
                   1136: 
                   1137:     foreach (split(/\:/,$Apache::lonnet::pr{'cr:c'})) {
                   1138: 	my ($priv,$restrict)=split(/\&/,$_);
                   1139:         unless ($restrict) { $restrict=''; }
                   1140:         if ($ENV{'form.'.$priv.':c'}) {
                   1141: 	    $courole.=':'.$_;
                   1142: 	}
                   1143:     }
                   1144: 
                   1145:     foreach (split(/\:/,$Apache::lonnet::pr{'cr:d'})) {
                   1146: 	my ($priv,$restrict)=split(/\&/,$_);
                   1147:         unless ($restrict) { $restrict=''; }
                   1148:         if ($ENV{'form.'.$priv.':d'}) {
                   1149: 	    $domrole.=':'.$_;
                   1150: 	}
                   1151:     }
                   1152: 
                   1153:     foreach (split(/\:/,$Apache::lonnet::pr{'cr:s'})) {
                   1154: 	my ($priv,$restrict)=split(/\&/,$_);
                   1155:         unless ($restrict) { $restrict=''; }
                   1156:         if ($ENV{'form.'.$priv.':s'}) {
                   1157: 	    $sysrole.=':'.$_;
                   1158: 	}
                   1159:     }
1.63      www      1160:     $r->print('<br />Defining Role: '.
1.61      www      1161: 	   &Apache::lonnet::definerole($rolename,$sysrole,$domrole,$courole));
1.63      www      1162:     if ($ENV{'request.course.id'}) {
                   1163:         my $url='/'.$ENV{'request.course.id'};
                   1164:         $url=~s/\_/\//g;
1.73    ! sakharuk 1165: 	$r->print('<br />'.&mt('Assigning Role to Self').': '.
1.63      www      1166: 	      &Apache::lonnet::assigncustomrole($ENV{'user.domain'},
                   1167: 						$ENV{'user.name'},
                   1168: 						$url,
                   1169: 						$ENV{'user.domain'},
                   1170: 						$ENV{'user.name'},
                   1171: 						$rolename));
                   1172:     }
1.61      www      1173:     $r->print('</body></html>');
1.58      www      1174: }
                   1175: 
1.2       www      1176: # ================================================================ Main Handler
                   1177: sub handler {
                   1178:     my $r = shift;
                   1179: 
                   1180:     if ($r->header_only) {
1.68      www      1181:        &Apache::loncommon::content_type($r,'text/html');
1.2       www      1182:        $r->send_http_header;
                   1183:        return OK;
                   1184:     }
                   1185: 
                   1186:     if ((&Apache::lonnet::allowed('cta',$ENV{'request.course.id'})) ||
                   1187:         (&Apache::lonnet::allowed('cin',$ENV{'request.course.id'})) || 
                   1188:         (&Apache::lonnet::allowed('ccr',$ENV{'request.course.id'})) || 
                   1189:         (&Apache::lonnet::allowed('cep',$ENV{'request.course.id'})) ||
1.42      matthew  1190:         (&Apache::lonnet::allowed('cca',$ENV{'request.role.domain'})) ||
                   1191:         (&Apache::lonnet::allowed('mau',$ENV{'request.role.domain'}))) {
1.68      www      1192:        &Apache::loncommon::content_type($r,'text/html');
1.2       www      1193:        $r->send_http_header;
                   1194:        unless ($ENV{'form.phase'}) {
1.42      matthew  1195: 	   &print_username_entry_form($r);
1.2       www      1196:        }
1.42      matthew  1197:        if ($ENV{'form.phase'} eq 'get_user_info') {
                   1198:            &print_user_modification_page($r);
                   1199:        } elsif ($ENV{'form.phase'} eq 'update_user_data') {
                   1200:            &update_user_data($r);
1.58      www      1201:        } elsif ($ENV{'form.phase'} eq 'selected_custom_edit') {
                   1202:            &custom_role_editor($r);
1.61      www      1203:        } elsif ($ENV{'form.phase'} eq 'set_custom_roles') {
                   1204: 	   &set_custom_role($r);
1.2       www      1205:        }
1.1       www      1206:    } else {
                   1207:       $ENV{'user.error.msg'}=
1.9       albertel 1208:         "/adm/createuser:mau:0:0:Cannot modify user data";
1.1       www      1209:       return HTTP_NOT_ACCEPTABLE; 
                   1210:    }
                   1211:    return OK;
                   1212: } 
1.26      matthew  1213: 
1.27      matthew  1214: #-------------------------------------------------- functions for &phase_two
1.26      matthew  1215: sub course_level_table {
                   1216:     my %inccourses = @_;
                   1217:     my $table = '';
1.62      www      1218: # Custom Roles?
                   1219: 
                   1220:     my %customroles=&my_custom_roles();
                   1221: 
1.26      matthew  1222:     foreach (sort( keys(%inccourses))) {
                   1223: 	my $thiscourse=$_;
                   1224: 	my $protectedcourse=$_;
                   1225: 	$thiscourse=~s:_:/:g;
                   1226: 	my %coursedata=&Apache::lonnet::coursedescription($thiscourse);
                   1227: 	my $area=$coursedata{'description'};
1.72      sakharuk 1228: 	if (!defined($area)) { $area=&mt('Unavailable course').': '.$_; }
1.26      matthew  1229: 	my $bgcol=$thiscourse;
1.62      www      1230: 	$bgcol=~s/[^7-9a-e]//g;
                   1231: 	$bgcol=substr($bgcol.$bgcol.$bgcol.'ffffff',2,6);
1.26      matthew  1232: 	foreach  ('st','ta','ep','ad','in','cc') {
                   1233: 	    if (&Apache::lonnet::allowed('c'.$_,$thiscourse)) {
                   1234: 		my $plrole=&Apache::lonnet::plaintext($_);
                   1235: 		$table .= <<ENDEXTENT;
                   1236: <tr bgcolor="#$bgcol">
                   1237: <td><input type="checkbox" name="act_$protectedcourse\_$_"></td>
                   1238: <td>$plrole</td>
                   1239: <td>$area</td>
                   1240: ENDEXTENT
                   1241: 	        if ($_ ne 'cc') {
                   1242: 		    $table .= <<ENDSECTION;
                   1243: <td><input type="text" size="5" name="sec_$protectedcourse\_$_"></td>
                   1244: ENDSECTION
                   1245:                 } else { 
                   1246: 		    $table .= <<ENDSECTION;
                   1247: <td>&nbsp</td> 
                   1248: ENDSECTION
                   1249:                 }
1.73    ! sakharuk 1250: 		my %lt=&Apache::lonlocal::texthash(
        !          1251:                                'ssd'  => "Set Start Date",
        !          1252:                                'sed'  => "Set End Date"
        !          1253: 						   );
1.26      matthew  1254: 		$table .= <<ENDTIMEENTRY;
                   1255: <td><input type=hidden name="start_$protectedcourse\_$_" value=''>
                   1256: <a href=
1.73    ! sakharuk 1257: "javascript:pjump('date_start','Start Date $plrole',document.cu.start_$protectedcourse\_$_.value,'start_$protectedcourse\_$_','cu.pres','dateset')">$lt{'ssd'}</a></td>
1.26      matthew  1258: <td><input type=hidden name="end_$protectedcourse\_$_" value=''>
                   1259: <a href=
1.73    ! sakharuk 1260: "javascript:pjump('date_end','End Date $plrole',document.cu.end_$protectedcourse\_$_.value,'end_$protectedcourse\_$_','cu.pres','dateset')">$lt{'sed'}</a></td>
1.26      matthew  1261: ENDTIMEENTRY
                   1262:                 $table.= "</tr>\n";
                   1263:             }
                   1264:         }
1.62      www      1265:         foreach (sort keys %customroles) {
1.65      www      1266: 	    if (&Apache::lonnet::allowed('ccr',$thiscourse)) {
                   1267: 		my $plrole=$_;
                   1268:                 my $customrole=$protectedcourse.'_cr_cr_'.$ENV{'user.domain'}.
                   1269: 		    '_'.$ENV{'user.name'}.'_'.$plrole;
1.73    ! sakharuk 1270: 		my %lt=&Apache::lonlocal::texthash(
        !          1271:                                'ssd'  => "Set Start Date",
        !          1272:                                'sed'  => "Set End Date"
        !          1273: 						   );
1.65      www      1274: 		$table .= <<ENDENTRY;
1.62      www      1275: <tr bgcolor="#$bgcol">
1.65      www      1276: <td><input type="checkbox" name="act_$customrole"></td>
1.62      www      1277: <td>$plrole</td>
                   1278: <td>$area</td>
1.65      www      1279: <td><input type="text" size="5" name="sec_$customrole"></td>
                   1280: <td><input type=hidden name="start_$customrole" value=''>
1.62      www      1281: <a href=
1.73    ! sakharuk 1282: "javascript:pjump('date_start','Start Date $plrole',document.cu.start_$customrole.value,'start_$customrole','cu.pres','dateset')">$lt{'ssd'}</a></td>
1.65      www      1283: <td><input type=hidden name="end_$customrole" value=''>
1.62      www      1284: <a href=
1.73    ! sakharuk 1285: "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      1286: ENDENTRY
1.65      www      1287:            }
1.62      www      1288: 	}
1.26      matthew  1289:     }
                   1290:     return '' if ($table eq ''); # return nothing if there is nothing 
                   1291:                                  # in the table
1.73    ! sakharuk 1292:     my %lt=&Apache::lonlocal::texthash(
        !          1293: 		    'crl'  => "Course Level",
        !          1294:                     'act'  => "Activate",
        !          1295:                     'rol'  => "Role",
        !          1296:                     'ext'  => "Extent",
        !          1297:                     'grs'  => "Group/Section",
        !          1298:                     'sta'  => "Start",
        !          1299:                     'end'  => "End"
        !          1300: 				       );
1.26      matthew  1301:     my $result = <<ENDTABLE;
1.73    ! sakharuk 1302: <h4>$lt{'crl'}</h4>
        !          1303: <table border=2><tr><th>$lt{'act'}</th><th>$lt{'rol'}</th><th>$lt{'ext'}</th>
        !          1304: <th>$lt{'grs'}</th><th>$lt{'sta'}</th><th>$lt{'end'}</th></tr>
1.26      matthew  1305: $table
                   1306: </table>
                   1307: ENDTABLE
                   1308:     return $result;
                   1309: }
1.27      matthew  1310: #---------------------------------------------- end functions for &phase_two
1.29      matthew  1311: 
                   1312: #--------------------------------- functions for &phase_two and &phase_three
                   1313: 
                   1314: #--------------------------end of functions for &phase_two and &phase_three
1.1       www      1315: 
                   1316: 1;
                   1317: __END__
1.2       www      1318: 
                   1319: 

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