--- loncom/interface/lonmenu.pm 2013/08/08 02:24:02 1.369.2.44 +++ loncom/interface/lonmenu.pm 2014/02/23 22:36:16 1.369.2.51 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.369.2.44 2013/08/08 02:24:02 raeburn Exp $ +# $Id: lonmenu.pm,v 1.369.2.51 2014/02/23 22:36:16 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -281,7 +281,7 @@ sub primary_menu { push(@primsub,$item); } if (@primsub > 0) { - $menu{$position} .= &create_submenu($link,$target,$title,\@primsub); + $menu{$position} .= &create_submenu($link,$target,$title,\@primsub,1); } elsif ($link) { $menu{$position} .= '
  • '.&mt($title).'
  • '; } @@ -303,8 +303,14 @@ sub primary_menu { $menu{$position} .= prep_menuitem($menuitem); } } - return ("
      $menu{'left'}
    ", - "
      $menu{'right'}
    "); + my @output = ('',''); + if ($menu{'left'} ne '') { + $output[0] = "
      $menu{'left'}
    "; + } + if ($menu{'right'} ne '') { + $output[1] = "
      $menu{'right'}
    "; + } + return @output; } #returns hashref {user=>'',dom=>''} containing: @@ -333,6 +339,7 @@ sub getauthor{ } sub secondary_menu { + my ($httphost) = @_; my $menu; my $crstype = &Apache::loncommon::course_type(); @@ -352,7 +359,7 @@ sub secondary_menu { my $canmgr = &Apache::lonnet::allowed('mgr', $crs_sec); my $author = &getauthor(); - my ($cdom,$cnum,$showsyllabus,$showfeeds); + my ($cdom,$cnum,$showsyllabus,$showfeeds,$showresv); if ($env{'request.course.id'}) { $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; @@ -369,6 +376,12 @@ sub secondary_menu { $showfeeds = 1; } } + unless ($canmgr) { + my %slots = &Apache::lonnet::get_course_slots($cnum,$cdom); + if (keys(%slots) > 0) { + $showresv = 1; + } + } } my ($canmodifycoauthor); @@ -409,8 +422,8 @@ sub secondary_menu { && ($canmodifyuser || !$canviewroster); next if $$menuitem[4] eq 'mgr' && !$canmgr; - next if $$menuitem[4] eq 'nmgr' - && $canmgr; + next if $$menuitem[4] eq 'showresv' + && !$showresv; next if $$menuitem[4] eq 'whn' && !$canviewwnew; next if $$menuitem[4] eq 'opa' @@ -449,7 +462,7 @@ sub secondary_menu { } } if (@scndsub > 0) { - $menu .= &create_submenu($link,$target,$title,\@scndsub); + $menu .= &create_submenu($link,$target,$title,\@scndsub,1); } elsif ($link ne '#') { $menu .= '
  • '.&mt($title).'
  • '; } @@ -459,7 +472,8 @@ sub secondary_menu { ($roleswitcher_js,$roleswitcher_form,my $switcher) = &roles_selector( $env{'course.' . $env{'request.course.id'} . '.domain'}, - $env{'course.' . $env{'request.course.id'} . '.num'} + $env{'course.' . $env{'request.course.id'} . '.num'}, + $httphost ); $menu .= $switcher; } else { @@ -511,7 +525,7 @@ sub secondary_menu { } sub create_submenu { - my ($link,$target,$title,$submenu) = @_; + my ($link,$target,$title,$submenu,$translate) = @_; return unless (ref($submenu) eq 'ARRAY'); my $disptarget; if ($target ne '') { @@ -548,9 +562,17 @@ sub create_submenu { if ($count == $numsub) { $borderbot = 'border-bottom:1px solid black;'; } + unless (($href eq '') || ($href =~ /^\#/)) { + $target = ' target="_top"'; + } $menu .= '
  • '. - &mt($item->[1]).'
  • '; + $borderbot.'">'; + if ($translate) { + $menu .= &mt($item->[1]); + } else { + $menu .= $item->[1]; + } + $menu .= ''; } } $menu .= ''; @@ -838,7 +860,7 @@ ENDMENUITEMS # wishlist is only available for users with access to resource-pool # and links can only be set for resources within the resource-pool $menuitems .= (<'."\n". + '
    '."\n". ' '."\n". ' '."\n".