1 update.admin.inc update_settings($form, &$form_state)

Form constructor for the update settings form.

See also

update_settings_validate()

update_settings_submit()

Related topics

File

core/modules/update/update.admin.inc, line 14
Admin page callbacks for the Update Manager module.

Code

function update_settings($form, &$form_state) {
  $config = config('update.settings');

  $form['check'] = array(
    '#type' => 'fieldset',
    '#title' => t('Check for available updates'),
    '#description' => t('This website will check for new releases of Backdrop core, as well as contributed modules, themes, and layouts. If there are updates available, a message will appear on the <a href="@status_report">status report</a> page. An error message will appear if there is a security update available.', 
    array('@status_report' => url('admin/reports/status'))),
  );
  $form['check']['update_check_frequency'] = array(
    '#type' => 'radios',
    '#title' => t('How frequently should this website check for updates?'),
    '#default_value' => $config->get('update_interval_days'),
    '#options' => array(
      '1' => t('Check daily'),
      '7' => t('Check weekly'),
      '0' => t('Do not check automatically'),
    ),
  );
  $form['check']['update_check_disabled'] = array(
    '#type' => 'checkbox',
    '#title' => t('Also check for updates of disabled modules, themes, and layouts'),
    '#default_value' => $config->get('update_disabled_extensions'),
  );

  $form['email'] = array(
    '#type' => 'fieldset',
    '#title' => t('Update Notifications'),
    '#description' => t('This website can send notifications via e-mail when updates are available.'),
    '#states' => array(
      'visible' => array(
        'input[name=update_check_frequency]' => array('!value' => 0),
      ),
    ),
  );
  $form['email']['update_notification_threshold'] = array(
    '#type' => 'radios',
    '#title' => t('When should this website send e-mail notifications?'),
    '#default_value' => $config->get('update_threshold'),
    '#options' => array(
      'all' => t('When any update is available'),
      'security' => t('Only if a security update is available'),
      'none' => t('Do not send email notifications'),
    ),
  );
  $notify_emails = $config->get('update_emails');
  if (empty($notify_emails)) {
    $notify_emails = array();
  }
  $form['email']['update_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('Put each email address on a separate line. If blank, no e-mails will be sent.'),
    '#states' => array(
      'visible' => array(
        'input[name=update_notification_threshold]' => array('!value' => 'none'),
      ),
    ),
  );

  $docs = l('File permissions and ownership', 'https://backdropcms.org/file-permissions-and-ownership');
  $form['self_update'] = array(
    '#type' => 'fieldset',
    '#title' => t('Self-updates'),
    '#description' => t('This website has the ability to update itself, but the file system permissions must be set properly. For more details, see !link.', 
    array('!link' => $docs)),
  );
  $core_update = config_get('installer.settings', 'core_update');
  $form['self_update']['core_update'] = array(
    '#type' => 'checkbox',
    '#title' => t('Manual self-update'),
    '#default_value' => $core_update,
    '#description' => t('When updating manually, allow this website to delete the old version of core, and then replace it with the new version.'),
  );
  $form['self_update']['automatic_update'] = array(
    '#type' => 'checkbox',
    '#title' => t('Automatic self-update (coming soon!)'),
    '#description' => t('When updates are available, allow this website to <strong>automatically</strong> delete the old version of core, and then replace it with the new version.'),
    '#default_value' => FALSE, // @todo update when #414 goes in
    '#disabled' => TRUE, // @todo update when #414 goes in
    '#states' => array(
      'visible' => array(
        'input[name=update_check_frequency]' => array('!value' => 0),
      ),
    ),
  );

  $form['actions']['#type'] = 'actions';
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save configuration')
  );

  return $form;
}