You are here

function hosting_ssl_nodeapi_site_update in Hosting 7.4

Same name and namespace in other branches
  1. 6.2 web_server/ssl/hosting_ssl.nodeapi.inc \hosting_ssl_nodeapi_site_update()
  2. 7.3 web_server/ssl/hosting_ssl.nodeapi.inc \hosting_ssl_nodeapi_site_update()

Implements hook_nodeapi_TYPE_OP().

File

web_server/ssl/hosting_ssl.nodeapi.inc, line 288
NodeAPI functions for the Hosting SSL module.

Code

function hosting_ssl_nodeapi_site_update($node) {

  // check if an existing record is there
  $result = db_query("SELECT ssl_enabled FROM {hosting_ssl_site} WHERE vid = :vid", array(
    ':vid' => $node->vid,
  ));
  if (!($obj = $result
    ->fetch())) {
    hosting_ssl_nodeapi_site_insert($node);
  }
  else {
    if ($node->site_status == HOSTING_SITE_DELETED || !$node->ssl_enabled && $node->ssl_key != 0) {
      hosting_ssl_clean_keys($node);
    }
    db_update('hosting_ssl_site')
      ->fields(array(
      'ssl_enabled' => $node->ssl_enabled,
      'ssl_key' => $node->ssl_key,
    ))
      ->condition('vid', $node->vid)
      ->execute();
  }
}