--- loncom/interface/lonmenu.pm 2012/05/29 19:41:27 1.369.2.13
+++ loncom/interface/lonmenu.pm 2012/08/07 01:35:47 1.369.2.20
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines to control the menu
#
-# $Id: lonmenu.pm,v 1.369.2.13 2012/05/29 19:41:27 raeburn Exp $
+# $Id: lonmenu.pm,v 1.369.2.20 2012/08/07 01:35:47 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -131,6 +131,26 @@ Inputs: 4 - (a) link and (b) target for
This gets called in order to register a URL in the body of the document
+=item loadevents()
+
+=item unloadevents()
+
+=item startupremote()
+
+=item setflags()
+
+=item maincall()
+
+=item load_remote_msg()
+
+=item get_menu_name()
+
+=item reopenmenu()
+
+=item open()
+
+Open the menu
+
=item clear()
=item switch()
@@ -247,9 +267,7 @@ sub primary_menu {
my @primsub;
if (ref($primary_submenu{$title}) eq 'ARRAY') {
foreach my $item (@{$primary_submenu{$title}}) {
- next if (($item->[2] eq 'wishlist') &&
- ((!&Apache::lonnet::allowed('bre',"/res/$env{'user.domain'}/")) &&
- (!&Apache::lonnet::allowed('bro',"/res/$env{'user.domain'}/"))));
+ next if (($item->[2] eq 'wishlist') && (!$env{'user.adv'}));
next if (($item->[2] eq 'reqcrs') && (!&check_for_rcrs()));
next if ((($item->[2] eq 'portfolio') ||
($item->[2] eq 'blog')) &&
@@ -460,6 +478,34 @@ sub create_submenu {
return $menu;
}
+sub registerurl {
+ my ($forcereg) = @_;
+ my $result = '';
+ if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
+ my $force_title='';
+ if ($env{'request.state'} eq 'construct') {
+ $force_title=&Apache::lonxml::display_title();
+ }
+ if (($env{'environment.remote'} eq 'off') ||
+ ((($env{'request.publicaccess'}) ||
+ (!&Apache::lonnet::is_on_map(
+ &unescape($env{'request.noversionuri'})))) &&
+ (!$forcereg))) {
+ return
+ $result
+ .''
+ .$force_title;
+ }
+# Graphical display after login only
+ if ($env{'request.registered'} && !$forcereg) { return ''; }
+ $result.=&innerregister($forcereg);
+ return $result.$force_title;
+}
+
sub innerregister {
my ($forcereg,$bread_crumbs) = @_;
my $const_space = ($env{'request.state'} eq 'construct');
@@ -469,8 +515,19 @@ sub innerregister {
$env{'request.registered'} = 1;
+ my $noremote = ($env{'environment.remote'} eq 'off');
+
undef(@inlineremote);
+ my $reopen=&Apache::lonmenu::reopenmenu();
+
+ my $newmail='';
+
+ if (&Apache::lonmsg::newmail() && !$noremote) {
+ # We have new mail and remote is up
+ $newmail= 'swmenu.setstatus("you have","messages");';
+ }
+
my $resurl;
if ( $env{'request.symb'} && $env{'request.course.id'} ) {
@@ -509,11 +566,11 @@ sub innerregister {
&Apache::lonhtmlcommon::clear_breadcrumbs();
&Apache::lonhtmlcommon::add_breadcrumb({text => 'View Resource'});
}
+ my $timesync = ( $noremote ? '' : 'swmenu.syncclock(1000*'.time.');' );
# =============================================================================
# ============================ This is for URLs that actually can be registered
- return '' unless ( ($env{'request.noversionuri'}!~m{^/(res/)*adm/})
- || $forcereg );
-
+ if ( ($env{'request.noversionuri'}!~m{^/(res/)*adm/})
+ || ($forcereg)) {
# -- This applies to homework problems for users with grading privileges
my $crs='/'.$env{'request.course.id'};
if ($env{'request.course.sec'}) {
@@ -521,30 +578,38 @@ sub innerregister {
}
$crs=~s/\_/\//g;
+ my %swtext;
+ if ($noremote) {
+ %swtext = &get_inline_text();
+ } else {
+ %swtext = &get_rc_text();
+ }
my $hwkadd='';
if ($env{'request.symb'} ne '' &&
$env{'request.filename'}=~/$LONCAPA::assess_re/) {
if (&Apache::lonnet::allowed('mgr',$crs)) {
- $hwkadd.=&switch('','',7,2,'pgrd.png','Content Grades','grades[_4]',
+ $hwkadd.=&switch('','',7,2,'pgrd.png',$swtext{'pgrd'},'grades[_4]',
"gocmd('/adm/grades','gradingmenu')",
'Content Grades');
} elsif (&Apache::lonnet::allowed('vgr',$crs)) {
- $hwkadd.=&switch('','',7,2,'subm.png','Content Submissions','missions[_1]',
+ $hwkadd.=&switch('','',7,2,'subm.png',$swtext{'subm'},'missions[_1]',
"gocmd('/adm/grades','submission')",
'Content Submissions');
}
}
if ($env{'request.symb'} ne '' &&
&Apache::lonnet::allowed('opa',$crs)) {
- $hwkadd.=&switch('','',7,3,'pparm.png','Content Settings','parms[_2]',
+ $hwkadd.=&switch('','',7,3,'pparm.png',$swtext{'pparm'},'parms[_2]',
"gocmd('/adm/parmset','set')",
'Content Settings');
}
- if ($env{'request.symb'}=~/^uploaded/ &&
- &Apache::lonnet::allowed('mdc',$crs)) {
- $hwkadd.=&switch('','',7,4,'docs.png','Folder/Page Content','parms[_2]',
- "gocmd('/adm/coursedocs','direct')",
- 'Folder/Page Content');
+ if ($noremote) {
+ if ($env{'request.symb'}=~/^uploaded/ &&
+ &Apache::lonnet::allowed('mdc',$crs)) {
+ $hwkadd.=&switch('','',7,4,'docs.png',$swtext{'docs'},'parms[_2]',
+ "gocmd('/adm/coursedocs','direct')",
+ 'Folder/Page Content');
+ }
}
# -- End Homework
###
@@ -587,7 +652,7 @@ sub innerregister {
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);
+ $editbutton=&switch('','',6,1,,$top,$bottom,$action,$desc);
$noeditbutton = 0;
}
}
@@ -654,7 +719,7 @@ sub innerregister {
}
}
$editbutton=&switch
- ('','',6,1,'pcstr.png','Edit','resource[_2]',
+ ('','',6,1,'pcstr.png',$swtext{'pcstr'},'resource[_2]',
$bot,"Edit this resource");
$noeditbutton = 0;
}
@@ -670,7 +735,7 @@ sub innerregister {
my $cfile = &edit_course_upload($file,$cnum,$cdom);
if ($cfile) {
$editbutton=&switch
- ('','',6,1,'pcstr.png','Edit',
+ ('','',6,1,'pcstr.png',$swtext{'pcstr'},
'resource[_2]',"go('".$cfile."');",
'Edit this resource');
}
@@ -682,7 +747,7 @@ sub innerregister {
if ($resurl eq "public/$cdom/$cnum/syllabus") {
if ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ /\w/) {
if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
- $editbutton=&switch('','',6,1,'pcstr.png','Edit',
+ $editbutton=&switch('','',6,1,'pcstr.png',$swtext{'pcstr'},
'resource[_2]',
"go('/adm/courseprefs?phase=display&actions=courseinfo')",
'Edit this resource');
@@ -693,7 +758,7 @@ sub innerregister {
###
###
# Prepare the rest of the buttons
- my $menuitems;
+ my ($menuitems,$got_prt,$got_wishlist);
if ($const_space) {
#
# We are in construction space
@@ -713,11 +778,11 @@ sub innerregister {
# Probably should be in mydesk.tab
#
$menuitems=(< 0){
}else{
$menuitems.="anot.png";
}
-$menuitems.="&Notes&&annotate()&";
+$menuitems.="&$swtext{'anot'}&tations[_1]&annotate()&";
$menuitems.="Make notes and annotations about this resource&&1\n";
unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme|viewclasslist|portfolio)(\?|$)/) {
- if ((!$env{'request.enc'}) && ($env{'request.noversionuri'} !~ m{^/adm/wrapper/ext/})) {
+ if ((!$env{'request.enc'}) && ($env{'request.noversionuri'} !~ m{^/adm/wrapper/ext/}) && ($env{'request.noversionuri'} !~ m{^/uploaded/$match_domain/$match_courseid/docs/})) {
$menuitems.=(<
+//
+
+ENDREGTHIS
}
+ } else {
+ unless ($noremote) {
+# Not registered, graphical
+ return (<
+//
+
+ENDDONOTREGTHIS
+
+ }
+ return '';
+ }
+}
+
+sub get_inline_text {
+ my %text = (
+ pgrd => 'Content Grades',
+ subm => 'Content Submissions',
+ pparm => 'Content Settings',
+ docs => 'Folder/Page Content',
+ pcstr => 'Edit',
+ list => 'Directory',
+ rtrv => 'Retrieve',
+ pub => 'Publish',
+ del => 'Delete',
+ prt => 'Print',
+ alnk => 'Stored Links',
+ anot => 'Notes',
+ catalog => 'Info',
+ eval => 'Evaluate',
+ fdbk => 'Feedback',
+ );
+ return %text;
+}
+
+sub get_rc_text {
+ my %text = (
+ pgrd => 'problem[_1]',
+ subm => 'view sub-[_1]',
+ pparm => 'problem[_2]',
+ pcstr => 'edit[_1]',
+ list => 'list[_1]',
+ rtrv => 'retrieve[_1]',
+ pub => 'publish[_1]',
+ del => 'delete[_1]',
+ prt => 'prepare[_1]',
+ back => 'backward[_1]',
+ forw => 'forward[_1]',
+ alnk => 'add to[_1]',
+ anot => 'anno-[_1]',
+ catalog => 'catalog[_2]',
+ eval => 'evaluate[_1]',
+ fdbk => 'feedback[_1]',
+ );
+ return %text;
}
sub is_course_upload {
@@ -882,10 +1103,22 @@ sub edit_course_upload {
return $cfile;
}
+sub loadevents() {
+ if ($env{'request.state'} eq 'construct' ||
+ $env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
+ return 'LONCAPAreg();';
+}
+
+sub unloadevents() {
+ if ($env{'request.state'} eq 'construct' ||
+ $env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
+ return 'LONCAPAstale();';
+}
+
sub startupremote {
my ($lowerurl)=@_;
- if ($env{'environment.remote'} eq 'off') {
- return ('');
+ unless ($env{'environment.remote'} eq 'on') {
+ return ('');
}
#
# The Remote actually gets launched!
@@ -963,7 +1196,7 @@ ENDSETFLAGS
}
sub maincall() {
- if ($env{'environment.remote'} eq 'off') { return ''; }
+ unless ($env{'environment.remote'} eq 'on') { return ''; }
return(<
// '."\n"
.'// 13)) { return ''; }
+ return "\n".qq(window.status+='.';swmenu.clearbut($row,$col););
+ } else {
+ $inlineremote[10*$row+$col]='';
+ return '';
+ }
}
# ============================================ Switch a button or create a link
@@ -1062,6 +1300,14 @@ sub switch {
my $idx=10*$row+$col;
$category_members{$cat}.=':'.$idx;
+ if ($env{'environment.remote'} eq 'on') {
+ if (($row<1) || ($row>13)) { return ''; }
+# Remote
+ $img=~s/\.png$/\.gif/;
+ return "\n".
+ qq(window.status+='.';swmenu.switchbutton($row,$col,"$img","$top","$bot","$act","$desc"););
+ }
+
# Inline Menu
if ($nobreak==2) { return ''; }
my $text=$top.' '.$bot;
@@ -1123,6 +1369,13 @@ sub secondlevel {
return $output;
}
+sub openmenu {
+ my $menuname = &get_menu_name();
+ unless ($env{'environment.remote'} eq 'on') { return ''; }
+ my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
+ return "window.open(".$nothing.",'".$menuname."');";
+}
+
sub inlinemenu {
undef(@inlineremote);
undef(%category_members);
@@ -1165,7 +1418,13 @@ sub rawconfig {
#
my $textualoverride=shift;
my $output='';
- return '' unless $textualoverride;
+ if ($env{'environment.remote'} eq 'on') {
+ $output.=
+ "window.status='Opening Remote Control';var swmenu=".&openmenu().
+"\nwindow.status='Configuring Remote Control ';";
+ } else {
+ unless ($textualoverride) { return ''; }
+ }
my $uname=$env{'user.name'};
my $udom=$env{'user.domain'};
my $adv=$env{'user.adv'};
@@ -1340,6 +1599,12 @@ sub rawconfig {
$uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
}
}
+ if ($env{'environment.remote'} eq 'on') {
+ $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;
}
@@ -1368,7 +1633,7 @@ sub check_for_rcrs {
# ======================================================================= Close
sub close {
- if ($env{'environment.remote'} eq 'off') { return ''; }
+ unless ($env{'environment.remote'} eq 'on') { return ''; }
my $menuname = &get_menu_name();
return(<
@@ -1653,6 +1918,16 @@ sub constspaceform {
ENDCONSTSPACEFORM
}
+sub get_nav_status {
+ my $navstatus="swmenu.w_loncapanav_flag=";
+ if ($env{'environment.remotenavmap'} eq 'on') {
+ $navstatus.="1";
+ } else {
+ $navstatus.="-1";
+ }
+ return $navstatus;
+}
+
sub hidden_button_check {
if ( $env{'request.course.id'} eq ''
|| $env{'request.role.adv'} ) {