Annotation of loncom/interface/domainstatus.pm, revision 1.3
1.1 raeburn 1: # The LearningOnline Network
2: # Generate a menu page containing links to server status pages accessible
3: # to user.
4: #
1.3 ! bisitz 5: # $Id: domainstatus.pm,v 1.2 2008/12/25 01:52:50 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').
1.3 ! bisitz 77: &Apache::lonhtmlcommon::breadcrumbs('Server Status Information'));
1.1 raeburn 78:
79: if (keys(%candisplay) > 0) {
80: $r->print('<h2>'.&mt('Server Utilities for Domain: [_1]','<i>'.$domdesc.'</i>').
81: '</h2>'.&print_status_menu(\%candisplay));
82: } else {
1.3 ! bisitz 83: $r->print(
! 84: '<h2>'.&mt('No information available').'</h2>'
! 85: .'<p class="LC_warning">'
! 86: .&mt('Your current role and/or IP address does not have permission to display information about server status for servers in the domain: [_1].',
! 87: '<b>'.$domdesc.'</b> ('.$dom.')')
! 88: .'</p>'
! 89: );
1.1 raeburn 90: }
91: $r->print(&Apache::loncommon::end_page());
92: return OK;
93: }
94:
95: sub print_status_menu {
96: my ($candisplay) = @_;
97: return '' if (ref($candisplay) ne 'HASH');
1.3 ! bisitz 98: return &Apache::lonhtmlcommon::generate_menu(
! 99: &servermenu_items($candisplay));
1.1 raeburn 100: }
101:
102: sub servermenu_items {
103: my ($candisplay) = @_;
1.2 raeburn 104: my $titles = &LONCAPA::lonauthcgi::serverstatus_titles();
1.1 raeburn 105: my $linknames = &serverstatus_links();
106: my @menu;
107: if ((ref($candisplay) eq 'HASH') && (ref($titles) eq 'HASH') &&
108: (ref($linknames) eq 'HASH')) {
109: @menu = ( {categorytitle => 'Status information',
110: items =>
111: [{
112: linktext => $linknames->{'userstatus'},
1.3 ! bisitz 113: icon => 'srvr.png',
1.1 raeburn 114: #help => 'Domain_Coordination_Userstatus',
115: url => '/cgi-bin/userstatus.pl',
116: permission => $candisplay->{'userstatus'},
117: linktitle => $titles->{'userstatus'},
118: },
119: {
120: linktext => $linknames->{'lonstatus'},
1.3 ! bisitz 121: icon => 'srvr.png',
1.1 raeburn 122: #help => 'Domain_Coordination_Connection_Status',
123: url => '/lon-status/',
124: permission => $candisplay->{'lonstatus'},
125: linktitle => $titles->{'lonstatus'},
126: },
127: {
128: linktext => $linknames->{'server-status'},
1.3 ! bisitz 129: icon => 'srvr.png',
1.1 raeburn 130: #help => 'Domain_Coordination_Apache_Status',
131: url => '/server-status',
132: permission => $candisplay->{'server-status'},
133: linktitle => $titles->{'server-status'},
134: },
135: {
136: linktext => $linknames->{'clusterstatus'},
1.3 ! bisitz 137: icon => 'srvr.png',
1.1 raeburn 138: #help => 'Domain_Coordination_Apache_Status',
139: url => '/cgi-bin/clusterstatus.pl',
140: permission => $candisplay->{'clusterstatus'},
141: linktitle => $titles->{'clusterstatus'},
142: },
143: {
144: linktext => $linknames->{'codeversions'},
1.3 ! bisitz 145: icon => 'srvr.png',
1.1 raeburn 146: #help => 'Domain_Coordination_Code_Versions',
147: url => '/cgi-bin/lonversions.pl',
148: permission => $candisplay->{'codeversions'},
149: linktitle => $titles->{'codeversions'},
150: },
151: {
152: linktext => $linknames->{'showenv'},
1.3 ! bisitz 153: icon => 'srvr.png',
1.1 raeburn 154: #help => 'Domain_Coordination_User_Environment',
155: url => '/adm/test',
156: permission => $candisplay->{'showenv'},
157: linktitle => $titles->{'showenv'},
158: }]},
159: {categorytitle => 'Server Actions',
160: items =>
161: [{
162: linktext => $linknames->{'loncron'},
1.3 ! bisitz 163: icon => 'srvr.png',
1.1 raeburn 164: #help => 'Domain_Coordination_Connection_Reload',
165: url => '/cgi-bin/loncron.pl',
166: permission => $candisplay->{'loncron'},
167: linktitle => $titles->{'loncron'},
168: },
169: {
170: linktext => $linknames->{'takeoffline'},
1.3 ! bisitz 171: icon => 'srvr.png',
1.1 raeburn 172: #help => 'Domain_Coordination_Server_Offline',
173: url => '/cgi-bin/takeoffline.pl',
174: permission => $candisplay->{'takeoffline'},
175: linktitle => $titles->{'takeoffline'},
176: },
177: {
178: linktext => $linknames->{'takeonline'},
1.3 ! bisitz 179: icon => 'srvr.png',
1.1 raeburn 180: #help => 'Domain_Coordination_Server_Online',
181: url => '/cgi-bin/takeonline.pl',
182: permission => $candisplay->{'takeonline'},
183: linktitle => $titles->{'takeonline'},
184: }]},
185: {categorytitle => 'Metadata Information',
186: items =>
187: [{
188: linktext => $linknames->{'metadata_keywords'},
1.3 ! bisitz 189: icon => 'srvr.png',
1.1 raeburn 190: #help => 'Domain_Coordination_Metadata_Keywords',
191: url => '/cgi-bin/metadata_keywords.pl',
192: permission => $candisplay->{'metadata_keywords'},
193: linktitle => $titles->{'metadata_keywords'},
194: },
195: {
196: linktext => $linknames->{'metadata_harvest'},
1.3 ! bisitz 197: icon => 'srvr.png',
1.1 raeburn 198: #help => 'Domain_Coordination_Metadata_Harvest',
199: url => '/cgi-bin/metadata_harvest.pl',
200: permission => $candisplay->{'metadata_harvest'},
201: linktitle => $titles->{'metadata_harvest'},
202: }]},
203: );
204: }
205: return @menu;
206: }
207:
208: sub serverstatus_links {
209: my $linkname = {
210: 'userstatus' => 'User Sessions',
211: 'lonstatus' => 'Connection Status',
212: 'server-status' => 'Apache Server Status',
213: 'clusterstatus' => 'Domain Status',
214: 'codeversions' => 'LON-CAPA Modules',
215: 'showenv' => 'User Environment for current log-in',
216: 'loncron' => 'Update Connections and Refresh Status Information',
217: 'takeoffline' => 'Replace log-in page with offline notice',
218: 'takeonline' => 'Replace offline notice with log-in page',
219: 'metadata_keywords' => 'Display Metadata Keywords',
220: 'metadata_harvest' => 'Harvest Metadata Keywords',
221: };
222: return $linkname;
223: }
224:
225: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>