You are here

function monitoring_config_sensors_overview_form in Monitoring 7

Sensors overview settings form.

1 string reference to 'monitoring_config_sensors_overview_form'
monitoring_menu in ./monitoring.module
Implements hook_menu().

File

./monitoring.admin.inc, line 16
Admin page/form callbacks.

Code

function monitoring_config_sensors_overview_form($form, &$form_state) {
  $options = array();
  $default_value = array();
  foreach (monitoring_sensor_info() as $sensor_name => $sensor_info) {
    $row = array(
      'category' => $sensor_info
        ->getCategory(),
      'label' => $sensor_info
        ->getLabel(),
      'description' => $sensor_info
        ->getDescription(),
    );
    $row['status'] = $sensor_info
      ->isEnabled() ? t('Enabled') : t('Disabled');
    $links = array();
    if ($sensor_info
      ->isConfigurable()) {
      $links[] = array(
        'title' => t('Settings'),
        'href' => 'admin/config/system/monitoring/sensors/' . $sensor_name,
        'query' => array(
          'destination' => 'admin/config/system/monitoring/sensors',
        ),
      );
    }
    $row['actions'] = '';
    if (!empty($links)) {
      $row['actions'] = theme('links', array(
        'links' => $links,
      ));
    }
    $options[$sensor_name] = $row;
    $default_value[$sensor_name] = $sensor_info
      ->isEnabled();
  }
  $header = array(
    'category' => t('Category'),
    'label' => t('Label'),
    'description' => t('Description'),
    'status' => t('Status'),
    'actions' => t('Actions'),
  );
  $form['sensors'] = array(
    '#type' => 'tableselect',
    '#header' => $header,
    '#options' => $options,
    '#default_value' => $default_value,
    '#attributes' => array(
      'id' => 'monitoring-sensors-config-overview',
    ),
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save configuration'),
  );
  return $form;
}