From 9a32ca468a320bec9769ed3c29c50b5a1f4459b1 Mon Sep 17 00:00:00 2001 From: Angie Byron Date: Thu, 8 Jan 2009 08:42:13 +0000 Subject: #8 by sun and most of #drupal: Users can now cancel their accounts. Fixing the 8th issue, almost 8 years later, on January 8th, after working 8 days full-time on it. GREAT WORK :D --- modules/comment/comment.module | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) (limited to 'modules/comment/comment.module') diff --git a/modules/comment/comment.module b/modules/comment/comment.module index 04ddc9d2d..ef4f0ee39 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -697,17 +697,31 @@ function comment_nodeapi_rss_item($node) { } /** - * Implementation of hook_user_delete(). + * Implementation of hook_user_cancel(). */ -function comment_user_delete(&$edit, &$user, $category = NULL) { - db_update('comment') - ->fields(array('uid' => 0)) - ->condition('uid', $user->uid) - ->execute(); - db_update('node_comment_statistics') - ->fields(array('last_comment_uid' => 0)) - ->condition('last_comment_uid', $user->uid) - ->execute(); +function comment_user_cancel(&$edit, &$account, $method) { + switch ($method) { + case 'user_cancel_block_unpublish': + db_update('comment')->fields(array('status' => 0))->condition('uid', $account->uid)->execute(); + db_update('node_comment_statistics')->fields(array('last_comment_uid' => 0))->condition('last_comment_uid', $account->uid)->execute(); + break; + + case 'user_cancel_reassign': + db_update('comment')->fields(array('uid' => 0))->condition('uid', $account->uid)->execute(); + db_update('node_comment_statistics')->fields(array('last_comment_uid' => 0))->condition('last_comment_uid', $account->uid)->execute(); + break; + + case 'user_cancel_delete': + module_load_include('inc', 'comment', 'comment.admin'); + $comments = db_select('comment', 'c')->fields('c', array('cid'))->condition('uid', $account->uid)->execute()->fetchCol(); + foreach ($comments as $cid) { + $comment = comment_load($cid); + // Delete the comment and its replies. + _comment_delete_thread($comment); + _comment_update_node_statistics($comment->nid); + } + break; + } } /** -- cgit v1.2.3