--- loncom/interface/lonmenu.pm 2003/11/21 21:38:50 1.103 +++ loncom/interface/lonmenu.pm 2004/08/13 20:12:11 1.113 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.103 2003/11/21 21:38:50 www Exp $ +# $Id: lonmenu.pm,v 1.113 2004/08/13 20:12:11 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -43,7 +43,6 @@ use Apache::lonnet; use Apache::Constants qw(:common); use Apache::lonhtmlcommon(); use Apache::loncommon; -use Apache::File; use Apache::lonlocal; use vars qw(@desklines $readdesk); @@ -69,6 +68,11 @@ 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'}); @@ -264,30 +268,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 ### @@ -312,9 +315,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); } } ## @@ -326,11 +331,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; } } @@ -338,7 +346,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); @@ -349,20 +357,20 @@ sub innerregister { # Prepare the rest of the buttons my $menuitems=(< @@ -429,6 +438,7 @@ var swmenu=null; swmenu.currentSymb="$ENV{'request.symb'}"; swmenu.reloadSymb="$ENV{'request.symb'}"; swmenu.currentStale=0; + $navstatus $hwkadd $editbutton } @@ -445,7 +455,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); } @@ -601,7 +611,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 @@ -646,6 +658,7 @@ sub switch { $top=&mt($top); $bot=&mt($bot); $desc=&mt($desc); + $img=&mt($img); unless (($ENV{'browser.interface'} eq 'textual') || ($ENV{'environment.remote'} eq 'off')) { # Remote @@ -668,8 +681,12 @@ sub switch { if ($nobreak==2) { return ''; } my $text=$top.' '.$bot; $text=~s/\s*\-\s*//gs; + + my $lonhttpdPort=$Apache::lonnet::perlvar{'lonhttpdPort'}; + if (!defined($lonhttpdPort)) { $lonhttpdPort='8080'; } my $pic= - ''.$text.''; if (($ENV{'browser.interface'} eq 'textual') || ($ENV{'browser.interface'} eq 'faketextual')) { # Accessibility @@ -807,7 +824,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); } @@ -911,6 +931,17 @@ sub serverform { 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 @@ -962,15 +993,17 @@ ENDHEADER BEGIN { if (! defined($readdesk)) { { - my $config=Apache::File->new($Apache::lonnet::perlvar{'lonTabDir'}. - '/mydesk.tab'); - while (my $configline=<$config>) { - $configline=(split(/\#/,$configline))[0]; - $configline=~s/^\s+//; - chomp($configline); - if ($configline) { - $desklines[$#desklines+1]=$configline; - } + my $tabfile = $Apache::lonnet::perlvar{'lonTabDir'}.'/mydesk.tab'; + if ( CORE::open( my $config,"<$tabfile") ) { + while (my $configline=<$config>) { + $configline=(split(/\#/,$configline))[0]; + $configline=~s/^\s+//; + chomp($configline); + if ($configline) { + $desklines[$#desklines+1]=$configline; + } + } + CORE::close($config); } } $readdesk='done';