--- loncom/interface/lonmenu.pm 2021/11/15 23:29:20 1.512 +++ loncom/interface/lonmenu.pm 2022/05/28 15:55:34 1.519 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.512 2021/11/15 23:29:20 raeburn Exp $ +# $Id: lonmenu.pm,v 1.519 2022/05/28 15:55:34 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -99,7 +99,7 @@ It gets filled in the BEGIN block of thi =over -=item prep_menuitems(\@menuitem,$ltitarget) +=item prep_menuitems(\@menuitem,$ltitarget,$deeplinktarget,$listclass,$linkattr) This routine wraps a menuitem in proper HTML. It is used by primary_menu() and secondary_menu(). @@ -220,7 +220,7 @@ use vars qw(@desklines %category_names % my @inlineremote; sub prep_menuitem { - my ($menuitem,$ltitarget,$listclass,$linkattr) = @_; + my ($menuitem,$ltitarget,$deeplinktarget,$listclass,$linkattr) = @_; return '' unless(ref($menuitem) eq 'ARRAY'); my $link; if ($$menuitem[1]) { # graphical Link @@ -233,6 +233,8 @@ sub prep_menuitem { my $target = ' target="_top"'; if ($ltitarget eq 'iframe') { $target =''; + } elsif ($deeplinktarget eq '_self') { + $target = ' target="'.$deeplinktarget.'"'; } return ($listclass?'
  • ':'
  • ').'[0] ne '') { $link = $menuitem->[0]; - unless ($ltitarget eq 'iframe') { + unless (($ltitarget eq 'iframe') || ($deeplinktarget eq '_self')) { $target = '_top'; } } else { @@ -391,7 +396,7 @@ sub primary_menu { 'helpdeskmail', $defdom,$origmail); if ($to ne '') { - $menu{$position} .= &prep_menuitem($menuitem,$ltitarget,$listclass,$linkattr); + $menu{$position} .= &prep_menuitem($menuitem,$ltitarget,$deeplinktarget,$listclass,$linkattr); } } else { $menu{$position} .= ($listclass?'
  • ':'
  • '). @@ -404,9 +409,9 @@ sub primary_menu { $$menuitem[0] = '/adm/login'; } } - $menu{$position} .= prep_menuitem($menuitem,$ltitarget,$listclass,$linkattr); + $menu{$position} .= prep_menuitem($menuitem,$ltitarget,$deeplinktarget,$listclass,$linkattr); } else { - $menu{$position} .= prep_menuitem($menuitem,$ltitarget,$listclass,$linkattr); + $menu{$position} .= prep_menuitem($menuitem,$ltitarget,$deeplinktarget,$listclass,$linkattr); } } my @output = ('',''); @@ -537,10 +542,13 @@ sub secondary_menu { } } - my ($roleswitcher_js,$roleswitcher_form,$ltitarget); + my ($roleswitcher_js,$roleswitcher_form,$ltitarget,$deeplinktarget); if ($env{'request.lti.login'}) { $ltitarget = $env{'request.lti.target'}; } + if ($env{'request.deeplink.login'}) { + $deeplinktarget = $env{'request.deeplink.target'}; + } foreach my $menuitem (@secondary_menu) { # evaluate conditions @@ -598,7 +606,7 @@ sub secondary_menu { my ($link,$target); if ($menuitem->[0] ne '') { $link = $menuitem->[0]; - unless ($ltitarget eq 'iframe') { + unless (($ltitarget eq 'iframe') || ($deeplinktarget eq '_self')) { $target = '_top'; } } else { @@ -649,7 +657,7 @@ sub secondary_menu { &roles_selector( $env{'course.' . $env{'request.course.id'} . '.domain'}, $env{'course.' . $env{'request.course.id'} . '.num'}, - $httphost,$ltitarget + $httphost,$menucoll,$menuref ); if (($$menuitem[5]) && (!$menuopts{$$menuitem[5]})) { next unless ($has_opa_priv); @@ -683,7 +691,7 @@ sub secondary_menu { } $$menuitem[0] = &HTML::Entities::encode($$menuitem[0],'&<>"'); } - $menu .= &prep_menuitem(\@$menuitem,$ltitarget,$listclass,$linkattr); + $menu .= &prep_menuitem(\@$menuitem,$ltitarget,$deeplinktarget,$listclass,$linkattr); } } if ($menu =~ /\[url\].*\[symb\]/) { @@ -811,7 +819,7 @@ sub build_submenu { } } - $menu .= '
  • '; $menu .= '' . $title . ''; @@ -1056,6 +1064,13 @@ sub innerregister { $currdir =~ s|[^/]+$||; my $cleandisfn = &Apache::loncommon::escape_single($thisdisfn); my $esc_currdir = &Apache::loncommon::escape_single($currdir); + my $pubfile = "/res/$udom/$uname/$thisdisfn"; + my $candelete = 1; + if (-e $londocroot.$pubfile) { + unless (&Apache::lonnet::metadata($pubfile,'obsolete')) { + undef($candelete); + } + } # # Probably should be in mydesk.tab # @@ -1063,7 +1078,18 @@ sub innerregister { s&6&1&list.png&Directory&dir[_1]&golist('$esc_currdir')&List current directory s&6&2&rtrv.png&Retrieve&version[_1]&gocstr('/adm/retrieve','/priv/$udom/$uname/$cleandisfn')&Retrieve old version s&6&3&pub.png&Publish&resource[_3]&gocstr('/adm/publish','/priv/$udom/$uname/$cleandisfn')&Publish this resource +s&7&3©.png&Copy&resource[_4]&gocstr('/adm/cfile?action=copy','/priv/$udom/$uname/$cleandisfn')&Copy this resource +ENDMENUITEMS +# +# Rename and Delete only available if obsolete or unpublished +# + if ($candelete) { + $menuitems .= (< @@ -2425,10 +2481,17 @@ ENDSERVERFORM } sub constspaceform { + my ($frameset) = @_; my ($target,$printtarget); - unless (($env{'request.lti.login'}) && ($env{'request.lti.target'} eq 'iframe')) { - $target = ' target="_top"'; + if ($frameset) { + $target = ' target="_parent"'; $printtarget = ' target="_parent"'; + } else { + unless ((($env{'request.lti.login'}) && ($env{'request.lti.target'} eq 'iframe')) || + (($env{'request.deeplink.login'}) && ($env{'request.deeplink.target'} eq '_self'))) { + $target = ' target="_top"'; + $printtarget = ' target="_parent"'; + } } return(< @@ -2443,6 +2506,11 @@ sub constspaceform { +
    + + + +
    ENDCONSTSPACEFORM } @@ -2458,7 +2526,7 @@ sub hidden_button_check { } sub roles_selector { - my ($cdom,$cnum,$httphost,$ltitarget) = @_; + my ($cdom,$cnum,$httphost,$menucoll,$menuref) = @_; my $crstype = &Apache::loncommon::course_type(); my $now = time; my (%courseroles,%seccount,%courseprivs,%roledesc); @@ -2565,7 +2633,8 @@ sub roles_selector { } if ((keys(%seccount) > 1) || ($numdiffsec > 1)) { my @submenu; - $js = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles,\%courseprivs,\%roledesc,$privref); + $js = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles,\%courseprivs, + \%roledesc,$privref,$menucoll,$menuref); $form = '
    '."\n". ' 0) && (ref($courseprivs) eq 'HASH')) { my %disallowed; foreach my $role (sort(keys(%{$courseprivs}))) { @@ -2854,8 +2927,22 @@ sub jump_to_role { $checkroles = 1; $js .= " var disallow = new Array('".join("','",keys(%disallowed))."');\n". " var rolecheck = 1;\n"; + if ($menucoll) { + if (ref($menuref) eq 'HASH') { + if ($menuref->{'main'} eq 'n') { + $fallback = '/adm/navmaps'; + if (&Apache::loncommon::course_type() eq 'Community') { + $displaymsg = &mt('Switch role, but display Community Contents page instead?'); + } else { + $displaymsg = &mt('Switch role, but display Course Contents page instead?'); + } + &js_escape(\$displaymsg); + } + } + } } } + &js_escape(\$fallback); if (!$checkroles) { $js .= " var disallow = new Array();\n". " rolecheck = 0;\n"; @@ -2878,8 +2965,8 @@ function adhocRole(newrole) { if (rolecheck > 0) { for (var i=0; i