--- loncom/interface/lonmenu.pm 2003/12/08 20:21:23 1.105 +++ loncom/interface/lonmenu.pm 2004/09/18 16:55:33 1.117 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.105 2003/12/08 20:21:23 www Exp $ +# $Id: lonmenu.pm,v 1.117 2004/09/18 16:55:33 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -39,10 +39,11 @@ package Apache::lonmenu; use strict; -use Apache::lonnet; +use Apache::lonnet(); use Apache::Constants qw(:common); use Apache::lonhtmlcommon(); -use Apache::loncommon; +use Apache::loncommon(); +use Apache::lonnavmaps(); use Apache::lonlocal; use vars qw(@desklines $readdesk); @@ -68,6 +69,10 @@ sub menubuttons { my $forcereg=shift; my $target =shift; my $registration=shift; + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, + ['inhibitmenu']); + if ($ENV{'form.inhibitmenu'} eq 'yes') { return ''; } + my $navmaps=''; my $reloadlink=''; my $escurl=&Apache::lonnet::escape($ENV{'request.noversionuri'}); @@ -91,9 +96,11 @@ ENDNAV ENDRELOAD } } + my $utility=&utilityfunctions(); my $output=(< // BEGIN LON-CAPA Internal +$utility $lt{'main'} $reloadlink $navmaps
@@ -128,11 +135,11 @@ ENDMAINMENU my $sidebg=&Apache::loncommon::designparm($function.'.sidebg',$domain); # Do we have a NAV link? if ($ENV{'request.course.id'}) { - $navmaps=(< -$lt{'nav'} -ENDNAVREM - if (($ENV{'request.noversionuri'}=~/^\/adm\//) && +$lt{'nav'} +ENDNAV + if (($ENV{'request.noversionuri'}=~/^\/adm\//) && ($ENV{'request.noversionuri'}!~/^\/adm\/wrapper\//) && ($ENV{'request.noversionuri'}!~/^\/adm\/.*\/(smppg|bulletinboard|aboutme)(\?|$)/)) { my $escreload=&Apache::lonnet::escape('return:'); @@ -146,9 +153,11 @@ ENDRELOAD if ($registration) { $reg=&innerregister($forcereg,$target); } + my $utility=&utilityfunctions(); return (< // BEGIN LON-CAPA Internal +$utility @@ -263,30 +272,29 @@ sub innerregister { # ============================ This is for URLs that actually can be registered if (($ENV{'request.noversionuri'}!~/^\/(res\/)*adm\//) || ($forcereg)) { # -- This applies to homework problems for users with grading privileges - my $hwkadd=''; - if - ($ENV{'request.filename'}=~/\.(problem|exam|quiz|assess|survey|form)$/) { - my $crs='/'.$ENV{'request.course.id'}; - if ($ENV{'request.course.sec'}) { - $crs.='_'.$ENV{'request.course.sec'}; - } - $crs=~s/\_/\//g; + my $crs='/'.$ENV{'request.course.id'}; + if ($ENV{'request.course.sec'}) { + $crs.='_'.$ENV{'request.course.sec'}; + } + $crs=~s/\_/\//g; + my $hwkadd=''; + if ($ENV{'request.filename'}=~/\.(problem|exam|quiz|assess|survey|form)$/) { if (&Apache::lonnet::allowed('vgr',$crs)) { - $hwkadd.=&switch('','',7,1,'subm.gif','view sub-','missions', + $hwkadd.=&switch('','',7,1,'subm.gif','view sub-[_1]','missions[_1]', "gocmd('/adm/grades','submission')", 'View user submissions for this assessment resource'); } if (&Apache::lonnet::allowed('mgr',$crs)) { - $hwkadd.=&switch('','',7,2,'pgrd.gif','problem','grades', + $hwkadd.=&switch('','',7,2,'pgrd.gif','problem[_1]','grades[_3]', "gocmd('/adm/grades','gradingmenu')", 'Modify user grades for this assessment resource'); } - if (&Apache::lonnet::allowed('opa',$crs)) { - $hwkadd.=&switch('','',7,3,'pparm.gif','problem','parms', - "gocmd('/adm/parmset','set')", - 'Modify deadlines, etc, for this assessment resource'); - } + } + if (&Apache::lonnet::allowed('opa',$crs)) { + $hwkadd.=&switch('','',7,3,'pparm.gif','problem[_2]','parms[_2]', + "gocmd('/adm/parmset','set')", + 'Modify deadlines, etc, for this resource'); } # -- End Homework ### @@ -311,9 +319,11 @@ sub innerregister { } # Check that we are on the correct machine my $home = &Apache::lonnet::homeserver($caname,$cadom); - if ($home eq $Apache::lonnet::perlvar{'lonHostID'}) { - $editbutton=&switch - ('','',6,1,$top,,$bottom,$action,$desc); + my $allowed=0; + my @ids=&Apache::lonnet::current_machine_ids(); + foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } } + if (!$allowed) { + $editbutton=&switch('','',6,1,$top,,$bottom,$action,$desc); } } ## @@ -325,11 +335,14 @@ sub innerregister { if ($ENV{'request.filename'}) { my $file=&Apache::lonnet::declutter($ENV{'request.filename'}); $file=~s/^(\w+)\/(\w+)/\/priv\/$2/; - # Chech that the user has permission to edit this resource + # Check that the user has permission to edit this resource ($cfuname,$cfudom)=&Apache::loncacc::constructaccess($file,$1); if (defined($cfudom)) { - if (&Apache::lonnet::homeserver($cfuname,$cfudom) - eq $Apache::lonnet::perlvar{'lonHostID'}) { + my $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; } } @@ -337,7 +350,7 @@ sub innerregister { # Finally, turn the button on or off if ($cfile) { $editbutton=&switch - ('','',6,1,'cstr.gif','edit','resource', + ('','',6,1,'cstr.gif','edit[_1]','resource[_2]', "go('".$cfile."');","Edit this resource"); } elsif ($editbutton eq '') { $editbutton=&clear(6,1); @@ -348,20 +361,20 @@ sub innerregister { # Prepare the rest of the buttons my $menuitems=(< // BEGIN LON-CAPA Internal -$utility $timesync $newmail @@ -411,6 +422,7 @@ ENDREGTEXT } else { my $requri=(split(/\?/,$ENV{'request.noversionuri'}))[0]; $requri=&Apache::lonnet::unescape($requri); + my $navstatus=&get_nav_status(); $result = (< @@ -428,6 +440,7 @@ var swmenu=null; swmenu.currentSymb="$ENV{'request.symb'}"; swmenu.reloadSymb="$ENV{'request.symb'}"; swmenu.currentStale=0; + $navstatus $hwkadd $editbutton } @@ -444,7 +457,7 @@ var swmenu=null; swmenu.clearbut(7,3); swmenu.menucltim=swmenu.setTimeout( 'clearbut(2,1);clearbut(2,3);clearbut(8,1);clearbut(8,2);clearbut(8,3);'+ - 'clearbut(9,1);clearbut(9,2);clearbut(9,3);clearbut(6,3);clearbut(6,1)', + 'clearbut(9,1);clearbut(9,3);clearbut(6,3);clearbut(6,1)', 2000); } @@ -600,7 +613,9 @@ sub reopenmenu { sub open { my $returnval=''; if (($ENV{'browser.interface'} eq 'textual') || - ($ENV{'environment.remote'} eq 'off')) { return ''; } + ($ENV{'environment.remote'} eq 'off')) { + return ''; + } my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'}; unless (shift eq 'unix') { # resizing does not work on linux because of virtual desktop sizes @@ -811,7 +826,10 @@ sub rawconfig { } $act =~ s/\$caname/$caname/g; my $home = &Apache::lonnet::homeserver($caname,$cadom); - if ($home eq $Apache::lonnet::perlvar{'lonHostID'}) { + my $allowed=0; + my @ids=&Apache::lonnet::current_machine_ids(); + foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } } + if ($allowed) { $output.=switch($caname,$cadom, $row,$col,$img,$top,$bot,$act,$desc); } @@ -858,12 +876,15 @@ sub utilityfunctions { ($ENV{'environment.remote'} eq 'off')) { return ''; } my $currenturl=$ENV{'request.noversionuri'}; my $currentsymb=$ENV{'request.symb'}; + my $nav_control=&Apache::lonnavmaps::nav_control_js(); return (< ENDSERVERFORM } + +sub get_nav_status { + my $navstatus="swmenu.w_loncapanav_flag="; + if ($ENV{'environment.remotenavmap'} eq 'on') { + $navstatus.="1"; + } else { + $navstatus.="-1"; + } + return $navstatus; +} + # ================================================ Handler when called directly @@ -946,13 +978,9 @@ sub handler { $ENV{'browser.interface'}='faketextual'; $ENV{'environment.remote'}='off'; } - my $utility=&utilityfunctions(); $r->print(< LON-CAPA Main Menu - $bodytag ENDHEADER