You are here

function template_preprocess_simplenews_block in Simplenews 6

Same name and namespace in other branches
  1. 6.2 simplenews.module \template_preprocess_simplenews_block()
  2. 7.2 simplenews.module \template_preprocess_simplenews_block()
  3. 7 simplenews.module \template_preprocess_simplenews_block()

Process variables to format the simplenews block.

Collect data and apply access restrictions.

$variables contains:

  • $tid

See also

simplenews-block.tpl.php

theme_simplenews-block()

File

./simplenews.module, line 2477
Simplnews node handling, sent email, newsletter block and general hooks

Code

function template_preprocess_simplenews_block(&$variables) {
  global $user;
  $tid = $variables['tid'];

  // Set default values in case of missing permission.
  $variables['form'] = '';
  $variables['subscription_link'] = '';
  $variables['newsletter_link'] = '';
  $variables['issue_list'] = '';
  $variables['rssfeed'] = '';

  // Block content variables
  $variables['message'] = check_plain(variable_get('simplenews_block_m_' . $tid, t('Stay informed on our latest news!')));
  if (user_access('subscribe to newsletters')) {
    $variables['form'] = drupal_get_form('simplenews_block_form_' . $tid);
    $variables['subscription_link'] = l(t('Manage my subscriptions'), 'newsletter/subscriptions');
  }
  $variables['newsletter_link'] = l(t('Previous issues'), 'taxonomy/term/' . $tid);
  $recent = simplenews_recent_newsletters($tid, variable_get('simplenews_block_i_' . $tid, 5));
  $variables['issue_list'] = theme('item_list', $recent, t('Previous issues'), 'ul');
  $term = taxonomy_get_term($tid);
  $variables['rssfeed'] = theme('feed_icon', url('taxonomy/term/' . $tid . '/0/feed'), t('@newsletter feed', array(
    '@newsletter' => $term->name,
  )));

  // Block content control variables
  $variables['use_form'] = variable_get('simplenews_block_f_' . $tid, 1);
  $variables['use_issue_link'] = variable_get('simplenews_block_l_' . $tid, 1);
  $variables['use_issue_list'] = variable_get('simplenews_block_i_status_' . $tid, 0);
  $variables['use_rss'] = variable_get('simplenews_block_r_' . $tid, 1);

  // Additional variables
  $variables['subscribed'] = empty($user->uid) ? FALSE : simplenews_user_is_subscribed($user->mail, $tid) == TRUE;
  $variables['user'] = !empty($user->uid);
}