Commit 5885925b authored by Gerhard Killesreiter's avatar Gerhard Killesreiter

#53348, Handling of deleted/blocked user accounts, patch by jreyero and Zen

parent e01c325d
......@@ -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);
}
}
/**
......
......@@ -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);
}
}
/**
......
......@@ -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']);
......
......@@ -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']);
......
......@@ -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);
}
}
......@@ -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);
}
}
......@@ -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);
}
}
......
......@@ -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);
}
}
......
......@@ -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)) {
......
......@@ -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)) {
......
......@@ -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')) {
......
......@@ -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')) {
......
......@@ -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.
*/
......
......@@ -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.
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment