--- loncom/interface/lonmenu.pm 2004/12/04 02:01:04 1.137
+++ loncom/interface/lonmenu.pm 2009/08/12 18:38:04 1.279
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines to control the menu
#
-# $Id: lonmenu.pm,v 1.137 2004/12/04 02:01:04 raeburn Exp $
+# $Id: lonmenu.pm,v 1.279 2009/08/12 18:38:04 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -26,167 +26,300 @@
# http://www.lon-capa.org/
#
#
-# There are two parameters controlling the action of this module:
-#
-# browser.interface - if this is 'textual', it overrides the second parameter
-# and goes to screen reader PDA mode
+# There is one parameter controlling the action of this module:
#
# environment.remote - if this is 'on', the routines controll the remote
-# control, otherwise they render the main window controls; ignored it
-# browser.interface is 'textual'
-#
+# control, otherwise they render the main window controls;
+
+=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
+
+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;
-use Apache::lonnet();
-use Apache::Constants qw(:common);
+use Apache::lonnet;
use Apache::lonhtmlcommon();
use Apache::loncommon();
use Apache::lonenc();
use Apache::lonlocal;
+use LONCAPA qw(:DEFAULT :match);
-use vars qw(@desklines $readdesk);
+use vars qw(@desklines %category_names %category_members %category_positions $readdesk);
my @inlineremote;
-my $font;
-my $tabbg;
-my $pgbg;
-# ================================================================ Little texts
+#
+# This routine returns a translated hash for the menu items in the top inline menu row
+# Probably should be in mydesk.tab
sub initlittle {
return &Apache::lonlocal::texthash('ret' => 'Return to Last Location',
'nav' => 'Navigate Contents',
'main' => 'Main Menu',
- 'launch' => 'Launch Remote Control');
+ 'roles' => (&Apache::loncommon::show_course()?
+ 'Courses':'Roles'),
+ 'other' => 'Other Roles',
+ 'docs' => 'Edit Course',
+ 'exit' => 'Logout',
+ 'login' => 'Log In',
+ 'launch' => 'Launch Remote Control',
+ 'groups' => 'Groups',
+ 'gdoc' => 'Group Documents',
+ );
}
-# ============================= This gets called at the top of the body section
-
sub menubuttons {
my $forcereg=shift;
- my $target =shift;
- my $registration=shift;
my $titletable=shift;
+#
+# Early-out for pages that should not have a menu, triggered by query string "inhibitmenu=yes"
+#
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
['inhibitmenu']);
- if ($ENV{'form.inhibitmenu'} eq 'yes') { return ''; }
+ if (($env{'form.inhibitmenu'} eq 'yes') ||
+ ($ENV{'REQUEST_URI'} eq '/adm/logout')) { return ''; }
+
+ if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
+ my %lt=&initlittle();
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'};
+ my $docs='';
+ my $groups='';
+ my $roles=''.$lt{'roles'}.'';
+ my $role_selector;
+ my $showgroups=0;
+ my ($cnum,$cdom);
+#
+# if the URL is hidden, symbs and the non-versioned version of the URL would be encrypted
+#
+ 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') {
+#
+# We are in construction space
+#
+ 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);
+ $escurl = &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=(<$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=(<$lt{'ret'}
-ENDRELOAD
- }
+ if ($env{'request.course.id'}) {
+#
+# We are in a course
+#
+ $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'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''));
+ if (!$viewgrps_permission) {
+ %coursegroups = &Apache::lonnet::get_active_groups($env{'user.domain'},$env{'user.name'},$cdom,$cnum);
+ }
+ if ((keys(%coursegroups) > 0) || ($viewgrps_permission)) {
+ $showgroups = 1;
}
- my $form=&serverform();
- my $utility=&utilityfunctions();
- my $output=(<
-// BEGIN LON-CAPA Internal
-$utility
-
-$lt{'main'}
-$reloadlink $navmaps
-
-$form
-ENDMAINMENU
- if ($registration) { $output.=&innerregister($forcereg,$target); }
- return $output."
";
- } elsif ($ENV{'environment.remote'} eq 'off') {
+ $role_selector = &roles_selector($cdom,$cnum);
+ if ($role_selector) {
+ $roles = ''.$role_selector.' '.$lt{'other'}.'';
+ }
+ }
+
+ if ($env{'environment.remote'} eq 'off') {
# Remote Control is switched off
# figure out colors
- my %lt=&initlittle();
- my $function='student';
- if ($ENV{'request.role'}=~/^(cc|in|ta|ep)/) {
- $function='coordinator';
- }
- if ($ENV{'request.role'}=~/^(su|dc|ad|li)/) {
- $function='admin';
- }
- if (($ENV{'request.role'}=~/^(au|ca)/) ||
- ($ENV{'request.noversionuri'}=~/^(\/priv|\~)/)) {
- $function='author';
- }
+ my %lt=&initlittle();
+
my $domain=&Apache::loncommon::determinedomain();
- $pgbg=&Apache::loncommon::designparm($function.'.pgbg',$domain);
- $tabbg=&Apache::loncommon::designparm($function.'.tabbg',$domain);
- $font=&Apache::loncommon::designparm($function.'.font',$domain);
+ my $function =&Apache::loncommon::get_users_function();
my $link=&Apache::loncommon::designparm($function.'.link',$domain);
my $alink=&Apache::loncommon::designparm($function.'.alink',$domain);
my $vlink=&Apache::loncommon::designparm($function.'.vlink',$domain);
my $sidebg=&Apache::loncommon::designparm($function.'.sidebg',$domain);
+
+ if ($env{'user.name'} eq 'public' && $env{'user.domain'} eq 'public') {
+ return (<