Annotation of loncom/interface/lonmainmenu.pm, revision 1.8.4.12
1.1 albertel 1: # The LearningOnline Network with CAPA
2: # displays the main menu
3: #
1.8.4.12! raeburn 4: # $Id: lonmainmenu.pm,v 1.8.4.11 2010/12/05 16:39:33 raeburn Exp $
1.1 albertel 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();
1.2 albertel 44: use Apache::lonnet;
45: use Apache::lonmenu();
1.8.4.1 raeburn 46: use Apache::lonlocal;
47: use LONCAPA qw(:DEFAULT :match);
1.1 albertel 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:
1.8.4.8 raeburn 56: my $custommenu = &Apache::loncommon::needs_gci_custom();
57: my $cid = $env{'request.course.id'};
1.8.4.11 raeburn 58:
59: my %cicourses;
60: my $udom = $env{'user.domain'};
61: my %allnums = &Apache::loncommon::get_faculty_cnums();
1.8.4.12! raeburn 62: if (($udom ne '') && (ref($allnums{$udom}) eq 'HASH')) {
1.8.4.11 raeburn 63: foreach my $key (%{$allnums{$udom}}) {
64: $cicourses{$udom.'_'.$key} = $allnums{$udom}->{$key};
65: }
66: }
67:
68: if (($custommenu && $cid ne '' && ($cicourses{$cid} || $env{'request.role'} !~ m{^cc\./\Q$udom\Etest/})) ||
69: ($cid ne '' && $env{'user.domain'} =~ /^\w+citest$/)) {
1.8.4.8 raeburn 70: $r->internal_redirect('/adm/navmaps');
71: return OK;
72: }
73:
74: my $form;
1.7 www 75: if ($env{'environment.remote'} ne 'off') {
1.1 albertel 76: $form=&Apache::lonmenu::serverform();
77: }
1.3 albertel 78:
1.8.4.8 raeburn 79: my $script_tag;
1.1 albertel 80: if ($env{'environment.remote'} ne 'off') {
81: my $utility=&Apache::lonmenu::utilityfunctions('/adm/menu');
82: $script_tag=(<<ENDSCRIPT);
83: <script type="text/javascript">
84: $utility
85: </script>
86: ENDSCRIPT
87: }
88: # ---- Print the screen, pretend to be in text mode to generate text-based menu
1.8 www 89: # temporarily set interface to "faketextual" and remote to "off", which renders
90: # the main menu
1.7 www 91: $env{'browser.interface'}='faketextual';
92: $env{'environment.remote'}='off';
93:
1.8.4.8 raeburn 94: # Breadcrumbs
1.8.4.10 raeburn 95: my ($nocrumbs,$args);
96: if ($custommenu) {
97: if ($env{'request.course.id'}) {
1.8.4.11 raeburn 98: unless ($cicourses{$env{'request.course.id'}}) {
1.8.4.10 raeburn 99: $nocrumbs = 1;
100: }
101: } else {
102: $nocrumbs = 1;
103: }
104: }
105: unless ($nocrumbs) {
1.8.4.8 raeburn 106: my $brcrum = [];
107: $args = {bread_crumbs => $brcrum};
108: }
109: $r->print(&Apache::loncommon::start_page('Main Menu',$script_tag,$args));
110:
111: my ($rolecount,$numcourses) = (0,0);
1.8.4.9 raeburn 112: my $now = time;
1.8.4.11 raeburn 113: unless (($custommenu) || ($env{'user.domain'} =~ /^\w+citest$/)) {
1.8.4.7 raeburn 114: foreach my $envkey (keys(%env)) {
115: next unless ($envkey =~ /^user\.role\./);
1.8.4.9 raeburn 116: my ($start,$end) = split(/\./,$env{$envkey});
117: if (($start eq '' || $start <= $now) && ($end eq '' || $end > $now)) {
118: $rolecount ++;
119: }
1.8.4.7 raeburn 120: }
121: }
1.8.4.1 raeburn 122: if ($custommenu) {
1.8.4.8 raeburn 123: $r->print(&Apache::lonmenu::inlinemenu('gcicustom').$form);
1.8.4.7 raeburn 124: } elsif (!$rolecount) {
125: $r->print(&Apache::lonmenu::inlinemenu('gcinorole').$form);
1.8.4.1 raeburn 126: } else {
127: $r->print(&Apache::lonmenu::inlinemenu().$form);
128: }
1.1 albertel 129: $r->print(&Apache::loncommon::end_page());
130: return OK;
131: }
132:
133: 1;
134: __END__
135:
136:
137:
138:
139:
140:
141:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>