--- loncom/interface/lonmenu.pm 2003/09/17 23:40:25 1.91 +++ loncom/interface/lonmenu.pm 2004/11/30 22:44:29 1.132 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.91 2003/09/17 23:40:25 www Exp $ +# $Id: lonmenu.pm,v 1.132 2004/11/30 22:44:29 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -39,11 +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::File; +use Apache::loncommon(); +use Apache::lonenc(); use Apache::lonlocal; use vars qw(@desklines $readdesk); @@ -66,39 +66,50 @@ sub initlittle { # ============================= This gets called at the top of the body section sub menubuttons { - &Apache::lonlocal::reroutetrans(); my $forcereg=shift; my $target =shift; my $registration=shift; + my $titletable=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_URI'}); - my $escsymb=&Apache::lonnet::escape($ENV{'request.symb'}); + my $escurl=&Apache::lonnet::escape(&Apache::lonenc::check_encrypt($ENV{'request.noversionuri'})); + my $escsymb=&Apache::lonnet::escape(&Apache::lonenc::check_encrypt($ENV{'request.symb'})); if ($ENV{'browser.interface'} eq 'textual') { # Textual display only my %lt=&initlittle(); + $pgbg='#FFFFFF'; + $tabbg='#FFFFFF'; + $font='#000000'; if ($ENV{'request.course.id'}) { $navmaps=(<$lt{'nav'} ENDNAV - if (($ENV{'REQUEST_URI'}=~/^\/adm\//) && - ($ENV{'REQUEST_URI'}!~/^\/adm\/wrapper\//) && - ($ENV{'REQUEST_URI'}!~/^\/adm\/.*\/(smppg|bulletinboard|aboutme)(\?|$)/)) { + if (($ENV{'request.noversionuri'}=~/^\/adm\//) && + ($ENV{'request.noversionuri'}!~/^\/adm\/wrapper\//) && + ($ENV{'request.noversionuri'}!~/^\/adm\/.*\/(smppg|bulletinboard|aboutme)(\?|$)/)) { my $escreload=&Apache::lonnet::escape('return:'); $reloadlink=(<$lt{'ret'} ENDRELOAD } } + my $form=&serverform(); + my $utility=&utilityfunctions(); my $output=(< + $lt{'main'} $reloadlink $navmaps
- +$form ENDMAINMENU if ($registration) { $output.=&innerregister($forcereg,$target); } return $output."
"; @@ -114,7 +125,7 @@ ENDMAINMENU $function='admin'; } if (($ENV{'request.role'}=~/^(au|ca)/) || - ($ENV{'REQUEST_URI'}=~/^(\/priv|\~)/)) { + ($ENV{'request.noversionuri'}=~/^(\/priv|\~)/)) { $function='author'; } my $domain=&Apache::loncommon::determinedomain(); @@ -127,13 +138,13 @@ 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_URI'}=~/^\/adm\//) && - ($ENV{'REQUEST_URI'}!~/^\/adm\/wrapper\//) && - ($ENV{'REQUEST_URI'}!~/^\/adm\/.*\/(smppg|bulletinboard|aboutme)(\?|$)/)) { +$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:'); $reloadlink=(< @@ -143,13 +154,16 @@ ENDRELOAD } my $reg=''; if ($registration) { - $reg=&innerregister($forcereg,$target); + $reg=&innerregister($forcereg,$target,$titletable); } + my $form=&serverform(); + my $utility=&utilityfunctions(); return (< + - +
+$form
$lt{'main'} @@ -157,14 +171,16 @@ ENDRELOAD $reloadlink $navmaps - + $lt{'launch'} LON-CAPA
- $reg @@ -177,11 +193,10 @@ ENDINLINEMENU # ====================================== This gets called in the header section sub registerurl { - &Apache::lonlocal::reroutetrans(); my $forcereg=shift; my $target = shift; my $result = ''; - if ($ENV{'REQUEST_URI'} eq '/res/adm/pages/menu.html') { return ''; } + if ($ENV{'request.noversionuri'} eq '/res/adm/pages/menu.html') { return ''; } my $force_title=''; if ($ENV{'request.state'} eq 'construct') { $force_title=&Apache::lonxml::display_title(); @@ -196,14 +211,16 @@ sub registerurl { ($ENV{'environment.remote'} eq 'off') || ((($ENV{'request.publicaccess'}) || (!&Apache::lonnet::is_on_map( - &Apache::lonnet::unescape($ENV{'REQUEST_URI'})))) && + &Apache::lonnet::unescape($ENV{'request.noversionuri'})))) && (!$forcereg))) { return $result. ''.$force_title; } # Graphical display after login only if ($Apache::lonxml::registered && !$forcereg) { return ''; } - $result.=&innerregister($forcereg,$target); + if ($target ne 'edit') { + $result.=&innerregister($forcereg,$target); + } return $result.$force_title; } @@ -211,11 +228,15 @@ sub registerurl { # =========== and in the body of the document sub innerregister { - &Apache::lonlocal::reroutetrans(); my $forcereg=shift; my $target = shift; + my $titletable = shift; my $result = ''; - if ($ENV{'REQUEST_URI'} eq '/res/adm/pages/menu.html') { return ''; } + my ($uname,$thisdisfn); + my $const_space = ($ENV{'request.state'} eq 'construct'); + my $is_const_dir = 0; + + if ($ENV{'request.noversionuri'} eq '/res/adm/pages/menu.html') { return ''; } $Apache::lonxml::registered=1; @@ -231,7 +252,7 @@ sub innerregister { my $newmail=''; if ($noremote) { - $newmail='
'; + $newmail='
'; } if (($textual) && ($ENV{'request.symb'}) && ($ENV{'request.course.id'})) { my ($mapurl,$rid,$resurl)=&Apache::lonnet::decode_symb($ENV{'request.symb'}); @@ -251,40 +272,42 @@ sub innerregister { 'You have new messages
': 'swmenu.setstatus("you have","messages");'); } + if ($ENV{'request.state'} eq 'construct') { + $newmail = $titletable; + } if ($noremote) { - $newmail.='
'; + $newmail.='
'; } my $timesync=($textual?'':'swmenu.syncclock(1000*'.time.');'); - my $tablestart=($noremote?'':''); - my $tableend=($noremote?'
':''); + my $tablestart=($noremote?'':'').($textinter?'
'.&mt('Skip to Content').'
':''); + my $tableend=($noremote?'
':'').($textinter?'':''); # ============================================================================= # ============================ This is for URLs that actually can be registered - if (($ENV{'REQUEST_URI'}!~/^\/(res\/)*adm\//) || ($forcereg)) { + 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 ### @@ -309,9 +332,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); } } ## @@ -323,19 +348,22 @@ 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; } } } # Finally, turn the button on or off - if ($cfile) { + if ($cfile && !$const_space) { $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); @@ -344,24 +372,43 @@ sub innerregister { ### ### # Prepare the rest of the buttons - my $menuitems=(<$inlineremote[21] $inlineremote[23] +$inlineremote[61]$inlineremote[62]$inlineremote[63] +$inlineremote[71]$inlineremote[72]$inlineremote[73] +$inlineremote[81]$inlineremote[82]$inlineremote[83] +$inlineremote[91]$inlineremote[92]$inlineremote[93] +ENDINLINE + } + if ($const_space && $is_const_dir) { + $inlinebuttons = ''; + } $result =(< + $timesync $newmail $tablestart $inlinebuttons $tableend -$form - ENDREGTEXT # Registered, graphical output } else { - my $requri=(split(/\?/,$ENV{'REQUEST_URI'}))[0]; - $requri=&Apache::lonnet::unescape($requri); + my $requri=(split(/\?/,$ENV{'request.noversionuri'}))[0]; + $requri=&Apache::lonenc::check_encrypt(&Apache::lonnet::unescape($requri)); + my $cursymb=&Apache::lonenc::check_encrypt($ENV{'request.symb'}); + my $navstatus=&get_nav_status(); $result = (< + @@ -566,11 +636,30 @@ sub maincall() { if (($ENV{'browser.interface'} eq 'textual') || ($ENV{'environment.remote'} eq 'off')) { return ''; } return(< + ENDMAINCALL } + +sub load_remote_msg { + my ($lowerurl)=@_; + + if (($ENV{'browser.interface'} eq 'textual') || + ($ENV{'environment.remote'} eq 'off')) { return ''; } + + my $esclowerurl=&Apache::lonnet::escape($lowerurl); + my $link=&mt('Continue on in Inline Menu mode', + "/adm/remote?action=collapse?url=$esclowerurl"); + return(< +
+ +
+

+

$link

+ENDREMOTEFORM +} # ================================================================= Reopen menu sub reopenmenu { @@ -586,7 +675,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 @@ -603,7 +694,7 @@ var menu=window.open("/res/adm/pages/men "height=350,width=150,scrollbars=no,menubar=no,top=5,left=5,screenX=5,screenY=5"); self.name='loncapaclient'; ENDOPEN - return ''; + return ''; } @@ -631,6 +722,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 @@ -641,21 +733,51 @@ sub switch { if ($nobreak==2) { return ''; } my $text=$top.' '.$bot; $text=~s/\s*\-\s*//gs; - $inlineremote[10*$row+$col]="\n".($nobreak?' ':'
'). - ''.$text.' '. - ($nobreak?'':$desc); + if ($nobreak) { + $inlineremote[10*$row+$col]= + ''.$text.''; + } else { + $inlineremote[10*$row+$col]="\n
". + $desc.' '.$text.''; + } } else { # Inline Remote if ($nobreak==2) { return ''; } my $text=$top.' '.$bot; $text=~s/\s*\-\s*//gs; - $inlineremote[10*$row+$col]="\n". - ($nobreak==3?''.$text.''. - ($nobreak?'':''.$desc.'').($nobreak!=1?'':''); + + 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 + if ($nobreak==3) { + $inlineremote[10*$row+$col]="\n". + ''.$text. + ''. + ''.$pic.''; + } elsif ($nobreak) { + $inlineremote[10*$row+$col]="\n". + ''. + ''.$pic. + ''.$text.''; + } else { + $inlineremote[10*$row+$col]="\n". + ''. + ''.$pic. + ''.$desc. + ''; + } + } else { +# Inline Menu + $inlineremote[10*$row+$col]= + ''.$pic. + ''.$desc. + ''; + } } return ''; } @@ -745,6 +867,11 @@ sub rawconfig { if ($ENV{'request.course.fn'}) { $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc); } + } 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); + } } elsif ($pro =~ /^course_(.*)$/) { # Check for permissions inside of a course if (($ENV{'request.course.id'}) && @@ -766,7 +893,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); } @@ -777,7 +907,11 @@ sub rawconfig { unless (($ENV{'browser.interface'} eq 'textual') || ($ENV{'environment.remote'} eq 'off')) { $output.="\nwindow.status='Synchronizing Time';swmenu.syncclock(1000*".time.");\nwindow.status='Remote Control Configured.';"; + if (&Apache::lonmsg::newmail()) { + $output.='swmenu.setstatus("you have","messages");'; + } } + return $output; } @@ -788,7 +922,7 @@ sub close { ($ENV{'environment.remote'} eq 'off')) { return ''; } my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'}; return(< + +ENDSCRIPT + } +# ---- Print the screen, pretend to be in text mode to generate text-based menu + unless ($ENV{'browser.interface'} eq 'textual') { + $ENV{'browser.interface'}='faketextual'; $ENV{'environment.remote'}='off'; } - my $utility=&utilityfunctions(); $r->print(< LON-CAPA Main Menu - +$script_tag $bodytag ENDHEADER $r->print(''.&inlinemenu().'
'.$form); - $r->print(&Apache::lonlocal::endreroutetrans()); $r->print(''); return OK; } @@ -923,15 +1134,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';