[LON-CAPA-cvs] cvs: loncom /auth lonroles.pm
raeburn
lon-capa-cvs-allow@mail.lon-capa.org
Wed, 03 Sep 2008 04:28:22 -0000
raeburn Wed Sep 3 00:28:22 2008 EDT
Modified files:
/loncom/auth lonroles.pm
Log:
Bug 5779 (introduced in 1.183 -- work on bug 3765):
- If user was a DC in at least one domain, but was not a DC in the domain to which the CA role belonged, the assigned CA role could not be selected.
- Fix is to check if DC actually has the CA role active in user roles in %env, before checking for DC status in the domain to which the CA belongs. If so, check if switchserver is needed.
- Also check if requested CA role is actually for author space of current user - if so, set role request to AU instead of CA (CA in the user's own CSTR doesn't make sense).
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.205 loncom/auth/lonroles.pm:1.206
--- loncom/auth/lonroles.pm:1.205 Mon Sep 1 22:56:52 2008
+++ loncom/auth/lonroles.pm Wed Sep 3 00:28:22 2008
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# User Roles Screen
#
-# $Id: lonroles.pm,v 1.205 2008/09/02 02:56:52 raeburn Exp $
+# $Id: lonroles.pm,v 1.206 2008/09/03 04:28:22 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -146,16 +146,36 @@
# Is this an ad-hoc CA-role?
if (my ($domain,$user) =
($envkey =~ m-^form\.ca\./($match_domain)/($match_username)$-)) {
- # Check if author blocked ca-access
- my %blocked=&Apache::lonnet::get('environment',['domcoord.author'],$domain,$user);
- if ($blocked{'domcoord.author'} eq 'blocked') {
- my %roleshash = &Apache::lonnet::get_my_roles($user,$domain);
- if (!defined($roleshash{$env{'user.name'}.':'.$env{'user.domain'}.':ca'})) {
- delete($env{$envkey});
- $env{'user.error.msg'}=':::1:User '.$user.' in domain '.$domain.' blocked domain coordinator access';
+ if (($domain eq $env{'user.domain'}) && ($user eq $env{'user.name'})) {
+ delete($env{$envkey});
+ $env{'form.au./'.$domain.'/'} = 1;
+ my ($server_status,$home) = &check_author_homeserver($user,$domain);
+ if ($server_status eq 'switchserver') {
+ my $trolecode = 'au./'.$domain.'/';
+ my $switchserver = '/adm/switchserver?otherserver='.$home.'&role='.$trolecode;
+ $r->internal_redirect($switchserver);
+ }
+ last;
+ }
+ if (my ($castart,$caend) = ($env{'user.role.ca./'.$domain.'/'.$user} =~ /^(\d*)\.(\d*)$/)) {
+ if (((($castart) && ($castart < $now)) || !$castart) &&
+ ((!$caend) || (($caend) && ($caend > $now)))) {
+ my ($server_status,$home) = &check_author_homeserver($user,$domain);
+ if ($server_status eq 'switchserver') {
+ my $trolecode = 'ca./'.$domain.'/'.$user;
+ my $switchserver = '/adm/switchserver?otherserver='.$home.'&role='.$trolecode;
+ $r->internal_redirect($switchserver);
+ }
last;
}
}
+ # Check if author blocked ca-access
+ 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}) {
my ($server_status,$home) = &check_author_homeserver($user,$domain);
if (($server_status eq 'ok') || ($server_status eq 'switchserver')) {