--- loncom/interface/lonmenu.pm 2023/10/06 02:04:47 1.540
+++ loncom/interface/lonmenu.pm 2025/01/07 22:21:56 1.560
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines to control the menu
#
-# $Id: lonmenu.pm,v 1.540 2023/10/06 02:04:47 raeburn Exp $
+# $Id: lonmenu.pm,v 1.560 2025/01/07 22:21:56 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,19 @@ 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 +434,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 +453,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 +497,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 +565,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,11 +606,19 @@ 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);
+ next if $$menuitem[4] eq 'crseditCourse'
+ && ($crstype eq 'Community');
+ next if $$menuitem[4] eq 'crseditCommunity'
+ && ($crstype ne 'Community');
next if $$menuitem[4] eq 'nvgr'
&& ($canvgr || $ltiexc{'grades'});
next if $$menuitem[4] eq 'vgr'
@@ -599,9 +643,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 +689,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 +776,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;
@@ -848,7 +914,7 @@ sub innerregister {
my ($forcereg,$bread_crumbs,$group,$pagebuttonshide,$hostname,
$ltiscope,$ltiuri,$showncrumbsref) = @_;
my $const_space = ($env{'request.state'} eq 'construct');
- my $is_const_dir = 0;
+ my $in_daxe = 0;
if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
@@ -1173,8 +1239,8 @@ END
# End course context
# Prepare the rest of the buttons
- my ($menuitems,$got_prt,$got_wishlist,$crsauthor);
- if ($const_space) {
+ my ($menuitems,$got_prt,$got_wishlist,$crsauthor,$toplevel_cstr,$crsauthor_cstr);
+ if ($const_space) {
#
# We are in construction space
#
@@ -1182,17 +1248,15 @@ END
my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
my ($udom,$uname,$thisdisfn) =
($env{'request.filename'}=~m{^\Q$londocroot/priv/\E([^/]+)/([^/]+)/(.*)$});
- my $crsauthor;
if (($env{'request.course.id'}) &&
($env{'course.'.$env{'request.course.id'}.'.num'} eq $uname) &&
($env{'course.'.$env{'request.course.id'}.'.domain'} eq $udom)) {
- $crsauthor = 1;
+ $crsauthor_cstr = 1;
}
my $currdir = '/priv/'.$udom.'/'.$uname.'/'.$thisdisfn;
if ($currdir =~ m-/$-) {
- $is_const_dir = 1;
- if (($thisdisfn eq '') && ($crsauthor)) {
- $is_const_dir = 2;
+ if ($thisdisfn eq '') {
+ $toplevel_cstr = 1;
}
my $esc_currdir = &Apache::loncommon::escape_single($currdir);
$menuitems=(<
+
ENDSERVERFORM
}
@@ -2948,7 +3118,7 @@ sub roles_selector {
$js = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles,\%courseprivs,
\%roledesc,$privref,$menucoll,$menuref);
$form =
- ''."\n";
+ $form .= ''."\n".
+ ''."\n";
foreach my $role (@roles_order) {
my $include;
if (defined($courseroles{$role})) {
@@ -3447,7 +3618,7 @@ $donebutton
-
+