--- loncom/interface/lonmenu.pm 2003/04/03 15:23:41 1.52
+++ loncom/interface/lonmenu.pm 2004/12/07 23:59:52 1.140
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines to control the menu
#
-# $Id: lonmenu.pm,v 1.52 2003/04/03 15:23:41 www Exp $
+# $Id: lonmenu.pm,v 1.140 2004/12/07 23:59:52 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -39,46 +39,159 @@
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);
+
+my @inlineremote;
+my $font;
+my $tabbg;
+my $pgbg;
+
+# ================================================================ Little texts
+
+sub initlittle {
+ return &Apache::lonlocal::texthash('ret' => 'Return to Last Location',
+ 'nav' => 'Navigate Contents',
+ 'main' => 'Main Menu',
+ 'launch' => 'Launch Remote Control');
+}
+
# ============================= This gets called at the top of the body section
sub menubuttons {
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(&Apache::lonenc::check_encrypt($ENV{'request.noversionuri'}));
+ my $escsymb=&Apache::lonnet::escape(&Apache::lonenc::check_encrypt($ENV{'request.symb'}));
+ if ($ENV{'request.state'} eq 'construct') {
+ if (($ENV{'request.noversionuri'} eq '') || (!defined($ENV{'request.noversionuri'}))) {
+ my $returnurl = $ENV{'request.filename'};
+ $returnurl =~ s:^/home/([^/]+)/public_html/(.*)$:/priv/$1/$2:;
+ $escurl = &Apache::lonnet::escape($returnurl);
+ }
+ }
if ($ENV{'browser.interface'} eq 'textual') {
# Textual display only
+ my %lt=&initlittle();
+ $pgbg='#FFFFFF';
+ $tabbg='#FFFFFF';
+ $font='#000000';
+ if ($ENV{'request.course.id'}) {
+ $navmaps=(<
-
+$form
ENDMAINMENU
if ($registration) { $output.=&innerregister($forcereg,$target); }
return $output."
";
} elsif ($ENV{'environment.remote'} eq 'off') {
# Remote Control is switched off
- my $output=(<
";
} else {
return '';
}
@@ -90,7 +203,11 @@ sub registerurl {
my $forcereg=shift;
my $target = shift;
my $result = '';
-
+ 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();
+ }
if ($target eq 'edit') {
$result .="\n";
}
if (($ENV{'browser.interface'} eq 'textual') ||
+ ($ENV{'environment.remote'} eq 'off') ||
((($ENV{'request.publicaccess'}) ||
- (!&Apache::lonnet::is_on_map($ENV{'REQUEST_URI'}))) &&
+ (!&Apache::lonnet::is_on_map(
+ &Apache::lonnet::unescape($ENV{'request.noversionuri'})))) &&
(!$forcereg))) {
- return $result.
- '';
+ return $result.
+ ''.$force_title;
}
# Graphical display after login only
if ($Apache::lonxml::registered && !$forcereg) { return ''; }
- $result.=&innerregister($forcereg,$target);
- return $result;
+ if ($target ne 'edit') {
+ $result.=&innerregister($forcereg,$target);
+ }
+ return $result.$force_title;
}
# =========== This gets called in order to register a URL, both with the Remote
@@ -116,7 +237,13 @@ sub registerurl {
sub innerregister {
my $forcereg=shift;
my $target = shift;
+ my $titletable = shift;
my $result = '';
+ 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;
@@ -125,37 +252,69 @@ sub innerregister {
my $textual=($textinter || $noremote);
+ @inlineremote=();
+ undef @inlineremote;
+
my $reopen=&Apache::lonmenu::reopenmenu();
my $newmail='';
+ if ($noremote) {
+ $newmail='
';
+ }
my $timesync=($textual?'':'swmenu.syncclock(1000*'.time.');');
+ my $tablestart=($noremote?'';
+ }
+ if (($textual) && ($ENV{'request.symb'}) && ($ENV{'request.course.id'})) {
+ my ($mapurl,$rid,$resurl)=&Apache::lonnet::decode_symb($ENV{'request.symb'});
+ $newmail.=$ENV{'course.'.$ENV{'request.course.id'}.'.description'};
+ my $maptitle=&Apache::lonnet::gettitle($mapurl);
+ my $restitle=&Apache::lonnet::gettitle($resurl);
+ if ($maptitle && $maptitle ne 'default.sequence') {
+ $newmail.=', '.$maptitle;
+ }
+ if ($restitle) {
+ $newmail.=': '.$restitle;
+ }
+ $newmail.=' ';
+ }
if (&Apache::lonmsg::newmail()) {
$newmail=($textual?
- 'You have new messages
':
+ 'You have new messages
':
'swmenu.setstatus("you have","messages");');
}
+ if ($ENV{'request.state'} eq 'construct') {
+ $newmail = $titletable;
+ }
+ if ($noremote) {
+ $newmail.='':'').($textinter?'
':'').($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 $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',$ENV{'request.course.id'})) {
- $hwkadd.=&switch('','',7,1,'subm.gif','view sub','missions',
+ if ($ENV{'request.filename'}=~/\.(problem|exam|quiz|assess|survey|form)$/) {
+ if (&Apache::lonnet::allowed('vgr',$crs)) {
+ $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',$ENV{'request.course.id'})) {
- $hwkadd.=&switch('','',7,2,'pgrd.gif','problem','grades',
+ if (&Apache::lonnet::allowed('mgr',$crs)) {
+ $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',$ENV{'request.course.id'})) {
- $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
###
@@ -180,9 +339,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);
}
}
##
@@ -194,19 +355,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);
@@ -215,18 +379,43 @@ sub innerregister {
###
###
# Prepare the rest of the buttons
- my $menuitems=(<
'.&mt('Skip to Content').'
':'');
+ my $tableend=($noremote?'$inlineremote[21] $inlineremote[23]
+
+$inlineremote[61] $inlineremote[62] $inlineremote[63]
+$inlineremote[71] $inlineremote[72] $inlineremote[73]
+$inlineremote[81] $inlineremote[82] $inlineremote[83]
+ENDINLINE
+ }
+ if ($const_space && $is_const_dir) {
+ $inlinebuttons = '';
+ }
$result =(<$inlineremote[91] $inlineremote[92] $inlineremote[93]
$link
+ENDREMOTEFORM +} # ================================================================= Reopen menu sub reopenmenu { @@ -446,7 +686,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 @@ -461,8 +703,9 @@ ENDRESIZE window.status='Opening LON-CAPA Remote Control'; var menu=window.open("/res/adm/pages/menu.html","$menuname", "height=350,width=150,scrollbars=no,menubar=no,top=5,left=5,screenX=5,screenY=5"); +self.name='loncapaclient'; ENDOPEN - return ''; + return ''; } @@ -473,7 +716,10 @@ sub clear { unless (($ENV{'browser.interface'} eq 'textual') || ($ENV{'environment.remote'} eq 'off')) { return "\n".qq(window.status+='.';swmenu.clearbut($row,$col);); - } else { return ''; } + } else { + $inlineremote[10*$row+$col]=''; + return ''; + } } # ============================================ Switch a button or create a link @@ -484,6 +730,10 @@ sub switch { my ($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$nobreak)=@_; $act=~s/\$uname/$uname/g; $act=~s/\$udom/$udom/g; + $top=&mt($top); + $bot=&mt($bot); + $desc=&mt($desc); + $img=&mt($img); unless (($ENV{'browser.interface'} eq 'textual') || ($ENV{'environment.remote'} eq 'off')) { # Remote @@ -493,19 +743,54 @@ sub switch { # Accessibility if ($nobreak==2) { return ''; } my $text=$top.' '.$bot; - $text=~s/\- //; - return "\n".($nobreak?' ':'