system_status.module in System Status 8
Same filename and directory in other branches
Drupal system status
File
system_status.moduleView source
<?php
/**
* @file
* Drupal system status
*/
use Drupal\user\UserInterface;
/**
* Implements hook_help().
*
* Displays help and module information.
*/
function system_status_help($path, $arg) {
switch ($path) {
case 'admin/help#system_status':
$output = '<h2>' . t('System Status module information') . '</h2>';
$output .= '<p>' . t('System Status provides an easy way to get an overview of all the available updates for your Drupal websites.') . '<br/>';
$output .= t('Enable the System Status module on all your Drupal websites and allow reporting to DrupalStatus.org for a centralized overview and email summaries of available updates and installed versions.') . '</p>';
$output .= '<p>' . t('The accompanying service offered by DrupalStatus.org is free but if you do not want to use this service this lightweight module allows you to built your own overviews and dashboard.') . '</p>';
$output .= '<p>' . t('How does it work?') . '</p>';
$output .= '<ul>';
$output .= '<li>' . t('Enable the System Status module on your Drupal website') . '</li>';
$output .= '<li>' . t('Click the "Add this site to your DrupalStatus.org overview" button to be redirected to the DrupalStatus website with the necessary credentials.') . '</li>';
$output .= '</ul>';
return $output;
break;
}
}
/**
* Implements hook_menu().
*/
function system_status_menu() {
$items = array();
$items['admin/config/system/system_status'] = array(
'title' => 'System Status',
'description' => 'Configuration for System status module',
'route_name' => 'system_status.admin_settings',
'type' => MENU_LOCAL_TASK | MENU_NORMAL_ITEM,
);
return $items;
}
/**
* Access callback: Check authorized IP.
*
* @see system_status_menu()
*/
// TODOD* $request->attributes->get('_raw_variables')->get('system_status_token')
function system_status_access_callback($token = FALSE) {
$config = \Drupal::config('system_status.settings');
if ($config
->get('system_status_service_allow_drupalstatus') == 0 || $token !== $config
->get('system_status_token')) {
return FALSE;
}
$ip_address = Drupal::request()
->getClientIp();
if ($config
->get('system_status_service_allow_drupalstatus') == 1) {
if ($ip_address == gethostbyname("status.drupalstatus.org.")) {
return TRUE;
}
}
return FALSE;
}
function system_status_add_site($form, &$form_state) {
global $base_url;
$config = \Drupal::config('system_status.settings');
$siteUrl = urlencode($base_url);
$siteUrl .= "|" . $config
->get('system_status_token');
$siteUrl .= "|" . $config
->get('system_status_encrypt_token');
$url = "https://www.drupalstatus.org/addsite?op=addSite&siteUrl={$siteUrl}";
if (Drupal::moduleHandler()
->moduleExists('overlay') && overlay_get_mode() == 'child') {
unset($_GET['destination']);
overlay_close_dialog($url, array(
'external' => TRUE,
));
$form_state['redirect'] = FALSE;
}
else {
$form_state['redirect'] = $url;
}
}
Functions
Name | Description |
---|---|
system_status_access_callback | |
system_status_add_site | |
system_status_help | Implements hook_help(). |
system_status_menu | Implements hook_menu(). |