Annotation of loncom/auth/lonroles.pm, revision 1.269.2.1
1.1 harris41 1: # The LearningOnline Network with CAPA
2: # User Roles Screen
1.31 www 3: #
1.269.2.1! raeburn 4: # $Id: lonroles.pm,v 1.269 2012/07/21 21:09:03 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.210 jms 30: =pod
31:
32: =head1 NAME
33:
34: Apache::lonroles - User Roles Screen
35:
36: =head1 SYNOPSIS
37:
38: Invoked by /etc/httpd/conf/srm.conf:
39:
40: <Location /adm/roles>
41: PerlAccessHandler Apache::lonacc
42: SetHandler perl-script
43: PerlHandler Apache::lonroles
44: ErrorDocument 403 /adm/login
45: ErrorDocument 500 /adm/errorhandler
46: </Location>
47:
48: =head1 OVERVIEW
49:
50: =head2 Choosing Roles
51:
52: C<lonroles> is a handler that allows a user to switch roles in
53: mid-session. LON-CAPA attempts to work with "No Role Specified", the
54: default role that a user has before selecting a role, as widely as
55: possible, but certain handlers for example need specification which
56: course they should act on, etc. Both in this scenario, and when the
57: handler determines via C<lonnet>'s C<&allowed> function that a certain
58: action is not allowed, C<lonroles> is used as error handler. This
59: allows the user to select another role which may have permission to do
1.246 droeschl 60: what they were trying to do.
1.210 jms 61:
62: =begin latex
63:
64: \begin{figure}
65: \begin{center}
66: \includegraphics[width=0.45\paperwidth,keepaspectratio]{Sample_Roles_Screen}
67: \caption{\label{Sample_Roles_Screen}Sample Roles Screen}
68: \end{center}
69: \end{figure}
70:
71: =end latex
72:
73: =head2 Role Initialization
74:
75: 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.
76:
77: =head1 INTRODUCTION
78:
79: This module enables a user to select what role he wishes to
80: operate under (instructor, student, teaching assistant, course
81: coordinator, etc). These roles are pre-established by the actions
82: of upper-level users.
83:
84: This is part of the LearningOnline Network with CAPA project
85: described at http://www.lon-capa.org.
86:
87: =head1 HANDLER SUBROUTINE
88:
89: This routine is called by Apache and mod_perl.
90:
91: =over 4
92:
93: =item *
94:
95: Roles Initialization (yes/no)
96:
97: =item *
98:
99: Get Error Message from Environment
100:
101: =item *
102:
103: Who is this?
104:
105: =item *
106:
107: Generate Page Output
108:
109: =item *
110:
111: Choice or no choice
112:
113: =item *
114:
115: Table
116:
117: =item *
118:
119: Privileges
120:
121: =back
122:
123: =cut
124:
125:
1.1 harris41 126: package Apache::lonroles;
127:
128: use strict;
1.118 albertel 129: use Apache::lonnet;
1.7 www 130: use Apache::lonuserstate();
1.1 harris41 131: use Apache::Constants qw(:common);
1.2 www 132: use Apache::File();
1.26 www 133: use Apache::lonmenu;
1.29 albertel 134: use Apache::loncommon;
1.104 raeburn 135: use Apache::lonhtmlcommon;
1.57 www 136: use Apache::lonannounce;
1.72 www 137: use Apache::lonlocal;
1.151 www 138: use Apache::lonpageflip();
1.167 albertel 139: use Apache::lonnavdisplay();
1.241 raeburn 140: use Apache::loncoursequeueadmin;
1.120 albertel 141: use GDBM_File;
1.170 albertel 142: use LONCAPA qw(:DEFAULT :match);
1.201 raeburn 143: use HTML::Entities;
1.149 www 144:
1.1 harris41 145:
1.62 matthew 146: sub redirect_user {
1.245 droeschl 147: my ($r,$title,$url,$msg) = @_;
1.62 matthew 148: $msg = $title if (! defined($msg));
1.73 www 149: &Apache::loncommon::content_type($r,'text/html');
1.62 matthew 150: &Apache::loncommon::no_cache($r);
151: $r->send_http_header;
1.269.2.1! raeburn 152: my $swinfo=&Apache::lonmenu::rawconfig();
1.228 bisitz 153:
154: # Breadcrumbs
155: my $brcrum = [{'href' => $url,
156: 'text' => 'Switching Role'},];
1.147 albertel 157: my $start_page = &Apache::loncommon::start_page('Switching Role',undef,
1.228 bisitz 158: {'redirect' => [1,$url],
159: 'bread_crumbs' => $brcrum,});
1.147 albertel 160: my $end_page = &Apache::loncommon::end_page();
161:
1.92 www 162: # Note to style police:
163: # This must only replace the spaces, nothing else, or it bombs elsewhere.
164: $url=~s/ /\%20/g;
1.93 albertel 165: $r->print(<<ENDREDIR);
1.147 albertel 166: $start_page
1.269.2.1! raeburn 167: <script type="text/javascript">
! 168: // <![CDATA[
! 169: $swinfo
! 170: // ]]>
! 171: </script>
1.222 bisitz 172: <p>$msg</p>
1.147 albertel 173: $end_page
1.62 matthew 174: ENDREDIR
175: return;
176: }
177:
1.150 www 178: sub error_page {
179: my ($r,$error,$dest)=@_;
180: &Apache::loncommon::content_type($r,'text/html');
181: &Apache::loncommon::no_cache($r);
182: $r->send_http_header;
183: return OK if $r->header_only;
1.228 bisitz 184: # Breadcrumbs
185: my $brcrum = [{'href' => $dest,
186: 'text' => 'Problems during Course Initialization'},];
187: $r->print(&Apache::loncommon::start_page('Problems during Course Initialization',
188: undef,
189: {'bread_crumbs' => $brcrum,})
190: );
191: $r->print(
1.225 bisitz 192: '<script type="text/javascript">'.
193: '// <![CDATA['.
194: &Apache::lonmenu::rawconfig().
195: '// ]]>'.
196: '</script>'.
197: '<p class="LC_error">'.&mt('The following problems occurred:').
1.228 bisitz 198: '<br />'.
1.150 www 199: $error.
1.228 bisitz 200: '</p><br /><a href="'.$dest.'">'.&mt('Continue').'</a>'
201: );
202: $r->print(&Apache::loncommon::end_page());
1.150 www 203: }
204:
1.1 harris41 205: sub handler {
1.10 www 206:
1.1 harris41 207: my $r = shift;
208:
1.6 www 209: my $now=time;
1.118 albertel 210: my $then=$env{'user.login.time'};
1.226 raeburn 211: my $refresh=$env{'user.refresh.time'};
1.260 raeburn 212: my $update=$env{'user.update.time'};
1.226 raeburn 213: if (!$refresh) {
214: $refresh = $then;
215: }
1.260 raeburn 216: if (!$update) {
217: $update = $then;
218: }
219:
220: # -------------------------------------------------------- Check for new roles
221: my $updateresult;
222: if ($env{'form.doupdate'}) {
223: my $show_course=&Apache::loncommon::show_course();
224: my $checkingtxt;
225: if ($show_course) {
226: $checkingtxt = &mt('Checking for new courses ...');
227: } else {
228: $checkingtxt = &mt('Checking for new roles ...');
229: }
1.264 raeburn 230: $updateresult = '<span class="LC_info">'.$checkingtxt.'</span>';
1.260 raeburn 231: $updateresult .= &update_session_roles();
232: &Apache::lonnet::appenv({'user.update.time' => $now});
233: $update = $now;
234: }
235:
1.6 www 236: my $envkey;
1.107 raeburn 237: my %dcroles = ();
1.260 raeburn 238: my $numdc = &check_fordc(\%dcroles,$update,$then);
1.148 albertel 239: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'});
1.255 raeburn 240: my $loncaparev = $Apache::lonnet::perlvar{'lonVersion'};
1.10 www 241:
1.6 www 242: # ================================================================== Roles Init
1.118 albertel 243: if ($env{'form.selectrole'}) {
1.188 www 244:
245: my $locknum=&Apache::lonnet::get_locks();
246: if ($locknum) { return 409; }
247:
1.134 www 248: if ($env{'form.newrole'}) {
249: $env{'form.'.$env{'form.newrole'}}=1;
250: }
1.118 albertel 251: if ($env{'request.course.id'}) {
1.185 raeburn 252: # Check if user is CC trying to select a course role
253: if ($env{'form.switchrole'}) {
1.252 raeburn 254: my $switch_is_active;
255: if (defined($env{'user.role.'.$env{'form.switchrole'}})) {
256: my ($start,$end) = split(/\./,$env{'user.role.'.$env{'form.switchrole'}});
257: if (!$end || $end > $now) {
1.260 raeburn 258: if (!$start || $start < $update) {
1.252 raeburn 259: $switch_is_active = 1;
260: }
261: }
262: }
263: unless ($switch_is_active) {
1.260 raeburn 264: &adhoc_course_role($refresh,$update,$then);
1.185 raeburn 265: }
266: }
1.118 albertel 267: my %temp=('logout_'.$env{'request.course.id'} => time);
1.33 www 268: &Apache::lonnet::put('email_status',\%temp);
1.118 albertel 269: &Apache::lonnet::delenv('user.state.'.$env{'request.course.id'});
1.100 albertel 270: }
1.186 raeburn 271: &Apache::lonnet::appenv({"request.course.id" => '',
272: "request.course.fn" => '',
273: "request.course.uri" => '',
274: "request.course.sec" => '',
1.269 raeburn 275: "request.course.tied" => '',
1.186 raeburn 276: "request.role" => 'cm',
277: "request.role.adv" => $env{'user.adv'},
278: "request.role.domain" => $env{'user.domain'}});
1.182 www 279: # Check if user is a DC trying to enter a course or author space and needs privs to be created
1.107 raeburn 280: if ($numdc > 0) {
1.118 albertel 281: foreach my $envkey (keys %env) {
1.240 raeburn 282: # Is this an ad-hoc Coordinator role?
283: if (my ($ccrole,$domain,$coursenum) =
284: ($envkey =~ m-^form\.(cc|co)\./($match_domain)/($match_courseid)$-)) {
1.146 raeburn 285: if ($dcroles{$domain}) {
1.218 raeburn 286: &Apache::lonnet::check_adhoc_privs($domain,$coursenum,
1.260 raeburn 287: $update,$refresh,$now,$ccrole);
1.182 www 288: }
289: last;
290: }
1.193 raeburn 291: # Is this an ad-hoc CA-role?
1.183 www 292: if (my ($domain,$user) =
293: ($envkey =~ m-^form\.ca\./($match_domain)/($match_username)$-)) {
1.206 raeburn 294: if (($domain eq $env{'user.domain'}) && ($user eq $env{'user.name'})) {
295: delete($env{$envkey});
296: $env{'form.au./'.$domain.'/'} = 1;
297: my ($server_status,$home) = &check_author_homeserver($user,$domain);
298: if ($server_status eq 'switchserver') {
299: my $trolecode = 'au./'.$domain.'/';
1.248 raeburn 300: my $switchserver = '/adm/switchserver?otherserver='.$home.'&role='.$trolecode;
1.206 raeburn 301: $r->internal_redirect($switchserver);
302: }
303: last;
304: }
305: if (my ($castart,$caend) = ($env{'user.role.ca./'.$domain.'/'.$user} =~ /^(\d*)\.(\d*)$/)) {
306: if (((($castart) && ($castart < $now)) || !$castart) &&
307: ((!$caend) || (($caend) && ($caend > $now)))) {
308: my ($server_status,$home) = &check_author_homeserver($user,$domain);
309: if ($server_status eq 'switchserver') {
310: my $trolecode = 'ca./'.$domain.'/'.$user;
1.248 raeburn 311: my $switchserver = '/adm/switchserver?otherserver='.$home.'&role='.$trolecode;
1.206 raeburn 312: $r->internal_redirect($switchserver);
313: }
314: last;
315: }
316: }
317: # Check if author blocked ca-access
1.190 www 318: my %blocked=&Apache::lonnet::get('environment',['domcoord.author'],$domain,$user);
319: if ($blocked{'domcoord.author'} eq 'blocked') {
1.206 raeburn 320: delete($env{$envkey});
321: $env{'user.error.msg'}=':::1:User '.$user.' in domain '.$domain.' blocked domain coordinator access';
322: last;
1.190 www 323: }
1.193 raeburn 324: if ($dcroles{$domain}) {
325: my ($server_status,$home) = &check_author_homeserver($user,$domain);
326: if (($server_status eq 'ok') || ($server_status eq 'switchserver')) {
1.260 raeburn 327: &Apache::lonnet::check_adhoc_privs($domain,$user,$update,
1.230 raeburn 328: $refresh,$now,'ca');
1.193 raeburn 329: if ($server_status eq 'switchserver') {
330: my $trolecode = 'ca./'.$domain.'/'.$user;
331: my $switchserver = '/adm/switchserver?'
1.248 raeburn 332: .'otherserver='.$home.'&role='.$trolecode;
1.193 raeburn 333: $r->internal_redirect($switchserver);
334: }
335: } else {
336: delete($env{$envkey});
337: }
1.183 www 338: } else {
339: delete($env{$envkey});
1.182 www 340: }
341: last;
342: }
1.107 raeburn 343: }
344: }
345:
1.118 albertel 346: foreach $envkey (keys %env) {
1.40 matthew 347: next if ($envkey!~/^user\.role\./);
1.102 raeburn 348: my ($where,$trolecode,$role,$tstatus,$tend,$tstart);
1.260 raeburn 349: &Apache::lonnet::role_status($envkey,$update,$refresh,$now,\$role,\$where,
1.218 raeburn 350: \$trolecode,\$tstatus,\$tstart,\$tend);
1.118 albertel 351: if ($env{'form.'.$trolecode}) {
1.55 albertel 352: if ($tstatus eq 'is') {
353: $where=~s/^\///;
354: my ($cdom,$cnum,$csec)=split(/\//,$where);
1.255 raeburn 355: if (($cnum) && ($role ne 'ca') && ($role ne 'aa')) {
356: my $home = $env{'course.'.$cdom.'_'.$cnum.'.home'};
357: my @ids = &Apache::lonnet::current_machine_ids();
358: unless ($loncaparev eq '' && $home && grep(/^\Q$home\E$/,@ids)) {
359: my %curr_reqd_hash = &Apache::lonnet::userenvironment($cdom,$cnum,'internal.releaserequired');
1.256 raeburn 360: if ($curr_reqd_hash{'internal.releaserequired'} ne '') {
1.255 raeburn 361: my ($switchserver,$switchwarning) =
362: &check_release_required($loncaparev,$cdom.'_'.$cnum,$trolecode,$curr_reqd_hash{'internal.releaserequired'});
1.256 raeburn 363: if ($switchwarning ne '' || $switchserver ne '') {
364: &Apache::loncommon::content_type($r,'text/html');
365: &Apache::loncommon::no_cache($r);
366: $r->send_http_header;
367: my $end_page=&Apache::loncommon::end_page();
368: $r->print(&Apache::loncommon::start_page('Selected course unavailable on this server').
369: '<p class="LC_warning">');
370: if ($switchwarning) {
371: $r->print($switchwarning.'<br /><a href="/adm/roles">');
372: if (&Apache::loncommon::show_course()) {
373: $r->print(&mt('Display courses'));
374: } else {
375: $r->print(&mt('Display roles'));
376: }
377: $r->print('</a>');
378: } elsif ($switchserver) {
379: $r->print(&mt('This course requires a newer version of LON-CAPA than is installed on this server.').
380: '<br />'.
381: '<a href="/adm/switchserver?'.$switchserver.'">'.
382: &mt('Switch Server').
383: '</a>');
1.255 raeburn 384: }
1.256 raeburn 385: $r->print('</p>'.&Apache::loncommon::end_page());
386: return OK;
1.255 raeburn 387: }
388: }
389: }
390: }
1.137 raeburn 391: # check for course groups
392: my %coursegroups = &Apache::lonnet::get_active_groups(
393: $env{'user.domain'},$env{'user.name'},$cdom, $cnum);
394: my $cgrps = join(':',keys(%coursegroups));
395:
1.111 albertel 396: # store role if recent_role list being kept
1.118 albertel 397: if ($env{'environment.recentroles'}) {
1.158 albertel 398: my %frozen_roles =
399: &Apache::lonhtmlcommon::get_recent_frozen('roles',$env{'environment.recentrolesn'});
1.111 albertel 400: &Apache::lonhtmlcommon::store_recent('roles',
1.158 albertel 401: $trolecode,' ',$frozen_roles{$trolecode});
1.111 albertel 402: }
403:
404:
1.53 www 405: # check for keyed access
1.55 albertel 406: if (($role eq 'st') &&
1.118 albertel 407: ($env{'course.'.$cdom.'_'.$cnum.'.keyaccess'} eq 'yes')) {
1.89 www 408: # who is key authority?
409: my $authdom=$cdom;
410: my $authnum=$cnum;
1.118 albertel 411: if ($env{'course.'.$cdom.'_'.$cnum.'.keyauth'}) {
1.89 www 412: ($authnum,$authdom)=
1.172 albertel 413: split(/:/,$env{'course.'.$cdom.'_'.$cnum.'.keyauth'});
1.89 www 414: }
415: # check with key authority
416: unless (&Apache::lonnet::validate_access_key(
1.118 albertel 417: $env{'environment.key.'.$cdom.'_'.$cnum},
1.89 www 418: $authdom,$authnum)) {
1.53 www 419: # there is no valid key
1.118 albertel 420: if ($env{'form.newkey'}) {
1.53 www 421: # student attempts to register a new key
1.89 www 422: &Apache::loncommon::content_type($r,'text/html');
423: &Apache::loncommon::no_cache($r);
424: $r->send_http_header;
425: my $swinfo=&Apache::lonmenu::rawconfig();
1.147 albertel 426: my $start_page=&Apache::loncommon::start_page
1.89 www 427: ('Verifying Access Key to Unlock this Course');
1.147 albertel 428: my $end_page=&Apache::loncommon::end_page();
1.90 www 429: my $buttontext=&mt('Enter Course');
430: my $message=&mt('Successfully registered key');
431: my $assignresult=
432: &Apache::lonnet::assign_access_key(
1.118 albertel 433: $env{'form.newkey'},
1.90 www 434: $authdom,$authnum,
1.91 www 435: $cdom,$cnum,
1.118 albertel 436: $env{'user.domain'},
437: $env{'user.name'},
1.204 bisitz 438: &mt('Assigned from [_1] at [_2] for [_3]'
439: ,$ENV{'REMOTE_ADDR'}
440: ,&Apache::lonlocal::locallocaltime()
441: ,$trolecode)
442: );
1.90 www 443: unless ($assignresult eq 'ok') {
444: $assignresult=~s/^error\:\s*//;
445: $message=&mt($assignresult).
446: '<br /><a href="/adm/logout">'.
1.89 www 447: &mt('Logout').'</a>';
1.90 www 448: $buttontext=&mt('Re-Enter Key');
449: }
1.89 www 450: $r->print(<<ENDENTEREDKEY);
1.147 albertel 451: $start_page
1.179 raeburn 452: <script type="text/javascript">
1.225 bisitz 453: // <![CDATA[
1.89 www 454: $swinfo
1.225 bisitz 455: // ]]>
1.89 www 456: </script>
1.225 bisitz 457: <form action="" method="post">
1.89 www 458: <input type="hidden" name="selectrole" value="1" />
459: <input type="hidden" name="$trolecode" value="1" />
1.211 tempelho 460: <span class="LC_fontsize_large">$message</span><br />
1.89 www 461: <input type="submit" value="$buttontext" />
462: </form>
1.147 albertel 463: $end_page
1.89 www 464: ENDENTEREDKEY
465: return OK;
1.55 albertel 466: } else {
1.53 www 467: # print form to enter a new key
1.73 www 468: &Apache::loncommon::content_type($r,'text/html');
1.55 albertel 469: &Apache::loncommon::no_cache($r);
470: $r->send_http_header;
471: my $swinfo=&Apache::lonmenu::rawconfig();
1.147 albertel 472: my $start_page=&Apache::loncommon::start_page
1.55 albertel 473: ('Enter Access Key to Unlock this Course');
1.147 albertel 474: my $end_page=&Apache::loncommon::end_page();
1.55 albertel 475: $r->print(<<ENDENTERKEY);
1.147 albertel 476: $start_page
1.179 raeburn 477: <script type="text/javascript">
1.225 bisitz 478: // <![CDATA[
1.53 www 479: $swinfo
1.225 bisitz 480: // ]]>
1.53 www 481: </script>
1.225 bisitz 482: <form action="" method="post">
1.89 www 483: <input type="hidden" name="selectrole" value="1" />
484: <input type="hidden" name="$trolecode" value="1" />
1.118 albertel 485: <input type="text" size="20" name="newkey" value="$env{'form.newkey'}" />
1.53 www 486: <input type="submit" value="Enter key" />
487: </form>
1.147 albertel 488: $end_page
1.53 www 489: ENDENTERKEY
1.55 albertel 490: return OK;
491: }
492: }
493: }
1.118 albertel 494: &Apache::lonnet::log($env{'user.domain'},
495: $env{'user.name'},
496: $env{'user.home'},
1.87 www 497: "Role ".$trolecode);
1.101 albertel 498:
1.56 www 499: &Apache::lonnet::appenv(
1.186 raeburn 500: {'request.role' => $trolecode,
501: 'request.role.domain' => $cdom,
502: 'request.course.sec' => $csec,
503: 'request.course.groups' => $cgrps});
1.101 albertel 504: my $tadv=0;
1.62 matthew 505:
1.125 www 506: if (($cnum) && ($role ne 'ca') && ($role ne 'aa')) {
1.152 raeburn 507: my $msg;
1.55 albertel 508: my ($furl,$ferr)=
509: &Apache::lonuserstate::readmap($cdom.'/'.$cnum);
1.118 albertel 510: if (($env{'form.orgurl'}) &&
511: ($env{'form.orgurl'}!~/^\/adm\/flip/)) {
512: my $dest=$env{'form.orgurl'};
1.219 raeburn 513: if ($env{'form.symb'}) {
514: if ($dest =~ /\?/) {
515: $dest .= '&';
516: } else {
517: $dest .= '?'
518: }
519: $dest .= 'symb='.$env{'form.symb'};
520: }
1.117 albertel 521: if (&Apache::lonnet::allowed('adv') eq 'F') { $tadv=1; }
1.186 raeburn 522: &Apache::lonnet::appenv({'request.role.adv'=>$tadv});
1.150 www 523: if (($ferr) && ($tadv)) {
524: &error_page($r,$ferr,$dest);
525: } else {
1.255 raeburn 526: if ($dest =~ m{^/adm/coursedocs\?folderpath}) {
527: if ($env{'request.course.id'} eq $cdom.'_'.$cnum) {
528: my $chome = &Apache::lonnet::homeserver($cnum,$cdom);
1.268 raeburn 529: &Apache::loncommon::update_content_constraints($cdom,$cnum,$chome,
530: $cdom.'_'.$cnum);
1.255 raeburn 531: }
532: }
1.150 www 533: $r->internal_redirect($dest);
534: }
1.55 albertel 535: return OK;
536: } else {
1.155 albertel 537: if (!$env{'request.course.id'}) {
1.55 albertel 538: &Apache::lonnet::appenv(
1.186 raeburn 539: {"request.course.id" => $cdom.'_'.$cnum});
1.61 www 540: $furl='/adm/roles?tryagain=1';
1.221 bisitz 541: $msg='<p><span class="LC_error">'
542: .&mt('Could not initialize [_1] at this time.',
543: $env{'course.'.$cdom.'_'.$cnum.'.description'})
544: .'</span></p>'
545: .'<p>'.&mt('Please try again.').'</p>'
546: .'<p>'.$ferr.'</p>';
1.55 albertel 547: }
1.117 albertel 548: if (&Apache::lonnet::allowed('adv') eq 'F') { $tadv=1; }
1.186 raeburn 549: &Apache::lonnet::appenv({'request.role.adv'=>$tadv});
1.152 raeburn 550:
1.150 www 551: if (($ferr) && ($tadv)) {
552: &error_page($r,$ferr,$furl);
553: } else {
554: # Check to see if the user is a CC entering a course
555: # for the first time
556: my (undef, undef, $role, $courseid) = split(/\./, $envkey);
557: if (substr($courseid, 0, 1) eq '/') {
558: $courseid = substr($courseid, 1);
559: }
560: $courseid =~ s/\//_/;
1.240 raeburn 561: if ((($role eq 'cc') || ($role eq 'co'))
562: && ($env{'course.' . $courseid .'.course.helper.not.run'})) {
1.150 www 563: $furl = "/adm/helper/course.initialization.helper";
564: # Send the user to the course they selected
565: } elsif ($env{'request.course.id'}) {
1.185 raeburn 566: if ($env{'form.destinationurl'}) {
567: my $dest = $env{'form.destinationurl'};
1.203 raeburn 568: if ($env{'form.destsymb'} ne '') {
569: my $esc_symb = &HTML::Entities::encode($env{'form.destsymb'},'"<>&');
570: $dest .= '?symb='.$esc_symb;
571: }
1.245 droeschl 572: &redirect_user($r, &mt('Entering [_1]',
573: $env{'course.'.$courseid.'.description'}),
574: $dest, $msg);
1.185 raeburn 575: return OK;
576: }
1.150 www 577: if (&Apache::lonnet::allowed('whn',
578: $env{'request.course.id'})
579: || &Apache::lonnet::allowed('whn',
580: $env{'request.course.id'}.'/'
581: .$env{'request.course.sec'})
582: ) {
583: my $startpage = &courseloadpage($courseid);
584: unless ($startpage eq 'firstres') {
1.204 bisitz 585: $msg = &mt('Entering [_1] ...',
1.162 albertel 586: $env{'course.'.$courseid.'.description'});
1.245 droeschl 587: &redirect_user($r, &mt('New in course'),
588: '/adm/whatsnew?refpage=start', $msg);
1.150 www 589: return OK;
590: }
591: }
592: }
1.151 www 593: # Are we allowed to look at the first resource?
1.169 albertel 594: if ($furl !~ m|^/adm/|) {
1.151 www 595: # Guess not ...
596: $furl=&Apache::lonpageflip::first_accessible_resource();
597: }
1.162 albertel 598: $msg = &mt('Entering [_1] ...',
599: $env{'course.'.$courseid.'.description'});
1.245 droeschl 600: &redirect_user($r, &mt('Entering [_1]',
601: $env{'course.'.$courseid.'.description'}),
602: $furl, $msg);
1.58 bowersj2 603: }
1.124 albertel 604: return OK;
1.55 albertel 605: }
606: }
1.62 matthew 607: #
608: # Send the user to the construction space they selected
1.125 www 609: if ($role =~ /^(au|ca|aa)$/) {
1.62 matthew 610: my $redirect_url = '/priv/';
611: if ($role eq 'au') {
1.262 www 612: $redirect_url.=$env{'user.domain'}.'/'.$env{'user.name'};
1.62 matthew 613: } else {
1.263 www 614: $redirect_url .= $where;
1.62 matthew 615: }
616: $redirect_url .= '/';
1.78 sakharuk 617: &redirect_user($r,&mt('Entering Construction Space'),
1.62 matthew 618: $redirect_url);
619: return OK;
620: }
1.104 raeburn 621: if ($role eq 'dc') {
1.108 raeburn 622: my $redirect_url = '/adm/menu/';
623: &redirect_user($r,&mt('Loading Domain Coordinator Menu'),
1.104 raeburn 624: $redirect_url);
1.108 raeburn 625: return OK;
1.104 raeburn 626: }
1.220 raeburn 627: if ($role eq 'sc') {
628: my $redirect_url = '/adm/grades?command=scantronupload';
629: &redirect_user($r,&mt('Loading Data Upload Page'),
630: $redirect_url);
631: return OK;
632: }
1.55 albertel 633: }
634: }
1.6 www 635: }
1.40 matthew 636: }
1.44 www 637:
1.10 www 638:
1.6 www 639: # =============================================================== No Roles Init
1.10 www 640:
1.73 www 641: &Apache::loncommon::content_type($r,'text/html');
1.30 albertel 642: &Apache::loncommon::no_cache($r);
1.10 www 643: $r->send_http_header;
644: return OK if $r->header_only;
645:
1.224 raeburn 646: my $crumbtext = 'User Roles';
647: my $pagetitle = 'My Roles';
648: my $recent = &mt('Recent Roles');
649: my $show_course=&Apache::loncommon::show_course();
650: if ($show_course) {
651: $crumbtext = 'Courses';
652: $pagetitle = 'My Courses';
653: $recent = &mt('Recent Courses');
654: }
655: my $brcrum =[{href=>"/adm/roles",text=>$crumbtext}];
1.52 www 656: my $swinfo=&Apache::lonmenu::rawconfig();
1.224 raeburn 657: my $start_page=&Apache::loncommon::start_page($pagetitle,undef,{bread_crumbs=>$brcrum});
1.134 www 658: my $standby=&mt('Role selected. Please stand by.');
1.135 albertel 659: $standby=~s/\n/\\n/g;
1.184 raeburn 660: my $noscript='<span class="LC_error">'.&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.').'<br />'.&mt('As this is not the case, most functionality in the system will be unavailable.').'</span><br />';
1.163 www 661:
1.10 www 662: $r->print(<<ENDHEADER);
1.147 albertel 663: $start_page
1.163 www 664: <br />
1.179 raeburn 665: <noscript>
666: $noscript
667: </noscript>
668: <script type="text/javascript">
1.225 bisitz 669: // <![CDATA[
1.26 www 670: $swinfo
671: window.focus();
1.134 www 672:
673: active=true;
674:
675: function enterrole (thisform,rolecode,buttonname) {
676: if (active) {
677: active=false;
678: document.title='$standby';
679: window.status='$standby';
680: thisform.newrole.value=rolecode;
681: thisform.submit();
682: } else {
683: alert('$standby');
1.260 raeburn 684: }
685: }
686:
687: function setToUpdate(thisform) {
688: thisform.doupdate.value='1';
689: thisform.selectrole.value='';
690: thisform.submit();
1.134 www 691: }
1.260 raeburn 692:
1.225 bisitz 693: // ]]>
1.26 www 694: </script>
1.10 www 695: ENDHEADER
1.6 www 696:
1.2 www 697: # ------------------------------------------ Get Error Message from Environment
698:
1.118 albertel 699: my ($fn,$priv,$nochoose,$error,$msg)=split(/:/,$env{'user.error.msg'});
700: if ($env{'user.error.msg'}) {
1.55 albertel 701: $r->log_reason(
1.118 albertel 702: "$msg for $env{'user.name'} domain $env{'user.domain'} access $priv",$fn);
1.12 www 703: }
1.1 harris41 704:
1.61 www 705: # ------------------------------------------------- Can this user re-init, etc?
1.6 www 706:
1.118 albertel 707: my $advanced=$env{'user.adv'};
1.61 www 708: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['tryagain']);
1.118 albertel 709: my $tryagain=$env{'form.tryagain'};
1.209 raeburn 710: my $reinit=$env{'user.reinit'};
711: delete $env{'user.reinit'};
1.6 www 712:
1.2 www 713: # -------------------------------------------------------- Generate Page Output
1.6 www 714: # --------------------------------------------------------------- Error Header?
1.2 www 715: if ($error) {
1.187 bisitz 716: $r->print("<h1>".&mt('LON-CAPA Access Control')."</h1>");
1.174 albertel 717: $r->print("<!-- LONCAPAACCESSCONTROLERRORSCREEN --><hr /><pre>");
718: if ($priv ne '') {
1.187 bisitz 719: $r->print(&mt('Access : ').&Apache::lonnet::plaintext($priv)."\n");
1.174 albertel 720: }
721: if ($fn ne '') {
1.187 bisitz 722: $r->print(&mt('Resource: ').&Apache::lonenc::check_encrypt($fn)."\n");
1.174 albertel 723: }
724: if ($msg ne '') {
1.187 bisitz 725: $r->print(&mt('Action : ').$msg."\n");
1.174 albertel 726: }
727: $r->print("</pre><hr />");
1.120 albertel 728: my $url=$fn;
729: my $last;
730: if (tie(my %hash,'GDBM_File',$env{'request.course.fn'}.'_symb.db',
731: &GDBM_READER(),0640)) {
732: $last=$hash{'last_known'};
733: untie(%hash);
734: }
1.149 www 735: if ($last) { $fn.='?symb='.&escape($last); }
1.120 albertel 736:
737: &Apache::londocs::changewarning($r,undef,'You have modified your course recently, [_1] may fix this access problem.',
738: &Apache::lonenc::check_encrypt($fn));
1.2 www 739: } else {
1.118 albertel 740: if ($env{'user.error.msg'}) {
1.209 raeburn 741: if ($reinit) {
742: $r->print(
743: '<h3><span class="LC_error">'.
1.234 raeburn 744: &mt('As your session file for the course or community has expired, you will need to re-select it.').'</span></h3>');
1.209 raeburn 745: } else {
746: $r->print(
1.157 albertel 747: '<h3><span class="LC_error">'.
1.235 bisitz 748: &mt('You need to choose another user role or enter a specific course or community for this function.').
749: '</span></h3>');
1.209 raeburn 750: }
751: }
1.2 www 752: }
753: if ($nochoose) {
1.177 www 754: $r->print("<h2>".&mt('Sorry ...')."</h2>\n<span class='LC_error'>".
755: &mt('This action is currently not authorized.').'</span>'.
1.150 www 756: &Apache::loncommon::end_page());
757: return OK;
1.6 www 758: } else {
1.260 raeburn 759: $r->print($updateresult);
1.18 www 760: if (($ENV{'REDIRECT_QUERY_STRING'}) && ($fn)) {
761: $fn.='?'.$ENV{'REDIRECT_QUERY_STRING'};
1.6 www 762: }
1.84 www 763: $r->print('<form method="post" name="rolechoice" action="'.(($fn)?$fn:$r->uri).'">');
1.116 albertel 764: $r->print('<input type="hidden" name="orgurl" value="'.$fn.'" />');
765: $r->print('<input type="hidden" name="selectrole" value="1" />');
1.134 www 766: $r->print('<input type="hidden" name="newrole" value="" />');
1.6 www 767: }
1.259 raeburn 768: $r->rflush();
1.226 raeburn 769:
770: my (%roletext,%sortrole,%roleclass,%futureroles,%timezones);
771: my ($countactive,$countfuture,$inrole,$possiblerole) =
1.260 raeburn 772: &gather_roles($update,$refresh,$now,$reinit,$nochoose,\%roletext,\%sortrole,\%roleclass,
1.254 raeburn 773: \%futureroles,\%timezones,$loncaparev);
1.226 raeburn 774: $refresh = $now;
775: &Apache::lonnet::appenv({'user.refresh.time' => $refresh});
1.260 raeburn 776: my $updatebutton = &mt('Check for role changes');
777: my $show_course=&Apache::loncommon::show_course();
778: if ($show_course) {
779: $updatebutton = &mt('Check for new courses');
780: }
781: my $do_update;
782: unless (($env{'form.source'} eq 'login') || ($env{'form.doupdate'})) {
783: $do_update = '<input type="hidden" name="doupdate" value="" />'.
784: '<input type="button" name="update" value="'.
785: $updatebutton.'" onclick="javascript:setToUpdate(this.form)" />';
786: }
1.196 raeburn 787: if ($env{'user.adv'}) {
1.260 raeburn 788: my $showall = '<label><input type="checkbox" name="showall"';
789: if ($env{'form.showall'}) {
790: $showall .= ' checked="checked" ';
791: }
1.264 raeburn 792: $showall .= ' />'.&mt('Show all roles').'</label> '.
1.260 raeburn 793: '<input type="submit" value="'.&mt('Update display').'" />';
794: if ($do_update) {
795: $r->print('<div class="LC_left_float"><fieldset>'.
796: '<legend>'. &mt('Display').'</legend>'.
797: $showall.'</fieldset></div>'.
798: '<div class="LC_left_float"><fieldset><legend>'.
799: &mt('Changes?').'</legend>'.
800: $do_update.'</fieldset></div><br clear="all" />');
801: } else {
802: $r->print($showall);
803: }
1.196 raeburn 804: } else {
1.260 raeburn 805: $r->print('<p>'.$do_update.'</p>');
1.196 raeburn 806: if ($countactive > 0) {
1.241 raeburn 807: $r->print(&Apache::loncoursequeueadmin::queued_selfenrollment());
1.196 raeburn 808: my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description');
1.201 raeburn 809: my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&');
1.233 bisitz 810: $r->print(
811: '<p>'
812: .&mt('[_1]Visit the [_2]Course/Community Catalog[_3]'
813: .' to view all [_4] LON-CAPA courses and communities.'
814: ,'<b>'
815: ,'<a href="/adm/coursecatalog?showdom='.$esc_dom.'">'
816: ,'</a></b>',$domdesc)
817: .'<br />'
1.235 bisitz 818: .&mt('If a course or community is [_1]not[_2] in your list of current courses and communities below,'
1.233 bisitz 819: .' you may be able to enroll if self-enrollment is permitted.'
820: ,'<b>','</b>')
821: .'</p>'
822: );
1.196 raeburn 823: }
824: }
825:
1.84 www 826: # No active roles
827: if ($countactive==0) {
828: if ($inrole) {
1.234 raeburn 829: $r->print('<h2>'.&mt('Currently no additional roles, courses or communities').'</h2>');
1.84 www 830: } else {
1.234 raeburn 831: $r->print('<h2>'.&mt('Currently no active roles, courses or communities').'</h2>');
1.84 www 832: }
1.191 raeburn 833: &findcourse_advice($r);
1.234 raeburn 834: &requestcourse_advice($r);
1.191 raeburn 835: $r->print('</form>');
836: if ($countfuture) {
837: $r->print(&mt('The following [quant,_1,role,roles] will become active in the future:',$countfuture));
838: my $doheaders = &roletable_headers($r,\%roleclass,\%sortrole,
839: $nochoose);
840: &print_rolerows($r,$doheaders,\%roleclass,\%sortrole,\%dcroles,
841: \%roletext);
842: my $tremark='';
1.212 bisitz 843: my $tbg;
1.191 raeburn 844: if ($env{'request.role'} eq 'cm') {
1.212 bisitz 845: $tbg="LC_roles_selected";
1.204 bisitz 846: $tremark=&mt('Currently selected.').' ';
1.191 raeburn 847: } else {
1.212 bisitz 848: $tbg="LC_roles_is";
1.191 raeburn 849: }
1.212 bisitz 850: $r->print(&Apache::loncommon::start_data_table_row()
851: .'<td class="'.$tbg.'"> </td>'
852: .'<td colspan="3">'
853: .&mt('No role specified')
854: .'</td>'
855: .'<td>'.$tremark.' </td>'
856: .&Apache::loncommon::end_data_table_row()
857: );
1.191 raeburn 858:
1.212 bisitz 859: $r->print(&Apache::loncommon::end_data_table());
1.191 raeburn 860: }
861: $r->print(&Apache::loncommon::end_page());
1.84 www 862: return OK;
863: }
864: # ----------------------------------------------------------------------- Table
1.247 raeburn 865:
866: if ($numdc > 0) {
867: $r->print(&coursepick_jscript());
868: $r->print(&Apache::loncommon::coursebrowser_javascript().
869: &Apache::loncommon::authorbrowser_javascript());
870: }
871:
1.224 raeburn 872: unless ((!&Apache::loncommon::show_course()) || ($nochoose) || ($countactive==1)) {
1.173 albertel 873: $r->print("<h2>".&mt('Select a Course to Enter')."</h2>\n");
1.84 www 874: }
1.229 raeburn 875: if ($env{'form.destinationurl'}) {
876: $r->print('<input type="hidden" name="destinationurl" value="'.
877: $env{'form.destinationurl'}.'" />');
878: if ($env{'form.destsymb'} ne '') {
879: $r->print('<input type="hidden" name="destsymb" value="'.
880: $env{'form.destsymb'}.'" />');
881: }
882: }
1.247 raeburn 883:
1.191 raeburn 884: my $doheaders = &roletable_headers($r,\%roleclass,\%sortrole,$nochoose);
1.118 albertel 885: if ($env{'environment.recentroles'}) {
1.111 albertel 886: my %recent_roles =
1.118 albertel 887: &Apache::lonhtmlcommon::get_recent('roles',$env{'environment.recentrolesn'});
1.111 albertel 888: my $output='';
1.247 raeburn 889: foreach my $role (sort(keys(%recent_roles))) {
890: if (ref($roletext{'user.role.'.$role}) eq 'ARRAY') {
1.223 raeburn 891: $output.= &Apache::loncommon::start_data_table_row().
1.247 raeburn 892: $roletext{'user.role.'.$role}->[0].
1.223 raeburn 893: &Apache::loncommon::end_data_table_row();
1.249 raeburn 894: if ($roletext{'user.role.'.$role}->[1] ne '') {
895: $output .= &Apache::loncommon::continue_data_table_row().
896: $roletext{'user.role.'.$role}->[1].
897: &Apache::loncommon::end_data_table_row();
898: }
1.247 raeburn 899: if ($role =~ m{dc\./($match_domain)/}
1.170 albertel 900: && $dcroles{$1}) {
1.192 raeburn 901: $output .= &adhoc_roles_row($1,'recent');
1.133 albertel 902: }
1.113 raeburn 903: } elsif ($numdc > 0) {
1.247 raeburn 904: unless ($role =~/^error\:/) {
1.249 raeburn 905: my ($roletext,$role_text_end) = &display_cc_role('user.role.'.$role);
1.259 raeburn 906: if ($roletext) {
907: $output.= &Apache::loncommon::start_data_table_row().
908: $roletext.
909: &Apache::loncommon::end_data_table_row();
910: if ($role_text_end) {
911: $output .= &Apache::loncommon::continue_data_table_row().
912: $role_text_end.
913: &Apache::loncommon::end_data_table_row();
914: }
915: }
1.113 raeburn 916: }
1.247 raeburn 917: }
1.111 albertel 918: }
919: if ($output) {
1.212 bisitz 920: $r->print(&Apache::loncommon::start_data_table_empty_row()
921: .'<td align="center" colspan="5">'
1.224 raeburn 922: .$recent
1.212 bisitz 923: .'</td>'
924: .&Apache::loncommon::end_data_table_empty_row()
925: );
1.111 albertel 926: $r->print($output);
1.114 raeburn 927: $doheaders ++;
1.111 albertel 928: }
929: }
1.191 raeburn 930: &print_rolerows($r,$doheaders,\%roleclass,\%sortrole,\%dcroles,\%roletext);
1.202 raeburn 931: if ($countactive > 1) {
932: my $tremark='';
1.212 bisitz 933: my $tbg;
1.202 raeburn 934: if ($env{'request.role'} eq 'cm') {
1.212 bisitz 935: $tbg="LC_roles_selected";
1.204 bisitz 936: $tremark=&mt('Currently selected.').' ';
1.202 raeburn 937: } else {
1.212 bisitz 938: $tbg="LC_roles_is";
1.202 raeburn 939: }
1.212 bisitz 940: $r->print(&Apache::loncommon::start_data_table_row());
1.202 raeburn 941: unless ($nochoose) {
942: if ($env{'request.role'} ne 'cm') {
1.212 bisitz 943: $r->print('<td class="'.$tbg.'"><input type="submit" value="'.
1.202 raeburn 944: &mt('Select').'" name="cm" /></td>');
945: } else {
1.212 bisitz 946: $r->print('<td class="'.$tbg.'"> </td>');
1.202 raeburn 947: }
948: }
1.212 bisitz 949: $r->print('<td colspan="3">'
950: .&mt('No role specified')
951: .'</td>'
952: .'<td>'.$tremark.' </td>'
953: .&Apache::loncommon::end_data_table_row()
954: );
1.202 raeburn 955: }
1.212 bisitz 956: $r->print(&Apache::loncommon::end_data_table());
1.4 www 957: unless ($nochoose) {
958: $r->print("</form>\n");
959: }
1.22 harris41 960: # ------------------------------------------------------------ Privileges Info
1.118 albertel 961: if (($advanced) && (($env{'user.error.msg'}) || ($error))) {
1.212 bisitz 962: $r->print('<hr /><h2>'.&mt('Current Privileges').'</h2>');
1.175 albertel 963: $r->print(&privileges_info());
1.4 www 964: }
1.267 bisitz 965: my $announcements = &Apache::lonnet::getannounce();
966: $r->print(
967: '<br />'.
968: '<h2>'.&mt('Announcements').'</h2>'.
969: $announcements
970: ) unless (!$announcements);
1.65 www 971: if ($advanced) {
1.201 raeburn 972: my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&');
1.231 bisitz 973: $r->print('<p><small><i>'
974: .&mt('This LON-CAPA server is version [_1]',$r->dir_config('lonVersion'))
975: .'</i><br />'
976: .'<a href="/adm/logout">'.&mt('Logout').'</a> '
1.201 raeburn 977: .'<a href="/adm/coursecatalog?showdom='.$esc_dom.'">'
1.233 bisitz 978: .&mt('Course/Community Catalog')
1.225 bisitz 979: .'</a></small></p>');
1.65 www 980: }
1.147 albertel 981: $r->print(&Apache::loncommon::end_page());
1.1 harris41 982: return OK;
1.102 raeburn 983: }
984:
1.226 raeburn 985: sub gather_roles {
1.260 raeburn 986: my ($update,$refresh,$now,$reinit,$nochoose,$roletext,$sortrole,$roleclass,$futureroles,$timezones,$loncaparev) = @_;
1.226 raeburn 987: my ($countactive,$countfuture,$inrole,$possiblerole) = (0,0,0,'');
988: my $advanced = $env{'user.adv'};
989: my $tryagain = $env{'form.tryagain'};
1.254 raeburn 990: my @ids = &Apache::lonnet::current_machine_ids();
1.226 raeburn 991: foreach my $envkey (sort(keys(%env))) {
992: my $button = 1;
993: my $switchserver='';
1.254 raeburn 994: my $switchwarning;
1.226 raeburn 995: my ($role_text,$role_text_end,$sortkey);
996: if ($envkey=~/^user\.role\./) {
997: my ($role,$where,$trolecode,$tstart,$tend,$tremark,$tstatus,$tpstart,$tpend);
1.260 raeburn 998: &Apache::lonnet::role_status($envkey,$update,$refresh,$now,\$role,\$where,
1.226 raeburn 999: \$trolecode,\$tstatus,\$tstart,\$tend);
1000: next if (!defined($role) || $role eq '' || $role =~ /^gr/);
1001: $tremark='';
1002: $tpstart=' ';
1003: $tpend=' ';
1004: if ($env{'request.role'} eq $trolecode) {
1005: $tstatus='selected';
1006: }
1007: my $tbg;
1008: if (($tstatus eq 'is')
1009: || ($tstatus eq 'selected')
1010: || ($tstatus eq 'future')
1011: || ($env{'form.showall'})) {
1.259 raeburn 1012: my $timezone = &role_timezone($where,$timezones);
1013: if ($tstart) {
1014: $tpstart=&Apache::lonlocal::locallocaltime($tstart,$timezone);
1015: }
1016: if ($tend) {
1017: $tpend=&Apache::lonlocal::locallocaltime($tend,$timezone);
1018: }
1.226 raeburn 1019: if ($tstatus eq 'is') {
1020: $tbg='LC_roles_is';
1021: $possiblerole=$trolecode;
1022: $countactive++;
1023: } elsif ($tstatus eq 'future') {
1024: $tbg='LC_roles_future';
1025: $button=0;
1026: $futureroles->{$trolecode} = $tstart.':'.$tend;
1027: $countfuture ++;
1028: } elsif ($tstatus eq 'expired') {
1029: $tbg='LC_roles_expired';
1030: $button=0;
1031: } elsif ($tstatus eq 'will_not') {
1032: $tbg='LC_roles_will_not';
1033: $tremark.=&mt('Expired after logout.').' ';
1034: } elsif ($tstatus eq 'selected') {
1035: $tbg='LC_roles_selected';
1036: $inrole=1;
1037: $countactive++;
1038: $tremark.=&mt('Currently selected.').' ';
1039: }
1040: my $trole;
1041: if ($role =~ /^cr\//) {
1042: my ($rdummy,$rdomain,$rauthor,$rrole)=split(/\//,$role);
1043: if ($tremark) { $tremark.='<br />'; }
1.253 bisitz 1044: $tremark.=&mt('Customrole defined by [_1].',$rauthor.':'.$rdomain);
1.226 raeburn 1045: }
1046: $trole=Apache::lonnet::plaintext($role);
1047: my $ttype;
1048: my $twhere;
1049: my ($tdom,$trest,$tsection)=
1050: split(/\//,Apache::lonnet::declutter($where));
1051: # First, Co-Authorship roles
1052: if (($role eq 'ca') || ($role eq 'aa')) {
1053: my $home = &Apache::lonnet::homeserver($trest,$tdom);
1054: my $allowed=0;
1055: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
1056: if (!$allowed) {
1057: $button=0;
1.248 raeburn 1058: $switchserver='otherserver='.$home.'&role='.$trolecode;
1.226 raeburn 1059: }
1060: #next if ($home eq 'no_host');
1061: $home = &Apache::lonnet::hostname($home);
1062: $ttype='Construction Space';
1063: $twhere=&mt('User').': '.$trest.'<br />'.&mt('Domain').
1064: ': '.$tdom.'<br />'.
1065: ' '.&mt('Server').': '.$home;
1066: $env{'course.'.$tdom.'_'.$trest.'.description'}='ca';
1067: $tremark.=&Apache::lonhtmlcommon::authorbombs('/res/'.$tdom.'/'.$trest.'/');
1068: $sortkey=$role."$trest:$tdom";
1069: } elsif ($role eq 'au') {
1070: # Authors
1071: my $home = &Apache::lonnet::homeserver
1072: ($env{'user.name'},$env{'user.domain'});
1073: my $allowed=0;
1074: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
1075: if (!$allowed) {
1076: $button=0;
1.248 raeburn 1077: $switchserver='otherserver='.$home.'&role='.$trolecode;
1.226 raeburn 1078: }
1079: #next if ($home eq 'no_host');
1080: $home = &Apache::lonnet::hostname($home);
1081: $ttype='Construction Space';
1082: $twhere=&mt('Domain').': '.$tdom.'<br />'.&mt('Server').
1083: ': '.$home;
1084: $env{'course.'.$tdom.'_'.$trest.'.description'}='ca';
1085: $tremark.=&Apache::lonhtmlcommon::authorbombs('/res/'.$tdom.'/'.$env{'user.name'}.'/');
1086: $sortkey=$role;
1087: } elsif ($trest) {
1088: my $tcourseid=$tdom.'_'.$trest;
1089: $ttype = &Apache::loncommon::course_type($tcourseid);
1.242 raeburn 1090: $trole = &Apache::lonnet::plaintext($role,$ttype,$tcourseid);
1.226 raeburn 1091: if ($env{'course.'.$tcourseid.'.description'}) {
1.254 raeburn 1092: my $home=$env{'course.'.$tcourseid.'.home'};
1.226 raeburn 1093: $twhere=$env{'course.'.$tcourseid.'.description'};
1094: $sortkey=$role."\0".$tdom."\0".$twhere."\0".$envkey;
1.248 raeburn 1095: $twhere = &HTML::Entities::encode($twhere,'"<>&');
1.226 raeburn 1096: unless ($twhere eq &mt('Currently not available')) {
1097: $twhere.=' <span class="LC_fontsize_small">'.
1098: &Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$trest,$tdom).
1099: '</span>';
1.254 raeburn 1100: unless ($home && grep(/^\Q$home\E$/,@ids) && $loncaparev eq '') {
1.255 raeburn 1101: my $required = $env{'course.'.$tcourseid.'.internal.releaserequired'};
1.259 raeburn 1102: if ($required ne '') {
1103: ($switchserver,$switchwarning) =
1104: &check_release_required($loncaparev,$tcourseid,$trolecode,$required);
1105: if ($switchserver || $switchwarning) {
1106: $button = 0;
1107: }
1.254 raeburn 1108: }
1109: }
1.226 raeburn 1110: }
1111: } else {
1112: my %newhash=&Apache::lonnet::coursedescription($tcourseid);
1113: if (%newhash) {
1114: $sortkey=$role."\0".$tdom."\0".$newhash{'description'}.
1115: "\0".$envkey;
1.248 raeburn 1116: $twhere=&HTML::Entities::encode($newhash{'description'},'"<>&').
1117: ' <span class="LC_fontsize_small">'.
1118: &Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$trest,$tdom).
1119: '</span>';
1.226 raeburn 1120: $ttype = $newhash{'type'};
1.243 raeburn 1121: $trole = &Apache::lonnet::plaintext($role,$ttype,$tcourseid);
1.254 raeburn 1122: my $home = $newhash{'home'};
1123: unless ($home && grep(/^\Q$home\E$/,@ids) && $loncaparev eq '') {
1.255 raeburn 1124: my $required = $newhash{'internal.releaserequired'};
1.259 raeburn 1125: if ($required ne '') {
1126: ($switchserver,$switchwarning) =
1127: &check_release_required($loncaparev,$tcourseid,$trolecode,$required);
1128: if ($switchserver || $switchwarning) {
1129: $button = 0;
1130: }
1.254 raeburn 1131: }
1132: }
1.226 raeburn 1133: } else {
1134: $twhere=&mt('Currently not available');
1135: $env{'course.'.$tcourseid.'.description'}=$twhere;
1136: $sortkey=$role."\0".$tdom."\0".$twhere."\0".$envkey;
1137: $ttype = 'Unavailable';
1138: }
1139: }
1140: if ($tsection) {
1141: $twhere.='<br />'.&mt('Section').': '.$tsection;
1142: }
1143: if ($role ne 'st') { $twhere.="<br />".&mt('Domain').":".$tdom; }
1144: } elsif ($tdom) {
1145: $ttype='Domain';
1146: $twhere=$tdom;
1147: $sortkey=$role.$twhere;
1148: } else {
1149: $ttype='System';
1150: $twhere=&mt('system wide');
1151: $sortkey=$role.$twhere;
1152: }
1153: ($role_text,$role_text_end) =
1154: &build_roletext($trolecode,$tdom,$trest,$tstatus,$tryagain,
1155: $advanced,$tremark,$tbg,$trole,$twhere,$tpstart,
1.254 raeburn 1156: $tpend,$nochoose,$button,$switchserver,$reinit,$switchwarning);
1.226 raeburn 1157: $roletext->{$envkey}=[$role_text,$role_text_end];
1158: if (!$sortkey) {$sortkey=$twhere."\0".$envkey;}
1159: $sortrole->{$sortkey}=$envkey;
1160: $roleclass->{$envkey}=$ttype;
1161: }
1162: }
1163: }
1164: return ($countactive,$countfuture,$inrole,$possiblerole);
1165: }
1166:
1.215 raeburn 1167: sub role_timezone {
1168: my ($where,$timezones) = @_;
1169: my $timezone;
1170: if (ref($timezones) eq 'HASH') {
1171: if ($where =~ m{^/($match_domain)/($match_courseid)}) {
1172: my $cdom = $1;
1173: my $cnum = $2;
1174: if ($cdom && $cnum) {
1175: if (!exists($timezones->{$cdom.'_'.$cnum})) {
1.259 raeburn 1176: my $tz;
1177: if ($env{'course.'.$cdom.'_'.$cnum.'.description'}) {
1178: $tz = $env{'course.'.$cdom.'_'.$cnum.'.timezone'};
1179: } else {
1180: my %timehash =
1181: &Apache::lonnet::get('environment',['timezone'],$cdom,$cnum);
1182: $tz = $timehash{'timezone'};
1183: }
1184: if ($tz eq '') {
1.215 raeburn 1185: if (!exists($timezones->{$cdom})) {
1186: my %domdefaults =
1187: &Apache::lonnet::get_domain_defaults($cdom);
1188: if ($domdefaults{'timezone_def'} eq '') {
1189: $timezones->{$cdom} = 'local';
1190: } else {
1191: $timezones->{$cdom} = $domdefaults{'timezone_def'};
1192: }
1193: }
1194: $timezones->{$cdom.'_'.$cnum} = $timezones->{$cdom};
1195: } else {
1196: $timezones->{$cdom.'_'.$cnum} =
1.259 raeburn 1197: &Apache::lonlocal::gettimezone($tz);
1.215 raeburn 1198: }
1199: }
1200: $timezone = $timezones->{$cdom.'_'.$cnum};
1201: }
1202: } else {
1203: my ($tdom) = ($where =~ m{^/($match_domain)});
1204: if ($tdom) {
1205: if (!exists($timezones->{$tdom})) {
1206: my %domdefaults = &Apache::lonnet::get_domain_defaults($tdom);
1207: if ($domdefaults{'timezone_def'} eq '') {
1208: $timezones->{$tdom} = 'local';
1209: } else {
1210: $timezones->{$tdom} = $domdefaults{'timezone_def'};
1211: }
1212: }
1213: $timezone = $timezones->{$tdom};
1214: }
1215: }
1216: if ($timezone eq 'local') {
1217: $timezone = undef;
1218: }
1219: }
1220: return $timezone;
1221: }
1222:
1.191 raeburn 1223: sub roletable_headers {
1224: my ($r,$roleclass,$sortrole,$nochoose) = @_;
1225: my $doheaders;
1226: if ((ref($sortrole) eq 'HASH') && (ref($roleclass) eq 'HASH')) {
1.212 bisitz 1227: $r->print('<br />'
1228: .&Apache::loncommon::start_data_table()
1229: .&Apache::loncommon::start_data_table_header_row()
1230: );
1.191 raeburn 1231: if (!$nochoose) { $r->print('<th> </th>'); }
1.212 bisitz 1232: $r->print('<th>'.&mt('User Role').'</th>'
1233: .'<th>'.&mt('Extent').'</th>'
1234: .'<th>'.&mt('Start').'</th>'
1235: .'<th>'.&mt('End').'</th>'
1236: .&Apache::loncommon::end_data_table_header_row()
1237: );
1.191 raeburn 1238: $doheaders=-1;
1239: my @roletypes = &roletypes();
1240: foreach my $type (@roletypes) {
1241: my $haverole=0;
1242: foreach my $which (sort {uc($a) cmp uc($b)} (keys(%{$sortrole}))) {
1243: if ($roleclass->{$sortrole->{$which}} =~ /^\Q$type\E/) {
1244: $haverole=1;
1245: }
1246: }
1247: if ($haverole) { $doheaders++; }
1248: }
1249: }
1250: return $doheaders;
1251: }
1252:
1253: sub roletypes {
1.237 raeburn 1254: my @types = ('Domain','Construction Space','Course','Community','Unavailable','System');
1.191 raeburn 1255: return @types;
1256: }
1257:
1258: sub print_rolerows {
1259: my ($r,$doheaders,$roleclass,$sortrole,$dcroles,$roletext) = @_;
1260: if ((ref($roleclass) eq 'HASH') && (ref($sortrole) eq 'HASH')) {
1261: my @types = &roletypes();
1262: foreach my $type (@types) {
1263: my $output;
1264: foreach my $which (sort {uc($a) cmp uc($b)} (keys(%{$sortrole}))) {
1265: if ($roleclass->{$sortrole->{$which}} =~ /^\Q$type\E/) {
1266: if (ref($roletext) eq 'HASH') {
1.223 raeburn 1267: if (ref($roletext->{$sortrole->{$which}}) eq 'ARRAY') {
1268: $output.= &Apache::loncommon::start_data_table_row().
1269: $roletext->{$sortrole->{$which}}->[0].
1270: &Apache::loncommon::end_data_table_row();
1.251 raeburn 1271: if ($roletext->{$sortrole->{$which}}->[1] ne '') {
1272: $output .= &Apache::loncommon::continue_data_table_row().
1273: $roletext->{$sortrole->{$which}}->[1].
1274: &Apache::loncommon::end_data_table_row();
1275: }
1.223 raeburn 1276: }
1.191 raeburn 1277: if ($sortrole->{$which} =~ m-dc\./($match_domain)/-) {
1278: if (ref($dcroles) eq 'HASH') {
1279: if ($dcroles->{$1}) {
1.192 raeburn 1280: $output .= &adhoc_roles_row($1,'');
1.191 raeburn 1281: }
1282: }
1283: }
1284: }
1285: }
1286: }
1287: if ($output) {
1288: if ($doheaders > 0) {
1.212 bisitz 1289: $r->print(&Apache::loncommon::start_data_table_empty_row()
1290: .'<td align="center" colspan="5">'
1291: .&mt($type)
1292: .'</td>'
1293: .&Apache::loncommon::end_data_table_empty_row()
1294: );
1.191 raeburn 1295: }
1296: $r->print($output);
1297: }
1298: }
1299: }
1300: }
1301:
1302: sub findcourse_advice {
1303: my ($r) = @_;
1304: my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description');
1.201 raeburn 1305: my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&');
1.200 raeburn 1306: if (&Apache::lonnet::auto_run(undef,$env{'user.domain'})) {
1.191 raeburn 1307: $r->print(&mt('If you were expecting to see an active role listed for a particular course in the [_1] domain, it may be missing for one of the following reasons:',$domdesc).'
1308: <ul>
1309: <li>'.&mt('The course has yet to be created.').'</li>
1310: <li>'.&mt('Automatic enrollment of registered students has not been enabled for the course.').'</li>
1311: <li>'.&mt('You are in a section of course for which automatic enrollment in the corresponding LON-CAPA course is not active.').'</li>
1312: <li>'.&mt('The start date for automated enrollment has yet to be reached.').'</li>
1313: <li>'.&mt('You registered for the course recently and there is a time lag between the time you register, and the time this information becomes available for the update of LON-CAPA course rosters.').'</li>
1314: </ul>');
1315: } else {
1316: $r->print(&mt('If you were expecting to see an active role listed for a particular course, that course may not have been created yet.').'<br />');
1317: }
1.235 bisitz 1318: $r->print('<h3>'.&mt('Self-Enrollment').'</h3>'.
1.234 raeburn 1319: '<p>'.&mt('The [_1]Course/Community Catalog[_2] provides information about all [_3] classes for which LON-CAPA courses have been created, as well as any communities in the domain.','<a href="/adm/coursecatalog?showdom='.$esc_dom.'">','</a>',$domdesc).'<br />');
1.241 raeburn 1320: $r->print(&mt('You can search for courses and communities which permit self-enrollment, if you would like to enroll in one.').'</p>'.
1321: &Apache::loncoursequeueadmin::queued_selfenrollment());
1.216 raeburn 1322: return;
1323: }
1324:
1.234 raeburn 1325: sub requestcourse_advice {
1326: my ($r) = @_;
1327: my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description');
1328: my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&');
1329: my (%can_request,%request_doms);
1330: &Apache::lonnet::check_can_request($env{'user.domain'},\%can_request,\%request_doms);
1331: if (keys(%request_doms) > 0) {
1332: my ($types,$typename) = &Apache::loncommon::course_types();
1333: if ((ref($types) eq 'ARRAY') && (ref($typename) eq 'HASH')) {
1334: $r->print('<h3>'.&mt('Request creation of a course or community').'</h3>'.
1.238 bisitz 1335: '<p>'.&mt('You have rights to request the creation of courses and/or communities in the following domain(s):').'<ul>');
1.234 raeburn 1336: my (@reqdoms,@reqtypes);
1337: foreach my $type (sort(keys(%request_doms))) {
1338: push(@reqtypes,$type);
1339: if (ref($request_doms{$type}) eq 'ARRAY') {
1340: my $domstr = join(', ',map { &Apache::lonnet::domain($_) } sort(@{$request_doms{$type}}));
1.238 bisitz 1341: $r->print(
1342: '<li>'
1343: .&mt('[_1]'.$typename->{$type}.'[_2] in domain: [_3]',
1344: '<i>',
1345: '</i>',
1346: '<b>'.$domstr.'</b>')
1347: .'</li>'
1348: );
1.234 raeburn 1349: foreach my $dom (@{$request_doms{$type}}) {
1350: unless (grep(/^\Q$dom\E/,@reqdoms)) {
1351: push(@reqdoms,$dom);
1352: }
1353: }
1354: }
1355: }
1356: my @showtypes;
1357: foreach my $type (@{$types}) {
1358: if (grep(/^\Q$type\E$/,@reqtypes)) {
1359: push(@showtypes,$type);
1360: }
1361: }
1362: my $requrl = '/adm/requestcourse';
1363: if (@reqdoms == 1) {
1364: $requrl .= '?showdom='.$reqdoms[0];
1365: }
1366: if (@showtypes > 0) {
1367: $requrl.=(($requrl=~/\?/)?'&':'?').'crstype='.$showtypes[0];
1368: }
1369: if (@reqdoms == 1 || @showtypes > 0) {
1370: $requrl .= '&state=crstype&action=new';
1371: }
1372: $r->print('</ul>'.&mt('Use the [_1]request form[_2] to submit a request for creation of a new course or community.','<a href="'.$requrl.'">','</a>').'</p>');
1373: }
1374: }
1375: return;
1376: }
1377:
1.175 albertel 1378: sub privileges_info {
1379: my ($which) = @_;
1380: my $output;
1381:
1382: $which ||= $env{'request.role'};
1383:
1384: foreach my $envkey (sort(keys(%env))) {
1385: next if ($envkey!~/^user\.priv\.\Q$which\E\.(.*)/);
1386:
1387: my $where=$1;
1388: my $ttype;
1389: my $twhere;
1390: my (undef,$tdom,$trest,$tsec)=split(m{/},$where);
1391: if ($trest) {
1392: if ($env{'course.'.$tdom.'_'.$trest.'.description'} eq 'ca') {
1393: $ttype='Construction Space';
1394: $twhere='User: '.$trest.', Domain: '.$tdom;
1395: } else {
1396: $ttype= &Apache::loncommon::course_type($tdom.'_'.$trest);
1397: $twhere=$env{'course.'.$tdom.'_'.$trest.'.description'};
1398: if ($tsec) {
1399: my $sec_type = 'Section';
1400: if (exists($env{"user.role.gr.$where"})) {
1401: $sec_type = 'Group';
1402: }
1403: $twhere.=' ('.$sec_type.': '.$tsec.')';
1404: }
1405: }
1406: } elsif ($tdom) {
1407: $ttype='Domain';
1408: $twhere=$tdom;
1409: } else {
1410: $ttype='System';
1411: $twhere='/';
1412: }
1.204 bisitz 1413: $output .= "\n<h3>".&mt($ttype).': '.$twhere.'</h3>'."\n<ul>";
1.175 albertel 1414: foreach my $priv (sort(split(/:/,$env{$envkey}))) {
1415: next if (!$priv);
1416:
1417: my ($prv,$restr)=split(/\&/,$priv);
1418: my $trestr='';
1419: if ($restr ne 'F') {
1420: $trestr.=' ('.
1421: join(', ',
1422: map { &Apache::lonnet::plaintext($_) }
1423: (split('',$restr))).') ';
1424: }
1425: $output .= "\n\t".
1426: '<li>'.&Apache::lonnet::plaintext($prv).$trestr.'</li>';
1427: }
1428: $output .= "\n".'</ul>';
1429: }
1430: return $output;
1431: }
1432:
1.110 raeburn 1433: sub build_roletext {
1.254 raeburn 1434: my ($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$trole,$twhere,$tpstart,$tpend,$nochoose,$button,$switchserver,$reinit,$switchwarning) = @_;
1.223 raeburn 1435: my ($roletext,$roletext_end);
1.132 albertel 1436: my $is_dc=($trolecode =~ m/^dc\./);
1437: my $rowspan=($is_dc) ? ''
1438: : ' rowspan="2" ';
1439:
1.110 raeburn 1440: unless ($nochoose) {
1.134 www 1441: my $buttonname=$trolecode;
1442: $buttonname=~s/\W//g;
1.110 raeburn 1443: if (!$button) {
1444: if ($switchserver) {
1.212 bisitz 1445: $roletext.='<td'.$rowspan.' class="'.$tbg.'">'
1446: .'<a href="/adm/switchserver?'.$switchserver.'">'
1447: .&mt('Switch Server')
1448: .'</a></td>';
1.110 raeburn 1449: } else {
1.212 bisitz 1450: $roletext.=('<td'.$rowspan.' class="'.$tbg.'"> </td>');
1.110 raeburn 1451: }
1.255 raeburn 1452: if ($switchwarning) {
1453: if ($tremark eq '') {
1454: $tremark = $switchwarning;
1455: } else {
1456: $tremark .= '<br />'.$switchwarning;
1457: }
1458: }
1.110 raeburn 1459: } elsif ($tstatus eq 'is') {
1.212 bisitz 1460: $roletext.='<td'.$rowspan.' class="'.$tbg.'">'.
1461: '<input name="'.$buttonname.'" type="button" value="'.
1.225 bisitz 1462: &mt('Select').'" onclick="javascript:enterrole(this.form,\''.
1.192 raeburn 1463: $trolecode."','".$buttonname.'\');" /></td>';
1.110 raeburn 1464: } elsif ($tryagain) {
1465: $roletext.=
1.212 bisitz 1466: '<td'.$rowspan.' class="'.$tbg.'">'.
1467: '<input name="'.$buttonname.'" type="button" value="'.
1.225 bisitz 1468: &mt('Try Selecting Again').'" onclick="javascript:enterrole(this.form,\''.
1.192 raeburn 1469: $trolecode."','".$buttonname.'\');" /></td>';
1.110 raeburn 1470: } elsif ($advanced) {
1471: $roletext.=
1.212 bisitz 1472: '<td'.$rowspan.' class="'.$tbg.'">'.
1473: '<input name="'.$buttonname.'" type="button" value="'.
1.225 bisitz 1474: &mt('Re-Initialize').'" onclick="javascript:enterrole(this.form,\''.
1.192 raeburn 1475: $trolecode."','".$buttonname.'\');" /></td>';
1.209 raeburn 1476: } elsif ($reinit) {
1477: $roletext.=
1.212 bisitz 1478: '<td'.$rowspan.' class="'.$tbg.'">'.
1479: '<input name="'.$buttonname.'" type="button" value="'.
1.225 bisitz 1480: &mt('Re-Select').'" onclick="javascript:enterrole(this.form,\''.
1.209 raeburn 1481: $trolecode."','".$buttonname.'\');" /></td>';
1.110 raeburn 1482: } else {
1.209 raeburn 1483: $roletext.=
1.212 bisitz 1484: '<td'.$rowspan.' class="'.$tbg.'">'.
1485: '<input name="'.$buttonname.'" type="button" value="'.
1.225 bisitz 1486: &mt('Re-Select').'" onclick="javascript:enterrole(this.form,\''.
1.209 raeburn 1487: $trolecode."','".$buttonname.'\');" /></td>';
1.110 raeburn 1488: }
1489: }
1.165 albertel 1490: if ($trolecode !~ m/^(dc|ca|au|aa)\./) {
1491: $tremark.=&Apache::lonannounce::showday(time,1,
1492: &Apache::lonannounce::readcalendar($tdom.'_'.$trest));
1493: }
1.212 bisitz 1494: $roletext.='<td>'.$trole.'</td>'
1495: .'<td>'.$twhere.'</td>'
1496: .'<td>'.$tpstart.'</td>'
1.223 raeburn 1497: .'<td>'.$tpend.'</td>';
1.132 albertel 1498: if (!$is_dc) {
1.223 raeburn 1499: $roletext_end = '<td colspan="4">'.
1500: $tremark.' '.
1501: '</td>';
1.132 albertel 1502: }
1.223 raeburn 1503: return ($roletext,$roletext_end);
1.110 raeburn 1504: }
1505:
1.202 raeburn 1506: sub check_needs_switchserver {
1507: my ($possiblerole) = @_;
1508: my $needs_switchserver;
1509: my ($role,$where) = split(/\./,$possiblerole,2);
1510: my (undef,$tdom,$twho) = split(/\//,$where);
1511: my ($server_status,$home);
1512: if (($role eq 'ca') || ($role eq 'aa')) {
1513: ($server_status,$home) = &check_author_homeserver($twho,$tdom);
1514: } else {
1515: ($server_status,$home) = &check_author_homeserver($env{'user.name'},
1516: $env{'user.domain'});
1517: }
1518: if ($server_status eq 'switchserver') {
1519: $needs_switchserver = 1;
1520: }
1521: return $needs_switchserver;
1522: }
1523:
1.193 raeburn 1524: sub check_author_homeserver {
1.183 www 1525: my ($uname,$udom)=@_;
1.193 raeburn 1526: if (($uname eq '') || ($udom eq '')) {
1527: return ('fail','');
1528: }
1.183 www 1529: my $home = &Apache::lonnet::homeserver($uname,$udom);
1.193 raeburn 1530: if (&Apache::lonnet::host_domain($home) ne $udom) {
1531: return ('fail',$home);
1532: }
1.183 www 1533: my @ids=&Apache::lonnet::current_machine_ids();
1.193 raeburn 1534: if (grep(/^\Q$home\E$/,@ids)) {
1535: return ('ok',$home);
1536: } else {
1537: return ('switchserver',$home);
1.183 www 1538: }
1539: }
1540:
1.104 raeburn 1541: sub check_fordc {
1.260 raeburn 1542: my ($dcroles,$update,$then) = @_;
1.104 raeburn 1543: my $numdc = 0;
1.118 albertel 1544: if ($env{'user.adv'}) {
1545: foreach my $envkey (sort keys %env) {
1.170 albertel 1546: if ($envkey=~/^user\.role\.dc\.\/($match_domain)\/$/) {
1.104 raeburn 1547: my $dcdom = $1;
1548: my $livedc = 1;
1.118 albertel 1549: my ($tstart,$tend)=split(/\./,$env{$envkey});
1.260 raeburn 1550: my $limit = $update;
1551: if ($env{'request.role'} eq 'dc./'.$dcdom.'/') {
1552: $limit = $then;
1553: }
1554: if ($tstart && $tstart>$limit) { $livedc = 0; }
1555: if ($tend && $tend <$limit) { $livedc = 0; }
1.104 raeburn 1556: if ($livedc) {
1557: $$dcroles{$dcdom} = $envkey;
1.105 raeburn 1558: $numdc++;
1.104 raeburn 1559: }
1560: }
1561: }
1562: }
1563: return $numdc;
1564: }
1565:
1.185 raeburn 1566: sub adhoc_course_role {
1.260 raeburn 1567: my ($refresh,$update,$then) = @_;
1.239 raeburn 1568: my ($cdom,$cnum,$crstype);
1.201 raeburn 1569: $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1570: $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
1.239 raeburn 1571: $crstype = &Apache::loncommon::course_type();
1.260 raeburn 1572: if (&check_forcc($cdom,$cnum,$refresh,$update,$then,$crstype)) {
1.185 raeburn 1573: my $setprivs;
1.198 raeburn 1574: if (!defined($env{'user.role.'.$env{'form.switchrole'}})) {
1.185 raeburn 1575: $setprivs = 1;
1576: } else {
1.198 raeburn 1577: my ($start,$end) = split(/\./,$env{'user.role.'.$env{'form.switchrole'}});
1.232 raeburn 1578: if (($start && ($start>$refresh || $start == -1)) ||
1.260 raeburn 1579: ($end && $end<$update)) {
1.185 raeburn 1580: $setprivs = 1;
1581: }
1.232 raeburn 1582: }
1.185 raeburn 1583: if ($setprivs) {
1.198 raeburn 1584: if ($env{'form.switchrole'} =~ m-^(in|ta|ep|ad|st|cr)([\w/]*)\./\Q$cdom\E/\Q$cnum\E/?(\w*)$-) {
1.185 raeburn 1585: my $role = $1;
1586: my $custom_role = $2;
1587: my $usec = $3;
1588: if ($role eq 'cr') {
1.199 raeburn 1589: if ($custom_role =~ m-^/$match_domain/$match_username/\w+$-) {
1.185 raeburn 1590: $role .= $custom_role;
1591: } else {
1592: return;
1593: }
1594: }
1.208 raeburn 1595: my (%userroles,%newrole,%newgroups,%group_privs);
1596: my %cgroups =
1597: &Apache::lonnet::get_active_groups($env{'user.domain'},
1598: $env{'user.name'},$cdom,$cnum);
1599: foreach my $group (keys(%cgroups)) {
1600: $group_privs{$group} =
1601: $env{'user.priv.cc./'.$cdom.'/'.$cnum.'./'.$cdom.'/'.$cnum.'/'.$group};
1602: }
1603: $newgroups{'/'.$cdom.'/'.$cnum} = \%group_privs;
1.185 raeburn 1604: my $area = '/'.$cdom.'/'.$cnum;
1605: my $spec = $role.'.'.$area;
1606: if ($usec ne '') {
1607: $spec .= '/'.$usec;
1608: $area .= '/'.$usec;
1609: }
1610: &Apache::lonnet::standard_roleprivs(\%newrole,$role,$cdom,$spec,$cnum,$area);
1.208 raeburn 1611: &Apache::lonnet::set_userprivs(\%userroles,\%newrole,\%newgroups);
1.232 raeburn 1612: my $adhocstart = $refresh-1;
1.185 raeburn 1613: $userroles{'user.role.'.$spec} = $adhocstart.'.';
1.186 raeburn 1614: &Apache::lonnet::appenv(\%userroles,[$role,'cm']);
1.185 raeburn 1615: }
1616: }
1617: }
1618: return;
1619: }
1620:
1621: sub check_forcc {
1.260 raeburn 1622: my ($cdom,$cnum,$refresh,$update,$then,$crstype) = @_;
1.239 raeburn 1623: my ($is_cc,$ccrole);
1624: if ($crstype eq 'Community') {
1625: $ccrole = 'co';
1626: } else {
1627: $ccrole = 'cc';
1628: }
1.266 droeschl 1629: if (&Apache::lonnet::is_course($cdom,$cnum)) {
1630: my $envkey = 'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum;
1631: if (defined($env{$envkey})) {
1632: $is_cc = 1;
1633: my ($tstart,$tend)=split(/\./,$env{$envkey});
1634: my $limit = $update;
1635: if ($env{'request.role'} eq $ccrole.'./'.$cdom.'/'.$cnum) {
1636: $limit = $then;
1.185 raeburn 1637: }
1.266 droeschl 1638: if ($tstart && $tstart>$refresh) { $is_cc = 0; }
1639: if ($tend && $tend <$limit) { $is_cc = 0; }
1.185 raeburn 1640: }
1641: }
1642: return $is_cc;
1643: }
1644:
1.254 raeburn 1645: sub check_release_required {
1.255 raeburn 1646: my ($loncaparev,$tcourseid,$trolecode,$required) = @_;
1.254 raeburn 1647: my ($switchserver,$warning);
1.255 raeburn 1648: if ($required ne '') {
1649: my ($reqdmajor,$reqdminor) = ($required =~ /^(\d+)\.(\d+)$/);
1.257 raeburn 1650: my ($major,$minor) = ($loncaparev =~ /^\'?(\d+)\.(\d+)\.[\w.\-]+\'?$/);
1.254 raeburn 1651: if ($reqdmajor ne '' && $reqdminor ne '') {
1652: my $otherserver;
1653: if (($major eq '' && $minor eq '') ||
1654: (($reqdmajor > $major) || (($reqdmajor == $major) && ($reqdminor > $minor)))) {
1655: my ($userdomserver) = &Apache::lonnet::choose_server($env{'user.domain'});
1656: my $switchlcrev =
1657: &Apache::lonnet::get_server_loncaparev($env{'user.domain'},
1658: $userdomserver);
1.257 raeburn 1659: my ($swmajor,$swminor) = ($switchlcrev =~ /^\'?(\d+)\.(\d+)\.[\w.\-]+\'?$/);
1.254 raeburn 1660: if (($swmajor eq '' && $swminor eq '') || ($reqdmajor > $swmajor) ||
1661: (($reqdmajor == $swmajor) && ($reqdminor > $swminor))) {
1662: my $cdom = $env{'course.'.$tcourseid.'.domain'};
1663: if ($cdom ne $env{'user.domain'}) {
1664: my ($coursedomserver,$coursehostname) = &Apache::lonnet::choose_server($cdom);
1665: my $serverhomeID = &Apache::lonnet::get_server_homeID($coursehostname);
1666: my $serverhomedom = &Apache::lonnet::host_domain($serverhomeID);
1667: my %defdomdefaults = &Apache::lonnet::get_domain_defaults($serverhomedom);
1668: my %udomdefaults = &Apache::lonnet::get_domain_defaults($env{'user.domain'});
1669: my $remoterev = &Apache::lonnet::get_server_loncaparev($serverhomedom,$coursedomserver);
1670: my $canhost =
1671: &Apache::lonnet::can_host_session($env{'user.domain'},
1672: $coursedomserver,
1673: $remoterev,
1674: $udomdefaults{'remotesessions'},
1675: $defdomdefaults{'hostedsessions'});
1676:
1677: if ($canhost) {
1678: $otherserver = $coursedomserver;
1679: } else {
1680: $warning = &mt('Requires LON-CAPA version [_1].',$env{'course.'.$tcourseid.'.internal.releaserequired'}).'<br />'. &mt("No suitable server could be found amongst servers in either your own domain or in the course's domain.");
1681: }
1682: } else {
1683: $warning = &mt('Requires LON-CAPA version [_1].',$env{'course.'.$tcourseid.'.internal.releaserequired'}).'<br />'.&mt("No suitable server could be found amongst servers in your own domain (which is also the course's domain).");
1684: }
1685: } else {
1686: $otherserver = $userdomserver;
1687: }
1688: }
1689: if ($otherserver ne '') {
1690: $switchserver = 'otherserver='.$otherserver.'&role='.$trolecode;
1691: }
1692: }
1693: }
1694: return ($switchserver,$warning);
1695: }
1696:
1.108 raeburn 1697: sub courselink {
1.193 raeburn 1698: my ($dcdom,$rowtype) = @_;
1.109 raeburn 1699: my $courseform=&Apache::loncommon::selectcourse_link
1.152 raeburn 1700: ('rolechoice','dccourse'.$rowtype.'_'.$dcdom,
1701: 'dcdomain'.$rowtype.'_'.$dcdom,'coursedesc'.$rowtype.'_'.
1.239 raeburn 1702: $dcdom,$dcdom,undef,'Course/Community');
1.138 raeburn 1703: my $hiddenitems = '<input type="hidden" name="dcdomain'.$rowtype.'_'.$dcdom.'" value="'.$dcdom.'" />'.
1704: '<input type="hidden" name="origdom'.$rowtype.'_'.$dcdom.'" value="'.$dcdom.'" />'.
1705: '<input type="hidden" name="dccourse'.$rowtype.'_'.$dcdom.'" value="" />'.
1706: '<input type="hidden" name="coursedesc'.$rowtype.'_'.$dcdom.'" value="" />';
1.112 raeburn 1707: return $courseform.$hiddenitems;
1.109 raeburn 1708: }
1709:
1710: sub coursepick_jscript {
1.184 raeburn 1711: my %lt = &Apache::lonlocal::texthash(
1.239 raeburn 1712: plsu => "Please use the 'Select Course/Community' link to open a separate pick course window where you may select the course or community you wish to enter.",
1.234 raeburn 1713: youc => 'You can only use this screen to select courses and communities in the current domain.',
1.184 raeburn 1714: );
1.104 raeburn 1715: my $verify_script = <<"END";
1.179 raeburn 1716: <script type="text/javascript">
1.225 bisitz 1717: // <![CDATA[
1.108 raeburn 1718: function verifyCoursePick(caller) {
1719: var numbutton = getIndex(caller)
1.112 raeburn 1720: var pickedCourse = document.rolechoice.elements[numbutton+4].value
1721: var pickedDomain = document.rolechoice.elements[numbutton+2].value
1722: if (document.rolechoice.elements[numbutton+2].value == document.rolechoice.elements[numbutton+3].value) {
1.104 raeburn 1723: if (pickedCourse != '') {
1.108 raeburn 1724: if (numbutton != -1) {
1725: var courseTarget = "cc./"+pickedDomain+"/"+pickedCourse
1726: document.rolechoice.elements[numbutton+1].name = courseTarget
1727: document.rolechoice.submit()
1728: }
1.104 raeburn 1729: }
1730: else {
1.184 raeburn 1731: alert("$lt{'plsu'}");
1.104 raeburn 1732: }
1733: }
1734: else {
1.184 raeburn 1735: alert("$lt{'youc'}")
1.104 raeburn 1736: }
1737: }
1.109 raeburn 1738: function getIndex(caller) {
1.108 raeburn 1739: for (var i=0;i<document.rolechoice.elements.length;i++) {
1.109 raeburn 1740: if (document.rolechoice.elements[i] == caller) {
1.108 raeburn 1741: return i;
1742: }
1743: }
1744: return -1;
1745: }
1.225 bisitz 1746: // ]]>
1.104 raeburn 1747: </script>
1748: END
1.109 raeburn 1749: return $verify_script;
1.104 raeburn 1750: }
1751:
1.193 raeburn 1752: sub coauthorlink {
1753: my ($dcdom,$rowtype) = @_;
1754: my $coauthorform=&Apache::loncommon::selectauthor_link('rolechoice',$dcdom);
1755: my $hiddenitems = '<input type="hidden" name="adhoccauname'.$rowtype.'_'.$dcdom.'" value="" />';
1756: return $coauthorform.$hiddenitems;
1757: }
1758:
1.113 raeburn 1759: sub display_cc_role {
1760: my $rolekey = shift;
1.223 raeburn 1761: my ($roletext,$roletext_end);
1.118 albertel 1762: my $advanced = $env{'user.adv'};
1763: my $tryagain = $env{'form.tryagain'};
1.113 raeburn 1764: unless ($rolekey =~/^error\:/) {
1.240 raeburn 1765: if ($rolekey =~ m{^user\.role\.(cc|co)\./($match_domain)/($match_courseid)$}) {
1766: my $ccrole = $1;
1.249 raeburn 1767: my $tdom = $2;
1768: my $trest = $3;
1769: my $tcourseid = $tdom.'_'.$trest;
1770: my $trolecode = $ccrole.'./'.$tdom.'/'.$trest;
1.113 raeburn 1771: my $twhere;
1.152 raeburn 1772: my $ttype;
1.212 bisitz 1773: my $tbg='LC_roles_is';
1.113 raeburn 1774: my %newhash=&Apache::lonnet::coursedescription($tcourseid);
1775: if (%newhash) {
1776: $twhere=$newhash{'description'}.
1.261 bisitz 1777: ' <span class="LC_fontsize_small">'.
1.249 raeburn 1778: &Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$trest,$tdom).
1.211 tempelho 1779: '</span>';
1.153 raeburn 1780: $ttype = $newhash{'type'};
1.113 raeburn 1781: } else {
1782: $twhere=&mt('Currently not available');
1.118 albertel 1783: $env{'course.'.$tcourseid.'.description'}=$twhere;
1.110 raeburn 1784: }
1.242 raeburn 1785: my $trole = &Apache::lonnet::plaintext($ccrole,$ttype,$tcourseid);
1.258 raeburn 1786: $twhere.="<br />".&mt('Domain').":".$tdom;
1.249 raeburn 1787: ($roletext,$roletext_end) = &build_roletext($trolecode,$tdom,$trest,'is',$tryagain,$advanced,'',$tbg,$trole,$twhere,'','','',1,'');
1.104 raeburn 1788: }
1789: }
1.223 raeburn 1790: return ($roletext,$roletext_end);
1.104 raeburn 1791: }
1792:
1.192 raeburn 1793: sub adhoc_roles_row {
1.138 raeburn 1794: my ($dcdom,$rowtype) = @_;
1.212 bisitz 1795: my $output = &Apache::loncommon::continue_data_table_row()
1796: .' <td colspan="5">'
1797: .&mt('[_1]Ad hoc[_2] roles in domain [_3] --'
1798: ,'<span class="LC_cusr_emph">','</span>',$dcdom)
1.227 bisitz 1799: .' ';
1.193 raeburn 1800: my $selectcclink = &courselink($dcdom,$rowtype);
1.239 raeburn 1801: my $ccrole = &Apache::lonnet::plaintext('co',undef,undef,1);
1.182 www 1802: my $carole = &Apache::lonnet::plaintext('ca');
1.193 raeburn 1803: my $selectcalink = &coauthorlink($dcdom,$rowtype);
1.227 bisitz 1804: $output.=$ccrole.': '.$selectcclink
1.249 raeburn 1805: .' | '.$carole.': '.$selectcalink.'</td>'
1.212 bisitz 1806: .&Apache::loncommon::end_data_table_row();
1.108 raeburn 1807: return $output;
1808: }
1809:
1.104 raeburn 1810: sub recent_filename {
1811: my $area=shift;
1.149 www 1812: return 'nohist_recent_'.&escape($area);
1.104 raeburn 1813: }
1814:
1.139 raeburn 1815: sub courseloadpage {
1816: my ($courseid) = @_;
1817: my $startpage;
1.144 albertel 1818: my %entry_settings = &Apache::lonnet::get('nohist_whatsnew',
1819: [$courseid.':courseinit']);
1.139 raeburn 1820: my ($tmp) = %entry_settings;
1.144 albertel 1821: unless ($tmp =~ /^error: 2 /) {
1.139 raeburn 1822: $startpage = $entry_settings{$courseid.':courseinit'};
1823: }
1824: if ($startpage eq '') {
1825: if (exists($env{'environment.course_init_display'})) {
1826: $startpage = $env{'environment.course_init_display'};
1827: }
1828: }
1829: return $startpage;
1830: }
1831:
1.260 raeburn 1832: sub update_session_roles {
1833: my $then=$env{'user.login.time'};
1834: my $refresh=$env{'user.refresh.time'};
1835: if (!$refresh) {
1836: $refresh = $then;
1837: }
1838: my $update = $env{'user.update.time'};
1839: if (!$update) {
1840: $update = $then;
1841: }
1842: my $now = time;
1843: my %roleshash =
1844: &Apache::lonnet::get_my_roles('','','userroles',
1845: ['active','future','previous'],
1846: undef,undef,1);
1847: my ($msg,@newsec,$oldsec,$currrole_expired,@changed_roles,
1.264 raeburn 1848: %changed_groups,%dbroles,%deletedroles,%allroles,%allgroups,
1.260 raeburn 1849: %userroles,%checkedgroup,%crprivs,$hasgroups,%rolechange,
1850: %groupchange,%newrole,%newgroup,%customprivchg,%groups_roles,
1851: @rolecodes);
1852: my @possroles = ('cr','st','ta','ad','ep','in','co','cc');
1853: my %courseroles;
1854: foreach my $item (keys(%roleshash)) {
1855: my ($uname,$udom,$role,$remainder) = split(/:/,$item,4);
1856: my ($tstart,$tend) = split(/:/,$roleshash{$item});
1857: my ($section,$group,@group_privs);
1858: if ($role =~ m{^gr/(\w*)$}) {
1859: $role = 'gr';
1860: my $priv = $1;
1861: next if ($tstart eq '-1');
1862: if (&curr_role_status($tstart,$tend,$refresh,$now) eq 'active') {
1863: if ($priv ne '') {
1864: push(@group_privs,$priv);
1865: }
1866: }
1867: if ($remainder =~ /:/) {
1868: (my $additional_privs,$group) =
1869: ($remainder =~ /^([\w:]+):([^:]+)$/);
1870: if ($additional_privs ne '') {
1871: if (&curr_role_status($tstart,$tend,$refresh,$now) eq 'active') {
1872: push(@group_privs,split(/:/,$additional_privs));
1873: @group_privs = sort(@group_privs);
1874: }
1875: }
1876: } else {
1877: $group = $remainder;
1878: }
1879: } else {
1880: $section = $remainder;
1881: }
1882: my $where = "/$udom/$uname";
1883: if ($section ne '') {
1884: $where .= "/$section";
1885: } elsif ($group ne '') {
1886: $where .= "/$group";
1887: }
1888: my $rolekey = "$role.$where";
1889: my $envkey = "user.role.$rolekey";
1890: $dbroles{$envkey} = 1;
1891: if (($env{'request.role'} eq $rolekey) && ($role ne 'st')) {
1892: if (&curr_role_status($tstart,$tend,$refresh,$now) ne 'active') {
1893: $currrole_expired = 1;
1894: }
1895: }
1896: if ($env{$envkey} eq '') {
1897: my $status_in_db =
1898: &curr_role_status($tstart,$tend,$refresh,$now);
1899: &gather_roleprivs(\%allroles,\%allgroups,\%userroles,$where,$role,$tstart,$tend,$status_in_db);
1900: if (($role eq 'st') && ($env{'request.role'} =~ m{^\Q$role\E\.\Q/$udom/$uname\E})) {
1901: if ($status_in_db eq 'active') {
1902: if ($section eq '') {
1903: push(@newsec,'none');
1904: } else {
1905: push(@newsec,$section);
1906: }
1907: }
1908: } else {
1909: unless (grep(/^\Q$role\E$/,@changed_roles)) {
1910: push(@changed_roles,$role);
1911: }
1912: if ($status_in_db ne 'previous') {
1913: if ($role eq 'gr') {
1914: $newgroup{$rolekey} = $status_in_db;
1915: if ($status_in_db eq 'active') {
1916: unless (ref($courseroles{$udom}) eq 'HASH') {
1917: %{$courseroles{$udom}} =
1918: &Apache::lonnet::get_my_roles('','','userroles',
1919: ['active'],\@possroles,
1920: [$udom],1);
1921: }
1922: &Apache::lonnet::get_groups_roles($udom,$uname,
1923: $courseroles{$udom},
1924: \@rolecodes,\%groups_roles);
1925: }
1926: } else {
1927: $newrole{$rolekey} = $status_in_db;
1928: }
1929: }
1930: }
1931: } else {
1932: my ($currstart,$currend) = split(/\./,$env{$envkey});
1933: if ($role eq 'gr') {
1934: if (&curr_role_status($currstart,$currend,$refresh,$update) ne 'previous') {
1935: $hasgroups = 1;
1936: }
1937: }
1938: if (($currstart ne $tstart) || ($currend ne $tend)) {
1939: my $status_in_env =
1940: &curr_role_status($currstart,$currend,$refresh,$update);
1941: my $status_in_db =
1942: &curr_role_status($tstart,$tend,$refresh,$now);
1943: if ($status_in_env ne $status_in_db) {
1944: if ($status_in_env eq 'active') {
1945: if ($role eq 'st') {
1946: if ($env{'request.role'} eq $rolekey) {
1947: my $switchsection;
1948: unless (ref($courseroles{$udom}) eq 'HASH') {
1949: %{$courseroles{$udom}} =
1950: &Apache::lonnet::get_my_roles('','','userroles',
1951: ['active'],
1952: \@possroles,[$udom],1);
1953: }
1954: foreach my $crsrole (keys(%{$courseroles{$udom}})) {
1955: if ($crsrole =~ /^\Q$uname\E:\Q$udom\E:st/) {
1956: $switchsection = 1;
1957: last;
1958: }
1959: }
1960: if ($switchsection) {
1961: if ($section eq '') {
1962: $oldsec = 'none';
1963: } else {
1964: $oldsec = $section;
1965: }
1966: &gather_roleprivs(\%allroles,\%allgroups,\%userroles,$where,$role,$tstart,$tend,$status_in_db);
1967: } else {
1968: $currrole_expired = 1;
1969: next;
1970: }
1971: }
1972: }
1973: unless ($rolekey eq $env{'request.role'}) {
1974: if ($role eq 'gr') {
1975: &Apache::lonnet::delete_env_groupprivs($where,\%courseroles,\@possroles);
1976: } else {
1977: &Apache::lonnet::delenv("user.priv.$rolekey",undef,[$role]);
1978: &Apache::lonnet::delenv("user.priv.cm.$where",undef,['cm']);
1979: }
1980: &gather_roleprivs(\%allroles,\%allgroups,\%userroles,$where,$role,$tstart,$tend,$status_in_db);
1981: }
1982: } elsif ($status_in_db eq 'active') {
1983: if (($role eq 'st') &&
1984: ($env{'request.role'} =~ m{^\Q$role\E\.\Q/$udom/$uname\E})) {
1985: if ($section eq '') {
1986: push(@newsec,'none');
1987: } else {
1988: push(@newsec,$section);
1989: }
1990: } elsif ($role eq 'gr') {
1991: unless (ref($courseroles{$udom}) eq 'HASH') {
1992: %{$courseroles{$udom}} =
1993: &Apache::lonnet::get_my_roles('','','userroles',
1994: ['active'],
1995: \@possroles,[$udom],1);
1996: }
1997: &Apache::lonnet::get_groups_roles($udom,$uname,
1998: $courseroles{$udom},
1999: \@rolecodes,\%groups_roles);
2000: }
2001: &gather_roleprivs(\%allroles,\%allgroups,\%userroles,$where,$role,$tstart,$tend,$status_in_db);
2002: }
2003: unless (grep(/^\Q$role\E$/,@changed_roles)) {
2004: push(@changed_roles,$role);
2005: }
2006: if ($role eq 'gr') {
2007: $groupchange{"/$udom/$uname"}{$group} = $status_in_db;
2008: } else {
2009: $rolechange{$rolekey} = $status_in_db;
2010: }
2011: }
2012: } else {
2013: if ($role eq 'gr') {
2014: unless ($checkedgroup{$where}) {
2015: my $status_in_db =
2016: &curr_role_status($tstart,$tend,$refresh,$now);
2017: if ($tstart eq '-1') {
2018: $status_in_db = 'deleted';
2019: }
2020: unless (ref($courseroles{$udom}) eq 'HASH') {
2021: %{$courseroles{$udom}} =
2022: &Apache::lonnet::get_my_roles('','','userroles',
2023: ['active'],
2024: \@possroles,[$udom],1);
2025: }
2026: if (ref($courseroles{$udom}) eq 'HASH') {
2027: foreach my $item (keys(%{$courseroles{$udom}})) {
2028: next unless ($item =~ /^\Q$uname\E/);
2029: my ($cnum,$cdom,$crsrole,$crssec) = split(/:/,$item);
2030: my $area = '/'.$cdom.'/'.$cnum;
2031: if ($crssec ne '') {
2032: $area .= '/'.$crssec;
2033: }
2034: my $crsrolekey = $crsrole.'.'.$area;
2035: my $currprivs = $env{'user.priv.'.$crsrole.'.'.$area.'.'.$where};
2036: $currprivs =~ s/^://;
2037: $currprivs =~ s/\&F$//;
2038: my @curr_grp_privs = split(/\&F:/,$currprivs);
2039: @curr_grp_privs = sort(@curr_grp_privs);
2040: my @diffs;
2041: if (@group_privs > 0 || @curr_grp_privs > 0) {
2042: @diffs = &Apache::loncommon::compare_arrays(\@group_privs,\@curr_grp_privs);
2043: }
2044: if (@diffs == 0) {
2045: last;
2046: } else {
2047: unless(grep(/^\Qgr\E$/,@rolecodes)) {
2048: push(@rolecodes,'gr');
2049: }
2050: &gather_roleprivs(\%allroles,\%allgroups,
2051: \%userroles,$where,$role,
2052: $tstart,$tend,$status_in_db);
2053: if ($status_in_db eq 'active') {
2054: &Apache::lonnet::get_groups_roles($udom,$uname,
2055: $courseroles{$udom},
2056: \@rolecodes,\%groups_roles);
2057: }
2058: $changed_groups{$udom.'_'.$uname}{$group} = $status_in_db;
2059: last;
2060: }
2061: }
2062: }
2063: $checkedgroup{$where} = 1;
2064: }
2065: } elsif ($role =~ /^cr/) {
2066: my $status_in_db =
2067: &curr_role_status($tstart,$tend,$refresh,$now);
2068: my ($rdummy,$rest) = split(/\//,$role,2);
2069: my ($rdummy,$rdomain,$rauthor,$rrole)=split(/\//,$role);
2070: my %currpriv;
2071: unless (exists($crprivs{$rest})) {
2072: my ($rdomain,$rauthor,$rrole)=split(/\//,$rest);
2073: my $homsvr=&Apache::lonnet::homeserver($rauthor,$rdomain);
2074: if (&Apache::lonnet::hostname($homsvr) ne '') {
2075: my ($rdummy,$roledef)=
2076: &Apache::lonnet::get('roles',["rolesdef_$rrole"],
2077: $rdomain,$rauthor);
2078: if (($rdummy ne 'con_lost') && ($roledef ne '')) {
2079: my $i = 0;
2080: my @scopes = ('sys','dom','crs');
2081: my @privs = split(/\_/,$roledef);
2082: foreach my $priv (@privs) {
2083: my ($blank,@prv) = split(/:/,$priv);
2084: @prv = map { $_ .= (/\&\w+$/ ? '':'&F') } @prv;
1.264 raeburn 2085: if (@prv) {
2086: $priv = ':'.join(':',sort(@prv));
2087: }
1.260 raeburn 2088: $crprivs{$rest}{$scopes[$i]} = $priv;
2089: $i++;
2090: }
2091: }
2092: }
2093: }
2094: $currpriv{sys} = $env{"user.priv.$rolekey./"};
2095: $currpriv{dom} = $env{"user.priv.$rolekey./$udom/"};
2096: $currpriv{crs} = $env{"user.priv.$rolekey.$where"};
2097: if (keys(%crprivs)) {
2098: if (($crprivs{$rest}{sys} ne $currpriv{sys}) ||
2099: ($crprivs{$rest}{dom} ne $currpriv{dom})
2100: ||
2101: ($crprivs{$rest}{crs} ne $currpriv{crs})) {
2102: &gather_roleprivs(\%allroles,\%allgroups,\%userroles,$where,$role,$tstart,$tend,$status_in_db);
2103: unless (grep(/^\Q$role\E$/,@changed_roles)) {
2104: push(@changed_roles,$role);
2105: }
2106: my $status_in_env =
2107: &curr_role_status($currstart,$currend,$refresh,$update);
2108: if ($status_in_env eq 'active') {
2109: $customprivchg{$rolekey} = $status_in_env;
2110: }
2111: }
2112: }
2113: }
2114: }
2115: }
2116: }
2117: foreach my $envkey (keys(%env)) {
2118: next unless ($envkey =~ /^user\.role\./);
2119: next if ($dbroles{$envkey});
2120: next if ($envkey eq 'user.role.'.$env{'request.role'});
2121: my ($currstart,$currend) = split(/\./,$env{$envkey});
2122: my $status_in_env =
2123: &curr_role_status($currstart,$currend,$refresh,$update);
2124: my ($rolekey) = ($envkey =~ /^user\.role\.(.+)$/);
2125: my ($role,$rest)=split(/\./,$rolekey,2);
2126: if (&Apache::lonnet::delenv($envkey,undef,[$role])) {
2127: if ($status_in_env eq 'active') {
2128: if ($role eq 'gr') {
2129: &Apache::lonnet::delete_env_groupprivs($rest,\%courseroles,
2130: \@possroles);
2131: } else {
2132: &Apache::lonnet::delenv("user.priv.$rolekey",undef,[$role]);
2133: &Apache::lonnet::delenv("user.priv.cm.$rest",undef,['cm']);
2134: }
2135: unless (grep(/^\Q$role\E$/,@changed_roles)) {
2136: push(@changed_roles,$role);
2137: }
2138: $deletedroles{$rolekey} = 1;
2139: }
2140: }
2141: }
2142: if (($oldsec) && (@newsec > 0)) {
2143: if (@newsec > 1) {
2144: $msg = '<div class="LC_warning">'.&mt('The section has changed for your current role. Log-out and log-in again to select a role for the new section.').'</div>';
2145: } else {
2146: my $newrole = $env{'request.role'};
2147: if ($newsec[0] eq 'none') {
2148: $newrole =~ s{(/[^/])$}{};
2149: } elsif ($oldsec eq 'none') {
2150: $newrole .= '/'.$newsec[0];
2151: } else {
2152: $newrole =~ s{([^/]+)$}{$newsec[0]};
2153: }
2154: my $coursedesc = $env{'course.'.$env{'request.course.id'}.'.description'};
2155: my ($curr_role) = ($env{'request.role'} =~ m{^(\w+)\./$match_domain/$match_courseid});
2156: my %temp=('logout_'.$env{'request.course.id'} => time);
2157: &Apache::lonnet::put('email_status',\%temp);
2158: &Apache::lonnet::delenv('user.state.'.$env{'request.course.id'});
2159: &Apache::lonnet::appenv({"request.course.id" => '',
2160: "request.course.fn" => '',
2161: "request.course.uri" => '',
2162: "request.course.sec" => '',
2163: "request.role" => 'cm',
2164: "request.role.adv" => $env{'user.adv'},
2165: "request.role.domain" => $env{'user.domain'}});
2166: my $rolename = &Apache::loncommon::plainname($curr_role);
2167: $msg = '<p><form name="reselectrole" action="/adm/roles" method="post" />'.
2168: '<input type="hidden" name="newrole" value="" />'.
2169: '<input type="hidden" name="selectrole" value="1" />'.
2170: '<span class="LC_info">'.
2171: &mt('Your section has changed for your current [_1] role in [_2].',$rolename,$coursedesc).'</span><br />';
2172: my $button = '<input type="button" name="sectionchanged" value="'.
2173: &mt('Re-Select').'" onclick="javascript:enterrole(this.form,'."'$newrole','sectionchanged'".')" />';
2174: if ($newsec[0] eq 'none') {
2175: $msg .= &mt('[_1] to continue with your new section-less role.',$button);
2176: } else {
2177: $msg .= &mt('[_1] to continue with your new role in section ([_2]).',$button,$newsec[0]);
2178: }
2179: $msg .= '</form></p>';
2180: }
2181: } elsif ($currrole_expired) {
2182: $msg .= '<div class="LC_warning">';
2183: if (&Apache::loncommon::show_course()) {
2184: $msg .= &mt('Your role in the current course has expired.');
2185: } else {
2186: $msg .= &mt('Your current role has expired.');
2187: }
2188: $msg .= '<br />'.&mt('However you can continue to use this role until you logout, click the "Re-Select" button, or your session has been idle for more than 24 hours.').'</div>';
2189: }
2190: if (!@changed_roles || !(keys(%changed_groups))) {
1.264 raeburn 2191: my ($rolesmsg,$groupsmsg);
1.260 raeburn 2192: if (!@changed_roles) {
2193: if (&Apache::loncommon::show_course()) {
1.264 raeburn 2194: $rolesmsg = &mt('No new courses or communities');
1.260 raeburn 2195: } else {
1.264 raeburn 2196: $rolesmsg = &mt('No role changes');
1.260 raeburn 2197: }
2198: }
2199: if ($hasgroups && !(keys(%changed_groups)) && !(grep(/gr/,@changed_roles))) {
1.264 raeburn 2200: $groupsmsg = &mt('No changes in course/community groups');
1.260 raeburn 2201: }
2202: if (!@changed_roles && !(keys(%changed_groups))) {
1.264 raeburn 2203: if (($msg ne '') || ($groupsmsg ne '')) {
2204: $msg .= '<ul>';
2205: if ($rolesmsg) {
2206: $msg .= '<li>'.$rolesmsg.'</li>';
2207: }
2208: if ($groupsmsg) {
2209: $msg .= '<li>'.$groupsmsg.'</li>';
2210: }
2211: $msg .= '</ul>';
2212: } else {
1.265 raeburn 2213: $msg = ' <span class="LC_cusr_emph">'.$rolesmsg.'</span><br /><br />';
1.264 raeburn 2214: }
1.260 raeburn 2215: return $msg;
2216: }
2217: }
2218: my $changemsg;
2219: if (@changed_roles > 0) {
2220: if (keys(%newgroup) > 0) {
2221: my $groupmsg;
2222: foreach my $item (sort(keys(%newgroup))) {
2223: if (&is_active_course($item,$refresh,$update,\%roleshash)) {
2224: $groupmsg .= '<li>'.
2225: &mt('[_1] with status: [_2].',
2226: $item,$newgroup{$item}).'</li>';
2227: }
2228: }
2229: if ($groupmsg) {
2230: $changemsg .= '<li>'.
2231: &mt('Courses with new groups').'</li>'.
2232: '<ul>'.$groupmsg.'</ul></li>';
2233: }
2234: }
2235: if (keys(%newrole) > 0) {
2236: $changemsg .= '<li>'.&mt('New roles').
2237: '<ul>';
2238: foreach my $item (sort(keys(%newrole))) {
2239: $changemsg .= '<li>'.
2240: &mt('[_1] with status: [_2].',
2241: $item,$newrole{$item}).'</li>';
2242: }
2243: $changemsg .= '</ul></li>';
2244: }
2245: if (keys(%customprivchg) > 0) {
2246: $changemsg .= '<li>'.
2247: &mt('Custom roles with privilege changes').
2248: '<ul>';
2249: foreach my $item (sort(keys(%customprivchg))) {
2250: $changemsg .= '<li>'.$item.'</li>';
2251: }
2252: $changemsg .= '</ul></li>';
2253: }
2254: if (keys(%rolechange) > 0) {
2255: $changemsg .= '<li>'.
2256: &mt('Existing roles with status changes').'</li>'.
2257: '<ul>';
2258: foreach my $item (sort(keys(%rolechange))) {
2259: $changemsg .= '<li>'.
2260: &mt('[_1] status now: [_2].',$item,
2261: $rolechange{$item}).'</li>';
2262: }
2263: $changemsg .= '</ul></li>';
2264: }
2265: if (keys(%deletedroles) > 0) {
2266: $changemsg .= '<li>'.
1.268 raeburn 2267: &mt('Existing roles now expired').'</li>'.
1.260 raeburn 2268: '<ul>';
2269: foreach my $item (sort(keys(%deletedroles))) {
2270: $changemsg .= '<li>'.$item.'</li>';
2271: }
2272: $changemsg .= '</ul></li>';
2273: }
2274: }
2275: if ((keys(%changed_groups) > 0) || (keys(%groupchange) > 0)) {
2276: my $groupchgmsg;
2277: foreach my $key (sort(keys(%changed_groups))) {
2278: my $crs = 'gr/'.$key;
2279: $crs =~ s/_/\//;
2280: if (&is_active_course($crs,$refresh,$update,\%roleshash)) {
2281: if (ref($changed_groups{$key}) eq 'HASH') {
2282: my @showgroups;
2283: foreach my $group (sort(keys(%{$changed_groups{$key}}))) {
2284: if ($changed_groups{$key}{$group} eq 'active') {
2285: push(@showgroups,$group);
2286: }
2287: }
2288: if (@showgroups > 0) {
2289: $groupchgmsg .= '<li>'.
2290: &mt('Course: [_1], groups: [_2].',$key,
2291: join(', ',@showgroups)).
2292: '</li>';
2293: }
2294: }
2295: }
2296: }
2297: if (keys(%groupchange) > 0) {
2298: $groupchgmsg .= '<li>'.
2299: &mt('Existing course/community groups with status changes').'</li>'.
2300: '<ul>';
2301: foreach my $crs (sort(keys(%groupchange))) {
2302: if (ref($groupchange{$crs}) eq 'HASH') {
2303: $groupchgmsg .= '<li>'.&mt('Course/Community: [_1]','<b>'.$crs.'</b><ul>');
2304: foreach my $group (sort(keys(%{$groupchange{$crs}}))) {
2305: $groupchgmsg .= '<li>'.&mt('Group: [_1] status now: [_2].','<b>'.$group.'</b>',$groupchange{$crs}{$group}).'</li>';
2306: }
2307: $groupchgmsg .= '</ul></li>';
2308: }
2309: }
2310: $groupchgmsg .= '</ul></li>';
2311: }
2312: if ($groupchgmsg) {
2313: $changemsg .= '<li>'.
2314: &mt('Courses with changes in groups').'</li>'.
2315: '<ul>'.$groupchgmsg.'</ul></li>';
2316: }
2317: }
2318: if ($changemsg) {
2319: $msg .= '<ul>'.$changemsg.'</ul>';
2320: }
2321: &Apache::lonnet::set_userprivs(\%userroles,\%allroles,\%allgroups,\%groups_roles);
2322: my ($curr_is_adv,$curr_role_adv,$curr_author,$curr_role_author);
2323: $curr_author = $env{'user.author'};
2324: if (($env{'request.role'} =~/^au/) || ($env{'request.role'} =~/^ca/) ||
2325: ($env{'request.role'} =~/^aa/)) {
2326: $curr_role_author=1;
2327: }
2328: $curr_is_adv = $env{'user.adv'};
2329: $curr_role_adv = $env{'request.role.adv'};
2330: if (keys(%userroles) > 0) {
2331: foreach my $role (@changed_roles) {
2332: unless(grep(/^\Q$role\E$/,@rolecodes)) {
2333: push(@rolecodes,$role);
2334: }
2335: }
2336: unless(grep(/^\Qcm\E$/,@rolecodes)) {
2337: push(@rolecodes,'cm');
2338: }
2339: &Apache::lonnet::appenv(\%userroles,\@rolecodes);
2340: }
2341: my %newenv;
2342: if (&Apache::lonnet::is_advanced_user($env{'user.domain'},$env{'user.name'})) {
2343: unless ($curr_is_adv) {
2344: $newenv{'user.adv'} = 1;
2345: }
2346: } elsif ($curr_is_adv && !$curr_role_adv) {
2347: &Apache::lonnet::delenv('user.adv');
2348: }
2349: my %authorroleshash =
2350: &Apache::lonnet::get_my_roles('','','userroles',['active'],['au','ca','aa']);
2351: if (keys(%authorroleshash)) {
2352: unless ($curr_author) {
2353: $newenv{'user.author'} = 1;
2354: }
2355: } elsif ($curr_author && !$curr_role_author) {
2356: &Apache::lonnet::delenv('user.author');
2357: }
2358: if ($env{'request.course.id'}) {
2359: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
2360: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
2361: my (@activecrsgroups,$crsgroupschanged);
2362: if ($env{'request.course.groups'}) {
2363: @activecrsgroups = split(/:/,$env{'request.course.groups'});
2364: foreach my $item (keys(%deletedroles)) {
2365: if ($item =~ m{^gr\./\Q$cdom\E/\Q$cnum\E/(\w+)$}) {
2366: if (grep(/^\Q$1\E$/,@activecrsgroups)) {
2367: $crsgroupschanged = 1;
2368: last;
2369: }
2370: }
2371: }
2372: }
2373: unless ($crsgroupschanged) {
2374: foreach my $item (keys(%newgroup)) {
2375: if ($item =~ m{^gr\./\Q$cdom\E/\Q$cnum\E/(\w+)$}) {
2376: if ($newgroup{$item} eq 'active') {
2377: $crsgroupschanged = 1;
2378: last;
2379: }
2380: }
2381: }
2382: }
2383: if ((ref($changed_groups{$env{'request.course.id'}}) eq 'HASH') ||
2384: (ref($groupchange{"/$cdom/$cnum"}) eq 'HASH') ||
2385: ($crsgroupschanged)) {
2386: my %grouproles = &Apache::lonnet::get_my_roles('','','userroles',
2387: ['active'],['gr'],[$cdom],1);
2388: my @activegroups;
2389: foreach my $item (keys(%grouproles)) {
2390: next unless($item =~ /^\Q$cnum\E:\Q$cdom\E/);
2391: my $group;
2392: my ($crsn,$crsd,$role,$remainder) = split(/:/,$item,4);
2393: if ($remainder =~ /:/) {
2394: (my $other,$group) = ($remainder =~ /^([\w:]+):([^:]+)$/);
2395: } else {
2396: $group = $remainder;
2397: }
2398: if ($group ne '') {
2399: push(@activegroups,$group);
2400: }
2401: }
2402: $newenv{'request.course.groups'} = join(':',@activegroups);
2403: }
2404: }
2405: if (keys(%newenv)) {
2406: &Apache::lonnet::appenv(\%newenv);
2407: }
2408: return $msg;
2409: }
2410:
2411: sub curr_role_status {
2412: my ($start,$end,$refresh,$update) = @_;
2413: if (($start) && ($start<0)) { return 'deleted' };
2414: my $status = 'active';
2415: if (($end) && ($end<=$update)) {
2416: $status = 'previous';
2417: }
2418: if (($start) && ($refresh<$start)) {
2419: $status = 'future';
2420: }
2421: return $status;
2422: }
2423:
2424: sub gather_roleprivs {
2425: my ($allroles,$allgroups,$userroles,$area,$role,$tstart,$tend,$status) = @_;
2426: return unless ((ref($allroles) eq 'HASH') && (ref($allgroups) eq 'HASH') && (ref($userroles) eq 'HASH'));
2427: if (($area ne '') && ($role ne '')) {
2428: &Apache::lonnet::userrolelog($role,$env{'user.name'},$env{'user.domain'},
2429: $area,$tstart,$tend);
2430: my $spec=$role.'.'.$area;
2431: $userroles->{'user.role.'.$spec} = $tstart.'.'.$tend;
2432: my ($tdummy,$tdomain,$trest)=split(/\//,$area);
2433: if ($status eq 'active') {
2434: if ($role =~ /^cr\//) {
2435: &Apache::lonnet::custom_roleprivs($allroles,$role,$tdomain,$trest,$spec,$area);
2436: } elsif ($role eq 'gr') {
2437: my %rolehash = &Apache::lonnet::get('roles',[$area.'_'.$role],
2438: $env{'user.domain'},
2439: $env{'user.name'});
2440: my ($trole) = split(/_/,$rolehash{$area.'_'.$role},2);
2441: (undef,my $group_privs) = split(/\//,$trole);
2442: $group_privs = &unescape($group_privs);
2443: &Apache::lonnet::group_roleprivs($allgroups,$area,$group_privs,$tend,$tstart);
2444: } else {
2445: &Apache::lonnet::standard_roleprivs($allroles,$role,$tdomain,$spec,$trest,$area);
2446: }
2447: }
2448: }
2449: return;
2450: }
2451:
2452: sub is_active_course {
2453: my ($rolekey,$refresh,$update,$roleshashref) = @_;
2454: return unless(ref($roleshashref) eq 'HASH');
2455: my ($role,$cdom,$cnum) = split(/\//,$rolekey);
2456: my $is_active;
2457: foreach my $key (keys(%{$roleshashref})) {
2458: if ($key =~ /^\Q$cnum\E:\Q$cdom\E:/) {
2459: my ($tstart,$tend) = split(/:/,$roleshashref->{$key});
2460: my $status = &curr_role_status($tstart,$tend,$refresh,$update);
2461: if ($status eq 'active') {
2462: $is_active = 1;
2463: last;
2464: }
2465: }
2466: }
2467: return $is_active;
2468: }
2469:
1.1 harris41 2470: 1;
2471: __END__
1.32 harris41 2472:
2473: =head1 NAME
2474:
2475: Apache::lonroles - User Roles Screen
2476:
2477: =head1 SYNOPSIS
2478:
2479: Invoked by /etc/httpd/conf/srm.conf:
2480:
2481: <Location /adm/roles>
2482: PerlAccessHandler Apache::lonacc
2483: SetHandler perl-script
2484: PerlHandler Apache::lonroles
2485: ErrorDocument 403 /adm/login
2486: ErrorDocument 500 /adm/errorhandler
2487: </Location>
1.64 bowersj2 2488:
2489: =head1 OVERVIEW
2490:
2491: =head2 Choosing Roles
2492:
2493: C<lonroles> is a handler that allows a user to switch roles in
2494: mid-session. LON-CAPA attempts to work with "No Role Specified", the
2495: default role that a user has before selecting a role, as widely as
2496: possible, but certain handlers for example need specification which
2497: course they should act on, etc. Both in this scenario, and when the
2498: handler determines via C<lonnet>'s C<&allowed> function that a certain
2499: action is not allowed, C<lonroles> is used as error handler. This
2500: allows the user to select another role which may have permission to do
1.246 droeschl 2501: what they were trying to do.
1.64 bowersj2 2502:
2503: =begin latex
2504:
2505: \begin{figure}
2506: \begin{center}
2507: \includegraphics[width=0.45\paperwidth,keepaspectratio]{Sample_Roles_Screen}
2508: \caption{\label{Sample_Roles_Screen}Sample Roles Screen}
2509: \end{center}
2510: \end{figure}
2511:
2512: =end latex
2513:
2514: =head2 Role Initialization
2515:
2516: 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 2517:
2518: =head1 INTRODUCTION
2519:
2520: This module enables a user to select what role he wishes to
2521: operate under (instructor, student, teaching assistant, course
2522: coordinator, etc). These roles are pre-established by the actions
2523: of upper-level users.
2524:
2525: This is part of the LearningOnline Network with CAPA project
2526: described at http://www.lon-capa.org.
2527:
2528: =head1 HANDLER SUBROUTINE
2529:
2530: This routine is called by Apache and mod_perl.
2531:
2532: =over 4
2533:
2534: =item *
2535:
2536: Roles Initialization (yes/no)
2537:
2538: =item *
2539:
2540: Get Error Message from Environment
2541:
2542: =item *
2543:
2544: Who is this?
2545:
2546: =item *
2547:
2548: Generate Page Output
2549:
2550: =item *
2551:
2552: Choice or no choice
2553:
2554: =item *
2555:
2556: Table
2557:
2558: =item *
2559:
2560: Privileges
2561:
2562: =back
2563:
2564: =cut
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>