--- loncom/interface/lonmenu.pm 2008/01/15 16:53:27 1.233
+++ loncom/interface/lonmenu.pm 2009/03/29 20:10:37 1.256
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines to control the menu
#
-# $Id: lonmenu.pm,v 1.233 2008/01/15 16:53:27 www Exp $
+# $Id: lonmenu.pm,v 1.256 2009/03/29 20:10:37 kaisler 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;
@@ -53,7 +152,6 @@ my @inlineremote;
-# ================================================================ Little texts
sub show_course {
my $course = !$env{'user.adv'};
if (!$env{'user.adv'}) {
@@ -74,6 +172,7 @@ sub initlittle {
'main' => 'Main Menu',
'roles' => (&show_course()?
'Courses':'Roles'),
+ 'other' => 'Other Roles',
'docs' => 'Edit Course',
'exit' => 'Exit',
'login' => 'Log In',
@@ -83,8 +182,6 @@ sub initlittle {
);
}
-# ============================= This gets called at the top of the body section
-
sub menubuttons {
my $forcereg=shift;
my $registration=shift;
@@ -101,13 +198,16 @@ 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 = '
';
+ $logo = '';
if ($env{'request.state'} eq 'construct') {
if (($env{'request.noversionuri'} eq '') || (!defined($env{'request.noversionuri'}))) {
@@ -117,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'}.($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') {
@@ -160,8 +266,7 @@ $utility
-
ENDINLINEMENU
}
+ $roles = ''.$lt{'roles'}.'';
# Do we have a NAV link?
if ($env{'request.course.id'}) {
my $link='/adm/navmaps?postdata='.$escurl.'&postsymb='.
@@ -205,31 +310,35 @@ ENDINLINEMENU
$link="javascript:gonav('".$link."')";
}
$navmaps=(<$lt{'nav'}
+
ENDCRELOAD
}
my $reg='';
@@ -238,11 +347,13 @@ ENDCRELOAD
}
my $form=&serverform();
my $utility=&utilityfunctions();
- my $remote;
- if ($env{'user.adv'}) {
- $remote = '
+$role_selector
+
$form
+
$reg
ENDINLINEMENU
} else {
@@ -289,7 +402,6 @@ sub show_return_link {
));
}
-# ====================================== This gets called in the header section
sub registerurl {
my ($forcereg) = @_;
@@ -314,9 +426,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 = '';
@@ -415,19 +524,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'}=~/($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);
@@ -501,13 +615,24 @@ c&8&1
c&8&2
s&8&3&prt.gif&prepare[_1]&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document
s&9&1&sbkm.gif&set[_1]&bookmark[_2]&set_bookmark()&Set a bookmark for this resource&&1
-s&9&3&anot.gif&anno-[_1]&tations[_1]&annotate()&Make notes and annotations about this resource&&1
ENDMENUITEMS
+my $currentURL = &Apache::loncommon::get_symb();
+my ($symb_old,$symb_old_enc) = &Apache::loncommon::clean_symb($currentURL);
+my $annotation = &Apache::loncommon::get_annotation($symb_old,$symb_old_enc);
+$menuitems.="s&9&3&";
+if(length($annotation) > 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)(\?|$)/) {
if (!$env{'request.enc'}) {
$menuitems.=(<';
+ '" align="'.($nobreak==3?'right':'left').'" class="LC_noBorder" />';
if ($env{'browser.interface'} eq 'faketextual') {
# Accessibility
if ($nobreak==3) {
$inlineremote[$idx]="\n".
'