function simplenews_subscriptions_multi_block_form in Simplenews 6.2
Same name and namespace in other branches
- 7.2 includes/simplenews.subscription.inc \simplenews_subscriptions_multi_block_form()
- 7 includes/simplenews.subscription.inc \simplenews_subscriptions_multi_block_form()
FAPI MULTI BLOCK subscription form.
Menu callback: Generates the subscription form for users for the multisignup block.
See also
simplenews_subscriptions_multi_block_form_validate()
simplenews_subscriptions_multi_block_form_submit()
1 string reference to 'simplenews_subscriptions_multi_block_form'
- template_preprocess_simplenews_multi_block in ./
simplenews.module - Process variables to format the simplenews newsletter footer.
File
- includes/
simplenews.subscription.inc, line 382 - (Un)subscription and (un)subscription confirmation
Code
function simplenews_subscriptions_multi_block_form(&$form_state) {
global $user;
$subscription = simplenews_get_subscription($user);
// If someone not authorized to edit their subscription, return empty form.
if (!user_access('subscribe to newsletters')) {
return;
}
$form = array();
$options = array();
$default_value = array();
// Get newsletters for subscription form checkboxes.
// Newsletters with opt-in/out method 'hidden' will not be listed.
foreach (simplenews_get_newsletters(variable_get('simplenews_vid', '')) as $newsletter) {
$options[$newsletter->tid] = check_plain($newsletter->name);
$default_value[$newsletter->tid] = FALSE;
}
$form['newsletters'] = array(
'#type' => 'checkboxes',
'#options' => $options,
'#default_value' => array_merge($default_value, (array) $subscription->tids),
);
// If current user is logged in, just display email.
// Anonymous users see an email box and will receive confirmations
if ($subscription->mail) {
// @todo why not simply Manage your subscriptions?
$form['mail'] = array(
'#type' => 'value',
'#value' => $subscription->mail,
);
$form['update'] = array(
'#type' => 'submit',
'#value' => t('Update'),
'#weight' => 20,
);
}
else {
$form['mail'] = array(
'#type' => 'textfield',
'#title' => t('Email'),
'#size' => 20,
'#maxlength' => 128,
'#weight' => 10,
'#required' => TRUE,
);
$form['subscribe'] = array(
'#type' => 'submit',
'#value' => t('Subscribe'),
'#weight' => 20,
);
$form['unsubscribe'] = array(
'#type' => 'submit',
'#value' => t('Unsubscribe'),
'#weight' => 30,
);
}
$form['#validate'][] = 'simplenews_subscriptions_page_form_validate';
$form['#submit'][] = 'simplenews_subscriptions_page_form_submit';
return $form;
}