Annotation of loncom/interface/domainstatus.pm, revision 1.2
1.1 raeburn 1: # The LearningOnline Network
2: # Generate a menu page containing links to server status pages accessible
3: # to user.
4: #
1.2 ! raeburn 5: # $Id: domainstatus.pm,v 1.1 2008/12/22 21:13:25 raeburn Exp $
1.1 raeburn 6: #
7: # Copyright Michigan State University Board of Trustees
8: #
9: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
10: #
11: # LON-CAPA is free software; you can redistribute it and/or modify
12: # it under the terms of the GNU General Public License as published by
13: # the Free Software Foundation; either version 2 of the License, or
14: # (at your option) any later version.
15: #
16: # LON-CAPA is distributed in the hope that it will be useful,
17: # but WITHOUT ANY WARRANTY; without even the implied warranty of
18: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19: # GNU General Public License for more details.
20: #
21: # You should have received a copy of the GNU General Public License
22: # along with LON-CAPA; if not, write to the Free Software
23: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24: #
25: # /home/httpd/html/adm/gpl.txt
26: #
27: # http://www.lon-capa.org/
28: #
29: #
30: package Apache::domainstatus;
31:
32: use strict;
33: use Apache::Constants qw(:common);
34: use Apache::lonnet;
35: use Apache::loncommon;
36: use Apache::lonhtmlcommon;
37: use Apache::lonlocal;
1.2 ! raeburn 38: use LONCAPA::lonauthcgi;
1.1 raeburn 39:
40: sub handler {
41: my $r = shift;
42: &Apache::loncommon::content_type($r,'text/html');
43: $r->send_http_header;
44: if ($r->header_only) {
45: return OK;
46: }
47:
48: &Apache::lonlocal::get_language_handle();
49: my $dom = &Apache::lonnet::default_login_domain();
50:
51: if (($env{'user.domain'} ne '') && ($env{'user.domain'} ne 'public')) {
52: $dom = $env{'user.domain'};
53: if ($env{'request.role.domain'} ne '') {
54: $dom = $env{'request.role.domain'};
55: }
56: }
57: my $domdesc = &Apache::lonnet::domain($dom,'description');
58:
59: my %candisplay;
1.2 ! raeburn 60: my $titles = &LONCAPA::lonauthcgi::serverstatus_titles();
1.1 raeburn 61: if (ref($titles) eq 'HASH') {
62: foreach my $page (keys(%{$titles})) {
1.2 ! raeburn 63: if (&LONCAPA::lonauthcgi::can_view($page)) {
1.1 raeburn 64: $candisplay{$page} = 'F';
1.2 ! raeburn 65: } elsif (&LONCAPA::lonauthcgi::check_ipbased_access($page)) {
1.1 raeburn 66: $candisplay{$page} = 'F';
67: }
68: }
69: }
70:
71: &Apache::lonhtmlcommon::clear_breadcrumbs();
72: &Apache::lonhtmlcommon::add_breadcrumb
73: ({href=>"/adm/domainstatus",
74: text=>"Server Status Information"});
75:
76: $r->print(&Apache::loncommon::start_page('Server Status').
77: &Apache::lonhtmlcommon::breadcrumbs('Server Status Information').
78: '<div class="LC_clear_float_header"></div>');
79:
80: if (keys(%candisplay) > 0) {
81: $r->print('<h2>'.&mt('Server Utilities for Domain: [_1]','<i>'.$domdesc.'</i>').
82: '</h2>'.&print_status_menu(\%candisplay));
83: } else {
84: $r->print('<h2>'.&mt('No information available').'</h2>'.
85: '<span class="LC_error">'.&mt('Your current role and/or IP address does not have permission to display information about server status for servers in the domain: [_1].','<b>'.$domdesc.'</b> ('.$dom.')').'</span>');
86: }
87: $r->print(&Apache::loncommon::end_page());
88: return OK;
89: }
90:
91: sub print_status_menu {
92: my ($candisplay) = @_;
93: return '' if (ref($candisplay) ne 'HASH');
94: my $menu_html;
95: my @menu = &servermenu_items($candisplay);
96: foreach my $item (@menu) {
97: if (ref($item) eq 'HASH') {
98: my $display;
99: if (ref($item->{'items'}) eq 'ARRAY') {
100: foreach my $page (@{$item->{'items'}}) {
101: if (ref($page) eq 'HASH') {
102: if ($page->{'permission'} eq 'F') {
103: $display .= '<span class="LC_parm_menu_item">';
104: if ($page->{'help'} ne '') {
105: $display .=
106: &Apache::loncommon::help_open_topic($page->{'help'});
107: }
108: $display .= '<a href="'.$page->{'url'}.'" title="'.
109: &mt($page->{'linktitle'}).'">'.
110: &mt($page->{'linktext'}).
111: '</a></span><br /><br />';
112: }
113: }
114: }
115: }
116: if ($display) {
117: $menu_html .= '<div class="LC_left_float">'.
118: '<h3>'.&mt($item->{'categorytitle'}).'</h3>'.
119: $display.'</div>';
120: }
121: }
122: }
123: if ($menu_html) {
124: $menu_html .= '<div class="LC_clear_float_footer"></div>';
125: }
126: return $menu_html;
127: }
128:
129: sub servermenu_items {
130: my ($candisplay) = @_;
1.2 ! raeburn 131: my $titles = &LONCAPA::lonauthcgi::serverstatus_titles();
1.1 raeburn 132: my $linknames = &serverstatus_links();
133: my @menu;
134: if ((ref($candisplay) eq 'HASH') && (ref($titles) eq 'HASH') &&
135: (ref($linknames) eq 'HASH')) {
136: @menu = ( {categorytitle => 'Status information',
137: items =>
138: [{
139: linktext => $linknames->{'userstatus'},
140: #icon => '',
141: #help => 'Domain_Coordination_Userstatus',
142: url => '/cgi-bin/userstatus.pl',
143: permission => $candisplay->{'userstatus'},
144: linktitle => $titles->{'userstatus'},
145: },
146: {
147: linktext => $linknames->{'lonstatus'},
148: #icon => '',
149: #help => 'Domain_Coordination_Connection_Status',
150: url => '/lon-status/',
151: permission => $candisplay->{'lonstatus'},
152: linktitle => $titles->{'lonstatus'},
153: },
154: {
155: linktext => $linknames->{'server-status'},
156: #icon => '',
157: #help => 'Domain_Coordination_Apache_Status',
158: url => '/server-status',
159: permission => $candisplay->{'server-status'},
160: linktitle => $titles->{'server-status'},
161: },
162: {
163: linktext => $linknames->{'clusterstatus'},
164: #icon => '',
165: #help => 'Domain_Coordination_Apache_Status',
166: url => '/cgi-bin/clusterstatus.pl',
167: permission => $candisplay->{'clusterstatus'},
168: linktitle => $titles->{'clusterstatus'},
169: },
170: {
171: linktext => $linknames->{'codeversions'},
172: #icon => '',
173: #help => 'Domain_Coordination_Code_Versions',
174: url => '/cgi-bin/lonversions.pl',
175: permission => $candisplay->{'codeversions'},
176: linktitle => $titles->{'codeversions'},
177: },
178: {
179: linktext => $linknames->{'showenv'},
180: #icon => '',
181: #help => 'Domain_Coordination_User_Environment',
182: url => '/adm/test',
183: permission => $candisplay->{'showenv'},
184: linktitle => $titles->{'showenv'},
185: }]},
186: {categorytitle => 'Server Actions',
187: items =>
188: [{
189: linktext => $linknames->{'loncron'},
190: #icon => '',
191: #help => 'Domain_Coordination_Connection_Reload',
192: url => '/cgi-bin/loncron.pl',
193: permission => $candisplay->{'loncron'},
194: linktitle => $titles->{'loncron'},
195: },
196: {
197: linktext => $linknames->{'takeoffline'},
198: #icon => '',
199: #help => 'Domain_Coordination_Server_Offline',
200: url => '/cgi-bin/takeoffline.pl',
201: permission => $candisplay->{'takeoffline'},
202: linktitle => $titles->{'takeoffline'},
203: },
204: {
205: linktext => $linknames->{'takeonline'},
206: #icon => '',
207: #help => 'Domain_Coordination_Server_Online',
208: url => '/cgi-bin/takeonline.pl',
209: permission => $candisplay->{'takeonline'},
210: linktitle => $titles->{'takeonline'},
211: }]},
212: {categorytitle => 'Metadata Information',
213: items =>
214: [{
215: linktext => $linknames->{'metadata_keywords'},
216: #icon => '',
217: #help => 'Domain_Coordination_Metadata_Keywords',
218: url => '/cgi-bin/metadata_keywords.pl',
219: permission => $candisplay->{'metadata_keywords'},
220: linktitle => $titles->{'metadata_keywords'},
221: },
222: {
223: linktext => $linknames->{'metadata_harvest'},
224: #icon => '',
225: #help => 'Domain_Coordination_Metadata_Harvest',
226: url => '/cgi-bin/metadata_harvest.pl',
227: permission => $candisplay->{'metadata_harvest'},
228: linktitle => $titles->{'metadata_harvest'},
229: }]},
230: );
231: }
232: return @menu;
233: }
234:
235: sub serverstatus_links {
236: my $linkname = {
237: 'userstatus' => 'User Sessions',
238: 'lonstatus' => 'Connection Status',
239: 'server-status' => 'Apache Server Status',
240: 'clusterstatus' => 'Domain Status',
241: 'codeversions' => 'LON-CAPA Modules',
242: 'showenv' => 'User Environment for current log-in',
243: 'loncron' => 'Update Connections and Refresh Status Information',
244: 'takeoffline' => 'Replace log-in page with offline notice',
245: 'takeonline' => 'Replace offline notice with log-in page',
246: 'metadata_keywords' => 'Display Metadata Keywords',
247: 'metadata_harvest' => 'Harvest Metadata Keywords',
248: };
249: return $linkname;
250: }
251:
252: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>