You are here

function mass_contact_admin_settings_body in Mass Contact 7

Same name and namespace in other branches
  1. 6 mass_contact.module \mass_contact_admin_settings_body()

Message body administration settings form.

Parameters

array $form: An associative array containing the structure of the form.

array $form_state: A keyed array containing the current state of the form.

Return value

array An associative array that defines the form to be built.

1 string reference to 'mass_contact_admin_settings_body'
mass_contact_menu in ./mass_contact.module
Implements hook_menu().

File

./mass_contact.admin.inc, line 496
The administrative settings pages.

Code

function mass_contact_admin_settings_body(array $form, array $form_state) {
  $mimemail = module_exists('mimemail');
  $token = module_exists('token');

  // Supplemental texts that are prepended and/or appended to every message.
  $form['mass_contact_supplemental_texts'] = array(
    '#type' => 'fieldset',
    '#title' => t('Supplemental message body texts'),
    '#description' => t('You may specify additional text to insert before and/or after the message text of every mass email that is sent.'),
  );
  $mass_contact_message_prefix = variable_get('mass_contact_message_prefix');
  $mass_contact_message_suffix = variable_get('mass_contact_message_suffix');
  if ($mimemail) {
    $field_type = 'text_format';
    if (is_array($mass_contact_message_prefix)) {
      $prefix_format = !empty($mass_contact_message_prefix['format']) ? $mass_contact_message_prefix['format'] : NULL;
      $suffix_format = !empty($mass_contact_message_suffix['format']) ? $mass_contact_message_suffix['format'] : NULL;
      if ($token) {
        $prefix_default_value = isset($mass_contact_message_prefix['value']) ? $mass_contact_message_prefix['value'] : t('[current-user:name] has sent you a group email from [site:name].');
        $suffix_default_value = isset($mass_contact_message_suffix['value']) ? $mass_contact_message_suffix['value'] : '';
      }
      else {
        $prefix_default_value = isset($mass_contact_message_prefix['value']) ? $mass_contact_message_prefix['value'] : t('You were sent a group email from @site.', array(
          '@site' => url(NULL, array(
            'absolute' => TRUE,
          )),
        ));
        $suffix_default_value = isset($mass_contact_message_suffix['value']) ? $mass_contact_message_suffix['value'] : '';
      }
    }
    else {
      $prefix_format = !empty($mass_contact_message_prefix) ? $mass_contact_message_prefix : NULL;
      $suffix_format = !empty($mass_contact_message_suffix) ? $mass_contact_message_suffix : NULL;
      if ($token) {
        $prefix_default_value = isset($mass_contact_message_prefix) ? $mass_contact_message_prefix : t('[current-user:name] has sent you a group email from [site:name].');
        $suffix_default_value = isset($mass_contact_message_suffix) ? $mass_contact_message_suffix : '';
      }
      else {
        $prefix_default_value = isset($mass_contact_message_prefix) ? $mass_contact_message_prefix : t('You were sent a group email from @site.', array(
          '@site' => url(NULL, array(
            'absolute' => TRUE,
          )),
        ));
        $suffix_default_value = isset($mass_contact_message_suffix) ? $mass_contact_message_suffix : '';
      }
    }
  }
  else {
    $field_type = 'textarea';
    $prefix_format = NULL;
    $suffix_format = NULL;
    if ($token) {
      $prefix_default_value = isset($mass_contact_message_prefix) ? $mass_contact_message_prefix : t('[current-user:name] has sent you a group email from [site:name].');
      $suffix_default_value = isset($mass_contact_message_suffix) ? $mass_contact_message_suffix : '';
    }
    else {
      $prefix_default_value = isset($mass_contact_message_prefix) ? $mass_contact_message_prefix : t('You were sent a group email from @site.', array(
        '@site' => url(NULL, array(
          'absolute' => TRUE,
        )),
      ));
      $suffix_default_value = isset($mass_contact_message_suffix) ? $mass_contact_message_suffix : '';
    }
  }
  $form['mass_contact_supplemental_texts']['mass_contact_message_prefix'] = array(
    '#type' => $field_type,
    '#title' => t('Text to be prepended to all messages'),
    '#default_value' => $prefix_default_value,
    '#format' => $prefix_format,
    '#description' => t('The text you specify in this field will be added to all Mass Contact messages sent out and will be placed before the message text entered in by the sender.'),
  );
  $form['mass_contact_supplemental_texts']['mass_contact_message_suffix'] = array(
    '#type' => $field_type,
    '#title' => t('Text to be appended to all messages'),
    '#default_value' => $suffix_default_value,
    '#format' => $suffix_format,
    '#description' => t('The text you specify in this field will be added to all Mass Contact messages sent out and will be placed after the message text entered in by the sender.'),
  );
  if ($token) {

    // Display the user documentation of placeholders supported by this module,
    // as a description on the last pattern.
    $form['mass_contact_supplemental_texts']['mass_contact_replacement_tokens'] = array(
      '#type' => 'fieldset',
      '#title' => t('Replacement patterns'),
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
      '#description' => t('You may use any of the following replacements tokens for use in the prefix and/or suffix texts above.'),
    );
    $form['mass_contact_supplemental_texts']['mass_contact_replacement_tokens']['token_help'] = array(
      '#theme' => 'token_tree',
      '#token_types' => array(
        'global',
      ),
    );
  }

  // HTML options.
  $form['mass_contact_html_settings'] = array(
    '#type' => 'fieldset',
    '#title' => t('HTML Settings'),
  );
  if ($mimemail) {
    $mass_contact_html_format = variable_get('mass_contact_html_format');
    $form['mass_contact_html_settings']['mass_contact_html_format'] = array(
      '#type' => 'text_format',
      '#title' => t('The default text format'),
      '#default_value' => t('This text of this field is not saved or used anywhere.'),
      '#format' => !empty($mass_contact_html_format['format']) ? $mass_contact_html_format['format'] : NULL,
      '#description' => t('This is the text format that will be initially selected. If you do not want to allow HTML messages, then specify a plain text text format and do not aloow it to be overridden below. Keep in mind that the user sending the message may not have access to all the text formats that are available here.'),
    );
  }
  else {
    $form['mass_contact_html_settings']['mass_contact_no_mimemail'] = array(
      '#type' => 'item',
      '#description' => t('This module no longer supports HTML email without the Mime Mail module, which can be found here: http://drupal.org/project/mimemail.'),
    );
  }

  // Attachment options.
  $form['mass_contact_attachment_settings'] = array(
    '#type' => 'fieldset',
    '#title' => t('Attachment Settings'),
  );
  if ($mimemail) {
    $form['mass_contact_attachment_settings']['mass_contact_number_of_attachments'] = array(
      '#type' => 'textfield',
      '#title' => t('Number of attachments'),
      '#default_value' => variable_get('mass_contact_number_of_attachments', '3'),
      '#size' => 10,
      '#description' => t("The number of attachments to allow on the contact form. The maximum number of allowed uploads may be limited by PHP. If necessary, check your system's PHP php.ini file for a max_file_uploads directive to change."),
    );
    $form['mass_contact_attachment_settings']['mass_contact_attachment_location'] = array(
      '#type' => 'textfield',
      '#title' => t('Attachment location'),
      '#default_value' => variable_get('mass_contact_attachment_location', 'mass_contact_attachments'),
      '#description' => t('If a copy of the message is saved as a node, this is the file path where to save the attachment(s) so it can be viewed later. If you specify anything here, it will be a subdirectory of your Public file system path, which is set on !file_conf_page. If you do not specify anything here, all attachments will be saved in the directory specified in the Public file system path.', array(
        '!file_conf_page' => l(t('File system configuration page'), '/admin/config/media/file-system'),
      )),
    );
  }
  else {
    $form['mass_contact_attachment_settings']['mass_contact_no_mimemail'] = array(
      '#type' => 'item',
      '#description' => t('This module no longer supports attachments without the Mime Mail module, which can be found here: http://drupal.org/project/mimemail.'),
    );
  }
  return system_settings_form($form);
}