[LON-CAPA-cvs] cvs: loncom /interface lonmenu.pm
www
www@source.lon-capa.org
Sat, 11 Jul 2009 19:58:29 -0000
www Sat Jul 11 19:58:29 2009 EDT
Modified files:
/loncom/interface lonmenu.pm
Log:
This needs serious cleanup. Adding some comments.
Index: loncom/interface/lonmenu.pm
diff -u loncom/interface/lonmenu.pm:1.273 loncom/interface/lonmenu.pm:1.274
--- loncom/interface/lonmenu.pm:1.273 Thu Jul 9 19:28:36 2009
+++ loncom/interface/lonmenu.pm Sat Jul 11 19:58:29 2009
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines to control the menu
#
-# $Id: lonmenu.pm,v 1.273 2009/07/09 19:28:36 droeschl Exp $
+# $Id: lonmenu.pm,v 1.274 2009/07/11 19:58:29 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -143,6 +143,10 @@
my @inlineremote;
+#
+# 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',
@@ -163,6 +167,9 @@
my $forcereg=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') ||
@@ -179,6 +186,9 @@
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'}));
@@ -187,6 +197,9 @@
$logo.'" alt="LON-CAPA Logo" class="LC_noBorder" /></a>';
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:;
@@ -194,6 +207,9 @@
}
}
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;
@@ -453,6 +469,9 @@
}
if ($env{'user.author'}) {
if ($env{'request.role'}=~/^(aa|ca|au)/) {
+#
+# We have the role of an author
+#
# Set defaults for authors
my ($top,$bottom) = ('con-','struct');
my $action = "go('/priv/".$env{'user.name'}."');";
@@ -481,6 +500,11 @@
$noeditbutton = 0;
}
}
+#
+# We are an author for some stuff, but currently do not have the role of author.
+# Figure out if we have authoring privileges for the resource we are looking at.
+# This should maybe become a privilege check in lonnet
+#
##
## Determine if user can edit url.
##
@@ -539,6 +563,9 @@
# Prepare the rest of the buttons
my $menuitems;
if ($const_space) {
+#
+# We are in construction space
+#
my ($uname,$thisdisfn) =
($env{'request.filename'}=~m|^/home/([^/]+)/public_html/(.*)|);
my $currdir = '/priv/'.$uname.'/'.$thisdisfn;
@@ -548,6 +575,9 @@
$currdir =~ s|[^/]+$||;
my $cleandisfn = &Apache::loncommon::escape_single($thisdisfn);
my $esc_currdir = &Apache::loncommon::escape_single($currdir);
+#
+# Probably should be in mydesk.tab
+#
$menuitems=(<<ENDMENUITEMS);
s&6&1&list.gif&list[_1]&dir[_1]&golist('$esc_currdir')&List current directory
s&6&2&rtrv.gif&retrieve[_1]&version[_1]&gocstr('/adm/retrieve','/~$uname/$cleandisfn')&Retrieve old version
@@ -558,6 +588,10 @@
}
} elsif ( defined($env{'request.course.id'}) &&
$env{'request.symb'} ne '' ) {
+#
+# We are in a course and looking at a registred URL
+# Should probably be in mydesk.tab
+#
$menuitems=(<<ENDMENUITEMS);
c&3&1
s&2&1&back.gif&backward[_1]&&gopost('/adm/flip','back:'+currentURL)&Go to the previous resource in the course sequence&&1
@@ -1005,7 +1039,7 @@
&Apache::loncommon::lonhttpdurl('/res/adm/pages/'.$img).
'" align="'.($nobreak==3?'right':'left').'" class="LC_noBorder" />';
if ($env{'browser.interface'} eq 'faketextual') {
-# Accessibility
+# Main Menu
if ($nobreak==3) {
$inlineremote[$idx]="\n".
'<td class="LC_menubuttons_text" align="right">'.$text.
@@ -1092,6 +1126,11 @@
}
sub rawconfig {
+#
+# This evaluates mydesk.tab
+# Need to add more positions and more privileges to deal with all
+# menu items.
+#
my $textualoverride=shift;
my $output='';
unless ($env{'environment.remote'} eq 'off') {
@@ -1126,9 +1165,12 @@
$prt=~s/\$requested_domain/$requested_domain/g;
if ($category_names{$cat}!~/\w/) { $cat='oth'; }
my $type = &Apache::loncommon::course_type();
- if ($type eq 'Group') {
- $desc = &convert_menu_function($desc,$type);
- }
+#
+# I don't think we support this
+#
+# if ($type eq 'Group') {
+# $desc = &convert_menu_function($desc,$type);
+# }
if ($pro eq 'clear') {
$output.=&clear($row,$col);
} elsif ($pro eq 'any') {
@@ -1498,18 +1540,21 @@
return $navstatus;
}
-#FIXME this needs to move into mydesktab and the other locations
+#FIXME this needs to move into mydesk.tab and the other locations
# the text is generated
-sub convert_menu_function {
- my ($rolename,$type) = @_;
- if ($type eq 'Group') {
- $rolename =~ s/student/member/g;
- $rolename =~ s/group/team/g;
- $rolename =~ s/course/group/g;
- $rolename =~ s/Course/Group/g;
- }
- return $rolename;
-}
+#
+# We currently do not support this anyway.
+#
+#sub convert_menu_function {
+# my ($rolename,$type) = @_;
+# if ($type eq 'Group') {
+# $rolename =~ s/student/member/g;
+# $rolename =~ s/group/team/g;
+# $rolename =~ s/course/group/g;
+# $rolename =~ s/Course/Group/g;
+# }
+# return $rolename;
+#}
sub hidden_button_check {
my $hidden;