--- loncom/interface/lonmenu.pm 2023/12/28 19:38:17 1.544 +++ loncom/interface/lonmenu.pm 2024/11/22 22:43:54 1.558 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.544 2023/12/28 19:38:17 raeburn Exp $ +# $Id: lonmenu.pm,v 1.558 2024/11/22 22:43:54 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -378,6 +378,7 @@ sub primary_menu { } else { next; } + } if ($env{'request.course.id'} && $menucoll) { next if ($item->[3]) && (!$menuopts{$item->[3]}); } @@ -909,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 ''; } @@ -1234,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 # @@ -1243,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); @@ -1262,6 +1261,14 @@ 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'}) && + ($uname eq $env{'user.name'}) && ($udom eq $env{'user.domain'})) { + $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); @@ -1276,7 +1283,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 @@ -1306,6 +1313,35 @@ 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(); foreach my $crumb (@{$bread_crumbs}){ @@ -1515,8 +1551,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 { @@ -1524,6 +1565,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) { @@ -1534,7 +1581,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'))) { @@ -1708,7 +1755,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); @@ -1850,7 +1904,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]); @@ -2633,6 +2687,7 @@ sub utilityfunctions { my $esc_url=&escape($currenturl); my $esc_symb=&escape($currentsymb); my $newname = &mt('New Name'); + &js_escape(\$newname); my $countdown = &countdown_toggle_js(); @@ -2641,7 +2696,7 @@ sub utilityfunctions { ($env{'request.symb'} ne '') && ($env{'request.filename'}=~/$LONCAPA::assess_re/)) { my $canview; - foreach my $priv ('msg','vgr') { + foreach my $priv ('mgr','vgr') { $canview = &Apache::lonnet::allowed($priv,$env{'request.course.id'}); if (!$canview && $env{'request.course.sec'} ne '') { $canview = @@ -2766,6 +2821,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; @@ -2883,12 +2942,14 @@ sub serverform { if (($env{'request.deeplink.login'}) && ($env{'request.deeplink.target'} eq '_self')) { $target = ' target="_self"'; } + my $submit = &mt('Submit'); return(<<ENDSERVERFORM); -<form name="server" action="/adm/logout" method="post"$target> +<form name="server" action="/adm/logout" method="post"$target aria-hidden="true"> <input type="hidden" name="postdata" value="none" /> <input type="hidden" name="command" value="none" /> <input type="hidden" name="url" value="none" /> <input type="hidden" name="symb" value="none" /> +<input type="submit" value="$submit" class="LC_visually_hidden" tabindex="-1" disabled="disabled" /> </form> ENDSERVERFORM } @@ -3053,7 +3114,7 @@ sub roles_selector { $js = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles,\%courseprivs, \%roledesc,$privref,$menucoll,$menuref); $form = - '<form name="rolechooser" method="post" action="'.$httphost.'/adm/roles"'.$targetattr.'>'."\n". + '<form name="rolechooser" method="post" action="'.$httphost.'/adm/roles"'.$targetattr.' aria-hidden="true">'."\n". ' <input type="hidden" name="destinationurl" value="'. &HTML::Entities::encode($destinationurl).'" />'."\n". ' <input type="hidden" name="gotorole" value="1" />'."\n". @@ -3063,7 +3124,8 @@ sub roles_selector { $form .= ' <input type="hidden" name="destsymb" value="'. &HTML::Entities::encode($destsymb).'" />'."\n"; } - $form .= '</form>'."\n"; + $form .= '<input type="submit" value="'.&mt('Submit').'" class="LC_visually_hidden" tabindex="-1" disabled="disabled" />'."\n". + '</form>'."\n"; foreach my $role (@roles_order) { my $include; if (defined($courseroles{$role})) { @@ -3552,7 +3614,7 @@ $donebutton <span id="ddcountcollapse" class="LC_menubuttons_inline_text"> $collapse </span></a> -<span id="duedatecountdown" class="LC_menubuttons_inline_text" style="display: $currdisp;"></span> +<span id="duedatecountdown" class="LC_menubuttons_inline_text" style="display: $currdisp;" role="timer"></span> <a href="javascript:toggleCountdown();" class="LC_menubuttons_link"> <span id="ddcountexpand" class="LC_menubuttons_inline_text" >$expand</span> <img src="/res/adm/pages/timer.png" title="$desc" class="LC_icon" alt="$alttxt" /><span class="LC_menubuttons_inline_text">$title</span></a>