function simplenews_subscriptions_admin_form in Simplenews 7
Same name and namespace in other branches
- 6.2 includes/simplenews.subscription.inc \simplenews_subscriptions_admin_form()
- 7.2 includes/simplenews.subscription.inc \simplenews_subscriptions_admin_form()
FAPI ADMIN subscription form.
Menu callback: handle the edit subscription page and a subscription page for anonymous users.
See also
simplenews_subscriptions_admin_form_validate()
simplenews_subscriptions_admin_form_submit()
1 string reference to 'simplenews_subscriptions_admin_form'
- simplenews_menu in ./
simplenews.module - Implements hook_menu().
File
- includes/
simplenews.subscription.inc, line 719 - (Un)subscription and (un)subscription confirmation
Code
function simplenews_subscriptions_admin_form($form, &$form_state, $snid) {
$subscriber = simplenews_subscriber_load($snid);
$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_category_get_visible() as $newsletter) {
$options[$newsletter->tid] = check_plain(_simplenews_newsletter_name($newsletter));
$default_value[$newsletter->tid] = FALSE;
}
$form['subscriptions'] = array(
'#title' => t('Subscriptions for %mail', array(
'%mail' => $subscriber->mail,
)),
'#type' => 'fieldset',
'#description' => t('Select the newsletter(s) to add/remove from subscription.'),
);
$form['subscriptions']['newsletters'] = array(
'#type' => 'checkboxes',
'#options' => $options,
'#default_value' => array_merge($default_value, $subscriber->tids),
);
$form['activated'] = array(
'#title' => t('Activation'),
'#type' => 'fieldset',
'#description' => t('Activate or inactivate account.'),
);
$form['activated']['activated'] = array(
'#type' => 'checkbox',
'#title' => t('Activated'),
'#default_value' => $subscriber->activated,
);
if (variable_get('language_count', 1) > 1) {
$languages = language_list('enabled');
foreach ($languages[1] as $langcode => $item) {
$name = t($item->name);
$language_options[$langcode] = $name . ($item->native != $name ? ' (' . $item->native . ')' : '');
}
$form['language'] = array(
'#type' => 'fieldset',
'#title' => t('Preferred language'),
'#description' => t('The e-mails will be localized in language chosen. Real users have their preference in account settings.'),
'#disabled' => FALSE,
);
if ($subscriber->uid) {
// Fallback if user has not defined a language.
$language_default = t('Site default language (@name)', array(
'@name' => $language_options[language_default()->language],
));
$form['language']['language'] = array(
'#type' => 'item',
'#title' => t('User language'),
'#markup' => isset($language_options[$subscriber->language]) ? $language_options[$subscriber->language] : $language_default,
);
}
else {
$form['language']['language'] = array(
'#type' => 'select',
'#default_value' => $subscriber->language,
'#options' => $language_options,
);
}
}
$form['subscriptions']['mail'] = array(
'#type' => 'value',
'#value' => $subscriber->mail,
);
$form['update'] = array(
'#type' => 'submit',
'#value' => t('Update'),
'#weight' => 20,
);
$form['#validate'][] = 'simplenews_subscriptions_admin_form_validate';
$form['#submit'][] = 'simplenews_subscriptions_admin_form_submit';
$form['#redirect'] = 'admin/content/simplenews/users';
return $form;
}