Annotation of loncom/auth/lonroles.pm, revision 1.104
1.1 harris41 1: # The LearningOnline Network with CAPA
2: # User Roles Screen
1.31 www 3: #
1.103 raeburn 4: # $Id: lonroles.pm,v 1.102 2004/11/09 15:52:29 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.35 matthew 542: my %newhash=Apache::lonnet::coursedescription
543: ($tcourseid);
544: if (%newhash) {
1.80 albertel 545: $sortkey=$role."\0".$tdom."\0".$newhash{'description'}.
1.77 albertel 546: "\0".$envkey;
1.49 www 547: $twhere=$newhash{'description'}.
548: ' <font size="-2">'.
1.72 www 549: &Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$trest,$tdom,$tfont).
1.49 www 550: '</font>';
1.35 matthew 551: } else {
1.72 www 552: $twhere=&mt('Currently not available');
1.35 matthew 553: $ENV{'course.'.$tcourseid.'.description'}=$twhere;
1.80 albertel 554: $sortkey=$role."\0".$tdom."\0".$twhere."\0".$envkey;
1.35 matthew 555: }
1.8 www 556: }
1.72 www 557: if ($role ne 'st') { $twhere.="<br />".&mt('Domain').":".$tdom; }
1.35 matthew 558: } elsif ($tdom) {
1.78 sakharuk 559: $ttype='Domain';
1.35 matthew 560: $twhere=$tdom;
1.75 albertel 561: $sortkey=$role.$twhere;
1.35 matthew 562: } else {
1.78 sakharuk 563: $ttype='System';
1.72 www 564: $twhere=&mt('system wide');
1.75 albertel 565: $sortkey=$role.$twhere;
1.13 www 566: }
1.35 matthew 567:
1.75 albertel 568: $roletext.='<tr bgcolor='.$tbg.'>';
1.35 matthew 569: unless ($nochoose) {
570: if (!$button) {
1.49 www 571: if ($switchserver) {
1.75 albertel 572: $roletext.='<td><a href="/adm/logout?handover='.
573: $switchserver.'">'.&mt('Switch Server').'</a></td>';
1.49 www 574: } else {
1.75 albertel 575: $roletext.=('<td> </td>');
1.49 www 576: }
1.35 matthew 577: } elsif ($tstatus eq 'is') {
1.75 albertel 578: $roletext.=('<td><input type=submit value="'.
1.72 www 579: &mt('Select').'" name="'.
1.35 matthew 580: $trolecode.'"></td>');
1.61 www 581: } elsif ($tryagain) {
1.75 albertel 582: $roletext.=
583: '<td><input type=submit value="'.
584: &mt('Try Selecting Again').'" name="'.$trolecode.'"></td>';
1.61 www 585: } elsif ($advanced) {
1.75 albertel 586: $roletext.=
587: '<td><input type=submit value="'.
588: &mt('Re-Initialize').'" name="'.$trolecode.'"></td>';
1.35 matthew 589: } else {
1.75 albertel 590: $roletext.='<td> </td>';
1.35 matthew 591: }
1.6 www 592: }
1.57 www 593: $tremark.=&Apache::lonannounce::showday(time,1,
594: &Apache::lonannounce::readcalendar($tdom.'_'.$trest));
595:
1.75 albertel 596: $roletext.='<td><font color="'.$tfont.'">'.$trole.
1.47 www 597: '</font></td><td><font color="'.$tfont.'">'.$ttype.
598: '</font></td><td><font color="'.$tfont.'">'.$twhere.
599: '</font></td><td><font color="'.$tfont.'">'.$tpstart.
600: '</font></td><td><font color="'.$tfont.'">'.$tpend.
601: '</font></td><td><font color="'.$tfont.'">'.$tremark.
1.75 albertel 602: ' </font></td></tr>'."\n";
603: $roletext{$envkey}=$roletext;
604: if (!$sortkey) {$sortkey=$twhere."\0".$envkey;}
605: $sortrole{$sortkey}=$envkey;
606: $roleclass{$envkey}=$ttype;
1.55 albertel 607: }
1.4 www 608: }
1.75 albertel 609: }
1.84 www 610: # No active roles
611: if ($countactive==0) {
612: if ($inrole) {
613: $r->print('<h2>'.&mt('Currently no additional roles or courses').'</h2>');
614: } else {
615: $r->print('<h2>'.&mt('Currently no active roles or courses').'</h2>');
616: }
617: $r->print('</form></body></html>');
618: return OK;
619: # Is there only one choice?
1.88 www 620: } elsif (($countactive==1) && ($ENV{'request.role'} eq 'cm')) {
1.84 www 621: $r->print('<h3>'.&mt('Please stand by.').'</h3>'.
622: '<input type="hidden" name="'.$possiblerole.'" value="1" />');
623: $r->print("</form>\n");
624: $r->rflush();
625: $r->print('<script>document.forms.rolechoice.submit();</script>');
626: $r->print('</body></html>');
627: return OK;
628: }
629: # More than one possible role
630: # ----------------------------------------------------------------------- Table
631: unless (($advanced) || ($nochoose)) {
632: $r->print("<h2>".&mt('Select a Course to Enter')."</h2>\n");
633: }
634: $r->print('<br /><table><tr>');
635: unless ($nochoose) { $r->print('<th> </th>'); }
636: $r->print('<th>'.&mt('User Role').'</th><th colspan=2>'.&mt('Extent').
637: '</th><th>'.&mt('Start').'</th><th>'.&mt('End').'</th><th>'.
1.99 www 638: &mt('Remarks and Calendar Announcements').'</th></tr>'."\n");
1.76 albertel 639: my $doheaders=-1;
1.78 sakharuk 640: foreach my $type ('Construction Space','Course','Domain','System') {
1.76 albertel 641: my $haverole=0;
1.75 albertel 642: foreach my $which (sort {uc($a) cmp uc($b)} (keys(%sortrole))) {
643: if ($roleclass{$sortrole{$which}} =~ /^\Q$type\E/) {
1.76 albertel 644: $haverole=1;
1.75 albertel 645: }
1.76 albertel 646: }
647: if ($haverole) { $doheaders++; }
648: }
1.104 ! raeburn 649: if ($numdc > 0) {
! 650: $r->print('<tr bgcolor="#BBffBB">'.
! 651: '<td align="center" colspan="7">'.
! 652: '<input type="hidden" name="all_cc_roles" value="1"/>'.
! 653: '<input type="hidden" name="dcselected" value=""/>'.
! 654: &mt('Domain').'</td>');
! 655: foreach my $dcdom (keys %dcroles) {
! 656: my $output = $roletext{$dcroles{$dcdom}};
! 657: my $ccrole = Apache::lonnet::plaintext('cc');
! 658: if ($ENV{'request.role'} =~ m-cc\./$dcdom/-) {
! 659: $output.=$roletext{'user.role.'.$ENV{'request.role'}};
! 660: }
! 661: $r->print($output);
! 662: $r->print('<tr bgcolor="#77FF77">');
! 663: $r->print('<td><input type="button" value="'.
! 664: &mt('Select').'" name="dcpick_'.$dcdom.'/" '.
! 665: 'onClick="setDCchoice('."'$dcdom'".')"></td>'.
! 666: '<td><font color="#002200">'.
! 667: $ccrole.'</font></td><td>'.&mt('Course').'</td>'.
! 668: '<td><font color="#002200"><b>'.&mt('All courses').'</b>'.
! 669: '<br />'.&mt('Domain').':'.$dcdom.'</font>'.
! 670: '<td colspan="4"><font color="#002200">'.
! 671: &mt('Course Coordinator access to all courses in domain').
! 672: ': <b>'.$dcdom.'</b></font></td></tr>'."\n");
! 673: }
! 674: foreach my $type ('Construction Space','Course','Domain','System') {
! 675: my $output;
! 676: foreach my $which (sort {uc($a) cmp uc($b)} (keys(%sortrole))) {
! 677: my $skiprole = 0;
! 678: foreach my $dcdom (keys %dcroles) {
! 679: if ($sortrole{$which} =~ m-(dc|cc)\./$dcdom/-) {
! 680: $skiprole = 1;
! 681: last;
! 682: }
! 683: }
! 684: if (($roleclass{$sortrole{$which}} =~ /^\Q$type\E/) && (!$skiprole)) {
! 685: $output.=$roletext{$sortrole{$which}};
! 686: }
! 687: }
! 688: if ($output) {
! 689: if ($doheaders > 0) {
! 690: $r->print("<tr bgcolor='#BBffBB'>".
! 691: "<td align='center' colspan='7'>".&mt($type)."</td>
! 692: ");
! 693: }
! 694: $r->print($output);
! 695: }
! 696: }
! 697: } else {
! 698: foreach my $type ('Construction Space','Course','Domain','System') {
! 699: my $output;
! 700: foreach my $which (sort {uc($a) cmp uc($b)} (keys(%sortrole))) {
! 701: if ($roleclass{$sortrole{$which}} =~ /^\Q$type\E/) {
! 702: $output.=$roletext{$sortrole{$which}};
! 703: }
1.76 albertel 704: }
1.104 ! raeburn 705: if ($output) {
! 706: if ($doheaders > 0) {
! 707: $r->print("<tr bgcolor='#BBffBB'>".
! 708: "<td align='center' colspan='7'>".&mt($type)."</td>");
! 709: }
! 710: $r->print($output);
1.76 albertel 711: }
1.104 ! raeburn 712: }
1.4 www 713: }
1.14 www 714: my $tremark='';
1.47 www 715: my $tfont='#003300';
1.14 www 716: if ($ENV{'request.role'} eq 'cm') {
1.19 www 717: $r->print('<tr bgcolor="#11CC55">');
1.72 www 718: $tremark=&mt('Currently selected. ');
1.47 www 719: $tfont='#002200';
1.14 www 720: } else {
721: $r->print('<tr bgcolor="#77FF77">');
722: }
723: unless ($nochoose) {
1.55 albertel 724: if ($ENV{'request.role'} ne 'cm') {
1.72 www 725: $r->print('<td><input type=submit value="'.
726: &mt('Select').'" name="cm"></td>');
1.55 albertel 727: } else {
728: $r->print('<td> </td>');
729: }
1.14 www 730: }
1.72 www 731: $r->print('<td colspan=5><font color="'.$tfont.'">'.&mt('No role specified').
1.47 www 732: '</font></td><td><font color="'.$tfont.'">'.$tremark.
733: ' </font></td></tr>'."\n");
1.4 www 734:
735: $r->print('</table>');
736: unless ($nochoose) {
737: $r->print("</form>\n");
738: }
1.22 harris41 739: # ------------------------------------------------------------ Privileges Info
1.55 albertel 740: if (($advanced) && (($ENV{'user.error.msg'}) || ($error))) {
741: $r->print('<hr><h2>Current Privileges</h2>');
1.4 www 742:
1.55 albertel 743: foreach $envkey (sort keys %ENV) {
744: if ($envkey=~/^user\.priv\.$ENV{'request.role'}\./) {
745: my $where=$envkey;
746: $where=~s/^user\.priv\.$ENV{'request.role'}\.//;
747: my $ttype;
748: my $twhere;
749: my ($tdom,$trest,$tsec)=
750: split(/\//,Apache::lonnet::declutter($where));
751: if ($trest) {
752: if ($ENV{'course.'.$tdom.'_'.$trest.'.description'} eq 'ca') {
753: $ttype='Construction Space';
754: $twhere='User: '.$trest.', Domain: '.$tdom;
755: } else {
756: $ttype='Course';
757: $twhere=$ENV{'course.'.$tdom.'_'.$trest.'.description'};
758: if ($tsec) {
759: $twhere.=' (Section/Group: '.$tsec.')';
760: }
761: }
762: } elsif ($tdom) {
763: $ttype='Domain';
764: $twhere=$tdom;
765: } else {
766: $ttype='System';
767: $twhere='/';
768: }
769: $r->print("\n<h3>".$ttype.': '.$twhere.'</h3><ul>');
770: foreach (sort split(/:/,$ENV{$envkey})) {
771: if ($_) {
772: my ($prv,$restr)=split(/\&/,$_);
773: my $trestr='';
774: if ($restr ne 'F') {
775: my $i;
776: $trestr.=' (';
777: for ($i=0;$i<length($restr);$i++) {
778: $trestr.=
779: Apache::lonnet::plaintext(substr($restr,$i,1));
780: if ($i<length($restr)-1) { $trestr.=', '; }
781: }
782: $trestr.=')';
783: }
784: $r->print('<li>'.
785: Apache::lonnet::plaintext($prv).$trestr.
786: '</li>');
787: }
788: }
789: $r->print('</ul>');
790: }
791: }
1.4 www 792: }
1.66 www 793: $r->print(&Apache::lonnet::getannounce());
1.65 www 794: if ($advanced) {
795: $r->print('<p><small><i>This is LON-CAPA '.
1.85 www 796: $r->dir_config('lonVersion').'</i><br />'.
797: '<a href="/adm/logout">'.&mt('Logout').'</a></small></p>');
1.65 www 798: }
1.1 harris41 799: $r->print("</body></html>\n");
800: return OK;
1.102 raeburn 801: }
802:
803: sub role_status {
804: my ($rolekey,$then,$now,$role,$where,$trolecode,$tstatus,$tstart,$tend) = @_;
805: my @pwhere = ();
806: if (exists($ENV{$rolekey}) && $ENV{$rolekey} ne '') {
807: (undef,undef,$$role,@pwhere)=split(/\./,$rolekey);
808: unless (!defined($$role) || $$role eq '') {
809: $$where=join('.',@pwhere);
810: $$trolecode=$$role.'.'.$$where;
811: ($$tstart,$$tend)=split(/\./,$ENV{$rolekey});
812: $$tstatus='is';
813: if ($$tstart) {
814: if ($$tstart>$then) {
815: $$tstatus='future';
816: if ($$tstart<$now) { $$tstatus='will'; }
817: }
818: }
819: if ($$tend) {
820: if ($$tend<$then) {
821: $$tstatus='expired';
1.103 raeburn 822: } elsif ($$tend<$now) {
1.104 ! raeburn 823: $$tstatus='will_not';
1.102 raeburn 824: }
825: }
826: }
827: }
828: }
1.1 harris41 829:
1.104 ! raeburn 830: sub dc_script {
! 831: my $response = (<<"END");
! 832: function setDCchoice(caller) {
! 833: var dcname = "dc./"+caller+"/"
! 834: document.rolechoice.dcselected.value = caller
! 835: document.rolechoice.elements[3].name = dcname
! 836: document.rolechoice.submit()
! 837: }
! 838: END
! 839: return $response;
! 840: }
! 841:
! 842: sub check_fordc {
! 843: my ($dcroles,$then) = @_;
! 844: my $numdc = 0;
! 845: if ($ENV{'user.adv'}) {
! 846: foreach my $envkey (sort keys %ENV) {
! 847: if ($envkey=~/^user\.role\.dc\.\/(\w+)\/$/) {
! 848: my $dcdom = $1;
! 849: my $livedc = 1;
! 850: my ($tstart,$tend)=split(/\./,$ENV{$envkey});
! 851: if ($tstart) {
! 852: if ($tstart>$then) {
! 853: $livedc = 0;
! 854: }
! 855: }
! 856: if ($tend) {
! 857: if ($tend<$then) {
! 858: $livedc = 0;
! 859: }
! 860: }
! 861: if ($livedc) {
! 862: $$dcroles{$dcdom} = $envkey;
! 863: $numdc ++;
! 864: }
! 865: }
! 866: }
! 867: }
! 868: return $numdc;
! 869: }
! 870:
! 871: sub choosecourse_display {
! 872: my ($r,$dcdom,$then,$now) = @_;
! 873: my $cb_jscript = &Apache::loncommon::coursebrowser_javascript($dcdom,'dom');
! 874: my $verify_script = <<"END";
! 875: <script>
! 876: function verifyCoursePick() {
! 877: var pickedCourse = document.roles.dccourse.value
! 878: var pickedDomain = document.roles.dcdomain.value
! 879: if (document.roles.dcdomain.value == document.roles.origdom.value) {
! 880: if (pickedCourse != '') {
! 881: var courseTarget = "cc./"+pickedDomain+"/"+pickedCourse
! 882: document.roles.elements[0].value = 1
! 883: document.roles.elements[0].name = courseTarget
! 884: document.roles.selectrole.value = 1
! 885: document.roles.submit()
! 886: }
! 887: else {
! 888: 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");
! 889: }
! 890: }
! 891: else {
! 892: alert("You can only use this screen to select courses in the current domain")
! 893: }
! 894: }
! 895: </script>
! 896: END
! 897: my $courseform=&Apache::loncommon::selectcourse_link
! 898: ('roles','dccourse','dcdomain','coursedesc');
! 899: $r->print($cb_jscript.$verify_script);
! 900: my $formaction='/adm/roles';
! 901: $formaction=~s/\/+/\//g;
! 902: my $crs;
! 903: &select_recent_courses($r,$dcdom,$then,$now);
! 904: $r->print('<br /><form name="roles" method="post" action="'.$formaction.'" />');
! 905: $r->print('<h3>'.&mt('Choose a course from domain').': '.$dcdom.'</h3><font size="+1">'.$courseform.'</font><br /><br />'.
! 906: '<input type="hidden" name="chosencourse" value=""/>'.
! 907: 'Course Title: <input type="text" size="20" name="coursedesc" value=""><br />'.
! 908: 'Course ID: <input type="text" size="15" name="dccourse" />'.
! 909: '<input type="hidden" name="dcdomain" value="'.$dcdom.'" />'.
! 910: '<input type="hidden" name="origdom" value="'.$dcdom.'" />'.
! 911: '<input type="hidden" name="selectrole" value="" />'.
! 912: '<br /><br /><input type="button" name="proceed" value="'.&mt('Enter this course').'" onClick="verifyCoursePick()" />'.
! 913: '</form>');
! 914: return;
! 915: }
! 916:
! 917: sub select_recent_courses {
! 918: my ($r,$dcdom,$then,$now)=@_;
! 919: my $advanced = $ENV{'user.adv'};
! 920: my $tryagain = $ENV{'form.tryagain'};
! 921: my %recent=&Apache::lonnet::dump(&recent_filename('cc_pickby_dc_'.$dcdom));
! 922: my $numrecent = 0;
! 923: my $roletext = '<h3>'.&mt('Enter a recently visited course').'</h3>'.
! 924: '<form name="rolechoice" action="/adm/roles" method="post">'.
! 925: '<table><tr><th> </th>'.
! 926: '<th>'.&mt('User Role').'</th><th colspan=2>'.&mt('Extent').
! 927: '</th><th>'.&mt('Start').'</th><th>'.&mt('End').'</th><th>'.
! 928: &mt('Remarks and Calendar Announcements').'</th></tr>'."\n".
! 929: '<tr bgcolor="#BBffBB">'.
! 930: '<td align="center" colspan="7">'.
! 931: &mt('Domain').' - '.&mt('Recent courses accessed in this domain').
! 932: '</td></tr>'."\n";
! 933: foreach my $courseid (sort keys %recent) {
! 934: unless ($courseid =~/^error\:/) {
! 935: my ($dom,$crs) = split/_/,$courseid;
! 936: if ($dom eq $dcdom) {
! 937: $numrecent ++;
! 938: my $crskey = 'user.role.cc./'.$dom.'/'.$crs;
! 939: my ($where,$trolecode,$role,$tstatus,$tend,$tstart,$tbg,$tfont,$tremark,$inrole,$tpstart,$tpend);
! 940: my $button = 1;
! 941: &role_status($crskey,$then,$now,\$role,\$where,\$trolecode,\$tstatus,\$tstart,\$tend);
! 942: if ($tstart) {
! 943: $tpstart=&Apache::lonlocal::locallocaltime($tstart);
! 944: }
! 945: if ($tend) {
! 946: $tpend=&Apache::lonlocal::locallocaltime($tend);
! 947: }
! 948: my $ttype = &mt('Course');
! 949: my $twhere;
! 950: if ($ENV{'course.'.$courseid.'.description'}) {
! 951: $twhere=$ENV{'course.'.$courseid.'.description'};
! 952: }
! 953: my ($tdom,$trest,$tsection)=
! 954: split(/\//,Apache::lonnet::declutter($where));
! 955: if ($ENV{'request.role'} eq $trolecode) {
! 956: $tstatus='selected';
! 957: }
! 958: if ($tstatus eq 'is') {
! 959: $tbg='#77FF77';
! 960: $tfont='#003300';
! 961: } elsif ($tstatus eq 'future') {
! 962: $tbg='#FFFF77';
! 963: $button=0;
! 964: } elsif ($tstatus eq 'will') {
! 965: $tbg='#FFAA77';
! 966: $tremark.=&mt('Active at next login. ');
! 967: } elsif ($tstatus eq 'expired') {
! 968: $tbg='#FF7777';
! 969: $tfont='#330000';
! 970: $button=0;
! 971: } elsif ($tstatus eq 'will_not') {
! 972: $tbg='#AAFF77';
! 973: $tremark.=&mt('Expired after logout. ');
! 974: } elsif ($tstatus eq 'selected') {
! 975: $tbg='#11CC55';
! 976: $tfont='#002200';
! 977: $inrole=1;
! 978: $tremark.=&mt('Currently selected. ');
! 979: }
! 980: my $trole=Apache::lonnet::plaintext($role);
! 981: $roletext.='<tr bgcolor='.$tbg.'>';
! 982: if (!$button) {
! 983: $roletext.=('<td> </td>');
! 984: } elsif ($tstatus eq 'is') {
! 985: $roletext.=('<td><input type=submit value="'.
! 986: &mt('Select').'" name="'.
! 987: $trolecode.'"></td>');
! 988: } elsif ($tryagain) {
! 989: $roletext.=
! 990: '<td><input type=submit value="'.
! 991: &mt('Try Selecting Again').'" name="'.$trolecode.'"></td>';
! 992: } elsif ($advanced) {
! 993: $roletext.=
! 994: '<td><input type=submit value="'.
! 995: &mt('Re-Initialize').'" name="'.$trolecode.'"></td>';
! 996: } else {
! 997: $roletext.='<td> </td>';
! 998: }
! 999: $tremark.=&Apache::lonannounce::showday(time,1,
! 1000: &Apache::lonannounce::readcalendar($tdom.'_'.$trest));
! 1001:
! 1002: $roletext.='<td><font color="'.$tfont.'">'.$trole.
! 1003: '</font></td><td><font color="'.$tfont.'">'.$ttype.
! 1004: '</font></td><td><font color="'.$tfont.'">'.$twhere.
! 1005: '</font></td><td><font color="'.$tfont.'">'.$tpstart.
! 1006: '</font></td><td><font color="'.$tfont.'">'.$tpend.
! 1007: '</font></td><td><font color="'.$tfont.'">'.$tremark.
! 1008: ' </font></td></tr>'."\n";
! 1009: }
! 1010: }
! 1011: }
! 1012: if ($numrecent > 0) {
! 1013: $r->print($roletext.'</table><input type="hidden" '.
! 1014: 'name="selectrole" value="1" /></form>'."\n");
! 1015: }
! 1016: }
! 1017:
! 1018: sub recent_filename {
! 1019: my $area=shift;
! 1020: return 'nohist_recent_'.&Apache::lonnet::escape($area);
! 1021: }
! 1022:
1.1 harris41 1023: 1;
1024: __END__
1.32 harris41 1025:
1026: =head1 NAME
1027:
1028: Apache::lonroles - User Roles Screen
1029:
1030: =head1 SYNOPSIS
1031:
1032: Invoked by /etc/httpd/conf/srm.conf:
1033:
1034: <Location /adm/roles>
1035: PerlAccessHandler Apache::lonacc
1036: SetHandler perl-script
1037: PerlHandler Apache::lonroles
1038: ErrorDocument 403 /adm/login
1039: ErrorDocument 500 /adm/errorhandler
1040: </Location>
1.64 bowersj2 1041:
1042: =head1 OVERVIEW
1043:
1044: =head2 Choosing Roles
1045:
1046: C<lonroles> is a handler that allows a user to switch roles in
1047: mid-session. LON-CAPA attempts to work with "No Role Specified", the
1048: default role that a user has before selecting a role, as widely as
1049: possible, but certain handlers for example need specification which
1050: course they should act on, etc. Both in this scenario, and when the
1051: handler determines via C<lonnet>'s C<&allowed> function that a certain
1052: action is not allowed, C<lonroles> is used as error handler. This
1053: allows the user to select another role which may have permission to do
1054: what they were trying to do. C<lonroles> can also be accessed via the
1055: B<CRS> button in the Remote Control.
1056:
1057: =begin latex
1058:
1059: \begin{figure}
1060: \begin{center}
1061: \includegraphics[width=0.45\paperwidth,keepaspectratio]{Sample_Roles_Screen}
1062: \caption{\label{Sample_Roles_Screen}Sample Roles Screen}
1063: \end{center}
1064: \end{figure}
1065:
1066: =end latex
1067:
1068: =head2 Role Initialization
1069:
1070: 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 1071:
1072: =head1 INTRODUCTION
1073:
1074: This module enables a user to select what role he wishes to
1075: operate under (instructor, student, teaching assistant, course
1076: coordinator, etc). These roles are pre-established by the actions
1077: of upper-level users.
1078:
1079: This is part of the LearningOnline Network with CAPA project
1080: described at http://www.lon-capa.org.
1081:
1082: =head1 HANDLER SUBROUTINE
1083:
1084: This routine is called by Apache and mod_perl.
1085:
1086: =over 4
1087:
1088: =item *
1089:
1090: Roles Initialization (yes/no)
1091:
1092: =item *
1093:
1094: Get Error Message from Environment
1095:
1096: =item *
1097:
1098: Who is this?
1099:
1100: =item *
1101:
1102: Generate Page Output
1103:
1104: =item *
1105:
1106: Choice or no choice
1107:
1108: =item *
1109:
1110: Table
1111:
1112: =item *
1113:
1114: Privileges
1115:
1116: =back
1117:
1118: =cut
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>