You are here

function hosting_nodeapi_server_presave in Hosting 6.2

Same name and namespace in other branches
  1. 7.4 server/hosting_server.module \hosting_nodeapi_server_presave()
  2. 7.3 server/hosting_server.module \hosting_nodeapi_server_presave()

Implementation of hook_presave()

We resolve the server name to IP addresses if none has been given by the operator. we also fire up the regular services hooks.

File

server/hosting_server.module, line 313

Code

function hosting_nodeapi_server_presave(&$node) {
  if (empty($node->ip_addresses)) {

    // this returns an array or FALSE
    $ips = gethostbynamel($node->title);
    if ($ips) {
      drupal_set_message(t('Initialized the IP to %ip based on hostname %name. If an HTTP service is enabled, this will be used to create database grants so make sure it is the right address, as seen from the database server.', array(
        '%ip' => join(',', $ips),
        '%name' => $node->title,
      )), 'message');
      $node->new_ip_addresses = $ips;
    }
    else {
      drupal_set_message(t("Could not resolve IP address of server %name, not automatically setting IP address. DNS may fail.", array(
        '%name' => $node->title,
      )));
    }
  }
  hosting_server_services_from_post($node);
}