function hosting_client_update in Hosting 6.2
Same name and namespace in other branches
- 5 client/hosting_client.module \hosting_client_update()
- 7.4 client/hosting_client.module \hosting_client_update()
- 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 400
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 {
if ($node->uname) {
$node->uname = hosting_client_sanitize($node->uname);
}
else {
$node->uname = hosting_client_sanitize($node->title);
}
db_query("UPDATE {hosting_client} SET uname='%s' WHERE nid=%d", $node->uname, $node->nid);
}
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, '');
}
}