You are here

function signature_forum_admin_settings in Signatures for Forums 5.2

Same name and namespace in other branches
  1. 5 signature_forum.module \signature_forum_admin_settings()
  2. 6 signature_forum.module \signature_forum_admin_settings()

Admin settings form.

1 string reference to 'signature_forum_admin_settings'
signature_forum_menu in ./signature_forum.module
Implementation of hook_menu().

File

./signature_forum.module, line 81
Tweaks signatures in ways inspired by other traditional forum software:

Code

function signature_forum_admin_settings() {
  $settings = variable_get('signature_forum_settings', signature_forum_defaults());
  $form['signature'] = array(
    '#type' => 'fieldset',
    '#title' => t('Show signatures with nodes and comments for'),
  );
  foreach (node_get_types('names') as $type => $name) {
    $form['signature']['signature_forum_show_for_' . $type] = array(
      '#type' => 'checkbox',
      '#title' => $name,
      '#return_value' => 1,
      '#default_value' => isset($settings['signature_forum_show_for_' . $type]) ? $settings['signature_forum_show_for_' . $type] : FALSE,
    );
  }
  $form['template'] = array(
    '#type' => 'textarea',
    '#title' => t('Template for signatures'),
    '#default_value' => $settings['signature_forum_template'],
    '#description' => t("%s will be replaced with the user's signature."),
  );
  $form['filter'] = filter_form($settings['signature_forum_format'], NULL, array(
    'filter',
  ));
  $form['content_settings'] = array(
    '#type' => 'fieldset',
    '#title' => t('Minimum content length'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['content_settings']['min_content_length'] = array(
    '#type' => 'textfield',
    '#title' => t('Minimum content length'),
    '#size' => 3,
    '#maxlength' => 10,
    '#default_value' => $settings['signature_forum_min_content_length'],
    '#description' => t('The minimum number of characters in the content a signature is being attached to. 0 means no limit.'),
  );
  $form['content_settings']['min_content_length_action'] = array(
    '#type' => 'radios',
    '#title' => t('Minimum content action'),
    '#default_value' => $settings['signature_forum_min_content_length_action'],
    '#options' => array(
      MIN_CONTENT_ACTION_DO_NOT_DISPLAY => t('Do not display signature'),
      MIN_CONTENT_ACTION_ADDITIONAL_FILTER => t('Run through an additional filter'),
    ),
    '#description' => t('What to do if the content is under the minimum length. Set the filter below.'),
  );
  $form['content_settings']['min_content_length_filter'] = filter_form($settings['signature_forum_min_content_length_filter'], NULL, array(
    'min_content_length_filter',
  ));
  $form['content_settings']['min_content_length_filter']['#title'] = t('Minimum content additional filter format (if enabled)');

  // If admin has opted to run signature through additional filter when content too short,
  // expand the additional filter selection fieldset
  if ($settings['signature_forum_min_content_length_action'] == MIN_CONTENT_ACTION_ADDITIONAL_FILTER) {
    $form['content_settings']['min_content_length_filter']['#collapsed'] = FALSE;
  }
  $roles = user_roles(TRUE);
  $form['content_settings']['roles'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Exempt roles'),
    '#default_value' => isset($settings['signature_forum_roles']) ? $settings['signature_forum_roles'] : array(),
    '#options' => $roles,
    '#description' => t('Members of these roles will be exempt from content length settings.'),
  );
  $form['show_once'] = array(
    '#type' => 'fieldset',
    '#title' => t('Per-conversation signatures'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['show_once']['show_once_options'] = array(
    '#type' => 'radios',
    '#title' => t("Show a user's signature"),
    '#default_value' => $settings['signature_forum_show_once_options'],
    '#options' => array(
      SHOW_ONCE_OPTIONS_ALWAYS => t('Always'),
      SHOW_ONCE_OPTIONS_ONCE => t('Once per conversation'),
    ),
  );
  $form['show_once']['show_once_roles'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Exempt roles'),
    '#default_value' => isset($settings['signature_forum_show_once_roles']) ? $settings['signature_forum_show_once_roles'] : array(),
    '#options' => $roles,
    '#description' => t('Members of these roles will have their signatures shown in every post.'),
  );
  $form['signature_other'] = array(
    '#type' => 'fieldset',
    '#title' => t('Other options'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['signature_other']['line_limit'] = array(
    '#type' => 'textfield',
    '#title' => t('Line limit'),
    '#size' => 3,
    '#maxlength' => 10,
    '#default_value' => $settings['signature_forum_line_limit'],
    '#description' => t('The maximum number of lines allowed in a signature. 0 means no limit. Note: existing signatures that are too long will not be changed.'),
  );
  $form['signature_other']['delete_signatures'] = array(
    '#type' => 'checkbox',
    '#title' => t('Delete embedded signatures'),
    '#description' => t('Deletes signatures that are embedded in existing comments (warning: cannot be undone!).'),
    '#default_value' => FALSE,
  );
  $form['signature_other']['auto_insert'] = array(
    '#type' => 'checkbox',
    '#title' => t('Automatically add signatures to content'),
    '#description' => t('If this is switched on signatures will automatically be added to content. Themers may wish to switch this off, so the signature may be positioned in the templates manually.'),
    '#default_value' => $settings['signature_forum_auto_insert'],
  );
  return system_settings_form($form);
}