function notifications_usermerge_merge_users in User Merge 6
Implement hook_usermerge_merge_users() on behalf of notifications.
File
- ./
usermerge.module, line 228 - Main file for the user merge module, which re-assigns data from an abandoned account to a live one.
Code
function notifications_usermerge_merge_users($user_to_delete, $user_to_keep) {
// Get blocked-user's notifications.
$blocked = array();
$result = db_query("SELECT sid FROM {notifications} WHERE uid = %d" . $user_to_delete->uid);
while ($record = db_fetch_array($result)) {
$blocked[] = $record['sid'];
}
if (!empty($blocked)) {
// Delete notification settings.
db_query("DELETE FROM {notifications} WHERE uid = %d", $user_to_delete->uid);
// Delete fields of blocked-user's notifications settings, they aren't used.
db_query("DELETE FROM {notifications_fields} WHERE sid IN (%s)", implode(',', $blocked));
}
// Delete notifications in the queue for blocked-user.
db_query("DELETE FROM {notifications_queue} WHERE uid = %d", $user_to_delete->uid);
}