--- loncom/interface/lonmenu.pm 2017/09/04 19:17:02 1.476
+++ loncom/interface/lonmenu.pm 2017/10/07 22:20:19 1.482
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines to control the menu
#
-# $Id: lonmenu.pm,v 1.476 2017/09/04 19:17:02 raeburn Exp $
+# $Id: lonmenu.pm,v 1.482 2017/10/07 22:20:19 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -214,7 +214,7 @@ use HTML::Entities();
use Apache::lonwishlist();
use vars qw(@desklines %category_names %category_members %category_positions
- $readdesk @primary_menu %primary_submenu @secondary_menu);
+ $readdesk @primary_menu %primary_submenu @secondary_menu %secondary_submenu);
my @inlineremote;
@@ -401,10 +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 || $canvieweditor) {
- $showsyllabus = 1;
- $showfeeds = 1;
- } else {
+ unless ($canedit || $canvieweditor) {
unless (&Apache::lonnet::is_on_map("public/$cdom/$cnum/syllabus")) {
if (($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'}) ||
($env{'course.'.$env{'request.course.id'}.'.uploadedsyllabus'}) ||
@@ -471,9 +468,8 @@ sub secondary_menu {
&& !$canviewwnew;
next if $$menuitem[4] eq 'params'
&& (!$canmodpara && !$canviewpara);
- next if $$menuitem[4] =~ /showgroups$/
- && !$canviewgrps
- && !$grouptools;
+ next if $$menuitem[4] eq 'showgroups'
+ && ($canviewgrps || !$grouptools);
next if $$menuitem[4] eq 'showsyllabus'
&& !$showsyllabus;
next if $$menuitem[4] eq 'showfeeds'
@@ -483,7 +479,37 @@ sub secondary_menu {
next if $$menuitem[4] eq 'cca'
&& !$canmodifycoauthor;
- if ($$menuitem[3] eq 'Roles' && $env{'request.course.id'}) {
+ my $title = $menuitem->[3];
+ if (defined($secondary_submenu{$title})) {
+ my ($link,$target);
+ if ($menuitem->[0] ne '') {
+ $link = $menuitem->[0];
+ $target = '_top';
+ } else {
+ $link = '#';
+ }
+ my @scndsub;
+ if (ref($secondary_submenu{$title}) eq 'ARRAY') {
+ foreach my $item (@{$secondary_submenu{$title}}) {
+ if (ref($item) eq 'ARRAY') {
+ next if ($item->[2] eq 'vgr' && !$canvgr);
+ next if ($item->[2] eq 'opa' && !$canmodpara);
+ next if ($item->[2] eq 'vpa' && !$canviewpara);
+ next if ($item->[2] eq 'viewusers' && !($canmodifyuser || $canviewusers));
+ next if ($item->[2] eq 'mgr' && !$canmgr);
+ next if ($item->[2] eq 'vcg' && !$canviewgrps);
+ next if ($item->[2] eq 'crsedit' && !$canedit && !$canvieweditor);
+ next if ($item->[2] eq 'params' && !$canmodpara && !$canviewpara);
+ push(@scndsub,$item);
+ }
+ }
+ if (@scndsub > 0) {
+ $menu .= &create_submenu($link,$target,$title,\@scndsub,1);
+ } elsif ($link ne '#') {
+ $menu .= '
'.&mt($title).'';
+ }
+ }
+ } elsif ($$menuitem[3] eq 'Roles' && $env{'request.course.id'}) {
# special treatment for role selector
($roleswitcher_js,$roleswitcher_form,my $switcher) =
&roles_selector(
@@ -538,7 +564,7 @@ sub secondary_menu {
}
$menu =~ s/\[uname\]/$$author{user}/g;
$menu =~ s/\[udom\]/$$author{dom}/g;
- if ($showsyllabus || $showfeeds) {
+ if ($env{'request.course.id'}) {
$menu =~ s/\[cnum\]/$cnum/g;
$menu =~ s/\[cdom\]/$cdom/g;
}
@@ -665,10 +691,11 @@ sub innerregister {
my $maptitle = &Apache::lonnet::gettitle($mapurl);
my $restitle = &Apache::lonnet::gettitle($symb);
my (@crumbs,@mapcrumbs);
- if (($env{'request.noversionuri'} ne '/adm/navmaps') && ($mapurl ne '')) {
+ 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);
+ @mapcrumbs = $navmap->recursed_crumbs($mapurl,$restitle);
}
}
unless (($forcereg) &&
@@ -681,7 +708,7 @@ sub innerregister {
if ($mapurl ne $env{'course.'.$env{'request.course.id'}.'.url'}) {
if (@mapcrumbs) {
push(@crumbs,@mapcrumbs);
- } else {
+ } elsif (!(($crstype eq 'Placement') && (!$env{'request.role.adv'}))) {
push(@crumbs, {text => '...',
no_mt => 1});
}
@@ -692,8 +719,9 @@ sub innerregister {
($mapurl eq $env{'course.'.$env{'request.course.id'}.'.url'})) {
push @crumbs, {text => $maptitle, no_mt => 1, href => $mapurl};
}
-
- push @crumbs, {text => $restitle, no_mt => 1} if $restitle;
+ if ($restitle && !@mapcrumbs) {
+ push(@crumbs,{text => $restitle, no_mt => 1});
+ }
my @tools;
if ($env{'request.filename'} =~ /\.page$/) {
my %breadcrumb_tools = &Apache::lonhtmlcommon::current_breadcrumb_tools();
@@ -1112,8 +1140,9 @@ sub prepare_functions {
}
my $editbutton = '';
+ my $viewsrcbutton = '';
#
-# Determine whether or not to display 'Edit' icon/button
+# Determine whether or not to display 'Edit' or 'View Source' icon/button
#
if ($resurl =~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) {
my $file=&Apache::lonnet::declutter($env{'request.filename'});
@@ -1145,7 +1174,8 @@ sub prepare_functions {
#
if (($perms{'mdc'}) &&
(($resurl =~ m{^/?public/$cdom/$cnum/syllabus}) ||
- ($resurl =~ m{^/?uploaded/$cdom/$cnum/portfolio/syllabus/}))) {
+ ($resurl =~ m{^/?uploaded/$cdom/$cnum/portfolio/syllabus/}) ||
+ (($resurl =~ m{^/?uploaded/$cdom/$cnum/default_\d+\.sequence$}) && ($env{'form.navmap'})))) {
if ($resurl =~ m{^/}) {
$cfile = $resurl;
} else {
@@ -1157,9 +1187,17 @@ sub prepare_functions {
} else {
$forceedit = 1;
}
- $editbutton = &get_editbutton($cfile,$home,$switchserver,
- $forceedit,$forceview,$forcereg,
- $hostname);
+ if ($cfile =~ m{^/uploaded/$cdom/$cnum/default_\d+\.sequence$}) {
+ my $text = 'Edit Folder';
+ &switch('','',7,4,'docs-22x22.png','Edit Folder','parms[_2]',
+ "gocmd('/adm/coursedocs','direct')",
+ 'Folder/Page Content');
+ $editbutton = 1;
+ } else {
+ $editbutton = &get_editbutton($cfile,$home,$switchserver,
+ $forceedit,$forceview,$forcereg,
+ $hostname);
+ }
} elsif (($resurl eq '/adm/extresedit') &&
(($env{'form.symb'}) || ($env{'form.folderpath'}))) {
($cfile,$home,$switchserver,$forceedit,$forceview) =
@@ -1188,6 +1226,29 @@ sub prepare_functions {
$forceedit,$forceview,$forcereg,
$hostname);
}
+ if ((($cfile eq '') || (!$editbutton)) &&
+ ($resurl =~ /$LONCAPA::assess_re/)) {
+ my $showurl = &Apache::lonnet::clutter($resurl);
+ if ((&Apache::lonnet::allowed('cre','/')) &&
+ (&Apache::lonnet::metadata($resurl,'sourceavail') eq 'open')) {
+ $viewsrcbutton = 1;
+ } elsif (&Apache::lonnet::allowed('vxc',$env{'request.course.id'})) {
+ if ($showurl =~ m{^\Q/res/$cdom/\E($match_username)/}) {
+ my $auname = $1;
+ if (($env{'request.course.adhocsrcaccess'} ne '') &&
+ (grep(/^\Q$auname\E$/,split(/,/,$env{'request.course.adhocsrcaccess'})))) {
+ $viewsrcbutton = 1;
+ } elsif ((&Apache::lonnet::metadata($resurl,'sourceavail') eq 'open') &&
+ (&Apache::lonnet::allowed('bre','/'))) {
+ $viewsrcbutton = 1;
+ }
+ }
+ }
+ if ($viewsrcbutton) {
+ &switch('','',6,1,'pcstr.png','View Source','resource[_2]','open_source()',
+ 'View source code');
+ }
+ }
}
}
}
@@ -1265,7 +1326,7 @@ sub prepare_functions {
&advtools_crumbs(@inlineremote);
return $editbutton;
} elsif ($env{'request.registered'}) {
- return $editbutton;
+ return $editbutton || $viewsrcbutton;
} else {
if (ref($bread_crumbs) eq 'ARRAY') {
if (@inlineremote > 0) {
@@ -2072,6 +2133,12 @@ function open_StoredLinks_Import(rat) {
newWin.focus();
}
+function open_source() {
+ var url = escape(window.location.pathname);
+ sourcewin=window.open('/adm/source?inhibitmenu=yes&viewonly=1&filename='+url,'LONsource',
+ 'height=500,width=600,resizable=yes,location=no,menubar=no,toolbar=no,scrollbars=yes');
+}
+
(function (\$) {
\$(document).ready(function () {
\$.single=function(a){return function(b){a[0]=b;return a}}(\$([1]));
@@ -2742,6 +2809,9 @@ BEGIN {
} elsif ($configline=~/^scnd\:/) {
my @entries = (split(/\:/, $configline))[1..5];
push(@secondary_menu,\@entries);
+ } elsif ($configline=~/^scndsub\:/) {
+ my ($parent,@entries) = (split(/\:/, $configline))[1..4];
+ push(@{$secondary_submenu{$parent}},\@entries);
} elsif ($configline) {
push(@desklines,$configline);
}