File:  [LON-CAPA] / loncom / interface / domainstatus.pm
Revision 1.9: download - view: text, annotated - select for diffs
Tue Mar 4 02:24:03 2025 UTC (3 months, 4 weeks ago) by raeburn
Branches: MAIN
CVS tags: version_2_12_X, HEAD
- Remove redundant heading, as domain isalready included in top menu row),
  and header text is already included as last item in breadcrumbs trail.

    1: # The LearningOnline Network
    2: # Generate a menu page containing links to server status pages accessible
    3: # to user. 
    4: #
    5: # $Id: domainstatus.pm,v 1.9 2025/03/04 02:24:03 raeburn Exp $
    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;
   38: use LONCAPA::lonauthcgi;
   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;
   60:     my $titles = &LONCAPA::lonauthcgi::serverstatus_titles();
   61:     if (ref($titles) eq 'HASH') {
   62:         foreach my $page (keys(%{$titles})) {
   63:             if (&LONCAPA::lonauthcgi::can_view($page)) {
   64:                 $candisplay{$page} = 'F';       
   65:             } elsif (&LONCAPA::lonauthcgi::check_ipbased_access($page)) {
   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: 
   79:     if (keys(%candisplay) > 0) {
   80:         $r->print(&print_status_menu(\%candisplay,$dom));
   81:     } else {
   82:         $r->print(
   83:             '<h2>'.&mt('No information available').'</h2>'
   84:            .'<p class="LC_warning">'
   85:            .&mt('Your current role and/or IP address does not have permission to display information about server status for servers in the domain: [_1].',
   86:                 '<b>'.$domdesc.'</b> ('.$dom.')')
   87:            .'</p>'
   88:         ); 
   89:     }
   90:     $r->print(&Apache::loncommon::end_page());
   91:     return OK;
   92: }
   93: 
   94: sub print_status_menu {
   95:     my ($candisplay,$dom) = @_;
   96:     return '' if (ref($candisplay) ne 'HASH');
   97:     return &Apache::lonhtmlcommon::generate_menu(
   98:                &servermenu_items($candisplay,$dom));
   99: }
  100: 
  101: sub servermenu_items {
  102:     my ($candisplay,$dom) = @_;
  103:     my $titles = &LONCAPA::lonauthcgi::serverstatus_titles();
  104:     my $linknames = &serverstatus_links();
  105:     my @menu;
  106:     if ((ref($candisplay) eq 'HASH') && (ref($titles) eq 'HASH') && 
  107:         (ref($linknames) eq 'HASH')) { 
  108:         @menu = ( {categorytitle => 'Status information',
  109:                   items =>
  110:                  [{
  111:                  linktext => $linknames->{'userstatus'},
  112:                  icon => '',
  113:                  alttext => '',
  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'},
  121:                  icon => '',
  122:                  alttext => '',
  123:                  #help => 'Domain_Coordination_Connection_Status',
  124:                  url => '/lon-status/',
  125:                  permission => $candisplay->{'lonstatus'},
  126:                  linktitle => $titles->{'lonstatus'},
  127:              },
  128:              {
  129:                  linktext => $linknames->{'server-status'},
  130:                  icon => '',
  131:                  alttext => '',
  132:                  #help => 'Domain_Coordination_Apache_Status',
  133:                  url => '/server-status',
  134:                  permission => $candisplay->{'server-status'},
  135:                  linktitle => $titles->{'server-status'},
  136:              },
  137:              {
  138:                  linktext => $linknames->{'clusterstatus'},
  139:                  icon => '',
  140:                  alttext => '',
  141:                  #help => 'Domain_Coordination_Apache_Status',
  142:                  url => '/cgi-bin/clusterstatus.pl',
  143:                  permission => $candisplay->{'clusterstatus'},
  144:                  linktitle => $titles->{'clusterstatus'},
  145:              },
  146:              {
  147:                  linktext => $linknames->{'certstatus'},
  148:                  icon => '',
  149:                  alttext => '',
  150:                  #help => 'Domain_Coordination_Apache_Status',
  151:                  url => '/cgi-bin/loncertstatus.pl',
  152:                  permission => $candisplay->{'certstatus'},
  153:                  linktitle => $titles->{'certstatus'},
  154:              },
  155:              {
  156:                  linktext => $linknames->{'codeversions'},
  157:                  icon => '',
  158:                  alttext => '',
  159:                  #help => 'Domain_Coordination_Code_Versions',
  160:                  url => '/cgi-bin/lonversions.pl',
  161:                  permission => $candisplay->{'codeversions'},
  162:                  linktitle => $titles->{'codeversions'},
  163:              },
  164:              {
  165:                  linktext => $linknames->{'checksums'},
  166:                  icon => '',
  167:                  alttext => '',
  168:                  #help => 'Domain_Coordination_Code_Checksums',
  169:                  url => '/cgi-bin/lonmodulecheck.pl',
  170:                  permission => $candisplay->{'checksums'},
  171:                  linktitle => $titles->{'checksums'},
  172:              },
  173:              {
  174:                  linktext => $linknames->{'diskusage'},
  175:                  icon => '',
  176:                  alttext => '',
  177:                  #help => 'Domain_Coordination_Disk_Usage',
  178:                  url => '/cgi-bin/quotacheck.pl?domain='.$dom,
  179:                  permission => $candisplay->{'diskusage'},
  180:                  linktitle => $titles->{'diskusage'},
  181:              },
  182:              {
  183:                  linktext => $linknames->{'uniquecodes'},
  184:                  icon => '',
  185:                  alttext => '',
  186:                  #help => 'Domain_Coordination_Uniquecodes',
  187:                  url => '/cgi-bin/listcodes.pl?domain='.$dom.'&amp;format=html',
  188:                  permission => $candisplay->{'uniquecodes'},
  189:                  linktitle => $titles->{'uniquecodes'},
  190:              },
  191:              {
  192:                  linktext => $linknames->{'showenv'},
  193:                  icon => '',
  194:                  alttext => '',
  195:                  #help => 'Domain_Coordination_User_Environment',
  196:                  url => '/adm/test',
  197:                  permission => $candisplay->{'showenv'},
  198:                  linktitle => $titles->{'showenv'},
  199:              }]},
  200:              {categorytitle => 'Server Actions',
  201:              items =>
  202:              [{
  203:                  linktext => $linknames->{'loncron'},
  204:                  icon => '',
  205:                  alttext => '',
  206:                  #help => 'Domain_Coordination_Connection_Reload',
  207:                  url => '/cgi-bin/loncron.pl',
  208:                  permission => $candisplay->{'loncron'},
  209:                  linktitle => $titles->{'loncron'},
  210:              },
  211:              {
  212:                  linktext => $linknames->{'takeoffline'},
  213:                  icon => '',
  214:                  alttext => '',
  215:                  #help => 'Domain_Coordination_Server_Offline',
  216:                  url => '/cgi-bin/takeoffline.pl',
  217:                  permission => $candisplay->{'takeoffline'},
  218:                  linktitle => $titles->{'takeoffline'},
  219:              },
  220:              {
  221:                  linktext => $linknames->{'takeonline'},
  222:                  icon => '',
  223:                  alttext => '',
  224:                  #help => 'Domain_Coordination_Server_Online',
  225:                  url => '/cgi-bin/takeonline.pl',
  226:                  permission => $candisplay->{'takeonline'},
  227:                  linktitle => $titles->{'takeonline'},
  228:              }]},
  229:              {categorytitle => 'Metadata Information',
  230:              items =>
  231:              [{
  232:                  linktext => $linknames->{'metadata_keywords'},
  233:                  icon => '',
  234:                  alttext => '',
  235:                  #help => 'Domain_Coordination_Metadata_Keywords',
  236:                  url => '/cgi-bin/metadata_keywords.pl',
  237:                  permission => $candisplay->{'metadata_keywords'},
  238:                  linktitle => $titles->{'metadata_keywords'},
  239:              },
  240:              {
  241:                  linktext => $linknames->{'metadata_harvest'},
  242:                  icon => '',
  243:                  alttext => '',
  244:                  #help => 'Domain_Coordination_Metadata_Harvest',
  245:                  url => '/cgi-bin/metadata_harvest.pl',
  246:                  permission => $candisplay->{'metadata_harvest'},
  247:                  linktitle => $titles->{'metadata_harvest'},
  248:              }]},
  249:            );
  250:         }
  251:     return @menu;
  252: }
  253: 
  254: sub serverstatus_links {
  255:     my $linkname = { 
  256:                     'userstatus' => 'User Sessions',
  257:                     'lonstatus' => 'Connection Status',
  258:                     'server-status' => 'Apache Server Status',
  259:                     'clusterstatus' => 'Domain Status',
  260:                     'certstatus' => 'LON-CAPA SSL Certificates Status',   
  261:                     'codeversions' => 'LON-CAPA Modules',
  262:                     'checksums'    => 'Check for LON-CAPA Module changes',   
  263:                     'diskusage'    => 'Display quotas and usage for Course/Community Content',
  264:                     'showenv' => 'User Environment for current log-in',
  265:                     'loncron' => 'Update Connections and Refresh Status Information',
  266:                     'uniquecodes' => "List Domain's Courses with Assigned Six Character codes",
  267:                     'takeoffline' => 'Replace log-in page with offline notice',
  268:                     'takeonline' => 'Replace offline notice with log-in page',
  269:                     'metadata_keywords' => 'Display Metadata Keywords',
  270:                     'metadata_harvest' => 'Harvest Metadata Keywords',
  271:     };
  272:     return $linkname;
  273: }
  274: 
  275: 1;

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