You are here

function simplenews_scheduler_node_page in Simplenews Scheduler 7

Same name and namespace in other branches
  1. 5 simplenews_scheduler.module \simplenews_scheduler_node_page()
  2. 6.2 simplenews_scheduler.module \simplenews_scheduler_node_page()
  3. 6 simplenews_scheduler.module \simplenews_scheduler_node_page()

Menu callback to provide an overview page with the scheduled newsletters.

@todo replace the output of this function with a default view that will be provided by the views integration of this module. Code below is ported from D6!

1 string reference to 'simplenews_scheduler_node_page'
simplenews_scheduler_menu in ./simplenews_scheduler.module
Implements hook_menu().

File

./simplenews_scheduler.module, line 592
Simplenews Scheduler module allows a schedule to be set for sending (and resending) a Simplenews item.

Code

function simplenews_scheduler_node_page($node) {
  drupal_set_title(t('Scheduled newsletter editions'));
  $nid = _simplenews_scheduler_get_pid($node);
  $output = '';
  $rows = array();
  if ($nid == $node->nid) {

    // This is the template newsletter.
    $output .= '<p>' . t('This is a newsletter template node of which all corresponding editions nodes are based on.') . '</p>';
  }
  else {

    // This is a newsletter edition.
    $output .= '<p>' . t('This node is part of a scheduled newsletter configuration. View the original newsletter <a href="@parent">here</a>.', array(
      '@parent' => url('node/' . $nid),
    )) . '</p>';
  }

  // Load the corresponding editions from the database to further process.
  $result = db_select('simplenews_scheduler_editions', 's')
    ->extend('PagerDefault')
    ->limit(20)
    ->fields('s')
    ->condition('s.pid', $nid)
    ->execute()
    ->fetchAll();
  foreach ($result as $row) {
    $node = node_load($row->eid);
    $rows[] = array(
      l($node->title, 'node/' . $row->eid),
      format_date($row->date_issued, 'custom', 'Y-m-d H:i'),
    );
  }

  // Display a table with all editions.
  $tablecontent = array(
    'header' => array(
      t('Edition Node'),
      t('Date sent'),
    ),
    'rows' => $rows,
    'attributes' => array(
      'class' => array(
        'schedule-history',
      ),
    ),
    'empty' => '<p>' . t('No scheduled newsletter editions have been sent.') . '</p>',
  );
  $output .= theme('table', $tablecontent);
  $output .= theme('pager', array(
    'tags' => 20,
  ));
  return $output;
}