--- loncom/interface/lonmenu.pm 2010/01/18 21:35:55 1.244.2.12 +++ 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.12 2010/01/18 21:35:55 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 # @@ -163,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 { @@ -242,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) { @@ -312,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) { @@ -559,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); } @@ -1238,7 +1261,6 @@ 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'); @@ -1504,6 +1526,9 @@ sub utilityfunctions { my $end_page_bookmark = &Apache::loncommon::end_page({'js_ready' => 1}); + my $confirm_switch = &mt("Editing requires switching to the reource's home server.").'\n'. + &mt('Switch server?'); + return (<