version 1.464, 2016/12/01 16:37:53
|
version 1.466, 2017/01/28 03:48:44
|
Line 2099 sub roles_selector {
|
Line 2099 sub roles_selector {
|
my ($cdom,$cnum,$httphost) = @_; |
my ($cdom,$cnum,$httphost) = @_; |
my $crstype = &Apache::loncommon::course_type(); |
my $crstype = &Apache::loncommon::course_type(); |
my $now = time; |
my $now = time; |
my (%courseroles,%seccount,%courseprivs); |
my (%courseroles,%seccount,%courseprivs,%roledesc); |
my $is_cc; |
my $is_cc; |
my ($js,$form,$switcher); |
my ($js,$form,$switcher); |
my $ccrole; |
my $ccrole; |
Line 2149 sub roles_selector {
|
Line 2149 sub roles_selector {
|
if ($is_cc) { |
if ($is_cc) { |
&get_all_courseroles($cdom,$cnum,\%courseroles,\%seccount,\%courseprivs); |
&get_all_courseroles($cdom,$cnum,\%courseroles,\%seccount,\%courseprivs); |
} elsif ($env{'request.role'} =~ m{^\Qcr/$cdom/$cdom-domainconfig/\E(\w+)\.\Q/$cdom/$cnum\E}) { |
} elsif ($env{'request.role'} =~ m{^\Qcr/$cdom/$cdom-domainconfig/\E(\w+)\.\Q/$cdom/$cnum\E}) { |
&get_customadhoc_roles($cdom,$cnum,\%courseroles,\%seccount,\%courseprivs,$privref); |
&get_customadhoc_roles($cdom,$cnum,\%courseroles,\%seccount,\%courseprivs,\%roledesc,$privref); |
} else { |
} else { |
my %gotnosection; |
my %gotnosection; |
foreach my $item (keys(%env)) { |
foreach my $item (keys(%env)) { |
Line 2203 sub roles_selector {
|
Line 2203 sub roles_selector {
|
} |
} |
if ((keys(%seccount) > 1) || ($numdiffsec > 1)) { |
if ((keys(%seccount) > 1) || ($numdiffsec > 1)) { |
my @submenu; |
my @submenu; |
$js = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles,\%courseprivs,$privref); |
$js = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles,\%courseprivs,\%roledesc,$privref); |
$form = |
$form = |
'<form name="rolechooser" method="post" action="'.$httphost.'/adm/roles">'."\n". |
'<form name="rolechooser" method="post" action="'.$httphost.'/adm/roles">'."\n". |
' <input type="hidden" name="destinationurl" value="'. |
' <input type="hidden" name="destinationurl" value="'. |
Line 2245 sub roles_selector {
|
Line 2245 sub roles_selector {
|
if ($include) { |
if ($include) { |
my $rolename; |
my $rolename; |
if ($role =~ m{^cr/$cdom/$cdom\-domainconfig/(\w+)(?:/\w+|$)}) { |
if ($role =~ m{^cr/$cdom/$cdom\-domainconfig/(\w+)(?:/\w+|$)}) { |
$rolename = &mt('Helpdesk [_1]',$1); |
$rolename = $roledesc{$role}; |
|
if ($rolename eq '') { |
|
$rolename = &mt('Helpdesk [_1]',$1); |
|
} |
} else { |
} else { |
$rolename = &Apache::lonnet::plaintext($role); |
$rolename = &Apache::lonnet::plaintext($role); |
} |
} |
Line 2332 sub get_all_courseroles {
|
Line 2335 sub get_all_courseroles {
|
} |
} |
|
|
sub get_customadhoc_roles { |
sub get_customadhoc_roles { |
my ($cdom,$cnum,$courseroles,$seccount,$courseprivs,$privref) = @_; |
my ($cdom,$cnum,$courseroles,$seccount,$courseprivs,$roledesc,$privref) = @_; |
unless ((ref($courseroles) eq 'HASH') && (ref($seccount) eq 'HASH') && |
unless ((ref($courseroles) eq 'HASH') && (ref($seccount) eq 'HASH') && |
(ref($courseprivs) eq 'HASH')) { |
(ref($courseprivs) eq 'HASH') && (ref($roledesc) eq 'HASH')) { |
return; |
return; |
} |
} |
if ($env{'environment.adhocroles.'.$cdom} ne '') { |
my $is_helpdesk = 0; |
my @customroles = split(/,/,$env{'environment.adhocroles.'.$cdom}); |
my $now = time; |
if (@customroles > 1) { |
foreach my $role ('dh','da') { |
if ($env{"user.role.dh./$cdom/"}) { |
if ($env{"user.role.$role./$cdom/"}) { |
my ($start,$end)=split(/\./,$env{"user.role.dh./$cdom/"}); |
my ($start,$end)=split(/\./,$env{"user.role.$role./$cdom/"}); |
my $now = time; |
if (!($start && ($now<$start)) && !($end && ($now>$end))) { |
if (!($start && ($now<$start)) & !($end && ($now>$end))) { |
$is_helpdesk = 1; |
my $numsec = 1; |
last; |
my @sections; |
} |
my ($allseclist,$cached) = |
} |
&Apache::lonnet::is_cached_new('courseseclist',$cdom.'_'.$cnum); |
} |
if (defined($cached)) { |
if ($is_helpdesk) { |
if ($allseclist ne '') { |
my ($possroles,$description) = &Apache::lonnet::get_my_adhocroles($cdom.'_'.$cnum); |
@sections = split(/,/,$allseclist); |
my %available; |
$numsec += scalar(@sections); |
if (ref($possroles) eq 'ARRAY') { |
} |
map { $available{$_} = 1; } @{$possroles}; |
} else { |
} |
my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum); |
my %domdefaults = &Apache::lonnet::get_domain_defaults($cdom); |
$numsec += scalar(keys(%sections_count)); |
if (ref($domdefaults{'adhocroles'}) eq 'HASH') { |
$allseclist = join(',',sort(keys(%sections_count))); |
if (keys(%{$domdefaults{'adhocroles'}})) { |
&Apache::lonnet::do_cache_new('courseseclist',$cdom.'_'.$cnum,$allseclist); |
my $numsec = 1; |
|
my @sections; |
|
my ($allseclist,$cached) = |
|
&Apache::lonnet::is_cached_new('courseseclist',$cdom.'_'.$cnum); |
|
if (defined($cached)) { |
|
if ($allseclist ne '') { |
|
@sections = split(/,/,$allseclist); |
|
$numsec += scalar(@sections); |
} |
} |
my (%adhoc,$gotprivs); |
} else { |
my $prefix = "cr/$cdom/$cdom".'-domainconfig'; |
my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum); |
foreach my $role (@customroles) { |
@sections = sort(keys(%sections_count)); |
next if (($role eq '') || ($role =~ /\W/)); |
$numsec += scalar(@sections); |
$seccount->{"$prefix/$role"} = $numsec; |
$allseclist = join(',',@sections); |
$courseroles->{"$prefix/$role"} = \@sections; |
&Apache::lonnet::do_cache_new('courseseclist',$cdom.'_'.$cnum,$allseclist); |
if ((ref($privref) eq 'ARRAY') && (@{$privref} > 0)) { |
} |
if (exists($env{"user.priv.$prefix/$role./$cdom/$cnum./"})) { |
my (%adhoc,$gotprivs); |
$courseprivs->{"$prefix/$role./$cdom/$cnum./"} = |
my $prefix = "cr/$cdom/$cdom".'-domainconfig'; |
$env{"user.priv.$prefix/$role./$cdom/$cnum./"}; |
foreach my $role (keys(%{$domdefaults{'adhocroles'}})) { |
$courseprivs->{"$prefix/$role./$cdom/$cnum./$cdom/"} = |
next if (($role eq '') || ($role =~ /\W/)); |
$env{"user.priv.$prefix/$role./$cdom/$cnum./$cdom/"}; |
$seccount->{"$prefix/$role"} = $numsec; |
$courseprivs->{"$prefix/$role./$cdom/$cnum./$cdom/$cnum"} = |
$roledesc->{"$prefix/$role"} = $description->{$role}; |
$env{"user.priv.$prefix/$role./$cdom/$cnum./$cdom/$cnum"}; |
if ((ref($privref) eq 'ARRAY') && (@{$privref} > 0)) { |
} else { |
if (exists($env{"user.priv.$prefix/$role./$cdom/$cnum./"})) { |
unless ($gotprivs) { |
$courseprivs->{"$prefix/$role./$cdom/$cnum./"} = |
my ($adhocroles,$privscached) = |
$env{"user.priv.$prefix/$role./$cdom/$cnum./"}; |
&Apache::lonnet::is_cached_new('adhocroles',$cdom); |
$courseprivs->{"$prefix/$role./$cdom/$cnum./$cdom/"} = |
if ((defined($privscached)) && (ref($adhocroles) eq 'HASH')) { |
$env{"user.priv.$prefix/$role./$cdom/$cnum./$cdom/"}; |
%adhoc = %{$adhocroles}; |
$courseprivs->{"$prefix/$role./$cdom/$cnum./$cdom/$cnum"} = |
} else { |
$env{"user.priv.$prefix/$role./$cdom/$cnum./$cdom/$cnum"}; |
my $confname = &Apache::lonnet::get_domainconfiguser($cdom); |
} else { |
my %roledefs = &Apache::lonnet::dump('roles',$cdom,$confname,'rolesdef_'); |
unless ($gotprivs) { |
foreach my $key (keys(%roledefs)) { |
my ($adhocroles,$privscached) = |
(undef,my $rolename) = split(/_/,$key); |
&Apache::lonnet::is_cached_new('adhocroles',$cdom); |
if ($rolename ne '') { |
if ((defined($privscached)) && (ref($adhocroles) eq 'HASH')) { |
$adhoc{$rolename} = $roledefs{$key}; |
%adhoc = %{$adhocroles}; |
} |
} else { |
|
my $confname = &Apache::lonnet::get_domainconfiguser($cdom); |
|
my %roledefs = &Apache::lonnet::dump('roles',$cdom,$confname,'rolesdef_'); |
|
foreach my $key (keys(%roledefs)) { |
|
(undef,my $rolename) = split(/_/,$key); |
|
if ($rolename ne '') { |
|
my ($systempriv,$domainpriv,$coursepriv) = split(/\_/,$roledefs{$key}); |
|
$coursepriv = &Apache::lonnet::course_adhocrole_privs($rolename,$cdom,$cnum,$coursepriv); |
|
$adhoc{$rolename} = join('_',($systempriv,$domainpriv,$coursepriv)); |
} |
} |
&Apache::lonnet::do_cache_new('adhocroles',$cdom,\%adhoc); |
|
} |
} |
$gotprivs = 1; |
&Apache::lonnet::do_cache_new('adhocroles',$cdom,\%adhoc); |
} |
} |
($courseprivs->{"$prefix/$role./$cdom/$cnum./"}, |
$gotprivs = 1; |
$courseprivs->{"$prefix/$role./$cdom/$cnum./$cdom/"}, |
|
$courseprivs->{"$prefix/$role./$cdom/$cnum./$cdom/$cnum"}) = |
|
split(/\_/,$adhoc{$role}); |
|
} |
} |
|
($courseprivs->{"$prefix/$role./$cdom/$cnum./"}, |
|
$courseprivs->{"$prefix/$role./$cdom/$cnum./$cdom/"}, |
|
$courseprivs->{"$prefix/$role./$cdom/$cnum./$cdom/$cnum"}) = |
|
split(/\_/,$adhoc{$role}); |
} |
} |
} |
} |
|
if ($available{$role}) { |
|
$courseroles->{"$prefix/$role"} = \@sections; |
|
} |
} |
} |
} |
} |
} |
} |
Line 2407 sub get_customadhoc_roles {
|
Line 2428 sub get_customadhoc_roles {
|
} |
} |
|
|
sub jump_to_role { |
sub jump_to_role { |
my ($cdom,$cnum,$seccount,$courseroles,$courseprivs,$privref) = @_; |
my ($cdom,$cnum,$seccount,$courseroles,$courseprivs,$roledesc,$privref) = @_; |
my %lt = &Apache::lonlocal::texthash( |
my %lt = &Apache::lonlocal::texthash( |
this => 'This role has section(s) associated with it.', |
this => 'This role has section(s) associated with it.', |
ente => 'Enter a specific section.', |
ente => 'Enter a specific section.', |