--- loncom/interface/lonmenu.pm 2009/10/04 17:47:21 1.283
+++ loncom/interface/lonmenu.pm 2010/02/24 17:38:52 1.314
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines to control the menu
#
-# $Id: lonmenu.pm,v 1.283 2009/10/04 17:47:21 droeschl Exp $
+# $Id: lonmenu.pm,v 1.314 2010/02/24 17:38:52 droeschl Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -42,13 +42,77 @@ Coordinates the response to clicking an
This is part of the LearningOnline Network with CAPA project
described at http://www.lon-capa.org.
+=head1 GLOBAL VARIABLES
+
+=over
+
+=item @desklines
+
+Each element of this array contains a line of mydesk.tab that doesn't start with
+cat, prim or scnd.
+It gets filled in the BEGIN block of this module.
+
+=item %category_names
+
+The keys of this hash are the abbreviations used in mydesk.tab in those lines that
+start with cat, the values are strings representing titles.
+It gets filled in the BEGIN block of this module.
+
+=item %category_members
+
+TODO
+
+=item %category_positions
+
+The keys of this hash are the abbreviations used in mydesk.tab in those lines that
+start with cat, its values are position vectors (column, row).
+It gets filled in the BEGIN block of this module.
+
+=item $readdesk
+
+Indicates that mydesk.tab has been read.
+It is set to 'done' in the BEGIN block of this module.
+
+=item @primary_menu
+
+The elements of this array reference arrays that are made up of the components
+of those lines of mydesk.tab that start with prim.
+It is used by primary_menu() to generate the corresponding menu.
+It gets filled in the BEGIN block of this module.
+
+=item @secondary_menu
+
+The elements of this array reference arrays that are made up of the components
+of those lines of mydesk.tab that start with scnd.
+It is used by secondary_menu() to generate the corresponding menu.
+It gets filled in the BEGIN block of this module.
+
+=back
+
=head1 SUBROUTINES
=over
-Little texts
+=item prep_menuitems(\@menuitem)
+
+This routine wraps a menuitem in proper HTML. It is used by primary_menu() and
+secondary_menu().
+
+=item primary_menu()
+
+This routine evaluates @primary_menu and returns XHTML for the menu
+that contains following links: About, Message, Roles, Help, Logout
+@primary_menu is filled within the BEGIN block of this module with
+entries from mydesk.tab
+
+=item secondary_menu()
-=item initlittle()
+Same as primary_menu() but operates on @secondary_menu.
+
+=item DEPRECATED: initlittle()
+
+This routine returns a translated hash for the menu items in the top inline
+menu row
=item menubuttons()
@@ -113,11 +177,6 @@ The javascript is usually similar to "go
=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()
@@ -142,21 +201,23 @@ use HTML::Entities();
use vars qw(@desklines %category_names %category_members %category_positions
$readdesk @primary_menu @secondary_menu);
-
my @inlineremote;
sub prep_menuitem {
- my $menuitem = shift;
- return '' unless ref $menuitem eq 'ARRAY';
+ my ($menuitem) = @_;
+ return '' unless(ref($menuitem) eq 'ARRAY');
my $link;
if ($$menuitem[1]) { # graphical Link
$link = "
";
+ . " src=\"" . &Apache::loncommon::lonhttpdurl($$menuitem[1]) . "\""
+ . " alt=\"" . &mt($$menuitem[2]) . "\" />";
} else { # textual Link
- $link = mt($$menuitem[3]);
- }
- return "
$link";
+ $link = &mt($$menuitem[3]);
+ }
+ if($$menuitem[4] eq 'newmsg'){ #special style for New Messages
+ return ''.$link.'';
+ }
+ return ''.$link.'';
}
# primary_menu() evaluates @primary_menu and returns XHTML for the menu
@@ -170,10 +231,11 @@ sub primary_menu {
# (link url, icon path, alt text, link text, condition)
foreach my $menuitem (@primary_menu) {
# evaluate conditions
+ next if ref($menuitem) ne 'ARRAY'; #
next if $$menuitem[4] eq 'nonewmsg' # show links depending on
- && Apache::lonmsg::mynewmail(); # whether a new msg
+ && &Apache::lonmsg::mynewmail(); # whether a new msg
next if $$menuitem[4] eq 'newmsg' # arrived or not
- && !Apache::lonmsg::mynewmail(); #
+ && !&Apache::lonmsg::mynewmail(); #
next if $$menuitem[4] !~ /public/ ##we've a public user,
&& $env{'user.name'} eq 'public' ##who should not see all
&& $env{'user.domain'} eq 'public'; ##links
@@ -181,70 +243,90 @@ sub primary_menu {
&& $env{'user.name'} ne 'public' # only visible to public
&& $env{'user.domain'} ne 'public'; # users
next if $$menuitem[4] eq 'roles' ##show links depending on
- && Apache::loncommon::show_course(); ##term 'Courses' or
+ && &Apache::loncommon::show_course(); ##term 'Courses' or
next if $$menuitem[4] eq 'courses' ##'Roles' wanted
- && !Apache::loncommon::show_course(); ##
-
-
+ && !&Apache::loncommon::show_course(); ##
+
+
if ($$menuitem[3] eq 'Help') { # special treatment for helplink
- $menu .= Apache::loncommon::top_nav_help('Help');
+ $menu .= ''.&Apache::loncommon::top_nav_help('Help').'';
} else {
- $menu .= prep_menuitem(\@$menuitem);
+ my @items = @{$menuitem};
+ $items[0] = 'javascript:'.$menuitem->[0].';';
+ $menu .= &prep_menuitem(\@items);
}
- }
+ }
- return "";
+ return "";
}
sub secondary_menu {
my $menu;
+ my $crstype = &Apache::loncommon::course_type();
+ my $canedit = &Apache::lonnet::allowed('mdc', $env{'request.course.id'});
+ my $canviewgrps = &Apache::lonnet::allowed('vcg', $env{'request.course.id'}
+ . ($env{'request.course.sec'} ? "/$env{'request.course.sec'}"
+ : ''));
+ my $showlink = &show_return_link();
+ my %groups = &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'});
foreach my $menuitem (@secondary_menu) {
# evaluate conditions
+ next if ref($menuitem) ne 'ARRAY';
next if $$menuitem[4] ne 'always'
&& !$env{'request.course.id'};
next if $$menuitem[4] eq 'showreturn'
- && !show_return_link()
+ && !$showlink
&& !($env{'request.state'} eq 'construct');
next if $$menuitem[4] =~ /^mdc/
- && !Apache::lonnet::allowed('mdc', $env{'request.course.id'});
- next if $$menuitem[4] =~ /nogrp$/
- && Apache::loncommon::course_type() eq 'Group';
- next if $$menuitem[4] =~ /group$/
- && Apache::loncommon::course_type() ne 'Group';
- next if $$menuitem[4] eq 'remotenav'
+ && !$canedit;
+ next if $$menuitem[4] eq 'mdcCourse'
+ && $crstype eq 'Community';
+ next if $$menuitem[4] eq 'mdcCommunity'
+ && $crstype ne 'Community';
+ next if $$menuitem[4] =~ /^remotenav/
&& $env{'environment.remotenavmap'} ne 'on';
- next if $$menuitem[4] eq 'noremotenav'
+ next if $$menuitem[4] =~ /noremotenav/
&& $env{'environment.remotenavmap'} eq 'on';
+ next if $$menuitem[4] =~ /^(no|)remotenav$/
+ && $crstype eq 'Community';
+ next if $$menuitem[4] =~ /^(no|)remotenavCommunity$/
+ && $crstype ne 'Community';
next if $$menuitem[4] =~ /showgroups$/
- && !Apache::lonnet::allowed('vcg', $env{'request.course.id'}
- . ($env{'request.course.sec'} ? "/$env{'request.course.sec'}"
- : ''))
- && !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'});
-
+ && !$canviewgrps
+ && !%groups;
- if($$menuitem[3] eq 'Roles' && $env{'request.course.id'}) {
+ if ($$menuitem[3] eq 'Roles' && $env{'request.course.id'}) {
# special treatment for role selector
- my $roles_selector = roles_selector(
+ my $roles_selector = &roles_selector(
$env{'course.' . $env{'request.course.id'} . '.domain'},
$env{'course.' . $env{'request.course.id'} . '.num'} );
$menu .= $roles_selector ? "$roles_selector"
: '';
+ } elsif ($env{'environment.remotenavmap'} eq 'on') {
+ # open link using javascript when remote navmap is activated
+ my @items = @{$menuitem};
+ if ($menuitem->[4] eq 'remotenav') {
+ $items[0] = "javascript:gonav('$menuitem->[0]');";
+ } else {
+ $items[0] = "javascript:go('$menuitem->[0]');";
+ }
+ $menu .= &prep_menuitem(\@items);
} else {
- $menu .= prep_menuitem(\@$menuitem);
+ $menu .= &prep_menuitem(\@$menuitem);
}
}
if ($menu =~ /\[url\].*\[symb\]/) {
- my $escurl = escape( Apache::lonenc::check_encrypt(
- $env{'request.noversionuri'}));
+ my $escurl = &escape( &Apache::lonenc::check_encrypt(
+ $env{'request.noversionuri'}));
- my $escsymb = escape( Apache::lonenc::check_encrypt(
- $env{'request.symb'}));
+ my $escsymb = &escape( &Apache::lonenc::check_encrypt(
+ $env{'request.symb'}));
if ( $env{'request.state'} eq 'construct'
and ( $env{'request.noversionuri'} eq ''
@@ -253,13 +335,13 @@ sub secondary_menu {
($escurl = $env{'request.filename'}) =~
s{^/home/([^/]+)/public_html/(.*)$}{/priv/$1/$2};
- $escurl = escape($escurl);
+ $escurl = &escape($escurl);
}
$menu =~ s/\[url\]/$escurl/g;
$menu =~ s/\[symb\]/$escsymb/g;
}
- return "";
+ return "";
}
@@ -275,12 +357,12 @@ sub initlittle {
'roles' => (&Apache::loncommon::show_course()?
'Courses':'Roles'),
'other' => 'Other Roles',
- 'docs' => 'Edit Course',
+ 'docs' => 'Course Editor',
'exit' => 'Logout',
'login' => 'Log In',
'launch' => 'Launch Remote Control',
'groups' => 'Groups',
- 'gdoc' => 'Group Documents',
+ 'gdoc' => 'Community Documents',
);
}
@@ -355,7 +437,7 @@ sub menubuttons {
my %lt=&initlittle();
my $domain=&Apache::loncommon::determinedomain();
- my $function =&Apache::loncommon::get_users_function();
+ 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);
@@ -363,7 +445,7 @@ sub menubuttons {
if ($env{'user.name'} eq 'public' && $env{'user.domain'} eq 'public') {
return (<