--- loncom/auth/lonroles.pm 2008/05/12 23:47:37 1.188
+++ loncom/auth/lonroles.pm 2008/05/15 01:00:37 1.192
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# User Roles Screen
#
-# $Id: lonroles.pm,v 1.188 2008/05/12 23:47:37 www Exp $
+# $Id: lonroles.pm,v 1.192 2008/05/15 01:00:37 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -137,6 +137,18 @@ sub handler {
# Is this an ad-hoc CC-role?
if (my ($domain,$coursenum) =
($envkey =~ m-^form\.cc\./($match_domain)/($match_courseid)$-)) {
+ # See if that is even allowed
+ my %crsenv=&Apache::lonnet::get('environment',['internal.courseowner'],$domain,$coursenum);
+ # First find course owner
+ my ($owneruser,$ownerdomain)=split(/\:/,$crsenv{'internal.courseowner'});
+ # Check if course owner blocked cc-access
+ if (($owneruser) && ($ownerdomain)) {
+ my %blocked=&Apache::lonnet::get('environment',['domcoord.cc'],$ownerdomain,$owneruser);
+ if ($blocked{'domcoord.cc'} eq 'blocked') {
+ $env{'user.error.msg'}=':::1:Course owner '.$owneruser.' in domain '.$ownerdomain.' blocked domain coordinator access';
+ last;
+ }
+ }
if ($dcroles{$domain}) {
&check_privs($domain,$coursenum,$then,$now,'cc');
}
@@ -145,6 +157,13 @@ sub handler {
# Is this a recent ad-hoc CA-role?
if (my ($domain,$user) =
($envkey =~ m-^form\.ca\./($match_domain)/($match_username)$-)) {
+ # See if still allowed
+ my %blocked=&Apache::lonnet::get('environment',['domcoord.author'],$domain,$user);
+ if ($blocked{'domcoord.author'} eq 'blocked') {
+ delete($env{$envkey});
+ $env{'user.error.msg'}=':::1:User '.$user.' in domain '.$domain.' blocked domain coordinator access';
+ last;
+ }
if (($dcroles{$domain}) && (&is_author_homeserver($user,$domain))) {
&check_privs($domain,$user,$then,$now,'ca');
} else {
@@ -155,9 +174,15 @@ sub handler {
# Is this a new ad-hoc CA-role?
if (my ($domain) =
($envkey =~ m-^form\.adhocca\./($match_domain)$-)) {
+ my $user=$env{'form.adhoccauname.'.$domain};
+ if (!$user) { $user=$env{'form.adhoccaunamerecent.'.$domain} };
+ # See if that is even allowed
+ my %blocked=&Apache::lonnet::get('environment',['domcoord.author'],$domain,$user);
+ if ($blocked{'domcoord.author'} eq 'blocked') {
+ $env{'user.error.msg'}=':::1:User '.$user.' in domain '.$domain.' blocked domain coordinator access';
+ last;
+ }
if ($dcroles{$domain}) {
- my $user=$env{'form.adhoccauname.'.$domain};
- if (!$user) { $user=$env{'form.adhoccaunamerecent.'.$domain} };
if (($user) && ($user=~/$match_username/) && (&is_author_homeserver($user,$domain))) {
&check_privs($domain,$user,$then,$now,'ca');
$env{'form.ca./'.$domain.'/'.$user}=1;
@@ -505,8 +530,12 @@ ENDHEADER
my (%roletext,%sortrole,%roleclass);
my $countactive=0;
+ my $countfuture=0;
+ my $countwill=0;
my $inrole=0;
my $possiblerole='';
+ my %futureroles;
+ my %roles_nextlogin;
foreach $envkey (sort keys %env) {
my $button = 1;
my $switchserver='';
@@ -543,9 +572,13 @@ ENDHEADER
} elsif ($tstatus eq 'future') {
$tbg='#FFFF77';
$button=0;
+ $futureroles{$trolecode} = $tstart.':'.$tend;
+ $countfuture ++;
} elsif ($tstatus eq 'will') {
$tbg='#FFAA77';
$tremark.=&mt('Active at next login. ');
+ $roles_nextlogin{$trolecode} = $tstart.':'.$tend;
+ $countwill ++;
} elsif ($tstatus eq 'expired') {
$tbg='#FF7777';
$tfont='#330000';
@@ -668,7 +701,30 @@ ENDHEADER
} else {
$r->print('
'.&mt('Currently no active roles or courses').'
');
}
- $r->print(''.&Apache::loncommon::end_page());
+ &findcourse_advice($r);
+ $r->print('');
+ if ($countfuture) {
+ $r->print(&mt('The following [quant,_1,role,roles] will become active in the future:',$countfuture));
+ my $doheaders = &roletable_headers($r,\%roleclass,\%sortrole,
+ $nochoose);
+ &print_rolerows($r,$doheaders,\%roleclass,\%sortrole,\%dcroles,
+ \%roletext);
+ my $tremark='';
+ my $tfont='#003300';
+ if ($env{'request.role'} eq 'cm') {
+ $r->print('');
+ $tremark=&mt('Currently selected. ');
+ $tfont='#002200';
+ } else {
+ $r->print('
');
+ }
+ $r->print(' | '.&mt('No role specified').
+ ' | '.$tremark.
+ ' |
'."\n");
+
+ $r->print('');
+ }
+ $r->print(&Apache::loncommon::end_page());
return OK;
# Is there only one choice?
} elsif (($countactive==1) && ($env{'request.role'} eq 'cm')) {
@@ -686,21 +742,7 @@ ENDHEADER
unless ((!&Apache::lonmenu::show_course()) || ($nochoose)) {
$r->print("".&mt('Select a Course to Enter')."
\n");
}
- $r->print('
');
@@ -793,6 +813,87 @@ ENDHEADER
return OK;
}
+sub roletable_headers {
+ my ($r,$roleclass,$sortrole,$nochoose) = @_;
+ my $doheaders;
+ if ((ref($sortrole) eq 'HASH') && (ref($roleclass) eq 'HASH')) {
+ $r->print('