You are here

node_expire.inc in Node expire 6

Non hook functions.

File

node_expire.inc
View source
<?php

/**
 * @file
 * Non hook functions.
 */

/**
 * List all currently expired nodes
 */
function node_expire_outdated_nodes() {

  // Prepare for the content
  $header = array(
    array(
      'data' => t('Title'),
      'field' => 'b.title',
    ),
    array(
      'data' => t('Last Updated'),
      'field' => 'b.changed',
      'width' => '150px',
    ),
    array(
      'data' => t('Expiration Date'),
      'field' => 'a.expire',
      'sort' => 'asc',
      'width' => '150px',
    ),
    array(
      'data' => t('Owner'),
      'field' => 'c.name',
    ),
    array(
      'data' => t('Operations'),
      'colspan' => '2',
    ),
  );

  // Figure out what documents are old
  $query = db_query("SELECT a.nid, a.expire, b.title, b.changed, c.name\n    FROM {node_expire} a\n    LEFT JOIN {node} b ON a.nid = b.nid\n    LEFT JOIN {users} c ON b.uid = c.uid\n    WHERE a.expire <= %d AND a.expiremode <> %d AND b.status = 1" . tablesort_sql($header), time(), NODE_EXPIRE_NONE);
  while ($node = db_fetch_object($query)) {
    $data[] = $node;
  }
  return theme('node_expire_outdated_nodes', $header, $data);
}

/**
 * List all currently expired nodes
 *
 * @ingroup themable
 */
function theme_node_expire_outdated_nodes($header, $data) {

  // No results? Everything must be current.
  if (empty($data)) {
    $rows[] = array(
      array(
        'data' => t('No content are expired!'),
        'colspan' => '5',
        'align' => 'center',
      ),
    );
  }
  else {
    foreach ($data as $node) {
      $rows[] = array(
        $node->title,
        format_date($node->changed, 'small'),
        $node->expire == 0 ? t('Never') : format_date($node->expire, 'small'),
        !empty($node->name) ? $node->name : variable_get('anonymous', 'Anonymous'),
        array(
          'data' => l(t('view'), 'node/' . $node->nid),
          'align' => 'center',
          'width' => '50px',
        ),
        array(
          'data' => l(t('edit'), 'node/' . $node->nid . '/edit'),
          'align' => 'center',
          'width' => '50px',
        ),
      );
    }
  }
  return theme('table', $header, $rows);
}

Functions

Namesort descending Description
node_expire_outdated_nodes List all currently expired nodes
theme_node_expire_outdated_nodes List all currently expired nodes