--- loncom/interface/lonmenu.pm 2010/01/18 21:05:08 1.244.2.11 +++ loncom/interface/lonmenu.pm 2010/01/18 21:35:55 1.244.2.12 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.244.2.11 2010/01/18 21:05:08 raeburn Exp $ +# $Id: lonmenu.pm,v 1.244.2.12 2010/01/18 21:35:55 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -120,11 +120,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() @@ -1226,12 +1221,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'); @@ -1241,13 +1238,18 @@ 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; + $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 ($type eq 'Group') { - $desc = &convert_menu_function($desc,$type); - } if ($pro eq 'clear') { $output.=&clear($row,$col); } elsif ($pro eq 'any') { @@ -1274,26 +1276,69 @@ 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}) { - $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat); + if ($crstype ne 'Community') { + my $coursepref = $env{'course.'.$env{'request.course.id'}.'.'.$key}; + if ($key eq 'canuse_pdfforms') { + if ($env{'request.course.id'} && $coursepref eq '') { + my %domdefs = &Apache::lonnet::get_domain_defaults($env{'course.'.$env{'request.course.id'}.'.domain'}); + $coursepref = $domdefs{'canuse_pdfforms'}; + } + } + if ($coursepref) { + $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat); + } + } + } elsif ($pro =~ /^communityenv_(.*)$/) { + my $key = $1; + if ($crstype eq 'Community') { + my $coursepref = $env{'course.'.$env{'request.course.id'}.'.'.$key}; + if ($key eq 'canuse_pdfforms') { + if ($env{'request.course.id'} && $coursepref eq '') { + my %domdefs = &Apache::lonnet::get_domain_defaults($env{'course.'.$env{'request.course.id'}.'.domain'}); + $coursepref = $domdefs{'canuse_pdfforms'}; + } + } + if ($coursepref) { + $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/)) || @@ -1645,19 +1690,6 @@ sub get_nav_status { return $navstatus; } -#FIXME this needs to move into mydesktab and the other locations -# the text is generated -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 '') {