You are here

function spam_user_report_submit in Spam 5

Submit code for the spam_user_report form/function

File

./spam.module, line 945

Code

function spam_user_report_submit($form_id, $form_values) {

  /* spam/report/<type>/<id>
   * 0    1      2      3
   */
  global $user;
  $source = arg(2);
  $id = arg(3);
  db_query("INSERT INTO {spam_reported} (source, id, uid, hostname, feedback, timestamp) VALUES('%s', %d, %d, '%s', '%s', %d)", $source, $id, $user->uid, $_SERVER['REMOTE_ADDR'], $form_values['spam_feedback'], time());
  drupal_set_message(t('Thank you for your assistance.  The site administrator has been notified and will review the content shortly.'));
  $feedback = strlen($form_values['spam_feedback']) < 128 ? $form_values['spam_feedback'] : substr($form_values['spam_feedback'], 0, 128) . '...';
  spam_log(SPAM_LOG, t('spam_report: reported as possible spam.  User feedback begins, "@feedback"', array(
    '@feedback' => $feedback,
  )), $source, $id);
  switch ($source) {
    case 'node':
      $url = "node/{$id}";
      break;
    case 'comment':
      $comment = db_fetch_object(db_query('SELECT subject,nid FROM {comments} WHERE cid = %d', $id));
      $url = "node/{$comment->nid}";
      break;
    default:
      $hook = spam_invoke_hook('report', $source, $id);
      $url = $hook['return_path'];
      break;
  }
  drupal_goto($url);
}