--- loncom/interface/lonmenu.pm 2009/10/20 03:18:14 1.294 +++ loncom/interface/lonmenu.pm 2009/10/28 09:01:59 1.296 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.294 2009/10/20 03:18:14 raeburn Exp $ +# $Id: lonmenu.pm,v 1.296 2009/10/28 09:01:59 droeschl Exp $ # # Copyright Michigan State University Board of Trustees # @@ -164,6 +164,7 @@ sub primary_menu { # (link url, icon path, alt text, link text, condition) foreach my $menuitem (@primary_menu) { # evaluate conditions + next if ref($menuitem) ne 'ARRAY'; # next if $$menuitem[4] eq 'nonewmsg' # show links depending on && &Apache::lonmsg::mynewmail(); # whether a new msg next if $$menuitem[4] eq 'newmsg' # arrived or not @@ -183,11 +184,9 @@ sub primary_menu { if ($$menuitem[3] eq 'Help') { # special treatment for helplink $menu .= '
  • '.&Apache::loncommon::top_nav_help('Help').'
  • '; } else { - if (ref($menuitem) eq 'ARRAY') { - my @items = @{$menuitem}; - $items[0] = 'javascript:'.$menuitem->[0].';'; - $menu .= &prep_menuitem(\@items); - } + my @items = @{$menuitem}; + $items[0] = 'javascript:'.$menuitem->[0].';'; + $menu .= &prep_menuitem(\@items); } } @@ -210,6 +209,7 @@ sub secondary_menu { $env{'course.' . $env{'request.course.id'} . '.num'}); foreach my $menuitem (@secondary_menu) { # evaluate conditions + next if ref($menuitem) ne 'ARRAY'; next if $$menuitem[4] ne 'always' && !$env{'request.course.id'}; next if $$menuitem[4] eq 'showreturn' @@ -225,6 +225,10 @@ sub secondary_menu { && $env{'environment.remotenavmap'} ne 'on'; next if $$menuitem[4] =~ /noremotenav/ && $env{'environment.remotenavmap'} eq 'on'; + next if $$menuitem[4] =~ /^(no|)remotenav$/ + && $crstype eq 'Community'; + next if $$menuitem[4] =~ /^(no|)remotenavCommunity$/ + && $crstype ne 'Community'; next if $$menuitem[4] =~ /showgroups$/ && $canviewgrps && !%groups; @@ -237,18 +241,17 @@ sub secondary_menu { $menu .= $roles_selector ? "
  • $roles_selector
  • " : ''; - } else { - if ($env{'environment.remotenavmap'} eq 'on') { - my @items = @{$menuitem}; - if ($menuitem->[4] eq 'remotenav') { - $items[0] = "javascript:gonav('$menuitem->[0]');"; - } else { - $items[0] = "javascript:go('$menuitem->[0]');"; - } - $menu .= &prep_menuitem(\@items); + } elsif ($env{'environment.remotenavmap'} eq 'on') { + # open link using javascript when remote navmap is activated + my @items = @{$menuitem}; + if ($menuitem->[4] eq 'remotenav') { + $items[0] = "javascript:gonav('$menuitem->[0]');"; } else { - $menu .= &prep_menuitem(\@$menuitem); + $items[0] = "javascript:go('$menuitem->[0]');"; } + $menu .= &prep_menuitem(\@items); + } else { + $menu .= &prep_menuitem(\@$menuitem); } } if ($menu =~ /\[url\].*\[symb\]/) { @@ -574,7 +577,7 @@ sub innerregister { my $tableend = ( $noremote ? '' : ''); # ============================================================================= # ============================ This is for URLs that actually can be registered - if (($env{'request.noversionuri'}!~m|^/(res/)*adm/|) || ($forcereg)) { + if (($env{'request.noversionuri'}!~m{^/(res/)*adm/}) || ($forcereg)) { # -- This applies to homework problems for users with grading privileges my $crs='/'.$env{'request.course.id'}; if ($env{'request.course.sec'}) { @@ -1320,12 +1323,14 @@ sub rawconfig { my $show_course=&Apache::loncommon::show_course(); my $author=$env{'user.author'}; my $crs=''; + my $crstype=''; if ($env{'request.course.id'}) { $crs='/'.$env{'request.course.id'}; if ($env{'request.course.sec'}) { $crs.='_'.$env{'request.course.sec'}; } $crs=~s/\_/\//g; + $crstype = &Apache::loncommon::course_type(); } my $pub=($env{'request.state'} eq 'published'); my $con=($env{'request.state'} eq 'construct'); @@ -1335,10 +1340,17 @@ sub rawconfig { my ($row,$col,$pro,$prt,$img,$top,$bot,$act,$desc,$cat)=split(/\:/,$line); $prt=~s/\$uname/$uname/g; $prt=~s/\$udom/$udom/g; - $prt=~s/\$crs/$crs/g; + if ($prt =~ /\$crs/) { + next unless ($env{'request.course.id'}); + next if ($crstype eq 'Community'); + $prt=~s/\$crs/$crs/g; + } elsif ($prt =~ /\$cmty/) { + next unless ($env{'request.course.id'}); + next if ($crstype ne 'Community'); + $prt=~s/\$cmty/$crs/g; + } $prt=~s/\$requested_domain/$requested_domain/g; if ($category_names{$cat}!~/\w/) { $cat='oth'; } - my $type = &Apache::loncommon::course_type(); if ($pro eq 'clear') { $output.=&clear($row,$col); } elsif ($pro eq 'any') { @@ -1365,26 +1377,53 @@ sub rawconfig { $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat); } } elsif (($pro=~/^p(\w+)/) && ($prt)) { - if (&Apache::lonnet::allowed($1,$prt)) { + my $priv = $1; + if ($priv =~ /^mdc(Course|Community)/) { + if ($crstype eq $1) { + $priv = 'mdc'; + } else { + next; + } + } + if (&Apache::lonnet::allowed($priv,$prt)) { $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat); } - } elsif ($pro eq 'course') { - if ($env{'request.course.fn'}) { + } elsif ($pro eq 'course') { + if (($env{'request.course.fn'}) && ($crstype ne 'Community')) { $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat); } + } elsif ($pro eq 'community') { + if (($env{'request.course.fn'}) && ($crstype eq 'Community')) { + $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat); + } } elsif ($pro =~ /^courseenv_(.*)$/) { my $key = $1; - if ($env{'course.'.$env{'request.course.id'}.'.'.$key}) { + if (($env{'course.'.$env{'request.course.id'}.'.'.$key}) && + ($crstype ne 'Community')) { + $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat); + } + } elsif ($pro =~ /^communityenv_(.*)$/) { + my $key = $1; + if (($env{'course.'.$env{'request.course.id'}.'.'.$key}) && + ($crstype eq 'Community')) { $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat); } } elsif ($pro =~ /^course_(.*)$/) { # Check for permissions inside of a course - if (($env{'request.course.id'}) && + if (($env{'request.course.id'}) && ($crstype ne 'Community') && (&Apache::lonnet::allowed($1,$env{'request.course.id'}. ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')) )) { $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat); } + } elsif ($pro =~ /^community_(.*)$/) { + # Check for permissions inside of a community + if (($env{'request.course.id'}) && ($crstype eq 'Community') && + (&Apache::lonnet::allowed($1,$env{'request.course.id'}. + ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')) + )) { + $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat); + } } elsif ($pro eq 'author') { if ($author) { if ((($prt eq 'rca') && ($env{'request.role'}=~/^ca/)) ||