You are here

function notify_admin_settings in Notify 7

Same name and namespace in other branches
  1. 5.2 notify.module \notify_admin_settings()
  2. 5 notify.module \notify_admin_settings()
  3. 6 notify.module \notify_admin_settings()

Menu callback, show admin notification settings form.

1 string reference to 'notify_admin_settings'
notify_menu in ./notify.module
Implements hook_menu().

File

./notify.admin.inc, line 11
Administrative pages callbacks for the Notify module.

Code

function notify_admin_settings($form, &$form_state) {
  $period = array(
    0 => t('Cron'),
    3600 => format_interval(3600),
    10800 => format_interval(10800),
    21600 => format_interval(21600),
    32400 => format_interval(32400),
    43200 => format_interval(43200),
    86400 => format_interval(86400),
    172800 => format_interval(172800),
    259200 => format_interval(259200),
    604800 => format_interval(604800),
    1209600 => format_interval(1209600),
    2419200 => format_interval(2419200),
    -1 => t('Never'),
  );
  $attempts = array(
    0 => t('Disabled'),
    1 => 1,
    2 => 2,
    3 => 3,
    4 => 4,
    5 => 5,
    6 => 6,
    7 => 7,
    8 => 8,
    9 => 9,
    10 => 10,
    15 => 15,
    20 => 20,
  );
  $batch = array(
    2 => 2,
    3 => 3,
    10 => 10,
    20 => 20,
    50 => 50,
    100 => 100,
    200 => 200,
    400 => 400,
  );
  $form = array();
  $form['notify_settings'] = array(
    '#type' => 'fieldset',
    '#title' => t('E-mail notification settings'),
    '#collapsible' => TRUE,
  );
  $form['notify_settings']['notify_period'] = array(
    '#type' => 'select',
    '#title' => t('Send notifications every'),
    '#default_value' => variable_get('notify_period', 86400),
    '#options' => $period,
    '#description' => t('How often should new content notifications be sent? Requires cron to be running at least this often.'),
  );
  $form['notify_settings']['notify_send_hour'] = array(
    '#type' => 'select',
    '#title' => t('Hour to send notifications'),
    '#description' => t('Specify the hour (24-hour clock) in which notifications should be sent, if the frequency is one day or greater.'),
    '#default_value' => variable_get('notify_send_hour', 9),
    '#options' => array(
      0,
      1,
      2,
      3,
      4,
      5,
      6,
      7,
      8,
      9,
      10,
      11,
      12,
      13,
      14,
      15,
      16,
      17,
      18,
      19,
      20,
      21,
      22,
      23,
    ),
  );
  $form['notify_settings']['notify_attempts'] = array(
    '#type' => 'select',
    '#title' => t('Number of failed sends after which notifications are disabled'),
    '#description' => t('The maximum number of failed attempts to send e-mail to tolerate before notification is suspended.'),
    '#default_value' => variable_get('notify_attempts', 5),
    '#options' => $attempts,
  );
  $form['notify_settings']['notify_batchsize'] = array(
    '#type' => 'select',
    '#title' => t('Maximum number of users to process out per cron run'),
    '#description' => t('The maximum number of users to process in each pass of  a <a href="@cron">cron maintenance task</a>. If necessary, reduce the number of users to prevent resource limit conflicts.', array(
      '@cron' => url('admin/reports/status'),
    )),
    '#default_value' => variable_get('notify_batchsize', 100),
    '#options' => $batch,
  );
  $form['notify_settings']['notify_include_updates'] = array(
    '#type' => 'checkbox',
    '#title' => t('Include updated posts in notifications.'),
    '#return_value' => 1,
    '#default_value' => variable_get('notify_include_updates', 0),
  );
  $form['notify_settings']['notify_unverified'] = array(
    '#type' => 'checkbox',
    '#title' => t('Exclude contents from unverified authors from user notifications.'),
    '#return_value' => 1,
    '#default_value' => variable_get('notify_unverified', 0),
  );
  $form['notify_settings']['notify_unpublished'] = array(
    '#type' => 'checkbox',
    '#title' => t('Administrators shall be notified about unpublished content of tracked types.'),
    '#return_value' => 1,
    '#default_value' => variable_get('notify_unpublished', 1),
  );
  if (drupal_multilingual()) {
    $form['notify_settings']['notify_multilingual'] = array(
      '#type' => 'radios',
      '#title' => t('Multilingual setting &ndash; new contents to include:'),
      '#default_value' => variable_get('notify_multilingual', 1),
      '#options' => array(
        t('All contents'),
        t("Contents in the user's preferred language + contents not yet translated"),
        t("Only contents in the user's preferred language"),
      ),
      '#description' => t('This setting lets you specfy what subscribed contents to include in user notifications on a multilingual site.  (Please note that new contents that are marked as "language neutral" will always be included, and that administrators will always be notified about all new contents.)'),
    );
  }
  $form['notify_settings']['notify_watchdog'] = array(
    '#type' => 'radios',
    '#title' => t('Watchdog log level'),
    '#default_value' => variable_get('notify_watchdog', 1),
    '#options' => array(
      t('All'),
      t('Failures+Summary'),
      t('Failures'),
      t('Nothing'),
    ),
    '#description' => t('This setting lets you specify how much to log.'),
  );
  $form['notify_settings']['notify_weightur'] = array(
    '#type' => 'textfield',
    '#title' => t('Weight of notification field in user registration form'),
    '#default_value' => variable_get('notify_weightur', 0),
    '#size' => 3,
    '#maxlength' => 5,
    '#description' => t('The weight you set here will determine the position of the notification field when it appears in the user registration form.'),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save settings'),
  );
  return $form;
}