version 1.209, 2008/10/20 03:25:48
|
version 1.211, 2008/12/04 08:53:04
|
Line 27
|
Line 27
|
# |
# |
### |
### |
|
|
|
=pod |
|
|
|
=head1 NAME |
|
|
|
Apache::lonroles - User Roles Screen |
|
|
|
=head1 SYNOPSIS |
|
|
|
Invoked by /etc/httpd/conf/srm.conf: |
|
|
|
<Location /adm/roles> |
|
PerlAccessHandler Apache::lonacc |
|
SetHandler perl-script |
|
PerlHandler Apache::lonroles |
|
ErrorDocument 403 /adm/login |
|
ErrorDocument 500 /adm/errorhandler |
|
</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 |
|
|
|
This module enables a user to select what role he wishes to |
|
operate under (instructor, student, teaching assistant, course |
|
coordinator, etc). These roles are pre-established by the actions |
|
of upper-level users. |
|
|
|
This is part of the LearningOnline Network with CAPA project |
|
described at http://www.lon-capa.org. |
|
|
|
=head1 HANDLER SUBROUTINE |
|
|
|
This routine is called by Apache and mod_perl. |
|
|
|
=over 4 |
|
|
|
=item * |
|
|
|
Roles Initialization (yes/no) |
|
|
|
=item * |
|
|
|
Get Error Message from Environment |
|
|
|
=item * |
|
|
|
Who is this? |
|
|
|
=item * |
|
|
|
Generate Page Output |
|
|
|
=item * |
|
|
|
Choice or no choice |
|
|
|
=item * |
|
|
|
Table |
|
|
|
=item * |
|
|
|
Privileges |
|
|
|
=back |
|
|
|
=cut |
|
|
|
|
package Apache::lonroles; |
package Apache::lonroles; |
|
|
use strict; |
use strict; |
Line 272 $swinfo
|
Line 369 $swinfo
|
<form method="post"> |
<form method="post"> |
<input type="hidden" name="selectrole" value="1" /> |
<input type="hidden" name="selectrole" value="1" /> |
<input type="hidden" name="$trolecode" value="1" /> |
<input type="hidden" name="$trolecode" value="1" /> |
<font size="+2">$message</font><br /> |
<span class="LC_fontsize_large">$message</span><br /> |
<input type="submit" value="$buttontext" /> |
<input type="submit" value="$buttontext" /> |
</form> |
</form> |
$end_page |
$end_page |
Line 662 ENDHEADER
|
Line 759 ENDHEADER
|
$twhere=$env{'course.'.$tcourseid.'.description'}; |
$twhere=$env{'course.'.$tcourseid.'.description'}; |
$sortkey=$role."\0".$tdom."\0".$twhere."\0".$envkey; |
$sortkey=$role."\0".$tdom."\0".$twhere."\0".$envkey; |
unless ($twhere eq &mt('Currently not available')) { |
unless ($twhere eq &mt('Currently not available')) { |
$twhere.=' <font size="-2">'. |
$twhere.=' <span class="LC_fontsize_small">'. |
&Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$trest,$tdom,$tfont). |
&Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$trest,$tdom,$tfont). |
'</font>'; |
'</span>'; |
} |
} |
} else { |
} else { |
my %newhash=&Apache::lonnet::coursedescription($tcourseid); |
my %newhash=&Apache::lonnet::coursedescription($tcourseid); |
Line 672 ENDHEADER
|
Line 769 ENDHEADER
|
$sortkey=$role."\0".$tdom."\0".$newhash{'description'}. |
$sortkey=$role."\0".$tdom."\0".$newhash{'description'}. |
"\0".$envkey; |
"\0".$envkey; |
$twhere=$newhash{'description'}. |
$twhere=$newhash{'description'}. |
' <font size="-2">'. |
' <span class="LC_fontsize_small">'. |
&Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$trest,$tdom,$tfont). |
&Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$trest,$tdom,$tfont). |
'</font>'; |
'</span>'; |
$ttype = $newhash{'type'}; |
$ttype = $newhash{'type'}; |
$trole = &Apache::lonnet::plaintext($role,$ttype); |
$trole = &Apache::lonnet::plaintext($role,$ttype); |
} else { |
} else { |
Line 742 ENDHEADER
|
Line 839 ENDHEADER
|
} else { |
} else { |
$r->print('<tr bgcolor="#77FF77">'); |
$r->print('<tr bgcolor="#77FF77">'); |
} |
} |
$r->print('<td></td><td colspan="3"><font color="'.$tfont.'"><span class="LC_rolesinfo">'.&mt('No role specified'). |
$r->print('<td></td><td colspan="3"><span style="color:'.$tfont.';"><span class="LC_rolesinfo">'.&mt('No role specified'). |
'</span></font></td><td><font color="'.$tfont.'">'.$tremark. |
'</span></font></td><td><span style="color:'.$tfont.';">'.$tremark. |
' </font></td></tr>'."\n"); |
' </font></td></tr>'."\n"); |
|
|
$r->print('</table>'); |
$r->print('</table>'); |
Line 774 ENDHEADER
|
Line 871 ENDHEADER
|
} |
} |
} |
} |
if ($output) { |
if ($output) { |
$r->print("<tr><td align='center' colspan='5'><font face='arial'>". |
$r->print("<tr><td align='center' colspan='5'>". |
&mt('Recent Roles')."</font></td></tr>"); |
&mt('Recent Roles')."</td></tr>"); |
$r->print($output); |
$r->print($output); |
$doheaders ++; |
$doheaders ++; |
} |
} |
Line 805 ENDHEADER
|
Line 902 ENDHEADER
|
$r->print('<td> </td>'); |
$r->print('<td> </td>'); |
} |
} |
} |
} |
$r->print('<td colspan="3"><font color="'.$tfont.'"><span class="LC_rolesinfo">'.&mt('No role specified'). |
$r->print('<td colspan="3"><span style="color:'.$tfont.';"><span class="LC_rolesinfo">'.&mt('No role specified'). |
'</span></font></td><td><font color="'.$tfont.'">'.$tremark. |
'</span></span></td><td><span style="color:'.$tfont.';">'.$tremark. |
' </font></td></tr>'."\n"); |
' </span></td></tr>'."\n"); |
} |
} |
$r->print('</table>'); |
$r->print('</table>'); |
unless ($nochoose) { |
unless ($nochoose) { |
Line 885 sub print_rolerows {
|
Line 982 sub print_rolerows {
|
if ($output) { |
if ($output) { |
if ($doheaders > 0) { |
if ($doheaders > 0) { |
$r->print("<tr>". |
$r->print("<tr>". |
"<td align='center' colspan='5'><font face='arial'>". |
"<td align='center' colspan='5'>". |
&mt($type)."</font></td></tr>"); |
&mt($type)."</td></tr>"); |
} |
} |
$r->print($output); |
$r->print($output); |
} |
} |
Line 1042 sub build_roletext {
|
Line 1139 sub build_roletext {
|
$tremark.=&Apache::lonannounce::showday(time,1, |
$tremark.=&Apache::lonannounce::showday(time,1, |
&Apache::lonannounce::readcalendar($tdom.'_'.$trest)); |
&Apache::lonannounce::readcalendar($tdom.'_'.$trest)); |
} |
} |
$roletext.='<td><font color="'.$tfont.'">'.$trole. |
$roletext.='<td><span style="color:'.$tfont.';">'.$trole. |
'</font></td><td><font color="'.$tfont.'">'.$twhere. |
'</span></td><td><span style="color:'.$tfont.';">'.$twhere. |
'</font></td><td><font color="'.$tfont.'">'.$tpstart. |
'</span></td><td><span style="color:'.$tfont.';">'.$tpstart. |
'</font></td><td><font color="'.$tfont.'">'.$tpend. |
'</span></td><td><span style="color:'.$tfont.';">'.$tpend. |
'</font></td></tr>'; |
'</span></td></tr>'; |
if (!$is_dc) { |
if (!$is_dc) { |
$roletext.='<tr bgcolor="'.$tbg.'"><td colspan="4"><font color="'.$tfont.'"><span class="LC_rolesinfo">'.$tremark. |
$roletext.='<tr bgcolor="'.$tbg.'"><td colspan="4"><span style="color:'.$tfont.';"><span class="LC_rolesinfo">'.$tremark. |
'</span> </font></td></tr><tr><td colspan="5" height="3"></td></tr>'."\n"; |
'</span> </span></td></tr><tr><td colspan="5" height="3"></td></tr>'."\n"; |
} |
} |
return $roletext; |
return $roletext; |
} |
} |
Line 1271 sub display_cc_role {
|
Line 1368 sub display_cc_role {
|
my %newhash=&Apache::lonnet::coursedescription($tcourseid); |
my %newhash=&Apache::lonnet::coursedescription($tcourseid); |
if (%newhash) { |
if (%newhash) { |
$twhere=$newhash{'description'}. |
$twhere=$newhash{'description'}. |
' <font size="-2">'. |
' <span style="LC_fontsize_small">'. |
&Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$2,$1,$tfont). |
&Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$2,$1,$tfont). |
'</font>'; |
'</span>'; |
$ttype = $newhash{'type'}; |
$ttype = $newhash{'type'}; |
} else { |
} else { |
$twhere=&mt('Currently not available'); |
$twhere=&mt('Currently not available'); |