--- loncom/interface/lonmenu.pm 2012/05/28 13:09:16 1.378 +++ loncom/interface/lonmenu.pm 2012/10/29 17:38:56 1.388 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.378 2012/05/28 13:09:16 raeburn Exp $ +# $Id: lonmenu.pm,v 1.388 2012/10/29 17:38:56 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -247,9 +247,7 @@ sub primary_menu { my @primsub; if (ref($primary_submenu{$title}) eq 'ARRAY') { foreach my $item (@{$primary_submenu{$title}}) { - next if (($item->[2] eq 'wishlist') && - ((!&Apache::lonnet::allowed('bre',"/res/$env{'user.domain'}/")) && - (!&Apache::lonnet::allowed('bro',"/res/$env{'user.domain'}/")))); + 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')) && @@ -395,15 +393,21 @@ sub secondary_menu { } $menu =~ s/\[uname\]/$$author{user}/g; $menu =~ s/\[udom\]/$$author{dom}/g; - - return ""; + if ($menu) { + $menu = ""; + } + return $menu; } 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). ''. ' ▼'. @@ -583,7 +587,7 @@ sub innerregister { # Check that the user has permission to edit this resource my $setpriv = 1; - ($cfuname,$cfudom)=&Apache::loncacc::constructaccess($file,$setpriv); + ($cfuname,$cfudom)=&Apache::lonnet::constructaccess($file,$setpriv); if (defined($cfudom)) { $home=&Apache::lonnet::homeserver($cfuname,$cfudom); my $allowed=0; @@ -659,7 +663,7 @@ sub innerregister { ### ### # Prepare the rest of the buttons - my $menuitems; + my ($menuitems,$got_prt,$got_wishlist); if ($const_space) { # # We are in construction space @@ -695,7 +699,7 @@ ENDMENUITEMS } elsif ( defined($env{'request.course.id'}) && $env{'request.symb'} ne '' ) { # -# We are in a course and looking at a registred URL +# We are in a course and looking at a registered URL # Should probably be in mydesk.tab # $menuitems=(<'.&Apache::lonnet::plaintext($role).''; } } - $role_selector .= ''."\n". + $role_selector .= ''."\n"; + if ($destsymb ne '') { + $role_selector .= ''."\n"; + } + $role_selector .= ''."\n". ''."\n". @@ -1807,13 +1843,44 @@ sub required_privs { sub countdown_timer { if (($env{'request.course.id'}) && ($env{'request.symb'} ne '') && - ($env{'request.filename'}=~/$LONCAPA::assess_re/) && - ($Apache::inputtags::status[-1] eq 'CAN_ANSWER')) { + ($env{'request.filename'}=~/$LONCAPA::assess_re/)) { + my ($type,$hastimeleft,$slothastime); + my $now = time; + if ($env{'request.filename'} =~ /\.task$/) { + $type = 'Task'; + } else { + $type = 'problem'; + } + my ($status,$accessmsg,$slot_name,$slot) = + &Apache::lonhomework::check_slot_access('0',$type); + if ($slot_name ne '') { + if (ref($slot) eq 'HASH') { + if (($slot->{'starttime'} < $now) && + ($slot->{'endtime'} > $now)) { + $slothastime = 1; + } + } + } + if ($status ne 'CAN_ANSWER') { + return; + } my $duedate = &Apache::lonnet::EXT("resource.0.duedate"); - if ($duedate && $duedate > time) { - my ($collapse,$expand,$title,$currdisp); - my @interval=&Apache::lonnet::EXT("resource.0.interval"); - if (@interval > 1) { + my @interval=&Apache::lonnet::EXT("resource.0.interval"); + my $hastimeleft; + if (@interval > 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) || + ($slot_name ne '' && $slothastime)) { + my ($collapse,$expand,$alttxt,$title,$currdisp); + if ((@interval > 1 && $hastimeleft) || + ($type eq 'Task' && $slothastime)) { $currdisp = 'inline'; $collapse = '► '; } else { @@ -1821,7 +1888,8 @@ sub countdown_timer { $expand = '◄ '; } unless ($env{'environment.icons'} eq 'iconsonly') { - $title = &mt('Timer'); + $alttxt = &mt('Timer'); + $title = $alttxt.' '; } my $desc = &mt('Countdown to due date/time'); return < $collapse - + $expand -$title +$alttxt$title END } }