Annotation of loncom/auth/lonroles.pm, revision 1.190

1.1       harris41    1: # The LearningOnline Network with CAPA
                      2: # User Roles Screen
1.31      www         3: #
1.190   ! www         4: # $Id: lonroles.pm,v 1.189 2008/05/14 19:18:37 www Exp $
1.31      www         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.32      harris41   28: ###
1.22      harris41   29: 
1.1       harris41   30: package Apache::lonroles;
                     31: 
                     32: use strict;
1.118     albertel   33: use Apache::lonnet;
1.7       www        34: use Apache::lonuserstate();
1.1       harris41   35: use Apache::Constants qw(:common);
1.2       www        36: use Apache::File();
1.26      www        37: use Apache::lonmenu;
1.29      albertel   38: use Apache::loncommon;
1.104     raeburn    39: use Apache::lonhtmlcommon;
1.57      www        40: use Apache::lonannounce;
1.72      www        41: use Apache::lonlocal;
1.151     www        42: use Apache::lonpageflip();
1.167     albertel   43: use Apache::lonnavdisplay();
1.120     albertel   44: use GDBM_File;
1.170     albertel   45: use LONCAPA qw(:DEFAULT :match);
1.149     www        46:  
1.1       harris41   47: 
1.62      matthew    48: sub redirect_user {
1.95      albertel   49:     my ($r,$title,$url,$msg,$launch_nav) = @_;
1.62      matthew    50:     $msg = $title if (! defined($msg));
1.73      www        51:     &Apache::loncommon::content_type($r,'text/html');
1.62      matthew    52:     &Apache::loncommon::no_cache($r);
                     53:     $r->send_http_header;
                     54:     my $swinfo=&Apache::lonmenu::rawconfig();
1.96      albertel   55:     my $navwindow;
1.95      albertel   56:     if ($launch_nav eq 'on') {
1.166     albertel   57: 	$navwindow.=&Apache::lonnavdisplay::launch_win('now',undef,undef,
                     58: 						       ($url =~ m-^/adm/whatsnew-));
1.96      albertel   59:     } else {
                     60: 	$navwindow.=&Apache::lonnavmaps::close();
1.95      albertel   61:     }
1.147     albertel   62:     my $start_page = &Apache::loncommon::start_page('Switching Role',undef,
                     63: 						    {'redirect' => [1,$url],});
                     64:     my $end_page   = &Apache::loncommon::end_page();
                     65: 
1.92      www        66: # Note to style police: 
                     67: # This must only replace the spaces, nothing else, or it bombs elsewhere.
                     68:     $url=~s/ /\%20/g;
1.93      albertel   69:     $r->print(<<ENDREDIR);
1.147     albertel   70: $start_page
1.96      albertel   71: <script type="text/javascript">
1.62      matthew    72: $swinfo
                     73: </script>
1.96      albertel   74: $navwindow
1.62      matthew    75: <h1>$msg</h1>
1.147     albertel   76: $end_page
1.62      matthew    77: ENDREDIR
                     78:     return;
                     79: }
                     80: 
1.150     www        81: sub error_page {
                     82:     my ($r,$error,$dest)=@_;
                     83:     &Apache::loncommon::content_type($r,'text/html');
                     84:     &Apache::loncommon::no_cache($r);
                     85:     $r->send_http_header;
                     86:     return OK if $r->header_only;
                     87:     $r->print(&Apache::loncommon::start_page('Problems during Course Initialization').
                     88: 	      '<script type="text/javascript">'.
                     89: 	      &Apache::lonmenu::rawconfig().'</script>'.
                     90: 	      '<p>'.&mt('The following problems occurred:').
                     91: 	      $error.
1.156     albertel   92: 	      '</p><br /><a href="'.$dest.'">'.&mt('Continue').'</a>'.
1.150     www        93: 	      &Apache::loncommon::end_page());
                     94: }
                     95: 
1.1       harris41   96: sub handler {
1.10      www        97: 
1.1       harris41   98:     my $r = shift;
                     99: 
1.6       www       100:     my $now=time;
1.118     albertel  101:     my $then=$env{'user.login.time'};
1.6       www       102:     my $envkey;
1.107     raeburn   103:     my %dcroles = ();
                    104:     my $numdc = &check_fordc(\%dcroles,$then);
1.148     albertel  105:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'});
1.10      www       106: 
1.6       www       107: # ================================================================== Roles Init
1.118     albertel  108:     if ($env{'form.selectrole'}) {
1.188     www       109: 
                    110:         my $locknum=&Apache::lonnet::get_locks();
                    111:         if ($locknum) { return 409; }
                    112: 
1.134     www       113:         if ($env{'form.newrole'}) {
                    114:             $env{'form.'.$env{'form.newrole'}}=1;
                    115: 	}
1.118     albertel  116: 	if ($env{'request.course.id'}) {
1.185     raeburn   117:             # Check if user is CC trying to select a course role
                    118:             if ($env{'form.switchrole'}) {
                    119:                 if (!defined($env{'user.role.'.$env{'form.switchrole'}})) {
                    120:                     &adhoc_course_role($then);
                    121:                 }
                    122:             }
1.118     albertel  123: 	    my %temp=('logout_'.$env{'request.course.id'} => time);
1.33      www       124: 	    &Apache::lonnet::put('email_status',\%temp);
1.118     albertel  125: 	    &Apache::lonnet::delenv('user.state.'.$env{'request.course.id'});
1.100     albertel  126: 	}
1.186     raeburn   127: 	&Apache::lonnet::appenv({"request.course.id"   => '',
                    128: 			 	 "request.course.fn"   => '',
                    129: 				 "request.course.uri"  => '',
                    130: 				 "request.course.sec"  => '',
                    131: 				 "request.role"        => 'cm',
                    132:                                  "request.role.adv"    => $env{'user.adv'},
                    133: 				 "request.role.domain" => $env{'user.domain'}});
1.182     www       134: # Check if user is a DC trying to enter a course or author space and needs privs to be created
1.107     raeburn   135:         if ($numdc > 0) {
1.118     albertel  136:             foreach my $envkey (keys %env) {
1.182     www       137: # Is this an ad-hoc CC-role?
1.146     raeburn   138:                 if (my ($domain,$coursenum) =
1.171     albertel  139: 		    ($envkey =~ m-^form\.cc\./($match_domain)/($match_courseid)$-)) {
1.189     www       140:                    # See if that is even allowed
1.190   ! www       141:                    my %crsenv=&Apache::lonnet::get('environment',['internal.courseowner'],$domain,$coursenum);
        !           142:                    # First find course owner
        !           143:                    my ($owneruser,$ownerdomain)=split(/\:/,$crsenv{'internal.courseowner'});
        !           144:                    # Check if course owner blocked cc-access
        !           145:                     if (($owneruser) && ($ownerdomain)) {
        !           146:                        my %blocked=&Apache::lonnet::get('environment',['domcoord.cc'],$ownerdomain,$owneruser);
        !           147:                        if ($blocked{'domcoord.cc'} eq 'blocked') {
        !           148:                           $env{'user.error.msg'}=':::1:Course owner '.$owneruser.' in domain '.$ownerdomain.' blocked domain coordinator access';
        !           149:                           last;
        !           150:                        }
        !           151:                     }
1.146     raeburn   152:                     if ($dcroles{$domain}) {
1.182     www       153:                         &check_privs($domain,$coursenum,$then,$now,'cc');
                    154:                     }
                    155:                     last;
                    156:                 }
                    157: # Is this a recent ad-hoc CA-role?
1.183     www       158:                 if (my ($domain,$user) =
                    159: 		    ($envkey =~ m-^form\.ca\./($match_domain)/($match_username)$-)) {
1.190   ! www       160:                    # See if still allowed
        !           161:                     my %blocked=&Apache::lonnet::get('environment',['domcoord.author'],$domain,$user);
        !           162:                     if ($blocked{'domcoord.author'} eq 'blocked') {
        !           163:                        delete($env{$envkey});
        !           164:                        $env{'user.error.msg'}=':::1:User '.$user.' in domain '.$domain.' blocked domain coordinator access';
        !           165:                        last;
        !           166:                     }
1.183     www       167:                     if (($dcroles{$domain}) && (&is_author_homeserver($user,$domain))) {
                    168:                         &check_privs($domain,$user,$then,$now,'ca');
                    169:                     } else {
                    170:                         delete($env{$envkey});
1.182     www       171:                     }
                    172:                     last;
                    173:                 }
                    174: # Is this a new ad-hoc CA-role?
                    175:                 if (my ($domain) =
                    176:                     ($envkey =~ m-^form\.adhocca\./($match_domain)$-)) {
1.189     www       177:                     my $user=$env{'form.adhoccauname.'.$domain};
                    178:                     if (!$user) { $user=$env{'form.adhoccaunamerecent.'.$domain} };
                    179:                    # See if that is even allowed
                    180:                     my %blocked=&Apache::lonnet::get('environment',['domcoord.author'],$domain,$user);
                    181:                     if ($blocked{'domcoord.author'} eq 'blocked') {
                    182:                        $env{'user.error.msg'}=':::1:User '.$user.' in domain '.$domain.' blocked domain coordinator access';
                    183:                        last;
                    184:                     }
1.182     www       185:                     if ($dcroles{$domain}) {
1.183     www       186:                         if (($user) && ($user=~/$match_username/) && (&is_author_homeserver($user,$domain))) { 
1.182     www       187:                            &check_privs($domain,$user,$then,$now,'ca');
                    188:                            $env{'form.ca./'.$domain.'/'.$user}=1;
                    189: 		       }
1.107     raeburn   190:                     }
                    191:                     last;
                    192:                 }
                    193:             }
                    194:         }
                    195: 
1.118     albertel  196:         foreach $envkey (keys %env) {
1.40      matthew   197:             next if ($envkey!~/^user\.role\./);
1.102     raeburn   198:             my ($where,$trolecode,$role,$tstatus,$tend,$tstart);
                    199:             &role_status($envkey,$then,$now,\$role,\$where,\$trolecode,\$tstatus,\$tstart,\$tend);
1.118     albertel  200:             if ($env{'form.'.$trolecode}) {
1.55      albertel  201: 		if ($tstatus eq 'is') {
                    202: 		    $where=~s/^\///;
                    203: 		    my ($cdom,$cnum,$csec)=split(/\//,$where);
1.137     raeburn   204: # check for course groups
                    205:                     my %coursegroups = &Apache::lonnet::get_active_groups(
                    206:                           $env{'user.domain'},$env{'user.name'},$cdom, $cnum);
                    207:                     my $cgrps = join(':',keys(%coursegroups));
                    208: 
1.111     albertel  209: # store role if recent_role list being kept
1.118     albertel  210:                     if ($env{'environment.recentroles'}) {
1.158     albertel  211:                         my %frozen_roles =
                    212:                            &Apache::lonhtmlcommon::get_recent_frozen('roles',$env{'environment.recentrolesn'});
1.111     albertel  213: 			&Apache::lonhtmlcommon::store_recent('roles',
1.158     albertel  214: 							     $trolecode,' ',$frozen_roles{$trolecode});
1.111     albertel  215:                     }
                    216: 
                    217: 
1.53      www       218: # check for keyed access
1.55      albertel  219: 		    if (($role eq 'st') && 
1.118     albertel  220:                        ($env{'course.'.$cdom.'_'.$cnum.'.keyaccess'} eq 'yes')) {
1.89      www       221: # who is key authority?
                    222: 			my $authdom=$cdom;
                    223: 			my $authnum=$cnum;
1.118     albertel  224: 			if ($env{'course.'.$cdom.'_'.$cnum.'.keyauth'}) {
1.89      www       225: 			    ($authnum,$authdom)=
1.172     albertel  226: 				split(/:/,$env{'course.'.$cdom.'_'.$cnum.'.keyauth'});
1.89      www       227: 			}
                    228: # check with key authority
                    229: 			unless (&Apache::lonnet::validate_access_key(
1.118     albertel  230: 				     $env{'environment.key.'.$cdom.'_'.$cnum},
1.89      www       231: 					     $authdom,$authnum)) {
1.53      www       232: # there is no valid key
1.118     albertel  233: 			     if ($env{'form.newkey'}) {
1.53      www       234: # student attempts to register a new key
1.89      www       235: 				 &Apache::loncommon::content_type($r,'text/html');
                    236: 				 &Apache::loncommon::no_cache($r);
                    237: 				 $r->send_http_header;
                    238: 				 my $swinfo=&Apache::lonmenu::rawconfig();
1.147     albertel  239: 				 my $start_page=&Apache::loncommon::start_page
1.89      www       240: 				    ('Verifying Access Key to Unlock this Course');
1.147     albertel  241: 				 my $end_page=&Apache::loncommon::end_page();
1.90      www       242: 				 my $buttontext=&mt('Enter Course');
                    243: 				 my $message=&mt('Successfully registered key');
                    244: 				 my $assignresult=
                    245: 				     &Apache::lonnet::assign_access_key(
1.118     albertel  246: 						     $env{'form.newkey'},
1.90      www       247: 						     $authdom,$authnum,
1.91      www       248: 						     $cdom,$cnum,
1.118     albertel  249:                                                      $env{'user.domain'},
                    250: 						     $env{'user.name'},
1.90      www       251: 	      'Assigned from '.$ENV{'REMOTE_ADDR'}.' at '.localtime().' for '.
                    252:                                                      $trolecode);
                    253: 				 unless ($assignresult eq 'ok') {
                    254: 				     $assignresult=~s/^error\:\s*//;
                    255: 				     $message=&mt($assignresult).
                    256: 				     '<br /><a href="/adm/logout">'.
1.89      www       257: 				     &mt('Logout').'</a>';
1.90      www       258: 				     $buttontext=&mt('Re-Enter Key');
                    259: 				 }
1.89      www       260: 				 $r->print(<<ENDENTEREDKEY);
1.147     albertel  261: $start_page
1.179     raeburn   262: <script type="text/javascript">
1.89      www       263: $swinfo
                    264: </script>
                    265: <form method="post">
                    266: <input type="hidden" name="selectrole" value="1" />
                    267: <input type="hidden" name="$trolecode" value="1" />
1.90      www       268: <font size="+2">$message</font><br />
1.89      www       269: <input type="submit" value="$buttontext" />
                    270: </form>
1.147     albertel  271: $end_page
1.89      www       272: ENDENTEREDKEY
                    273:                                  return OK;
1.55      albertel  274: 			     } else {
1.53      www       275: # print form to enter a new key
1.73      www       276: 				 &Apache::loncommon::content_type($r,'text/html');
1.55      albertel  277: 				 &Apache::loncommon::no_cache($r);
                    278: 				 $r->send_http_header;
                    279: 				 my $swinfo=&Apache::lonmenu::rawconfig();
1.147     albertel  280: 				 my $start_page=&Apache::loncommon::start_page
1.55      albertel  281: 				    ('Enter Access Key to Unlock this Course');
1.147     albertel  282: 				 my $end_page=&Apache::loncommon::end_page();
1.55      albertel  283: 				 $r->print(<<ENDENTERKEY);
1.147     albertel  284: $start_page
1.179     raeburn   285: <script type="text/javascript">
1.53      www       286: $swinfo
                    287: </script>
                    288: <form method="post">
1.89      www       289: <input type="hidden" name="selectrole" value="1" />
                    290: <input type="hidden" name="$trolecode" value="1" />
1.118     albertel  291: <input type="text" size="20" name="newkey" value="$env{'form.newkey'}" />
1.53      www       292: <input type="submit" value="Enter key" />
                    293: </form>
1.147     albertel  294: $end_page
1.53      www       295: ENDENTERKEY
1.55      albertel  296: 				 return OK;
                    297: 			     }
                    298: 			 }
                    299: 		     }
1.118     albertel  300: 		    &Apache::lonnet::log($env{'user.domain'},
                    301: 					 $env{'user.name'},
                    302: 					 $env{'user.home'},
1.87      www       303: 					 "Role ".$trolecode);
1.101     albertel  304: 		    
1.56      www       305: 		    &Apache::lonnet::appenv(
1.186     raeburn   306: 					   {'request.role'        => $trolecode,
                    307: 					    'request.role.domain' => $cdom,
                    308: 					    'request.course.sec'  => $csec,
                    309:                                             'request.course.groups' => $cgrps});
1.101     albertel  310:                     my $tadv=0;
1.62      matthew   311: 
1.125     www       312: 		    if (($cnum) && ($role ne 'ca') && ($role ne 'aa')) {
1.152     raeburn   313:                         my $msg;
1.55      albertel  314: 			my ($furl,$ferr)=
                    315: 			    &Apache::lonuserstate::readmap($cdom.'/'.$cnum);
1.118     albertel  316: 			if (($env{'form.orgurl'}) && 
                    317: 			    ($env{'form.orgurl'}!~/^\/adm\/flip/)) {
                    318: 			    my $dest=$env{'form.orgurl'};
1.117     albertel  319: 			    if (&Apache::lonnet::allowed('adv') eq 'F') { $tadv=1; }
1.186     raeburn   320: 			    &Apache::lonnet::appenv({'request.role.adv'=>$tadv});
1.150     www       321:                             if (($ferr) && ($tadv)) {
                    322: 				&error_page($r,$ferr,$dest);
                    323: 			    } else {
                    324: 				$r->internal_redirect($dest);
                    325: 			    }
1.55      albertel  326: 			    return OK;
                    327: 			} else {
1.155     albertel  328: 			    if (!$env{'request.course.id'}) {
1.55      albertel  329: 				&Apache::lonnet::appenv(
1.186     raeburn   330: 				      {"request.course.id"  => $cdom.'_'.$cnum});
1.61      www       331: 				$furl='/adm/roles?tryagain=1';
1.55      albertel  332: 				$msg=
1.157     albertel  333: 				    '<h1><span class="LC_error">'.
1.162     albertel  334: 				    &mt('Could not initialize [_1] at this time.',
                    335: 					$env{'course.'.$cdom.'_'.$cnum.'.description'}).
1.157     albertel  336: 				    '</span></h1><h3>'.&mt('Please try again.').'</h3>'.$ferr;
1.55      albertel  337: 			    }
1.117     albertel  338: 			    if (&Apache::lonnet::allowed('adv') eq 'F') { $tadv=1; }
1.186     raeburn   339: 			    &Apache::lonnet::appenv({'request.role.adv'=>$tadv});
1.152     raeburn   340: 
1.150     www       341: 			    if (($ferr) && ($tadv)) {
                    342: 				&error_page($r,$ferr,$furl);
                    343: 			    } else {
                    344: 				# Check to see if the user is a CC entering a course 
                    345: 				# for the first time
                    346: 				my (undef, undef, $role, $courseid) = split(/\./, $envkey);
                    347: 				if (substr($courseid, 0, 1) eq '/') {
                    348: 				    $courseid = substr($courseid, 1);
                    349: 				}
                    350: 				$courseid =~ s/\//_/;
                    351: 				if ($role eq 'cc' && $env{'course.' . $courseid . 
                    352: 							      '.course.helper.not.run'}) {
                    353: 				    $furl = "/adm/helper/course.initialization.helper";
                    354: 				    # Send the user to the course they selected
                    355: 				} elsif ($env{'request.course.id'}) {
1.185     raeburn   356:                                     if ($env{'form.destinationurl'}) {
                    357:                                         my $dest = $env{'form.destinationurl'};
                    358:                                         &redirect_user($r,&mt('Entering [_1]',
                    359:                                                       $env{'course.'.$courseid.'.description'}),
                    360:                                                $dest,$msg,
                    361:                                                $env{'environment.remotenavmap'});
                    362:                                         return OK;
                    363:                                     }
1.150     www       364: 				    if (&Apache::lonnet::allowed('whn',
                    365: 								 $env{'request.course.id'})
                    366: 					|| &Apache::lonnet::allowed('whn',
                    367: 								    $env{'request.course.id'}.'/'
                    368: 								    .$env{'request.course.sec'})
                    369: 					) {
                    370: 					my $startpage = &courseloadpage($courseid);
                    371: 					unless ($startpage eq 'firstres') {         
1.162     albertel  372: 					    $msg = &mt('Entering [_1] ....',
                    373: 						       $env{'course.'.$courseid.'.description'});
1.150     www       374: 					    &redirect_user($r,&mt('New in course'),
                    375: 							   '/adm/whatsnew?refpage=start',$msg,
                    376: 							   $env{'environment.remotenavmap'});
                    377: 					    return OK;
                    378: 					}
                    379: 				    }
                    380: 				}
1.151     www       381: # Are we allowed to look at the first resource?
1.169     albertel  382: 				if ($furl !~ m|^/adm/|) {
1.151     www       383: # Guess not ...
                    384: 				    $furl=&Apache::lonpageflip::first_accessible_resource();
                    385: 				}
1.162     albertel  386:                                 $msg = &mt('Entering [_1] ...',
                    387: 					   $env{'course.'.$courseid.'.description'});
                    388: 				&redirect_user($r,&mt('Entering [_1]',
                    389: 						      $env{'course.'.$courseid.'.description'}),
1.150     www       390: 					       $furl,$msg,
                    391: 					       $env{'environment.remotenavmap'});
1.58      bowersj2  392: 			    }
1.124     albertel  393: 			    return OK;
1.55      albertel  394: 			}
                    395: 		    }
1.62      matthew   396:                     #
                    397:                     # Send the user to the construction space they selected
1.125     www       398:                     if ($role =~ /^(au|ca|aa)$/) {
1.62      matthew   399:                         my $redirect_url = '/priv/';
                    400:                         if ($role eq 'au') {
1.118     albertel  401:                             $redirect_url.=$env{'user.name'};
1.62      matthew   402:                         } else {
                    403:                             $where =~ /\/(.*)$/;
                    404:                             $redirect_url .= $1;
                    405:                         }
                    406:                         $redirect_url .= '/';
1.78      sakharuk  407:                         &redirect_user($r,&mt('Entering Construction Space'),
1.62      matthew   408:                                        $redirect_url);
                    409:                         return OK;
                    410:                     }
1.104     raeburn   411:                     if ($role eq 'dc') {
1.108     raeburn   412:                         my $redirect_url = '/adm/menu/';
                    413:                         &redirect_user($r,&mt('Loading Domain Coordinator Menu'),
1.104     raeburn   414:                                        $redirect_url);
1.108     raeburn   415:                         return OK;
1.104     raeburn   416:                     }
1.55      albertel  417: 		}
                    418:             }
1.6       www       419:         }
1.40      matthew   420:     }
1.44      www       421: 
1.10      www       422: 
1.6       www       423: # =============================================================== No Roles Init
1.10      www       424: 
1.73      www       425:     &Apache::loncommon::content_type($r,'text/html');
1.30      albertel  426:     &Apache::loncommon::no_cache($r);
1.10      www       427:     $r->send_http_header;
                    428:     return OK if $r->header_only;
                    429: 
1.52      www       430:     my $swinfo=&Apache::lonmenu::rawconfig();
1.147     albertel  431:     my $start_page=&Apache::loncommon::start_page('User Roles');
1.134     www       432:     my $standby=&mt('Role selected. Please stand by.');
1.135     albertel  433:     $standby=~s/\n/\\n/g;
1.184     raeburn   434:     my $noscript='<span class="LC_error">'.&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.').'<br />'.&mt('As this is not the case, most functionality in the system will be unavailable.').'</span><br />';
1.163     www       435: 
1.10      www       436:     $r->print(<<ENDHEADER);
1.147     albertel  437: $start_page
1.163     www       438: <br />
1.179     raeburn   439: <noscript>
                    440: $noscript
                    441: </noscript>
                    442: <script type="text/javascript">
1.26      www       443: $swinfo
                    444: window.focus();
1.134     www       445: 
                    446: active=true;
                    447: 
                    448: function enterrole (thisform,rolecode,buttonname) {
                    449:     if (active) {
                    450: 	active=false;
                    451:         document.title='$standby';
                    452:         window.status='$standby';
                    453: 	thisform.newrole.value=rolecode;
                    454: 	thisform.submit();
                    455:     } else {
                    456:        alert('$standby');
                    457:     }   
                    458: }
1.26      www       459: </script>
1.10      www       460: ENDHEADER
1.6       www       461: 
1.2       www       462: # ------------------------------------------ Get Error Message from Environment
                    463: 
1.118     albertel  464:     my ($fn,$priv,$nochoose,$error,$msg)=split(/:/,$env{'user.error.msg'});
                    465:     if ($env{'user.error.msg'}) {
1.55      albertel  466: 	$r->log_reason(
1.118     albertel  467:    "$msg for $env{'user.name'} domain $env{'user.domain'} access $priv",$fn);
1.12      www       468:     }
1.1       harris41  469: 
1.61      www       470: # ------------------------------------------------- Can this user re-init, etc?
1.6       www       471: 
1.118     albertel  472:     my $advanced=$env{'user.adv'};
1.61      www       473:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['tryagain']);
1.118     albertel  474:     my $tryagain=$env{'form.tryagain'};
1.6       www       475: 
1.2       www       476: # -------------------------------------------------------- Generate Page Output
1.6       www       477: # --------------------------------------------------------------- Error Header?
1.2       www       478:     if ($error) {
1.187     bisitz    479:         $r->print("<h1>".&mt('LON-CAPA Access Control')."</h1>");
1.174     albertel  480: 	$r->print("<!-- LONCAPAACCESSCONTROLERRORSCREEN --><hr /><pre>");
                    481: 	if ($priv ne '') {
1.187     bisitz    482:             $r->print(&mt('Access  : ').&Apache::lonnet::plaintext($priv)."\n");
1.174     albertel  483: 	}
                    484: 	if ($fn ne '') {
1.187     bisitz    485:             $r->print(&mt('Resource: ').&Apache::lonenc::check_encrypt($fn)."\n");
1.174     albertel  486: 	}
                    487: 	if ($msg ne '') {
1.187     bisitz    488:             $r->print(&mt('Action  : ').$msg."\n");
1.174     albertel  489: 	}
                    490: 	$r->print("</pre><hr />");
1.120     albertel  491: 	my $url=$fn;
                    492: 	my $last;
                    493: 	if (tie(my %hash,'GDBM_File',$env{'request.course.fn'}.'_symb.db',
                    494: 		&GDBM_READER(),0640)) {
                    495: 	    $last=$hash{'last_known'};
                    496: 	    untie(%hash);
                    497: 	}
1.149     www       498: 	if ($last) { $fn.='?symb='.&escape($last); }
1.120     albertel  499: 
                    500: 	&Apache::londocs::changewarning($r,undef,'You have modified your course recently, [_1] may fix this access problem.',
                    501: 					&Apache::lonenc::check_encrypt($fn));
1.2       www       502:     } else {
1.118     albertel  503:         if ($env{'user.error.msg'}) {
1.25      www       504: 	    $r->print(
1.157     albertel  505:  '<h3><span class="LC_error">'.
                    506:  &mt('You need to choose another user role or enter a specific course for this function').'</span></h3>');
1.25      www       507: 	}
1.2       www       508:     }
1.6       www       509: # -------------------------------------------------------- Choice or no choice?
1.2       www       510:     if ($nochoose) {
1.177     www       511: 	$r->print("<h2>".&mt('Sorry ...')."</h2>\n<span class='LC_error'>".
                    512: 		  &mt('This action is currently not authorized.').'</span>'.
1.150     www       513: 		  &Apache::loncommon::end_page());
                    514: 	return OK;
1.6       www       515:     } else {
1.18      www       516:         if (($ENV{'REDIRECT_QUERY_STRING'}) && ($fn)) {
                    517:     	    $fn.='?'.$ENV{'REDIRECT_QUERY_STRING'};
1.6       www       518:         }
1.84      www       519:         $r->print('<form method="post" name="rolechoice" action="'.(($fn)?$fn:$r->uri).'">');
1.116     albertel  520:         $r->print('<input type="hidden" name="orgurl" value="'.$fn.'" />');
                    521:         $r->print('<input type="hidden" name="selectrole" value="1" />');
1.134     www       522:         $r->print('<input type="hidden" name="newrole" value="" />');
1.6       www       523:     }
1.118     albertel  524:     if ($env{'user.adv'}) {
1.63      www       525: 	$r->print(
1.177     www       526: 	      '<br /><span class="LC_rolesinfo"><label>'.&mt('Show all roles').': <input type="checkbox" name="showall"');
1.118     albertel  527: 	if ($env{'form.showall'}) { $r->print(' checked="checked" '); }
1.177     www       528: 	$r->print(' /></label><input type="submit" value="'.&mt('Display').'" /></span>');
1.63      www       529:     }
1.4       www       530: 
1.75      albertel  531:     my (%roletext,%sortrole,%roleclass);
1.84      www       532:     my $countactive=0;
                    533:     my $inrole=0;
                    534:     my $possiblerole='';
1.118     albertel  535:     foreach $envkey (sort keys %env) {
1.35      matthew   536:         my $button = 1;
1.49      www       537:         my $switchserver='';
1.75      albertel  538: 	my $roletext;
                    539: 	my $sortkey;
1.2       www       540:         if ($envkey=~/^user\.role\./) {
1.102     raeburn   541:             my ($role,$where,$trolecode,$tstart,$tend,$tremark,$tstatus,$tpstart,$tpend,$tfont);
                    542:             &role_status($envkey,$then,$now,\$role,\$where,\$trolecode,\$tstatus,\$tstart,\$tend);
1.136     raeburn   543:             next if (!defined($role) || $role eq '' || $role =~ /^gr/);
1.102     raeburn   544:             $tremark='';
                    545:             $tpstart='&nbsp;';
                    546:             $tpend='&nbsp;';
                    547:             $tfont='#000000';
1.4       www       548:             if ($tstart) {
1.74      www       549:                 $tpstart=&Apache::lonlocal::locallocaltime($tstart);
1.4       www       550:             }
                    551:             if ($tend) {
1.74      www       552:                 $tpend=&Apache::lonlocal::locallocaltime($tend);
1.4       www       553:             }
1.118     albertel  554:             if ($env{'request.role'} eq $trolecode) {
1.6       www       555: 		$tstatus='selected';
                    556:             }
1.4       www       557:             my $tbg;
1.164     albertel  558:             if (($tstatus eq 'is') 
                    559: 		|| ($tstatus eq 'selected') 
                    560: 		|| ($tstatus eq 'will') 
                    561: 		|| ($tstatus eq 'future') 
                    562:                 || ($env{'form.showall'})) {
1.35      matthew   563:                 if ($tstatus eq 'is') {
                    564:                     $tbg='#77FF77';
1.47      www       565:                     $tfont='#003300';
1.84      www       566: 		    $possiblerole=$trolecode;
                    567: 		    $countactive++;
1.35      matthew   568:                 } elsif ($tstatus eq 'future') {
                    569:                     $tbg='#FFFF77';
1.49      www       570:                     $button=0;
1.35      matthew   571:                 } elsif ($tstatus eq 'will') {
                    572:                     $tbg='#FFAA77';
1.72      www       573:                     $tremark.=&mt('Active at next login. ');
1.35      matthew   574:                 } elsif ($tstatus eq 'expired') {
                    575:                     $tbg='#FF7777';
1.47      www       576:                     $tfont='#330000';
1.49      www       577:                     $button=0;
1.35      matthew   578:                 } elsif ($tstatus eq 'will_not') {
                    579:                     $tbg='#AAFF77';
1.72      www       580:                     $tremark.=&mt('Expired after logout. ');
1.35      matthew   581:                 } elsif ($tstatus eq 'selected') {
                    582:                     $tbg='#11CC55';
1.47      www       583:                     $tfont='#002200';
1.84      www       584: 		    $inrole=1;
1.86      albertel  585: 		    $countactive++;
1.72      www       586:                     $tremark.=&mt('Currently selected. ');
1.35      matthew   587:                 }
                    588:                 my $trole;
                    589:                 if ($role =~ /^cr\//) {
                    590:                     my ($rdummy,$rdomain,$rauthor,$rrole)=split(/\//,$role);
1.132     albertel  591: 		    if ($tremark) { $tremark.='<br />'; }
                    592:                     $tremark.=&mt('Defined by ').$rauthor.
1.72      www       593: 			&mt(' at ').$rdomain.'.';
1.159     albertel  594: 		}
                    595: 		$trole=Apache::lonnet::plaintext($role);
1.35      matthew   596:                 my $ttype;
                    597:                 my $twhere;
                    598:                 my ($tdom,$trest,$tsection)=
                    599:                     split(/\//,Apache::lonnet::declutter($where));
                    600:                 # First, Co-Authorship roles
1.125     www       601:                 if (($role eq 'ca') || ($role eq 'aa')) {
1.39      stredwic  602:                     my $home = &Apache::lonnet::homeserver($trest,$tdom);
1.83      albertel  603: 		    my $allowed=0;
                    604: 		    my @ids=&Apache::lonnet::current_machine_ids();
                    605: 		    foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
                    606:                     if (!$allowed) {
1.49      www       607: 			$button=0;
1.130     albertel  608:                         $switchserver='otherserver='.$home.'&role='.$trolecode;
1.49      www       609:                     }
1.35      matthew   610:                     #next if ($home eq 'no_host');
1.176     albertel  611:                     $home = &Apache::lonnet::hostname($home);
1.78      sakharuk  612:                     $ttype='Construction Space';
1.72      www       613:                     $twhere=&mt('User').': '.$trest.'<br />'.&mt('Domain').
                    614: 			': '.$tdom.'<br />'.
                    615:                         ' '.&mt('Server').':&nbsp;'.$home;
1.118     albertel  616:                     $env{'course.'.$tdom.'_'.$trest.'.description'}='ca';
1.82      www       617: 		    $tremark.=&Apache::lonhtmlcommon::authorbombs('/res/'.$tdom.'/'.$trest.'/');
1.75      albertel  618: 		    $sortkey=$role."$trest:$tdom";
1.35      matthew   619:                 } elsif ($role eq 'au') {
                    620:                     # Authors
                    621:                     my $home = &Apache::lonnet::homeserver
1.118     albertel  622:                         ($env{'user.name'},$env{'user.domain'});
1.83      albertel  623: 		    my $allowed=0;
                    624: 		    my @ids=&Apache::lonnet::current_machine_ids();
                    625: 		    foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
                    626:                     if (!$allowed) {
1.49      www       627: 			$button=0;
1.143     albertel  628:                         $switchserver='otherserver='.$home.'&role='.$trolecode;
1.49      www       629:                     }
1.35      matthew   630:                     #next if ($home eq 'no_host');
1.176     albertel  631:                     $home = &Apache::lonnet::hostname($home);
1.78      sakharuk  632:                     $ttype='Construction Space';
1.72      www       633:                     $twhere=&mt('Domain').': '.$tdom.'<br />'.&mt('Server').
                    634: 			':&nbsp;'.$home;
1.118     albertel  635:                     $env{'course.'.$tdom.'_'.$trest.'.description'}='ca';
                    636: 		    $tremark.=&Apache::lonhtmlcommon::authorbombs('/res/'.$tdom.'/'.$env{'user.name'}.'/');
1.75      albertel  637: 		    $sortkey=$role;
1.35      matthew   638:                 } elsif ($trest) {
                    639:                     my $tcourseid=$tdom.'_'.$trest;
1.153     raeburn   640:                     $ttype = &Apache::loncommon::course_type($tcourseid);
                    641:                     $trole = &Apache::lonnet::plaintext($role,$ttype);
1.118     albertel  642:                     if ($env{'course.'.$tcourseid.'.description'}) {
                    643:                         $twhere=$env{'course.'.$tcourseid.'.description'};
1.80      albertel  644: 			$sortkey=$role."\0".$tdom."\0".$twhere."\0".$envkey;
1.72      www       645:                         unless ($twhere eq &mt('Currently not available')) {
1.55      albertel  646: 			    $twhere.=' <font size="-2">'.
1.72      www       647:         &Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$trest,$tdom,$tfont).
1.49      www       648:                                     '</font>';
1.55      albertel  649: 			}
1.8       www       650:                     } else {
1.105     raeburn   651:                         my %newhash=&Apache::lonnet::coursedescription($tcourseid);
1.35      matthew   652:                         if (%newhash) {
1.80      albertel  653: 			    $sortkey=$role."\0".$tdom."\0".$newhash{'description'}.
1.77      albertel  654: 				"\0".$envkey;
1.49      www       655:                             $twhere=$newhash{'description'}.
                    656:                               ' <font size="-2">'.
1.72      www       657:         &Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$trest,$tdom,$tfont).
1.49      www       658:                               '</font>';
1.152     raeburn   659:                             $ttype = $newhash{'type'};
1.153     raeburn   660:                             $trole = &Apache::lonnet::plaintext($role,$ttype);
1.35      matthew   661:                         } else {
1.72      www       662:                             $twhere=&mt('Currently not available');
1.118     albertel  663:                             $env{'course.'.$tcourseid.'.description'}=$twhere;
1.80      albertel  664: 			    $sortkey=$role."\0".$tdom."\0".$twhere."\0".$envkey;
1.152     raeburn   665:                             $ttype = 'Unavailable';
1.35      matthew   666:                         }
1.8       www       667:                     }
1.121     albertel  668:                     if ($tsection) {
1.175     albertel  669:                         $twhere.='<br />'.&mt('Section').': '.$tsection;
1.121     albertel  670: 		    }
1.72      www       671: 		    if ($role ne 'st') { $twhere.="<br />".&mt('Domain').":".$tdom; }
1.35      matthew   672:                 } elsif ($tdom) {
1.78      sakharuk  673:                     $ttype='Domain';
1.35      matthew   674:                     $twhere=$tdom;
1.75      albertel  675: 		    $sortkey=$role.$twhere;
1.35      matthew   676:                 } else {
1.78      sakharuk  677:                     $ttype='System';
1.72      www       678:                     $twhere=&mt('system wide');
1.75      albertel  679: 		    $sortkey=$role.$twhere;
1.13      www       680:                 }
1.152     raeburn   681:                 $roletext.=&build_roletext($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$tfont,$trole,$twhere,$tpstart,$tpend,$nochoose,$button,$switchserver);
1.75      albertel  682: 		$roletext{$envkey}=$roletext;
                    683: 		if (!$sortkey) {$sortkey=$twhere."\0".$envkey;}
                    684: 		$sortrole{$sortkey}=$envkey;
                    685: 		$roleclass{$envkey}=$ttype;
1.55      albertel  686: 	    }
1.4       www       687:         }
1.75      albertel  688:     }
1.84      www       689: # No active roles
                    690:     if ($countactive==0) {
                    691: 	if ($inrole) {
                    692: 	    $r->print('<h2>'.&mt('Currently no additional roles or courses').'</h2>');
                    693: 	} else {
                    694: 	    $r->print('<h2>'.&mt('Currently no active roles or courses').'</h2>');
                    695: 	}
1.147     albertel  696: 	$r->print('</form>'.&Apache::loncommon::end_page());
1.84      www       697: 	return OK;
                    698: # Is there only one choice?
1.118     albertel  699:     } elsif (($countactive==1) && ($env{'request.role'} eq 'cm')) {
1.84      www       700: 	$r->print('<h3>'.&mt('Please stand by.').'</h3>'.
1.179     raeburn   701: 	    '<input type="hidden" name="'.$possiblerole.'" value="1" />'.
                    702:             '<noscript><br /><input type="submit" name="submit" value="'.&mt('Continue').'" /></noscript>');
1.84      www       703: 	$r->print("</form>\n");
                    704: 	$r->rflush();
1.179     raeburn   705: 	$r->print('<script type="text/javascript">document.forms.rolechoice.submit();</script>');
1.147     albertel  706: 	$r->print(&Apache::loncommon::end_page());
1.84      www       707: 	return OK;
                    708:     }
                    709: # More than one possible role
                    710: # ----------------------------------------------------------------------- Table
1.181     albertel  711:     unless ((!&Apache::lonmenu::show_course()) || ($nochoose)) {
1.173     albertel  712: 	$r->print("<h2>".&mt('Select a Course to Enter')."</h2>\n");
1.84      www       713:     }
1.177     www       714:     $r->print('<br /><table id="LC_rolesmenu"><tr>');
1.84      www       715:     unless ($nochoose) { $r->print('<th>&nbsp;</th>'); }
1.121     albertel  716:     $r->print('<th>'.&mt('User Role').'</th><th>'.&mt('Extent').
1.132     albertel  717:          '</th><th>'.&mt('Start').'</th><th>'.&mt('End').'</th></tr>'."\n");
1.76      albertel  718:     my $doheaders=-1;
1.173     albertel  719:     foreach my $type ('Domain','Construction Space','Course','Unavailable','System') {
1.76      albertel  720: 	my $haverole=0;
1.75      albertel  721: 	foreach my $which (sort {uc($a) cmp uc($b)} (keys(%sortrole))) {
                    722: 	    if ($roleclass{$sortrole{$which}} =~ /^\Q$type\E/) { 
1.76      albertel  723: 		$haverole=1;
1.75      albertel  724: 	    }
1.76      albertel  725: 	}
                    726: 	if ($haverole) { $doheaders++; }
                    727:     }
1.111     albertel  728: 
1.118     albertel  729:     if ($env{'environment.recentroles'}) {
1.111     albertel  730:         my %recent_roles =
1.118     albertel  731:                &Apache::lonhtmlcommon::get_recent('roles',$env{'environment.recentrolesn'});
1.111     albertel  732: 	my $output='';
                    733: 	foreach (sort(keys(%recent_roles))) {
                    734: 	    if (defined($roletext{'user.role.'.$_})) {
                    735: 		$output.=$roletext{'user.role.'.$_};
1.170     albertel  736:                 if ($_ =~ m-dc\./($match_domain)/- 
                    737: 		    && $dcroles{$1}) {
1.182     www       738: 		    $output .= &allcourses_row($1,'recent').
                    739:                                &allcoauthors_row($1,'recent');
1.133     albertel  740:                 }
1.113     raeburn   741: 	    } elsif ($numdc > 0) {
                    742:                 unless ($_ =~/^error\:/) {
                    743:                     $output.=&display_cc_role('user.role.'.$_);
                    744:                 }
                    745:             } 
1.111     albertel  746: 	}
                    747: 	if ($output) {
1.132     albertel  748: 	    $r->print("<tr><td align='center' colspan='5'><font face='arial'>".
1.126     www       749: 		      &mt('Recent Roles')."</font></td>");
1.111     albertel  750: 	    $r->print($output);
                    751: 	    $r->print("</tr>");
1.114     raeburn   752:             $doheaders ++;
1.111     albertel  753: 	}
                    754:     }
                    755: 
1.104     raeburn   756:     if ($numdc > 0) {
1.112     raeburn   757:         $r->print(&coursepick_jscript());
                    758:         $r->print(&Apache::loncommon::coursebrowser_javascript());
1.108     raeburn   759:     }
1.173     albertel  760:     foreach my $type ('Construction Space','Domain','Course','Unavailable','System') {
1.108     raeburn   761: 	my $output;
                    762: 	foreach my $which (sort {uc($a) cmp uc($b)} (keys(%sortrole))) {
                    763: 	    if ($roleclass{$sortrole{$which}} =~ /^\Q$type\E/) { 
                    764: 		$output.=$roletext{$sortrole{$which}};
1.170     albertel  765:                 if ($sortrole{$which} =~ m-dc\./($match_domain)/-) {
1.108     raeburn   766:                     if ($dcroles{$1}) {
1.182     www       767:                         $output .= &allcourses_row($1,'').
                    768:                                    &allcoauthors_row($1,'');
1.104     raeburn   769:                     }
                    770:                 }
1.76      albertel  771: 	    }
1.108     raeburn   772: 	}
                    773: 	if ($output) {
                    774: 	    if ($doheaders > 0) {
1.126     www       775: 		$r->print("<tr>".
1.132     albertel  776: 			  "<td align='center' colspan='5'><font face='arial'>".&mt($type)."</font></td></tr>");
1.76      albertel  777: 	    }
1.108     raeburn   778: 	    $r->print($output);	
                    779: 	}
1.4       www       780:     }
1.14      www       781:     my $tremark='';
1.47      www       782:     my $tfont='#003300';
1.118     albertel  783:     if ($env{'request.role'} eq 'cm') {
1.19      www       784: 	$r->print('<tr bgcolor="#11CC55">');
1.72      www       785:         $tremark=&mt('Currently selected. ');
1.47      www       786:         $tfont='#002200';
1.14      www       787:     } else {
                    788:         $r->print('<tr bgcolor="#77FF77">');
                    789:     }
                    790:     unless ($nochoose) {
1.118     albertel  791: 	if ($env{'request.role'} ne 'cm') {
1.134     www       792: 	    $r->print('<td><input type="submit" value="'.
1.72      www       793: 		      &mt('Select').'" name="cm"></td>');
1.55      albertel  794: 	} else {
                    795: 	    $r->print('<td>&nbsp;</td>');
                    796: 	}
1.14      www       797:     }
1.177     www       798:     $r->print('<td colspan="3"><font color="'.$tfont.'"><span class="LC_rolesinfo">'.&mt('No role specified').
                    799:       '</font></span></td><td><font color="'.$tfont.'">'.$tremark.
1.47      www       800:       '&nbsp;</font></td></tr>'."\n");
1.4       www       801: 
                    802:     $r->print('</table>');
                    803:     unless ($nochoose) {
                    804: 	$r->print("</form>\n");
                    805:     }
1.22      harris41  806: # ------------------------------------------------------------ Privileges Info
1.118     albertel  807:     if (($advanced) && (($env{'user.error.msg'}) || ($error))) {
1.127     albertel  808: 	$r->print('<hr /><h2>Current Privileges</h2>');
1.175     albertel  809: 	$r->print(&privileges_info());
1.4       www       810:     }
1.66      www       811:     $r->print(&Apache::lonnet::getannounce());
1.65      www       812:     if ($advanced) {
                    813: 	$r->print('<p><small><i>This is LON-CAPA '.
1.85      www       814: 		  $r->dir_config('lonVersion').'</i><br />'.
                    815: 		  '<a href="/adm/logout">'.&mt('Logout').'</a></small></p>');
1.65      www       816:     }
1.147     albertel  817:     $r->print(&Apache::loncommon::end_page());
1.1       harris41  818:     return OK;
1.102     raeburn   819: }
                    820: 
1.175     albertel  821: sub privileges_info {
                    822:     my ($which) = @_;
                    823:     my $output;
                    824: 
                    825:     $which ||= $env{'request.role'};
                    826: 
                    827:     foreach my $envkey (sort(keys(%env))) {
                    828: 	next if ($envkey!~/^user\.priv\.\Q$which\E\.(.*)/);
                    829: 
                    830: 	my $where=$1;
                    831: 	my $ttype;
                    832: 	my $twhere;
                    833: 	my (undef,$tdom,$trest,$tsec)=split(m{/},$where);
                    834: 	if ($trest) {
                    835: 	    if ($env{'course.'.$tdom.'_'.$trest.'.description'} eq 'ca') {
                    836: 		$ttype='Construction Space';
                    837: 		$twhere='User: '.$trest.', Domain: '.$tdom;
                    838: 	    } else {
                    839: 		$ttype= &Apache::loncommon::course_type($tdom.'_'.$trest);
                    840: 		$twhere=$env{'course.'.$tdom.'_'.$trest.'.description'};
                    841: 		if ($tsec) {
                    842: 		    my $sec_type = 'Section';
                    843: 		    if (exists($env{"user.role.gr.$where"})) {
                    844: 			$sec_type = 'Group';
                    845: 		    }
                    846: 		    $twhere.=' ('.$sec_type.': '.$tsec.')';
                    847: 		}
                    848: 	    }
                    849: 	} elsif ($tdom) {
                    850: 	    $ttype='Domain';
                    851: 	    $twhere=$tdom;
                    852: 	} else {
                    853: 	    $ttype='System';
                    854: 	    $twhere='/';
                    855: 	}
                    856: 	$output .= "\n<h3>".$ttype.': '.$twhere.'</h3>'."\n<ul>";
                    857: 	foreach my $priv (sort(split(/:/,$env{$envkey}))) {
                    858: 	    next if (!$priv);
                    859: 
                    860: 	    my ($prv,$restr)=split(/\&/,$priv);
                    861: 	    my $trestr='';
                    862: 	    if ($restr ne 'F') {
                    863: 		$trestr.=' ('.
                    864: 		    join(', ',
                    865: 			 map { &Apache::lonnet::plaintext($_) } 
                    866: 			     (split('',$restr))).') ';
                    867: 	    }
                    868: 	    $output .= "\n\t".
                    869: 		'<li>'.&Apache::lonnet::plaintext($prv).$trestr.'</li>';
                    870: 	}
                    871: 	$output .= "\n".'</ul>';
                    872:     }
                    873:     return $output;
                    874: }
                    875: 
1.102     raeburn   876: sub role_status {
                    877:     my ($rolekey,$then,$now,$role,$where,$trolecode,$tstatus,$tstart,$tend) = @_;
                    878:     my @pwhere = ();
1.118     albertel  879:     if (exists($env{$rolekey}) && $env{$rolekey} ne '') {
1.102     raeburn   880:         (undef,undef,$$role,@pwhere)=split(/\./,$rolekey);
                    881:         unless (!defined($$role) || $$role eq '') {
                    882:             $$where=join('.',@pwhere);
                    883:             $$trolecode=$$role.'.'.$$where;
1.118     albertel  884:             ($$tstart,$$tend)=split(/\./,$env{$rolekey});
1.102     raeburn   885:             $$tstatus='is';
1.105     raeburn   886:             if ($$tstart && $$tstart>$then) {
                    887: 		$$tstatus='future';
                    888: 		if ($$tstart<$now) { $$tstatus='will'; }
1.102     raeburn   889:             }
                    890:             if ($$tend) {
                    891:                 if ($$tend<$then) {
                    892:                     $$tstatus='expired';
1.103     raeburn   893:                 } elsif ($$tend<$now) {
1.104     raeburn   894:                     $$tstatus='will_not';
1.102     raeburn   895:                 }
                    896:             }
                    897:         }
                    898:     }
                    899: }
1.1       harris41  900: 
1.110     raeburn   901: sub build_roletext {
1.152     raeburn   902:     my ($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$tfont,$trole,$twhere,$tpstart,$tpend,$nochoose,$button,$switchserver) = @_;
1.177     www       903:     my $roletext='<tr bgcolor="'.$tbg.'" class="LC_rolesmenu_'.$tstatus.'">';
1.132     albertel  904:     my $is_dc=($trolecode =~ m/^dc\./);
                    905:     my $rowspan=($is_dc) ? ''
                    906:                          : ' rowspan="2" ';
                    907: 
1.110     raeburn   908:     unless ($nochoose) {
1.134     www       909:         my $buttonname=$trolecode;
                    910:         $buttonname=~s/\W//g;
1.110     raeburn   911:         if (!$button) {
                    912:             if ($switchserver) {
1.177     www       913:                 $roletext.='<td'.$rowspan.'><span class="LC_rolesinfo"><a href="/adm/switchserver?'.
                    914:                 $switchserver.'">'.&mt('Switch Server').'</a></span></td>';
1.110     raeburn   915:             } else {
1.164     albertel  916:                 $roletext.=('<td'.$rowspan.'>&nbsp;</td>');
1.110     raeburn   917:             }
                    918:         } elsif ($tstatus eq 'is') {
1.134     www       919:             $roletext.='<td'.$rowspan.'><input name="'.$buttonname.'" type="button" value="'.
                    920:                         &mt('Select').'" onClick="javascript:enterrole(this.form,\''.
                    921:                         $trolecode."','".$buttonname.'\');"></td>';
1.110     raeburn   922:         } elsif ($tryagain) {
                    923:             $roletext.=
1.134     www       924:                 '<td'.$rowspan.'><input name="'.$buttonname.'" type="button" value="'.
                    925:                 &mt('Try Selecting Again').'" onClick="javascript:enterrole(this.form,\''.
                    926:                         $trolecode."','".$buttonname.'\');"></td>';
1.110     raeburn   927:         } elsif ($advanced) {
                    928:             $roletext.=
1.134     www       929:                 '<td'.$rowspan.'><input name="'.$buttonname.'" type="button" value="'.
                    930:                 &mt('Re-Initialize').'" onClick="javascript:enterrole(this.form,\''.
                    931:                         $trolecode."','".$buttonname.'\');"></td>';
1.110     raeburn   932:         } else {
1.132     albertel  933:             $roletext.='<td'.$rowspan.'>&nbsp;</td>';
1.110     raeburn   934:         }
                    935:     }
1.165     albertel  936:     if ($trolecode !~ m/^(dc|ca|au|aa)\./) {
                    937: 	$tremark.=&Apache::lonannounce::showday(time,1,
                    938: 			 &Apache::lonannounce::readcalendar($tdom.'_'.$trest));
                    939:     }
1.110     raeburn   940:     $roletext.='<td><font color="'.$tfont.'">'.$trole.
1.121     albertel  941: 	       '</font></td><td><font color="'.$tfont.'">'.$twhere.
1.110     raeburn   942:                '</font></td><td><font color="'.$tfont.'">'.$tpstart.
                    943:                '</font></td><td><font color="'.$tfont.'">'.$tpend.
1.132     albertel  944:                '</font></td></tr>';
                    945:     if (!$is_dc) {
1.177     www       946: 	$roletext.='<tr bgcolor="'.$tbg.'"><td colspan="4"><font color="'.$tfont.'"><span class="LC_rolesinfo">'.$tremark.
                    947: 	    '</span>&nbsp;</font></td></tr><tr><td colspan="5" height="3"></td></tr>'."\n";
1.132     albertel  948:     }
1.110     raeburn   949:     return $roletext;
                    950: }
                    951: 
1.183     www       952: sub is_author_homeserver {
                    953:     my ($uname,$udom)=@_;
                    954:     my $home = &Apache::lonnet::homeserver($uname,$udom);
                    955:     my @ids=&Apache::lonnet::current_machine_ids();
                    956:     foreach my $id (@ids) { 
                    957:        if ($id eq $home) { 
                    958:           if (-e "/home/".$uname."/public_html") {
                    959:              return 1;
                    960:           }
                    961:        }
                    962:     }
                    963:     return 0;
                    964: }
                    965: 
1.110     raeburn   966: sub check_privs {
1.182     www       967:     my ($cdom,$cnum,$then,$now,$checkrole) = @_;
                    968:     my $cckey = 'user.role.'.$checkrole.'./'.$cdom.'/'.$cnum; 
1.118     albertel  969:     if ($env{$cckey}) {
1.110     raeburn   970:         my ($role,$where,$trolecode,$tstart,$tend,$tremark,$tstatus,$tpstart,$tpend,$tfont);
                    971:         &role_status($cckey,$then,$now,\$role,\$where,\$trolecode,\$tstatus,\$tstart,\$tend);
                    972:         unless (($tstatus eq 'is') || ($tstatus eq 'will_not')) {
1.182     www       973:             &set_privileges($cdom,$cnum,$checkrole);
1.110     raeburn   974:         }
                    975:     } else {
1.182     www       976:         &set_privileges($cdom,$cnum,$checkrole);
1.110     raeburn   977:     }
                    978: }
                    979: 
1.104     raeburn   980: sub check_fordc {
                    981:     my ($dcroles,$then) = @_;
                    982:     my $numdc = 0;
1.118     albertel  983:     if ($env{'user.adv'}) {
                    984:         foreach my $envkey (sort keys %env) {
1.170     albertel  985:             if ($envkey=~/^user\.role\.dc\.\/($match_domain)\/$/) {
1.104     raeburn   986:                 my $dcdom = $1;
                    987:                 my $livedc = 1;
1.118     albertel  988:                 my ($tstart,$tend)=split(/\./,$env{$envkey});
1.105     raeburn   989:                 if ($tstart && $tstart>$then) { $livedc = 0; }
                    990:                 if ($tend   && $tend  <$then) { $livedc = 0; }
1.104     raeburn   991:                 if ($livedc) {
                    992:                     $$dcroles{$dcdom} = $envkey;
1.105     raeburn   993:                     $numdc++;
1.104     raeburn   994:                 }
                    995:             }
                    996:         }
                    997:     }
                    998:     return $numdc;
                    999: }
                   1000: 
1.185     raeburn  1001: sub adhoc_course_role {
                   1002:     my ($then) = @_; 
                   1003:     my ($cdom,$cnum);
                   1004:     my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
                   1005:     my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
                   1006:     if (&check_forcc($cdom,$cnum,$then)) {
                   1007:         my $setprivs;
                   1008:         if (!defined($env{'user.role.'.$env{'form.selectrole'}})) {
                   1009:             $setprivs = 1;
                   1010:         } else {
                   1011:             my ($start,$end) = split(/\./,$env{'user.role.'.$env{'form.selectrole'}});
                   1012:             if (($start && ($start>$then || $start == -1)) ||
                   1013:                 ($end && $end<$then)) {
                   1014:                 $setprivs = 1;
                   1015:             }
                   1016:         } 
                   1017:         if ($setprivs) {
                   1018:             if ($env{'form.switchrole'} =~ m-^(in|ta|ep|ad|st|cr)([\w/]*)\./\Q$cdom\E/\Q$cnum\E(/?\w*)$-) {
                   1019:                 my $role = $1;
                   1020:                 my $custom_role = $2;
                   1021:                 my $usec = $3;
                   1022:                 if ($role eq 'cr') {
                   1023:                     if ($custom_role =~ m-^$match_domain/$match_courseid/\w+$-) {
                   1024:                         $role .= $custom_role;
                   1025:                     } else {
                   1026:                         return;
                   1027:                     }
                   1028:                 }
                   1029:                 my (%userroles,%newrole,%newgroups);
                   1030:                 my $area = '/'.$cdom.'/'.$cnum;
                   1031:                 my $spec = $role.'.'.$area;
                   1032:                 if ($usec ne '') {
                   1033:                     $spec .= '/'.$usec;
                   1034:                     $area .= '/'.$usec;
                   1035:                 }
                   1036:                 &Apache::lonnet::standard_roleprivs(\%newrole,$role,$cdom,$spec,$cnum,$area);
                   1037:                 &Apache::lonnet::set_userprivs(\%userroles,\%newrole,%newgroups);
                   1038:                 my $adhocstart = $then-1;
                   1039:                 $userroles{'user.role.'.$spec} = $adhocstart.'.';
1.186     raeburn  1040:                 &Apache::lonnet::appenv(\%userroles,[$role,'cm']);
1.185     raeburn  1041:             }
                   1042:         }
                   1043:     }
                   1044:     return;
                   1045: }
                   1046: 
                   1047: sub check_forcc {
                   1048:     my ($cdom,$cnum,$then) = @_;
                   1049:     my $is_cc;
                   1050:     if ($cdom ne '' && $cnum ne '') {
                   1051:         if (&Apache::lonnet::is_course($cdom,$cnum)) {
                   1052:             my $envkey = 'user.role.cc./'.$cdom.'/'.$cnum;
                   1053:             if (defined($env{$envkey})) {
                   1054:                 $is_cc = 1;
                   1055:                 my ($tstart,$tend)=split(/\./,$env{$envkey});
                   1056:                 if ($tstart && $tstart>$then) { $is_cc = 0; }
                   1057:                 if ($tend   && $tend  <$then) { $is_cc = 0; }
                   1058:             }
                   1059:         }
                   1060:     }
                   1061:     return $is_cc;
                   1062: }
                   1063: 
1.108     raeburn  1064: sub courselink {
1.152     raeburn  1065:     my ($dcdom,$rowtype,$selecttype) = @_;
1.109     raeburn  1066:     my $courseform=&Apache::loncommon::selectcourse_link
1.152     raeburn  1067:                    ('rolechoice','dccourse'.$rowtype.'_'.$dcdom,
                   1068:                     'dcdomain'.$rowtype.'_'.$dcdom,'coursedesc'.$rowtype.'_'.
1.173     albertel 1069:                     $dcdom,$dcdom,undef);
1.138     raeburn  1070:     my $hiddenitems = '<input type="hidden" name="dcdomain'.$rowtype.'_'.$dcdom.'" value="'.$dcdom.'" />'.
                   1071:                       '<input type="hidden" name="origdom'.$rowtype.'_'.$dcdom.'" value="'.$dcdom.'" />'.
                   1072:                       '<input type="hidden" name="dccourse'.$rowtype.'_'.$dcdom.'" value="" />'.
                   1073:                       '<input type="hidden" name="coursedesc'.$rowtype.'_'.$dcdom.'" value="" />';
1.112     raeburn  1074:     return $courseform.$hiddenitems;
1.109     raeburn  1075: }
                   1076: 
                   1077: sub coursepick_jscript {
1.184     raeburn  1078:     my %lt = &Apache::lonlocal::texthash(
                   1079:                   plsu => "Please use the 'Select Course' link to open a separate pick course window where you may select the course you wish to enter.",
                   1080:                   youc => 'You can only use this screen to select courses in the current domain.',
                   1081:              );
1.104     raeburn  1082:     my $verify_script = <<"END";
1.179     raeburn  1083: <script type="text/javascript">
1.108     raeburn  1084: function verifyCoursePick(caller) {
                   1085:     var numbutton = getIndex(caller)
1.112     raeburn  1086:     var pickedCourse = document.rolechoice.elements[numbutton+4].value
                   1087:     var pickedDomain = document.rolechoice.elements[numbutton+2].value
                   1088:     if (document.rolechoice.elements[numbutton+2].value == document.rolechoice.elements[numbutton+3].value) {
1.104     raeburn  1089:         if (pickedCourse != '') {
1.108     raeburn  1090:             if (numbutton != -1) {
                   1091:                 var courseTarget = "cc./"+pickedDomain+"/"+pickedCourse
                   1092:                 document.rolechoice.elements[numbutton+1].name = courseTarget
                   1093:                 document.rolechoice.submit()
                   1094:             }
1.104     raeburn  1095:         }
                   1096:         else {
1.184     raeburn  1097:             alert("$lt{'plsu'}");
1.104     raeburn  1098:         }
                   1099:     }
                   1100:     else {
1.184     raeburn  1101:         alert("$lt{'youc'}")
1.104     raeburn  1102:     }
                   1103: }
1.109     raeburn  1104: function getIndex(caller) {
1.108     raeburn  1105:     for (var i=0;i<document.rolechoice.elements.length;i++) {
1.109     raeburn  1106:         if (document.rolechoice.elements[i] == caller) {
1.108     raeburn  1107:             return i;
                   1108:         }
                   1109:     }
                   1110:     return -1;
                   1111: }
1.104     raeburn  1112: </script>
                   1113: END
1.109     raeburn  1114:     return $verify_script;
1.104     raeburn  1115: }
                   1116: 
1.113     raeburn  1117: sub display_cc_role {
                   1118:     my $rolekey = shift;
                   1119:     my $roletext;
1.118     albertel 1120:     my $advanced = $env{'user.adv'};
                   1121:     my $tryagain = $env{'form.tryagain'};
1.113     raeburn  1122:     unless ($rolekey =~/^error\:/) {
1.171     albertel 1123:         if ($rolekey =~ m-^user\.role.cc\./($match_domain)/($match_courseid)$-) {
1.113     raeburn  1124:             my $tcourseid = $1.'_'.$2;
                   1125:             my $trolecode = 'cc./'.$1.'/'.$2;
                   1126:             my $twhere;
1.152     raeburn  1127:             my $ttype;
1.113     raeburn  1128:             my $tbg='#77FF77';
                   1129:             my $tfont='#003300';
                   1130:             my %newhash=&Apache::lonnet::coursedescription($tcourseid);
                   1131:             if (%newhash) {
                   1132:                 $twhere=$newhash{'description'}.
                   1133:                         ' <font size="-2">'.
                   1134:                         &Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$2,$1,$tfont).
                   1135:                         '</font>';
1.153     raeburn  1136:                 $ttype = $newhash{'type'};
1.113     raeburn  1137:             } else {
                   1138:                 $twhere=&mt('Currently not available');
1.118     albertel 1139:                 $env{'course.'.$tcourseid.'.description'}=$twhere;
1.110     raeburn  1140:             }
1.153     raeburn  1141:             my $trole = &Apache::lonnet::plaintext('cc',$ttype);
1.113     raeburn  1142:             $twhere.="<br />".&mt('Domain').":".$1;
1.152     raeburn  1143:             $roletext = &build_roletext($trolecode,$1,$2,'is',$tryagain,$advanced,'',$tbg,$tfont,$trole,$twhere,'','','',1,'');
1.104     raeburn  1144:         }
                   1145:     }
1.152     raeburn  1146:     return ($roletext);
1.104     raeburn  1147: }
                   1148: 
1.108     raeburn  1149: sub allcourses_row {
1.138     raeburn  1150:     my ($dcdom,$rowtype) = @_;
1.132     albertel 1151:     my $output = '<tr bgcolor="#77FF77">'.
1.152     raeburn  1152:                  ' <td colspan="5">';
1.173     albertel 1153:     my $selectlink = &courselink($dcdom,$rowtype);
                   1154:     my $ccrole = &Apache::lonnet::plaintext('cc');
1.177     www      1155:     $output.= '<span class="LC_rolesinfo">'.
                   1156:             &mt('[_1]: [_2] from domain [_3]',$ccrole,$selectlink,$dcdom).
1.182     www      1157:             '</span><br /></tr>'."\n";
                   1158:     return $output;
                   1159: }
                   1160: 
                   1161: sub allcoauthors_row {
                   1162:     my ($dcdom,$rowtype) = @_;
                   1163:     my $output = '<tr bgcolor="#77FF77">'.
                   1164:                  ' <td colspan="5">';
                   1165:     my $carole = &Apache::lonnet::plaintext('ca');
                   1166:     my $inputlink='<input type="text" size="10" name="adhoccauname'.$rowtype.'.'.$dcdom.'" />';
                   1167:     my $gobutton='<input type="submit" name="adhocca./'.$dcdom.'" value="'.&mt('Go').'" />';
                   1168:     $output.= '<span class="LC_rolesinfo">'.
                   1169:             &mt('[_1]: [_2] in domain [_3] [_4]',$carole,$inputlink,$dcdom,$gobutton).
1.177     www      1170:             '</span><br /></tr><tr><td colspan="5" height="3"></td></tr>'."\n";
1.108     raeburn  1171:     return $output;
                   1172: }
                   1173: 
1.104     raeburn  1174: sub recent_filename {
                   1175:     my $area=shift;
1.149     www      1176:     return 'nohist_recent_'.&escape($area);
1.104     raeburn  1177: }
                   1178: 
1.106     raeburn  1179: sub set_privileges {
1.182     www      1180: # role can be cc or ca
                   1181:     my ($dcdom,$pickedcourse,$role) = @_;
1.106     raeburn  1182:     my $area = '/'.$dcdom.'/'.$pickedcourse;
                   1183:     my $spec = $role.'.'.$area;
1.168     albertel 1184:     my %userroles = &Apache::lonnet::set_arearole($role,$area,'','',
                   1185: 						  $env{'user.domain'},
                   1186: 						  $env{'user.name'});
1.106     raeburn  1187:     my %ccrole = ();
                   1188:     &Apache::lonnet::standard_roleprivs(\%ccrole,$role,$dcdom,$spec,$pickedcourse,$area);
1.154     albertel 1189:     my ($author,$adv)= &Apache::lonnet::set_userprivs(\%userroles,\%ccrole);
1.186     raeburn  1190:     &Apache::lonnet::appenv(\%userroles,[$role,'cm']);
1.184     raeburn  1191: 
1.118     albertel 1192:     &Apache::lonnet::log($env{'user.domain'},
                   1193:                          $env{'user.name'},
                   1194:                          $env{'user.home'},
1.106     raeburn  1195:                         "Role ".$role);
                   1196:     &Apache::lonnet::appenv(
1.186     raeburn  1197:                           {'request.role'        => $spec,
1.106     raeburn  1198:                           'request.role.domain' => $dcdom,
1.186     raeburn  1199:                           'request.course.sec'  => ''});
1.106     raeburn  1200:     my $tadv=0;
                   1201:     if (&Apache::lonnet::allowed('adv') eq 'F') { $tadv=1; }
1.186     raeburn  1202:     &Apache::lonnet::appenv({'request.role.adv'    => $tadv});
1.106     raeburn  1203: }
                   1204: 
1.139     raeburn  1205: sub courseloadpage {
                   1206:     my ($courseid) = @_;
                   1207:     my $startpage;
1.144     albertel 1208:     my %entry_settings = &Apache::lonnet::get('nohist_whatsnew',
                   1209: 					      [$courseid.':courseinit']);
1.139     raeburn  1210:     my ($tmp) = %entry_settings;
1.144     albertel 1211:     unless ($tmp =~ /^error: 2 /) {
1.139     raeburn  1212:         $startpage = $entry_settings{$courseid.':courseinit'};
                   1213:     }
                   1214:     if ($startpage eq '') {
                   1215:         if (exists($env{'environment.course_init_display'})) {
                   1216:             $startpage = $env{'environment.course_init_display'};
                   1217:         }
                   1218:     }
                   1219:     return $startpage;
                   1220: }
                   1221: 
1.1       harris41 1222: 1;
                   1223: __END__
1.32      harris41 1224: 
                   1225: =head1 NAME
                   1226: 
                   1227: Apache::lonroles - User Roles Screen
                   1228: 
                   1229: =head1 SYNOPSIS
                   1230: 
                   1231: Invoked by /etc/httpd/conf/srm.conf:
                   1232: 
                   1233:  <Location /adm/roles>
                   1234:  PerlAccessHandler       Apache::lonacc
                   1235:  SetHandler perl-script
                   1236:  PerlHandler Apache::lonroles
                   1237:  ErrorDocument     403 /adm/login
                   1238:  ErrorDocument	  500 /adm/errorhandler
                   1239:  </Location>
1.64      bowersj2 1240: 
                   1241: =head1 OVERVIEW
                   1242: 
                   1243: =head2 Choosing Roles
                   1244: 
                   1245: C<lonroles> is a handler that allows a user to switch roles in
                   1246: mid-session. LON-CAPA attempts to work with "No Role Specified", the
                   1247: default role that a user has before selecting a role, as widely as
                   1248: possible, but certain handlers for example need specification which
                   1249: course they should act on, etc. Both in this scenario, and when the
                   1250: handler determines via C<lonnet>'s C<&allowed> function that a certain
                   1251: action is not allowed, C<lonroles> is used as error handler. This
                   1252: allows the user to select another role which may have permission to do
                   1253: what they were trying to do. C<lonroles> can also be accessed via the
                   1254: B<CRS> button in the Remote Control. 
                   1255: 
                   1256: =begin latex
                   1257: 
                   1258: \begin{figure}
                   1259: \begin{center}
                   1260: \includegraphics[width=0.45\paperwidth,keepaspectratio]{Sample_Roles_Screen}
                   1261:   \caption{\label{Sample_Roles_Screen}Sample Roles Screen} 
                   1262: \end{center}
                   1263: \end{figure}
                   1264: 
                   1265: =end latex
                   1266: 
                   1267: =head2 Role Initialization
                   1268: 
                   1269: The privileges for a user are established at login time and stored in the session environment. As a consequence, a new role does not become active till the next login. Handlers are able to query for privileges using C<lonnet>'s C<&allowed> function. When a user first logs in, their role is the "common" role, which means that they have the sum of all of their privileges. During a session it might become necessary to choose a particular role, which as a consequence also limits the user to only the privileges in that particular role.
1.32      harris41 1270: 
                   1271: =head1 INTRODUCTION
                   1272: 
                   1273: This module enables a user to select what role he wishes to
                   1274: operate under (instructor, student, teaching assistant, course
                   1275: coordinator, etc).  These roles are pre-established by the actions
                   1276: of upper-level users.
                   1277: 
                   1278: This is part of the LearningOnline Network with CAPA project
                   1279: described at http://www.lon-capa.org.
                   1280: 
                   1281: =head1 HANDLER SUBROUTINE
                   1282: 
                   1283: This routine is called by Apache and mod_perl.
                   1284: 
                   1285: =over 4
                   1286: 
                   1287: =item *
                   1288: 
                   1289: Roles Initialization (yes/no)
                   1290: 
                   1291: =item *
                   1292: 
                   1293: Get Error Message from Environment
                   1294: 
                   1295: =item *
                   1296: 
                   1297: Who is this?
                   1298: 
                   1299: =item *
                   1300: 
                   1301: Generate Page Output
                   1302: 
                   1303: =item *
                   1304: 
                   1305: Choice or no choice
                   1306: 
                   1307: =item *
                   1308: 
                   1309: Table
                   1310: 
                   1311: =item *
                   1312: 
                   1313: Privileges
                   1314: 
                   1315: =back
                   1316: 
                   1317: =cut

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