You are here

function sms_valid_admin_ruleset_form in SMS Framework 7

Same name and namespace in other branches
  1. 6.2 modules/sms_valid/sms_valid.admin.inc \sms_valid_admin_ruleset_form()
  2. 6 modules/sms_valid/sms_valid.admin.inc \sms_valid_admin_ruleset_form()

Form constructor for validation ruleset editing.

Parameters

int $prefix: Prefix for ruleset that will be displayed on page load.

1 string reference to 'sms_valid_admin_ruleset_form'
sms_valid_menu in modules/sms_valid/sms_valid.module
Implements hook_menu().

File

modules/sms_valid/sms_valid.admin.inc, line 295
SMS Framework core module: Admin settings form functions.

Code

function sms_valid_admin_ruleset_form($form, &$form_state, $prefix = NULL) {
  include_once DRUPAL_ROOT . '/includes/locale.inc';
  if ($prefix === NULL) {
    $ruleset = FALSE;
  }
  else {
    $ruleset = sms_valid_get_ruleset($prefix);
  }

  // Ruleset selection area.
  $form['title'] = array(
    '#type' => 'item',
    '#markup' => t('Choose a ruleset from the drop down box and click Refresh to update the ruleset form below.'),
  );
  $form['select_prefix'] = array(
    '#type' => 'select',
    '#options' => sms_valid_get_rulesets_for_form(),
    '#default_value' => $prefix,
  );
  $form['select'] = array(
    '#type' => 'submit',
    '#value' => t('Refresh Editor (below)'),
    '#submit' => array(
      'sms_valid_admin_ruleset_form_select',
    ),
  );

  // Ruleset editor area.
  $form['ruleset'] = array(
    '#type' => 'fieldset',
    '#title' => 'Ruleset',
  );

  // If this is a new ruleset then this should be a textfield.
  $form['ruleset']['prefix'] = array(
    '#type' => 'textfield',
    '#title' => t('Prefix'),
    '#size' => 5,
    '#maxlength' => 5,
    '#value' => $ruleset ? $ruleset['prefix'] : '',
    '#description' => 'Should be 4 digits or less. Highest allowed prefix is 65535.',
  );
  $form['ruleset']['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Name'),
    '#size' => 80,
    '#maxlength' => 200,
    '#default_value' => $ruleset ? $ruleset['name'] : '',
  );
  $options[''] = '(none)';
  $options = array_merge($options, country_get_list());
  $form['ruleset']['iso2'] = array(
    '#type' => 'select',
    '#title' => t('Associated country (optional)'),
    '#options' => $options,
    '#default_value' => $ruleset ? $ruleset['iso2'] : '',
  );
  $form['ruleset']['out'] = array(
    '#type' => 'checkbox',
    '#title' => 'Allow outbound communication',
    '#default_value' => $ruleset ? sms_valid_ruleset_is_enabled($prefix, SMS_DIR_OUT) : 0,
  );
  $form['ruleset']['in'] = array(
    '#type' => 'checkbox',
    '#title' => 'Allow inbound commmunication',
    '#default_value' => $ruleset ? sms_valid_ruleset_is_enabled($prefix, SMS_DIR_IN) : 0,
  );
  $form['ruleset']['rules'] = array(
    '#type' => 'textarea',
    '#title' => 'Rules',
    '#cols' => 80,
    '#rows' => 15,
    '#default_value' => $ruleset ? sms_valid_rules_to_text($ruleset['rules']) : '',
    '#description' => t('One rule per line. Enter a number prefix (any length), not including the ruleset prefix.<br />Any prefix with a "-" at the end signifies an expicit deny.<br />Any prefix with a "+" at the end signifies an explicit allow.<br />All other rules are ignored.<br />Default is to deny any numbers that do not match.<br />Comments must be prefixed with a hash (#). You may place comments in-line only.<br />See the guide at %url', array(
      '%url' => 'http://moo0.net/smsframework/?q=node/19',
    )),
  );
  $form['ruleset']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save Ruleset'),
  );
  return $form;
}