--- loncom/interface/lonmenu.pm 2018/12/29 23:24:40 1.494
+++ loncom/interface/lonmenu.pm 2023/11/19 21:28:17 1.542
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines to control the menu
#
-# $Id: lonmenu.pm,v 1.494 2018/12/29 23:24:40 raeburn Exp $
+# $Id: lonmenu.pm,v 1.542 2023/11/19 21:28:17 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,$ltitarget)
+=item prep_menuitems(\@menuitem,$target,$listclass,$linkattr)
This routine wraps a menuitem in proper HTML. It is used by primary_menu() and
secondary_menu().
@@ -210,7 +210,6 @@ use Apache::lonenc();
use Apache::lonlocal;
use Apache::lonmsg();
use LONCAPA qw(:DEFAULT :match);
-use LONCAPA::ltiutils;
use HTML::Entities();
use Apache::lonwishlist();
@@ -220,9 +219,9 @@ use vars qw(@desklines %category_names %
my @inlineremote;
sub prep_menuitem {
- my ($menuitem,$ltitarget) = @_;
+ my ($menuitem,$target,$listclass,$linkattr) = @_;
return '' unless(ref($menuitem) eq 'ARRAY');
- my $link;
+ my ($link,$targetattr);
if ($$menuitem[1]) { # graphical Link
$link = "':'').'$link |;
+ . qq| href="$$menuitem[0]"$targetattr $linkattr>$link |;
}
# primary_menu() evaluates @primary_menu and returns a two item array,
@@ -247,8 +245,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,$ltimenu) = @_;
- my (%menu,%ltiexc);
+ my ($crstype,$ltimenu,$menucoll,$menuref,$links_disabled,$links_target,$collapsible) = @_;
+ my (%menu,%ltiexc,%menuopts);
# each element of @primary contains following array:
# (link url, icon path, alt text, link text, condition, position)
my $public;
@@ -265,10 +263,9 @@ sub primary_menu {
my %roles_in_env;
$rolecount = &Apache::lonroles::roles_from_env(\%roles_in_env,$update);
}
- my ($lti,$ltitarget);
+ my $lti;
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}) {
@@ -277,6 +274,30 @@ sub primary_menu {
}
}
}
+ my ($listclass,$linkattr,$target);
+ if ($links_disabled) {
+ $listclass = 'LCisDisabled';
+ $linkattr = 'aria-disabled="true"';
+ }
+ if ($links_target ne '') {
+ $target = $links_target;
+ } else {
+ my ($ltitarget,$deeplinktarget);
+ if ($env{'request.lti.login'}) {
+ $ltitarget = $env{'request.lti.target'};
+ }
+ if ($env{'request.deeplink.login'}) {
+ $deeplinktarget = $env{'request.deeplink.target'};
+ }
+ if (($ltitarget eq 'iframe') || ($deeplinktarget eq '_self')) {
+ $target = '_self';
+ } else {
+ $target = '_top';
+ }
+ }
+ if (($menucoll) && (ref($menuref) eq 'HASH')) {
+ %menuopts = %{$menuref};
+ }
foreach my $menuitem (@primary_menu) {
# evaluate conditions
next if ref($menuitem) ne 'ARRAY'; #
@@ -292,10 +313,10 @@ sub primary_menu {
# users
next if $$menuitem[4] eq 'roles' ##show links depending on
&& (&Apache::loncommon::show_course() ##term 'Courses' or
- || $env{'request.lti.login'}); ##'Roles' wanted
+ || $lti); ##'Roles' wanted
next if $$menuitem[4] eq 'courses' ##and not LTI access
&& (!&Apache::loncommon::show_course()
- || !$env{'request.lti.login'});
+ || $lti);
next if $$menuitem[4] eq 'notlti'
&& $lti;
next if $$menuitem[4] eq 'ltiexc'
@@ -312,13 +333,27 @@ sub primary_menu {
if ($position eq '') {
$position = 'right';
}
+ if ($env{'request.course.id'} && $menucoll) {
+ if (($menuitem->[6]) && (!$menuopts{$menuitem->[6]})) {
+ if ($menuitem->[6] eq 'pers') {
+ if ($menuopts{'name'} && !$ltiexc{'fullname'} &&
+ $env{'user.name'} && $env{'user.domain'}) {
+ $menu{$position} .= '
'.
+ &Apache::loncommon::plainname($env{'user.name'},
+ $env{'user.domain'}).' ';
+ next;
+ } else {
+ next;
+ }
+ } else {
+ next;
+ }
+ }
+ }
if (defined($primary_submenu{$title})) {
- my ($link,$target);
+ my $link;
if ($menuitem->[0] ne '') {
$link = $menuitem->[0];
- unless ($ltitarget eq 'iframe') {
- $target = '_top';
- }
} else {
$link = '#';
}
@@ -331,19 +366,30 @@ sub primary_menu {
($item->[2] eq 'blog')) &&
(!&Apache::lonnet::usertools_access('','',$item->[2],
undef,'tools')));
+ if ($env{'request.course.id'} && $menucoll) {
+ next if ($item->[3]) && (!$menuopts{$item->[3]});
+ }
push(@primsub,$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 ($title eq 'Personal') {
+ if ($env{'user.name'} && $env{'user.domain'} && !$ltiexc{'fullname'}) {
+ unless (($env{'request.course.id'}) && ($menucoll) && (!$menuopts{'name'})) {
+ $title = &Apache::loncommon::plainname($env{'user.name'},$env{'user.domain'});
+ }
+ }
+ next if (($env{'request.course.id'}) && ($menucoll) && ($title eq 'Personal') &&
+ (!@primsub));
+ if ($title eq 'Personal') {
+ $title = &mt($title);
}
} else {
$title = &mt($title);
}
if (@primsub > 0) {
- $menu{$position} .= &create_submenu($link,$target,$title,\@primsub,1);
+ $menu{$position} .= &create_submenu($link,$target,$title,\@primsub,1,undef,$listclass,$linkattr);
} elsif ($link) {
- $menu{$position} .= ''.$title.' ';
+ $menu{$position} .= ($listclass?'':' ').
+ ''.$title.' ';
}
}
} elsif ($$menuitem[3] eq 'Help') { # special treatment for helplink
@@ -355,17 +401,30 @@ sub primary_menu {
'helpdeskmail',
$defdom,$origmail);
if ($to ne '') {
- $menu{$position} .= &prep_menuitem($menuitem,$ltitarget);
+ $menu{$position} .= &prep_menuitem($menuitem,$target,$listclass,$linkattr);
}
} else {
- $menu{$position} .= ''.&Apache::loncommon::top_nav_help('Help').' ';
+ $menu{$position} .= ($listclass?'':' ').
+ &Apache::loncommon::top_nav_help('Help',$linkattr).
+ ' ';
}
+ } elsif ($$menuitem[3] eq 'Log In') {
+ if ($public) {
+ if (&Apache::lonnet::get_saml_landing()) {
+ $$menuitem[0] = '/adm/login';
+ }
+ }
+ $menu{$position} .= prep_menuitem($menuitem,$target,$listclass,$linkattr);
} else {
- $menu{$position} .= prep_menuitem($menuitem,$ltitarget);
+ $menu{$position} .= prep_menuitem($menuitem,$target,$listclass,$linkattr);
}
}
my @output = ('','');
if ($menu{'left'} ne '') {
+ if ($collapsible) {
+ $menu{'left'} = ($listclass?'':' ').
+ ' '.$menu{'left'};
+ }
$output[0] = "";
}
if ($menu{'right'} ne '') {
@@ -381,10 +440,10 @@ sub primary_menu {
#
#TODO this should probably be moved somewhere more central
#since it can be used by different parts of the system
-sub getauthor{
+sub getauthor {
return unless $env{'request.role'}=~/^(ca|aa|au)/; #nothing to do if user isn't some kind of author
- #co- or assistent author?
+ #co- or assistant author?
my ($dom, $user) = ($env{'request.role'} =~ /^(?:ca|aa)\.\/($match_domain)\/($match_username)$/)
? ($1, $2) #domain, username of the parent author
: @env{ ('request.role.domain', 'user.name') }; #own domain, username
@@ -400,7 +459,8 @@ sub getauthor{
}
sub secondary_menu {
- my ($httphost,$ltiscope,$ltimenu,$noprimary) = @_;
+ my ($httphost,$ltiscope,$ltimenu,$noprimary,$menucoll,$menuref,
+ $links_disabled,$links_target) = @_;
my $menu;
my $crstype = &Apache::loncommon::course_type();
@@ -424,7 +484,17 @@ sub secondary_menu {
my $canplc = &Apache::lonnet::allowed('plc', $crs_sec);
my $author = &getauthor();
- my ($cdom,$cnum,$showsyllabus,$showfeeds,$showresv,$grouptools,$lti,$ltimapres,%ltiexc);
+ my ($is_author,$is_coauthor);
+ if ($author) {
+ if ($env{'request.role'} =~ /^au\./) {
+ $is_author = 1;
+ } elsif ($env{'request.role'} =~ /^ca\./) {
+ $is_coauthor = 1;
+ }
+ }
+
+ my ($cdom,$cnum,$showsyllabus,$showfeeds,$showresv,$grouptools,
+ $lti,$ltimapres,%ltiexc,%menuopts);
$grouptools = 0;
if ($env{'request.course.id'}) {
$cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
@@ -448,10 +518,9 @@ sub secondary_menu {
$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) {
@@ -473,27 +542,63 @@ sub secondary_menu {
}
}
}
+ if (($menucoll) && (ref($menuref) eq 'HASH')) {
+ %menuopts = %{$menuref};
+ }
- my ($canmodifycoauthor);
+ my ($listclass,$linkattr,$target);
+ if ($links_disabled) {
+ $listclass = 'LCisDisabled';
+ $linkattr = 'aria-disabled="true"';
+ }
+
+ my ($canlistcoauthors,$canmodifycoauthor);
if ($env{'request.role'} eq "au./$env{'user.domain'}/") {
my $extent = "$env{'user.domain'}/$env{'user.name'}";
if ((&Apache::lonnet::allowed('cca',$extent)) ||
(&Apache::lonnet::allowed('caa',$extent))) {
$canmodifycoauthor = 1;
}
+ } elsif ($env{'request.role'} =~ m{^(aa|ca)\./($match_domain/$match_username)$}) {
+ my ($role,$extent) = ($1,$2);
+ if (&Apache::lonnet::allowed('vca',$extent)) {
+ if ($env{"environment.internal.manager./$extent"}) {
+ $canmodifycoauthor = 1;
+ } else {
+ $canlistcoauthors = 1;
+ }
+ } elsif (&Apache::lonnet::allowed('vaa',$extent)) {
+ $canlistcoauthors = 1;
+ }
}
-
- my ($roleswitcher_js,$roleswitcher_form,$ltitarget);
- if ($env{'request.lti.login'}) {
- $ltitarget = $env{'request.lti.target'};
+ my ($roleswitcher_js,$roleswitcher_form);
+ if ($links_target ne '') {
+ $target = $links_target;
+ } else {
+ my ($ltitarget,$deeplinktarget);
+ if ($env{'request.lti.login'}) {
+ $ltitarget = $env{'request.lti.target'};
+ }
+ if ($env{'request.deeplink.login'}) {
+ $deeplinktarget = $env{'request.deeplink.target'};
+ }
+ if (($ltitarget eq 'iframe') || ($deeplinktarget eq '_self')) {
+ $target = '_self';
+ } else {
+ $target = '_top';
+ }
}
foreach my $menuitem (@secondary_menu) {
# evaluate conditions
next if ref($menuitem) ne 'ARRAY';
next if (($crstype eq 'Placement') && ($$menuitem[3] ne 'Roles') && (!$env{'request.role.adv'}));
- next if $$menuitem[4] ne 'always'
- && ($$menuitem[4] ne 'author' && $$menuitem[4] ne 'cca')
+ next if $$menuitem[4] ne 'always'
+ && $$menuitem[4] ne 'coauthor'
+ && $$menuitem[4] ne 'author'
+ && $$menuitem[4] ne 'authorspace'
+ && $$menuitem[4] ne 'vca'
+ && $$menuitem[4] ne 'mca'
&& !$env{'request.course.id'};
next if $$menuitem[4] =~ /^crsedit/
&& (!$canedit && !$canvieweditor);
@@ -521,9 +626,17 @@ sub secondary_menu {
&& !$showfeeds;
next if $$menuitem[4] eq 'plc'
&& !$canplc;
- next if $$menuitem[4] eq 'author'
+ next if $$menuitem[4] eq 'authorspace'
&& !$author;
- next if $$menuitem[4] eq 'cca'
+ next if $$menuitem[4] eq 'author'
+ && !$is_author;
+ next if $$menuitem[4] eq 'coauthor'
+ && !$is_coauthor;
+ next if $$menuitem[4] eq 'vca'
+ && (!$canlistcoauthors || $canmodifycoauthor);
+ next if $$menuitem[4] eq 'vaa'
+ && (!$canlistcoauthors || $canmodifycoauthor);
+ next if $$menuitem[4] eq 'mca'
&& !$canmodifycoauthor;
next if $$menuitem[4] eq 'notltimapres'
&& $ltimapres;
@@ -535,13 +648,15 @@ sub secondary_menu {
&& $ltiexc{'logout'};
my $title = $menuitem->[3];
+ if ($env{'request.course.id'} && $menucoll) {
+ unless ($$menuitem[5] eq 'roles') {
+ next if (($$menuitem[5]) && (!$menuopts{$$menuitem[5]}));
+ }
+ }
if (defined($secondary_submenu{$title})) {
- my ($link,$target);
+ my $link;
if ($menuitem->[0] ne '') {
$link = $menuitem->[0];
- unless ($ltitarget eq 'iframe') {
- $target = '_top';
- }
} else {
$link = '#';
}
@@ -557,8 +672,8 @@ sub secondary_menu {
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 'author' && !$is_author);
+ next if ($item->[2] eq 'vca' && !$canlistcoauthors);
next if ($item->[2] eq 'lti' && !$lti);
if ($item->[2] =~ /^lti(portfolio|wishlist|blog)$/) {
my $tool = $1;
@@ -569,25 +684,32 @@ sub secondary_menu {
push(@scndsub,$item);
}
}
- if ($title eq 'Personal' && $env{'user.name'} && $env{'user.domain'} ) {
+ 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);
+ $menu .= &create_submenu($link,$target,&mt($title),\@scndsub,1,undef,
+ $listclass,$linkattr);
} elsif ($link ne '#') {
- $menu .= ''.&mt($title).' ';
+ $menu .= ($listclass?'':' ').
+ ''.
+ &mt($title).' ';
}
}
} elsif ($$menuitem[3] eq 'Roles' && $env{'request.course.id'}) {
# special treatment for role selector
- ($roleswitcher_js,$roleswitcher_form,my $switcher) =
+ my ($switcher,$has_opa_priv);
+ ($roleswitcher_js,$roleswitcher_form,$switcher,$has_opa_priv) =
&roles_selector(
$env{'course.' . $env{'request.course.id'} . '.domain'},
$env{'course.' . $env{'request.course.id'} . '.num'},
- $httphost,$ltitarget
+ $httphost,$target,$menucoll,$menuref
);
+ if (($$menuitem[5]) && (!$menuopts{$$menuitem[5]})) {
+ next unless ($has_opa_priv);
+ }
$menu .= $switcher;
} elsif ($$menuitem[3] eq 'Help') { # special treatment for helplink
next if ($crstype eq 'Placement');
@@ -605,7 +727,7 @@ sub secondary_menu {
}
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 ((&Apache::lonnet::uses_sts()) || (&Apache::lonnet::waf_allssl())) {
unless ($$menuitem[0] =~ m{^https?://}) {
$$menuitem[0] = 'http://'.$ENV{'SERVER_NAME'}.$$menuitem[0];
}
@@ -617,7 +739,7 @@ sub secondary_menu {
}
$$menuitem[0] = &HTML::Entities::encode($$menuitem[0],'&<>"');
}
- $menu .= &prep_menuitem(\@$menuitem,$ltitarget);
+ $menu .= &prep_menuitem(\@$menuitem,$target,$listclass,$linkattr);
}
}
if ($menu =~ /\[url\].*\[symb\]/) {
@@ -637,6 +759,20 @@ sub secondary_menu {
}
$menu =~ s/\[url\]/$escurl/g;
$menu =~ s/\[symb\]/$escsymb/g;
+ } elsif (($menu =~ m{/adm/preferences\?}) && ($menu =~ /\[returnurl\]/)) {
+ my $returnurl = $ENV{'REQUEST_URI'};
+ if ($ENV{'REQUEST_URI'} =~ m{/adm/preferences\?action=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);
+ }
+ $menu =~ s/\[returnurl\]/$returnurl/;
}
$menu =~ s/\[uname\]/$$author{user}/g;
$menu =~ s/\[udom\]/$$author{dom}/g;
@@ -655,14 +791,14 @@ sub secondary_menu {
}
sub create_submenu {
- my ($link,$target,$title,$submenu,$translate,$addclass) = @_;
+ my ($link,$target,$title,$submenu,$translate,$addclass,$listclass,$linkattr) = @_;
return unless (ref($submenu) eq 'ARRAY');
- my $disptarget;
- if ($target ne '') {
- $disptarget = ' target="'.$target.'"';
+ my $targetattr;
+ if (($target ne '') && ($link ne '#')) {
+ $targetattr = ' target="'.$target.'"';
}
my $menu = ''.
- ''.
+ ' '.
''.$title.
''.
' ▼ '.
@@ -670,7 +806,7 @@ sub create_submenu {
# $link and $title are only used in the initial string written in $menu
# as seen above, not needed for nested submenus
- $menu .= &build_submenu($target, $submenu, $translate, '1');
+ $menu .= &build_submenu($target, $submenu, $translate, '1', $listclass, $linkattr);
$menu .= ' ';
return $menu;
@@ -680,7 +816,7 @@ sub create_submenu {
# build the dropdown (and nested submenus) recursively
# see perldoc create_submenu documentation for further information
sub build_submenu {
- my ($target, $submenu, $translate, $first_level) = @_;
+ my ($target, $submenu, $translate, $first_level, $listclass, $linkattr) = @_;
unless (@{$submenu}) {
return '';
}
@@ -739,14 +875,17 @@ sub build_submenu {
}
$href =~ s/\[returnurl\]/$returnurl/;
}
+ my $targetattr;
unless (($href eq '') || ($href =~ /^\#/)) {
- if ($target eq '_top') {
- $target = ' target="_top"';
+ if ($target ne '') {
+ $targetattr = ' target="'.$target.'"';
}
}
- $menu .= '';
- $menu .= '' . $title . ' ';
+ $menu .= ' ';
+ $menu .= '' . $title . ' ';
$menu .= ' ';
}
}
@@ -755,7 +894,8 @@ sub build_submenu {
}
sub innerregister {
- my ($forcereg,$bread_crumbs,$group,$pagebuttonshide,$hostname,$ltiscope,$ltiuri) = @_;
+ my ($forcereg,$bread_crumbs,$group,$pagebuttonshide,$hostname,
+ $ltiscope,$ltiuri,$showncrumbsref) = @_;
my $const_space = ($env{'request.state'} eq 'construct');
my $is_const_dir = 0;
@@ -796,10 +936,7 @@ sub innerregister {
}
}
}
- unless (($forcereg) &&
- ($env{'request.noversionuri'} eq '/adm/navmaps') &&
- ($mapurl eq $env{'course.'.$env{'request.course.id'}.'.url'}) ||
- (($crstype eq 'Placement') && (!$env{'request.role.adv'})) ||
+ unless ((($crstype eq 'Placement') && (!$env{'request.role.adv'})) ||
($ltiscope eq 'map') || ($ltiscope eq 'resource')) {
@crumbs = ({text => $crstype.' Contents',
href => "Javascript:gopost('/adm/navmaps','')"});
@@ -846,27 +983,51 @@ sub innerregister {
if ($env{'form.title'}) {
$title = $env{'form.title'};
}
- my $trail;
+ my ($trail,$cnum,$cdom);
+ if ($env{'form.folderpath'}) {
+ $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+ $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ &Apache::loncommon::validate_folderpath(1,'',$cnum,$cdom);
+ }
if ($env{'form.folderpath'}) {
&prepare_functions($resurl,$forcereg,$group,undef,undef,1,$hostname);
+ $title = &HTML::Entities::encode($title,'\'"<>&');
($trail) =
- &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1);
+ &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1,1);
} else {
&Apache::lonhtmlcommon::add_breadcrumb(
{text => "Supplemental $crstype Content",
href => "javascript:gopost('/adm/supplemental','')"});
- $title = &mt('View Resource');
+ $title = &HTML::Entities::encode(&mt('View Resource'),'\'"<>&');
($trail) =
- &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1);
+ &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1,1);
+ }
+ if (ref($showncrumbsref)) {
+ $$showncrumbsref = 1;
}
return $trail;
} elsif ($resurl =~ m{^\Q/uploaded$courseurl/portfolio/syllabus/}) {
&Apache::lonhtmlcommon::clear_breadcrumbs();
&prepare_functions('/public'.$courseurl."/syllabus",
$forcereg,$group,undef,undef,1,$hostname);
- $title = &mt('Syllabus File');
+ $title = &HTML::Entities::encode(&mt('Syllabus File'),'\'"<>&');
my ($trail) =
- &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1,$hostname);
+ &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1,1);
+ if (ref($showncrumbsref)) {
+ $$showncrumbsref = 1;
+ }
+ return $trail;
+ } elsif (($resurl eq '/public'.$courseurl.'/syllabus') &&
+ ($env{'form.folderpath'})) {
+ if ($env{'form.title'}) {
+ $title = $env{'form.title'};
+ } else {
+ $title = 'Syllabus';
+ }
+ &prepare_functions($resurl,$forcereg,$group,undef,undef,1,$hostname);
+ $title = &HTML::Entities::encode($title,'\'"<>&');
+ my ($trail) =
+ &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1,1);
return $trail;
}
unless ($env{'request.state'} eq 'construct') {
@@ -961,11 +1122,107 @@ sub innerregister {
'Folder/Page Content');
}
# End modifiable folder/page container check
+
+#
+# Determine whether to show View As button for shortcut to display problem, answer, and submissions
+#
+
+ if (($env{'request.symb'} ne '') &&
+ ($env{'request.filename'}=~/$LONCAPA::assess_re/) &&
+ (($perms{'mgr'}) || ($perms{'vgr'}))) {
+ my ($viewas,$text,$change,$visibility,$vuname,$vudom,$vid,$leftvis,$defdom,
+ $domselector,$righticon);
+ my %lt = &Apache::lonlocal::texthash(
+ view => 'View',
+ upda => 'Update',
+ );
+ my $possdomstr = $env{'course.'.$env{'request.course.id'}.'.internal.userdomains'};
+ if ($possdomstr =~ /,/) {
+ my @possdoms = split(/,/,$possdomstr);
+ if ($env{'request.user_in_effect'} =~ /^$match_username:($match_domain)$/) {
+ $defdom = $1;
+ } elsif (grep(/^\Q$cdom\E$/,@possdoms)) {
+ $defdom = $cdom;
+ } elsif (&Apache::lonnet::domain($possdoms[0]) ne '') {
+ $defdom = $possdoms[0];
+ }
+ $domselector = &Apache::loncommon::select_dom_form($defdom,'vudom','','','',\@possdoms);
+ } elsif (($possdomstr ne '') && (&Apache::lonnet::domain($possdomstr) ne '')) {
+ if ($env{'request.user_in_effect'} =~ /^$match_username:($match_domain)$/) {
+ $defdom = $1;
+ } else {
+ $defdom = $possdomstr;
+ }
+ }
+ if ($env{'request.user_in_effect'} =~ /^($match_username):($match_domain)$/) {
+ ($vuname,$vudom) = ($1,$2);
+ unless (&Apache::lonnet::is_advanced_user($vudom,$vuname)) {
+ $vid = (&Apache::lonnet::idrget($vudom,$vuname))[1];
+ }
+ $viewas = $env{'request.user_in_effect'};
+ $text = $lt{'upda'};
+ $change = 'off';
+ $visibility = 'inline';
+ $leftvis = 'none';
+ $defdom = $vudom;
+ $righticon = '✖';
+ } else {
+ $text = $lt{'view'};
+ $change = 'on';
+ $visibility = 'none';
+ $leftvis = 'inline';
+ if ($defdom eq '') {
+ $defdom = $cdom;
+ }
+ }
+ my $sellink = &Apache::loncommon::selectstudent_link('userview','vuname','vudom','','','vuidentifier');
+ my $selscript=&Apache::loncommon::studentbrowser_javascript();
+ my $shownsymb = &HTML::Entities::encode(&Apache::lonenc::check_encrypt($env{'request.symb'}),'<>&"');
+ my $input;
+ my @items = (
+ ' ',
+ ' ',
+ ' ',
+ ' '
+ );
+ if ($domselector) {
+ push(@items,$domselector);
+ $input = &mt('[_1]User:[_2] or [_3]ID:[_4] at [_5] | ',@items);
+ } else {
+ $input = &mt('[_1]Username:[_2] or [_3]ID:[_4] | ',@items).
+ ' ';
+ }
+ $input .= ' ',
+ ' ';
+ my $chooser = <