File:  [LON-CAPA] / loncom / auth / lonroles.pm
Revision 1.132: download - view: text, annotated - select for diffs
Tue Nov 8 21:54:03 2005 UTC (18 years, 7 months ago) by albertel
Branches: MAIN
CVS tags: HEAD
- the roles screen got some reorg to increase the space avaible for remarks, and to better associate the DC role with the associated line for the CC in any course line.

    1: # The LearningOnline Network with CAPA
    2: # User Roles Screen
    3: #
    4: # $Id: lonroles.pm,v 1.132 2005/11/08 21:54:03 albertel Exp $
    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: #
   28: ###
   29: 
   30: package Apache::lonroles;
   31: 
   32: use strict;
   33: use Apache::lonnet;
   34: use Apache::lonuserstate();
   35: use Apache::Constants qw(:common);
   36: use Apache::File();
   37: use Apache::lonmenu;
   38: use Apache::loncommon;
   39: use Apache::lonhtmlcommon;
   40: use Apache::lonannounce;
   41: use Apache::lonlocal;
   42: use GDBM_File;
   43: 
   44: sub redirect_user {
   45:     my ($r,$title,$url,$msg,$launch_nav) = @_;
   46:     $msg = $title if (! defined($msg));
   47:     &Apache::loncommon::content_type($r,'text/html');
   48:     &Apache::loncommon::no_cache($r);
   49:     $r->send_http_header;
   50:     my $swinfo=&Apache::lonmenu::rawconfig();
   51:     my $navwindow;
   52:     if ($launch_nav eq 'on') {
   53: 	$navwindow.=&Apache::lonnavmaps::launch_win('now',undef,undef,
   54: 						    ($url eq '/adm/whatsnew'));
   55:     } else {
   56: 	$navwindow.=&Apache::lonnavmaps::close();
   57:     }
   58:     my $bodytag=&Apache::loncommon::bodytag('Switching Role');
   59: # Note to style police: 
   60: # This must only replace the spaces, nothing else, or it bombs elsewhere.
   61:     $url=~s/ /\%20/g;
   62:     $r->print(<<ENDREDIR);
   63: <head><title>$title</title>
   64: <meta HTTP-EQUIV="Refresh" CONTENT="1; url=$url">
   65: </head>
   66: <html>
   67: $bodytag
   68: <script type="text/javascript">
   69: $swinfo
   70: </script>
   71: $navwindow
   72: <h1>$msg</h1>
   73: <a href="$url">Continue</a>
   74: </body>
   75: </html>
   76: ENDREDIR
   77:     return;
   78: }
   79: 
   80: sub handler {
   81: 
   82:     my $r = shift;
   83: 
   84:     my $now=time;
   85:     my $then=$env{'user.login.time'};
   86:     my $envkey;
   87:     my %dcroles = ();
   88:     my $numdc = &check_fordc(\%dcroles,$then);
   89: 
   90: # ================================================================== Roles Init
   91:     if ($env{'form.selectrole'}) {
   92: 	if ($env{'request.course.id'}) {
   93: 	    my %temp=('logout_'.$env{'request.course.id'} => time);
   94: 	    &Apache::lonnet::put('email_status',\%temp);
   95: 	    &Apache::lonnet::delenv('user.state.'.$env{'request.course.id'});
   96: 	}
   97: 	&Apache::lonnet::appenv("request.course.id"   => '',
   98: 				"request.course.fn"   => '',
   99: 				"request.course.uri"  => '',
  100: 				"request.course.sec"  => '',
  101: 				"request.role"        => 'cm',
  102:                                 "request.role.adv"    => $env{'user.adv'},
  103: 				"request.role.domain" => $env{'user.domain'});
  104: 
  105: # Check if user is a DC trying to enter a course and needs privs to be created
  106:         if ($numdc > 0) {
  107:             foreach my $envkey (keys %env) {
  108:                 if ($envkey =~ m-^form\.cc\./(\w+)/(\w+)$-) {
  109:                     if ($dcroles{$1}) {
  110:                         my $cckey = 'user.role.cc./'.$1.'/'.$2;
  111:                         &check_privs($cckey,$then,$now);
  112:                     }
  113:                     last;
  114:                 }
  115:             }
  116:         }
  117: 
  118:         foreach $envkey (keys %env) {
  119:             next if ($envkey!~/^user\.role\./);
  120:             my ($where,$trolecode,$role,$tstatus,$tend,$tstart);
  121:             &role_status($envkey,$then,$now,\$role,\$where,\$trolecode,\$tstatus,\$tstart,\$tend);
  122:             if ($env{'form.'.$trolecode}) {
  123: 		if ($tstatus eq 'is') {
  124: 		    $where=~s/^\///;
  125: 		    my ($cdom,$cnum,$csec)=split(/\//,$where);
  126: # store role if recent_role list being kept
  127:                     if ($env{'environment.recentroles'}) {
  128: 			&Apache::lonhtmlcommon::store_recent('roles',
  129: 							     $trolecode,' ');
  130:                     }
  131: 
  132: 
  133: # check for keyed access
  134: 		    if (($role eq 'st') && 
  135:                        ($env{'course.'.$cdom.'_'.$cnum.'.keyaccess'} eq 'yes')) {
  136: # who is key authority?
  137: 			my $authdom=$cdom;
  138: 			my $authnum=$cnum;
  139: 			if ($env{'course.'.$cdom.'_'.$cnum.'.keyauth'}) {
  140: 			    ($authnum,$authdom)=
  141: 				split(/\W/,$env{'course.'.$cdom.'_'.$cnum.'.keyauth'});
  142: 			}
  143: # check with key authority
  144: 			unless (&Apache::lonnet::validate_access_key(
  145: 				     $env{'environment.key.'.$cdom.'_'.$cnum},
  146: 					     $authdom,$authnum)) {
  147: # there is no valid key
  148: 			     if ($env{'form.newkey'}) {
  149: # student attempts to register a new key
  150: 				 &Apache::loncommon::content_type($r,'text/html');
  151: 				 &Apache::loncommon::no_cache($r);
  152: 				 $r->send_http_header;
  153: 				 my $swinfo=&Apache::lonmenu::rawconfig();
  154: 				 my $bodytag=&Apache::loncommon::bodytag
  155: 				    ('Verifying Access Key to Unlock this Course');
  156: 				 my $buttontext=&mt('Enter Course');
  157: 				 my $message=&mt('Successfully registered key');
  158: 				 my $assignresult=
  159: 				     &Apache::lonnet::assign_access_key(
  160: 						     $env{'form.newkey'},
  161: 						     $authdom,$authnum,
  162: 						     $cdom,$cnum,
  163:                                                      $env{'user.domain'},
  164: 						     $env{'user.name'},
  165: 	      'Assigned from '.$ENV{'REMOTE_ADDR'}.' at '.localtime().' for '.
  166:                                                      $trolecode);
  167: 				 unless ($assignresult eq 'ok') {
  168: 				     $assignresult=~s/^error\:\s*//;
  169: 				     $message=&mt($assignresult).
  170: 				     '<br /><a href="/adm/logout">'.
  171: 				     &mt('Logout').'</a>';
  172: 				     $buttontext=&mt('Re-Enter Key');
  173: 				 }
  174: 				 $r->print(<<ENDENTEREDKEY);
  175: <head><title>Verifying Course Access Key</title>
  176: </head>
  177: <html>
  178: $bodytag
  179: <script>
  180: $swinfo
  181: </script>
  182: <form method="post">
  183: <input type="hidden" name="selectrole" value="1" />
  184: <input type="hidden" name="$trolecode" value="1" />
  185: <font size="+2">$message</font><br />
  186: <input type="submit" value="$buttontext" />
  187: </form>
  188: </body></html>
  189: ENDENTEREDKEY
  190:                                  return OK;
  191: 			     } else {
  192: # print form to enter a new key
  193: 				 &Apache::loncommon::content_type($r,'text/html');
  194: 				 &Apache::loncommon::no_cache($r);
  195: 				 $r->send_http_header;
  196: 				 my $swinfo=&Apache::lonmenu::rawconfig();
  197: 				 my $bodytag=&Apache::loncommon::bodytag
  198: 				    ('Enter Access Key to Unlock this Course');
  199: 				 $r->print(<<ENDENTERKEY);
  200: <head><title>Entering Course Access Key</title>
  201: </head>
  202: <html>
  203: $bodytag
  204: <script>
  205: $swinfo
  206: </script>
  207: <form method="post">
  208: <input type="hidden" name="selectrole" value="1" />
  209: <input type="hidden" name="$trolecode" value="1" />
  210: <input type="text" size="20" name="newkey" value="$env{'form.newkey'}" />
  211: <input type="submit" value="Enter key" />
  212: </form>
  213: </body></html>
  214: ENDENTERKEY
  215: 				 return OK;
  216: 			     }
  217: 			 }
  218: 		     }
  219: 		    &Apache::lonnet::log($env{'user.domain'},
  220: 					 $env{'user.name'},
  221: 					 $env{'user.home'},
  222: 					 "Role ".$trolecode);
  223: 		    
  224: 		    &Apache::lonnet::appenv(
  225: 					   'request.role'        => $trolecode,
  226: 					   'request.role.domain' => $cdom,
  227: 					   'request.course.sec'  => $csec);
  228:                     my $tadv=0;
  229: 		    my $msg=&mt('Entering course ...');
  230: 
  231: 		    if (($cnum) && ($role ne 'ca') && ($role ne 'aa')) {
  232: 			my ($furl,$ferr)=
  233: 			    &Apache::lonuserstate::readmap($cdom.'/'.$cnum);
  234: 			if (($env{'form.orgurl'}) && 
  235: 			    ($env{'form.orgurl'}!~/^\/adm\/flip/)) {
  236: 			    my $dest=$env{'form.orgurl'};
  237: 			    if (&Apache::lonnet::allowed('adv') eq 'F') { $tadv=1; }
  238: 			    &Apache::lonnet::appenv('request.role.adv'=>$tadv);
  239: 			    $r->internal_redirect($dest);
  240: 			    return OK;
  241: 			} else {
  242: 			    unless ($env{'request.course.id'}) {
  243: 				&Apache::lonnet::appenv(
  244: 				      "request.course.id"  => $cdom.'_'.$cnum);
  245: 				$furl='/adm/roles?tryagain=1';
  246: 				$msg=
  247: 				    '<h1><font color="red">'.
  248: 			 &mt('Could not initialize course at this time.').
  249: 		    '</font></h1><h3>'.&mt('Please try again.').'</h3>'.$ferr;
  250: 			    }
  251: 			    if (&Apache::lonnet::allowed('adv') eq 'F') { $tadv=1; }
  252: 			    &Apache::lonnet::appenv('request.role.adv'=>$tadv);
  253: 
  254: 			    # Check to see if the user is a CC entering a course 
  255: 			    # for the first time
  256: 			    my (undef, undef, $role, $courseid) = split(/\./, $envkey);
  257: 			    if (substr($courseid, 0, 1) eq '/') {
  258: 				$courseid = substr($courseid, 1);
  259: 			    }
  260: 			    $courseid =~ s/\//_/;
  261: 			    if ($role eq 'cc' && $env{'course.' . $courseid . 
  262: 							  '.course.helper.not.run'}) {
  263: 				$furl = "/adm/helper/course.initialization.helper";
  264: 				# Send the user to the course they selected
  265: 			    } elsif (($env{'request.course.fn'}) 
  266: 				     && ($role eq 'cc' && ($env{'environment.course_init_display'} ne 'firstres')))  {
  267: 				$msg = &mt('Entering course ....');
  268: 				&redirect_user($r,&mt('New in course'),
  269: 					       '/adm/whatsnew',$msg,
  270: 					       $env{'environment.remotenavmap'});
  271: 				return OK;
  272: 			    }
  273: 			    &redirect_user($r,&mt('Entering Course'),
  274:                                            $furl,$msg,
  275: 					   $env{'environment.remotenavmap'});
  276: 			    return OK;
  277: 			}
  278: 		    }
  279:                     #
  280:                     # Send the user to the construction space they selected
  281:                     if ($role =~ /^(au|ca|aa)$/) {
  282:                         my $redirect_url = '/priv/';
  283:                         if ($role eq 'au') {
  284:                             $redirect_url.=$env{'user.name'};
  285:                         } else {
  286:                             $where =~ /\/(.*)$/;
  287:                             $redirect_url .= $1;
  288:                         }
  289:                         $redirect_url .= '/';
  290:                         &redirect_user($r,&mt('Entering Construction Space'),
  291:                                        $redirect_url);
  292:                         return OK;
  293:                     }
  294:                     if ($role eq 'dc') {
  295:                         my $redirect_url = '/adm/menu/';
  296:                         &redirect_user($r,&mt('Loading Domain Coordinator Menu'),
  297:                                        $redirect_url);
  298:                         return OK;
  299:                     }
  300: 		}
  301:             }
  302:         }
  303:     }
  304: 
  305: 
  306: # =============================================================== No Roles Init
  307: 
  308:     &Apache::loncommon::content_type($r,'text/html');
  309:     &Apache::loncommon::no_cache($r);
  310:     $r->send_http_header;
  311:     return OK if $r->header_only;
  312: 
  313:     my $swinfo=&Apache::lonmenu::rawconfig();
  314:     my $bodytag=&Apache::loncommon::bodytag('User Roles');
  315:     my $helptag='<table><tr><td>'.&Apache::loncommon::help_open_menu('','General Intro','General_Intro','User Roles',1,undef,undef,undef,undef,,&mt("Click here for help")).'</td></td></tr></table>';
  316:     $r->print(<<ENDHEADER);
  317: <html>
  318: <head>
  319: <title>LON-CAPA User Roles</title>
  320: </head>
  321: $bodytag
  322: $helptag<br />
  323: <script>
  324: $swinfo
  325: window.focus();
  326: </script>
  327: ENDHEADER
  328: 
  329: # ------------------------------------------ Get Error Message from Environment
  330: 
  331:     my ($fn,$priv,$nochoose,$error,$msg)=split(/:/,$env{'user.error.msg'});
  332:     if ($env{'user.error.msg'}) {
  333: 	$r->log_reason(
  334:    "$msg for $env{'user.name'} domain $env{'user.domain'} access $priv",$fn);
  335:     }
  336: 
  337: # ------------------------------------------------- Can this user re-init, etc?
  338: 
  339:     my $advanced=$env{'user.adv'};
  340:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['tryagain']);
  341:     my $tryagain=$env{'form.tryagain'};
  342: 
  343: # -------------------------------------------------------- Generate Page Output
  344: # --------------------------------------------------------------- Error Header?
  345:     if ($error) {
  346: 	$r->print("<h1>LON-CAPA Access Control</h1>");
  347:         $r->print("<!-- LONCAPAACCESSCONTROLERRORSCREEN --><hr /><pre>Access  : ".
  348:                   Apache::lonnet::plaintext($priv)."\n");
  349:         $r->print("Resource: ".&Apache::lonenc::check_encrypt($fn)."\n");
  350:         $r->print("Action  : $msg\n</pre><hr />");
  351: 	my $url=$fn;
  352: 	my $last;
  353: 	if (tie(my %hash,'GDBM_File',$env{'request.course.fn'}.'_symb.db',
  354: 		&GDBM_READER(),0640)) {
  355: 	    $last=$hash{'last_known'};
  356: 	    untie(%hash);
  357: 	}
  358: 	if ($last) { $fn.='?symb='.&Apache::lonnet::escape($last); }
  359: 
  360: 	&Apache::londocs::changewarning($r,undef,'You have modified your course recently, [_1] may fix this access problem.',
  361: 					&Apache::lonenc::check_encrypt($fn));
  362:     } else {
  363:         if ($env{'user.error.msg'}) {
  364: 	    $r->print(
  365:  '<h3><font color="red">'.
  366:  &mt('You need to choose another user role or enter a specific course for this function').'</font></h3>');
  367: 	}
  368:     }
  369: # -------------------------------------------------------- Choice or no choice?
  370:     if ($nochoose) {
  371:         if ($advanced) {
  372: 	    $r->print("<h2>".&mt('Assigned User Roles')."</h2>\n");
  373:         } else {
  374: 	    $r->print("<h2>".&mt('Sorry ...')."</h2>\n".
  375: 		      &mt('This resource might be part of'));
  376: 	    if ($env{'request.course.id'}) {
  377: 		$r->print(&mt(' another'));
  378: 	    } else {
  379: 		$r->print(&mt(' a certain'));
  380: 	    } 
  381: 	    $r->print(&mt(' course.').'</body></html>');
  382: 	    return OK;
  383:         } 
  384:     } else {
  385:         if ($advanced) {
  386: 	    $r->print(&mt("Your home server is ").
  387: 		      $Apache::lonnet::hostname{&Apache::lonnet::homeserver
  388:                       ($env{'user.name'},$env{'user.domain'})}.
  389: 		      "<br />\n");
  390: 	    $r->print(&mt(
  391:       "Author and Co-Author roles are not available on servers other than their respective home servers."));
  392:         }
  393:         if (($ENV{'REDIRECT_QUERY_STRING'}) && ($fn)) {
  394:     	    $fn.='?'.$ENV{'REDIRECT_QUERY_STRING'};
  395:         }
  396:         $r->print('<form method="post" name="rolechoice" action="'.(($fn)?$fn:$r->uri).'">');
  397:         $r->print('<input type="hidden" name="orgurl" value="'.$fn.'" />');
  398:         $r->print('<input type="hidden" name="selectrole" value="1" />');
  399:     }
  400:     if ($env{'user.adv'}) {
  401: 	$r->print(
  402: 	      '<br /><label>'.&mt('Show all roles').': <input type="checkbox" name="showall"');
  403: 	if ($env{'form.showall'}) { $r->print(' checked="checked" '); }
  404: 	$r->print(' /></label><input type="submit" value="'.&mt('Display').'" />');
  405:     }
  406: 
  407:     my (%roletext,%sortrole,%roleclass);
  408:     my $countactive=0;
  409:     my $inrole=0;
  410:     my $possiblerole='';
  411:     foreach $envkey (sort keys %env) {
  412:         my $button = 1;
  413:         my $switchserver='';
  414: 	my $roletext;
  415: 	my $sortkey;
  416:         if ($envkey=~/^user\.role\./) {
  417:             my ($role,$where,$trolecode,$tstart,$tend,$tremark,$tstatus,$tpstart,$tpend,$tfont);
  418:             &role_status($envkey,$then,$now,\$role,\$where,\$trolecode,\$tstatus,\$tstart,\$tend);
  419:             next if (!defined($role) || $role eq '');
  420:             $tremark='';
  421:             $tpstart='&nbsp;';
  422:             $tpend='&nbsp;';
  423:             $tfont='#000000';
  424:             if ($tstart) {
  425:                 $tpstart=&Apache::lonlocal::locallocaltime($tstart);
  426:             }
  427:             if ($tend) {
  428:                 $tpend=&Apache::lonlocal::locallocaltime($tend);
  429:             }
  430:             if ($env{'request.role'} eq $trolecode) {
  431: 		$tstatus='selected';
  432:             }
  433:             my $tbg;
  434:             if (($tstatus eq 'is') || ($tstatus eq 'selected') ||
  435:                 ($env{'form.showall'})) {
  436:                 if ($tstatus eq 'is') {
  437:                     $tbg='#77FF77';
  438:                     $tfont='#003300';
  439: 		    $possiblerole=$trolecode;
  440: 		    $countactive++;
  441:                 } elsif ($tstatus eq 'future') {
  442:                     $tbg='#FFFF77';
  443:                     $button=0;
  444:                 } elsif ($tstatus eq 'will') {
  445:                     $tbg='#FFAA77';
  446:                     $tremark.=&mt('Active at next login. ');
  447:                 } elsif ($tstatus eq 'expired') {
  448:                     $tbg='#FF7777';
  449:                     $tfont='#330000';
  450:                     $button=0;
  451:                 } elsif ($tstatus eq 'will_not') {
  452:                     $tbg='#AAFF77';
  453:                     $tremark.=&mt('Expired after logout. ');
  454:                 } elsif ($tstatus eq 'selected') {
  455:                     $tbg='#11CC55';
  456:                     $tfont='#002200';
  457: 		    $inrole=1;
  458: 		    $countactive++;
  459:                     $tremark.=&mt('Currently selected. ');
  460:                 }
  461:                 my $trole;
  462:                 if ($role =~ /^cr\//) {
  463:                     my ($rdummy,$rdomain,$rauthor,$rrole)=split(/\//,$role);
  464: 		    if ($tremark) { $tremark.='<br />'; }
  465:                     $tremark.=&mt('Defined by ').$rauthor.
  466: 			&mt(' at ').$rdomain.'.';
  467:                     $trole=$rrole;
  468:                 } else {
  469:                     $trole=Apache::lonnet::plaintext($role);
  470:                 }
  471:                 my $ttype;
  472:                 my $twhere;
  473:                 my ($tdom,$trest,$tsection)=
  474:                     split(/\//,Apache::lonnet::declutter($where));
  475:                 # First, Co-Authorship roles
  476:                 if (($role eq 'ca') || ($role eq 'aa')) {
  477:                     my $home = &Apache::lonnet::homeserver($trest,$tdom);
  478: 		    my $allowed=0;
  479: 		    my @ids=&Apache::lonnet::current_machine_ids();
  480: 		    foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
  481:                     if (!$allowed) {
  482: 			$button=0;
  483:                         $switchserver='otherserver='.$home.'&role='.$trolecode;
  484:                     }
  485:                     #next if ($home eq 'no_host');
  486:                     $home = $Apache::lonnet::hostname{$home};
  487:                     $ttype='Construction Space';
  488:                     $twhere=&mt('User').': '.$trest.'<br />'.&mt('Domain').
  489: 			': '.$tdom.'<br />'.
  490:                         ' '.&mt('Server').':&nbsp;'.$home;
  491:                     $env{'course.'.$tdom.'_'.$trest.'.description'}='ca';
  492: 		    $tremark.=&Apache::lonhtmlcommon::authorbombs('/res/'.$tdom.'/'.$trest.'/');
  493: 		    $sortkey=$role."$trest:$tdom";
  494:                 } elsif ($role eq 'au') {
  495:                     # Authors
  496:                     my $home = &Apache::lonnet::homeserver
  497:                         ($env{'user.name'},$env{'user.domain'});
  498: 		    my $allowed=0;
  499: 		    my @ids=&Apache::lonnet::current_machine_ids();
  500: 		    foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
  501:                     if (!$allowed) {
  502: 			$button=0;
  503:                         $switchserver=&Apache::lonnet::escape('http://'.
  504:                          $Apache::lonnet::hostname{$home}.
  505:                           '/adm/login?domain='.$env{'user.domain'}.
  506: 			   '&username='.$env{'user.name'}.
  507:                            '&firsturl=/priv/'.$env{'user.name'}.'/');
  508:                     }
  509:                     #next if ($home eq 'no_host');
  510:                     $home = $Apache::lonnet::hostname{$home};
  511:                     $ttype='Construction Space';
  512:                     $twhere=&mt('Domain').': '.$tdom.'<br />'.&mt('Server').
  513: 			':&nbsp;'.$home;
  514:                     $env{'course.'.$tdom.'_'.$trest.'.description'}='ca';
  515: 		    $tremark.=&Apache::lonhtmlcommon::authorbombs('/res/'.$tdom.'/'.$env{'user.name'}.'/');
  516: 		    $sortkey=$role;
  517:                 } elsif ($trest) {
  518:                     $ttype='Course';
  519:                     my $tcourseid=$tdom.'_'.$trest;
  520:                     if ($env{'course.'.$tcourseid.'.description'}) {
  521:                         $twhere=$env{'course.'.$tcourseid.'.description'};
  522: 			$sortkey=$role."\0".$tdom."\0".$twhere."\0".$envkey;
  523:                         unless ($twhere eq &mt('Currently not available')) {
  524: 			    $twhere.=' <font size="-2">'.
  525:         &Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$trest,$tdom,$tfont).
  526:                                     '</font>';
  527: 			}
  528:                     } else {
  529:                         my %newhash=&Apache::lonnet::coursedescription($tcourseid);
  530:                         if (%newhash) {
  531: 			    $sortkey=$role."\0".$tdom."\0".$newhash{'description'}.
  532: 				"\0".$envkey;
  533:                             $twhere=$newhash{'description'}.
  534:                               ' <font size="-2">'.
  535:         &Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$trest,$tdom,$tfont).
  536:                               '</font>';
  537:                         } else {
  538:                             $twhere=&mt('Currently not available');
  539:                             $env{'course.'.$tcourseid.'.description'}=$twhere;
  540: 			    $sortkey=$role."\0".$tdom."\0".$twhere."\0".$envkey;
  541:                         }
  542:                     }
  543:                     if ($tsection) {
  544:                         $twhere.='<br />'.&mt('Section/Group').': '.$tsection;
  545: 		    }
  546: 
  547: 		    if ($role ne 'st') { $twhere.="<br />".&mt('Domain').":".$tdom; }
  548:                 } elsif ($tdom) {
  549:                     $ttype='Domain';
  550:                     $twhere=$tdom;
  551: 		    $sortkey=$role.$twhere;
  552:                 } else {
  553:                     $ttype='System';
  554:                     $twhere=&mt('system wide');
  555: 		    $sortkey=$role.$twhere;
  556:                 }
  557:  
  558:                 $roletext.=&build_roletext($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$tfont,$trole,$ttype,$twhere,$tpstart,$tpend,$nochoose,$button,$switchserver);
  559: 		$roletext{$envkey}=$roletext;
  560: 		if (!$sortkey) {$sortkey=$twhere."\0".$envkey;}
  561: 		$sortrole{$sortkey}=$envkey;
  562: 		$roleclass{$envkey}=$ttype;
  563: 	    }
  564:         }
  565:     }
  566: # No active roles
  567:     if ($countactive==0) {
  568: 	if ($inrole) {
  569: 	    $r->print('<h2>'.&mt('Currently no additional roles or courses').'</h2>');
  570: 	} else {
  571: 	    $r->print('<h2>'.&mt('Currently no active roles or courses').'</h2>');
  572: 	}
  573: 	$r->print('</form></body></html>');
  574: 	return OK;
  575: # Is there only one choice?
  576:     } elsif (($countactive==1) && ($env{'request.role'} eq 'cm')) {
  577: 	$r->print('<h3>'.&mt('Please stand by.').'</h3>'.
  578: 	    '<input type="hidden" name="'.$possiblerole.'" value="1" />');
  579: 	$r->print("</form>\n");
  580: 	$r->rflush();
  581: 	$r->print('<script>document.forms.rolechoice.submit();</script>');
  582: 	$r->print('</body></html>');
  583: 	return OK;
  584:     }
  585: # More than one possible role
  586: # ----------------------------------------------------------------------- Table
  587:     unless (($advanced) || ($nochoose)) {
  588: 	$r->print("<h2>".&mt('Select a Course to Enter')."</h2>\n");
  589:     }
  590:     $r->print('<br /><table><tr>');
  591:     unless ($nochoose) { $r->print('<th>&nbsp;</th>'); }
  592:     $r->print('<th>'.&mt('User Role').'</th><th>'.&mt('Extent').
  593:          '</th><th>'.&mt('Start').'</th><th>'.&mt('End').'</th></tr>'."\n");
  594:     my $doheaders=-1;
  595:     foreach my $type ('Domain','Construction Space','Course','System') {
  596: 	my $haverole=0;
  597: 	foreach my $which (sort {uc($a) cmp uc($b)} (keys(%sortrole))) {
  598: 	    if ($roleclass{$sortrole{$which}} =~ /^\Q$type\E/) { 
  599: 		$haverole=1;
  600: 	    }
  601: 	}
  602: 	if ($haverole) { $doheaders++; }
  603:     }
  604: 
  605:     if ($env{'environment.recentroles'}) {
  606:         my %recent_roles =
  607:                &Apache::lonhtmlcommon::get_recent('roles',$env{'environment.recentrolesn'});
  608: 	my $output='';
  609: 	foreach (sort(keys(%recent_roles))) {
  610: 	    if (defined($roletext{'user.role.'.$_})) {
  611: 		$output.=$roletext{'user.role.'.$_};
  612: 	    } elsif ($numdc > 0) {
  613:                 unless ($_ =~/^error\:/) {
  614:                     $output.=&display_cc_role('user.role.'.$_);
  615:                 }
  616:             } 
  617: 	}
  618: 	if ($output) {
  619: 	    $r->print("<tr><td align='center' colspan='5'><font face='arial'>".
  620: 		      &mt('Recent Roles')."</font></td>");
  621: 	    $r->print($output);
  622: 	    $r->print("</tr>");
  623:             $doheaders ++;
  624: 	}
  625:     }
  626: 
  627:     if ($numdc > 0) {
  628:         $r->print(&coursepick_jscript());
  629:         $r->print(&Apache::loncommon::coursebrowser_javascript());
  630:     }
  631:     foreach my $type ('Construction Space','Domain','Course','System') {
  632: 	my $output;
  633: 	foreach my $which (sort {uc($a) cmp uc($b)} (keys(%sortrole))) {
  634: 	    if ($roleclass{$sortrole{$which}} =~ /^\Q$type\E/) { 
  635: 		$output.=$roletext{$sortrole{$which}};
  636:                 if ($sortrole{$which} =~ m-dc\./(\w+)/-) {
  637:                     if ($dcroles{$1}) {
  638:                         $output .= &allcourses_row($1);
  639:                     }
  640:                 }
  641: 	    }
  642: 	}
  643: 	if ($output) {
  644: 	    if ($doheaders > 0) {
  645: 		$r->print("<tr>".
  646: 			  "<td align='center' colspan='5'><font face='arial'>".&mt($type)."</font></td></tr>");
  647: 	    }
  648: 	    $r->print($output);	
  649: 	}
  650:     }
  651:     my $tremark='';
  652:     my $tfont='#003300';
  653:     if ($env{'request.role'} eq 'cm') {
  654: 	$r->print('<tr bgcolor="#11CC55">');
  655:         $tremark=&mt('Currently selected. ');
  656:         $tfont='#002200';
  657:     } else {
  658:         $r->print('<tr bgcolor="#77FF77">');
  659:     }
  660:     unless ($nochoose) {
  661: 	if ($env{'request.role'} ne 'cm') {
  662: 	    $r->print('<td><input type=submit value="'.
  663: 		      &mt('Select').'" name="cm"></td>');
  664: 	} else {
  665: 	    $r->print('<td>&nbsp;</td>');
  666: 	}
  667:     }
  668:     $r->print('<td colspan="3"><font color="'.$tfont.'">'.&mt('No role specified').
  669:       '</font></td><td><font color="'.$tfont.'">'.$tremark.
  670:       '&nbsp;</font></td></tr>'."\n");
  671: 
  672:     $r->print('</table>');
  673:     unless ($nochoose) {
  674: 	$r->print("</form>\n");
  675:     }
  676: # ------------------------------------------------------------ Privileges Info
  677:     if (($advanced) && (($env{'user.error.msg'}) || ($error))) {
  678: 	$r->print('<hr /><h2>Current Privileges</h2>');
  679: 
  680: 	foreach $envkey (sort keys %env) {
  681: 	    if ($envkey=~/^user\.priv\.$env{'request.role'}\./) {
  682: 		my $where=$envkey;
  683: 		$where=~s/^user\.priv\.$env{'request.role'}\.//;
  684: 		my $ttype;
  685: 		my $twhere;
  686: 		my ($tdom,$trest,$tsec)=
  687: 		    split(/\//,Apache::lonnet::declutter($where));
  688: 		if ($trest) {
  689: 		    if ($env{'course.'.$tdom.'_'.$trest.'.description'} eq 'ca') {
  690: 			$ttype='Construction Space';
  691: 			$twhere='User: '.$trest.', Domain: '.$tdom;
  692: 		    } else {
  693: 			$ttype='Course';
  694: 			$twhere=$env{'course.'.$tdom.'_'.$trest.'.description'};
  695: 			if ($tsec) {
  696: 			    $twhere.=' (Section/Group: '.$tsec.')';
  697: 			}
  698: 		    }
  699: 		} elsif ($tdom) {
  700: 		    $ttype='Domain';
  701: 		    $twhere=$tdom;
  702: 		} else {
  703: 		    $ttype='System';
  704: 		    $twhere='/';
  705: 		}
  706: 		$r->print("\n<h3>".$ttype.': '.$twhere.'</h3><ul>');
  707: 		foreach (sort split(/:/,$env{$envkey})) {
  708: 		    if ($_) {
  709: 			my ($prv,$restr)=split(/\&/,$_);
  710: 			my $trestr='';
  711: 			if ($restr ne 'F') {
  712: 			    my $i;
  713: 			    $trestr.=' (';
  714: 			    for ($i=0;$i<length($restr);$i++) {
  715: 				$trestr.=
  716: 			       Apache::lonnet::plaintext(substr($restr,$i,1));
  717: 				if ($i<length($restr)-1) { $trestr.=', '; }
  718: 			    }
  719: 			    $trestr.=')';
  720: 			}
  721: 			$r->print('<li>'.
  722: 				  Apache::lonnet::plaintext($prv).$trestr.
  723: 				  '</li>');
  724: 		    }
  725: 		}
  726: 		$r->print('</ul>');
  727: 	    }
  728: 	}
  729:     }
  730:     $r->print(&Apache::lonnet::getannounce());
  731:     if ($advanced) {
  732: 	$r->print('<p><small><i>This is LON-CAPA '.
  733: 		  $r->dir_config('lonVersion').'</i><br />'.
  734: 		  '<a href="/adm/logout">'.&mt('Logout').'</a></small></p>');
  735:     }
  736:     $r->print("</body></html>\n");
  737:     return OK;
  738: }
  739: 
  740: sub role_status {
  741:     my ($rolekey,$then,$now,$role,$where,$trolecode,$tstatus,$tstart,$tend) = @_;
  742:     my @pwhere = ();
  743:     if (exists($env{$rolekey}) && $env{$rolekey} ne '') {
  744:         (undef,undef,$$role,@pwhere)=split(/\./,$rolekey);
  745:         unless (!defined($$role) || $$role eq '') {
  746:             $$where=join('.',@pwhere);
  747:             $$trolecode=$$role.'.'.$$where;
  748:             ($$tstart,$$tend)=split(/\./,$env{$rolekey});
  749:             $$tstatus='is';
  750:             if ($$tstart && $$tstart>$then) {
  751: 		$$tstatus='future';
  752: 		if ($$tstart<$now) { $$tstatus='will'; }
  753:             }
  754:             if ($$tend) {
  755:                 if ($$tend<$then) {
  756:                     $$tstatus='expired';
  757:                 } elsif ($$tend<$now) {
  758:                     $$tstatus='will_not';
  759:                 }
  760:             }
  761:         }
  762:     }
  763: }
  764: 
  765: sub build_roletext {
  766:     my ($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$tfont,$trole,$ttype,$twhere,$tpstart,$tpend,$nochoose,$button,$switchserver) = @_;
  767:     my $roletext='<tr bgcolor="'.$tbg.'">';
  768:     my $is_dc=($trolecode =~ m/^dc\./);
  769:     my $rowspan=($is_dc) ? ''
  770:                          : ' rowspan="2" ';
  771: 
  772:     unless ($nochoose) {
  773:         if (!$button) {
  774:             if ($switchserver) {
  775:                 $roletext.='<td'.$rowspan.'><a href="/adm/switchserver?'.
  776:                 $switchserver.'">'.&mt('Switch Server').'</a></td>';
  777:             } else {
  778:                 $roletext.=('<td>&nbsp;</td>');
  779:             }
  780:         } elsif ($tstatus eq 'is') {
  781:             $roletext.=('<td'.$rowspan.'><input type=submit value="'.
  782:                         &mt('Select').'" name="'.
  783:                         $trolecode.'"></td>');
  784:         } elsif ($tryagain) {
  785:             $roletext.=
  786:                 '<td'.$rowspan.'><input type=submit value="'.
  787:                 &mt('Try Selecting Again').'" name="'.$trolecode.'"></td>';
  788:         } elsif ($advanced) {
  789:             $roletext.=
  790:                 '<td'.$rowspan.'><input type=submit value="'.
  791:                 &mt('Re-Initialize').'" name="'.$trolecode.'"></td>';
  792:         } else {
  793:             $roletext.='<td'.$rowspan.'>&nbsp;</td>';
  794:         }
  795:     }
  796:     $tremark.=&Apache::lonannounce::showday(time,1,
  797:                  &Apache::lonannounce::readcalendar($tdom.'_'.$trest));
  798: 
  799:     $roletext.='<td><font color="'.$tfont.'">'.$trole.
  800: 	       '</font></td><td><font color="'.$tfont.'">'.$twhere.
  801:                '</font></td><td><font color="'.$tfont.'">'.$tpstart.
  802:                '</font></td><td><font color="'.$tfont.'">'.$tpend.
  803:                '</font></td></tr>';
  804:     if (!$is_dc) {
  805: 	$roletext.='<tr bgcolor="'.$tbg.'"><td colspan="4"><font color="'.$tfont.'">'.$tremark.
  806: 	    '&nbsp;</font></td></tr><tr><td colspan="5" height="3"></td></tr>'."\n";
  807:     }
  808:     return $roletext;
  809: }
  810: 
  811: sub check_privs {
  812:     my ($cckey,$then,$now) = @_;
  813:     if ($env{$cckey}) {
  814:         my ($role,$where,$trolecode,$tstart,$tend,$tremark,$tstatus,$tpstart,$tpend,$tfont);
  815:         &role_status($cckey,$then,$now,\$role,\$where,\$trolecode,\$tstatus,\$tstart,\$tend);
  816:         unless (($tstatus eq 'is') || ($tstatus eq 'will_not')) {
  817:             &set_privileges($1,$2);
  818:         }
  819:     } else {
  820:         &set_privileges($1,$2);
  821:     }
  822: }
  823: 
  824: sub check_fordc {
  825:     my ($dcroles,$then) = @_;
  826:     my $numdc = 0;
  827:     if ($env{'user.adv'}) {
  828:         foreach my $envkey (sort keys %env) {
  829:             if ($envkey=~/^user\.role\.dc\.\/(\w+)\/$/) {
  830:                 my $dcdom = $1;
  831:                 my $livedc = 1;
  832:                 my ($tstart,$tend)=split(/\./,$env{$envkey});
  833:                 if ($tstart && $tstart>$then) { $livedc = 0; }
  834:                 if ($tend   && $tend  <$then) { $livedc = 0; }
  835:                 if ($livedc) {
  836:                     $$dcroles{$dcdom} = $envkey;
  837:                     $numdc++;
  838:                 }
  839:             }
  840:         }
  841:     }
  842:     return $numdc;
  843: }
  844: 
  845: sub courselink {
  846:     my ($dcdom) = @_;
  847:     my $courseform=&Apache::loncommon::selectcourse_link
  848:                      ('rolechoice','dccourse_'.$dcdom,'dcdomain_'.$dcdom,'coursedesc_'.$dcdom,$dcdom);
  849:     my $hiddenitems = '<input type="hidden" name="dcdomain_'.$dcdom.'" value="'.$dcdom.'" />'.
  850:                       '<input type="hidden" name="origdom_'.$dcdom.'" value="'.$dcdom.'" />'.
  851:                       '<input type="hidden" name="dccourse_'.$dcdom.'" value="" />'.
  852:                       '<input type="hidden" name="coursedesc_'.$dcdom.'" value="" />';
  853:     return $courseform.$hiddenitems;
  854: }
  855: 
  856: sub coursepick_jscript {
  857:     my $verify_script = <<"END";
  858: <script>
  859: function verifyCoursePick(caller) {
  860:     var numbutton = getIndex(caller)
  861:     var pickedCourse = document.rolechoice.elements[numbutton+4].value
  862:     var pickedDomain = document.rolechoice.elements[numbutton+2].value
  863:     if (document.rolechoice.elements[numbutton+2].value == document.rolechoice.elements[numbutton+3].value) {
  864:         if (pickedCourse != '') {
  865:             if (numbutton != -1) {
  866:                 var courseTarget = "cc./"+pickedDomain+"/"+pickedCourse
  867:                 document.rolechoice.elements[numbutton+1].name = courseTarget
  868:                 document.rolechoice.submit()
  869:             }
  870:         }
  871:         else {
  872:             alert("Please use the 'Select Course' link to open a separate pick course window where you may select the course you wish to enter.");
  873:         }
  874:     }
  875:     else {
  876:         alert("You can only use this screen to select courses in the current domain")
  877:     }
  878: }
  879: function getIndex(caller) {
  880:     for (var i=0;i<document.rolechoice.elements.length;i++) {
  881:         if (document.rolechoice.elements[i] == caller) {
  882:             return i;
  883:         }
  884:     }
  885:     return -1;
  886: }
  887: </script>
  888: END
  889:     return $verify_script;
  890: }
  891: 
  892: sub processpick {
  893:     my $dcdom = shift;
  894:     my $process_pick = <<"END";
  895: <script>
  896: function process_pick(dom) {
  897:     var numbutton = getIndex(dom)
  898:     var pickedCourse = opener.document.rolechoice.dccourse_$dcdom.value
  899:     var pickedDomain = opener.document.rolechoice.dcdomain_$dcdom.value
  900:     if (opener.document.rolechoice.dcdomain_$dcdom.value == opener.document.rolechoice.origdom_$dcdom.value) {
  901:         if (pickedCourse != '') {
  902:             if (numbutton != -1) {
  903:                 var courseTarget = "cc./"+pickedDomain+"/"+pickedCourse
  904:                 opener.document.rolechoice.elements[numbutton].name = courseTarget
  905:                 opener.document.rolechoice.submit()
  906:             }
  907:         }
  908:     }
  909: }
  910:  
  911: function getIndex(dom) {
  912:     var callername = 'ccpick_'+dom
  913:     for (var i=0;i<opener.document.rolechoice.elements.length;i++) {
  914:         var elemname = opener.document.rolechoice.elements[i].name
  915:         if (elemname == callername) {
  916:             return i;
  917:         }
  918:     }
  919:     return -1;
  920: }
  921: </script>
  922: END
  923:     return $process_pick;
  924: }
  925: 
  926: sub display_cc_role {
  927:     my $rolekey = shift;
  928:     my $roletext;
  929:     my $advanced = $env{'user.adv'};
  930:     my $tryagain = $env{'form.tryagain'};
  931:     unless ($rolekey =~/^error\:/) {
  932:         if ($rolekey =~ m-^user\.role.cc\./(\w+)/(\w+)$-) {
  933:             my $tcourseid = $1.'_'.$2;
  934:             my $trolecode = 'cc./'.$1.'/'.$2;
  935:             my $trole = Apache::lonnet::plaintext('cc');
  936:             my $twhere;
  937:             my $tbg='#77FF77';
  938:             my $tfont='#003300';
  939:             my %newhash=&Apache::lonnet::coursedescription($tcourseid);
  940:             if (%newhash) {
  941:                 $twhere=$newhash{'description'}.
  942:                         ' <font size="-2">'.
  943:                         &Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$2,$1,$tfont).
  944:                         '</font>';
  945:             } else {
  946:                 $twhere=&mt('Currently not available');
  947:                 $env{'course.'.$tcourseid.'.description'}=$twhere;
  948:             }
  949:             $twhere.="<br />".&mt('Domain').":".$1;
  950:             $roletext = &build_roletext($trolecode,$1,$2,'is',$tryagain,$advanced,'',$tbg,$tfont,$trole,&mt('Course'),$twhere,'','','',1,'');
  951:         }
  952:     }
  953:     return $roletext;
  954: }
  955: 
  956: sub allcourses_row {
  957:     my $dcdom = shift;
  958:     my $ccrole = Apache::lonnet::plaintext('cc');
  959:     my $selectlink = &courselink($dcdom);
  960:     my $output = '<tr bgcolor="#77FF77">'.
  961: 	'<input type="hidden" name="ccpick_'.$dcdom.'" />'.
  962: 	'<input type="hidden" name="pick_'.$dcdom.'" value="1" />'.
  963: 	'<td colspan="5">'.
  964: 	'<font color="#002200">'.$ccrole.'</font>'.
  965: 	' <b>'.$selectlink.'</b>'.
  966: 	' from '.&mt('Domain').' '.$dcdom.
  967: 	'<tr><td colspan="5" height="3"></td></tr>'."\n";
  968:     return $output;
  969: }
  970: 
  971: sub recent_filename {
  972:     my $area=shift;
  973:     return 'nohist_recent_'.&Apache::lonnet::escape($area);
  974: }
  975: 
  976: sub set_privileges {
  977:     my ($dcdom,$pickedcourse) = @_;
  978:     my $area = '/'.$dcdom.'/'.$pickedcourse;
  979:     my $role = 'cc';
  980:     my $spec = $role.'.'.$area;
  981:     my $userroles = &Apache::lonnet::set_arearole($role,$area,'','',$dcdom,$env{'user.name'});
  982:     my %ccrole = ();
  983:     &Apache::lonnet::standard_roleprivs(\%ccrole,$role,$dcdom,$spec,$pickedcourse,$area);
  984:     my ($author,$adv)= &Apache::lonnet::set_userprivs(\$userroles,\%ccrole);
  985:     my @newprivs = split/\n/,$userroles;
  986:     my %newccroles = ();
  987:     foreach (@newprivs) {
  988:         my ($key,$val) = split/=/,$_;
  989:         $newccroles{$key} = $val;
  990:     }
  991:     &Apache::lonnet::appenv(%newccroles);
  992:     &Apache::lonnet::log($env{'user.domain'},
  993:                          $env{'user.name'},
  994:                          $env{'user.home'},
  995:                         "Role ".$role);
  996:     &Apache::lonnet::appenv(
  997:                           'request.role'        => $role,
  998:                           'request.role.domain' => $dcdom,
  999:                           'request.course.sec'  => '');
 1000:     my $tadv=0;
 1001:     if (&Apache::lonnet::allowed('adv') eq 'F') { $tadv=1; }
 1002:     &Apache::lonnet::appenv('request.role.adv'    => $tadv);
 1003: }
 1004: 
 1005: 1;
 1006: __END__
 1007: 
 1008: =head1 NAME
 1009: 
 1010: Apache::lonroles - User Roles Screen
 1011: 
 1012: =head1 SYNOPSIS
 1013: 
 1014: Invoked by /etc/httpd/conf/srm.conf:
 1015: 
 1016:  <Location /adm/roles>
 1017:  PerlAccessHandler       Apache::lonacc
 1018:  SetHandler perl-script
 1019:  PerlHandler Apache::lonroles
 1020:  ErrorDocument     403 /adm/login
 1021:  ErrorDocument	  500 /adm/errorhandler
 1022:  </Location>
 1023: 
 1024: =head1 OVERVIEW
 1025: 
 1026: =head2 Choosing Roles
 1027: 
 1028: C<lonroles> is a handler that allows a user to switch roles in
 1029: mid-session. LON-CAPA attempts to work with "No Role Specified", the
 1030: default role that a user has before selecting a role, as widely as
 1031: possible, but certain handlers for example need specification which
 1032: course they should act on, etc. Both in this scenario, and when the
 1033: handler determines via C<lonnet>'s C<&allowed> function that a certain
 1034: action is not allowed, C<lonroles> is used as error handler. This
 1035: allows the user to select another role which may have permission to do
 1036: what they were trying to do. C<lonroles> can also be accessed via the
 1037: B<CRS> button in the Remote Control. 
 1038: 
 1039: =begin latex
 1040: 
 1041: \begin{figure}
 1042: \begin{center}
 1043: \includegraphics[width=0.45\paperwidth,keepaspectratio]{Sample_Roles_Screen}
 1044:   \caption{\label{Sample_Roles_Screen}Sample Roles Screen} 
 1045: \end{center}
 1046: \end{figure}
 1047: 
 1048: =end latex
 1049: 
 1050: =head2 Role Initialization
 1051: 
 1052: 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.
 1053: 
 1054: =head1 INTRODUCTION
 1055: 
 1056: This module enables a user to select what role he wishes to
 1057: operate under (instructor, student, teaching assistant, course
 1058: coordinator, etc).  These roles are pre-established by the actions
 1059: of upper-level users.
 1060: 
 1061: This is part of the LearningOnline Network with CAPA project
 1062: described at http://www.lon-capa.org.
 1063: 
 1064: =head1 HANDLER SUBROUTINE
 1065: 
 1066: This routine is called by Apache and mod_perl.
 1067: 
 1068: =over 4
 1069: 
 1070: =item *
 1071: 
 1072: Roles Initialization (yes/no)
 1073: 
 1074: =item *
 1075: 
 1076: Get Error Message from Environment
 1077: 
 1078: =item *
 1079: 
 1080: Who is this?
 1081: 
 1082: =item *
 1083: 
 1084: Generate Page Output
 1085: 
 1086: =item *
 1087: 
 1088: Choice or no choice
 1089: 
 1090: =item *
 1091: 
 1092: Table
 1093: 
 1094: =item *
 1095: 
 1096: Privileges
 1097: 
 1098: =back
 1099: 
 1100: =cut

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