You are here

protected function Notifications_Scheduler_Latest_Posts::load_content in Notifications 7

Load nodes created and published or updated since latest time. It doesn't check node access

Overrides Notifications_Scheduler_Event::load_content

1 method overrides Notifications_Scheduler_Latest_Posts::load_content()
Notifications_Scheduler_New_Posts::load_content in notifications_scheduler/notifications_scheduler.inc
Load nodes created and published since last time this was executed. It doesn't check node access

File

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

Class

Notifications_Scheduler_Latest_Posts
Test this schedule class, send latest created nodes

Code

protected function load_content() {
  $query = db_select('node', 'n')
    ->fields('n', array(
    'nid',
    'created',
  ))
    ->orderBy('n.created', 'DESC')
    ->condition('n.status', 1)
    ->extend('PagerDefault')
    ->limit($this
    ->get_action_context('node_number', variable_get('default_nodes_main', 10)));
  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);
  }
}