Report abuse links

Events happening in the community are now at Drupal community events on www.drupal.org.
ejohns's picture

I was interested in knowing if there are any modules/innovative ways to include a "Report abusive comment" link on the bottom of comments...

I have seen some modules with this functionality: but there development appears to have been stagnated over the past few years..

Thanks!

Comments

On Economist.com we use the

stewsnooze's picture

On Economist.com we use the VotingAPI for both comment recommends and abuse reports

Check out

http://www.economist.com/world/international/displayStory.cfm?story_id=1...

We have a simple module that goes along side voting_api that handles whether it is a recommend or an abuse report.

Below is a sample piece of code that is the submit function for the form that appears on the page listed above when you report abuse.

function ec_vote_report_abuse_form_submit($form, &$form_state) {
  $cid = isset($form_state['values']['cid']) ? $form_state['values']['cid'] : NULL;
  $nid = isset($form_state['values']['nid']) ? $form_state['values']['nid'] : NULL;
  $ec_abuse_explanation = isset($form_state['values']['ec_abuse_explanation']) ? $form_state['values']['ec_abuse_explanation'] : NULL;
  $reason_key = isset($form_state['values']['ec_abuse_reason']) ? $form_state['values']['ec_abuse_reason'] : NULL;
  $ec_abuse_reason = isset($form_state['values']['abuse_reasons'][$reason_key]) ? $form_state['values' ['abuse_reasons'][$reason_key] : NULL;
  $result = ec_vote_insert_vote($cid, $ec_abuse_reason, $ec_abuse_explanation);
  $redirect_url = isset($nid) ? 'node/' . $nid . '/talk' : '/';
  $form_state['redirect'] = $redirect_url;
}

The code for recommending is quite similar although I think this function handles being called with a nid or a cid

function ec_vote_set_vote($content_type) {
  $params = ec_proxy_get_params();
  $votes[] = array(
    'content_type' => $content_type,
    'content_id' => !empty($params['dr_cid']) ? $params['dr_cid'] : $params['ec_nid'],
    'value_type' => 'points',
    'value' => 1,
    'ec_abuse_reason' => $params['ec_abuse_reason'],
    'ec_abuse_explanation' => $params['ec_abuse_explanation'],
  );
  $affected = votingapi_set_votes($votes);

  // For recommend-comments we need to know what to clear from the cache in CF
  // so return nid (or named_key for api).
  if (!empty($params['dr_cid'])) {
    $sql = 'SELECT n.nid, n.type, n.title FROM {comments} c, {node} n WHERE c.nid = n.nid AND c.cid = %d';
    $result = db_query($sql, $params['dr_cid']);
    while ($row = db_fetch_object($result)) {
      if ($row->type == 'api') {
        $key_to_clear = $row->title;
      }
      else {
        $key_to_clear = $row->nid;
      }
    }
    $affected['recommend-comment'][$params['dr_cid']]['key_to_clear'] = $key_to_clear;

    // Store the rendered comment in the cache.
    cache_clear_all('ec_comment_'. $params['dr_cid']);
  }
  $return = array(
    'content' => $affected[$content_type],
    'status' => 200,
  );
  return ec_json($return);
}

With these you just need to set up a bit of Ajax magic to call those callbacks.

Full Fat Things ( http://fullfatthings.com ), my Drupal consultancy that makes sites fast.

Newspapers on Drupal

Group organizers

Group categories

Topics - Newspaper on Drupal

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: