--- loncom/interface/lonmenu.pm 2006/06/30 02:14:58 1.189
+++ loncom/interface/lonmenu.pm 2008/12/04 13:41:37 1.247
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines to control the menu
#
-# $Id: lonmenu.pm,v 1.189 2006/06/30 02:14:58 albertel Exp $
+# $Id: lonmenu.pm,v 1.247 2008/12/04 13:41:37 harmsja Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -36,6 +36,105 @@
# browser.interface is 'textual'
#
+=head1 NAME
+
+Apache::lonmenu
+
+=head1 SYNOPSIS
+
+Coordinates the response to clicking an image.
+
+This is part of the LearningOnline Network with CAPA project
+described at http://www.lon-capa.org.
+
+=head1 SUBROUTINES
+
+=over
+
+=item show_course()
+
+Little texts
+
+=item initlittle()
+
+=item menubuttons()
+
+This gets called at the top of the body section
+
+=item show_return_link()
+
+=item registerurl()
+
+This gets called in the header section
+
+=item innerregister()
+
+This gets called in order to register a URL, both with the Remote
+and 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()
+
+Switch a button or create a link
+Switch acts on the javascript that is executed when a button is clicked.
+The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)".
+
+=item secondlevel()
+
+=item openmenu()
+
+=item inlinemenu()
+
+=item rawconfig()
+
+=item close()
+
+=item footer()
+
+=item utilityfunctions()
+
+=item serverform()
+
+=item constspaceform()
+
+=item get_nav_status()
+
+=item convert_menu_function()
+
+FIXME this needs to move into mydesktab and the other locations
+the text is generated
+
+=item hidden_button_check()
+
+=item roles_selector()
+
+=item jump_to_role()
+
+=back
+
+=cut
+
package Apache::lonmenu;
use strict;
@@ -44,33 +143,45 @@ use Apache::lonhtmlcommon();
use Apache::loncommon();
use Apache::lonenc();
use Apache::lonlocal;
-use lib '/home/httpd/lib/perl/';
-use LONCAPA;
+use LONCAPA qw(:DEFAULT :match);
-use vars qw(@desklines $readdesk);
+use vars qw(@desklines %category_names %category_members %category_positions $readdesk);
my @inlineremote;
-# ================================================================ Little texts
+
+
+sub show_course {
+ my $course = !$env{'user.adv'};
+ if (!$env{'user.adv'}) {
+ foreach my $env (keys(%env)) {
+ next if ($env !~ m/^user\.priv\./);
+ if ($env !~ m/^user\.priv\.(?:st|cm)/) {
+ $course = 0;
+ last;
+ }
+ }
+ }
+ return $course;
+}
sub initlittle {
return &Apache::lonlocal::texthash('ret' => 'Return to Last Location',
'nav' => 'Navigate Contents',
'main' => 'Main Menu',
- 'roles' => ($env{'user.adv'}?
- 'Roles':'Courses'),
- 'docs' => 'Course Documents',
+ 'roles' => (&show_course()?
+ 'Courses':'Roles'),
+ 'other' => 'Other Roles',
+ 'docs' => 'Edit Course',
'exit' => 'Exit',
+ 'login' => 'Log In',
'launch' => 'Launch Remote Control',
'groups' => 'Groups',
'gdoc' => 'Group Documents',
- 'teams' => 'Teams',
);
}
-# ============================= This gets called at the top of the body section
-
sub menubuttons {
my $forcereg=shift;
my $registration=shift;
@@ -87,10 +198,17 @@ sub menubuttons {
my $reloadlink='';
my $docs='';
my $groups='';
+ my $roles=''.$lt{'roles'}.'';
+ my $role_selector;
my $showgroups=0;
+ my ($cnum,$cdom);
my $escurl=&escape(&Apache::lonenc::check_encrypt($env{'request.noversionuri'}));
my $escsymb=&escape(&Apache::lonenc::check_encrypt($env{'request.symb'}));
+ my $logo=&Apache::loncommon::lonhttpdurl("/adm/lonIcons/minilogo.gif");
+ $logo = '
';
+
if ($env{'request.state'} eq 'construct') {
if (($env{'request.noversionuri'} eq '') || (!defined($env{'request.noversionuri'}))) {
my $returnurl = $env{'request.filename'};
@@ -99,15 +217,21 @@ sub menubuttons {
}
}
if ($env{'request.course.id'}) {
+ $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+ $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
my %coursegroups;
my $viewgrps_permission =
- &Apache::lonnet::allowed('vcg',$env{'request.course.id'});
+ &Apache::lonnet::allowed('vcg',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''));
if (!$viewgrps_permission) {
- %coursegroups = &Apache::lonnet::get_active_groups($env{'user.domain'},$env{'user.name'},$env{'course.'.$env{'request.course.id'}.'.domain'}, $env{'course.'.$env{'request.course.id'}.'.num'});
+ %coursegroups = &Apache::lonnet::get_active_groups($env{'user.domain'},$env{'user.name'},$cdom,$cnum);
}
if ((keys(%coursegroups) > 0) || ($viewgrps_permission)) {
$showgroups = 1;
}
+ $role_selector = &roles_selector($cdom,$cnum);
+ if ($role_selector) {
+ $roles = ''.$role_selector.' '.$lt{'other'}.'';
+ }
}
if ($env{'browser.interface'} eq 'textual') {
@@ -116,9 +240,7 @@ sub menubuttons {
$navmaps=(<$lt{'nav'}
ENDNAV
- if (($env{'request.noversionuri'}=~/^\/adm\//) &&
- ($env{'request.noversionuri'}!~/^\/adm\/wrapper\//) &&
- ($env{'request.noversionuri'}!~/^\/adm\/.*\/(smppg|bulletinboard|aboutme)(\?|$)/)) {
+ if (&show_return_link()) {
my $escreload=&escape('return:');
$reloadlink=(<$lt{'ret'}
@@ -131,7 +253,7 @@ ENDDOCS
}
if ($showgroups) {
$groups =(<$lt{'groups'}
+$lt{'groups'}
ENDGROUPS
}
}
@@ -144,8 +266,7 @@ $utility
';
# Do we have a NAV link?
if ($env{'request.course.id'}) {
my $link='/adm/navmaps?postdata='.$escurl.'&postsymb='.
@@ -191,7 +312,7 @@ ENDINLINEMENU
$navmaps=(<$lt{'nav'}
ENDNAV
-my $is_group = (&Apache::loncommon::course_type() eq 'Group');
+ my $is_group = (&Apache::loncommon::course_type() eq 'Group');
if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
my $text = ($is_group) ? $lt{'gdoc'} : $lt{'docs'};
$docs=(<$text
+
$form
@@ -268,7 +379,19 @@ ENDINLINEMENU
}
}
-# ====================================== This gets called in the header section
+sub show_return_link {
+ return (($env{'request.noversionuri'}=~m{^/(res|public)/} &&
+ $env{'request.symb'} eq '')
+ ||
+ ($env{'request.noversionuri'}=~ m{^/cgi-bin/printout.pl})
+ ||
+ (($env{'request.noversionuri'}=~/^\/adm\//) &&
+ ($env{'request.noversionuri'}!~/^\/adm\/wrapper\//) &&
+ ($env{'request.noversionuri'}!~
+ m[^/adm/.*/(smppg|bulletinboard|aboutme)($|\?)])
+ ));
+}
+
sub registerurl {
my ($forcereg) = @_;
@@ -293,9 +416,6 @@ sub registerurl {
return $result.$force_title;
}
-# =========== This gets called in order to register a URL, both with the Remote
-# =========== and in the body of the document
-
sub innerregister {
my ($forcereg, $titletable) = @_;
my $result = '';
@@ -328,16 +448,18 @@ sub innerregister {
} else {
$newmail= 'swmenu.setstatus("you have","messages");';
}
- } elsif (($textual)
+ }
+ if (($textual)
&& ($env{'request.symb'})
&& ($env{'request.course.id'})) {
$newmail.= '
';
my ($mapurl,$rid,$resurl)=
&Apache::lonnet::decode_symb(&Apache::lonnet::symbread());
- $newmail.=$env{'course.'.$env{'request.course.id'}.'.description'};
+ my $coursetitle=$env{'course.'.$env{'request.course.id'}.'.description'};
+ $newmail.=$coursetitle;
my $maptitle=&Apache::lonnet::gettitle($mapurl);
my $restitle=&Apache::lonnet::gettitle(&Apache::lonnet::symbread());
- if ($maptitle && $maptitle ne 'default.sequence') {
+ if ($maptitle && ($maptitle ne 'default.sequence') && ($maptitle ne $coursetitle)) {
$newmail.=', '.$maptitle;
}
if ($restitle) {
@@ -383,7 +505,7 @@ sub innerregister {
&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');
+ 'Modify parameter settings for this resource');
}
# -- End Homework
###
@@ -392,19 +514,24 @@ sub innerregister {
###
my $editbutton = '';
if ($env{'user.author'}) {
- if ($env{'request.role'}=~/^(ca|au)/) {
+ if ($env{'request.role'}=~/^(aa|ca|au)/) {
# Set defaults for authors
my ($top,$bottom) = ('con-','struct');
my $action = "go('/priv/".$env{'user.name'}."');";
my $cadom = $env{'request.role.domain'};
my $caname = $env{'user.name'};
- my $desc = "Enter my resource construction space";
+ my $desc = "Enter my construction space";
# Set defaults for co-authors
if ($env{'request.role'} =~ /^ca/) {
- ($cadom,$caname)=($env{'request.role'}=~/(\w+)\/(\w+)$/);
+ ($cadom,$caname)=($env{'request.role'}=~/($match_domain)\/($match_username)$/);
($top,$bottom) = ('co con-','struct');
$action = "go('/priv/".$caname."');";
$desc = "Enter construction space as co-author";
+ } elsif ($env{'request.role'} =~ /^aa/) {
+ ($cadom,$caname)=($env{'request.role'}=~/($match_domain)\/($match_username)$/);
+ ($top,$bottom) = ('co con-','struct');
+ $action = "go('/priv/".$caname."');";
+ $desc = "Enter construction space as assistant co-author";
}
# Check that we are on the correct machine
my $home = &Apache::lonnet::homeserver($caname,$cadom);
@@ -423,7 +550,7 @@ sub innerregister {
my $cfudom='';
if ($env{'request.filename'}) {
my $file=&Apache::lonnet::declutter($env{'request.filename'});
- $file=~s/^(\w+)\/(\w+)/\/priv\/$2/;
+ $file=~s/^($match_domain)\/($match_username)/\/priv\/$2/;
# Check that the user has permission to edit this resource
($cfuname,$cfudom)=&Apache::loncacc::constructaccess($file,$1);
if (defined($cfudom)) {
@@ -439,13 +566,10 @@ sub innerregister {
# Finally, turn the button on or off
if ($cfile && !$const_space) {
$editbutton=&switch
- ('','',6,1,'cstr.gif','edit[_1]','resource[_2]',
+ ('','',6,1,'pcstr.gif','edit[_1]','resource[_2]',
"go('".$cfile."');","Edit this resource");
} elsif ($editbutton eq '') {
- $editbutton=&switch('','',6,1,'port.gif',
- 'port-[_1]','folio[_1]',
- "go('/adm/portfolio');",
- "Enter my portfolio space");
+ $editbutton=&clear(6,1);
}
}
###
@@ -460,42 +584,74 @@ sub innerregister {
$is_const_dir = 1;
} else {
$currdir =~ s#[^/]+$##;
+ my $cleandisfn = &Apache::loncommon::escape_single($thisdisfn);
+ my $esc_currdir = &Apache::loncommon::escape_single($currdir);
$menuitems=(< 0){
+ $menuitems.="anot2.gif";
+}else{
+ $menuitems.="anot.gif";
+}
+$menuitems.="&anno-[_1]&tations[_1]&annotate()&";
+$menuitems.="Make notes and annotations about this resource&&1\n";
+
unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme)(\?|$)/) {
- $menuitems.=(<
+$inlineremote[21] $inlineremote[23]
+ENDARROWSINLINE
+ if (&hidden_button_check() ne 'yes') {
+ $inlinebuttons .= (<
+ENDINLINEICONS
+ }
+ } else {
+ if ($inlineremote[21] ne '' || $inlineremote[23] ne '') {
+ $inlinebuttons=(<
$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
- }
+ENDFIRSTLINE
+ }
+ if (&hidden_button_check() ne 'yes') {
+ foreach my $row (6..9) {
+ if ($inlineremote[${row}.'1'] ne ''
+ || $inlineremote[$row.'2'] ne ''
+ || $inlineremote[$row.'3'] ne '') {
+ $inlinebuttons .= <<"ENDLINE";
+
$inlineremote["${row}1"]
$inlineremote["${row}2"]
$inlineremote["${row}3"]
+ENDLINE
+ }
+ }
+ }
+ }
+ }
}
$result =(<
// BEGIN LON-CAPA Internal
$timesync
-$newmail
$tablestart
$inlinebuttons
$tableend
+$newmail
@@ -639,7 +818,6 @@ sub unloadevents() {
return 'LONCAPAstale();';
}
-# ============================================================= Start up remote
sub startupremote {
my ($lowerurl)=@_;
@@ -746,17 +924,22 @@ sub load_remote_msg {
$link
ENDREMOTEFORM
}
-# ================================================================= Reopen menu
+
+sub get_menu_name {
+ my $hostid = $Apache::lonnet::perlvar{'lonHostID'};
+ $hostid =~ s/\W//g;
+ return 'LCmenu'.$hostid;
+}
+
sub reopenmenu {
if (($env{'browser.interface'} eq 'textual') ||
($env{'environment.remote'} eq 'off')) { return ''; }
- my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};
+ my $menuname = &get_menu_name();
my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
return('window.open('.$nothing.',"'.$menuname.'","",false);');
}
-# =============================================================== Open the menu
sub open {
my $returnval='';
@@ -764,20 +947,21 @@ sub open {
($env{'environment.remote'} eq 'off')) {
return '';
}
- my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};
- unless (shift eq 'unix') {
+ my $menuname = &get_menu_name();
+
+# unless (shift eq 'unix') {
# resizing does not work on linux because of virtual desktop sizes
- $returnval.=(<'.$returnval.'';
@@ -802,13 +986,17 @@ sub clear {
# The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)".
sub switch {
- my ($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$nobreak)=@_;
+ my ($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat,$nobreak)=@_;
$act=~s/\$uname/$uname/g;
$act=~s/\$udom/$udom/g;
$top=&mt($top);
$bot=&mt($bot);
$desc=&mt($desc);
- $img=&mt($img);
+ if (($env{'environment.remote'} ne 'off') || ($env{'environment.icons'} eq 'classic')) {
+ $img=&mt($img);
+ }
+ my $idx=10*$row+$col;
+ $category_members{$cat}.=':'.$idx;
unless (($env{'browser.interface'} eq 'textual') ||
($env{'environment.remote'} eq 'off')) {
@@ -821,48 +1009,53 @@ sub switch {
my $text=$top.' '.$bot;
$text=~s/\s*\-\s*//gs;
if ($nobreak) {
- $inlineremote[10*$row+$col]=
+ $inlineremote[$idx]=
''.$text.'';
} else {
- $inlineremote[10*$row+$col]="\n ".
+ $inlineremote[$idx]="\n ".
$desc.' '.$text.'';
}
} else {
# Inline Remote
+ if ($env{'environment.icons'} ne 'classic') {
+ $img=~s/\.gif$/\.png/;
+ }
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=
- '';
+ '';
if ($env{'browser.interface'} eq 'faketextual') {
# Accessibility
if ($nobreak==3) {
- $inlineremote[10*$row+$col]="\n".
+ $inlineremote[$idx]="\n".
'