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