You are here

function simplenews_subscription_list_add in Simplenews 6.2

Same name and namespace in other branches
  1. 5 simplenews.module \simplenews_subscription_list_add()
  2. 6 simplenews.admin.inc \simplenews_subscription_list_add()
  3. 7.2 includes/simplenews.admin.inc \simplenews_subscription_list_add()
  4. 7 includes/simplenews.admin.inc \simplenews_subscription_list_add()

Menu callback: Mass subscribe to newsletters.

@todo Add 32char description field as subscription source

See also

simplenews_subscription_list_add_submit()

1 string reference to 'simplenews_subscription_list_add'
simplenews_menu in ./simplenews.module
Implementation of hook_menu().

File

includes/simplenews.admin.inc, line 466
Newsletter admin, subscription admin, simplenews settings

Code

function simplenews_subscription_list_add() {
  global $language;
  $form['emails'] = array(
    '#type' => 'textarea',
    '#title' => t('Email addresses'),
    '#cols' => 60,
    '#rows' => 5,
    '#description' => t('Email addresses must be separated by comma, space or newline.'),
  );
  $newsletters = array();
  foreach (simplenews_get_newsletters(variable_get('simplenews_vid', ''), TRUE) as $newsletter) {
    $newsletters[$newsletter->tid] = check_plain($newsletter->name);
  }
  $form['newsletters'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Subscribe to'),
    '#options' => $newsletters,
    '#required' => TRUE,
  );

  // Include language selection when the site is multilingual.
  // Default value is the empty string which will result in receiving emails
  // in the site's default language.
  if (variable_get('language_count', 1) > 1) {
    $options[''] = t('Site default language');
    $languages = language_list('enabled');
    foreach ($languages[1] as $langcode => $item) {
      $name = t($item->name);
      $options[$langcode] = $name . ($item->native != $name ? ' (' . $item->native . ')' : '');
    }
    $form['language'] = array(
      '#type' => 'radios',
      '#title' => t('Anonymous user preferred language'),
      '#default_value' => '',
      '#options' => $options,
      '#description' => t('New anonymous mail addresses will be subscribed with the selected preferred language. Registered users will be subscribed with their preferred language as set on their account page. The language of existing subscribers is unchanged.'),
    );
  }
  else {
    $form['language'] = array(
      '#type' => 'value',
      '#value' => '',
    );
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Subscribe'),
  );
  return $form;
}