summaryrefslogtreecommitdiff
path: root/modules/comment/comment.admin.inc
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2010-03-07 07:15:28 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2010-03-07 07:15:28 +0000
commit8b762fce57fa55a38bf2b146766298c4fb0d2377 (patch)
treee5fa96cb2fca20f2dee5a5bb100a462126c6924d /modules/comment/comment.admin.inc
parent11ae79673ac66df672124a215e0fe70d2251a31d (diff)
downloadbrdo-8b762fce57fa55a38bf2b146766298c4fb0d2377.tar.gz
brdo-8b762fce57fa55a38bf2b146766298c4fb0d2377.tar.bz2
#699596 by mr.baileys and catch: Fixed (Un)publishing several comments doesn't work.
Diffstat (limited to 'modules/comment/comment.admin.inc')
-rw-r--r--modules/comment/comment.admin.inc49
1 files changed, 27 insertions, 22 deletions
diff --git a/modules/comment/comment.admin.inc b/modules/comment/comment.admin.inc
index 764a5adbd..b3a6499f8 100644
--- a/modules/comment/comment.admin.inc
+++ b/modules/comment/comment.admin.inc
@@ -41,10 +41,15 @@ function comment_admin_overview($form, &$form_state, $arg) {
'#title' => t('Update options'),
'#attributes' => array('class' => array('container-inline')),
);
- $options = array();
- foreach (comment_operations($arg == 'approval' ? 'publish' : 'unpublish') as $key => $value) {
- $options[$key] = $value[0];
+
+ if ($arg == 'approval') {
+ $options['publish'] = t('Publish the selected comments');
+ }
+ else {
+ $options['unpublish'] = t('Unpublish the selected comments');
}
+ $options['delete'] = t('Delete the selected comments');
+
$form['options']['operation'] = array(
'#type' => 'select',
'#options' => $options,
@@ -152,28 +157,28 @@ function comment_admin_overview_validate($form, &$form_state) {
* publishing, unpublishing or deleting.
*/
function comment_admin_overview_submit($form, &$form_state) {
- $operations = comment_operations();
- if (!empty($operations[$form_state['values']['operation']][1])) {
- // Extract the appropriate database query operation.
- $query = $operations[$form_state['values']['operation']][1];
- foreach ($form_state['values']['comments'] as $cid => $value) {
- if ($value) {
- // Perform the update action, then refresh node statistics.
- $query
- ->condition('cid', $cid )
- ->execute();
- $comment = comment_load($cid);
- _comment_update_node_statistics($comment->nid);
- // Allow modules to respond to the updating of a comment.
- module_invoke_all('comment_' . $form_state['values']['operation'], $comment);
- // Add an entry to the watchdog log.
- watchdog('content', 'Comment: updated %subject.', array('%subject' => $comment->subject), WATCHDOG_NOTICE, l(t('view'), 'node/' . $comment->nid, array('fragment' => 'comment-' . $comment->cid)));
+ $operation = $form_state['values']['operation'];
+ $cids = $form_state['values']['comments'];
+
+ if ($operation == 'delete') {
+ comment_delete_multiple($cids);
+ cache_clear_all();
+ }
+ else {
+ foreach ($cids as $cid => $value) {
+ $comment = comment_load($value);
+
+ if ($operation == 'unpublish') {
+ $comment->status = COMMENT_NOT_PUBLISHED;
}
+ else if ($operation == 'publish') {
+ $comment->status = COMMENT_PUBLISHED;
+ }
+ comment_save($comment);
}
- cache_clear_all();
- drupal_set_message(t('The update has been performed.'));
- $form_state['redirect'] = 'admin/content/comment';
}
+ drupal_set_message(t('The update has been performed.'));
+ $form_state['redirect'] = 'admin/content/comment';
}
/**