You are here

function nagios_form_system_theme_settings_alter in Nagios Monitoring 7

Same name and namespace in other branches
  1. 8 nagios.module \nagios_form_system_theme_settings_alter()

Implements hook_form_FORMID_alter().

Modify the module display view by adding a nagios ignore link to every module description.

File

./nagios.module, line 562

Code

function nagios_form_system_theme_settings_alter(&$form, &$form_state) {
  if (isset($form['confirm']) || !user_access('administer nagios ignore')) {
    return;
  }

  // We need to abort if the Update module is not installed.
  if (!db_table_exists('cache_update')) {
    watchdog('nagios', t('The core update module was never installed so we cannot use update check features.'));
    return;
  }

  // Grab the name of the theme.
  if (isset($form_state['build_info']['args'][0]) && !empty($form_state['build_info']['args'][0])) {
    $theme_name = check_plain($form_state['build_info']['args'][0]);
    $nagios_ignored_themes = variable_get('nagios_ignored_themes', []);

    // Check to see if the theme is provided by core, or if it's contrib/custom.
    $projects_data = _nagios_update_get_projects();
    if (array_key_exists($theme_name, $projects_data)) {

      // This is a settings page for a non-core theme, so add the checkbox.
      $form['nagios'] = [
        '#type' => 'fieldset',
        '#title' => t('Nagios Monitoring'),
        'nagios_ignore' => [
          '#type' => 'checkbox',
          '#title' => t('Ignore from Nagios'),
          '#weight' => 200,
          '#default_value' => !empty($nagios_ignored_themes[$theme_name]),
        ],
      ];
      $form['#submit'][] = 'nagios_system_theme_settings_form_submit';
    }
  }
}