--- loncom/auth/lonroles.pm 2008/01/26 21:12:32 1.182 +++ loncom/auth/lonroles.pm 2008/01/30 01:18:58 1.183 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # User Roles Screen # -# $Id: lonroles.pm,v 1.182 2008/01/26 21:12:32 www Exp $ +# $Id: lonroles.pm,v 1.183 2008/01/30 01:18:58 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -134,10 +134,12 @@ sub handler { last; } # Is this a recent ad-hoc CA-role? - if (my ($domain,$coursenum) = - ($envkey =~ m-^form\.ca\./($match_domain)/($match_courseid)$-)) { - if ($dcroles{$domain}) { - &check_privs($domain,$coursenum,$then,$now,'ca'); + if (my ($domain,$user) = + ($envkey =~ m-^form\.ca\./($match_domain)/($match_username)$-)) { + if (($dcroles{$domain}) && (&is_author_homeserver($user,$domain))) { + &check_privs($domain,$user,$then,$now,'ca'); + } else { + delete($env{$envkey}); } last; } @@ -147,7 +149,7 @@ sub handler { if ($dcroles{$domain}) { my $user=$env{'form.adhoccauname.'.$domain}; if (!$user) { $user=$env{'form.adhoccaunamerecent.'.$domain} }; - if (($user) && ($user=~/$match_username/)) { + if (($user) && ($user=~/$match_username/) && (&is_author_homeserver($user,$domain))) { &check_privs($domain,$user,$then,$now,'ca'); $env{'form.ca./'.$domain.'/'.$user}=1; } @@ -905,6 +907,20 @@ sub build_roletext { return $roletext; } +sub is_author_homeserver { + my ($uname,$udom)=@_; + my $home = &Apache::lonnet::homeserver($uname,$udom); + my @ids=&Apache::lonnet::current_machine_ids(); + foreach my $id (@ids) { + if ($id eq $home) { + if (-e "/home/".$uname."/public_html") { + return 1; + } + } + } + return 0; +} + sub check_privs { my ($cdom,$cnum,$then,$now,$checkrole) = @_; my $cckey = 'user.role.'.$checkrole.'./'.$cdom.'/'.$cnum;