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