You are here

function newsletter_configure in Newsletter 7

Menu callback; present newsletter configuration.

1 string reference to 'newsletter_configure'
newsletter_menu in ./newsletter.module
Implements hook_menu().

File

includes/newsletter.admin.inc, line 1376
Admin page callbacks for the newsletter module.

Code

function newsletter_configure($form, &$form_state) {
  $lists = db_query('SELECT nlid, title FROM {newsletter_list}')
    ->fetchAllKeyed();
  $personal_info_form = variable_get('newsletter_personal_info_form');
  $personal_info_options = array(
    'hidden' => t('hide'),
    'show' => t('show'),
    'require' => t('require'),
  );
  $form['test'] = array(
    '#attributes' => array(
      'class' => array(
        'container-inline',
      ),
    ),
    '#type' => 'fieldset',
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#title' => t('Send a test Email'),
  );
  $form['test']['newsletter_test_to'] = array(
    '#type' => 'textfield',
    '#title' => t('To'),
    '#default_value' => variable_get('newsletter_test_to', variable_get('site_mail')),
  );
  $form['test']['send_test'] = array(
    '#type' => 'submit',
    '#value' => t('Send'),
  );
  $form['settings'] = array(
    '#type' => 'fieldset',
    '#collapsible' => TRUE,
    '#title' => t('General settings'),
  );
  $form['settings']['newsletter_from'] = array(
    '#type' => 'textfield',
    '#title' => t('From'),
    '#size' => 60,
    '#maxlength' => 128,
    '#default_value' => variable_get('newsletter_from', variable_get('site_mail')),
    '#description' => t('Suggested format: User <user@example.com>'),
  );
  $form['settings']['newsletter_format'] = array(
    '#type' => 'select',
    '#title' => t('Format'),
    '#options' => array(
      'plain' => t('Plain Text'),
      'html' => t('HTML'),
    ),
    '#default_value' => variable_get('newsletter_format', 'html'),
  );
  $form['settings']['newsletter_track_open_rate'] = array(
    '#type' => 'checkbox',
    '#title' => t('Track open rate'),
    '#default_value' => variable_get('newsletter_track_open_rate', FALSE),
    '#description' => t('Enable it, only if you really want the email to be tracked,
      since the method used might cause some email clients to mark your emails as spam'),
  );
  $form['settings']['newsletter_cron_number'] = array(
    '#type' => 'textfield',
    '#title' => t('Number of mails to send per cron run'),
    '#default_value' => variable_get('newsletter_cron_number', 500),
    '#description' => t('The more newsletter lists the smaller this number should be.'),
  );
  $form['settings']['newsletter_node_limit'] = array(
    '#type' => 'textfield',
    '#title' => t('Number of nodes to send per newsletter'),
    '#default_value' => variable_get('newsletter_node_limit', 50),
    '#description' => t('The max number of nodes to send with a newsletter.'),
  );
  $form['settings']['newsletter_send_confirm'] = array(
    '#type' => 'checkbox',
    '#title' => t('Send confirmation email'),
    '#default_value' => variable_get('newsletter_send_confirm'),
    '#description' => t('Attention: If you disable confirmation e-mails, users will be able to subscribe others without their permission.'),
  );
  $form['settings']['newsletter_send_welcome'] = array(
    '#type' => 'checkbox',
    '#title' => t('Send welcome email'),
    '#default_value' => variable_get('newsletter_send_welcome'),
  );
  $form['settings']['newsletter_send_unsubscribe'] = array(
    '#type' => 'checkbox',
    '#title' => t('Send unsubscribe email, after a subscriber decides to unsubscribe'),
    '#default_value' => variable_get('newsletter_send_unsubscribe'),
  );
  $form['settings']['newsletter_auto_subscribe_new_users'] = array(
    '#type' => 'select',
    '#title' => t('Automatically subscribe newly registered user to the selected lists:'),
    '#options' => array_map('check_plain', $lists),
    '#multiple' => TRUE,
    '#description' => t('Leave empty to bypass this feature'),
    '#default_value' => variable_get('newsletter_auto_subscribe_new_users', array()),
  );
  $form['settings']['newsletter_use_smtp'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable SMTP support'),
    '#default_value' => variable_get('newsletter_use_smtp', FALSE),
    '#description' => t('Requires <a href=@url>SMTP</a> module', array(
      '@url' => 'http://drupal.org/project/smtp',
    )),
  );
  $form['subscribe_form'] = array(
    '#type' => 'fieldset',
    '#title' => t('Subscribe form'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['subscribe_form']['newsletter_show_email'] = array(
    '#type' => 'checkbox',
    '#title' => t('Always show e-mail in the subscribe form.'),
    '#default_value' => variable_get('newsletter_show_email', TRUE),
  );
  $form['subscribe_form']['newsletter_show_email_in_block'] = array(
    '#type' => 'checkbox',
    '#title' => t('Always show e-mail in the subscribe form block.'),
    '#default_value' => variable_get('newsletter_show_email_in_block', FALSE),
  );
  $form['subscribe_form']['newsletter_always_show_subscribe_block'] = array(
    '#type' => 'checkbox',
    '#title' => t('Always show subscribe block,even if user is subscribed.'),
    '#default_value' => variable_get('newsletter_always_show_subscribe_block', FALSE),
  );
  $form['subscribe_form']['newsletter_personal_info_form'] = array(
    '#type' => 'fieldset',
    '#title' => t('Personal info form'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#tree' => TRUE,
  );
  $form['subscribe_form']['newsletter_personal_info_form']['firstname'] = array(
    '#attributes' => array(
      'class' => array(
        'container-inline',
      ),
    ),
    '#type' => 'radios',
    '#title' => t('First Name (textfield)'),
    '#options' => $personal_info_options,
    '#default_value' => $personal_info_form['firstname'],
  );
  $form['subscribe_form']['newsletter_personal_info_form']['lastname'] = array(
    '#attributes' => array(
      'class' => array(
        'container-inline',
      ),
    ),
    '#type' => 'radios',
    '#title' => t('Last Name (textfield)'),
    '#options' => $personal_info_options,
    '#default_value' => $personal_info_form['lastname'],
  );
  $form['subscribe_form']['newsletter_personal_info_form']['gender'] = array(
    '#attributes' => array(
      'class' => array(
        'container-inline',
      ),
    ),
    '#type' => 'radios',
    '#title' => t('Gender (select)'),
    '#options' => $personal_info_options,
    '#default_value' => $personal_info_form['gender'],
  );
  $form['subscribe_form']['newsletter_personal_info_form']['receive_format'] = array(
    '#attributes' => array(
      'class' => array(
        'container-inline',
      ),
    ),
    '#type' => 'radios',
    '#title' => t('Preferred Format (select)'),
    '#options' => $personal_info_options,
    '#default_value' => $personal_info_form['receive_format'],
  );
  $form = system_settings_form($form);
  $form['#submit'][] = 'newsletter_configure_submit';
  return $form;
}