--- loncom/interface/lonmenu.pm 2016/05/13 22:48:05 1.448
+++ loncom/interface/lonmenu.pm 2017/10/07 21:07:17 1.481
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines to control the menu
#
-# $Id: lonmenu.pm,v 1.448 2016/05/13 22:48:05 raeburn Exp $
+# $Id: lonmenu.pm,v 1.481 2017/10/07 21:07:17 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -381,13 +381,16 @@ sub secondary_menu {
? "/$env{'request.course.sec'}"
: '');
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'};
if ($canviewroster eq 'disabled') {
undef($canviewroster);
}
my $canviewgrps = &Apache::lonnet::allowed('vcg', $crs_sec);
- my $canmodifyuser = &Apache::lonnet::allowed('cst', $crs_sec);
+ my $canmodifyuser = &Apache::lonnet::allowed('cst', $crs_sec);
+ my $canviewusers = &Apache::lonnet::allowed('vcl', $crs_sec);
my $canviewwnew = &Apache::lonnet::allowed('whn', $crs_sec);
+ my $canviewpara = &Apache::lonnet::allowed('vpa', $crs_sec);
my $canmodpara = &Apache::lonnet::allowed('opa', $crs_sec);
my $canvgr = &Apache::lonnet::allowed('vgr', $crs_sec);
my $canmgr = &Apache::lonnet::allowed('mgr', $crs_sec);
@@ -398,7 +401,7 @@ sub secondary_menu {
if ($env{'request.course.id'}) {
$cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
$cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
- if ($canedit) {
+ if ($canedit || $canvieweditor) {
$showsyllabus = 1;
$showfeeds = 1;
} else {
@@ -414,7 +417,7 @@ sub secondary_menu {
$showfeeds = 1;
}
}
- unless ($canmgr) {
+ unless ($canmgr || $canvgr) {
my %slots = &Apache::lonnet::get_course_slots($cnum,$cdom);
if (keys(%slots) > 0) {
$showresv = 1;
@@ -450,24 +453,24 @@ sub secondary_menu {
next if $$menuitem[4] ne 'always'
&& ($$menuitem[4] ne 'author' && $$menuitem[4] ne 'cca')
&& !$env{'request.course.id'};
- next if $$menuitem[4] =~ /^mdc/
- && !$canedit;
+ next if $$menuitem[4] =~ /^crsedit/
+ && (!$canedit && !$canvieweditor);
next if $$menuitem[4] eq 'nvgr'
&& $canvgr;
next if $$menuitem[4] eq 'vgr'
&& !$canvgr;
- next if $$menuitem[4] eq 'cst'
- && !$canmodifyuser;
- next if $$menuitem[4] eq 'ncst'
- && ($canmodifyuser || !$canviewroster);
+ next if $$menuitem[4] eq 'viewusers'
+ && !$canmodifyuser && !$canviewusers;
+ next if $$menuitem[4] eq 'noviewusers'
+ && ($canmodifyuser || $canviewusers || !$canviewroster);
next if $$menuitem[4] eq 'mgr'
&& !$canmgr;
next if $$menuitem[4] eq 'showresv'
&& !$showresv;
next if $$menuitem[4] eq 'whn'
&& !$canviewwnew;
- next if $$menuitem[4] eq 'opa'
- && !$canmodpara;
+ next if $$menuitem[4] eq 'params'
+ && (!$canmodpara && !$canviewpara);
next if $$menuitem[4] =~ /showgroups$/
&& !$canviewgrps
&& !$grouptools;
@@ -494,12 +497,23 @@ sub secondary_menu {
my $url = $$menuitem[0];
$url =~ s{\[cdom\]/\[cnum\]}{$cdom/$cnum};
if (&Apache::lonnet::is_on_map($url)) {
- unless ($$menuitem[0] =~ /\?register=1/) {
- $$menuitem[0] .= '?register=1';
+ unless ($$menuitem[0] =~ /(\?|\&)register=1/) {
+ $$menuitem[0] .= (($$menuitem[0]=~/\?/)? '&' : '?').'register=1';
}
} else {
- $$menuitem[0] =~ s{\?register=1}{};
+ $$menuitem[0] =~ s{\&?register=1}{};
}
+ if ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://}) {
+ if (($ENV{'SERVER_PORT'} == 443) || ($env{'request.use_absolute'} =~ m{^https://})) {
+ unless ($$menuitem[0] =~ m{^https?://}) {
+ $$menuitem[0] = 'http://'.$ENV{'SERVER_NAME'}.$$menuitem[0];
+ }
+ unless ($$menuitem[0] =~ /(\&|\?)usehttp=1/) {
+ $$menuitem[0] .= (($$menuitem[0]=~/\?/) ? '&' : '?').'usehttp=1';
+ }
+ }
+ }
+ $$menuitem[0] = &HTML::Entities::encode($$menuitem[0],'&<>"');
}
$menu .= &prep_menuitem(\@$menuitem);
}
@@ -518,7 +532,7 @@ sub secondary_menu {
my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
($escurl = $env{'request.filename'}) =~ s{^\Q$londocroot\E}{};
$escurl = &escape($escurl);
- }
+ }
$menu =~ s/\[url\]/$escurl/g;
$menu =~ s/\[symb\]/$escsymb/g;
}
@@ -622,7 +636,7 @@ sub build_submenu {
}
sub innerregister {
- my ($forcereg,$bread_crumbs,$group) = @_;
+ my ($forcereg,$bread_crumbs,$group,$pagebuttonshide,$hostname) = @_;
my $const_space = ($env{'request.state'} eq 'construct');
my $is_const_dir = 0;
@@ -632,7 +646,7 @@ sub innerregister {
undef(@inlineremote);
- my ($mapurl,$resurl,$crstype);
+ my ($mapurl,$resurl,$crstype,$navmap);
if ($env{'request.course.id'}) {
#
@@ -640,12 +654,24 @@ sub innerregister {
#
$crstype = &Apache::loncommon::course_type();
if ($env{'request.symb'}) {
- ($mapurl, my $rid, $resurl) = &Apache::lonnet::decode_symb(&Apache::lonnet::symbread());
+ my $ignorenull;
+ unless ($env{'request.noversionuri'} eq '/adm/navmaps') {
+ $ignorenull = 1;
+ }
+ my $symb = &Apache::lonnet::symbread('','',$ignorenull);
+ ($mapurl, my $rid, $resurl) = &Apache::lonnet::decode_symb($symb);
my $coursetitle = $env{'course.'.$env{'request.course.id'}.'.description'};
my $maptitle = &Apache::lonnet::gettitle($mapurl);
- my $restitle = &Apache::lonnet::gettitle(&Apache::lonnet::symbread());
- my @crumbs;
+ my $restitle = &Apache::lonnet::gettitle($symb);
+ my (@crumbs,@mapcrumbs);
+ if (($env{'request.noversionuri'} ne '/adm/navmaps') && ($mapurl ne '') &&
+ (!(($crstype eq 'Placement') && !$env{'request.role.adv'}))) {
+ $navmap = Apache::lonnavmaps::navmap->new();
+ if (ref($navmap)) {
+ @mapcrumbs = $navmap->recursed_crumbs($mapurl,$restitle);
+ }
+ }
unless (($forcereg) &&
($env{'request.noversionuri'} eq '/adm/navmaps') &&
($mapurl eq $env{'course.'.$env{'request.course.id'}.'.url'}) ||
@@ -654,17 +680,22 @@ sub innerregister {
href => "Javascript:gopost('/adm/navmaps','')"});
}
if ($mapurl ne $env{'course.'.$env{'request.course.id'}.'.url'}) {
- push(@crumbs, {text => '...',
- no_mt => 1});
+ if (@mapcrumbs) {
+ push(@crumbs,@mapcrumbs);
+ } elsif (!(($crstype eq 'Placement') && (!$env{'request.role.adv'}))) {
+ push(@crumbs, {text => '...',
+ no_mt => 1});
+ }
}
- unless (($crstype eq 'Placement') || (!$env{'request.role.adv'})) {
- push @crumbs, {text => $maptitle, no_mt => 1} if ($maptitle
- && $maptitle ne 'default.sequence'
- && $maptitle ne $coursetitle);
+ unless ((($crstype eq 'Placement') && (!$env{'request.role.adv'})) || (@mapcrumbs) ||
+ (!$maptitle) || ($maptitle eq 'default.sequence') ||
+ ($mapurl eq $env{'course.'.$env{'request.course.id'}.'.url'})) {
+ push @crumbs, {text => $maptitle, no_mt => 1, href => $mapurl};
+ }
+ if ($restitle && !@mapcrumbs) {
+ push(@crumbs,{text => $restitle, no_mt => 1});
}
-
- push @crumbs, {text => $restitle, no_mt => 1} if $restitle;
my @tools;
if ($env{'request.filename'} =~ /\.page$/) {
my %breadcrumb_tools = &Apache::lonhtmlcommon::current_breadcrumb_tools();
@@ -689,7 +720,7 @@ sub innerregister {
}
my $trail;
if ($env{'form.folderpath'}) {
- &prepare_functions($resurl,$forcereg,$group,undef,undef,1);
+ &prepare_functions($resurl,$forcereg,$group,undef,undef,1,$hostname);
($trail) =
&Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1);
} else {
@@ -704,10 +735,10 @@ sub innerregister {
} elsif ($resurl =~ m{^\Q/uploaded$courseurl/portfolio/syllabus/}) {
&Apache::lonhtmlcommon::clear_breadcrumbs();
&prepare_functions('/public'.$courseurl."/syllabus",
- $forcereg,$group,undef,undef,1);
+ $forcereg,$group,undef,undef,1,$hostname);
$title = &mt('Syllabus File');
my ($trail) =
- &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1);
+ &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1,$hostname);
return $trail;
}
unless ($env{'request.state'} eq 'construct') {
@@ -731,7 +762,7 @@ sub innerregister {
$forceview,$editbutton);
if (($resurl =~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) ||
($env{'request.role'} !~/^(aa|ca|au)/)) {
- $editbutton = &prepare_functions($resurl,$forcereg,$group);
+ $editbutton = &prepare_functions($resurl,$forcereg,$group,'','','',$hostname);
}
if ($editbutton eq '') {
$editbutton = &clear(6,1);
@@ -744,12 +775,13 @@ sub innerregister {
$cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
$cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
$perms{'mdc'} = &Apache::lonnet::allowed('mdc',$env{'request.course.id'});
+ $perms{'cev'} = &Apache::lonnet::allowed('cev',$env{'request.course.id'});
my @privs;
if ($env{'request.symb'} ne '') {
if ($env{'request.filename'}=~/$LONCAPA::assess_re/) {
push(@privs,('mgr','vgr'));
}
- push(@privs,'opa');
+ push(@privs,('opa','vpa'));
}
foreach my $priv (@privs) {
$perms{$priv} = &Apache::lonnet::allowed($priv,$env{'request.course.id'});
@@ -773,7 +805,7 @@ sub innerregister {
'Content Submissions');
}
}
- if (($env{'request.symb'} ne '') && ($perms{'opa'})) {
+ if (($env{'request.symb'} ne '') && (($perms{'opa'}) || ($perms{'vpa'}))) {
&switch('','',7,3,'pparm.png','Content Settings','parms[_2]',
"gocmd('/adm/parmset','set')",
'Content Settings');
@@ -783,7 +815,7 @@ sub innerregister {
#
# 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';
if (($mapurl =~ /\.page$/) ||
($env{'request.symb'}=~
@@ -812,7 +844,11 @@ sub innerregister {
if ($currdir =~ m-/$-) {
$is_const_dir = 1;
if ($thisdisfn eq '') {
- $is_const_dir = 2;
+ unless (($env{'request.course.id'}) &&
+ ($env{'course.'.$env{'request.course.id'}.'.num'} eq $uname) &&
+ ($env{'course.'.$env{'request.course.id'}.'.domain'} eq $udom)) {
+ $is_const_dir = 2;
+ }
}
} else {
$currdir =~ s|[^/]+$||;
@@ -873,12 +909,15 @@ ENDMENUITEMS
$got_prt = 1;
if (($env{'user.adv'}) && ($env{'request.uri'} =~ /^\/res/)
&& (!$env{'request.enc'})) {
- # wishlist is only available for users with access to resource-pool
- # and links can only be set for resources within the resource-pool
- $menuitems .= (<
$lt{'preamble'} $lt{$type}
$lt{'miss'}$lt{'proctor'}
- @@ -1795,7 +1880,7 @@ END