version 1.319, 2016/10/27 21:06:00
|
version 1.322, 2016/11/08 23:15:34
|
Line 305 sub handler {
|
Line 305 sub handler {
|
"request.role.adv" => $env{'user.adv'}, |
"request.role.adv" => $env{'user.adv'}, |
"request.role.domain" => $env{'user.domain'}}); |
"request.role.domain" => $env{'user.domain'}}); |
# Check if Domain Helpdesk role trying to enter a course needs privs to be created |
# 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)$}) { |
if ($env{'form.newrole'} =~ m{^cr/($match_domain)/\1\-domainconfig/(\w+)\./\1/($match_courseid)(?:/(\w+)|$)}) { |
my $cdom = $1; |
my $cdom = $1; |
my $rolename = $2; |
my $rolename = $2; |
my $cnum = $3; |
my $cnum = $3; |
|
my $sec = $4; |
if ($custom_adhoc) { |
if ($custom_adhoc) { |
my %adhocroles = &Apache::lonnet::userenvironment($env{'user.domain'},$env{'user.name'}, |
my %adhocroles = &Apache::lonnet::userenvironment($env{'user.domain'},$env{'user.name'}, |
'adhocroles.'.$cdom); |
'adhocroles.'.$cdom); |
Line 316 sub handler {
|
Line 317 sub handler {
|
my @adhoc = split(',',$adhocroles{'adhocroles.'.$cdom}); |
my @adhoc = split(',',$adhocroles{'adhocroles.'.$cdom}); |
if (grep(/^\Q$rolename\E$/,@adhoc)) { |
if (grep(/^\Q$rolename\E$/,@adhoc)) { |
if (&Apache::lonnet::check_adhoc_privs($cdom,$cnum,$update,$refresh,$now, |
if (&Apache::lonnet::check_adhoc_privs($cdom,$cnum,$update,$refresh,$now, |
"cr/$cdom/$cdom".'-domainconfig/'.$rolename)) { |
"cr/$cdom/$cdom".'-domainconfig/'.$rolename,undef,$sec)) { |
&Apache::lonnet::appenv({"environment.internal.$cdom.$cnum.cr/$cdom/$cdom".'-domainconfig/'."$rolename.adhoc" => time}); |
&Apache::lonnet::appenv({"environment.internal.$cdom.$cnum.cr/$cdom/$cdom".'-domainconfig/'."$rolename.adhoc" => time}); |
} |
} |
} |
} |
Line 396 sub handler {
|
Line 397 sub handler {
|
} |
} |
if ($numdh) { |
if ($numdh) { |
# Is this an ad hoc custom role in a course/community? |
# Is this an ad hoc custom role in a course/community? |
if (my ($domain,$rolename,$coursenum) = ($envkey =~ m{^form\.cr/($match_domain)/\1\-domainconfig/(\w+)\./\1/($match_courseid)$})) { |
if (my ($domain,$rolename,$coursenum,$sec) = ($envkey =~ m{^form\.cr/($match_domain)/\1\-domainconfig/(\w+)\./\1/($match_courseid)(?:/(\w+)|$)})) { |
if ($dhroles{$domain}) { |
if ($dhroles{$domain}) { |
my @adhoc; |
my @adhoc; |
if ($env{'environment.adhocroles.'.$domain}) { |
if ($env{'environment.adhocroles.'.$domain}) { |
@adhoc = split(',',$env{'environment.adhocroles.'.$domain}); |
@adhoc = split(',',$env{'environment.adhocroles.'.$domain}); |
} else { |
} else { |
my %adhocroles = &Apache::lonnet::userenvironment($env{'user.domain'},$env{'user.name'}, |
my %adhocroles = &Apache::lonnet::userenvironment($env{'user.domain'},$env{'user.name'}, |
'adhocroles.'.$domain); |
'adhocroles.'.$domain); |
if (keys(%adhocroles)) { |
if (keys(%adhocroles)) { |
@adhoc = split(',',$adhocroles{'adhocroles.'.$domain}); |
@adhoc = split(',',$adhocroles{'adhocroles.'.$domain}); |
}; |
} |
} |
} |
if ((@adhoc > 0) && ($rolename ne '')) { |
if ((@adhoc > 0) && ($rolename ne '')) { |
if (grep(/^\Q$rolename\E$/,@adhoc)) { |
if (grep(/^\Q$rolename\E$/,@adhoc)) { |
if (&Apache::lonnet::check_adhoc_privs($domain,$coursenum,$update,$refresh,$now, |
if (&Apache::lonnet::check_adhoc_privs($domain,$coursenum,$update,$refresh,$now, |
"cr/$domain/$domain".'-domainconfig/'.$rolename)) { |
"cr/$domain/$domain".'-domainconfig/'.$rolename, |
&Apache::lonnet::appenv({"environment.internal.$domain.$coursenum.cr/$domain/$domain". |
undef,$sec)) { |
'-domainconfig/'."$rolename.adhoc" => time}); |
&Apache::lonnet::appenv({"environment.internal.$domain.$coursenum.cr/$domain/$domain". |
} |
'-domainconfig/'."$rolename.adhoc" => time}); |
} else { |
} |
delete($env{$envkey}); |
} else { |
} |
delete($env{$envkey}); |
} else { |
} |
delete($env{$envkey}); |
} else { |
} |
delete($env{$envkey}); |
} else { |
} |
delete($env{$envkey}); |
} else { |
} |
delete($env{$envkey}); |
last; |
} |
} |
last; |
} |
} |
} |
} |
|
} |
} |
} |
foreach $envkey (keys(%env)) { |
foreach $envkey (keys(%env)) { |
next if ($envkey!~/^user\.role\./); |
next if ($envkey!~/^user\.role\./); |
Line 1275 sub gather_roles {
|
Line 1277 sub gather_roles {
|
my $trole; |
my $trole; |
if ($role =~ /^cr\//) { |
if ($role =~ /^cr\//) { |
my ($rdummy,$rdomain,$rauthor,$rrole)=split(/\//,$role); |
my ($rdummy,$rdomain,$rauthor,$rrole)=split(/\//,$role); |
if ($tremark) { $tremark.='<br />'; } |
unless ($rauthor eq $rdomain.'-domainconfig') { |
$tremark.=&mt('Custom role defined by [_1].',$rauthor.':'.$rdomain); |
if ($tremark) { $tremark.='<br />'; } |
|
$tremark.=&mt('Custom role defined by [_1].',$rauthor.':'.$rdomain); |
|
} |
} |
} |
$trole=Apache::lonnet::plaintext($role); |
$trole=Apache::lonnet::plaintext($role); |
my $ttype; |
my $ttype; |
Line 1323 sub gather_roles {
|
Line 1327 sub gather_roles {
|
} elsif ($trest) { |
} elsif ($trest) { |
my $tcourseid=$tdom.'_'.$trest; |
my $tcourseid=$tdom.'_'.$trest; |
$ttype = &Apache::loncommon::course_type($tcourseid); |
$ttype = &Apache::loncommon::course_type($tcourseid); |
$trole = &Apache::lonnet::plaintext($role,$ttype,$tcourseid); |
if ($role !~ /^cr/) { |
|
$trole = &Apache::lonnet::plaintext($role,$ttype,$tcourseid); |
|
} elsif ($role =~ m{^cr/($match_domain)/\1-domainconfig/(\w+)$}) { |
|
$trole = &mt('Helpdesk[_1]',' '.$2); |
|
} else { |
|
$trole = (split(/\//,$role,4))[-1]; |
|
} |
if ($env{'course.'.$tcourseid.'.description'}) { |
if ($env{'course.'.$tcourseid.'.description'}) { |
my $home=$env{'course.'.$tcourseid.'.home'}; |
my $home=$env{'course.'.$tcourseid.'.home'}; |
$twhere=$env{'course.'.$tcourseid.'.description'}; |
$twhere=$env{'course.'.$tcourseid.'.description'}; |
Line 1857 sub adhoc_course_role {
|
Line 1867 sub adhoc_course_role {
|
my %cgroups = |
my %cgroups = |
&Apache::lonnet::get_active_groups($env{'user.domain'}, |
&Apache::lonnet::get_active_groups($env{'user.domain'}, |
$env{'user.name'},$cdom,$cnum); |
$env{'user.name'},$cdom,$cnum); |
|
my $ccrole; |
|
if ($crstype eq 'Community') { |
|
$ccrole = 'co'; |
|
} else { |
|
$ccrole = 'cc'; |
|
} |
foreach my $group (keys(%cgroups)) { |
foreach my $group (keys(%cgroups)) { |
$group_privs{$group} = |
$group_privs{$group} = |
$env{'user.priv.cc./'.$cdom.'/'.$cnum.'./'.$cdom.'/'.$cnum.'/'.$group}; |
$env{'user.priv.'.$ccrole.'./'.$cdom.'/'.$cnum.'./'.$cdom.'/'.$cnum.'/'.$group}; |
} |
} |
$newgroups{'/'.$cdom.'/'.$cnum} = \%group_privs; |
$newgroups{'/'.$cdom.'/'.$cnum} = \%group_privs; |
my $area = '/'.$cdom.'/'.$cnum; |
my $area = '/'.$cdom.'/'.$cnum; |