function simplenews_block_form in Simplenews 6
Same name and namespace in other branches
- 5 simplenews.module \simplenews_block_form()
- 6.2 includes/simplenews.subscription.inc \simplenews_block_form()
- 7.2 includes/simplenews.subscription.inc \simplenews_block_form()
- 7 includes/simplenews.subscription.inc \simplenews_block_form()
Newsletter (un)subscription form for authenticated and anonymous users.
Parameters
$tid term id of selected newsletter.:
See also
simplenews_block_form_validate()
simplenews_block_form_submit()
1 string reference to 'simplenews_block_form'
- simplenews_forms in ./
simplenews.module - Implementation of hook_forms().
File
- ./
simplenews.module, line 1302 - Simplnews node handling, sent email, newsletter block and general hooks
Code
function simplenews_block_form(&$form_state, $tid) {
global $user;
$form = array();
if ($user->uid) {
if (simplenews_user_is_subscribed($user->mail, $tid)) {
$submit_text = t('Unsubscribe');
$form['action'] = array(
'#type' => 'value',
'#value' => 'unsubscribe',
);
}
else {
$submit_text = t('Subscribe');
$form['action'] = array(
'#type' => 'value',
'#value' => 'subscribe',
);
}
$form['display_mail'] = array(
'#type' => 'item',
'#title' => t('User'),
'#value' => check_plain($user->name),
);
$form['mail'] = array(
'#type' => 'value',
'#value' => $user->mail,
);
}
else {
$form['mail'] = array(
'#type' => 'textfield',
'#title' => t('Email'),
'#size' => 20,
'#maxlength' => 128,
'#required' => TRUE,
);
$form['action'] = array(
'#type' => 'radios',
'#default_value' => 'subscribe',
'#options' => array(
'subscribe' => t('Subscribe'),
'unsubscribe' => t('Unsubscribe'),
),
);
}
// All block forms use the same validate and submit function.
// #tid carries the tid for processing of the right newsletter issue term.
$form['#tid'] = $tid;
$form['#validate'][] = 'simplenews_block_form_validate';
$form['#submit'][] = 'simplenews_block_form_submit';
$form['submit'] = array(
'#type' => 'submit',
'#value' => isset($submit_text) ? $submit_text : t('Save'),
);
return $form;
}