You are here

function cmf_admin_comments_form_submit in Content Management Filter 7

Same name and namespace in other branches
  1. 5 comment.inc \cmf_admin_comments_form_submit()
  2. 6.2 comment.inc \cmf_admin_comments_form_submit()
  3. 6 comment.inc \cmf_admin_comments_form_submit()

Handle post-validation form submission. Execute the chosen 'Update option' on the selected comments, such as publishing, unpublishing or deleting.

Parameters

the ID of the passed form:

array with the form properties values:

File

./comment.inc, line 119
@brief Content management filter comment operations file.

Code

function cmf_admin_comments_form_submit($form, &$form_state) {
  $operations = comment_operations();
  if ($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.
        db_query($query, $cid);
        $comment = _comment_load($cid);
        _comment_update_node_statistics($comment->nid);

        // Allow modules to respond to the updating of a comment.
        comment_invoke_comment($comment, $form_state['values']['operation']);
      }
    }
    cache_clear_all();
    drupal_set_message(t('The update has been performed.'));
    $user_page_user = $form['#user_page_user'];
    if (_cmf_valid_user($user_page_user)) {
      $form_state['redirect'] = 'user/' . $user_page_user->uid . '/cmf';
    }
    else {
      $form_state['redirect'] = 'admin/content/filter';
    }
  }
}