You are here

function update_status_settings in Update Status 5.2

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

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

4 string references to 'update_status_settings'
update_status_calculate_project_data in ./update_status.module
Given the installed projects and the available release data retrieved from remote servers, calculate the current status.
update_status_menu in ./update_status.module
Implementation of hook_menu().
update_status_settings_submit in ./update_status.module
Submit callback handler for the update status settings tab.
update_status_uninstall in ./update_status.install
Implementation of hook_uninstall().

File

./update_status.module, line 166

Code

function update_status_settings() {
  $form = array();
  $form['update_status_check_disabled'] = array(
    '#type' => 'checkbox',
    '#title' => t('Check for updates of disabled modules'),
    '#default_value' => variable_get('update_status_check_disabled', FALSE),
  );
  if ($available = update_status_get_available(TRUE)) {
    $values = variable_get('update_status_settings', array());
    $form['projects'] = array(
      '#tree' => TRUE,
    );
    $data = update_status_calculate_project_data($available);
    $form['data'] = array(
      '#type' => 'value',
      '#value' => $data,
    );
    $form['avail'] = array(
      '#type' => 'value',
      '#value' => $available,
    );
    $notify_emails = variable_get('update_status_notify_emails', array());
    $form['notify_emails'] = array(
      '#type' => 'textarea',
      '#title' => t('E-mail addresses to notify when updates are available'),
      '#rows' => 4,
      '#default_value' => implode("\n", $notify_emails),
      '#description' => t('Whenever your site checks for available updates and finds new releases, it can notify a list of users via e-mail. Put each address on a separate line. If blank, no e-mails will be sent.'),
    );
    $form['check_frequency'] = array(
      '#type' => 'radios',
      '#title' => t('Check for updates'),
      '#default_value' => variable_get('update_status_check_frequency', 'daily'),
      '#options' => array(
        'daily' => t('Daily'),
        'weekly' => t('Weekly'),
      ),
      '#description' => t('Select how frequently you want to automatically check for new releases of your currently installed modules.'),
    );
    $form['notification_threshold'] = array(
      '#type' => 'radios',
      '#title' => t('E-mail notification threshold'),
      '#default_value' => variable_get('update_status_notification_threshold', 'all'),
      '#options' => array(
        'all' => t('All newer versions'),
        'security' => t('Only security updates'),
      ),
      '#description' => t('You can choose to send e-mail only if a security update is available, or to be notified about all newer versions. If there are updates available of Drupal core or any of your installed modules and themes, your site will always print a message on the <a href="@status_report">status report</a> page, and will also display an error message on administration pages if there is a security update.', array(
        '@status_report' => url('admin/logs/status'),
      )),
    );
    $form['project_help'] = array(
      '#value' => t('These settings allow you to control if a certain project, or even a specific release of that project, should be ignored by the available updates report. For each project, you can select if it should always warn you about a newer release, never warn you (ignore the project completely), or ignore a specific available release you do not want to upgrade to. You can also specify a note explaining why you are ignoring a specific project or version, and that will be displayed on the available updates report.'),
    );
    foreach ($data as $key => $project) {
      if (isset($available[$key])) {
        if (!isset($values[$key])) {
          $values[$key] = array(
            'check' => 'always',
            'notes' => '',
          );
        }
        $options = array();
        $options['always'] = t('Always');
        if (isset($project['recommended'])) {
          $options[$project['recommended']] = t('Ignore @version', array(
            '@version' => $project['recommended'],
          ));
        }
        $options['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', _update_status_no_data()),
    );
  }
  drupal_add_css(drupal_get_path('module', 'update_status') . '/update_status.css');
  return $form;
}