--- loncom/interface/lonmenu.pm 2010/11/08 22:51:23 1.309.2.18
+++ 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.309.2.18 2010/11/08 22:51:23 raeburn 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()
@@ -131,7 +195,6 @@ use Apache::lonhtmlcommon();
use Apache::loncommon();
use Apache::lonenc();
use Apache::lonlocal;
-use Apache::loncoursequeueadmin;
use LONCAPA qw(:DEFAULT :match);
use HTML::Entities();
@@ -164,8 +227,6 @@ sub prep_menuitem {
# entries from mydesk.tab
sub primary_menu {
my $menu;
- my $custommenu = &Apache::loncommon::needs_gci_custom();
- my $numdc = &Apache::loncommon::check_for_gci_dc();
# each element of @primary contains following array:
# (link url, icon path, alt text, link text, condition)
foreach my $menuitem (@primary_menu) {
@@ -181,17 +242,6 @@ sub primary_menu {
next if $$menuitem[4] eq 'onlypublic'# hide links which are
&& $env{'user.name'} ne 'public' # only visible to public
&& $env{'user.domain'} ne 'public'; # users
- next if $$menuitem[4] eq 'gci'
- && (!$custommenu || $env{'request.role'} =~ m{^st\./gcitest/});
- next if $$menuitem[4] eq 'home'
- && (($custommenu) || ($env{'user.domain'} eq 'gcitest') ||
- (($env{'user.domain'} eq 'gci') && !$numdc));
- next if $$menuitem[4] eq 'gcitest'
- && (($env{'user.domain'} eq 'gci') || ($env{'request.role'} eq 'cm'));
- next if $$menuitem[4] eq 'roles' # hide links which are
- && $custommenu; # not visible when GCI
- next if $$menuitem[4] eq 'courses' # tabbed interface in use
- && $custommenu; #
next if $$menuitem[4] eq 'roles' ##show links depending on
&& &Apache::loncommon::show_course(); ##term 'Courses' or
next if $$menuitem[4] eq 'courses' ##'Roles' wanted
@@ -224,16 +274,10 @@ sub secondary_menu {
$env{'user.domain'}, $env{'user.name'},
$env{'course.' . $env{'request.course.id'} . '.domain'},
$env{'course.' . $env{'request.course.id'} . '.num'});
- my $custommenu = &Apache::loncommon::needs_gci_custom();
- my $numdc = &Apache::loncommon::check_for_gci_dc();
- my $role = $env{'request.role'};
foreach my $menuitem (@secondary_menu) {
# evaluate conditions
next if ref($menuitem) ne 'ARRAY';
- next if $$menuitem[4] eq 'showmenu'
- && ($custommenu || (!$numdc && $role eq 'cm'));
- next if $$menuitem[4] ne 'showmenu'
- && $$menuitem[4] ne 'author'
+ next if $$menuitem[4] ne 'always'
&& !$env{'request.course.id'};
next if $$menuitem[4] eq 'showreturn'
&& !$showlink
@@ -255,9 +299,8 @@ sub secondary_menu {
next if $$menuitem[4] =~ /showgroups$/
&& !$canviewgrps
&& !%groups;
- next if $$menuitem[4] eq 'showroles'
- && ($custommenu || !$numdc || ($numdc && $env{'request.noversionuri'} eq '/adm/roles'));
- if ($$menuitem[3] eq 'Roles' && $env{'request.course.id'} && !$custommenu) {
+
+ if ($$menuitem[3] eq 'Roles' && $env{'request.course.id'}) {
# special treatment for role selector
my $roles_selector = &roles_selector(
$env{'course.' . $env{'request.course.id'} . '.domain'},
@@ -301,51 +344,6 @@ sub secondary_menu {
return "
";
}
-sub gci_secondary_menu {
- my %courses = (
- 'review' => 'gci_9615072b469884921gcil1',
- 'submit' => 'gci_1H96711d710194bfegcil1',
- 'tutorial' => 'gci_5422913620b814c90gcil1',
- );
- my %linktext = (
- 'review' => 'Review Questions',
- 'submit' => 'Submit Questions',
- 'managetest' => 'Manage Tests',
- 'tutorial' => 'Tutorials',
- );
- my %links = (
- 'managetest' => '/adm/menu',
- );
- my $current = 'managetest';
- if ($env{'form.destinationurl'} eq '/adm/gci_info') {
- undef($current);
- }
- foreach my $key (keys(%courses)) {
- $links{$key} = "javascript:switchpage('$key');";
- if ($env{'request.course.id'} eq $courses{$key}) {
- if ($env{'environment.remotenavmap'} eq 'on') {
- $links{$key} = "javascript:gonav('/adm/navmaps')";
- } else {
- $links{$key} = '/adm/navmaps';
- }
- $current = $key;
- $links{'managetest'} = '/adm/roles?selectrole=1&cm=1&orgurl=%2fadm%2fmenu';
- }
- }
- my @menutabs = ('review','submit','managetest','tutorial');
- my $tabs;
- foreach my $item (@menutabs) {
- if ($item eq $current) {
- $tabs .= ''.
- $linktext{$item}.'';
- } else {
- $tabs .= ''.
- $linktext{$item}.'';
- }
- }
- return '
';
-}
#
# This routine returns a translated hash for the menu items in the top inline menu row
@@ -359,7 +357,7 @@ 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',
@@ -539,11 +537,6 @@ ENDINLINEMENU
}
sub show_return_link {
- return unless ($env{'request.course.id'});
- if (($env{'request.noversionuri'} =~ m{^/adm/(viewclasslist|navmaps)($|\?)})
- || ($env{'request.noversionuri'} =~ m{^/adm/.*/aboutme($|\?)})) {
- return if ($env{'form.register'});
- }
return (($env{'request.noversionuri'}=~m{^/(res|public)/} &&
$env{'request.symb'} eq '')
||
@@ -552,7 +545,7 @@ sub show_return_link {
(($env{'request.noversionuri'}=~/^\/adm\//) &&
($env{'request.noversionuri'}!~/^\/adm\/wrapper\//) &&
($env{'request.noversionuri'}!~
- m[^/adm/.*/(smppg|bulletinboard)($|\?)])
+ m[^/adm/.*/(smppg|bulletinboard|aboutme)($|\?)])
));
}
@@ -625,17 +618,9 @@ sub innerregister {
} else {
$contentstext = &mt('Course Contents');
}
- my @crumbs;
- unless (($forcereg) && ($env{'request.noversionuri'} eq '/adm/navmaps')
- && ($mapurl eq $env{'course.'.$env{'request.course.id'}.'.url'})) {
- my $link = "javascript:gopost('/adm/navmaps','')";
- if ($env{'environment.remotenavmap'} eq 'on') {
- $link = "javascript:gonav('/adm/navmaps','')"
- }
- @crumbs = ({text => Apache::loncommon::course_type()
- . ' Contents',
- href => $link});
- }
+ my @crumbs = ({text => $contentstext,
+ href => "Javascript:gonav('/adm/navmaps')"});
+
if ($mapurl ne $env{'course.'.$env{'request.course.id'}.'.url'}) {
push(@crumbs, {text => '...',
no_mt => 1});
@@ -879,7 +864,7 @@ $menuitems.="Make notes and annotations
"&go('/adm/requestcourse')&Course requests\n";
}
}
- unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme|portfolio)(\?|$)/) {
+ unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme)(\?|$)/) {
if ((!$env{'request.enc'}) && ($env{'request.noversionuri'} !~ m{^/adm/wrapper/ext/})) {
$menuitems.=(<
@@ -1405,172 +1388,36 @@ sub openmenu {
}
sub inlinemenu {
- my ($context) = @_;
undef(@inlineremote);
undef(%category_members);
- my $output;
- if ($context eq 'gcicustom') {
- my (%can_request,%request_domains,$canreq,$createtext);
- my $role = 'st';
- my $custommenu = &Apache::loncommon::needs_gci_custom();
- if ($custommenu) {
- $role = 'cc';
- }
- my %courses = &Apache::loncommon::existing_gcitest_courses($role);
- my $numcourses = keys(%courses);
- my ($switcher_js,$switcher);
- my $formname = 'testpicker';
- if ($numcourses > 0) {
- $switcher = &Apache::loncommon::gcitest_switcher($role,$formname,%courses);
- my $current;
- my $cid = $env{'request.course.id'};
- if ($cid) {
- $current = $role.'./'.$env{'course.'.$cid.'.domain'}.
- '/'.$env{'course.'.$cid.'.num'};
- }
- $switcher_js = &Apache::loncommon::gcitest_switcher_js($current,$numcourses,$formname);
- if ($switcher_js) {
- $switcher_js= <<"ENDSCRIPT";
-
-
-ENDSCRIPT
- }
- $switcher = $switcher_js.$switcher;
- }
- if ($env{'user.domain'} eq 'gci') {
- $canreq =
- &Apache::lonnet::check_can_request('gcitest',\%can_request,\%request_domains);
- $createtext = &mt('Create Concept Test');
- if ($numcourses) {
- $createtext = &mt('Create New Test');
- }
- }
- if ($env{'request.course.id'}) {
- if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
- my $navlink;
- if ($env{'environment.remotenavmap'} eq 'on') {
- $navlink = "javascript:gonav('/adm/navmaps')";
- } else {
- $navlink = '/adm/navmaps';
- }
- $output .=
- '
';
- } else {
- my $navtext = &mt('Table of Contents');
- my $navdesc = &mt('Display Table of Contents for Geoscience Concept Inventory');
- if ($env{'request.role.domain'} eq 'gcitest') {
- $navtext = &mt('Display Test Contents');
- $navdesc = &mt('Display the table of contents for this Concept Test');
- }
- my $navlink;
- if ($env{'environment.remotenavmap'} eq 'on') {
- $navlink = "javascript:gonav('/adm/navmaps');"
- } else {
- $navlink = '/adm/navmaps';
- }
- $output .=
- '
';
- }
- } elsif ($switcher || $canreq) {
- $output .= '
'.
- '
';
- }
- } elsif ($context eq 'gcinorole') {
- my $queued = &Apache::loncoursequeueadmin::queued_selfenrollment('notitle');
- if ($queued) {
- $output .=
- ''.
- '
'.&mt('Pending Enrollment Requests').'
'.
- $queued.
- '';
- }
- } else {
- # calling rawconfig with "1" will evaluate mydesk.tab,
- # even if there is no active remote control
- &rawconfig(1);
- $output='';
- for (my $col=1; $col<=2; $col++) {
- $output.='';
- for (my $row=1; $row<=8; $row++) {
- foreach my $cat (keys(%category_members)) {
- if ($category_positions{$cat} ne "$col,$row") { next; }
- $output.='';
- $output.=' '.&mt($category_names{$cat}).'';
- $output.=' ';
- my %active=();
- foreach my $menu_item (split(/\:/,$category_members{$cat})) {
- if ($inlineremote[$menu_item]) {
- $active{$menu_item}=1;
- }
- }
- foreach my $item (sort(keys(%active))) {
- $output.=$inlineremote[$item];
- }
- $output.=' ';
- $output.=' ';
- }
+# calling rawconfig with "1" will evaluate mydesk.tab, even if there is no active remote control
+ &rawconfig(1);
+ my $output='';
+ for (my $col=1; $col<=2; $col++) {
+ $output.='';
+ for (my $row=1; $row<=8; $row++) {
+ foreach my $cat (keys(%category_members)) {
+ if ($category_positions{$cat} ne "$col,$row") { next; }
+ #$output.=' ';
+ $output.='';
+ $output.=' '.&mt($category_names{$cat}).'';
+ $output.=' ';
+ my %active=();
+ foreach my $menu_item (split(/\:/,$category_members{$cat})) {
+ if ($inlineremote[$menu_item]) {
+ $active{$menu_item}=1;
+ }
+ }
+ foreach my $item (sort(keys(%active))) {
+ $output.=$inlineremote[$item];
+ }
+ $output.=' ';
+ $output.=' ';
}
- $output.="";
- }
- $output.=" ";
+ }
+ $output.=" | ";
}
+ $output.=" ";
return $output;
}
@@ -1865,54 +1712,11 @@ END
}
sub utilityfunctions {
- my ($caller,$custommenu) = @_;
+ my $caller = shift;
unless ($env{'environment.remote'} eq 'off' ||
$caller eq '/adm/menu') {
return ''; }
-
- my $gcimenujs;
- if ($custommenu) {
- my %concepttests = &Apache::loncommon::existing_gcitest_courses('cc');
- my $managetesturl = '/adm/menu';
- my $createtesturl = '/adm/requestcourse';
- if (($env{'request.course.id'}) &&
- ($env{'course.'.$env{'request.course.id'}.'.domain'} eq 'gci')) {
- my @items = keys(%concepttests);
- if (@items== 1) {
- my $newrole = $items[0];
- $newrole =~ s{_}{/};
- $managetesturl = '/adm/roles?selectrole=1&cc./'.$newrole.'=1';
- } else {
- $managetesturl = '/adm/roles?selectrole=1&cm=1&orgurl=%2fadm%2fmenu';
- }
- }
- if ($env{'request.course.id'}) {
- $createtesturl = '/adm/roles?selectrole=1&cm=1&orgurl=%2fadm%2frequestcourse';
- }
- $gcimenujs = <<"ENDCUSTOM";
-
-function switchpage(caller) {
- if (caller == 'review') {
- document.location.href = '/adm/roles?selectrole=1&st./gci/9615072b469884921gcil1=1';
- }
- if (caller == 'submit') {
- document.location.href = '/adm/roles?selectrole=1&st./gci/1H96711d710194bfegcil1=1';
- }
- if (caller == 'createtest') {
- document.location.href = '$createtesturl';
- }
- if (caller == 'managetest') {
- document.location.href = '$managetesturl';
- }
- if (caller == 'tutorial') {
- document.location.href = '/adm/roles?selectrole=1&st./gci/5422913620b814c90gcil1=1';
- }
- return;
-}
-
-ENDCUSTOM
- }
-
+
my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));
if ($currenturl =~ m{^/adm/wrapper/ext/}) {
if ($env{'request.external.querystring'}) {
@@ -1960,8 +1764,6 @@ return (< |