--- loncom/interface/lonmenu.pm 2012/08/03 01:37:23 1.369.2.16
+++ loncom/interface/lonmenu.pm 2012/05/22 11:18:26 1.373
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines to control the menu
#
-# $Id: lonmenu.pm,v 1.369.2.16 2012/08/03 01:37:23 raeburn Exp $
+# $Id: lonmenu.pm,v 1.373 2012/05/22 11:18:26 bisitz Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -115,18 +115,6 @@ entries from mydesk.tab
Same as primary_menu() but operates on @secondary_menu.
-=item create_submenu()
-
-Creates XHTML for unordered list of sub-menu items which belong to a
-particular top-level menu item. Uses hover pseudo class in css to display
-dropdown list when mouse hovers over top-level item. Support for IE6
-(no hover psuedo class) via LC_hoverable class for
tag for top-
-level item, which employs jQuery to handle behavior on mouseover.
-
-Inputs: 4 - (a) link and (b) target for anchor href in top level item,
- (c) title for text wrapped by anchor tag in top level item.
- (d) reference to array of arrays of sub-menu items.
-
=item innerregister()
This gets called in order to register a URL in the body of the document
@@ -182,7 +170,7 @@ use HTML::Entities();
use Apache::lonwishlist();
use vars qw(@desklines %category_names %category_members %category_positions
- $readdesk @primary_menu %primary_submenu @secondary_menu %secondary_submenu);
+ $readdesk @primary_menu %primary_submenu @secondary_menu);
my @inlineremote;
@@ -237,30 +225,51 @@ sub primary_menu {
my $title = $menuitem->[3];
if (defined($primary_submenu{$title})) {
- my ($link,$target);
+ my ($link,$target,$numsub);
if ($menuitem->[0] ne '') {
$link = $menuitem->[0];
$target = '_top';
} else {
$link = '#';
}
- my @primsub;
if (ref($primary_submenu{$title}) eq 'ARRAY') {
- foreach my $item (@{$primary_submenu{$title}}) {
- next if (($item->[2] eq 'wishlist') && (!$env{'user.adv'}));
- next if (($item->[2] eq 'reqcrs') && (!&check_for_rcrs()));
- next if ((($item->[2] eq 'portfolio') ||
- ($item->[2] eq 'blog')) &&
- (!&Apache::lonnet::usertools_access('','',$item->[2],
- undef,'tools')));
- push(@primsub,$item);
- }
- if (@primsub > 0) {
- $menu .= &create_submenu($link,$target,$title,\@primsub);
- } elsif ($link) {
- $menu .= ''.&mt($title).'';
+ $numsub = @{$primary_submenu{$title}};
+ if ($numsub) {
+ $title =
+ ''.&mt($title).
+ ''.
+ '▼';
+ }
+ }
+ $menu .= ''.
+ ''.$title.'';
+ if ($numsub) {
+ $menu .= '';
+ foreach my $item (@{$primary_submenu{$menuitem->[3]}}) {
+ if (ref($item) eq 'ARRAY') {
+ if ($item->[2] eq 'wishlist') {
+ next unless ((&Apache::lonnet::allowed('bre',"/res/$env{'user.domain'}/")) ||
+ (&Apache::lonnet::allowed('bro',"/res/$env{'user.domain'}/")));
+ } elsif ($item->[2] eq 'reqcrs') {
+ next unless(&check_for_rcrs());
+ } elsif (($item->[2] eq 'portfolio') ||
+ ($item->[2] eq 'blog')) {
+ if (!&Apache::lonnet::usertools_access(
+ $env{'user.name'},
+ $env{'user.domain'},
+ $item->[2],undef,'tools')) {
+ next;
+ }
+ }
+ $menu .= '- '.
+ ''.
+ &mt($item->[1]).'
';
+ }
}
+ $menu .= '
';
}
+ $menu .= '';
} elsif ($$menuitem[3] eq 'Help') { # special treatment for helplink
if ($public) {
my $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
@@ -317,13 +326,12 @@ sub secondary_menu {
? "/$env{'request.course.sec'}"
: '');
my $canedit = &Apache::lonnet::allowed('mdc', $env{'request.course.id'});
- my $canviewroster = $env{'course.'.$env{'request.course.id'}.'.student_classlist_view'};
- my $canviewgrps = &Apache::lonnet::allowed('vcg', $crs_sec);
- my $canmodifyuser = &Apache::lonnet::allowed('cst', $crs_sec);
- my $canviewwnew = &Apache::lonnet::allowed('whn', $crs_sec);
+ my $canviewgrps = &Apache::lonnet::allowed('vcg', $crs_sec);
+ my $canmodifyuser = &Apache::lonnet::allowed('cst', $crs_sec);
+ my $canviewwnew = &Apache::lonnet::allowed('whn', $crs_sec);
my $canmodpara = &Apache::lonnet::allowed('opa', $crs_sec);
my $canvgr = &Apache::lonnet::allowed('vgr', $crs_sec);
- my $canmgr = &Apache::lonnet::allowed('mgr', $crs_sec);
+ my $canmgr = &Apache::lonnet::allowed('mgr', $crs_sec);
my $author = &getauthor();
my %groups = &Apache::lonnet::get_active_groups(
@@ -339,10 +347,6 @@ sub secondary_menu {
&& !$env{'request.course.id'};
next if $$menuitem[4] =~ /^mdc/
&& !$canedit;
- next if $$menuitem[4] eq 'mdcCourse'
- && ($crstype eq 'Community');
- next if $$menuitem[4] eq 'mdcCommunity'
- && ($crstype eq 'Course');
next if $$menuitem[4] eq 'nvgr'
&& $canvgr;
next if $$menuitem[4] eq 'vgr'
@@ -350,7 +354,7 @@ sub secondary_menu {
next if $$menuitem[4] eq 'cst'
&& !$canmodifyuser;
next if $$menuitem[4] eq 'ncst'
- && ($canmodifyuser || !$canviewroster);
+ && $canmodifyuser;
next if $$menuitem[4] eq 'mgr'
&& !$canmgr;
next if $$menuitem[4] eq 'nmgr'
@@ -359,45 +363,19 @@ sub secondary_menu {
&& !$canviewwnew;
next if $$menuitem[4] eq 'opa'
&& !$canmodpara;
- next if $$menuitem[4] eq 'nvcg'
- && ($canviewgrps || !%groups);
+ next if $$menuitem[4] =~ /showgroups$/
+ && !$canviewgrps
+ && !%groups;
next if $$menuitem[4] eq 'author'
&& !$author;
- my $title = $menuitem->[3];
- if (defined($secondary_submenu{$title})) {
- my ($link,$target);
- if ($menuitem->[0] ne '') {
- $link = $menuitem->[0];
- $target = '_top';
- } else {
- $link = '#';
- }
- my @scndsub;
- if (ref($secondary_submenu{$title}) eq 'ARRAY') {
- foreach my $item (@{$secondary_submenu{$title}}) {
- if (ref($item) eq 'ARRAY') {
- next if ($item->[2] eq 'vgr' && !$canvgr);
- next if ($item->[2] eq 'opa' && !$canmodpara);
- next if ($item->[2] eq 'cst' && !$canmodifyuser);
- next if ($item->[2] eq 'mgr' && !$canmgr);
- next if ($item->[2] eq 'vcg' && !$canviewgrps);
- push(@scndsub,$item);
- }
- }
- if (@scndsub > 0) {
- $menu .= &create_submenu($link,$target,$title,\@scndsub);
- } elsif ($link) {
- $menu .= ''.&mt($title).'';
- }
- }
- } elsif ($$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(
$env{'course.' . $env{'request.course.id'} . '.domain'},
$env{'course.' . $env{'request.course.id'} . '.num'} );
- $menu .= $roles_selector ? "$roles_selector"
+ $menu .= $roles_selector ? "$roles_selector"
: '';
} else {
$menu .= &prep_menuitem(\@$menuitem);
@@ -427,37 +405,6 @@ sub secondary_menu {
return "";
}
-sub create_submenu {
- my ($link,$target,$title,$submenu) = @_;
- return unless (ref($submenu) eq 'ARRAY');
- my $disptarget;
- if ($target ne '') {
- $disptarget = ' target="'.$target.'"';
- }
- my $menu = ''.
- ''.
- ''.&mt($title).
- ''.
- ' ▼'.
- '';
- my $count = 0;
- my $numsub = scalar(@{$submenu});
- foreach my $item (@{$submenu}) {
- $count ++;
- if (ref($item) eq 'ARRAY') {
- my $borderbot;
- if ($count == $numsub) {
- $borderbot = 'border-bottom:1px solid black;';
- }
- $menu .= '- '.
- &mt($item->[1]).'
';
- }
- }
- $menu .= '
';
- return $menu;
-}
-
sub innerregister {
my ($forcereg,$bread_crumbs) = @_;
my $const_space = ($env{'request.state'} eq 'construct');
@@ -691,7 +638,7 @@ sub innerregister {
###
###
# Prepare the rest of the buttons
- my ($menuitems,$got_prt,$got_wishlist);
+ my $menuitems;
if ($const_space) {
#
# We are in construction space
@@ -727,7 +674,7 @@ ENDMENUITEMS
} elsif ( defined($env{'request.course.id'}) &&
$env{'request.symb'} ne '' ) {
#
-# We are in a course and looking at a registered URL
+# We are in a course and looking at a registred URL
# Should probably be in mydesk.tab
#
$menuitems=(<');
- }
-#
-# The Remote actually gets launched!
-#
- my $configmenu=&rawconfig();
- my $esclowerurl=&escape($lowerurl);
- my $message=&mt('"Waiting for Remote Control window to load: "+[_1]','waited');
- return(<
-//
-
-ENDREMOTESTARTUP
-}
-
-sub setflags() {
- return(<
-//
-
-ENDSETFLAGS
-}
-
-sub maincall() {
- if ($env{'environment.remote'} eq 'off') { return ''; }
- return(<
-//
-
-ENDMAINCALL
-}
-
-sub load_remote_msg {
- my ($lowerurl)=@_;
-
- if ($env{'environment.remote'} eq 'off') { return ''; }
-
- my $esclowerurl=&escape($lowerurl);
- my $link=&mt('[_1]Continue[_2] on in Inline Menu mode'
- ,''
- ,'');
- return(<
-
-
-$link
-ENDREMOTEFORM
-}
-
-sub get_menu_name {
- my $hostid = $Apache::lonnet::perlvar{'lonHostID'};
- $hostid =~ s/\W//g;
- return 'LCmenu'.$hostid;
-}
-
-
-sub reopenmenu {
- if ($env{'environment.remote'} eq 'off') { return ''; }
- my $menuname = &get_menu_name();
- my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
- return('window.open('.$nothing.',"'.$menuname.'","",false);');
-}
-
-
-sub open {
- my $returnval='';
- if ($env{'environment.remote'} eq 'off') {
- return
- '';
- }
- my $menuname = &get_menu_name();
-
-# unless (shift eq 'unix') {
-# resizing does not work on linux because of virtual desktop sizes
-# $returnval.=(<
-ENDOPEN
- return '';
-}
-
-
# ================================================================== Raw Config
sub clear {
@@ -1103,19 +870,9 @@ sub switch {
}
} else {
# Inline Menu
- my @tools = (93,91,81,82,83);
- unless ($env{'request.state'} eq 'construct') {
- push(@tools,63);
- }
- if (($env{'environment.icons'} eq 'iconsonly') &&
- (grep(/^$idx$/,@tools))) {
- $inlineremote[$idx] =
- '';
- } else {
- $inlineremote[$idx] =
+ $inlineremote[$idx]=
'';
- }
}
return '';
}
@@ -1376,28 +1133,6 @@ sub check_for_rcrs {
return $showreqcrs;
}
-# ======================================================================= Close
-
-sub close {
- if ($env{'environment.remote'} eq 'off') { return ''; }
- my $menuname = &get_menu_name();
- return(<
-//
-
-ENDCLOSE
-}
-
sub dc_popup_js {
my %lt = &Apache::lonlocal::texthash(
more => '(More ...)',
@@ -1423,27 +1158,6 @@ END
}
-sub countdown_toggle_js {
- return <<"END";
-
-function toggleCountdown() {
- var countdownid = document.getElementById('duedatecountdown');
- var currstyle = countdownid.style.display;
- if (currstyle == 'inline') {
- countdownid.style.display = 'none';
- document.getElementById('ddcountcollapse').innerHTML='';
- document.getElementById('ddcountexpand').innerHTML='◄ ';
- } else {
- countdownid.style.display = 'inline';
- document.getElementById('ddcountcollapse').innerHTML='► ';
- document.getElementById('ddcountexpand').innerHTML='';
- }
- return;
-}
-
-END
-}
-
sub utilityfunctions {
my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));
if ($currenturl =~ m{^/adm/wrapper/ext/}
@@ -1478,8 +1192,6 @@ sub utilityfunctions {
my $esc_url=&escape($currenturl);
my $esc_symb=&escape($currentsymb);
- my $countdown = &countdown_toggle_js();
-
return (< 1) {
- my $first_access=&Apache::lonnet::get_first_access($interval[1]);
- if ($first_access > 0) {
- if ($first_access+$interval[0] > time) {
- $hastimeleft = 1;
- }
- }
- }
- if (($duedate && $duedate > time) ||
- (!$duedate && $hastimeleft)) {
- my ($collapse,$expand,$alttxt,$title,$currdisp);
- if (@interval > 1 && $hastimeleft) {
- $currdisp = 'inline';
- $collapse = '► ';
- } else {
- $currdisp = 'none';
- $expand = '◄ ';
- }
- unless ($env{'environment.icons'} eq 'iconsonly') {
- $alttxt = &mt('Timer');
- $title = $alttxt.' ';
- }
- my $desc = &mt('Countdown to due date/time');
- return <