version 1.59, 2003/06/04 22:13:28
|
version 1.70, 2003/09/17 17:50:49
|
Line 52 use Apache::lonmenu;
|
Line 52 use Apache::lonmenu;
|
use Apache::loncommon; |
use Apache::loncommon; |
use Apache::lonannounce; |
use Apache::lonannounce; |
|
|
|
sub redirect_user { |
|
my ($r,$title,$url,$msg) = @_; |
|
$msg = $title if (! defined($msg)); |
|
$r->content_type('text/html'); |
|
&Apache::loncommon::no_cache($r); |
|
$r->send_http_header; |
|
my $swinfo=&Apache::lonmenu::rawconfig(); |
|
my $bodytag=&Apache::loncommon::bodytag('Switching Role'); |
|
$r->print (<<ENDREDIR); |
|
<head><title>$title</title> |
|
<meta HTTP-EQUIV="Refresh" CONTENT="1; url=$url"> |
|
</head> |
|
<html> |
|
$bodytag |
|
<script> |
|
$swinfo |
|
</script> |
|
<h1>$msg</h1> |
|
</body> |
|
</html> |
|
ENDREDIR |
|
return; |
|
} |
|
|
sub handler { |
sub handler { |
|
|
my $r = shift; |
my $r = shift; |
Line 141 ENDENTERKEY
|
Line 165 ENDENTERKEY
|
'request.role.domain' => $cdom, |
'request.role.domain' => $cdom, |
'request.course.sec' => $csec); |
'request.course.sec' => $csec); |
my $msg='Entering course ...'; |
my $msg='Entering course ...'; |
|
|
if (($cnum) && ($role ne 'ca')) { |
if (($cnum) && ($role ne 'ca')) { |
my ($furl,$ferr)= |
my ($furl,$ferr)= |
&Apache::lonuserstate::readmap($cdom.'/'.$cnum); |
&Apache::lonuserstate::readmap($cdom.'/'.$cnum); |
if (($ENV{'form.orgurl'}) && |
if (($ENV{'form.orgurl'}) && |
($ENV{'form.orgurl'}!~/^\/adm\/flip/)) { |
($ENV{'form.orgurl'}!~/^\/adm\/flip/)) { |
$r->internal_redirect($ENV{'form.orgurl'}); |
my $dest=$ENV{'form.orgurl'}; |
|
if ( $Apache::lonnet::mod_perl_version() == 2 ) { |
|
&Apache::lonnet::cleanenv(); |
|
} |
|
$r->internal_redirect($dest); |
return OK; |
return OK; |
} else { |
} else { |
unless ($ENV{'request.course.id'}) { |
unless ($ENV{'request.course.id'}) { |
&Apache::lonnet::appenv( |
&Apache::lonnet::appenv( |
"request.course.id" => $cdom.'_'.$cnum); |
"request.course.id" => $cdom.'_'.$cnum); |
$furl='/adm/notfound.html'; |
$furl='/adm/roles?tryagain=1'; |
$msg= |
$msg= |
'<h1><font color=red>Could not initialize top-level map.</font></h1>'; |
'<h1><font color=red>Could not initialize course at this time.</font></h1><h3>Please try again.</h3>'.$ferr; |
} |
} |
|
|
# Check to see if the user is a CC entering a course |
# Check to see if the user is a CC entering a course |
Line 168 ENDENTERKEY
|
Line 197 ENDENTERKEY
|
'.course.helper.not.run'}) { |
'.course.helper.not.run'}) { |
$furl = "/adm/helper/course.initialization.helper"; |
$furl = "/adm/helper/course.initialization.helper"; |
} |
} |
|
# |
$r->content_type('text/html'); |
# Send the user to the course they selected |
&Apache::loncommon::no_cache($r); |
&redirect_user($r,'Entering Course', |
$r->send_http_header; |
$furl,$msg); |
my $swinfo=&Apache::lonmenu::rawconfig(); |
|
my $bodytag=&Apache::loncommon::bodytag('Switching Role'); |
|
print (<<ENDREDIR); |
|
<head><title>Entering Course</title> |
|
<meta HTTP-EQUIV="Refresh" CONTENT="1; url=$furl"> |
|
</head> |
|
<html> |
|
$bodytag |
|
<script> |
|
$swinfo |
|
</script> |
|
<h1>$msg</h1> |
|
</body> |
|
</html> |
|
ENDREDIR |
|
return OK; |
return OK; |
} |
} |
} |
} |
|
# |
|
# Send the user to the construction space they selected |
|
if ($role =~ /^(au|ca)$/) { |
|
my $redirect_url = '/priv/'; |
|
if ($role eq 'au') { |
|
$redirect_url.=$ENV{'user.name'}; |
|
} else { |
|
$where =~ /\/(.*)$/; |
|
$redirect_url .= $1; |
|
} |
|
$redirect_url .= '/'; |
|
&redirect_user($r,'Entering Construction Space', |
|
$redirect_url); |
|
return OK; |
|
} |
} |
} |
} |
} |
} |
} |
Line 228 ENDHEADER
|
Line 257 ENDHEADER
|
"$msg for $ENV{'user.name'} domain $ENV{'user.domain'} access $priv",$fn); |
"$msg for $ENV{'user.name'} domain $ENV{'user.domain'} access $priv",$fn); |
} |
} |
|
|
# ---------------------------------------------------------------- Who is this? |
# ------------------------------------------------- Can this user re-init, etc? |
|
|
my $advanced=0; |
my $advanced=$ENV{'user.adv'}; |
foreach $envkey (keys %ENV) { |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['tryagain']); |
if ($envkey=~/^user\.role\./) { |
my $tryagain=$ENV{'form.tryagain'}; |
my (undef,undef,$role,@pwhere)=split(/\./,$envkey); |
|
if ($role ne 'st') { $advanced=1; } |
|
} |
|
} |
|
|
|
# -------------------------------------------------------- Generate Page Output |
# -------------------------------------------------------- Generate Page Output |
# --------------------------------------------------------------- Error Header? |
# --------------------------------------------------------------- Error Header? |
Line 285 ENDHEADER
|
Line 310 ENDHEADER
|
$r->print('<input type=hidden name=orgurl value="'.$fn.'">'); |
$r->print('<input type=hidden name=orgurl value="'.$fn.'">'); |
$r->print('<input type=hidden name=selectrole value=1>'); |
$r->print('<input type=hidden name=selectrole value=1>'); |
} |
} |
$r->print('<br>Show all roles: <input type=checkbox name=showall'); |
if ($ENV{'user.adv'}) { |
if ($ENV{'form.showall'}) { $r->print(' checked'); } |
$r->print( |
$r->print('><input type=submit value="Display"><br>'); |
'<br />Show all roles: <input type="checkbox" name="showall"'); |
|
if ($ENV{'form.showall'}) { $r->print(' checked'); } |
|
$r->print('><input type=submit value="Display">'); |
|
} |
# ----------------------------------------------------------------------- Table |
# ----------------------------------------------------------------------- Table |
$r->print('<table><tr>'); |
$r->print('<br /><table><tr>'); |
unless ($nochoose) { $r->print('<th> </th>'); } |
unless ($nochoose) { $r->print('<th> </th>'); } |
$r->print('<th>User Role</th><th colspan=2>Extent</th>'. |
$r->print('<th>User Role</th><th colspan=2>Extent</th>'. |
'<th>Start</th><th>End</th><th>Remark</th></tr>'."\n"); |
'<th>Start</th><th>End</th><th>Remark</th></tr>'."\n"); |
Line 443 ENDHEADER
|
Line 471 ENDHEADER
|
} elsif ($tstatus eq 'is') { |
} elsif ($tstatus eq 'is') { |
$r->print('<td><input type=submit value=Select name="'. |
$r->print('<td><input type=submit value=Select name="'. |
$trolecode.'"></td>'); |
$trolecode.'"></td>'); |
} elsif ($ENV{'user.adv'}) { |
} elsif ($tryagain) { |
|
$r->print |
|
('<td><input type=submit value="Try Selecting Again"'. |
|
' name="'.$trolecode.'"></td>'); |
|
} elsif ($advanced) { |
$r->print |
$r->print |
('<td><input type=submit value="Re-Initialize"'. |
('<td><input type=submit value="Re-Initialize"'. |
' name="'.$trolecode.'"></td>'); |
' name="'.$trolecode.'"></td>'); |
Line 542 ENDHEADER
|
Line 574 ENDHEADER
|
} |
} |
} |
} |
} |
} |
|
$r->print(&Apache::lonnet::getannounce()); |
|
if ($advanced) { |
|
$r->print('<p><small><i>This is LON-CAPA '. |
|
$r->dir_config('lonVersion').'</i></small></p>'); |
|
} |
$r->print("</body></html>\n"); |
$r->print("</body></html>\n"); |
return OK; |
return OK; |
} |
} |
Line 566 Invoked by /etc/httpd/conf/srm.conf:
|
Line 602 Invoked by /etc/httpd/conf/srm.conf:
|
ErrorDocument 500 /adm/errorhandler |
ErrorDocument 500 /adm/errorhandler |
</Location> |
</Location> |
|
|
|
=head1 OVERVIEW |
|
|
|
=head2 Choosing Roles |
|
|
|
C<lonroles> is a handler that allows a user to switch roles in |
|
mid-session. LON-CAPA attempts to work with "No Role Specified", the |
|
default role that a user has before selecting a role, as widely as |
|
possible, but certain handlers for example need specification which |
|
course they should act on, etc. Both in this scenario, and when the |
|
handler determines via C<lonnet>'s C<&allowed> function that a certain |
|
action is not allowed, C<lonroles> is used as error handler. This |
|
allows the user to select another role which may have permission to do |
|
what they were trying to do. C<lonroles> can also be accessed via the |
|
B<CRS> button in the Remote Control. |
|
|
|
=begin latex |
|
|
|
\begin{figure} |
|
\begin{center} |
|
\includegraphics[width=0.45\paperwidth,keepaspectratio]{Sample_Roles_Screen} |
|
\caption{\label{Sample_Roles_Screen}Sample Roles Screen} |
|
\end{center} |
|
\end{figure} |
|
|
|
=end latex |
|
|
|
=head2 Role Initialization |
|
|
|
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. |
|
|
=head1 INTRODUCTION |
=head1 INTRODUCTION |
|
|
This module enables a user to select what role he wishes to |
This module enables a user to select what role he wishes to |