--- loncom/auth/lonroles.pm 2016/05/04 05:14:49 1.314 +++ loncom/auth/lonroles.pm 2016/10/05 13:30:16 1.315 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # User Roles Screen # -# $Id: lonroles.pm,v 1.314 2016/05/04 05:14:49 raeburn Exp $ +# $Id: lonroles.pm,v 1.315 2016/10/05 13:30:16 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -264,8 +264,15 @@ sub handler { my $locknum=&Apache::lonnet::get_locks(); if ($locknum) { return 409; } + my $custom_adhoc; if ($env{'form.newrole'}) { $env{'form.'.$env{'form.newrole'}}=1; +# Check if this is a Domain Helpdesk role trying to enter a course + if ($env{'form.newrole'} =~ m{^cr/($match_domain)/\1\-domainconfig/\w+\./\1/$match_courseid$}) { + if (&Apache::lonnet::allowed('rar',$1)) { + $custom_adhoc = 1; + } + } } if ($env{'request.course.id'}) { # Check if user is CC trying to select a course role @@ -296,8 +303,26 @@ sub handler { "request.role" => 'cm', "request.role.adv" => $env{'user.adv'}, "request.role.domain" => $env{'user.domain'}}); +# Check if Domain Helpdesk role trying to enter a course needs privs to be created + if ($env{'form.newrole'} =~ m{^cr/($match_domain)/\1\-domainconfig/(\w+)\./\1/($match_courseid)$}) { + my $cdom = $1; + my $rolename = $2; + my $cnum = $3; + if ($custom_adhoc) { + my %adhocroles = &Apache::lonnet::userenvironment($env{'user.domain'},$env{'user.name'}, + 'adhocroles.'.$cdom); + if (keys(%adhocroles)) { + my @adhoc = split(',',$adhocroles{'adhocroles.'.$cdom}); + if (grep(/^\Q$rolename\E$/,@adhoc)) { + if (&Apache::lonnet::check_adhoc_privs($cdom,$cnum,$update,$refresh,$now, + "cr/$cdom/$cdom".'-domainconfig/'.$rolename)) { + &Apache::lonnet::appenv({"environment.internal.$cdom.$cnum.cr/$cdom/$cdom".'-domainconfig'."$rolename.adhoc" => time}); + } + } + } + } + } elsif ($numdc > 0) { # 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 Coordinator role? if (my ($ccrole,$domain,$coursenum) = @@ -716,6 +741,12 @@ ENDENTERKEY $redirect_url); return OK; } + if ($role eq 'dh') { + my $redirect_url = '/adm/menu/'; + &redirect_user($r,&mt('Loading Domain Helpdesk Menu'), + $redirect_url); + return OK; + } if ($role eq 'sc') { my $redirect_url = '/adm/grades?command=scantronupload'; &redirect_user($r,&mt('Loading Data Upload Page'),