You are here

function spam_admin_overview in Spam 5.3

Same name and namespace in other branches
  1. 6 spam.module \spam_admin_overview()

A filterable list of spam.

1 string reference to 'spam_admin_overview'
spam_admin_list in ./spam.module
Manage spam content.

File

./spam.module, line 1299

Code

function spam_admin_overview() {
  $filter = spam_build_filter_query();
  $result = pager_query('SELECT t.* FROM {spam_tracker} t ' . $filter['join'] . ' ' . $filter['where'] . ' ORDER BY t.timestamp DESC', 50, 0, NULL, $filter['args']);
  $form['options'] = array(
    '#type' => 'fieldset',
    '#title' => t('Update options'),
    '#prefix' => '<div class="container-inline">',
    '#suffix' => '</div>',
  );
  $options = array();
  foreach (module_invoke_all('spam_operations') as $operation => $array) {
    $options[$operation] = $array['label'];
  }
  $form['options']['operation'] = array(
    '#type' => 'select',
    '#options' => $options,
    '#default_value' => 'approve',
  );
  $form['options']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Update'),
  );
  $destination = drupal_get_destination();
  while ($spam = db_fetch_object($result)) {
    $all["{$spam->content_type}-{$spam->content_id}"] = '';
    $form['content_type']["{$spam->content_type}-{$spam->content_id}"] = array(
      '#value' => $spam->content_type,
    );
    $title = spam_invoke_module($spam->content_type, 'title', $spam->content_id);
    $link = spam_invoke_module($spam->content_type, 'edit_link', $spam->content_id);
    $form['title']["{$spam->content_type}-{$spam->content_id}"] = array(
      '#value' => l($title, $link),
    );
    $form['score']["{$spam->content_type}-{$spam->content_id}"] = array(
      '#value' => $spam->score,
    );
    $status = spam_invoke_module($spam->content_type, 'status', $spam->content_id);
    $form['status']["{$spam->content_type}-{$spam->content_id}"] = array(
      '#value' => $status == SPAM_PUBLISHED ? t('published') : t('not published'),
    );
    $form['hostname']["{$spam->content_type}-{$spam->content_id}"] = array(
      '#value' => $spam->hostname,
    );
    $feedback = db_result(db_query("SELECT bid FROM {spam_filters_errors} WHERE content_type = '%s' AND content_id = %d", $spam->content_type, $spam->content_id));
    if ($feedback) {
      $form['feedback']["{$spam->content_type}-{$spam->content_id}"] = array(
        '#value' => l('view', "admin/content/spam/feedback/{$feedback}"),
      );
    }
    else {
      $form['feedback']["{$spam->content_type}-{$spam->content_id}"] = array(
        '#value' => '<em>n/a</em>',
      );
    }

    //$form['operations']["$spam->content_type-$spam->content_id"] = array('#value' => l(t('edit'), 'node/'. $ad->aid .'/edit', array(), $destination));
  }
  $form['spam'] = array(
    '#type' => 'checkboxes',
    '#options' => $all,
  );
  $form['pager'] = array(
    '#value' => theme('pager', NULL, 50, 0),
  );
  return $form;
}