version 1.461, 2016/11/09 14:23:36
|
version 1.467, 2017/02/18 23:39:16
|
Line 381 sub secondary_menu {
|
Line 381 sub secondary_menu {
|
? "/$env{'request.course.sec'}" |
? "/$env{'request.course.sec'}" |
: ''); |
: ''); |
my $canedit = &Apache::lonnet::allowed('mdc', $env{'request.course.id'}); |
my $canedit = &Apache::lonnet::allowed('mdc', $env{'request.course.id'}); |
|
my $canvieweditor = &Apache::lonnet::allowed('cev', $env{'request.course.id'}); |
my $canviewroster = $env{'course.'.$env{'request.course.id'}.'.student_classlist_view'}; |
my $canviewroster = $env{'course.'.$env{'request.course.id'}.'.student_classlist_view'}; |
if ($canviewroster eq 'disabled') { |
if ($canviewroster eq 'disabled') { |
undef($canviewroster); |
undef($canviewroster); |
Line 400 sub secondary_menu {
|
Line 401 sub secondary_menu {
|
if ($env{'request.course.id'}) { |
if ($env{'request.course.id'}) { |
$cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
$cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
$cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
$cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
if ($canedit) { |
if ($canedit || $canvieweditor) { |
$showsyllabus = 1; |
$showsyllabus = 1; |
$showfeeds = 1; |
$showfeeds = 1; |
} else { |
} else { |
Line 416 sub secondary_menu {
|
Line 417 sub secondary_menu {
|
$showfeeds = 1; |
$showfeeds = 1; |
} |
} |
} |
} |
unless (($canmgr || $canvgr)) { |
unless ($canmgr || $canvgr) { |
my %slots = &Apache::lonnet::get_course_slots($cnum,$cdom); |
my %slots = &Apache::lonnet::get_course_slots($cnum,$cdom); |
if (keys(%slots) > 0) { |
if (keys(%slots) > 0) { |
$showresv = 1; |
$showresv = 1; |
Line 452 sub secondary_menu {
|
Line 453 sub secondary_menu {
|
next if $$menuitem[4] ne 'always' |
next if $$menuitem[4] ne 'always' |
&& ($$menuitem[4] ne 'author' && $$menuitem[4] ne 'cca') |
&& ($$menuitem[4] ne 'author' && $$menuitem[4] ne 'cca') |
&& !$env{'request.course.id'}; |
&& !$env{'request.course.id'}; |
next if $$menuitem[4] =~ /^mdc/ |
next if $$menuitem[4] =~ /^crsedit/ |
&& !$canedit; |
&& (!$canedit && !$canvieweditor); |
next if $$menuitem[4] eq 'nvgr' |
next if $$menuitem[4] eq 'nvgr' |
&& $canvgr; |
&& $canvgr; |
next if $$menuitem[4] eq 'vgr' |
next if $$menuitem[4] eq 'vgr' |
Line 502 sub secondary_menu {
|
Line 503 sub secondary_menu {
|
} else { |
} else { |
$$menuitem[0] =~ s{\?register=1}{}; |
$$menuitem[0] =~ s{\?register=1}{}; |
} |
} |
|
if (($ENV{'SERVER_PORT'} == 443) && |
|
($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) { |
|
$$menuitem[0] .= ($$menuitem[0]=~/\?/) ? '&' : '?' . 'usehttp=1'; |
|
} |
} |
} |
$menu .= &prep_menuitem(\@$menuitem); |
$menu .= &prep_menuitem(\@$menuitem); |
} |
} |
Line 746 sub innerregister {
|
Line 751 sub innerregister {
|
$cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
$cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
$cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
$cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
$perms{'mdc'} = &Apache::lonnet::allowed('mdc',$env{'request.course.id'}); |
$perms{'mdc'} = &Apache::lonnet::allowed('mdc',$env{'request.course.id'}); |
|
$perms{'cev'} = &Apache::lonnet::allowed('cev',$env{'request.course.id'}); |
my @privs; |
my @privs; |
if ($env{'request.symb'} ne '') { |
if ($env{'request.symb'} ne '') { |
if ($env{'request.filename'}=~/$LONCAPA::assess_re/) { |
if ($env{'request.filename'}=~/$LONCAPA::assess_re/) { |
Line 785 sub innerregister {
|
Line 791 sub innerregister {
|
# |
# |
# This applies to items inside a folder/page modifiable in the course. |
# This applies to items inside a folder/page modifiable in the course. |
# |
# |
if (($env{'request.symb'}=~/^uploaded/) && ($perms{'mdc'})) { |
if (($env{'request.symb'}=~/^uploaded/) && (($perms{'mdc'}) || ($perms{'cev'}))) { |
my $text = 'Edit Folder'; |
my $text = 'Edit Folder'; |
if (($mapurl =~ /\.page$/) || |
if (($mapurl =~ /\.page$/) || |
($env{'request.symb'}=~ |
($env{'request.symb'}=~ |
Line 1034 sub get_editbutton {
|
Line 1040 sub get_editbutton {
|
my ($cfile,$home,$switchserver,$forceedit,$forceview,$forcereg) = @_; |
my ($cfile,$home,$switchserver,$forceedit,$forceview,$forcereg) = @_; |
my $jscall; |
my $jscall; |
if (($forceview) && ($env{'form.todocs'})) { |
if (($forceview) && ($env{'form.todocs'})) { |
my ($folderpath,$command); |
my ($folderpath,$command,$navmap); |
if ($env{'request.symb'}) { |
if ($env{'request.symb'}) { |
$folderpath = &Apache::loncommon::symb_to_docspath($env{'request.symb'}); |
$folderpath = &Apache::loncommon::symb_to_docspath($env{'request.symb'},\$navmap); |
} elsif ($env{'form.folderpath'} =~ /^supplemental/) { |
} elsif ($env{'form.folderpath'} =~ /^supplemental/) { |
$folderpath = $env{'form.folderpath'}; |
$folderpath = $env{'form.folderpath'}; |
$command = '&forcesupplement=1'; |
$command = '&forcesupplement=1'; |
Line 2097 sub roles_selector {
|
Line 2103 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 2147 sub roles_selector {
|
Line 2153 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 2201 sub roles_selector {
|
Line 2207 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 2243 sub roles_selector {
|
Line 2249 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 2330 sub get_all_courseroles {
|
Line 2339 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 2405 sub get_customadhoc_roles {
|
Line 2432 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.', |