hosting_https.module in Aegir HTTPS 7.3
Hook implementations for the Hosting HTTPS module.
File
hosting_https.module
View source
<?php
define('HOSTING_HTTPS_DISABLED', 0);
define('HOSTING_HTTPS_ENABLED', 1);
define('HOSTING_HTTPS_REQUIRED', 2);
define('HOSTING_HTTPS_CLIENT_AUTHENTICATION_DISABLED', 0);
define('HOSTING_HTTPS_CLIENT_AUTHENTICATION_ENABLED', 1);
include_once 'hosting_https.nodeapi.inc';
function hosting_https_permission() {
return array(
'manage site HTTPS settings' => array(
'title' => t('Manage site HTTPS settings.'),
),
);
}
function hosting_https_get_servers($access_check = TRUE) {
$servers = hosting_get_servers('http', $access_check);
$https_servers = array();
foreach ($servers as $nid => $title) {
$server = node_load($nid);
$check_servers = array();
if ($server->services['http']->type == 'cluster') {
foreach ($server->services['http']->web_servers as $inner_nid) {
$check_servers[] = node_load($inner_nid);
}
}
elseif ($server->services['http']->type == 'pack') {
foreach ($server->services['http']->master_servers as $inner_nid) {
$check_servers[] = node_load($inner_nid);
}
foreach ($server->services['http']->slave_servers as $inner_nid) {
$check_servers[] = node_load($inner_nid);
}
}
else {
$check_servers[] = $server;
}
$https_available = TRUE;
foreach ($check_servers as $node) {
$https_available = $https_available && $node->services['http']->https_enabled;
}
if ($https_available) {
$https_servers[] = $nid;
}
}
return $https_servers;
}
function hosting_https_get_platforms() {
$https_servers = hosting_https_get_servers();
$https_platforms = array();
$platforms = _hosting_get_platforms();
foreach ($platforms as $nid => $title) {
$platform = node_load($nid);
if (in_array($platform->web_server, $https_servers)) {
$https_platforms[] = $nid;
}
}
return $https_platforms;
}
function hosting_https_get_profiles() {
$https_platforms = hosting_https_get_platforms();
$https_profiles = array();
foreach ($https_platforms as $nid) {
$platform = node_load($nid);
$https_profiles = array_merge($https_profiles, array_keys($platform->profiles));
}
return array_unique($https_profiles);
}
function hosting_https_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'site_node_form') {
hosting_https_site_form($form, $form_state, $form_id);
}
}
function hosting_https_feature_enable_callback() {
drupal_set_message(t("Please make sure you have enabled HTTPS support in your webserver, e.g. by enabling mod_ssl in Apache."));
drupal_set_message(t("To start using HTTPS please edit the desired server node within Aegir to set it from e.g. 'apache' to 'apache_https'."));
}
function hosting_https_is_available($site, $check_server_access = TRUE) {
$https_available = FALSE;
if (isset($site->nid)) {
$platform = node_load($site->platform);
if (in_array($platform->web_server, hosting_https_get_servers($check_server_access))) {
$https_available = TRUE;
}
}
elseif (count(hosting_https_get_servers($check_server_access)) > 0) {
$https_available = TRUE;
}
return $https_available;
}