function simplenews_subscriptions_admin_form in Simplenews 6.2
Same name and namespace in other branches
- 7.2 includes/simplenews.subscription.inc \simplenews_subscriptions_admin_form()
- 7 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 - Implementation of hook_menu().
File
- includes/
simplenews.subscription.inc, line 625 - (Un)subscription and (un)subscription confirmation
Code
function simplenews_subscriptions_admin_form(&$form_state, $snid) {
$account = (object) array(
'snid' => $snid,
);
$subscription = simplenews_get_subscription($account);
$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['subscriptions'] = array(
'#title' => t('Subscriptions for %mail', array(
'%mail' => $subscription->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, (array) $subscription->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' => $subscription->activated,
);
if (variable_get('language_count', 1) > 1) {
// TODO we could allow to switch back to "default", but user_load
//$language_options[''] = t('Site default language');
$languages = language_list('enabled');
foreach ($languages[1] as $langcode => $item) {
$name = t($item->name);
$language_options[$langcode] = $name . ($item->native != $name ? ' (' . $item->native . ')' : '');
}
// std users have language in profile. disable
$disabled = $subscription->uid ? TRUE : FALSE;
$form['language'] = array(
'#type' => 'fieldset',
'#title' => 'Preferred language',
'#description' => t('The emails will be localized in language chosen. Real users have their preference in account settings.'),
'#disabled' => FALSE,
);
if ($subscription->uid) {
// fapi error: disabled not supported for select type. workaround: output markup
$form['language']['language'] = array(
'#type' => 'markup',
'#value' => $language_options[$subscription->language->language],
);
}
else {
$form['language']['language'] = array(
'#type' => 'select',
'#default_value' => $subscription->language->language,
'#options' => $language_options,
);
}
}
$form['subscriptions']['mail'] = array(
'#type' => 'value',
'#value' => $subscription->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;
}