function template_preprocess_simplenews_block in Simplenews 6.2
Same name and namespace in other branches
- 6 simplenews.module \template_preprocess_simplenews_block()
- 7.2 simplenews.module \template_preprocess_simplenews_block()
- 7 simplenews.module \template_preprocess_simplenews_block()
Process variables to format the simplenews block.
Collect data and apply access restrictions.
$variables
See also
File
- ./
simplenews.module, line 2474 - Simplenews 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
// @todo: clean localization / i18n needed
$variables['message'] = check_plain(variable_get('simplenews_block_m_' . $tid, t('Stay informed on our latest news!')));
if (user_access('subscribe to newsletters')) {
module_load_include('inc', 'simplenews', 'includes/simplenews.subscription');
$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);
}