function pm_email_notify_form_privatemsg_admin_settings_alter

7-1 pm_email_notify.module pm_email_notify_form_privatemsg_admin_settings_alter(&$form, &$form_state)
7-2 pm_email_notify.module pm_email_notify_form_privatemsg_admin_settings_alter(&$form, &$form_state)

Implements hook_form_FORM_ID_alter().

File

pm_email_notify/pm_email_notify.module, line 401
Notifies users about new Private Messages via Email.

Code

function pm_email_notify_form_privatemsg_admin_settings_alter(&$form, &$form_state) {
  $form['pm_email_notify'] = array(
    '#type' => 'fieldset',
    '#title' => t('E-mail notify'),
    '#group' => 'settings',
    '#weight' => 22,
  );

  $form['pm_email_notify']['privatemsg_setting_email_notify_level'] = array(
    '#type' => 'radios',
    '#title' => t('Default e-mail notification level'),
    '#options' => array(
      PM_EMAIL_NOTIFY_LEVEL_DISABLED => t('Never send a notification'),
      PM_EMAIL_NOTIFY_LEVEL_THREAD => t('Only send a notification when a new discussion thread is created'),
      PM_EMAIL_NOTIFY_LEVEL_UNREAD_ONCE => t("Only send a notification when the user has not already received a notification since he last viewed a discussion thread."),
      PM_EMAIL_NOTIFY_LEVEL_ALL => t('Always send a notification'),
    ),
    '#default_value' => variable_get('privatemsg_setting_email_notify_level', PM_EMAIL_NOTIFY_LEVEL_ALL),
    '#description' => t('Choose when e-mail notifications will be sent by the system. Users with the appropriate permission may override this setting on the account edit page.'),
    '#weight' => 0,
  );
  $form['pm_email_notify']['privatemsg_setting_email_notify_only_user'] = array(
    '#type' => 'checkbox',
    '#title' => t('Only send e-mail notifications to individual users who are addressed directly'),
    '#default_value' => variable_get('privatemsg_setting_email_only_user', FALSE),
    '#weight' => 1,
  );

  $form['pm_email_notify']['pm_email_notify_desc'] = array(
    '#type' => 'item',
    '#title' => t('Customize the email messages sent to users upon receipt of a new private message.'),
    '#weight' => 2,
  );

  $form['pm_email_notify']['pm_email_notify_from'] = array(
    '#type' => 'textfield',
    '#title' => t('From e-mail address for notifications'),
    '#default_value' => variable_get('pm_email_notify_from', ''),
    '#weight' => 3,
    '#description' => t('This is the e-mail address that notifications will come from. Leave blank to use the site default.'),
  );

  $form['pm_email_notify']['privatemsg_setting_show_sender_mail'] = array(
    '#type' => 'checkbox',
    '#title' => t("Use sender's email address"),
    '#description' => t("Use the sender's private email address instead of a generic sender for notification mails. This is the site default setting; users may override it individually."),
    '#default_value' => variable_get('privatemsg_setting_show_sender_mail', FALSE),
    '#weight' => 3,
  );

  $form['pm_email_notify']['pm_email_notify_subject'] = array(
    '#type' => 'textfield',
    '#title' => t('Subject of notification messages'),
    '#default_value' => variable_get('pm_email_notify_subject', _pm_email_notify_source_text('subject')),
    '#weight' => 4,
  );

  $form['pm_email_notify']['pm_email_notify_body'] = array(
    '#type' => 'textarea',
    '#title' => t('Body of notification messages'),
    '#default_value' => variable_get('pm_email_notify_body', _pm_email_notify_source_text('body')),
    '#weight' => 5,
  );

  if (module_exists('token')) {
    $form['pm_email_notify']['token'] = array(
      '#type' => 'fieldset',
      '#title' => t('Token browser'),
      '#weight' => -1,
      '#weight' => 6,
    );
    $form['pm_email_notify']['token']['browser'] = array(
      '#theme' => 'token_tree',
      '#token_types' => array('privatemsg_message'),
    );
  }
  else {
    $form['pm_email_notify']['tokens'] = array(
      '#type' => 'item',
      '#value' => t('Available variables are: !author, !author_uid, !pm_subject, !pm_body, !thread, !site, !login_url, !uri, !uri_brief, !message (URL) and !settings (URL).'),
      '#weight' => 6,
    );
  }

  if (module_exists('i18n_string')) {
    $form['#submit'][] = 'pm_email_notify_admin_settings_update_strings';
  }
}