function hosting_client_insert in Hosting 7.3
Same name and namespace in other branches
- 5 client/hosting_client.module \hosting_client_insert()
- 6.2 client/hosting_client.module \hosting_client_insert()
- 7.4 client/hosting_client.module \hosting_client_insert()
Implements hook_insert().
1 call to hosting_client_insert()
- hosting_client_update in client/
hosting_client.module - Implements hook_update().
File
- client/
hosting_client.module, line 412
Code
function hosting_client_insert($node) {
if (!empty($node->uname)) {
$node->uname = hosting_client_sanitize($node->uname);
}
else {
$node->uname = hosting_client_sanitize($node->title);
}
$id = db_insert('hosting_client')
->fields(array(
'vid' => $node->vid,
'nid' => $node->nid,
'uname' => $node->uname,
))
->execute();
if (variable_get('hosting_client_register_user', FALSE) && user_load_multiple(array(), array(
'mail' => $node->email,
)) == FALSE) {
$user = hosting_client_register_user($node);
$node->uid = $user->uid;
db_update('node')
->fields(array(
'uid' => $user->uid,
))
->condition('nid', $node->nid)
->execute();
db_update('node_revision')
->fields(array(
'uid' => $user->uid,
))
->condition('vid', $node->vid)
->execute();
}
if (isset($node->new_user)) {
$user = user_load_multiple(array(), array(
'name' => $node->new_user,
));
$user = array_shift($user);
if ($user) {
$id = db_insert('hosting_client_user')
->fields(array(
'client' => $node->nid,
'user' => $user->uid,
'contact_type' => '',
))
->execute();
}
}
}