You are here

function hosting_https_site_form_validate in Aegir HTTPS 7.3

Site form validation callback.

See also

hosting_https_site_form()

1 string reference to 'hosting_https_site_form_validate'
hosting_https_site_form in ./hosting_https.nodeapi.inc
Form API code to extend the site form with HTTPS fields.

File

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

Code

function hosting_https_site_form_validate($form, $form_state) {
  if ($form_state['values']['https_enabled']) {
    $node = $form['#node'];

    // Check that the server to host this site has HTTPS enabled.
    if (!empty($node->platform)) {
      $platform = node_load($node->platform);
      $server = node_load($platform->web_server);
      if (!in_array($server->nid, hosting_https_get_servers())) {
        $server_name = strlen($server->human_name) ? $server->human_name : $server->title;
        $server_edit_path = 'node/' . $server->nid . '/edit';
        if (drupal_valid_path($server_edit_path, TRUE)) {
          $enable = t('Enable HTTPS on !server.', array(
            '!server' => l($server_name, $server_edit_path),
          ));
        }
        else {
          $enable = t('Ask your site administrator to enable HTTPS.');
        }
        return form_set_error('hosting_https_wrapper', t("This site's platform is installed on a server that does not have HTTPS enabled. !enable", array(
          '!enable' => $enable,
        )));
      }
    }
  }
}