You are here

function _hosting_ip_save in Hosting 7.4

Same name and namespace in other branches
  1. 7.3 server/hosting.ip.inc \_hosting_ip_save()

IP Utility function for hook_update/hook_insert.

2 calls to _hosting_ip_save()
hosting_server_insert in server/hosting_server.module
Implements hook_insert().
hosting_server_update in server/hosting_server.module
Implements hook_update().

File

server/hosting.ip.inc, line 25
General IP address CRUD routines.

Code

function _hosting_ip_save($node) {

  // Delete all IPs for this node.
  db_delete('hosting_ip_addresses')
    ->condition('nid', $node->nid)
    ->execute();
  $ips = isset($node->ip_addresses) ? (array) $node->ip_addresses : array();
  $ips = array_unique($ips);
  foreach ($ips as $id => $ip) {
    if (!empty($ip)) {

      // new entries are prefixed with the string 'new', insert those
      db_insert('hosting_ip_addresses')
        ->fields(array(
        'nid' => $node->nid,
        'ip_address' => $ip,
      ))
        ->execute();
    }
  }
}