File:  [LON-CAPA] / loncom / auth / lonroles.pm
Revision 1.127: download - view: text, annotated - select for diffs
Wed Jul 13 19:56:17 2005 UTC (18 years, 10 months ago) by albertel
Branches: MAIN
CVS tags: version_1_99_2, HEAD
- taking out the highlighting code
- recentering the 'realm' dividers

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

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