--- loncom/interface/lonmenu.pm 2006/05/15 17:27:51 1.182
+++ loncom/interface/lonmenu.pm 2009/08/20 06:04:14 1.244.2.6
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines to control the menu
#
-# $Id: lonmenu.pm,v 1.182 2006/05/15 17:27:51 albertel Exp $
+# $Id: lonmenu.pm,v 1.244.2.6 2009/08/20 06:04:14 raeburn 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,28 +143,45 @@ 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;
-# ================================================================ 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',
- 'exit' => 'Exit',
+ 'roles' => (&Apache::loncommon::show_course()?
+ 'Courses':'Roles'),
+ 'other' => 'Other Roles',
+ 'docs' => 'Edit Course',
+ 'exit' => 'Logout',
+ 'login' => 'Log In',
'launch' => 'Launch Remote Control',
- 'groups' => 'Groups');
+ 'groups' => 'Groups',
+ 'gdoc' => 'Group Documents',
+ );
}
-# ============================= This gets called at the top of the body section
-
sub menubuttons {
my $forcereg=shift;
my $registration=shift;
@@ -82,27 +198,40 @@ sub menubuttons {
my $reloadlink='';
my $docs='';
my $groups='';
+ my $roles=''.$lt{'roles'}.'';
+ my $role_selector;
my $showgroups=0;
- my $escurl=&Apache::lonnet::escape(&Apache::lonenc::check_encrypt($env{'request.noversionuri'}));
- my $escsymb=&Apache::lonnet::escape(&Apache::lonenc::check_encrypt($env{'request.symb'}));
+ 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'};
$returnurl =~ s:^/home/([^/]+)/public_html/(.*)$:/priv/$1/$2:;
- $escurl = &Apache::lonnet::escape($returnurl);
+ $escurl = &escape($returnurl);
}
}
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'});
+ 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'},$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') {
@@ -111,10 +240,8 @@ sub menubuttons {
$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:');
+ if (&show_return_link()) {
+ my $escreload=&escape('return:');
$reloadlink=(<$lt{'ret'}
ENDRELOAD
@@ -126,7 +253,7 @@ ENDDOCS
}
if ($showgroups) {
$groups =(<$lt{'groups'}
+$lt{'groups'}
ENDGROUPS
}
}
@@ -139,8 +266,7 @@ $utility
';
# Do we have a NAV link?
if ($env{'request.course.id'}) {
my $link='/adm/navmaps?postdata='.$escurl.'&postsymb='.
@@ -189,9 +313,11 @@ ENDINLINEMENU
$navmaps=(<$lt{'nav'}
ENDNAV
+ 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=(<$lt{'docs'}
+