You are here

protected function Notifications_Scheduler_New_Posts::load_content in Notifications 7

Load nodes created and published since last time this was executed. It doesn't check node access

Overrides Notifications_Scheduler_Latest_Posts::load_content

File

notifications_scheduler/notifications_scheduler.inc, line 268
Drupal Notifications Framework - Default class file

Class

Notifications_Scheduler_New_Posts
Send new content posted since last notification.

Code

protected function load_content() {

  // Only nodes updated since last time
  $query = db_select('node', 'n')
    ->fields('n', array(
    'nid',
    'created',
  ))
    ->orderBy('n.created', 'DESC')
    ->condition('n.status', 1)
    ->condition('n.changed', $this
    ->get_last_time(), '>=')
    ->extend('PagerDefault')
    ->limit($this
    ->get_action_context('node_number', 50));
  if ($type = $this
    ->get_action_context('node_type')) {
    $query
      ->condition('type', $type);
  }
  if ($tid = $this
    ->get_action_context('taxonomy_term')) {
    $query
      ->join('taxonomy_index', 't', 'n.nid = t.nid');
    $query
      ->condition('t.tid', $tid);
  }
  if ($nids = $query
    ->execute()
    ->fetchCol()) {
    return node_load_multiple($nids);
  }
}