You are here

function rules_admin_settings in Rules 7.2

Same name and namespace in other branches
  1. 6 rules_admin/rules_admin.rule_forms.inc \rules_admin_settings()

Rules settings form.

1 string reference to 'rules_admin_settings'
rules_admin_menu in rules_admin/rules_admin.module
Implements hook_menu().

File

rules_admin/rules_admin.inc, line 147
Implements rule management and configuration screens.

Code

function rules_admin_settings($form, &$form_state) {
  if (module_exists('path')) {

    // Present a list of available path cleaning callbacks.
    // @see rules_clean_path()
    $options = array(
      'rules_path_default_cleaning_method' => t('Rules (built in)'),
    );
    if (module_exists('ctools')) {
      $options['rules_path_clean_ctools'] = t('CTools');
    }
    if (module_exists('pathauto')) {
      $options['rules_path_clean_pathauto'] = t('Pathauto');
      $pathauto_help = t("Note that Pathauto's URL path cleaning method can be configured at <a href='!url'>admin/config/search/path/settings</a>.", array(
        '!url' => url('admin/config/search/path/settings'),
      ));
    }
    else {
      $pathauto_help = t('Install the <a href="https://www.drupal.org/project/pathauto">Pathauto module</a> in order to get a configurable URL path cleaning method.');
    }
    $form['path']['rules_path_cleaning_callback'] = array(
      '#type' => 'select',
      '#title' => t('URL path cleaning method'),
      '#description' => t('Choose the path cleaning method to be applied when generating URL path aliases.') . ' ' . $pathauto_help,
      '#default_value' => variable_get('rules_path_cleaning_callback', 'rules_path_default_cleaning_method'),
      '#options' => $options,
    );
  }
  $form['rules_log_errors'] = array(
    '#type' => 'radios',
    '#title' => t('Logging of Rules evaluation errors'),
    '#options' => array(
      RulesLog::WARN => t('Log all warnings and errors'),
      RulesLog::ERROR => t('Log errors only'),
    ),
    '#default_value' => variable_get('rules_log_errors', RulesLog::WARN),
    '#description' => t('Evaluations errors are logged to the system log.'),
  );
  $form['debug'] = array(
    '#type' => 'fieldset',
    '#title' => t('Debugging'),
  );
  $form['debug']['rules_debug_log'] = array(
    '#type' => 'checkbox',
    '#title' => t('Log debug information to the system log'),
    '#default_value' => variable_get('rules_debug_log', FALSE),
  );
  $form['debug']['rules_debug'] = array(
    '#type' => 'radios',
    '#title' => t('Show debug information'),
    '#default_value' => variable_get('rules_debug', 0),
    '#options' => array(
      0 => t('Never'),
      RulesLog::WARN => t('In case of errors'),
      RulesLog::INFO => t('Always'),
    ),
    '#description' => t('Debug information is only shown when rules are evaluated and is visible for users having the permission <a href="!url">%link</a>.', array(
      '%link' => t('Access the Rules debug log'),
      '!url' => url('admin/people/permissions', array(
        'fragment' => 'module-rules',
      )),
    )),
  );
  $form['debug']['regions'] = array(
    '#type' => 'container',
    '#states' => array(
      // Hide the regions settings when the debug log is disabled.
      'invisible' => array(
        'input[name="rules_debug"]' => array(
          'value' => 0,
        ),
      ),
    ),
  );
  $theme_default = variable_get('theme_default', 'bartik');
  $admin_theme = variable_get('admin_theme', 'seven');
  $form['debug']['regions']['rules_debug_region_' . $theme_default] = array(
    '#type' => 'select',
    '#title' => t('Default theme region'),
    '#description' => t("The region, where the debug log should be displayed on the default theme %theme. For other themes, Rules will try to display the log on the same region, or hide it in case it doesn't exist.", array(
      '%theme' => $theme_default,
    )),
    '#options' => system_region_list($theme_default, REGIONS_VISIBLE),
    '#default_value' => variable_get('rules_debug_region_' . $theme_default, 'help'),
  );
  $form['debug']['regions']['rules_debug_region_' . $admin_theme] = array(
    '#type' => 'select',
    '#title' => t('Admin theme region'),
    '#description' => t('The region, where the debug log should be displayed on the admin theme %theme.', array(
      '%theme' => $admin_theme,
    )),
    '#options' => system_region_list($admin_theme, REGIONS_VISIBLE),
    '#default_value' => variable_get('rules_debug_region_' . $admin_theme, 'help'),
  );
  if (db_table_exists('rules_rules')) {
    drupal_set_message(t('There are left over rule configurations from a previous Rules 1.x installation. Proceed to the <a href="!url">upgrade page</a> to convert them and consult the README.txt for more details.', array(
      '!url' => url('admin/config/workflow/rules/upgrade'),
    )), 'warning');
  }
  return system_settings_form($form);
}