--- loncom/auth/lonroles.pm 2008/03/10 23:47:24 1.185 +++ loncom/auth/lonroles.pm 2008/05/14 19:18:37 1.189 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # User Roles Screen # -# $Id: lonroles.pm,v 1.185 2008/03/10 23:47:24 raeburn Exp $ +# $Id: lonroles.pm,v 1.189 2008/05/14 19:18:37 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -106,6 +106,10 @@ sub handler { # ================================================================== Roles Init if ($env{'form.selectrole'}) { + + my $locknum=&Apache::lonnet::get_locks(); + if ($locknum) { return 409; } + if ($env{'form.newrole'}) { $env{'form.'.$env{'form.newrole'}}=1; } @@ -120,19 +124,21 @@ sub handler { &Apache::lonnet::put('email_status',\%temp); &Apache::lonnet::delenv('user.state.'.$env{'request.course.id'}); } - &Apache::lonnet::appenv("request.course.id" => '', - "request.course.fn" => '', - "request.course.uri" => '', - "request.course.sec" => '', - "request.role" => 'cm', - "request.role.adv" => $env{'user.adv'}, - "request.role.domain" => $env{'user.domain'}); + &Apache::lonnet::appenv({"request.course.id" => '', + "request.course.fn" => '', + "request.course.uri" => '', + "request.course.sec" => '', + "request.role" => 'cm', + "request.role.adv" => $env{'user.adv'}, + "request.role.domain" => $env{'user.domain'}}); # Check if user is a DC trying to enter a course or author space and needs privs to be created if ($numdc > 0) { foreach my $envkey (keys %env) { # 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 + if ($dcroles{$domain}) { &check_privs($domain,$coursenum,$then,$now,'cc'); } @@ -151,9 +157,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; @@ -274,10 +286,10 @@ ENDENTERKEY "Role ".$trolecode); &Apache::lonnet::appenv( - 'request.role' => $trolecode, - 'request.role.domain' => $cdom, - 'request.course.sec' => $csec, - 'request.course.groups' => $cgrps); + {'request.role' => $trolecode, + 'request.role.domain' => $cdom, + 'request.course.sec' => $csec, + 'request.course.groups' => $cgrps}); my $tadv=0; if (($cnum) && ($role ne 'ca') && ($role ne 'aa')) { @@ -288,7 +300,7 @@ ENDENTERKEY ($env{'form.orgurl'}!~/^\/adm\/flip/)) { my $dest=$env{'form.orgurl'}; if (&Apache::lonnet::allowed('adv') eq 'F') { $tadv=1; } - &Apache::lonnet::appenv('request.role.adv'=>$tadv); + &Apache::lonnet::appenv({'request.role.adv'=>$tadv}); if (($ferr) && ($tadv)) { &error_page($r,$ferr,$dest); } else { @@ -298,7 +310,7 @@ ENDENTERKEY } else { if (!$env{'request.course.id'}) { &Apache::lonnet::appenv( - "request.course.id" => $cdom.'_'.$cnum); + {"request.course.id" => $cdom.'_'.$cnum}); $furl='/adm/roles?tryagain=1'; $msg= '
"); if ($priv ne '') { - $r->print("Access : ".&Apache::lonnet::plaintext($priv)."\n"); + $r->print(&mt('Access : ').&Apache::lonnet::plaintext($priv)."\n"); } if ($fn ne '') { - $r->print("Resource: ".&Apache::lonenc::check_encrypt($fn)."\n"); + $r->print(&mt('Resource: ').&Apache::lonenc::check_encrypt($fn)."\n"); } if ($msg ne '') { - $r->print("Action : $msg\n"); + $r->print(&mt('Action : ').$msg."\n"); } $r->print("