You are here

function hosting_https_node_load in Aegir HTTPS 7.3

Implements hook_node_load().

@todo For the query, use "SELECT *" instead of concatenating possible fields together. Then, check which ones are set.

File

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

Code

function hosting_https_node_load($nodes, $types) {

  // Necessary if run through Drush not fully bootstrapped.
  require_once DRUPAL_ROOT . '/includes/install.inc';

  // Handle the case where hostmaster loads itself before DB schema updates run.
  $client_auth_enabled_column = drupal_get_installed_schema_version('hosting_https') >= 7001 ? ', client_authentication' : '';
  $client_auth_path_column = drupal_get_installed_schema_version('hosting_https') >= 7002 ? ', client_authentication_path' : '';
  foreach ($nodes as $nid => $node) {
    $result = db_query("SELECT https_enabled{$client_auth_enabled_column}{$client_auth_path_column} FROM {hosting_https_site} WHERE vid = :vid", array(
      ':vid' => $node->vid,
    ))
      ->fetchObject();
    if ($result) {
      $nodes[$nid]->https_enabled = $result->https_enabled;
      $nodes[$nid]->https_client_authentication_enabled = $client_auth_enabled_column ? $result->client_authentication : HOSTING_HTTPS_CLIENT_AUTHENTICATION_DISABLED;
      $nodes[$nid]->https_client_authentication_path = $client_auth_path_column ? $result->client_authentication_path : '';
      $nodes[$nid]->https_key = hosting_https_get_key($node);
    }
  }
}