You are here

function simplenews_categories_load_multiple in Simplenews 7

@todo

Related topics

17 calls to simplenews_categories_load_multiple()
SimpleNewsAdministrationTestCase::testCategorySettings in tests/simplenews.test
Test various combinations of newsletter category settings.
SimpleNewsAdministrationTestCase::testSubscriptionManagement in tests/simplenews.test
Test newsletter subscription management.
SimplenewsSubscribeTestCase::testSubscribeMultiple in tests/simplenews.test
Subscribe to multiple newsletters at the same time.
simplenews_admin_categories in includes/simplenews.admin.inc
Menu callback: list admin form with list of available list categories.
simplenews_block_info in ./simplenews.module
Implements hook_block_info().

... See full list

3 string references to 'simplenews_categories_load_multiple'
SimpleNewsAdministrationTestCase::testCategorySettings in tests/simplenews.test
Test various combinations of newsletter category settings.
SimpleNewsAdministrationTestCase::testSubscriptionManagement in tests/simplenews.test
Test newsletter subscription management.
SimplenewsSubscribeTestCase::testSubscribeMultiple in tests/simplenews.test
Subscribe to multiple newsletters at the same time.

File

./simplenews.module, line 1834
Simplenews node handling, sent email, newsletter block and general hooks

Code

function simplenews_categories_load_multiple($tids = array(), $conditions = array(), $reset = FALSE) {
  $categories =& drupal_static(__FUNCTION__, array());

  // Only cache if we load all records from the database. This could be improved.
  if (!$categories || $tids || $conditions || $reset) {
    $categories = array();
    $query = db_select('simplenews_category', 'sc');

    // This function might be called when the corresponding taxonomy term was
    // already deleted.
    $query
      ->leftJoin('taxonomy_term_data', 't', 't.tid = sc.tid');
    $query
      ->fields('sc')
      ->fields('t', array(
      'name',
      'description',
      'weight',
      'vid',
    ))
      ->orderBy('t.weight', 'ASC');
    if ($tids) {
      $query
        ->condition('sc.tid', $tids);
    }
    if ($conditions) {
      foreach ($conditions as $key => $condition) {
        if ($key == 'show_all') {
          if (!$condition) {
            $query
              ->condition('opt_inout', SIMPLENEWS_OPT_INOUT_HIDDEN, '<>');
          }
        }
        else {
          $query
            ->condition($key, $condition);
        }
      }
    }
    $categories = $query
      ->execute()
      ->fetchAllAssoc('tid');
  }
  return $categories;
}