function domain_user_save in Domain Access 7.3
Same name and namespace in other branches
- 7.2 domain.module \domain_user_save()
Helper function called by both hook_user_insert() and hook_user_update().
2 calls to domain_user_save()
- domain_user_insert in ./
domain.module - Implements hook_user_insert().
- domain_user_update in ./
domain.module - Implements hook_user_update().
File
- ./
domain.module, line 587 - Core module functions for the Domain Access suite.
Code
function domain_user_save(&$edit, $account, $category) {
// If our field element is missing, do nothing.
if (!isset($edit['domain_user'])) {
return;
}
// Clear and reset the {domain_editor} table.
db_delete('domain_editor')
->condition('uid', $account->uid)
->execute();
// Store the new domains.
$values = array();
foreach ($edit['domain_user'] as $domain_id => $status) {
if ($status != 0) {
$values[] = array(
'uid' => $account->uid,
'domain_id' => $domain_id,
);
}
}
if (!empty($values)) {
$query = db_insert('domain_editor')
->fields(array(
'uid',
'domain_id',
));
foreach ($values as $record) {
$query
->values($record);
}
$query
->execute();
}
// Clear the $edit field.
$edit['domain_user'] = NULL;
}