You are here

protected function NewsletterAutomated::getNodes in Newsletter 7

Same name and namespace in other branches
  1. 7.2 includes/newsletter.automated.inc \NewsletterAutomated::getNodes()

Get this newsletter nodes if list is not exposed.

Return value

Array containing node objects.

1 call to NewsletterAutomated::getNodes()
NewsletterAutomated::__construct in includes/newsletter.automated.inc

File

includes/newsletter.automated.inc, line 127
Contains NewsletterMail and NewsletterCustom that extend NewsletterBasic.

Class

NewsletterAutomated
Newsletter class that sends automated, non-custom newsletters with dynamic content based on taxonomy terms.

Code

protected function getNodes() {
  $check_exposed = db_query('SELECT *
      FROM {field_data_field_newsletter_list}
      WHERE field_newsletter_list_target_id = :lid AND target_id_tids IS NOT NULL', array(
    ':lid' => $this->list->nlid,
  ))
    ->fetchAll();

  // If we get even one subscriber with custom terms
  // or left nodes from previous cron run
  // then no need to continue here.
  if (!empty($check_exposed) || isset($this->left[$this->list->nlid][0]->nodes)) {
    return 'exposed';
  }
  $nodes = $this
    ->getQuery()
    ->execute()
    ->fetchAll();
  foreach ($nodes as $node) {
    $newsletter_nodes[] = node_load($node->nid);
  }
  return isset($newsletter_nodes) ? $newsletter_nodes : array();
}