You are here

function simplenews_block_info in Simplenews 7.2

Same name and namespace in other branches
  1. 7 simplenews.module \simplenews_block_info()

Implements hook_block_info().

File

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

Code

function simplenews_block_info() {
  $blocks = array();

  // Special block for multi
  $blocks[0] = array(
    'info' => t('Newsletter: Multi Subscription'),
  );

  // Only list a block if the newsletter is not 'hidden' and marked to provide a block.
  $newsletters = simplenews_newsletter_get_visible(array(
    'block' => '1',
  ));
  if ($newsletters) {
    foreach ($newsletters as $newsletter) {

      // @todo 1. without form -> by role; 2. with form -> user caching with
      // refresh on subscribe/unsubscribe (option as setting) or no caching.
      $blocks[$newsletter->newsletter_id] = array(
        'info' => t('Newsletter: @title', array(
          '@title' => $newsletter->name,
        )),
        // @todo Use block's own settings?
        'cache' => variable_get('simplenews_block_f_' . $newsletter->newsletter_id, 1) ? DRUPAL_NO_CACHE : DRUPAL_CACHE_PER_ROLE,
      );
    }
  }
  return $blocks;
}