public function SimplenewsSpool::nextSource in Simplenews 7
Same name and namespace in other branches
- 7.2 includes/simplenews.source.inc \SimplenewsSpool::nextSource()
Implements SimplenewsSpoolInterface::nextSource();
Overrides SimplenewsSpoolInterface::nextSource
File
- includes/
simplenews.source.inc, line 270 - Contains SimplenewsSource interface and implementations.
Class
- SimplenewsSpool
- Simplenews Spool implementation.
Code
public function nextSource() {
// Get the current mail spool row and update the internal pointer to the
// next row.
$return = each($this->spool_list);
// If we're done, return false.
if (!$return) {
return FALSE;
}
$spool_data = $return['value'];
// Store this spool row as processed.
$this->processed[$spool_data->msid] = $spool_data;
$node = node_load($spool_data->nid);
if (!$node) {
// If node the load failed, set the processed status done and proceed with
// the next mail.
$this->processed[$spool_data->msid]->result = array(
'status' => SIMPLENEWS_SPOOL_DONE,
'error' => TRUE,
);
return $this
->nextSource();
}
if ($spool_data->data) {
$subscriber = $spool_data->data;
}
else {
$subscriber = simplenews_subscriber_load_by_mail($spool_data->mail);
}
if (!$subscriber) {
// If loading the subscriber failed, set the processed status done and
// proceed with the next mail.
$this->processed[$spool_data->msid]->result = array(
'status' => SIMPLENEWS_SPOOL_DONE,
'error' => TRUE,
);
return $this
->nextSource();
}
$source_class = $this
->getSourceImplementation($spool_data);
$source = new $source_class($node, $subscriber);
// Set which node is actually used. In case of a translation set, this might
// not be the same node.
$this->processed[$spool_data->msid]->actual_nid = $source
->getNode()->nid;
return $source;
}