You are here

function scheduler_list in Scheduler 5

Same name and namespace in other branches
  1. 6 scheduler.module \scheduler_list()
  2. 7 scheduler.admin.inc \scheduler_list()
1 string reference to 'scheduler_list'
scheduler_menu in ./scheduler.module
Implementation of hook_menu().

File

./scheduler.module, line 159

Code

function scheduler_list() {
  $header = array(
    array(
      'data' => t('Title'),
      'field' => 'n.title',
    ),
    array(
      'data' => t('Author'),
      'field' => 'u.name',
    ),
    array(
      'data' => t('Publish on'),
      'field' => 's.publish_on',
    ),
    array(
      'data' => t('Unpublish on'),
      'field' => 's.unpublish_on',
    ),
    array(
      'data' => t('Operations'),
    ),
  );

  // Default ordering
  if (!isset($_GET['order']) && !isset($_GET['sort'])) {
    $_GET['order'] = t('Publish on');
    $_GET['sort'] = 'ASC';
  }
  $sql = 'SELECT n.nid, n.uid, n.status, u.name, n.title, s.publish_on, s.unpublish_on FROM {scheduler} s LEFT JOIN {node} n ON s.nid = n.nid LEFT JOIN {users} u ON n.uid = u.uid' . tablesort_sql($header);
  $result = pager_query($sql, 50);
  while ($node = db_fetch_object($result)) {
    $rows[] = array(
      l($node->title, "node/{$node->nid}"),
      theme('username', $node),
      $node->publish_on ? format_date($node->publish_on) : ' ',
      $node->unpublish_on ? format_date($node->unpublish_on) : ' ',
      l(t('edit'), 'node/' . $node->nid . '/edit', array(), 'destination=admin/content/node/scheduler'),
    );
  }
  if (count($rows)) {
    if ($pager = theme('pager', NULL, 50, 0)) {
      $rows[] = array(
        array(
          'data' => $pager,
          'colspan' => 6,
        ),
      );
    }
    print theme('page', theme('table', $header, $rows));
  }
  else {
    print theme('page', t('There are no scheduled nodes.'));
  }
}