function simplenews_node_load in Simplenews 7
Implements hook_node_load().
File
- ./
simplenews.module, line 519 - Simplenews node handling, sent email, newsletter block and general hooks
Code
function simplenews_node_load($nodes, $types) {
// We only support Simplenews enabled content types.
if (!simplenews_check_node_types($types)) {
return;
}
$newsletters = simplenews_newsletter_load_multiple(array_keys($nodes));
foreach ($nodes as $nid => $node) {
// We can have multiple nodes where not all of them are simplenews enabled
// content type. So we need to check for each individual node is it
// simplenews enabled.
if (!simplenews_check_node_types($node->type)) {
continue;
}
// Make sure every $node has valid newsletter data as object
$newsletter = array();
if (isset($newsletters[$nid])) {
$newsletter = $newsletters[$nid];
}
if (!$newsletter) {
$newsletter = (object) simplenews_newsletter_defaults($node);
}
$nodes[$nid]->simplenews = $newsletter;
}
}