abuse_warn_form_submit

Definition

abuse_warn_form_submit($form_id, $form_values)
abuse/abuse.module, line 771

Code

<?php
function abuse_warn_form_submit($form_id, $form_values) {
  $op = $form_values['op'];
  if ($op == t('cancel')) {
    drupal_set_message(t('Action cancelled'));
  } 
  else {
    $object = _abuse_load($form_values['object_type'], $form_values['object_oid']);
    $account = user_load(array('uid' => $object->uid));
    $subject = ($form_values['subject']) ? $form_values['subject'] : variable_get('abuse_warn_subject', '');
    $body = ($form_values['body']) ? $form_values['body'] : variable_get('abuse_warn_body', '');
    $vars = array(
      '!title' => $object->title,
      '!url' => $object->link,
      '!name' => $account->name
    );
    
    $subject = strtr($subject, $vars);
    $body = strtr($body, $vars);
    $bcc = variable_get('abuse_warn_bcc', '');
    $to = $account->mail;
    $from = variable_get('site_mail', '');
    $headers = array(
      'From' => $from,
      'Reply-to' => $from,
      'X-Mailer' => t('Drupal'),
      'Return-Path' => $from,
      'Errors-to' => $from
    );
    if ($bcc) {
      $headers['Bcc'] = $bcc;
    }
    
    drupal_mail('abuse', $to, $subject, $body, $from, $headers);
    db_query("INSERT INTO {abuse_warnings} (type, oid, created, uid) VALUES ('%s', %d, %d, %d)",
      $object->type, $object->oid, time(), $account->uid);
    if ($op == t('Warn and Allow')) {
      _abuse_allow($object->type, $object->oid);
    } 
    elseif ($op == t('Warn and Remove')) {
      _abuse_remove($object->type, $object->oid);
    }
    drupal_set_message(t('Your email has been sent.'));
  }
  drupal_goto('admin/content/abuse');
}
?>