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