You are here

function update_status_settings in Update Status 5

Same name and namespace in other branches
  1. 5.2 update_status.module \update_status_settings()

Menu callback. Show the settings for the update status module.

3 string references to 'update_status_settings'
update_status_calculate_project_data in ./update_status.module
update_status_menu in ./update_status.module
Implementation of hook_menu().
update_status_settings_submit in ./update_status.module

File

./update_status.module, line 111

Code

function update_status_settings() {
  $form = array();
  if ($info = variable_get('update_status', FALSE)) {
    $values = variable_get('update_status_settings', array());
    $form['projects'] = array(
      '#tree' => TRUE,
    );
    $data = update_status_get_projects();
    $form['data'] = array(
      '#type' => 'value',
      '#value' => $data,
    );
    $form['info'] = array(
      '#type' => 'value',
      '#value' => $info,
    );
    foreach ($data as $key => $project) {
      if (array_key_exists($key, $info)) {
        if (!isset($values[$key])) {
          $values[$key] = array(
            'check' => 'always',
            'notes' => '',
          );
        }
        $options = array(
          'always' => t('Always'),
          $info[$key]['version'] => t('Ignore @version', array(
            '@version' => $info[$key]['version'],
          )),
          'never' => t('Never'),
        );
        $form['projects'][$key]['check'] = array(
          '#type' => 'select',
          '#options' => $options,
          '#default_value' => $values[$key]['check'],
        );
        $form['projects'][$key]['notes'] = array(
          '#type' => 'textfield',
          '#size' => 50,
          '#default_value' => $values[$key]['notes'],
        );
      }
    }
    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Submit changes'),
    );
  }
  else {
    $form['error'] = array(
      '#value' => theme('update_status_report', t('No update data is available. To fetch data, you may need to !run_cron.', array(
        '!run_cron' => l(t('run cron'), 'admin/logs/status/run-cron', NULL, 'destination=' . url('admin/logs/updates')),
      ))),
    );
  }
  return $form;
}