function template_preprocess_simplenews_block in Simplenews 7
Same name and namespace in other branches
- 6.2 simplenews.module \template_preprocess_simplenews_block()
- 6 simplenews.module \template_preprocess_simplenews_block()
- 7.2 simplenews.module \template_preprocess_simplenews_block()
Process variables to format the simplenews block.
Collect data and apply access restrictions.
See also
File
- ./
simplenews.module, line 2352 - Simplenews node handling, sent email, newsletter block and general hooks
Code
function template_preprocess_simplenews_block(&$variables) {
global $user;
$tid = $variables['tid'];
$category = simplenews_category_load($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')) {
module_load_include('inc', 'simplenews', 'simplenews.subscription');
$variables['form'] = drupal_get_form('simplenews_block_form_' . $tid);
$variables['subscription_link'] = l(t('Manage my subscriptions'), 'newsletter/subscriptions');
}
// @todo replace path
$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'] = '';
if ($recent) {
$variables['issue_list'] = theme('item_list', array(
'items' => $recent,
'title' => t('Previous issues'),
'type' => 'ul',
));
}
$variables['rssfeed'] = theme('feed_icon', array(
'url' => 'taxonomy/term/' . $tid . '/feed',
'title' => t('@newsletter feed', array(
'@newsletter' => _simplenews_newsletter_name($category),
)),
));
// 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);
}