From 5885925b0d2881277c22c6d70d86f1bc060fb133 Mon Sep 17 00:00:00 2001 From: Gerhard Killesreiter <killes_www_drop_org@227.no-reply.drupal.org> Date: Sun, 26 Mar 2006 19:31:00 +0000 Subject: [PATCH] #53348, Handling of deleted/blocked user accounts, patch by jreyero and Zen --- modules/comment.module | 4 ++++ modules/comment/comment.module | 4 ++++ modules/node.module | 10 ++++++++++ modules/node/node.module | 10 ++++++++++ modules/poll.module | 9 +++++++++ modules/poll/poll.module | 9 +++++++++ modules/profile.module | 2 ++ modules/profile/profile.module | 2 ++ modules/statistics.module | 9 +++++++++ modules/statistics/statistics.module | 9 +++++++++ modules/user.module | 2 +- modules/user/user.module | 2 +- modules/watchdog.module | 9 +++++++++ modules/watchdog/watchdog.module | 9 +++++++++ 14 files changed, 88 insertions(+), 2 deletions(-) diff --git a/modules/comment.module b/modules/comment.module index f7c9383f0c52..1b6a172176e1 100644 --- a/modules/comment.module +++ b/modules/comment.module @@ -335,6 +335,10 @@ function comment_user($type, $edit, &$user, $category = NULL) { return $form; } + elseif ($type == 'delete') { + db_query('UPDATE {comments} SET uid = 0 WHERE uid = %d', $user->uid); + db_query('UPDATE {node_comment_statistics} SET last_comment_uid = 0 WHERE last_comment_uid = %d', $user->uid); + } } /** diff --git a/modules/comment/comment.module b/modules/comment/comment.module index f7c9383f0c52..1b6a172176e1 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -335,6 +335,10 @@ function comment_user($type, $edit, &$user, $category = NULL) { return $form; } + elseif ($type == 'delete') { + db_query('UPDATE {comments} SET uid = 0 WHERE uid = %d', $user->uid); + db_query('UPDATE {node_comment_statistics} SET last_comment_uid = 0 WHERE last_comment_uid = %d', $user->uid); + } } /** diff --git a/modules/node.module b/modules/node.module index ec8a58180e25..ebe013b93b9a 100644 --- a/modules/node.module +++ b/modules/node.module @@ -822,6 +822,16 @@ function node_search($op = 'search', $keys = null) { } } +/** + * Implementation of hook_user(). + */ +function node_user($op, &$edit, &$user) { + if ($op == 'delete') { + db_query('UPDATE {node} SET uid = 0 WHERE uid = %d', $user->uid); + db_query('UPDATE {node_revisions} SET uid = 0 WHERE uid = %d', $user->uid); + } +} + function theme_node_search_admin($form) { $output = form_render($form['info']); diff --git a/modules/node/node.module b/modules/node/node.module index ec8a58180e25..ebe013b93b9a 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -822,6 +822,16 @@ function node_search($op = 'search', $keys = null) { } } +/** + * Implementation of hook_user(). + */ +function node_user($op, &$edit, &$user) { + if ($op == 'delete') { + db_query('UPDATE {node} SET uid = 0 WHERE uid = %d', $user->uid); + db_query('UPDATE {node_revisions} SET uid = 0 WHERE uid = %d', $user->uid); + } +} + function theme_node_search_admin($form) { $output = form_render($form['info']); diff --git a/modules/poll.module b/modules/poll.module index 1cd9fce8ba32..7d452d5f44be 100644 --- a/modules/poll.module +++ b/modules/poll.module @@ -492,3 +492,12 @@ function poll_update($node) { } } } + +/** + * Implementation of hook_user(). + */ +function poll_user($op, &$edit, &$user) { + if ($op == 'delete') { + db_query('UPDATE {poll_votes} SET uid = 0 WHERE uid = %d', $user->uid); + } +} diff --git a/modules/poll/poll.module b/modules/poll/poll.module index 1cd9fce8ba32..7d452d5f44be 100644 --- a/modules/poll/poll.module +++ b/modules/poll/poll.module @@ -492,3 +492,12 @@ function poll_update($node) { } } } + +/** + * Implementation of hook_user(). + */ +function poll_user($op, &$edit, &$user) { + if ($op == 'delete') { + db_query('UPDATE {poll_votes} SET uid = 0 WHERE uid = %d', $user->uid); + } +} diff --git a/modules/profile.module b/modules/profile.module index 1e4845dff11a..d08b8be94079 100644 --- a/modules/profile.module +++ b/modules/profile.module @@ -165,6 +165,8 @@ function profile_user($type, &$edit, &$user, $category = NULL) { return profile_validate_profile($edit, $category); case 'categories': return profile_categories(); + case 'delete': + db_query('DELETE FROM {profile_values} WHERE uid = %d', $user->uid); } } diff --git a/modules/profile/profile.module b/modules/profile/profile.module index 1e4845dff11a..d08b8be94079 100644 --- a/modules/profile/profile.module +++ b/modules/profile/profile.module @@ -165,6 +165,8 @@ function profile_user($type, &$edit, &$user, $category = NULL) { return profile_validate_profile($edit, $category); case 'categories': return profile_categories(); + case 'delete': + db_query('DELETE FROM {profile_values} WHERE uid = %d', $user->uid); } } diff --git a/modules/statistics.module b/modules/statistics.module index 9eaccd6fe8af..1c79db6028d6 100644 --- a/modules/statistics.module +++ b/modules/statistics.module @@ -145,6 +145,15 @@ function statistics_menu($may_cache) { return $items; } +/** + * Implementation of hook_user(). + */ +function statistics_user($op, &$edit, &$user) { + if ($op == 'delete') { + db_query('UPDATE {accesslog} SET uid = 0 WHERE uid = %d', $user->uid); + } +} + function statistics_access_log($aid) { $result = db_query('SELECT a.*, u.name FROM {accesslog} a LEFT JOIN {users} u ON a.uid = u.uid WHERE aid = %d', $aid); if ($access = db_fetch_object($result)) { diff --git a/modules/statistics/statistics.module b/modules/statistics/statistics.module index 9eaccd6fe8af..1c79db6028d6 100644 --- a/modules/statistics/statistics.module +++ b/modules/statistics/statistics.module @@ -145,6 +145,15 @@ function statistics_menu($may_cache) { return $items; } +/** + * Implementation of hook_user(). + */ +function statistics_user($op, &$edit, &$user) { + if ($op == 'delete') { + db_query('UPDATE {accesslog} SET uid = 0 WHERE uid = %d', $user->uid); + } +} + function statistics_access_log($aid) { $result = db_query('SELECT a.*, u.name FROM {accesslog} a LEFT JOIN {users} u ON a.uid = u.uid WHERE aid = %d', $aid); if ($access = db_fetch_object($result)) { diff --git a/modules/user.module b/modules/user.module index 7527b77947aa..762a5442226e 100644 --- a/modules/user.module +++ b/modules/user.module @@ -1369,7 +1369,7 @@ function user_edit($category = 'account') { drupal_goto('admin/user'); } else { - return confirm_form('user_confirm_delete', $form, t('Are you sure you want to delete the account %name?', array('%name' => theme('placeholder', $account->name))), 'user/'. $account->uid, t('Deleting a user will remove all their submissions as well. This action cannot be undone.'), t('Delete')); + return confirm_form('user_confirm_delete', array(), t('Are you sure you want to delete the account %name?', array('%name' => theme('placeholder', $account->name))), 'user/'. $account->uid, t('All submissions made by this user will be attributed to the anonymous account. This action cannot be undone.'), t('Delete'), t('Cancel')); } } else if ($_POST['op'] == t('Delete')) { diff --git a/modules/user/user.module b/modules/user/user.module index 7527b77947aa..762a5442226e 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -1369,7 +1369,7 @@ function user_edit($category = 'account') { drupal_goto('admin/user'); } else { - return confirm_form('user_confirm_delete', $form, t('Are you sure you want to delete the account %name?', array('%name' => theme('placeholder', $account->name))), 'user/'. $account->uid, t('Deleting a user will remove all their submissions as well. This action cannot be undone.'), t('Delete')); + return confirm_form('user_confirm_delete', array(), t('Are you sure you want to delete the account %name?', array('%name' => theme('placeholder', $account->name))), 'user/'. $account->uid, t('All submissions made by this user will be attributed to the anonymous account. This action cannot be undone.'), t('Delete'), t('Cancel')); } } else if ($_POST['op'] == t('Delete')) { diff --git a/modules/watchdog.module b/modules/watchdog.module index 7bd72f8ae803..71f353d7f318 100644 --- a/modules/watchdog.module +++ b/modules/watchdog.module @@ -61,6 +61,15 @@ function watchdog_cron() { db_query('DELETE FROM {flood} WHERE timestamp < %d', time() - 3600); } +/** + * Implementation of hook_user(). + */ +function watchdog_user($op, &$edit, &$user) { + if ($op == 'delete') { + db_query('UPDATE {watchdog} SET uid=0 WHERE uid=%d', $user->uid); + } +} + /** * Menu callback; displays a listing of log messages. */ diff --git a/modules/watchdog/watchdog.module b/modules/watchdog/watchdog.module index 7bd72f8ae803..71f353d7f318 100644 --- a/modules/watchdog/watchdog.module +++ b/modules/watchdog/watchdog.module @@ -61,6 +61,15 @@ function watchdog_cron() { db_query('DELETE FROM {flood} WHERE timestamp < %d', time() - 3600); } +/** + * Implementation of hook_user(). + */ +function watchdog_user($op, &$edit, &$user) { + if ($op == 'delete') { + db_query('UPDATE {watchdog} SET uid=0 WHERE uid=%d', $user->uid); + } +} + /** * Menu callback; displays a listing of log messages. */ -- GitLab