function simplenews_newsletter_load_multiple in Simplenews 7
Same name and namespace in other branches
- 8 simplenews.module \simplenews_newsletter_load_multiple()
- 7.2 simplenews.module \simplenews_newsletter_load_multiple()
@todo
Related topics
2 calls to simplenews_newsletter_load_multiple()
- simplenews_newsletter_load in ./
simplenews.module - @todo
- simplenews_node_load in ./
simplenews.module - Implements hook_node_load().
File
- ./
simplenews.module, line 1960 - Simplenews node handling, sent email, newsletter block and general hooks
Code
function simplenews_newsletter_load_multiple($nids = array(), $conditions = array(), $reset = FALSE) {
$newsletters =& drupal_static(__FUNCTION__, array());
// We only cache if all records are loaded from the database,
// unless reset is forced.
if (!$newsletters || $nids || $conditions || $reset) {
$newsletters = array();
$query = db_select('simplenews_newsletter', 'sn');
$query
->innerJoin('taxonomy_term_data', 't', 't.tid = sn.tid');
$query
->fields('sn')
->fields('t', array(
'name',
'description',
'weight',
))
->orderBy('t.weight', 'ASC');
if ($nids) {
$query
->condition('nid', $nids);
}
if ($conditions) {
foreach ($conditions as $key => $condition) {
$query
->condition($key, $condition);
}
}
$newsletters = $query
->execute()
->fetchAllAssoc('nid');
}
return $newsletters;
}