abuse_report_form_submit

Definition

abuse_report_form_submit($form_id, $form_values)
abuse/abuse.module, line 611

Description

A hook to act on submission of abuse_report_form

Code

<?php
function abuse_report_form_submit($form_id, $form_values) {
  global $user;
  $oid = $form_values['object_oid'];
  $type = $form_values['object_type'];
  $object = _abuse_load($type, $oid);
  if (!$object || $form_values['op'] == t('cancel')) {
    drupal_goto($object->path['URL'], $object->path['QUERY'], $object->path['BREADCRUMB']);
  }
  if ($user->uid) {
    // CHECK FOR UNIQUE SUBMISSION
    if (db_result(db_query("SELECT COUNT(*) FROM {abuse} WHERE type = '%s' AND oid = %d AND uid = %d", $type, $oid, $user->uid)) > 0) {
      drupal_set_message(t('We have already received your report.  Thank you very much!'));
      drupal_goto($object->path['URL'], $object->path['QUERY'], $object->path['BREADCRUMB']);
    }
    
    // ENSURE USER IS NOT TRYING TO FLAG OWN CONTENT
    if ($user->uid == $object->uid) {
      drupal_set_message(t('You cannot flag your own content'));
      drupal_goto($object->path['URL'], $object->path['QUERY'], $object->path['BREADCRUMB']);
    }
  }
  
  _abuse_set_status($type, $oid, ABUSE_PENDING);
  $result = _abuse_disable($type, $oid);
  // Call the sequencer for sequencing content
  $aid = db_next_id('{abuse}_aid');
  db_query("INSERT INTO {abuse} (aid, type, oid, created, body, reason, uid, name, mail) VALUES (%d, '%s', %d, %d, '%s', '%s', %d, '%s', '%s')",
    $aid, $type, $oid, time(), $form_values['body'], $form_values['reason'], $user->uid, $form_values['name'], $form_values['mail']);
  drupal_set_message(t('Thank you for your report.'));
  drupal_goto($object->path['URL'], $object->path['QUERY'], $object->path['BREADCRUMB']);
}
?>