You are here

function hosting_client_update in Hosting 5

Same name and namespace in other branches
  1. 6.2 client/hosting_client.module \hosting_client_update()
  2. 7.4 client/hosting_client.module \hosting_client_update()
  3. 7.3 client/hosting_client.module \hosting_client_update()

Implementation of hook_update().

As an existing node is being updated in the database, we need to do our own database updates.

File

client/hosting_client.module, line 285

Code

function hosting_client_update($node) {

  // if this is a new node or we're adding a new revision,
  if ($node->revision) {
    hosting_client_insert($node);
  }
  else {
    db_query("UPDATE {hosting_client} SET nid=%d, name = '%s', organization = '%s', email='%s' WHERE vid=%d", $node->nid, $node->client_name, $node->organization, $node->email, $node->vid);
  }
  hosting_client_set_title($node);
  if ($node->users) {
    foreach ($node->users as $user) {
      db_query('DELETE FROM {hosting_client_user} WHERE user = %d AND client = %d', $user, $node->nid);
    }
  }
  if ($node->new_user) {
    $user = user_load(array(
      'name' => $node->new_user,
    ));
    db_query('INSERT INTO {hosting_client_user} (client, user, contact_type) VALUES (%d, %d, "%s")', $node->nid, $user->uid, '');
  }
}