File:  [LON-CAPA] / loncom / interface / lonmainmenu.pm
Revision 1.8.4.9: download - view: text, annotated - select for diffs
Thu Oct 7 15:25:08 2010 UTC (13 years, 7 months ago) by raeburn
Branches: GCI_3
Diff to branchpoint 1.8: preferred, unified
- Customization for GCI_3.
  - Don't redirect to Course Contents unless in course.
  - Expired roles excluded from role count.

    1: # The LearningOnline Network with CAPA
    2: # displays the main menu
    3: #
    4: # $Id: lonmainmenu.pm,v 1.8.4.9 2010/10/07 15:25:08 raeburn Exp $
    5: #
    6: # Copyright Michigan State University Board of Trustees
    7: #
    8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
    9: #
   10: # LON-CAPA is free software; you can redistribute it and/or modify
   11: # it under the terms of the GNU General Public License as published by
   12: # the Free Software Foundation; either version 2 of the License, or
   13: # (at your option) any later version.
   14: #
   15: # LON-CAPA is distributed in the hope that it will be useful,
   16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   18: # GNU General Public License for more details.
   19: #
   20: # You should have received a copy of the GNU General Public License
   21: # along with LON-CAPA; if not, write to the Free Software
   22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   23: #
   24: # /home/httpd/html/adm/gpl.txt
   25: #
   26: # http://www.lon-capa.org/
   27: #
   28: #
   29: # There are two parameters controlling the action of this module:
   30: #
   31: # browser.interface - if this is 'textual', it overrides the second parameter
   32: # and goes to screen reader PDA mode
   33: #
   34: # environment.remote - if this is 'on', the routines controll the remote
   35: # control, otherwise they render the main window controls; ignored it
   36: # browser.interface is 'textual'
   37: #
   38: 
   39: package Apache::lonmainmenu;
   40: 
   41: use strict;
   42: use Apache::Constants qw(:common);
   43: use Apache::loncommon();
   44: use Apache::lonnet;
   45: use Apache::lonmenu();
   46: use Apache::lonlocal;
   47: use LONCAPA qw(:DEFAULT :match);
   48: 
   49: sub handler {
   50:     my $r = shift;
   51:     &Apache::loncommon::no_cache($r);
   52:     &Apache::loncommon::content_type($r,'text/html');
   53:     $r->send_http_header;
   54:     return OK if $r->header_only;
   55: 
   56:     my $custommenu = &Apache::loncommon::needs_gci_custom();
   57:     my $cid = $env{'request.course.id'};
   58:     my %gcicourses = (
   59:                        gci_9615072b469884921gcil1 => 'review',
   60:                        gci_1H96711d710194bfegcil1 => 'submit',
   61:                        gci_5422913620b814c90gcil1 => 'tutorial',
   62:                      );
   63:     if (($custommenu && $cid ne '' && ($gcicourses{$cid} || $env{'request.role'} !~ m{^cc\./gcitest/})) || 
   64:         ($cid ne '' && $env{'user.domain'} eq 'gcitest')) {
   65:         $r->internal_redirect('/adm/navmaps');
   66:         return OK;
   67:     }
   68: 
   69:     my $form; 
   70:     if ($env{'environment.remote'} ne 'off') {
   71: 	$form=&Apache::lonmenu::serverform();
   72:     }
   73: 
   74:     my $script_tag;
   75:     if ($env{'environment.remote'} ne 'off') {
   76:         my $utility=&Apache::lonmenu::utilityfunctions('/adm/menu');
   77:         $script_tag=(<<ENDSCRIPT);
   78: <script type="text/javascript">
   79: $utility
   80: </script>
   81: ENDSCRIPT
   82:     }
   83: # ---- Print the screen, pretend to be in text mode to generate text-based menu
   84: # temporarily set interface to "faketextual" and remote to "off", which renders
   85: # the main menu
   86:     $env{'browser.interface'}='faketextual';
   87:     $env{'environment.remote'}='off';
   88: 
   89:     # Breadcrumbs
   90:     my $args;
   91:     unless ($custommenu && !$env{'request.course.id'}) {
   92:         my $brcrum = [];
   93:         $args = {bread_crumbs => $brcrum};
   94:     }
   95:     $r->print(&Apache::loncommon::start_page('Main Menu',$script_tag,$args));
   96: 
   97:     my ($rolecount,$numcourses) = (0,0);
   98:     my $now = time;
   99:     unless (($custommenu) || ($env{'user.domain'} eq 'gcitest')) {
  100:        foreach my $envkey (keys(%env)) {
  101:           next unless ($envkey =~ /^user\.role\./);
  102:           my ($start,$end) = split(/\./,$env{$envkey});
  103:           if (($start eq '' || $start <= $now) && ($end eq '' || $end > $now)) { 
  104:               $rolecount ++;
  105:           }
  106:        }
  107:     }
  108:     if ($custommenu) {
  109:         $r->print(&Apache::lonmenu::inlinemenu('gcicustom').$form);
  110:     } elsif (!$rolecount) {
  111:         $r->print(&Apache::lonmenu::inlinemenu('gcinorole').$form);
  112:     } else {
  113:         $r->print(&Apache::lonmenu::inlinemenu().$form);
  114:     }
  115:     $r->print(&Apache::loncommon::end_page());
  116:     return OK;
  117: }
  118: 
  119: 1;
  120: __END__
  121: 
  122: 
  123: 
  124: 
  125: 
  126: 
  127: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>