--- loncom/interface/lonmenu.pm 2023/11/03 01:12:15 1.541 +++ loncom/interface/lonmenu.pm 2024/05/21 02:57:16 1.554 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.541 2023/11/03 01:12:15 raeburn Exp $ +# $Id: lonmenu.pm,v 1.554 2024/05/21 02:57:16 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?'<li class="'.$listclass.'">':'<li>'). + ' </li>'.$menu{'left'}; + } $output[0] = "<ol class=\"LC_primary_menu LC_floatleft\">$menu{'left'}</ol>"; } if ($menu{'right'} ne '') { @@ -893,7 +910,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 ''; } @@ -1218,8 +1235,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 # @@ -1227,17 +1244,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=(<<ENDMENUITEMS); @@ -1246,6 +1261,13 @@ s&7&4&docs-22x22.png&Edit Metadata&defau s&7&2&prt.png&Print&printout[_1]&gocstr('/adm/printout','$esc_currdir')&Print contents of directory s&7&1&del.png&Delete&dir[_3]&gocstr('/adm/cfile?action=delete','$esc_currdir')&Delete this Directory ENDMENUITEMS + unless ($crsauthor_cstr) { + if ($env{'environment.canarchive'}) { + $menuitems .= (<<ENDMENUITEMS); +s&7&7&archive.png&Export&dir[_1]&gocstr('/adm/cfile?action=archive','$esc_currdir')&Export Authoring Space Archive +ENDMENUITEMS + } + } } else { $currdir =~ s|[^/]+$||; my $cleandisfn = &Apache::loncommon::escape_single($thisdisfn); @@ -1260,7 +1282,7 @@ ENDMENUITEMS # # Probably should be in mydesk.tab # - if (($crsauthor) && ($pubfile eq "/res/$udom/$uname/default.rights")) { + if (($crsauthor_cstr) && ($pubfile eq "/res/$udom/$uname/default.rights")) { $menuitems=(<<ENDMENUITEMS); s&6&1&list.png&Directory&dir[_1]&golist('$esc_currdir')&List current directory s&6&3&pub.png&Publish&resource[_3]&gocstr('/adm/publish','/priv/$udom/$uname/$cleandisfn')&Publish this resource @@ -1282,9 +1304,42 @@ s&7&4&rename.png&Rename&resource[_5]&goc s&7&1&del.png&Delete&resource[_2]&gocstr('/adm/cfile?action=delete','/priv/$udom/$uname/$cleandisfn')&Delete this resource ENDMENUITEMS } - $menuitems .= (<<ENDMENUITEMS); +# +# Print only makes sense for certain mime types +# + if ($thisdisfn=~/\.(xml|html|htm|xhtml|xhtm|tex)$/ || $thisdisfn=~/$LONCAPA::assess_re/) { + $menuitems .= (<<ENDMENUITEMS); s&7&2&prt.png&Print&printout[_1]&gocstr('/adm/printout','/priv/$udom/$uname/$cleandisfn')&Prepare a printable document ENDMENUITEMS + } +# +# "Exit Daxe" in Functions menu when using Daxe +# + if ((($env{'form.editmode'} eq 'daxe') && + ($thisdisfn=~/\.(xml|html|htm|xhtml|xhtm)$/)) || + (($env{'form.problemmode'} eq 'daxe') && + ($thisdisfn=~/$LONCAPA::assess_re/))) { + my %editors = &Apache::loncommon::permitted_editors(); + if ($editors{'daxe'}) { + my $privfile = &Apache::loncommon::escape_single("/priv/$udom/$uname/$thisdisfn"); + $in_daxe = 1; + $menuitems .= (<<ENDMENUITEMS); +my $privfile = &Apache::loncommon::escape_single("/priv/$udom/$uname/$thisdisfn"); +s&7&6&tolastloc.png&Exit Daxe&resource[_1]&go('$privfile')&Exit editing this resource +ENDMENUITEMS + } + } + } +# +# Editing options usually accessed via "Settings" in inline menu need to be +# accessed in a different way, when Authoring Space is accessed in course +# context +# + if ($env{'request.role'} !~/^(aa|ca|au)/) { + my $privfile = &Apache::loncommon::escape_single("/priv/$udom/$uname/$thisdisfn"); + $menuitems .= (<<ENDMENUITEMS); +s&7&5&editops.png&Options&edit[_1]&gocstr('/adm/preferences?action=authorsettings','$privfile')&Authoring Space Options +ENDMENUITEMS } if (ref($bread_crumbs) eq 'ARRAY') { &Apache::lonhtmlcommon::clear_breadcrumbs(); @@ -1495,8 +1550,13 @@ ENDMENUITEMS &Apache::lonhtmlcommon::add_breadcrumb_tool( 'tools',@tools); + #exit editing link/icon when using daxe in construction space #publish button in construction space if ($env{'request.state'} eq 'construct'){ + if ($in_daxe) { + &Apache::lonhtmlcommon::add_breadcrumb_tool( + 'advtools', $inlineremote[76]); + } &Apache::lonhtmlcommon::add_breadcrumb_tool( 'advtools', $inlineremote[63]); } else { @@ -1504,6 +1564,12 @@ ENDMENUITEMS 'tools', $inlineremote[63]); } &advtools_crumbs(@inlineremote); + #options link/icon in constructions space viewed with course role + if (($env{'request.state'} eq 'construct') && + ($env{'request.role'} !~/^(aa|ca|au)/)) { + &Apache::lonhtmlcommon::add_breadcrumb_tool( + 'advtools', $inlineremote[75]); + } } } else { if ($showprogress) { @@ -1514,7 +1580,7 @@ ENDMENUITEMS } } my ($topic_help,$topic_help_text); - if ($is_const_dir == 2) { + if ($toplevel_cstr && !$crsauthor_cstr) { if ((($ENV{'SERVER_PORT'} == 443) || ($Apache::lonnet::protocol{$Apache::lonnet::perlvar{'lonHostID'}} eq 'https')) && (&Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'},'webdav'))) { @@ -1688,7 +1754,14 @@ sub prepare_functions { } elsif (($resurl !~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) && ($resurl ne '/cgi-bin/printout.pl')) { if ($env{'request.filename'}) { - my $file=&Apache::lonnet::declutter($env{'request.filename'}); + my $file; + my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'}; + if ($env{'request.filename'} =~ m{^\Q$londocroot\E/priv/}) { + $file = $env{'request.filename'}; + $file =~ s{^\Q$londocroot\E/}{}; + } else { + $file=&Apache::lonnet::declutter($env{'request.filename'}); + } ($cfile,$home,$switchserver,$forceedit,$forceview) = &Apache::lonnet::can_edit_resource($file,$cnum,$cdom, &Apache::lonnet::clutter($resurl),$env{'request.symb'},$group); @@ -1830,7 +1903,7 @@ sub advtools_crumbs { } elsif ($env{'request.noversionuri'} !~ m{^/adm/(navmaps|viewclasslist)(\?|$)}) { if ($env{'request.state'} eq 'construct') { &Apache::lonhtmlcommon::add_breadcrumb_tool( - 'advtools', @funcs[61,73,74,71,72]); + 'advtools', @funcs[61,73,74,71,72,77]); } else { &Apache::lonhtmlcommon::add_breadcrumb_tool( 'advtools', @funcs[61,71,72,73,74,75,92]); @@ -2746,6 +2819,10 @@ function gocstr(url,filename) { this.document.cstrprint.submit(); return; } + if (url == '/adm/preferences?action=authorsettings') { + document.location.href=url+'&returnurl='+filename; + return; + } if (url !='') { this.document.constspace.filename.value = filename; this.document.constspace.action = url;