--- loncom/interface/lonmenu.pm 2023/10/08 15:21:48 1.369.2.83.2.12 +++ loncom/interface/lonmenu.pm 2024/08/22 02:11:11 1.369.2.83.2.19 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.369.2.83.2.12 2023/10/08 15:21:48 raeburn Exp $ +# $Id: lonmenu.pm,v 1.369.2.83.2.19 2024/08/22 02:11:11 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -266,7 +266,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) @@ -370,6 +370,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]}); } @@ -424,6 +437,10 @@ sub primary_menu { } my @output = ('',''); if ($menu{'left'} ne '') { + if ($collapsible) { + $menu{'left'} = ($listclass?'
  • ':'
  • '). + ' 
  • '.$menu{'left'}; + } $output[0] = "
      $menu{'left'}
    "; } if ($menu{'right'} ne '') { @@ -439,10 +456,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 @@ -483,6 +500,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; @@ -542,13 +568,24 @@ 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); @@ -573,7 +610,11 @@ sub secondary_menu { # evaluate conditions next if ref($menuitem) ne 'ARRAY'; next if $$menuitem[4] ne 'always' - && ($$menuitem[4] ne 'author' && $$menuitem[4] ne 'cca') + && $$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); @@ -605,9 +646,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; @@ -645,8 +694,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; @@ -729,6 +778,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; @@ -881,7 +944,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 ''; } @@ -1229,7 +1292,7 @@ END # End course context # Prepare the rest of the buttons - my ($menuitems,$got_prt,$got_wishlist,$cstritems); + my ($menuitems,$got_prt,$got_wishlist,$cstritems,$toplevel_cstr); if ($const_space) { # # We are in construction space @@ -1240,14 +1303,32 @@ END ($env{'request.filename'}=~m{^\Q$londocroot/priv/\E([^/]+)/([^/]+)/(.*)$}); my $currdir = '/priv/'.$udom.'/'.$uname.'/'.$thisdisfn; if ($currdir =~ m-/$-) { - $is_const_dir = 1; if ($thisdisfn eq '') { - $is_const_dir = 2; + $toplevel_cstr = 1; + } + my $esc_currdir = &Apache::loncommon::escape_single($currdir); + $menuitems=(<'; $inlineremote[$idx] = ''. - $pic.''.$top.' '.$form; + $pic.''.$top.' '; } # Remote $img=~s/\.png$/\.gif/; @@ -2187,7 +2358,7 @@ sub switch { } else { $inlineremote[$idx] = ''.$pic. - ''.$top.' '; + ''.$top.' '.$form; } } return ''; @@ -2339,6 +2510,8 @@ sub rawconfig { } else { next; } + } elsif ($priv eq 'cca') { + next if ($rol eq 'cm'); } if ((($priv eq 'bre') && (&Apache::lonnet::allowed($priv,$prt) eq 'F')) || (($priv ne 'bre') && (&Apache::lonnet::allowed($priv,$prt)))) { @@ -2420,6 +2593,24 @@ sub rawconfig { } } } + } elsif ($pro eq 'coauthor') { + if ($env{'request.role'}=~ m{^(ca|aa)\./($match_domain)/($match_username)$}) { + my ($role,$audom,$auname) = ($1,$2,$3); + if ((($prt eq 'raa') && ($role eq 'aa')) || + (($prt eq 'rca') && ($role eq 'ca') && + (!$env{"environment.internal.manager./$audom/$auname"}))) { + $output.=&switch($auname,$audom, + $row,$col,$img,$top,$bot,$act,$desc,$cat); + } + } + } elsif ($pro eq 'coauthorenv_manager') { + if ($env{'request.role'}=~ m{^ca\./($match_domain)/($match_username)$}) { + my ($audom,$auname) = ($1,$2); + if ($env{"environment.internal.manager./$audom/$auname"}) { + $output.=&switch($auname,$audom, + $row,$col,$img,$top,$bot,$act,$desc,$cat); + } + } } elsif ($pro eq 'tools') { my @tools = ('aboutme','blog','portfolio'); if (grep(/^\Q$prt\E$/,@tools)) { @@ -2905,6 +3096,8 @@ 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(); @@ -2996,6 +3189,22 @@ function gocstr(url,filename) { this.document.cstrdelete.submit(); return; } + if ((url == '/adm/cfile?action=copy') || (url == '/adm/cfile?action=rename')) { + this.document.cstrcopy.filename.value = filename; + var oldname = filename.substring(filename.lastIndexOf("/") + 1); + var newname=prompt('$newname',oldname); + if (newname == "" || !newname || newname == oldname) { + return; + } + if (url == '/adm/cfile?action=rename') { + this.document.cstrcopy.action.value = 'rename'; + } else { + this.document.cstrcopy.action.value = 'copy'; + } + this.document.cstrcopy.newfilename.value = newname; + this.document.cstrcopy.submit(); + return; + } if (url == '/adm/printout') { this.document.cstrprint.postdata.value = filename this.document.cstrprint.curseed.value = 0; @@ -3022,6 +3231,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; @@ -3173,6 +3386,11 @@ sub constspaceform { +
    + + + +
    ENDCONSTSPACEFORM }