--- loncom/interface/lonmenu.pm 2012/05/24 23:36:17 1.369.2.6 +++ loncom/interface/lonmenu.pm 2012/08/03 01:37:23 1.369.2.16 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.369.2.6 2012/05/24 23:36:17 raeburn Exp $ +# $Id: lonmenu.pm,v 1.369.2.16 2012/08/03 01:37:23 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -179,6 +179,7 @@ use Apache::lonlocal; use Apache::lonmsg(); use LONCAPA qw(:DEFAULT :match); 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); @@ -246,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')) && @@ -259,7 +258,7 @@ sub primary_menu { if (@primsub > 0) { $menu .= &create_submenu($link,$target,$title,\@primsub); } elsif ($link) { - $menu .= '
  • '.$title.'
  • '; + $menu .= '
  • '.&mt($title).'
  • '; } } } elsif ($$menuitem[3] eq 'Help') { # special treatment for helplink @@ -389,7 +388,7 @@ sub secondary_menu { if (@scndsub > 0) { $menu .= &create_submenu($link,$target,$title,\@scndsub); } elsif ($link) { - $menu .= '
  • '.$title.'
  • '; + $menu .= '
  • '.&mt($title).'
  • '; } } } elsif ($$menuitem[3] eq 'Roles' && $env{'request.course.id'}) { @@ -431,9 +430,13 @@ sub secondary_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 = '
  • '. - ''. - ''.$title. + ''. + ''.&mt($title). ''. ' ▼'. '
  • '; @@ -689,7 +691,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 @@ -725,7 +727,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=(<'.$pic.''; + } else { + $inlineremote[$idx] = ''.$pic. ''.$top.' '; + } } return ''; } @@ -1378,6 +1423,27 @@ 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/} @@ -1406,21 +1472,14 @@ sub utilityfunctions { my $end_page_annotate = &Apache::loncommon::end_page({'js_ready' => 1}); - my $start_page_bookmark = - &Apache::loncommon::start_page('Bookmarks',undef, - {'only_body' => 1, - 'js_ready' => 1, - 'bgcolor' => '#BBBBBB',}); - - my $end_page_bookmark = - &Apache::loncommon::end_page({'js_ready' => 1}); - my $confirm_switch = &mt("Editing requires switching to the resource's home server.").'\n'. &mt('Switch server?'); my $esc_url=&escape($currenturl); my $esc_symb=&escape($currentsymb); + my $countdown = &countdown_toggle_js(); + return (<
    ' - +'
    Link Name:
    ' - +'
    Address:

    ' - +'$end_page_bookmark' ); - bmquery.document.close(); -} +$countdown ENDUTILITY } @@ -1985,6 +2030,52 @@ sub required_privs { return $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')) { + my $duedate = &Apache::lonnet::EXT("resource.0.duedate"); + 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)) { + 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 < + +$collapse + + + +$expand +$alttxt$title +END + } + } + return; +} + # ================================================================ Main Program BEGIN {