You are here

function spam_user_report in Spam 5

Display the form that allows the user to edit comment spam

1 string reference to 'spam_user_report'
spam_menu in ./spam.module
Implementation of hook_menu().

File

./spam.module, line 978

Code

function spam_user_report() {
  global $user;

  /* spam/report/<type>/<id>
   * 0    1      2      3
   */
  $source = arg(2);
  $id = arg(3);
  $output = '';
  switch ($source) {
    case 'node':
      $node = node_load(array(
        'nid' => $id,
      ));
      $confirm_message = t('You are reporting the @type content "!title" as spam.', array(
        '@type' => node_get_types('name', $node),
        '!title' => l($node->title, "node/{$id}"),
      ));
      break;
    case 'comment':
      $comment = db_fetch_object(db_query('SELECT subject,nid FROM {comments} WHERE cid = %d', $id));
      $confirm_message = t('You are reporting the comment "!subject" as spam.', array(
        '!subject' => l($comment->subject, "node/{$comment->nid}", array(), NULL, "comment-{$id}"),
      ));
      break;
    default:
      $hook = spam_invoke_hook('report', $source, $id);
      $confirm_message = $hook['confirm_message'];
      break;
  }
  menu_set_location(array(
    array(
      'path' => '/',
      'title' => t('Report Spam'),
    ),
  ));
  $form['feedback'] = array(
    '#type' => 'fieldset',
    '#title' => t('Spam Feedback'),
  );
  $form['feedback']['message'] = array(
    '#type' => 'markup',
    '#value' => $confirm_message,
    '#weight' => -1,
  );
  $form['feedback']['spam_feedback'] = array(
    '#type' => 'textarea',
    '#title' => t('Please help us by entering a brief explanation as to why this content is spam'),
    '#rows' => 10,
    '#default_value' => '',
    '#weight' => 0,
    '#required' => variable_get('spam_report_feedback', TRUE),
    '#description' => t('It is not always obvious why content should be marked as spam, so please assist our efforts to keep these pages spam free by explaining how you know this content is spam.  Your assistance is greatly appreciated.  If you got to this page on accident, please press the "back" button on your web browser to return to the original page.'),
  );
  $form['feedback']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Submit Report'),
    '#weight' => 5,
  );
  return $form;
}