--- loncom/interface/lonmenu.pm 2010/01/18 20:47:57 1.244.2.9 +++ loncom/interface/lonmenu.pm 2010/08/20 17:59:04 1.244.2.18 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.244.2.9 2010/01/18 20:47:57 raeburn Exp $ +# $Id: lonmenu.pm,v 1.244.2.18 2010/08/20 17:59:04 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() @@ -168,19 +163,23 @@ sub show_course { } sub initlittle { - return &Apache::lonlocal::texthash('ret' => 'Return to Last Location', - 'nav' => 'Navigate Contents', + my %lt=&Apache::lonlocal::texthash('ret' => 'Return to Last Location', + 'nav' => 'Course Contents', 'main' => 'Main Menu', 'roles' => (&Apache::loncommon::show_course()? 'Courses':'Roles'), 'other' => 'Other Roles', - 'docs' => 'Edit Course', + 'docs' => 'Course Editor', 'exit' => 'Logout', 'login' => 'Log In', 'launch' => 'Launch Remote Control', 'groups' => 'Groups', - 'gdoc' => 'Community Documents', ); + if (&Apache::loncommon::course_type() eq 'Community') { + $lt{'nav'} = &mt('Community Contents'); + $lt{'docs'} = &mt('Community Editor'); + } + return %lt; } sub menubuttons { @@ -247,12 +246,9 @@ ENDNAV $lt{'ret'} ENDRELOAD } - my $is_community = - (&Apache::loncommon::course_type() eq 'Community'); if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) { - my $text = ($is_community) ? $lt{'gdoc'} : $lt{'docs'}; $docs=(<$text +$lt{'docs'} ENDDOCS } if ($showgroups) { @@ -317,12 +313,9 @@ ENDINLINEMENU $navmaps=(<$lt{'nav'} ENDNAV - my $is_community = - (&Apache::loncommon::course_type() eq 'Community'); if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) { - my $text = ($is_community) ? $lt{'gdoc'} : $lt{'docs'}; $docs=(<$text +$lt{'docs'} ENDDOCS } if ($showgroups) { @@ -564,27 +557,52 @@ sub innerregister { my $cfuname=''; my $cfudom=''; my $uploaded; + my $switchserver=''; + my $home; if ($env{'request.filename'}) { my $file=&Apache::lonnet::declutter($env{'request.filename'}); $file=~s/^($match_domain)\/($match_username)/\/priv\/$2/; # Check that the user has permission to edit this resource ($cfuname,$cfudom)=&Apache::loncacc::constructaccess($file,$1); if (defined($cfudom)) { - my $home=&Apache::lonnet::homeserver($cfuname,$cfudom); + $home=&Apache::lonnet::homeserver($cfuname,$cfudom); my $allowed=0; my @ids=&Apache::lonnet::current_machine_ids(); foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } } if ($allowed) { $cfile=$file; + } else { + $switchserver=$file; } } } # Finally, turn the button on or off - if ($cfile && !$const_space) { - $editbutton=&switch - ('','',6,1,'pcstr.gif','edit[_1]','resource[_2]', - "go('".$cfile."');","Edit this resource"); - $noeditbutton = 0; + if (($cfile || $switchserver) && !$const_space) { + my $nocrsedit; + # Suppress display where CC has switched to student role. + if ($env{'request.course.id'}) { + unless(&Apache::lonnet::allowed('mdc', + $env{'request.course.id'})) { + $nocrsedit = 1; + } + } + if ($nocrsedit) { + $editbutton=&clear(6,1); + } else { + my $bot = "go('$cfile')"; + if ($switchserver) { + if ( $env{'request.symb'} && $env{'request.course.id'} ) { + $cfile = '/adm/switchserver?otherserver='.$home.'&role='. + &HTML::Entities::encode($env{'request.role'},'"<>&').'&symb='. + &HTML::Entities::encode($env{'request.symb'},'"<>&'); + } + $bot = "need_switchserver('$cfile');"; + } + $editbutton=&switch + ('','',6,1,'pcstr.png','edit[_1]','resource[_2]', + $bot,"Edit this resource"); + $noeditbutton = 0; + } } elsif ($editbutton eq '') { $editbutton=&clear(6,1); } @@ -660,7 +678,7 @@ $menuitems.="Make notes and annotations } } unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme)(\?|$)/) { - if (!$env{'request.enc'}) { + if ((!$env{'request.enc'}) && ($env{'request.noversionuri'} !~ m{^/adm/wrapper/ext/})) { $menuitems.=(< 1}); + my $confirm_switch = &mt("Editing requires switching to the reource's home server.").'\n'. + &mt('Switch server?'); + return (<