--- loncom/interface/lonmenu.pm 2023/09/08 18:02:23 1.536
+++ loncom/interface/lonmenu.pm 2023/12/28 19:38:17 1.544
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines to control the menu
#
-# $Id: lonmenu.pm,v 1.536 2023/09/08 18:02:23 raeburn Exp $
+# $Id: lonmenu.pm,v 1.544 2023/12/28 19:38:17 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -245,7 +245,7 @@ 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,$menucoll,$menuref,$links_disabled,$links_target) = @_;
+ 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)
@@ -366,6 +366,18 @@ sub primary_menu {
($item->[2] eq 'blog')) &&
(!&Apache::lonnet::usertools_access('','',$item->[2],
undef,'tools')));
+ if (($item->[2] eq 'browsepub') && ($item->[0] eq '/res/')) {
+ if ($env{'request.role'} =~ /^au\./) {
+ $item->[0] .= $env{'request.role.domain'}.'/?launch=1';
+ } elsif ($env{'request.role'} =~ m{^ca\./($match_domain)/($match_username)$}) {
+ $item->[0] .= $1.'/'.$2.'/?launch=1';
+ } elsif (&Apache::lonnet::allowed('bre',$env{'user.domain'})) {
+ $item->[0] .= $env{'user.domain'}.'/?launch=1';
+ } elsif (&Apache::lonnet::allowed('bro','/res/')) {
+ $item->[0] .= '?launch=1';
+ } else {
+ next;
+ }
if ($env{'request.course.id'} && $menucoll) {
next if ($item->[3]) && (!$menuopts{$item->[3]});
}
@@ -421,6 +433,10 @@ sub primary_menu {
}
my @output = ('','');
if ($menu{'left'} ne '') {
+ if ($collapsible) {
+ $menu{'left'} = ($listclass?'
':'').
+ ' '.$menu{'left'};
+ }
$output[0] = "";
}
if ($menu{'right'} ne '') {
@@ -436,10 +452,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
@@ -480,6 +496,15 @@ sub secondary_menu {
my $canplc = &Apache::lonnet::allowed('plc', $crs_sec);
my $author = &getauthor();
+ 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;
@@ -539,15 +564,25 @@ sub secondary_menu {
$linkattr = 'aria-disabled="true"';
}
- my ($canmodifycoauthor);
+ 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);
if ($links_target ne '') {
$target = $links_target;
@@ -570,8 +605,12 @@ sub 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);
@@ -599,9 +638,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;
@@ -637,8 +684,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;
@@ -724,6 +771,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;
@@ -968,6 +1029,18 @@ sub innerregister {
$$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') {
&Apache::lonhtmlcommon::clear_breadcrumbs();
@@ -1069,11 +1142,30 @@ sub innerregister {
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,$righticon);
+ 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)) {
@@ -1091,17 +1183,29 @@ sub innerregister {
$change = 'on';
$visibility = 'none';
$leftvis = 'inline';
- $defdom = $cdom;
+ if ($defdom eq '') {
+ $defdom = $cdom;
+ }
}
- my $sellink = &Apache::loncommon::selectstudent_link('userview','vuname','vudom');
+ 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 = &mt('User: [_1] or ID: [_2] at: [_3]',
- '',
- '',
- &Apache::loncommon::select_dom_form($defdom,'vudom')).
- '',
- '';
+ 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 = <