You are here

function anonymous_publishing_cl_admin_unverified in Anonymous Publishing 7

Menu callback: Form to manage spambot report.

Return value

array $form

1 string reference to 'anonymous_publishing_cl_admin_unverified'
anonymous_publishing_cl_menu in modules/cl/anonymous_publishing_cl.admin.inc
Implements hook_menu().

File

modules/cl/anonymous_publishing_cl.admin.inc, line 801
Menu callbacks for the CL tabs on the module admin page.

Code

function anonymous_publishing_cl_admin_unverified($form, &$form_state) {
  $options = array(
    'delete' => 'Delete',
    'banip' => 'Delete+Ban IP',
    'approve' => 'Approve',
  );
  $form = array();
  $form['#tree'] = TRUE;
  $form['apu_info'] = array(
    '#markup' => t("<p>The following table shows the IP-addresses, verification e-mail address used, date posted and title of still <em>unverified</em> anonymous posts. You may select posts by checking the box in the “Select” column, select an operation in the “With selected do” menu, and press “Execute” to execute the selected operation.</p><p>Banned the IP-address is inserted in Drupal's <code>{blocked_ips}</code> table. As an alternative to the Drupal <code>{blocked_ips}</code> table you may instead deny access to unwanted IP-addresses using the appropriate command in the web server access file (e.g. <code>.htaccess</code>).</p>"),
  );

  // Build the 'Update options' form.
  $form['options'] = array(
    '#type' => 'fieldset',
    '#title' => t('With selected do'),
    '#attributes' => array(
      'class' => array(
        'container-inline',
      ),
    ),
  );
  $form['options']['operation'] = array(
    '#type' => 'select',
    '#title' => t('Operation'),
    '#title_display' => 'invisible',
    '#options' => $options,
    '#default_value' => 'banip',
  );
  $form['options']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Execute'),
  );

  // Fetch all unverified posts.
  $rows = db_query_range('SELECT apid, nid, cid, verified, email, ip
    FROM {anonymous_publishing} WHERE (verified = 0)
    ORDER BY apid ASC', 0, 100)
    ->fetchAll(PDO::FETCH_ASSOC);
  $form['unverified'] = array();
  foreach ($rows as $row) {
    if ($row['cid']) {
      $commentfields = db_query("SELECT created, subject FROM {comment} WHERE cid = :cid", array(
        ':cid' => $row['cid'],
      ))
        ->fetchAssoc();
      $datefield = $commentfields['created'];
      $titlefield = $commentfields['subject'];
      if (empty($titlefield)) {
        $titlefield = '- empty -';
      }
    }
    else {
      $nodefields = db_query("SELECT created, title FROM {node} WHERE (:nid = nid)", array(
        ':nid' => $row['nid'],
      ))
        ->fetchAssoc();
      $datefield = $nodefields['created'];
      $titlefield = $nodefields['title'];
    }
    $datefield = $datefield ? format_interval(REQUEST_TIME - $datefield, 1) . ' ' . t('ago') : '-NULL-';
    $form['unverified'][$row['apid']] = array();
    $form['unverified'][$row['apid']]['select'] = array(
      '#type' => 'checkbox',
      '#default_value' => FALSE,
    );
    $form['unverified'][$row['apid']]['apid'] = array(
      '#markup' => $row['apid'],
    );
    $form['unverified'][$row['apid']]['ip'] = array(
      '#markup' => $row['ip'],
    );
    $form['unverified'][$row['apid']]['email'] = array(
      '#markup' => check_plain($row['email']),
    );
    $form['unverified'][$row['apid']]['date'] = array(
      '#markup' => $datefield,
    );
    $form['unverified'][$row['apid']]['node/comment'] = array(
      '#markup' => check_plain($titlefield),
    );
    $form['unverified'][$row['apid']]['ip2'] = array(
      '#type' => 'hidden',
      '#value' => $row['ip'],
    );
    $form['unverified'][$row['apid']]['nid'] = array(
      '#type' => 'hidden',
      '#value' => $row['nid'],
    );
    $form['unverified'][$row['apid']]['cid'] = array(
      '#type' => 'hidden',
      '#value' => $row['cid'],
    );
  }
  return $form;
}