You are here

function ca_condition_node_field_comparison_form in Ubercart 6.2

See also

ca_condition_node_field_comparision()

File

ca/ca.ca.inc, line 253
This file includes some generic conditions and actions.

Code

function ca_condition_node_field_comparison_form($form_state, $settings = array()) {
  $form = array();

  // Define the fields this works for.
  $options = array(
    t('Core node fields') => array(
      'nid' => t('Node ID'),
      'vid' => t('Node revision ID'),
      'type' => t('Node type'),
      'title' => t('Title'),
      'uid' => t("Author's user ID"),
      'status' => t('Node is published?'),
      'promote' => t('Node is promoted?'),
      'sticky' => t('Node is sticky?'),
    ),
  );
  $form['field'] = array(
    '#type' => 'select',
    '#title' => t('Node field'),
    '#options' => $options,
    '#default_value' => $settings['field'],
  );

  // Define the operators for the fields.
  $options = array(
    t('Simple comparison') => array(
      'equal' => t('is equal to'),
      'not' => t('is not equal to'),
      'greater' => t('is greater than'),
      'less' => t('is less than'),
      'greater_equal' => t('is greater than or equal to'),
      'less_equal' => t('is less than or equal to'),
    ),
    t('Text matching') => array(
      'begins' => t('begins with'),
      'contains' => t('contains'),
      'ends' => t('ends with'),
    ),
    t('Yes/No') => array(
      'yes' => t('yes'),
      'no' => t('no'),
    ),
  );
  $form['operator'] = array(
    '#type' => 'select',
    '#title' => t('Operator'),
    '#description' => t('Please note that not every operator makes sense for every field.'),
    '#options' => $options,
    '#default_value' => $settings['operator'],
  );
  $form['value'] = array(
    '#type' => 'textfield',
    '#title' => t('Comparison value'),
    '#description' => t('You do not need to specify a value if your operator is in the Yes/No category.'),
    '#default_value' => $settings['value'],
  );
  return $form;
}