You are here

function spam_reported_nodes_overview in Spam 5

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

File

./spam.module, line 2465

Code

function spam_reported_nodes_overview() {

  //drupal_set_html_head(spam_javascript());
  $operations = array(
    'IGNORE' => t('Ignore the selected nodes'),
    'SPAM' => t('Mark the selected nodes as spam'),
    'DELETE' => t('Delete the selected nodes (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_reported_nodes_overview');
  $form['header'] = array(
    '#type' => 'value',
    '#value' => array(
      $selectButton,
      array(
        'data' => t('times reported'),
        'field' => 'count',
        'sort' => 'desc',
      ),
      array(
        'data' => t('last reported'),
        'field' => 's.timestamp',
      ),
      array(
        'data' => t('reported by'),
        'field' => 'r.name',
      ),
      array(
        'data' => t('title'),
        'field' => 'title',
      ),
      array(
        'data' => t('type'),
        'field' => 'type',
      ),
      array(
        'data' => t('author'),
        'field' => 'u.name',
      ),
      array(
        'data' => t('hostname'),
        'field' => 'hostname',
      ),
      array(
        'data' => t('status'),
        'field' => 'status',
      ),
      array(
        'data' => t('timestamp'),
        'field' => 'n.changed',
        'sort' => 'desc',
      ),
      array(
        'data' => t('operations'),
        'colspan' => 3,
      ),
    ),
  );
  $sql = "SELECT n.*, count(r.rid) as count, r.source, r.rid, r.id, r.uid as ruid, r.hostname, r.feedback, r.timestamp FROM {node} n, {spam_reported} r WHERE r.source = 'node' AND r.id = n.nid GROUP BY r.id";
  $sql .= tablesort_sql($form['header']['#value']);
  $result = pager_query($sql, variable_get('spam_display_quantity', 50));

  // build a table listing the appropriate comments
  while ($node = db_fetch_object($result)) {
    $nodes[$node->nid] = '';
    $form['times_reported'][$node->nid] = array(
      '#value' => $node->count,
    );
    $form['last_reported'][$node->nid] = array(
      '#value' => format_date($node->timestamp, 'small'),
    );
    $form['reported_by'][$node->nid] = array(
      '#value' => theme('username', user_load(array(
        'uid' => $node->ruid,
      ))),
    );
    $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', user_load(array(
        'uid' => $node->uid,
      ))),
    );
    $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('Details'), "admin/content/spam/reported/node/{$node->nid}/details", array(
        'title' => htmlspecialchars(substr($node->feedback, 0, 128)),
      )) . '&nbsp;' . l(t('Edit'), "node/{$node->nid}/edit"),
    );
  }
  $form['nodes'] = array(
    '#type' => 'checkboxes',
    '#options' => $nodes,
  );
  $form['pager'] = array(
    '#value' => theme('pager', NULL, variable_get('spam_display_quantity', 50), 0),
  );
  return $form;
}