You are here

function messaging_admin_method_filters in Messaging 6.4

Same name and namespace in other branches
  1. 7 messaging.admin.inc \messaging_admin_method_filters()

Settings for filter and formatting for each sending method

This page requires 'administer filters' permission so it doesn't need further checking

1 string reference to 'messaging_admin_method_filters'
messaging_menu in ./messaging.module
Implementation of hook_menu()

File

./messaging.admin.inc, line 205
Messaging Framework - Admin UI

Code

function messaging_admin_method_filters() {

  // Add information about input formats
  messaging_include('text.inc');

  // List of Input formats
  $format_options = $filter_options = array();
  foreach (filter_formats() as $format) {
    $format_options[$format->format] = $format->name;
  }
  $format_default = filter_resolve_format(FILTER_FORMAT_DEFAULT);

  // List of messaging filters
  $filter_info = array();
  foreach (messaging_text_filter_info() as $key => $filter) {
    $filter_options[$key] = $filter['name'];
    $filter_info[] = array(
      $filter['name'],
      $filter['description'],
    );
  }

  // We add this last for it not bo be default
  $filter_options[''] = t('No filter (Insecure)');
  $format_options[''] = t('No filter (Insecure)');
  $form['filter_info'] = array(
    '#title' => t('Available filters'),
    '#type' => 'item',
    '#value' => theme('table', array(), $filter_info),
  );

  // Sending methods settings
  if ($info = messaging_method_info()) {
    $form['methods'] = array(
      '#theme' => 'messaging_admin_settings_table',
    );
    foreach ($info as $method => $options) {
      $key = 'messaging_filters_' . $method;

      // This will preserve settings for disabled modules
      $form['methods'][$key]['#tree'] = TRUE;
      $form['methods'][$key]['title'] = array(
        '#title' => t('Method'),
        '#value' => $options['title'],
      );

      // Output filter applied to message body
      $form['methods'][$key]['body_format'] = array(
        '#title' => t('Format filter'),
        '#type' => 'select',
        '#default_value' => isset($options['body_format']) ? $options['body_format'] : $format_default,
        '#options' => $format_options,
      );

      // Final filter applied to message body
      $form['methods'][$key]['filter'] = array(
        '#title' => t('Final filter'),
        '#type' => 'select',
        '#default_value' => $options['filter'],
        '#options' => $filter_options,
      );
    }
  }
  else {
    $form['warning'] = array(
      '#value' => t('You should enable some messaging method plug-ins for this to work.'),
    );
  }
  $form = system_settings_form($form);
  return $form;
}