function hosting_client_insert in Hosting 6.2
Same name and namespace in other branches
- 5 client/hosting_client.module \hosting_client_insert()
- 7.4 client/hosting_client.module \hosting_client_insert()
- 7.3 client/hosting_client.module \hosting_client_insert()
Implementation of hook_insert().
1 call to hosting_client_insert()
- hosting_client_update in client/
hosting_client.module - Implementation of hook_update().
File
- client/
hosting_client.module, line 300
Code
function hosting_client_insert($node) {
if ($node->uname) {
$node->uname = hosting_client_sanitize($node->uname);
}
else {
$node->uname = hosting_client_sanitize($node->title);
}
db_query("INSERT INTO {hosting_client} (vid, nid, uname) VALUES (%d, %d, '%s' )", $node->vid, $node->nid, $node->uname);
if (variable_get('hosting_client_register_user', FALSE) && !user_load(array(
'mail' => $node->email,
))) {
$user = hosting_client_register_user($node);
$node->uid = $user->uid;
db_query("UPDATE {node} SET uid = %d WHERE nid = %d", $user->uid, $node->nid);
db_query("UPDATE {node_revisions} SET uid = %d WHERE vid = %d", $user->uid, $node->vid);
}
if (isset($node->new_user)) {
$user = user_load(array(
'name' => $node->new_user,
));
if ($user) {
db_query("INSERT INTO {hosting_client_user} (client, user, contact_type) VALUES (%d, %d, '%s')", $node->nid, $user->uid, '');
}
}
}