summaryrefslogtreecommitdiff
path: root/modules/comment/comment.admin.inc
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2009-07-31 19:44:21 +0000
committerDries Buytaert <dries@buytaert.net>2009-07-31 19:44:21 +0000
commita8a15bcd9015914d5350d868760f8d750b80354e (patch)
treec7bbfa7576430403282b0b9dc7ef20d06e218d61 /modules/comment/comment.admin.inc
parent04d7eb4acb8b892e489a3abe49c9a98e5d863f7e (diff)
downloadbrdo-a8a15bcd9015914d5350d868760f8d750b80354e.tar.gz
brdo-a8a15bcd9015914d5350d868760f8d750b80354e.tar.bz2
- Patch #504666 by catch, yched, et al: make comments fieldable. Oh my. Bye bye comments as nodes?
Diffstat (limited to 'modules/comment/comment.admin.inc')
-rw-r--r--modules/comment/comment.admin.inc47
1 files changed, 8 insertions, 39 deletions
diff --git a/modules/comment/comment.admin.inc b/modules/comment/comment.admin.inc
index 3ea0b5d7c..dbb8f16c0 100644
--- a/modules/comment/comment.admin.inc
+++ b/modules/comment/comment.admin.inc
@@ -196,14 +196,11 @@ function comment_multiple_delete_confirm(&$form_state) {
*/
function comment_multiple_delete_confirm_submit($form, &$form_state) {
if ($form_state['values']['confirm']) {
- foreach ($form_state['values']['comments'] as $cid => $value) {
- $comment = comment_load($cid);
- // Perform the actual comment deletion.
- _comment_delete_thread($comment);
- _comment_update_node_statistics($comment->nid);
- }
+ comment_delete_multiple(array_keys($form_state['values']['comments']));
cache_clear_all();
- drupal_set_message(t('The comments have been deleted.'));
+ $count = count($form_state['values']['comments']);
+ watchdog('content', 'Deleted @count comments.', array('@count' => $count));
+ drupal_set_message(t('Deleted @count comments.', array('@count' => $count)));
}
$form_state['redirect'] = 'admin/content/comment';
}
@@ -214,7 +211,7 @@ function comment_multiple_delete_confirm_submit($form, &$form_state) {
* @param $cid
* The comment to be deleted.
*/
-function comment_delete($cid = NULL) {
+function comment_delete_page($cid = NULL) {
$comment = db_query('SELECT c.*, u.name AS registered_name, u.uid FROM {comment} c INNER JOIN {users} u ON u.uid = c.uid WHERE c.cid = :cid', array(':cid' => $cid))->fetch();
$comment->name = $comment->uid ? $comment->registered_name : $comment->name;
$output = '';
@@ -252,41 +249,13 @@ function comment_confirm_delete(&$form_state, $comment) {
* Process comment_confirm_delete form submissions.
*/
function comment_confirm_delete_submit($form, &$form_state) {
- drupal_set_message(t('The comment and all its replies have been deleted.'));
$comment = $form['#comment'];
// Delete the comment and its replies.
- _comment_delete_thread($comment);
- _comment_update_node_statistics($comment->nid);
+ comment_delete($comment->cid);
+ drupal_set_message(t('The comment and all its replies have been deleted.'));
+ watchdog('content', t('Deleted comment @cid and its replies.', array('@cid' => $comment->cid)));
// Clear the cache so an anonymous user sees that his comment was deleted.
cache_clear_all();
$form_state['redirect'] = "node/$comment->nid";
}
-
-/**
- * Perform the actual deletion of a comment and all its replies.
- *
- * @param $comment
- * An associative array describing the comment to be deleted.
- */
-function _comment_delete_thread($comment) {
- if (!is_object($comment) || !is_numeric($comment->cid)) {
- watchdog('content', 'Cannot delete non-existent comment.', array(), WATCHDOG_WARNING);
-
- return;
- }
-
- // Delete the comment.
- db_delete('comment')
- ->condition('cid', $comment->cid)
- ->execute();
- watchdog('content', 'Comment: deleted %subject.', array('%subject' => $comment->subject));
- module_invoke_all('comment_delete', $comment);
-
- // Delete the comment's replies.
- $result = db_query('SELECT c.*, u.name AS registered_name, u.uid FROM {comment} c INNER JOIN {users} u ON u.uid = c.uid WHERE pid = :cid', array(':cid' => $comment->cid));
- foreach ($result as $comment) {
- $comment->name = $comment->uid ? $comment->registered_name : $comment->name;
- _comment_delete_thread($comment);
- }
-}