--- loncom/interface/lonmenu.pm 2016/11/29 03:01:04 1.463
+++ loncom/interface/lonmenu.pm 2019/08/06 23:10:18 1.499
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines to control the menu
#
-# $Id: lonmenu.pm,v 1.463 2016/11/29 03:01:04 raeburn Exp $
+# $Id: lonmenu.pm,v 1.499 2019/08/06 23:10:18 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -99,7 +99,7 @@ It gets filled in the BEGIN block of thi
=over
-=item prep_menuitems(\@menuitem)
+=item prep_menuitems(\@menuitem,$ltitarget)
This routine wraps a menuitem in proper HTML. It is used by primary_menu() and
secondary_menu().
@@ -210,16 +210,17 @@ use Apache::lonenc();
use Apache::lonlocal;
use Apache::lonmsg();
use LONCAPA qw(:DEFAULT :match);
+use LONCAPA::ltiutils;
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;
sub prep_menuitem {
- my ($menuitem) = @_;
+ my ($menuitem,$ltitarget) = @_;
return '' unless(ref($menuitem) eq 'ARRAY');
my $link;
if ($$menuitem[1]) { # graphical Link
@@ -229,10 +230,14 @@ sub prep_menuitem {
} else { # textual Link
$link = &mt($$menuitem[3]);
}
+ my $target = ' target="_top"';
+ if ($ltitarget eq 'iframe') {
+ $target ='';
+ }
return '
$link|;
+ . qq| href="$$menuitem[0]"$target>$link|;
}
# primary_menu() evaluates @primary_menu and returns a two item array,
@@ -242,8 +247,8 @@ sub prep_menuitem {
# @primary_menu is filled within the BEGIN block of this module with
# entries from mydesk.tab
sub primary_menu {
- my ($crstype) = @_;
- my (%menu);
+ my ($crstype,$ltimenu) = @_;
+ my (%menu,%ltiexc);
# each element of @primary contains following array:
# (link url, icon path, alt text, link text, condition, position)
my $public;
@@ -260,6 +265,18 @@ sub primary_menu {
my %roles_in_env;
$rolecount = &Apache::lonroles::roles_from_env(\%roles_in_env,$update);
}
+ my ($lti,$ltitarget);
+ if ($env{'request.lti.login'}) {
+ $lti = 1;
+ $ltitarget = $env{'request.lti.target'};
+ if (ref($ltimenu) eq 'HASH') {
+ foreach my $item ('fullname','logout') {
+ unless ($ltimenu->{$item}) {
+ $ltiexc{$item} = 1;
+ }
+ }
+ }
+ }
foreach my $menuitem (@primary_menu) {
# evaluate conditions
next if ref($menuitem) ne 'ARRAY'; #
@@ -274,9 +291,15 @@ sub primary_menu {
&& !$public; # only visible to public
# users
next if $$menuitem[4] eq 'roles' ##show links depending on
- && &Apache::loncommon::show_course(); ##term 'Courses' or
- next if $$menuitem[4] eq 'courses' ##'Roles' wanted
- && !&Apache::loncommon::show_course(); ##
+ && (&Apache::loncommon::show_course() ##term 'Courses' or
+ || $env{'request.lti.login'}); ##'Roles' wanted
+ next if $$menuitem[4] eq 'courses' ##and not LTI access
+ && (!&Apache::loncommon::show_course()
+ || !$env{'request.lti.login'});
+ next if $$menuitem[4] eq 'notlti'
+ && $lti;
+ next if $$menuitem[4] eq 'ltiexc'
+ && exists($ltiexc{lc($menuitem->[3])});
my $title = $menuitem->[3];
if (($crstype eq 'Placement') && (!$env{'request.role.adv'})) {
if ($menuitem->[4] eq 'courses') {
@@ -293,7 +316,9 @@ sub primary_menu {
my ($link,$target);
if ($menuitem->[0] ne '') {
$link = $menuitem->[0];
- $target = '_top';
+ unless ($ltitarget eq 'iframe') {
+ $target = '_top';
+ }
} else {
$link = '#';
}
@@ -309,7 +334,9 @@ sub primary_menu {
push(@primsub,$item);
}
if ($title eq 'Personal' && $env{'user.name'} && $env{'user.domain'} ) {
- $title = &Apache::loncommon::plainname($env{'user.name'},$env{'user.domain'});
+ unless ($ltiexc{'fullname'}) {
+ $title = &Apache::loncommon::plainname($env{'user.name'},$env{'user.domain'});
+ }
} else {
$title = &mt($title);
}
@@ -328,13 +355,13 @@ sub primary_menu {
'helpdeskmail',
$defdom,$origmail);
if ($to ne '') {
- $menu{$position} .= &prep_menuitem($menuitem);
+ $menu{$position} .= &prep_menuitem($menuitem,$ltitarget);
}
} else {
$menu{$position} .= ''.&Apache::loncommon::top_nav_help('Help').'';
}
} else {
- $menu{$position} .= prep_menuitem($menuitem);
+ $menu{$position} .= prep_menuitem($menuitem,$ltitarget);
}
}
my @output = ('','');
@@ -373,7 +400,7 @@ sub getauthor{
}
sub secondary_menu {
- my ($httphost) = @_;
+ my ($httphost,$ltiscope,$ltimenu,$noprimary) = @_;
my $menu;
my $crstype = &Apache::loncommon::course_type();
@@ -381,6 +408,7 @@ 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);
@@ -393,17 +421,15 @@ sub secondary_menu {
my $canmodpara = &Apache::lonnet::allowed('opa', $crs_sec);
my $canvgr = &Apache::lonnet::allowed('vgr', $crs_sec);
my $canmgr = &Apache::lonnet::allowed('mgr', $crs_sec);
+ my $canplc = &Apache::lonnet::allowed('plc', $crs_sec);
my $author = &getauthor();
- my ($cdom,$cnum,$showsyllabus,$showfeeds,$showresv,$grouptools);
+ my ($cdom,$cnum,$showsyllabus,$showfeeds,$showresv,$grouptools,$lti,$ltimapres,%ltiexc);
$grouptools = 0;
if ($env{'request.course.id'}) {
$cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
$cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
- if ($canedit) {
- $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'}) ||
@@ -416,16 +442,15 @@ sub secondary_menu {
$showfeeds = 1;
}
}
- unless (($canmgr || $canvgr)) {
+ unless ($canmgr || $canvgr) {
my %slots = &Apache::lonnet::get_course_slots($cnum,$cdom);
if (keys(%slots) > 0) {
$showresv = 1;
}
}
- my %groups = &Apache::lonnet::get_active_groups(
- $env{'user.domain'}, $env{'user.name'},$cdom,$cnum);
- if (%groups) {
- foreach my $group (keys(%groups)) {
+ if ($env{'request.course.groups'} ne '') {
+ foreach my $group (split(/:/,$env{'request.course.groups'})) {
+ next unless ($group =~ /^\w+$/);
my @privs = split(/:/,$env{"user.priv.$env{'request.role'}./$cdom/$cnum/$group"});
shift(@privs);
if (@privs) {
@@ -433,6 +458,19 @@ sub secondary_menu {
}
}
}
+ if ($env{'request.lti.login'}) {
+ $lti = 1;
+ if (ref($ltimenu) eq 'HASH') {
+ foreach my $item ('fullname','coursetitle','role','logout','grades') {
+ unless ($ltimenu->{$item}) {
+ $ltiexc{$item} = 1;
+ }
+ }
+ }
+ if (($ltiscope eq 'map') || ($ltiscope eq 'resource')) {
+ $ltimapres = 1;
+ }
+ }
}
my ($canmodifycoauthor);
@@ -443,7 +481,11 @@ sub secondary_menu {
$canmodifycoauthor = 1;
}
}
- my ($roleswitcher_js,$roleswitcher_form);
+
+ my ($roleswitcher_js,$roleswitcher_form,$ltitarget);
+ if ($env{'request.lti.login'}) {
+ $ltitarget = $env{'request.lti.target'};
+ }
foreach my $menuitem (@secondary_menu) {
# evaluate conditions
@@ -452,10 +494,10 @@ 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;
+ && ($canvgr || $ltiexc{'grades'});
next if $$menuitem[4] eq 'vgr'
&& !$canvgr;
next if $$menuitem[4] eq 'viewusers'
@@ -470,40 +512,111 @@ 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'
&& !$showfeeds;
+ next if $$menuitem[4] eq 'plc'
+ && !$canplc;
next if $$menuitem[4] eq 'author'
&& !$author;
next if $$menuitem[4] eq 'cca'
&& !$canmodifycoauthor;
+ next if $$menuitem[4] eq 'notltimapres'
+ && $ltimapres;
+ next if $$menuitem[4] eq 'notlti'
+ && $lti;
+ next if $$menuitem[4] eq 'lti'
+ && (!$lti || !$noprimary);
+ next if $$menuitem[3] eq 'Logout'
+ && $ltiexc{'logout'};
- 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];
+ unless ($ltitarget eq 'iframe') {
+ $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);
+ next if ($item->[2] eq 'author' && !$author);
+ next if ($item->[2] eq 'cca' && !$canmodifycoauthor);
+ next if ($item->[2] eq 'lti' && !$lti);
+ if ($item->[2] =~ /^lti(portfolio|wishlist|blog)$/) {
+ my $tool = $1;
+ next if !$lti;
+ next if (!&Apache::lonnet::usertools_access('','',$tool,
+ undef,'tools'));
+ }
+ push(@scndsub,$item);
+ }
+ }
+ if ($title eq 'Personal' && $env{'user.name'} && $env{'user.domain'} ) {
+ unless ($ltiexc{'fullname'}) {
+ $title = &Apache::loncommon::plainname($env{'user.name'},$env{'user.domain'});
+ }
+ }
+ 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(
- $env{'course.' . $env{'request.course.id'} . '.domain'},
- $env{'course.' . $env{'request.course.id'} . '.num'},
- $httphost
+ $env{'course.' . $env{'request.course.id'} . '.domain'},
+ $env{'course.' . $env{'request.course.id'} . '.num'},
+ $httphost,$ltitarget
);
$menu .= $switcher;
+ } elsif ($$menuitem[3] eq 'Help') { # special treatment for helplink
+ next if ($crstype eq 'Placement');
+ $menu .= ''.&Apache::loncommon::top_nav_help('Help').'';
} else {
if ($$menuitem[3] eq 'Syllabus' && $env{'request.course.id'}) {
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 (&Apache::lonnet::uses_sts()) {
+ 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);
+ $menu .= &prep_menuitem(\@$menuitem,$ltitarget);
}
}
if ($menu =~ /\[url\].*\[symb\]/) {
@@ -520,13 +633,14 @@ 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;
}
$menu =~ s/\[uname\]/$$author{user}/g;
$menu =~ s/\[udom\]/$$author{dom}/g;
- if ($showsyllabus || $showfeeds) {
+ $menu =~ s/\[javascript\]/javascript:/g;
+ if ($env{'request.course.id'}) {
$menu =~ s/\[cnum\]/$cnum/g;
$menu =~ s/\[cdom\]/$cdom/g;
}
@@ -609,9 +723,25 @@ sub build_submenu {
next unless (($env{'user.name'} ne '') && ($env{'user.domain'} ne ''));
$href =~ s/\[domain\]/$env{'user.domain'}/g;
$href =~ s/\[user\]/$env{'user.name'}/g;
+ } elsif (($href =~ m{^/adm/preferences\?}) && ($href =~ /\[returnurl\]/)) {
+ my $returnurl = $ENV{'REQUEST_URI'};
+ if ($ENV{'REQUEST_URI'} =~ m{/adm/preferences\?action=(?:changedomcoord|authorsettings)\&returnurl=([^\&]+)$}) {
+ $returnurl = $1;
+ }
+ if (($returnurl =~ m{^/adm/createuser($|\?action=)}) ||
+ ($returnurl =~ m{^/priv/$match_domain/$match_username}) ||
+ ($returnurl =~ m{^/res(/?$|/$match_domain/$match_username)})) {
+ $returnurl =~ s{\?.*$}{};
+ $returnurl = '&returnurl='.&HTML::Entities::encode($returnurl,'"<>&\'');
+ } else {
+ undef($returnurl);
+ }
+ $href =~ s/\[returnurl\]/$returnurl/;
}
unless (($href eq '') || ($href =~ /^\#/)) {
- $target = ' target="_top"';
+ if ($target eq '_top') {
+ $target = ' target="_top"';
+ }
}
$menu .= '';
@@ -624,7 +754,7 @@ sub build_submenu {
}
sub innerregister {
- my ($forcereg,$bread_crumbs,$group,$pagebuttonshide) = @_;
+ my ($forcereg,$bread_crumbs,$group,$pagebuttonshide,$hostname,$ltiscope,$ltiuri) = @_;
my $const_space = ($env{'request.state'} eq 'construct');
my $is_const_dir = 0;
@@ -634,7 +764,7 @@ sub innerregister {
undef(@inlineremote);
- my ($mapurl,$resurl,$crstype);
+ my ($mapurl,$resurl,$crstype,$navmap);
if ($env{'request.course.id'}) {
#
@@ -642,31 +772,57 @@ 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'}))) {
+ unless ($ltiscope eq 'resource') {
+ if (($mapurl ne $env{'course.'.$env{'request.course.id'}.'.url'}) &&
+ !(($ltiscope eq 'map') && (&Apache::lonnet::clutter($resurl) eq $ltiuri))) {
+ $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'}) ||
- (($crstype eq 'Placement') && (!$env{'request.role.adv'}))) {
+ (($crstype eq 'Placement') && (!$env{'request.role.adv'})) ||
+ ($ltiscope eq 'map') || ($ltiscope eq 'resource')) {
@crumbs = ({text => $crstype.' Contents',
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'})) &&
+ ($ltiscope ne 'map') && ($ltiscope ne 'resource')) {
+ 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'}) ||
+ ($ltiscope eq 'resource')) {
+ push @crumbs, {text => $maptitle, no_mt => 1,
+ href => &Apache::lonnet::clutter($mapurl).'?navmap=1'};
+ }
+ 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();
@@ -691,7 +847,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 {
@@ -706,10 +862,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') {
@@ -733,7 +889,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);
@@ -748,8 +904,14 @@ sub innerregister {
$perms{'mdc'} = &Apache::lonnet::allowed('mdc',$env{'request.course.id'});
$perms{'cev'} = &Apache::lonnet::allowed('cev',$env{'request.course.id'});
my @privs;
+ my $gradable_exttool;
if ($env{'request.symb'} ne '') {
- if ($env{'request.filename'}=~/$LONCAPA::assess_re/) {
+ if ($env{'request.noversionuri'} =~ m{^/adm/$cdom/$cnum/(\d+)/ext\.tool$}) {
+ if (&Apache::lonnet::EXT('resource.0.gradable') =~ /^yes$/i) {
+ $gradable_exttool = 1;
+ push(@privs,('mgr','vgr'));
+ }
+ } elsif ($env{'request.filename'}=~/$LONCAPA::assess_re/) {
push(@privs,('mgr','vgr'));
}
push(@privs,('opa','vpa'));
@@ -764,8 +926,8 @@ sub innerregister {
#
# Determine whether or not to show Grades and Submissions buttons
#
- if ($env{'request.symb'} ne '' &&
- $env{'request.filename'}=~/$LONCAPA::assess_re/) {
+ if (($env{'request.symb'} ne '') &&
+ (($env{'request.filename'}=~/$LONCAPA::assess_re/) || ($gradable_exttool))) {
if ($perms{'mgr'}) {
&switch('','',7,2,'pgrd.png','Content Grades','grades[_4]',
"gocmd('/adm/grades','gradingmenu')",
@@ -849,7 +1011,35 @@ ENDMENUITEMS
# Should probably be in mydesk.tab
#
$menuitems = "c&3&1";
- if (($crstype ne 'Placement') || ($env{'request.role.adv'})) {
+ if ($ltiscope eq 'resource') {
+# Suppress display of backward arrow for LTI Provider if scope is resource.
+# Suppress display of forward arrow for LTI Provider if scope is resource.
+ } elsif ($ltiscope eq 'map') {
+# Suppress display of backward arrow for LTI Provider if scope is map and this is first resource.
+# Suppress display of forward arrow for LTI Provider if scope is map and this is the last resource.
+ my $showforw = 1;
+ my $showback = 1;
+ my $navmap = Apache::lonnavmaps::navmap->new();
+ if (ref($navmap)) {
+ my $mapres = $navmap->getResourceByUrl($ltiuri);
+ if (ref($mapres)) {
+ if ($navmap->isLastResource($mapres,$env{'request.symb'})) {
+ $showforw = 0;
+ }
+ if ($navmap->isFirstResource($mapres,$env{'request.symb'})) {
+ $showback = 0;
+ }
+ }
+ }
+ if ($showback) {
+ $menuitems.="
+s&2&1&back.png&&&gopost('/adm/flip','back:'+currentURL)&Previous content resource&&1";
+ }
+ if ($showforw) {
+ $menuitems.="
+s&2&3&forw.png&&&gopost('/adm/flip','forward:'+currentURL)&Next content resource&&3";
+ }
+ } elsif (($crstype ne 'Placement') || ($env{'request.role.adv'})) {
$menuitems.="
s&2&1&back.png&&&gopost('/adm/flip','back:'+currentURL)&Previous content resource&&1
s&2&3&forw.png&&&gopost('/adm/flip','forward:'+currentURL)&Next content resource&&3";
@@ -907,14 +1097,15 @@ if ($env{'browser.mobile'}) {
$is_mobile = 1;
}
- unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme|viewclasslist|portfolio|exttools?)(\?|$)/) {
- if ((!$env{'request.enc'}) && ($env{'request.noversionuri'} !~ m{^/adm/wrapper/ext/}) && ($env{'request.noversionuri'} !~ m{^/uploaded/$match_domain/$match_courseid/docs/})) {
+ unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme|viewclasslist|portfolio)(\?|$)/) {
+ if ((!$env{'request.enc'}) && ($env{'request.noversionuri'} !~ m{^/adm/wrapper/ext/}) && ($env{'request.noversionuri'} !~ m{^/uploaded/$match_domain/$match_courseid/docs/}) && ($env{'request.noversionuri'} !~ m{^/adm/.+/ext\.tool$})) {
$menuitems.=(<&"'));
+ my $link = '/adm/coursedocs?command=direct&forcesupplement=1&supppath='.
+ "$esc_path&anchor=$suppanchor";
+ if ($env{'request.use_absolute'} ne '') {
+ $link = $env{'request.use_absolute'}.$link;
+ }
&switch('','',7,4,'docs-22x22.png','Edit Folder','parms[_2]',
- "location.href='/adm/coursedocs?command=direct&forcesupplement=1&supppath=$esc_path&anchor=$suppanchor'",
- 'Folder/Page Content');
+ "location.href='$link'",'Folder/Page Content');
}
}
}
@@ -1229,7 +1462,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) {
@@ -1319,7 +1552,8 @@ sub switch {
unless ($env{'request.state'} eq 'construct') {
push(@tools,63);
}
- if (($env{'environment.icons'} eq 'iconsonly') &&
+ if ((($env{'environment.icons'} eq 'iconsonly') ||
+ ($env{'environment.icons'} eq '') && ($env{'request.lti.login'})) &&
(grep(/^$idx$/,@tools))) {
$inlineremote[$idx] =
'';
@@ -1854,13 +2088,17 @@ END
sub utilityfunctions {
my ($httphost) = @_;
my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));
- if ($currenturl =~ m{^/adm/wrapper/ext/}
- && $env{'request.external.querystring'} ) {
+ my $currentsymb=&Apache::lonenc::check_encrypt($env{'request.symb'});
+ if ($currenturl =~ m{^/adm/wrapper/ext/}) {
+ if ($env{'request.external.querystring'}) {
$currenturl .= ($currenturl=~/\?/)?'&':'?'.$env{'request.external.querystring'};
+ }
+ my ($anchor) = ($env{'request.symb'} =~ /(\#[^\#]+)$/);
+ if (($anchor) && ($currenturl !~ /\Q$anchor\E$/)) {
+ $currenturl .= $1;
+ }
}
$currenturl=&Apache::lonenc::check_encrypt(&unescape($currenturl));
-
- my $currentsymb=&Apache::lonenc::check_encrypt($env{'request.symb'});
my $dc_popup_cid;
if ($env{'user.adv'} && exists($env{'user.role.dc./'.
@@ -1887,6 +2125,15 @@ sub utilityfunctions {
my $countdown = &countdown_toggle_js();
+ my $ltitarget;
+ if ($env{'request.lti.login'}) {
+ $ltitarget = $env{'request.lti.target'};
+ }
+
+ my $annotateurl = '/adm/annotation';
+ if ($httphost) {
+ $annotateurl = '/adm/annotations';
+ }
my $hostvar = '
function setLCHost() {
var lcHostname="";
@@ -1983,17 +2230,22 @@ function golist(url) {
currentURL = null;
currentSymb= null;
var lcHostname = setLCHost();
- top.location.href=lcHostname+url;
+ var ltitarget = '$ltitarget';
+ if (ltitarget == 'iframe') {
+ document.location.href=lcHostname+url;
+ } else {
+ top.location.href=lcHostname+url;
+ }
}
}
-function catalog_info(isMobile) {
+function catalog_info(url,isMobile) {
if (isMobile == 1) {
- openMyModal(window.location.pathname+'.meta?modal=1',500,400,'yes');
+ openMyModal(url+'.meta?modal=1',500,400,'yes');
} else {
- loncatinfo=window.open(window.location.pathname+'.meta',"LONcatInfo",'height=500,width=400,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
+ loncatinfo=window.open(url+'.meta',"LONcatInfo",'height=500,width=400,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
}
}
@@ -2015,7 +2267,7 @@ function annotate() {
annotator.document.write(
'$start_page_annotate'
+"