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