You are here

function spam_node_overview in Spam 5

Display the form that allows the user to edit comment spam

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

File

./spam.module, line 2866

Code

function spam_node_overview() {

  //drupal_set_html_head(spam_javascript());
  $operations = array(
    'NOT_SPAM' => t('Mark the selected posts as not spam'),
    'UNPUBLISH' => t('Unpublish the selected posts'),
    'PUBLISH' => t('Publish the selected posts'),
    'DELETE' => t('Delete the selected posts (no confirmation)'),
  );

  // build an 'Update options' form
  $form['options'] = array(
    '#type' => 'fieldset',
    '#title' => t('Update options'),
    '#prefix' => '<div class="container-inline">',
    '#suffix' => '</div>',
  );
  $form['options']['operation'] = array(
    '#type' => 'select',
    '#options' => $operations,
    '#description' => t(''),
  );
  $form['options']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Update'),
  );

  // create the select all button w/ select as a label

  //$selectButton = spam_select_all('spam_node_overview');
  $form['header'] = array(
    '#type' => 'value',
    '#value' => array(
      $selectButton,
      array(
        'data' => t('title'),
        'field' => 'n.title',
      ),
      array(
        'data' => t('type'),
        'field' => 'n.type',
      ),
      array(
        'data' => t('author'),
        'field' => 'u.name',
      ),
      array(
        'data' => t('hostname'),
        'field' => 's.hostname',
      ),
      array(
        'data' => t('status'),
        'field' => 'n.status',
      ),
      array(
        'data' => t('timestamp'),
        'field' => 'n.changed',
        'sort' => 'desc',
      ),
      array(
        'data' => t('operations'),
      ),
    ),
  );
  $sql = "SELECT n.*, u.name, u.uid, s.id, s.probability, s.hostname FROM {spam_tracker} s, {node} n, {users} u WHERE s.source = 'node' AND n.uid = u.uid AND s.id = n.nid AND s.probability >= " . variable_get('spam_threshold', 80);
  $sql .= tablesort_sql($form['header']['#value']);
  $result = pager_query($sql, variable_get('spam_display_quantity', 50));

  // build a table listing the appropriate nodes
  while ($node = db_fetch_object($result)) {
    $nodes[$node->nid] = '';
    $form['title'][$node->nid] = array(
      '#value' => l($node->title, "node/{$node->nid}") . ' ' . (node_last_viewed($node->nid) < $node->changed ? theme_mark() : ''),
    );
    $form['type'][$node->nid] = array(
      '#value' => node_get_types('name', $node),
    );
    $form['author'][$node->nid] = array(
      '#value' => theme('username', $node),
    );
    $form['hostname'][$node->nid] = array(
      '#value' => $node->hostname,
    );
    $form['status'][$node->nid] = array(
      '#value' => $node->status ? t('published') : t('not published'),
    );
    $form['timestamp'][$node->nid] = array(
      '#value' => format_date($node->changed, 'small'),
    );
    $form['operations'][$node->nid] = array(
      '#value' => l(t('View log'), "admin/logs/spam/logs/node/{$node->nid}") . '&nbsp;' . l(t('Edit'), "node/{$node->nid}/edit") . '&nbsp;' . l(t('Delete'), "admin/content/node/delete/{$node->nid}"),
    );
  }
  $form['nodes'] = array(
    '#type' => 'checkboxes',
    '#options' => $nodes,
  );
  $form['pager'] = array(
    '#value' => theme('pager', NULL, 50, 0),
  );
  return $form;
}