--- loncom/interface/lonmenu.pm 2009/10/13 13:18:25 1.285 +++ loncom/interface/lonmenu.pm 2009/10/16 00:46:01 1.289 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.285 2009/10/13 13:18:25 wenzelju Exp $ +# $Id: lonmenu.pm,v 1.289 2009/10/16 00:46:01 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -113,11 +113,6 @@ The javascript is usually similar to "go =item get_nav_status() -=item convert_menu_function() - -FIXME this needs to move into mydesktab and the other locations -the text is generated - =item hidden_button_check() =item roles_selector() @@ -200,34 +195,38 @@ sub primary_menu { sub secondary_menu { my $menu; + my $crstype = &Apache::loncommon::course_type(); + my $canedit = &Apache::lonnet::allowed('mdc', $env{'request.course.id'}); + my $canviewgrps = &Apache::lonnet::allowed('vcg', $env{'request.course.id'} + . ($env{'request.course.sec'} ? "/$env{'request.course.sec'}" + : '')); + my $showlink = &show_return_link(); + my %groups = &Apache::lonnet::get_active_groups( + $env{'user.domain'}, $env{'user.name'}, + $env{'course.' . $env{'request.course.id'} . '.domain'}, + $env{'course.' . $env{'request.course.id'} . '.num'}); foreach my $menuitem (@secondary_menu) { # evaluate conditions next if $$menuitem[4] ne 'always' && !$env{'request.course.id'}; next if $$menuitem[4] eq 'showreturn' - && !show_return_link() + && !$showlink && !($env{'request.state'} eq 'construct'); next if $$menuitem[4] =~ /^mdc/ - && !Apache::lonnet::allowed('mdc', $env{'request.course.id'}); - next if $$menuitem[4] =~ /nogrp$/ - && Apache::loncommon::course_type() eq 'Group'; - next if $$menuitem[4] =~ /group$/ - && Apache::loncommon::course_type() ne 'Group'; - next if $$menuitem[4] eq 'remotenav' + && !$canedit; + next if $$menuitem[4] eq 'mdcCourse' + && $crstype eq 'Community'; + next if $$menuitem[4] eq 'mdcCommunity' + && $crstype ne 'Community'; + next if $$menuitem[4] =~ /^remotenav/ && $env{'environment.remotenavmap'} ne 'on'; - next if $$menuitem[4] eq 'noremotenav' + next if $$menuitem[4] =~ /noremotenav/ && $env{'environment.remotenavmap'} eq 'on'; next if $$menuitem[4] =~ /showgroups$/ - && !Apache::lonnet::allowed('vcg', $env{'request.course.id'} - . ($env{'request.course.sec'} ? "/$env{'request.course.sec'}" - : '')) - && !Apache::lonnet::get_active_groups( - $env{'user.domain'}, $env{'user.name'}, - $env{'course.' . $env{'request.course.id'} . '.domain'}, - $env{'course.' . $env{'request.course.id'} . '.num'}); - + && $canviewgrps + && !%groups; - if($$menuitem[3] eq 'Roles' && $env{'request.course.id'}) { + if ($$menuitem[3] eq 'Roles' && $env{'request.course.id'}) { # special treatment for role selector my $roles_selector = roles_selector( $env{'course.' . $env{'request.course.id'} . '.domain'}, @@ -280,7 +279,7 @@ sub initlittle { 'login' => 'Log In', 'launch' => 'Launch Remote Control', 'groups' => 'Groups', - 'gdoc' => 'Group Documents', + 'gdoc' => 'Community Documents', ); } @@ -381,9 +380,10 @@ ENDINLINEMENU $navmaps=(<$lt{'nav'} ENDNAV - my $is_group = (&Apache::loncommon::course_type() eq 'Group'); + my $is_community = + (&Apache::loncommon::course_type() eq 'Community'); if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) { - my $text = ($is_group) ? $lt{'gdoc'} : $lt{'docs'}; + my $text = ($is_community) ? $lt{'gdoc'} : $lt{'docs'}; $docs=(<$text ENDDOCS @@ -519,7 +519,7 @@ sub innerregister { $newmail= 'swmenu.setstatus("you have","messages");'; } - my $breadcrumb; + my ($breadcrumb,$separator); if ($noremote && ($env{'request.symb'}) && ($env{'request.course.id'})) { @@ -529,10 +529,13 @@ sub innerregister { my $maptitle = &Apache::lonnet::gettitle($mapurl); my $restitle = &Apache::lonnet::gettitle(&Apache::lonnet::symbread()); - my @crumbs = ({text => "Course Content", - href => "Javascript:gonav('/adm/navmaps')"}, - {text => '...', - no_mt => 1}); + my @crumbs = ({text => "Course Contents", + href => "Javascript:gonav('/adm/navmaps')"}); + + if ($mapurl ne $env{'course.'.$env{'request.course.id'}.'.url'}) { + push(@crumbs, {text => '...', + no_mt => 1}); + } push @crumbs, {text => $maptitle, no_mt => 1} if ($maptitle && $maptitle ne 'default.sequence' @@ -543,6 +546,11 @@ sub innerregister { Apache::lonhtmlcommon::clear_breadcrumbs(); Apache::lonhtmlcommon::add_breadcrumb(@crumbs); $breadcrumb .= Apache::lonhtmlcommon::breadcrumbs(undef,undef,0); + unless (($env{'request.state'} eq 'edit') || ($newmail) || + ($env{'request.state'} eq 'construct') || + ($env{'form.register'})) { + $separator = &Apache::loncommon::head_subbox(); + } # } if ($env{'request.state'} eq 'construct') { @@ -831,6 +839,7 @@ $tablestart $inlinebuttons $tableend $newmail +$separator @@ -1317,12 +1326,6 @@ sub rawconfig { $prt=~s/\$requested_domain/$requested_domain/g; if ($category_names{$cat}!~/\w/) { $cat='oth'; } my $type = &Apache::loncommon::course_type(); -# -# I don't think we support this -# -# if ($type eq 'Group') { -# $desc = &convert_menu_function($desc,$type); -# } if ($pro eq 'clear') { $output.=&clear($row,$col); } elsif ($pro eq 'any') { @@ -1714,22 +1717,6 @@ sub get_nav_status { return $navstatus; } -#FIXME this needs to move into mydesk.tab and the other locations -# the text is generated -# -# We currently do not support this anyway. -# -#sub convert_menu_function { -# my ($rolename,$type) = @_; -# if ($type eq 'Group') { -# $rolename =~ s/student/member/g; -# $rolename =~ s/group/team/g; -# $rolename =~ s/course/group/g; -# $rolename =~ s/Course/Group/g; -# } -# return $rolename; -#} - sub hidden_button_check { my $hidden; if ($env{'request.course.id'} eq '') { @@ -1744,6 +1731,10 @@ sub hidden_button_check { sub roles_selector { my ($cdom,$cnum) = @_; + my $crstype = $env{'course.'.$env{'request.course.id'}.'.type'}; + if ($crstype eq '') { + $crstype = 'Course'; + } my $now = time; my (%courseroles,%seccount); my $is_cc; @@ -1793,12 +1784,18 @@ sub roles_selector { } } } + my $switchtext; + if ($crstype eq 'Community') { + $switchtext = &mt('Switch community role to...') + } else { + $switchtext = &mt('Switch course role to...') + } my @roles_order = ('cc','in','ta','ep','ad','st'); if (keys(%courseroles) > 1) { $role_selector = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles); $role_selector .= '