You are here

function hosting_https_site_form in Aegir HTTPS 7.3

Form API code to extend the site form with HTTPS fields.

1 call to hosting_https_site_form()
hosting_https_form_alter in ./hosting_https.module
Implements hook_form_alter().

File

./hosting_https.nodeapi.inc, line 11
NodeAPI functions for the Hosting HTTPS module.

Code

function hosting_https_site_form(&$form, &$form_state, $form_id) {
  $node = $form['#node'];
  if (!($https_available = hosting_https_is_available($node))) {
    return;
  }
  _hosting_site_field($form, $node, 'hosting_https_wrapper', array(
    '#type' => 'fieldset',
    '#title' => t('HTTPS Settings'),
    '#default_value' => NULL,
  ), 'filter_xss', $https_available);
  _hosting_site_field($form['hosting_https_wrapper'], $node, 'https_enabled', array(
    '#type' => 'radios',
    '#title' => t('Encryption'),
    '#options' => hosting_https_status_options(),
    '#description' => t('Enabling encryption will publish your site on both HTTP and HTTPS ports, allowing you to redirect users to the more secure version for certain pages that require the additional security. Requiring encryption will automatically redirect all unencrypted traffic to your HTTPS site.') . '<br/><strong>' . t("If the server is setup to generate the HTTPS certificate using Let's Encrypt, ensure that there is an existing public DNS entry for the site, otherwise installation will fail.") . '</strong>',
    '#required' => TRUE,
    '#default_value' => isset($node->https_enabled) ? $node->https_enabled : HOSTING_HTTPS_DISABLED,
    '#access' => user_access('manage site HTTPS settings'),
  ), 'hosting_https_status_options', $https_available);
  _hosting_site_field($form['hosting_https_wrapper'], $node, 'https_client_authentication_enabled', array(
    '#type' => 'checkbox',
    '#title' => t('Enable client authentication'),
    '#description' => t('Check this box to allow for server authentication of clients in addition to clients authenticating the server.  It should only be enabled if required by the hosted site (e.g. if using the <a href="https://www.drupal.org/project/certificatelogin">Certificate Login</a> module), or users will needlessly be asked to present identity certificates if they have them.  This will only work if HTTPS is enabled or required, and your Web server module for Aegir HTTPS supports it.'),
    '#default_value' => isset($node->https_client_authentication_enabled) ? $node->https_client_authentication_enabled : HOSTING_HTTPS_CLIENT_AUTHENTICATION_DISABLED,
    '#access' => user_access('manage site HTTPS settings'),
  ), 'filter_xss', $https_available);
  _hosting_site_field($form['hosting_https_wrapper'], $node, 'https_client_authentication_path', array(
    '#type' => 'textfield',
    '#title' => t('Client authentication path'),
    '#description' => t("If you'd rather not have client authentication enabled throughout the site, specify a path here such as <em>/certificate/login</em>. This option will only take effect on Apache; it's not supported on Nginx."),
    '#default_value' => isset($node->https_client_authentication_path) ? $node->https_client_authentication_path : '',
    '#size' => 60,
    '#maxlength' => 255,
    '#access' => user_access('manage site HTTPS settings'),
    '#states' => array(
      'visible' => array(
        ':input[name="https_client_authentication_enabled"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  ), 'filter_xss', $https_available);

  // Add our custom validate callback.
  $form['#validate'][] = 'hosting_https_site_form_validate';
}