=== removed directory 'ca'
=== removed file 'ca/ca.admin.inc'
--- ca/ca.admin.inc	2010-04-09 14:18:53 +0000
+++ ca/ca.admin.inc	1970-01-01 00:00:00 +0000
@@ -1,1322 +0,0 @@
-<?php
-// $Id$
-
-/**
- * @file
- * Conditional actions overview UI.
- */
-
-/**
- * Display the administration page that lets you add and modify predicates.
- */
-function ca_admin($groupby = 'trigger') {
-  drupal_add_css(drupal_get_path('module', 'ca') . '/ca.css');
-
-  // Load all the module defined predicates into a temporary array.
-  $temp = module_invoke_all('ca_predicate');
-
-  // Assign a default weight if need be.
-  foreach ($temp as $key => $value) {
-    $temp[$key]['#pid'] = $key;
-    if (!isset($value['#weight'])) {
-      $temp[$key]['#weight'] = 0;
-    }
-  }
-
-  // Load and loop through all the database stored predicates.
-  $result = db_query("SELECT * FROM {ca_predicates}");
-  while ($predicate = $result->fetchAssoc()) {
-    // Prepare the database data into a predicate.
-    $predicate = ca_prepare_db_predicate($predicate);
-
-    // Overrides the module defined predicate if it's been modified by a user.
-    $temp[$predicate['#pid']] = $predicate;
-  }
-
-  usort($temp, 'ca_weight_sort');
-
-  // Copy the temporary array of predicates into a keyed array.
-  $predicates = array();
-  foreach ($temp as $predicate) {
-    $predicates[$predicate['#pid']] = $predicate;
-  }
-
-  // Load up the trigger data so we can display them by title.
-  $triggers = module_invoke_all('ca_trigger');
-
-  // Build the header for the predicate tables based on the grouping type.
-  if ($groupby == 'trigger') {
-    $header = array(
-      array('data' => t('Title'), 'class' => array('col-title')),
-      t('Class'),
-      t('Status'),
-      t('Weight'),
-      t('Operations'),
-    );
-
-    $table_class = array('ca-predicate-trigger');
-    $table_label = '<strong>' . t('Trigger') . ':</strong> ';
-  }
-  elseif ($groupby == 'class') {
-    $header = array(
-      array('data' => t('Title'), 'class' => array('col-title')),
-      t('Trigger'),
-      t('Status'),
-      t('Weight'),
-      t('Operations'),
-    );
-
-    $table_class = array('ca-predicate-class');
-    $table_label = '<strong>' . t('Class') . ':</strong> ';
-  }
-
-  $rows = array();
-
-  foreach ($predicates as $key => $value) {
-    // Build the basic operation links for each predicate.
-    $ops = array(
-      l(t('edit'), CA_UI_PATH . '/' . $key . '/edit'),
-    );
-
-    // Add the reset link if a module defined predicate has been modified.
-    if (!is_numeric($key) && isset($value['#modified'])) {
-      $ops[] = l(t('reset'), CA_UI_PATH . '/' . $key . '/reset');
-    }
-
-    // Add a delete link if displaying a custom predicate.
-    if (is_numeric($key)) {
-      $ops[] = l(t('delete'), CA_UI_PATH . '/' . $key . '/delete');
-    }
-
-    // Add the predicate's row to the table based on the grouping type.
-    if ($groupby == 'trigger') {
-      $tables[$triggers[$value['#trigger']]['#title']]['rows'][] = array(
-        check_plain($value['#title']),
-        strpos($value['#class'], 'custom') === 0 ? check_plain(substr($value['#class'], 7)) : $value['#class'],
-        $value['#status'] == 0 ? t('Disabled') : t('Enabled'),
-        array('data' => $value['#weight'], 'class' => array('ca-predicate-table-weight')),
-        array('data' => implode(' ', $ops), 'class' => array('ca-predicate-table-ops')),
-      );
-    }
-    elseif ($groupby == 'class') {
-      $class = strpos($value['#class'], 'custom') === 0 ? check_plain(substr($value['#class'], 7)) : $value['#class'];
-
-      $tables[$class]['rows'][] = array(
-        check_plain($value['#title']),
-        check_plain($triggers[$value['#trigger']]['#title']),
-        $value['#status'] == 0 ? t('Disabled') : t('Enabled'),
-        array('data' => $value['#weight'], 'class' => array('ca-predicate-table-weight')),
-        array('data' => implode(' ', $ops), 'class' => array('ca-predicate-table-ops')),
-      );
-    }
-  }
-
-  // Put the tables in alphabetical order.
-  ksort($tables);
-
-  $build = array();
-
-  // Add the tables for each trigger to the output.
-  foreach ($tables as $key => $value) {
-    // Accommodate empty class names.
-    if (empty($key)) {
-      $key = t('- None -');
-    }
-
-    $build[] = array(
-      '#theme' => 'table',
-      '#header' => $header,
-      '#rows' => $value['rows'],
-      '#attributes' => array('class' => $table_class),
-      '#caption' => $table_label . check_plain($key),
-    );
-  }
-
-  $build['add_link'] = array(
-    '#markup' => l(t('Add a predicate'), CA_UI_PATH . '/add'),
-    '#weight' => 5,
-  );
-
-  return $build;
-}
-
-/**
- * Form to allow the creation and editing of conditional action predicates.
- */
-function ca_predicate_meta_form($form, &$form_state, $pid) {
-  // Load the predicate if an ID is passed in.
-  if (!empty($pid) && $pid !== 0) {
-    $predicate = ca_load_predicate($pid);
-
-    // Fail out if we didn't find a predicate for that ID.
-    if (empty($predicate)) {
-      drupal_set_message(t('That predicate does not exist.'), 'error');
-      drupal_goto(CA_UI_PATH);
-    }
-
-    drupal_set_title($predicate['#title']);
-  }
-
-  $form['predicate_pid'] = array(
-    '#type' => 'value',
-    '#value' => $pid,
-  );
-
-  $form['predicate_title'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Title'),
-    '#description' => t('Enter a title used for display on the overview tables.'),
-    '#default_value' => $pid ? $predicate['#title'] : '',
-    '#required' => TRUE,
-  );
-
-  // Create an array of triggers for the select box.
-  $triggers = module_invoke_all('ca_trigger');
-  foreach ($triggers as $key => $value) {
-    $options[$value['#category']][$key] = $value['#title'];
-  }
-
-  $form['predicate_trigger'] = array(
-    '#type' => 'select',
-    '#title' => t('Trigger'),
-    '#description' => t('Select the trigger for this predicate.<br />Cannot be modified if the predicate has conditions or actions.'),
-    '#options' => $options,
-    '#default_value' => $pid ? $predicate['#trigger'] : '',
-    '#disabled' => empty($predicate['#conditions']) && empty($predicate['#actions']) ? FALSE : TRUE,
-    '#required' => TRUE,
-  );
-
-  $form['predicate_description'] = array(
-    '#type' => 'textarea',
-    '#title' => t('Description'),
-    '#description' => t('Enter a description that summarizes the use and intent of the predicate.'),
-    '#default_value' => $pid ? $predicate['#description'] : '',
-  );
-
-  // Accommodate the mandatory custom prefix for predicate classes.
-  $class = $predicate['#class'];
-  if (strpos($class, 'custom') === 0) {
-    $class = ltrim(substr($class, 6), ':');
-  }
-
-  if (is_numeric($pid)) {
-    $form['predicate_class'] = array(
-      '#type' => 'textfield',
-      '#title' => t('Class'),
-      '#description' => t('Classes let you categorize your predicates based on the type of functionality they provide.'),
-      '#field_prefix' => 'custom:',
-      '#default_value' => $class,
-    );
-  }
-  else {
-    $form['predicate_class'] = array(
-      '#type' => 'value',
-      '#value' => $class,
-    );
-  }
-
-  $form['predicate_status'] = array(
-    '#type' => 'radios',
-    '#title' => t('Status'),
-    '#description' => t('Disabled predicates will not be processed when their trigger is pulled.'),
-    '#options' => array(
-      1 => t('Enabled'),
-      0 => t('Disabled'),
-    ),
-    '#default_value' => $pid ? $predicate['#status'] : 1,
-  );
-
-  $form['predicate_weight'] = array(
-    '#type' => 'weight',
-    '#title' => t('Weight'),
-    '#description' => t('Predicates will be sorted by weight and processed sequentially.'),
-    '#default_value' => ($pid && isset($predicate['#weight'])) ? $predicate['#weight'] : 0,
-  );
-
-  $form['submit'] = array(
-    '#type' => 'submit',
-    '#value' => t('Save predicate'),
-    '#suffix' => l(t('Cancel'), CA_UI_PATH),
-  );
-
-  return $form;
-}
-
-/**
- * @see ca_predicate_meta_form()
- */
-function ca_predicate_meta_form_submit($form, &$form_state) {
-  $form_state['redirect'] = CA_UI_PATH;
-  $save = FALSE;
-
-  // Load the original predicate.
-  if ($form_state['values']['pid'] !== 0) {
-    $predicate = ca_load_predicate($form_state['values']['predicate_pid']);
-    $predicate['#pid'] = $form_state['values']['predicate_pid'];
-  }
-
-  // Setup a list of fields to check for and apply changes.
-  $fields = array('title', 'trigger', 'description', 'class', 'status', 'weight');
-
-  // Compare the values from the form submission with what is already set.
-  foreach ($fields as $field) {
-    if ($form_state['values']['predicate_' . $field] != $predicate['#' . $field]) {
-      $predicate['#' . $field] = $form_state['values']['predicate_' . $field];
-      $save = TRUE;
-    }
-  }
-
-  // Add empty conditions and actions arrays if this is a new predicate.
-  if (empty($predicate['#pid'])) {
-    $predicate['#pid'] = variable_get('ca_predicates_pid', 1);
-    variable_set('ca_predicates_pid', $predicate['#pid'] + 1);
-    $predicate['#conditions'] = array();
-    $predicate['#actions'] = array();
-
-    // For new predicates, redirect to the conditions tab.
-    $form_state['redirect'] = CA_UI_PATH . '/' . $predicate['#pid'] . '/edit/conditions';
-  }
-
-  // Check to see if any changes were made and save if necessary.
-  if ($save) {
-    ca_save_predicate($predicate);
-  }
-
-  drupal_set_message(t('Predicate meta data saved.'));
-}
-
-/**
- * Form to reset a modified module defined predicate to its original state.
- */
-function ca_predicate_delete_form($form, &$form_state, $pid) {
-  $predicate = ca_load_predicate($pid);
-
-  // Fail if we received an invalid predicate ID.
-  if (empty($predicate)) {
-    drupal_set_message(t('That predicate does not exist.'), 'error');
-    drupal_goto(CA_UI_PATH);
-  }
-
-  $form['predicate_pid'] = array(
-    '#type' => 'value',
-    '#value' => $pid,
-  );
-
-  $form['predicate_title'] = array(
-    '#type' => 'value',
-    '#value' => $predicate['#title'],
-  );
-
-  $description = '<p><strong>' . check_plain($predicate['#title']) . '</strong><br />'
-               . check_plain($predicate['#description']) . '</p><p>'
-                . t('This action cannot be undone.') . '</p>';
-
-  return confirm_form($form, t('Are you sure you want to !op this predicate?', array('!op' => is_numeric($pid) ? t('delete') : t('reset'))), CA_UI_PATH, $description);
-}
-
-/**
- * @see ca_predicate_delete_form()
- */
-function ca_predicate_delete_form_submit($form, &$form_state) {
-  ca_delete_predicate($form_state['values']['predicate_pid']);
-
-  drupal_set_message(t('Predicate %title !op.', array('%title' => $form_state['values']['predicate_title'], '!op' => is_numeric($form_state['values']['predicate_pid']) ? t('deleted') : t('reset'))));
-
-  $form_state['redirect'] = CA_UI_PATH;
-}
-
-/**
- * Build a form for adding and editing actions on a predicate.
- *
- * @param $form_state
- *   Used by FAPI; the current state of the form as it processes.
- * @param $pid
- *   The ID of the predicate whose actions are being modified.
- * @param $title
- *   TRUE or FALSE to specify whether or not to set the predicate's title to be
- *     the title of the page.
- * @return
- *   The form array for the actions form.
- *
- * @ingroup forms
- * @see
- *   ca_actions_form_add_action_submit()
- *   ca_actions_form_add_action_submit()
- *   ca_actions_form_save_changes_submit()
- */
-function ca_actions_form($form, &$form_state, $pid, $title = TRUE) {
-  // Locate the specified predicate.
-  $predicate = ca_load_predicate($pid);
-
-  // Return an empty form if the predicate does not exist.
-  if (empty($predicate)) {
-    return array();
-  }
-
-  // Include the JS for conditional actions forms.
-  drupal_add_js(drupal_get_path('module', 'ca') . '/ca.js');
-
-  // Display the title if appropriate.
-  if ($title) {
-    drupal_set_title($predicate['#title']);
-  }
-
-  // Load up any actions that could possibly be on this predicate.
-  $action_data = ca_load_action();
-
-  $form['pid'] = array(
-    '#type' => 'value',
-    '#value' => $pid,
-  );
-
-  $form['actions'] = array(
-    '#type' => 'fieldset',
-    '#title' => t('Actions'),
-    '#description' => t('These actions will be performed in order when this predicate passes the conditions evaluation.'),
-    '#tree' => TRUE,
-  );
-
-  // Loop through the actions and add them to the form if valid.
-  $i = 0;
-
-  foreach ($predicate['#actions'] as $key => $action) {
-    // Add it to the form if the action's callback exists.
-    $callback = $action_data[$action['#name']]['#callback'];
-
-    if (function_exists($callback)) {
-      $form['actions'][$i] = array(
-        '#type' => 'fieldset',
-        '#title' => t('Action: @title', array('@title' => $action_data[$action['#name']]['#title'])),
-        '#description' => $action_data[$action['#name']]['#description'],
-        '#collapsible' => TRUE,
-        '#collapsed' => isset($_SESSION['ca_action_focus']) && $i == $_SESSION['ca_action_focus'] ? FALSE : TRUE,
-      );
-
-      $form['actions'][$i]['name'] = array(
-        '#type' => 'value',
-        '#value' => $action['#name'],
-      );
-
-      $form['actions'][$i]['title'] = array(
-        '#type' => 'textfield',
-        '#title' => t('Title'),
-        '#default_value' => $action['#title'],
-      );
-
-      $form['actions'][$i]['argument_map'] = array(
-        '#type' => 'fieldset',
-        '#title' => t('Arguments'),
-        '#description' => t('Some triggers pass in multiple options for arguments related to a particular action, so you must specify which options to use in the fields below.'),
-        '#collapsible' => TRUE,
-      );
-
-      // Setup a variable to decide if we can collapse the arguments fieldset.
-      $collapsed = TRUE;
-
-      foreach ($action_data[$action['#name']]['#arguments'] as $key => $value) {
-        // Load the available arguments for each entity as received by the
-        // trigger when it was pulled.
-        $options = ca_load_trigger_arguments($predicate['#trigger'], $value['#entity']);
-
-        // If we have more than one option for any argument, do not collapse.
-        if (count($options) > 1) {
-          $collapsed = FALSE;
-        }
-
-        $form['actions'][$i]['argument_map'][$key] = array(
-          '#type' => 'select',
-          '#title' => check_plain($value['#title']),
-          '#options' => $options,
-          '#default_value' => $action['#argument_map'][$key],
-        );
-      }
-
-      $form['actions'][$i]['argument_map']['#collapsed'] = $collapsed;
-
-      // Add the action's form elements if any exist.
-      $callback .= '_form';
-
-      if (function_exists($callback)) {
-        // Load the trigger data.
-        $trigger_data = ca_load_trigger($predicate['#trigger']);
-
-        $form['actions'][$i]['settings'] = $callback(array(), $action['#settings'], $trigger_data['#arguments']);
-      }
-
-      $form['actions'][$i]['remove'] = array(
-        '#type' => 'submit',
-        '#value' => t('Remove this action'),
-        '#name' => 'ca_remove_action_' . $i,
-        '#submit' => array('ca_actions_form_remove_action_submit'),
-        '#attributes' => array('class' => array('ca-remove-confirm')),
-      );
-
-      $i++;
-    }
-  }
-
-  // Unset the session variable used to focus on the new action.
-  unset($_SESSION['ca_action_focus']);
-
-  $form['actions']['add_action'] = array(
-    '#type' => 'select',
-    '#title' => t('Available actions'),
-    '#options' => ca_load_trigger_actions($predicate['#trigger']),
-  );
-
-  $form['actions']['add'] = array(
-    '#type' => 'submit',
-    '#value' => t('Add action'),
-    '#submit' => array('ca_actions_form_add_action_submit'),
-  );
-
-  $form['submit'] = array(
-    '#type' => 'submit',
-    '#value' => t('Save changes'),
-    '#submit' => array('ca_actions_form_save_changes_submit'),
-  );
-
-  return $form;
-}
-
-/**
- * Remove action submit handler.
- *
- * @see ca_actions_form()
- */
-function ca_actions_form_remove_action_submit($form, &$form_state) {
-  // Save the existing actions to preserve any changes.
-  ca_actions_form_update_actions($form_state['values']['pid'], $form_state['values']['actions']);
-
-  // Remove the appropriate action from the predicate and save it.
-  ca_remove_action($form_state['values']['pid'], $form_state['clicked_button']['#parents'][1]);
-
-  drupal_set_message(t('Action removed.'));
-}
-
-/**
- * Add action submit handler.
- *
- * @see ca_actions_form()
- */
-function ca_actions_form_add_action_submit($form, &$form_state) {
-  // Save the existing actions to preserve any changes.
-  $predicate = ca_actions_form_update_actions($form_state['values']['pid'], $form_state['values']['actions']);
-
-  // Store the presumed key of the new action.
-  $_SESSION['ca_action_focus'] = count($predicate['#actions']);
-
-  // Add the specified action to the predicate.
-  ca_add_action($form_state['values']['pid'], $form_state['values']['actions']['add_action']);
-
-  drupal_set_message(t('Action added.'));
-}
-
-/**
- * Save changes submit handler for the actions form.
- *
- * @see ca_actions_form()
- */
-function ca_actions_form_save_changes_submit($form, &$form_state) {
-  // Save the existing actions to preserve any changes.
-  ca_actions_form_update_actions($form_state['values']['pid'], $form_state['values']['actions']);
-
-  drupal_set_message(t('Actions saved.'));
-}
-
-/**
- * Updates a predicate's actions based on the values from an actions form.
- *
- * @param $pid
- *   The ID of the predicate whose actions should be updated.
- * @param $data
- *   The actions values from the form state that should be used to update the
- *     predicate; normally $form_state['values']['actions'].
- * @return
- *   An array representing the full, updated predicate.
- */
-function ca_actions_form_update_actions($pid, $data) {
-  $actions = array();
-
-  // Unset top level components we don't want to get in the way.
-  unset($data['add_action'], $data['add']);
-
-  // Loop through the actions from the form and add them to our temporary array.
-  foreach ((array) $data as $key => $value) {
-    $actions[] = array(
-      '#name' => $value['name'],
-      '#title' => $value['title'],
-      '#argument_map' => $value['argument_map'],
-      '#settings' => empty($value['settings']) ? array() : $value['settings'],
-    );
-  }
-
-  // Load the predicate as it is now.
-  $predicate = ca_load_predicate($pid);
-
-  // Update the actions and save the result.
-  $predicate['#actions'] = $actions;
-  ca_save_predicate($predicate);
-
-  return $predicate;
-}
-
-/**
- * Build a form for adding and editing conditions on a predicate.
- *
- * @ingroup forms
- * @see
- *   ca_conditions_form_add_condition_group_submit()
- *   ca_conditions_form_remove_condition_group_submit()
- *   ca_conditions_form_add_condition_submit()
- *   ca_conditions_form_remove_condition_submit()
- *   ca_conditions_form_save_changes_submit()
- */
-function ca_conditions_form($form, &$form_state, $pid, $title = TRUE) {
-  // Locate the specified predicate.
-  $predicate = ca_load_predicate($pid);
-
-  // Return an empty form if the predicate does not exist.
-  if (empty($predicate)) {
-    return array();
-  }
-
-  // Include the JS for conditional actions forms.
-  drupal_add_js(drupal_get_path('module', 'ca') . '/ca.js');
-
-  // Display the title if appropriate.
-  if ($title) {
-    drupal_set_title($predicate['#title']);
-  }
-
-  // Initialize the conditions available for this predicate.
-  ca_load_trigger_conditions($predicate['#trigger']);
-
-  // Add the predicate ID to the form array.
-  $form['pid'] = array(
-    '#type' => 'value',
-    '#value' => $pid,
-  );
-
-  // If the predicate conditions array isn't already a container of containers,
-  // make it so.  i.e. group => array('group' => array('cond', 'cond'))
-  if (empty($predicate['#conditions'])) {
-    $predicate['#conditions'] = ca_new_conditions();
-  }
-  else {
-    $key = array_shift(array_keys($predicate['#conditions']['#conditions']));
-
-    if (empty($predicate['#conditions']['#conditions'][$key]['#operator'])) {
-      $predicate['#conditions'] = array(
-        '#operator' => 'AND',
-        '#conditions' => array(
-          $predicate['#conditions'],
-        ),
-      );
-    }
-  }
-
-  // Recurse through the predicate's conditions to build the form.
-  $form['conditions'] = _ca_conditions_form_tree($predicate['#conditions'], $predicate['#trigger']);
-  $form['conditions'] = $form['conditions'][0];
-
-  // Always remove the top level condition group controls.
-  unset($form['conditions']['condition']);
-  unset($form['conditions']['add_condition']);
-  unset($form['conditions']['remove_condition_group']);
-
-  // If there are more than one top level condition groups...
-  if (count($form['conditions']['conditions']) > 1) {
-    // Update the top level fieldset.
-    $form['conditions']['#title'] = t('Condition groups');
-    $form['conditions']['#collapsible'] = FALSE;
-
-    // Adjust the titles of the operator options to be more explicit.
-    $form['conditions']['operator']['#options'] = array(
-      'AND' => t('AND. If all of these condition groups are TRUE.'),
-      'OR' => t('OR. If any of these condition groups are TRUE.'),
-    );
-  }
-  else {
-    // Otherwise remove the top level fieldset and operator.
-    unset($form['conditions']['#type']);
-    unset($form['conditions']['operator']);
-
-    // Adjust the second level conditions group to not collapse.
-    $form['conditions']['conditions'][0]['#collapsible'] = FALSE;
-  }
-
-  // Set the conditions array to a tree so the submitted form values mirror the
-  // structure of a predicate's #conditions array.
-  $form['conditions']['#tree'] = TRUE;
-
-  $form['save'] = array(
-    '#type' => 'submit',
-    '#value' => t('Save changes'),
-    '#submit' => array('ca_conditions_form_save_changes_submit'),
-  );
-
-  $form['add_condition_group'] = array(
-    '#type' => 'submit',
-    '#value' => t('Add condition group'),
-    '#submit' => array('ca_conditions_form_add_condition_group_submit'),
-  );
-
-  return $form;
-}
-
-/**
- * Recursively add logical groups to the conditions form as fieldsets.
- *
- * @param $condition
- *   An array consisting of an #operator and another array of #conditions, or
- *   a condition array with data pertaining to its callback function.
- * @param $trigger
- *   The trigger name and data concerning the arguments that are passed in to
- *   the condition.
- * @return
- *   A form array representing the tree of conditions.
- */
-function _ca_conditions_form_tree($condition, $trigger) {
-  // We need an index so condition group fieldsets have unique keys.
-  static $index = 0;
-  $form = array();
-
-  // If we're dealing with a conditions group and not a single condition.
-  if (isset($condition['#operator']) && is_array($condition['#conditions'])) {
-    $level = $index;
-
-    $form[$level] = array(
-      '#type' => 'fieldset',
-      '#title' => t('Conditions group'),
-      '#collapsible' => TRUE,
-    );
-
-    // Add an operator radio select for the group.
-    $form[$level]['operator'] = array(
-      '#type' => 'radios',
-      '#title' => t('Operator'),
-      '#options' => array(
-        'AND' => t('AND. If all of these conditions are TRUE.'),
-        'OR' => t('OR. If any of these conditions are TRUE.'),
-      ),
-      '#default_value' => $condition['#operator'],
-    );
-
-    $form[$level]['conditions'] = array();
-
-    // For each condition in #conditions, add a condition fieldset to the form.
-    foreach ($condition['#conditions'] as $sub_condition) {
-      $result = _ca_conditions_form_tree($sub_condition, $trigger);
-
-      if (is_array($result)) {
-        $form[$level]['conditions'] = array_merge($form[$level]['conditions'], $result);
-      }
-    }
-
-    $form[$level]['condition'] = array(
-      '#type' => 'select',
-      '#title' => t('Available conditions'),
-      '#options' => ca_load_trigger_conditions(),
-    );
-    $form[$level]['add_condition'] = array(
-      '#type' => 'submit',
-      '#value' => t('Add condition'),
-      '#submit' => array('ca_conditions_form_add_condition_submit'),
-      '#name' => 'add_condition_' . $level,
-    );
-    $form[$level]['remove_condition_group'] = array(
-      '#type' => 'submit',
-      '#value' => t('Remove group'),
-      '#submit' => array('ca_conditions_form_remove_condition_group_submit'),
-      '#attributes' => array('class' => array('ca-remove-confirm')),
-      '#name' => 'remove_condition_group_' . $level,
-    );
-
-    $index++;
-
-    return $form;
-  }
-  elseif (!empty($condition)) {
-    // Load the data for the conditions as defined by modules.
-    $condition_data = ca_load_condition();
-
-    // Otherwise add a fieldset for the individual condition.
-    $form[0] = array(
-      '#type' => 'fieldset',
-      '#title' => t('Condition: @title', array('@title' => $condition_data[$condition['#name']]['#title'])),
-      '#description' => t('@description', array('@description' => $condition_data[$condition['#name']]['#description'])),
-      '#collapsible' => TRUE,
-      '#collapsed' => isset($condition['#expanded']) ? FALSE : TRUE,
-    );
-
-    // Add form elements to the fieldset to adjust the condition's settings.
-    $form[0] += _ca_conditions_form_condition($condition, $trigger);
-
-    return $form;
-  }
-}
-
-/**
- * Add a single condition's fieldset to the conditions form.
- *
- * @param $condition
- *   The condition data array.
- * @param $trigger
- *   The trigger name and data concerning the arguments that are passed in to
- *   the condition.
- * @return
- *   A form array representing the condition.
- */
-function _ca_conditions_form_condition($condition, $trigger) {
-  static $identifier = 0;
-
-  // Load the data for the conditions as defined by modules.
-  $condition_data = ca_load_condition();
-
-  // Condition name is a hard reference to the condition and so not editable.
-  $form['name'] = array(
-    '#type' => 'value',
-    '#value' => $condition['#name'],
-  );
-
-  // The title for this particular instance of this condition.
-  $form['title'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Title'),
-    '#default_value' => $condition['#title'],
-  );
-
-  $form['argument_map'] = array(
-    '#type' => 'fieldset',
-    '#title' => t('Arguments'),
-    '#description' => t('Some triggers pass in multiple options for arguments related to a particular condition, so you must specify which options to use in the fields below.'),
-    '#collapsible' => TRUE,
-  );
-
-  // Setup a variable to decide if we can collapse the arguments fieldset.
-  $collapsed = TRUE;
-
-  // Cast to an array to accommodate conditions that need no arguments.
-  foreach ((array) $condition_data[$condition['#name']]['#arguments'] as $key => $value) {
-    // Load the available arguments for each entity as received by the
-    // trigger when it was pulled.
-    $options = ca_load_trigger_arguments($trigger, $value['#entity']);
-
-    // If we have more than one option for any argument, do not collapse.
-    if (count($options) > 1) {
-      $collapsed = FALSE;
-    }
-
-    $form['argument_map'][$key] = array(
-      '#type' => 'select',
-      '#title' => check_plain($value['#title']),
-      '#options' => $options,
-      '#default_value' => $condition['#argument_map'][$key],
-    );
-  }
-
-  $form['argument_map']['#collapsed'] = $collapsed;
-
-  // Whether or not to negate the result of this condition.
-  $form['settings']['negate'] = array(
-    '#type' => 'checkbox',
-    '#title' => t('Negate this condition.'),
-    '#description' => t('Return FALSE if the condition is TRUE and vice versa.'),
-    '#default_value' => $condition['#settings']['negate'],
-  );
-
-  // Get the callback for the condition we're displaying.
-  $callback = $condition_data[$condition['#name']]['#callback'] . '_form';
-
-  if (function_exists($callback)) {
-   // Load the trigger data.
-   $trigger_data = ca_load_trigger($trigger);
-
-  // Add the condition's form elements to the fieldset.
-    $form['settings'] += $callback(array(), $condition['#settings'], $trigger_data['#arguments']);
-  }
-
-  $form['remove'] = array(
-    '#type' => 'submit',
-    '#value' => t('Remove this condition'),
-    '#submit' => array('ca_conditions_form_remove_condition_submit'),
-    '#attributes' => array('class' => array('ca-remove-confirm')),
-    '#name' => 'remove_condition_group_' . $identifier++,
-  );
-
-  return $form;
-}
-
-/**
- * Submit handler for button to add a condition group.
- *
- * @see ca_conditions_form()
- */
-function ca_conditions_form_add_condition_group_submit($form, &$form_state) {
-  // Save the existing conditions to preserve any changes.
-  ca_conditions_form_update_conditions($form_state['values']['pid'], $form_state['values']['conditions']);
-
-  // Add the condition group to the predicate.
-  ca_add_condition_group($form_state['values']['pid']);
-
-  // Display a confirmation message.
-  drupal_set_message(t('Condition group added.'));
-}
-
-/**
- * Submit handler for button to remove a condition grou.
- *
- * @see ca_conditions_form()
- */
-function ca_conditions_form_remove_condition_group_submit($form, &$form_state) {
-  $group_key = FALSE;
-
-  // Loop through the array keys of the conditions group.
-  foreach (array_keys($form['conditions']['conditions']) as $key => $value) {
-    // If we find the key we're looking for...
-    if (is_numeric($value) && $value == $form_state['clicked_button']['#array_parents'][2]) {
-      // Store its position as the new group key once the conditions are saved.
-      // This is necessary because the save function will truncate any holes so
-      // the keys are in numerical order starting with 0.
-      $group_key = $key;
-    }
-  }
-
-  // Save the existing conditions to preserve any changes.
-  ca_conditions_form_update_conditions($form_state['values']['pid'], $form_state['values']['conditions']);
-
-  // Fail if we didn't find a new group key for some reason.
-  if ($group_key === FALSE) {
-    drupal_set_message(t('An error occurred when trying to add the condition.  Please try again.'), 'error');
-  }
-  else {
-    // Remove the condition group from the predicate.
-    ca_remove_condition_group($form_state['values']['pid'], $group_key);
-
-    // Display a confirmation message.
-    drupal_set_message(t('Condition group removed.'));
-  }
-}
-
-/**
- * Submit handler for button to add a condition to a condition group.
- *
- * @see ca_conditions_form()
- */
-function ca_conditions_form_add_condition_submit($form, &$form_state) {
-  $group_key = FALSE;
-
-  // Loop through the array keys of the conditions group.
-  foreach (array_keys($form['conditions']['conditions']) as $key => $value) {
-    // If we find the key we're looking for...
-    if (is_numeric($value) && $value == $form_state['clicked_button']['#array_parents'][2]) {
-      // Store its position as the new group key once the conditions are saved.
-      // This is necessary because the save function will truncate any holes so
-      // the keys are in numerical order starting with 0.
-      $group_key = $key;
-    }
-  }
-
-  // Save the existing conditions to preserve any changes.
-  ca_conditions_form_update_conditions($form_state['values']['pid'], $form_state['values']['conditions']);
-
-  // Fail if we didn't find a new group key for some reason.
-  if ($group_key === FALSE) {
-    drupal_set_message(t('An error occurred when trying to add the condition.  Please try again.'), 'error');
-  }
-  else {
-    // Otherwise add the condition to the specified group.
-    $name = $form_state['values']['conditions']['conditions'][$group_key]['condition'];
-
-    ca_add_condition($form_state['values']['pid'], $name, $group_key);
-
-    $condition = ca_load_condition($name);
-
-    drupal_set_message(t('%title condition added.', array('%title' => $condition['#title'])));
-  }
-}
-
-/**
- * Submit handler for button to remove a condition from a condition group.
- *
- * @see ca_conditions_form()
- */
-function ca_conditions_form_remove_condition_submit($form, &$form_state) {
-  $group_key = FALSE;
-  $cond_key = FALSE;
-
-  // Loop through the array keys of the conditions group.
-  foreach (array_keys($form['conditions']['conditions']) as $key => $value) {
-    // If we find the key we're looking for...
-    if (is_numeric($value) && $value == $form_state['clicked_button']['#array_parents'][2]) {
-      // Store its position as the new group key once the conditions are saved.
-      // This is necessary because the save function will truncate any holes so
-      // the keys are in numerical order starting with 0.
-      $group_key = $key;
-    }
-  }
-
-  // Loop through the array keys of the conditions in the group.
-  foreach (array_keys($form['conditions']['conditions'][$form_state['clicked_button']['#array_parents'][2]]['conditions']) as $key => $value) {
-    // If we find the key we're looking for...
-    if (is_numeric($value) && $value == $form_state['clicked_button']['#array_parents'][4]) {
-      // Store its position as the new condition key once the conditions are
-      // saved. This is necessary because the save function will truncate any
-      // holes so the keys are in numerical order starting with 0.
-      $cond_key = $key;
-    }
-  }
-
-  // Save the existing conditions to preserve any changes.
-  ca_conditions_form_update_conditions($form_state['values']['pid'], $form_state['values']['conditions']);
-
-  // Fail if we didn't find a new group key for some reason.
-  if ($group_key === FALSE || $cond_key === FALSE) {
-    drupal_set_message(t('An error occurred when trying to remove the condition.  Please try again.'), 'error');
-  }
-  else {
-    // Otherwise remove the condition from the specified group.
-    ca_remove_condition($form_state['values']['pid'], $group_key, $cond_key);
-
-    drupal_set_message(t('Condition removed.'));
-  }
-}
-
-/**
- * Save changes submit handler for the conditions form.
- *
- * @see ca_conditions_form()
- */
-function ca_conditions_form_save_changes_submit($form, &$form_state) {
-  // Save the existing conditions to preserve any changes.
-  ca_conditions_form_update_conditions($form_state['values']['pid'], $form_state['values']['conditions']);
-
-  drupal_set_message(t('Conditions saved.'));
-}
-
-/**
- * Update a predicate's conditions based on the values from a conditions form.
- *
- * @param $pid
- *   The ID of the predicate whose conditions should be updated.
- * @param $data
- *   The conditions values from the form state that should be used to update the
- *     predicate; normally $form_state['values']['conditions'].
- * @return
- *   An array representing the full, updated predicate.
- */
-function ca_conditions_form_update_conditions($pid, $data) {
-  // Build the new conditions array from scratch.
-  $conditions = ca_new_conditions();
-
-  // Override the top level operator if need be.
-  if (isset($data['operator'])) {
-    $conditions['#operator'] = $data['operator'];
-  }
-
-  // Use a variable to track the group array key so we can "reset" the keys.
-  $group = 0;
-
-  // Loop through each second level condition group.
-  foreach ($data['conditions'] as $key => $value) {
-    // Save the operator setting.
-    $conditions['#conditions'][$group]['#operator'] = $value['operator'];
-    $conditions['#conditions'][$group]['#conditions'] = array();
-
-    // If conditions exist...
-    if (is_array($value['conditions']) && count($value['conditions']) > 0) {
-      // Use a variable to track the condition array key as for groups.
-      $condition = 0;
-
-      // Loop through the conditions in this group.
-      foreach ($value['conditions'] as $cond_key => $cond_value) {
-        // Save the condition's settings.
-        $conditions['#conditions'][$group]['#conditions'][$condition] = array(
-          '#name' => $cond_value['name'],
-          '#title' => $cond_value['title'],
-          '#argument_map' => $cond_value['argument_map'],
-          '#settings' => $cond_value['settings'],
-        );
-
-        $condition++;
-      }
-    }
-
-    $group++;
-  }
-
-  // Load the predicate as it is now.
-  $predicate = ca_load_predicate($pid);
-
-  // Update the actions and save the result.
-  $predicate['#conditions'] = $conditions;
-  ca_save_predicate($predicate);
-
-  return $predicate;
-}
-
-/**
- * Landing page for converting Workflow-ng configurations.
- *
- * From this page, the user can begin the batch processing of any Workflow-ng
- * configurations in the site's database into Conditional Actions predicates.
- *
- * @ingroup forms
- * @see ca_conversion_form_submit()
- */
-function ca_conversion_form($form, &$form_state) {
-  $form['help'] = array(
-    '#markup' => '<div>' . t('Use this form during the update process from Ubercart 1.0 to 2.0 to convert your Workflow-ng configurations to Conditional Actions predicates.  Once your configurations are converted, you should complete your uninstallation of Workflow-ng.') . '</div>',
-  );
-
-  $form['submit'] = array(
-    '#type' => 'submit',
-    '#value' => t('Convert configurations'),
-  );
-
-  return $form;
-}
-
-/**
- * @see ca_conversion_form_submit()
- */
-function ca_conversion_form_submit($form, &$form_state) {
-  // Convert workflow-ng configurations in a batch process because there may be
-  // a lot of them.
-  $batch = array(
-    'operations' => array(
-      array('_ca_convert_configurations', array()),
-    ),
-    'finished' => '_ca_conversion_finished',
-    'title' => t('Converting Workflow-ng configurations'),
-    'init_message' => t('Beginning conversion...'),
-    'progress_message' => t('@percentage% converted'),
-    'file' => drupal_get_path('module', 'ca') . '/ca.admin.inc',
-  );
-
-  batch_set($batch);
-}
-
-/**
- * Batch API callback for Workflow-ng configuration conversion.
- */
-function _ca_convert_configurations(&$context) {
-  global $user;
-
-  if (db_table_exists('workflow_ng_cfgs')) {
-    if (!isset($context['sandbox']['progress'])) {
-      // Initialize batch data.
-      $context['sandbox']['progress'] = 0;
-      $context['sandbox']['current_cfg'] = '';
-      $context['sandbox']['max'] = db_query("SELECT COUNT(name) FROM {workflow_ng_cfgs} WHERE altered = 1")->fetchField();
-    }
-
-    $limit = 25;
-
-    $result = db_query_range("SELECT name, data FROM {workflow_ng_cfgs} WHERE altered = 1 AND name > '%s' ORDER BY name", $context['sandbox']['current_cfg'], 0, $limit);
-    $predicates = array();
-
-    foreach ($result as $configuration_row) {
-      $predicate = array('#pid' => $configuration_row->name);
-      $conditions = array();
-      $actions = array();
-      if ($configuration = unserialize($configuration_row->data)) {
-        $predicate['#class'] = $configuration['#module'];
-        $predicate['#title'] = $configuration['#label'];
-
-        // Convert event names to corresponding triggers.
-        switch ($configuration['#event']) {
-          case 'order_status_update':
-            $trigger = 'uc_order_status_update';
-          break;
-          case 'payment_entered':
-            $trigger = 'uc_payment_entered';
-          break;
-          case 'checkout_complete':
-            $trigger = 'uc_checkout_complete';
-          break;
-          default:
-            $trigger = $configuration['#event'];
-          break;
-        }
-
-        // In UC 1.x, taxes had an event for each tax rate, using the same
-        // action. In UC 2.x, they use the same trigger, but have separate
-        // actions.
-        if (strpos($trigger, 'calculate_tax_') === 0) {
-          $tax_id = substr($trigger, 14);
-          $trigger = 'calculate_taxes';
-        }
-
-        $predicate['#trigger'] = $trigger;
-        $predicate['#weight'] = $configuration['#weight'];
-        $predicate['#status'] = $configuration['#active'];
-
-        // Numeric keys in $configuration could be for conditions or actions.
-        // Take each and categorize them to add them to the predicate later.
-        for ($i = 0; isset($configuration[$i]); $i++) {
-          if ($configuration[$i]['#type'] == 'action') {
-            $action = _ca_convert_actions($configuration[$i], $tax_id);
-            if ($action) {
-              $actions[] = $action;
-            }
-          }
-          else {
-            $condition = _ca_convert_conditions($configuration[$i]);
-            if ($condition) {
-              $conditions[] = $condition;
-            }
-          }
-        }
-
-        // Conditions are optional. If there are no actions, there's no reason
-        // to make a predicate.
-        if ($conditions) {
-          $predicate['#conditions'] = array(
-            '#operator' => 'AND',
-            '#conditions' => $conditions,
-          );
-        }
-        if ($actions) {
-          $predicate['#actions'] = $actions;
-          $predicate['#uid'] = $user->uid;
-          ca_save_predicate($predicate);
-        }
-      }
-
-      // Store some result for post-processing in the finished callback.
-      $context['results'][] = $configuration_row->name;
-
-      // Update our progress information.
-      $context['sandbox']['progress']++;
-      $context['sandbox']['current_cfg'] = $configuration_row->name;
-      $context['message'] = t('Now processing %cfg', array('%cfg' => $configuration_row->name));
-    }
-
-    // Inform the batch engine that we are not finished,
-    // and provide an estimation of the completion level we reached.
-    if ($context['sandbox']['progress'] != $context['sandbox']['max']) {
-      $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
-    }
-  }
-}
-
-/**
- * Helper function for converting Ubercart's Workflow-ng conditions.
- */
-function _ca_convert_conditions($condition_tree) {
-  static $condition_data;
-  $ca_condition = array();
-
-  if (!isset($condition_data)) {
-    $condition_data = module_invoke_all('ca_condition');
-  }
-
-  // Handle multiple conditions recursively.
-  if ($condition_tree['#type'] == 'AND' || $condition_tree['#type'] == 'OR') {
-    $ca_condition['#operator'] = $condition_tree['#type'];
-    $ca_condition['#conditions'] = array();
-    for ($i = 0; isset($condition_tree[$i]); $i++) {
-      $condition = _ca_convert_conditions($condition_tree[$i]);
-      if ($condition) {
-        $ca_condition['#conditions'][] = $condition;
-      }
-    }
-  }
-  else if ($condition_tree['#type'] == 'condition') {
-    // Some conditions were renamed but check the same things.
-    switch ($condition_tree['#name']) {
-      case 'uc_order_condition_order_total':
-        $ca_condition['#name'] = 'uc_order_condition_total';
-        break;
-      case 'uc_payment_condition_balance':
-        $ca_condition['#name'] = 'uc_payment_condition_order_balance';
-        break;
-      case 'workflow_ng_condition_custom_php':
-        $ca_condition['#name'] = 'ca_condition_custom_php';
-        break;
-      case 'workflow_ng_condition_user_hasrole':
-        $ca_condition['#name'] = 'ca_condition_user_roles';
-        $condition_tree['#settings']['operator'] = $condition_tree['#settings']['operation'];
-        unset($condition_tree['#settings']['operation']);
-        break;
-      default:
-        $ca_condition['#name'] = $condition_tree['#name'];
-        break;
-    }
-
-    if (isset($condition_tree['#label'])) {
-      $ca_condition['#title'] = $condition_tree['#label'];
-    }
-    else {
-      $ca_condition['#title'] = $condition_data[$ca_condition['#name']]['#title'];
-    }
-
-    $ca_condition['#argument_map'] = $condition_tree['#argument map'];
-    foreach ($ca_condition['#argument_map'] as $key => $value) {
-      if ($key == 'user') {
-        $key = 'account';
-      }
-      if ($value == 'user') {
-        $value = 'account';
-      }
-      $ca_condition['#argument_map'][$key] = $value;
-    }
-
-    $ca_condition['#settings'] = $condition_tree['#settings'];
-    if (isset($condition_tree['#negate'])) {
-      $ca_condition['#settings']['negate'] = $condition_tree['#negate'];
-    }
-  }
-
-  return $ca_condition;
-}
-
-/**
- * Helper function for converting Ubercart's Workflow-ng actions.
- */
-function _ca_convert_actions($wf_action, $tax_id = NULL) {
-  static $action_data;
-  $action = $wf_action;
-
-  if (!isset($action_data)) {
-    $action_data = module_invoke_all('ca_action');
-  }
-
-  // Some actions were renamed, but do the same things.
-  switch ($action['#name']) {
-    case 'uc_order_action_update_status':
-      $action['#name'] = 'uc_order_update_status';
-      break;
-    case 'uc_taxes_action_apply_tax':
-      $action['#name'] = 'uc_taxes_action_apply_tax_' . $tax_id;
-      break;
-    case 'workflow_ng_action_custom_php':
-      $action['#name'] = 'ca_action_custom_php';
-      break;
-  }
-
-  if (isset($action['#label'])) {
-    $action['#title'] = $action['#label'];
-    unset($action['#label']);
-  }
-  else {
-    $action['#title'] = $action_data[$action['#name']]['#title'];
-  }
-
-  return $action;
-}
-
-/**
- * Batch finalization function to hide the conversion tab.
- */
-function _ca_conversion_finished() {
-  // Set a variable to hide the conversion tab.
-  variable_set('ca_show_conversion_tab', FALSE);
-
-  // Display a message and redirect to the overview page.
-  drupal_set_message('Your Workflow-ng configurations have been converted.  Please verify the results in your Conditional Actions predicates below.');
-
-  drupal_goto(CA_UI_PATH);
-}

=== removed file 'ca/ca.ca.inc'
--- ca/ca.ca.inc	2010-03-16 21:15:17 +0000
+++ ca/ca.ca.inc	1970-01-01 00:00:00 +0000
@@ -1,510 +0,0 @@
-<?php
-// $Id$
-
-/**
- * @file
- * This file includes some generic conditions and actions.
- */
-
-/*******************************************************************************
- * Conditional Actions Hooks
- ******************************************************************************/
-
-/**
- * Implement hook_ca_entity().
- *
- * Demonstrates defining a data object that may be passed in to ca_pull_trigger
- * and mapped to a predicate's arguments.
- */
-function ca_ca_entity() {
-  $entities = array();
-
-  $entities['user'] = array(
-    '#title' => t('Drupal user'),
-    '#type' => 'object',
-    '#load' => 'user_load',
-    '#save' => 'user_save',
-  );
-  $entities['node'] = array(
-    '#title' => t('Node'),
-    '#type' => 'object',
-    '#load' => 'node_load',
-    '#save' => 'node_save',
-  );
-  $entities['arguments'] = array(
-    '#title' => t('Trigger arguments'),
-    '#type' => 'array',
-  );
-
-  return $entities;
-}
-
-/**
- * Implement hook_ca_condition().
- */
-function ca_ca_condition() {
-  $conditions = array();
-
-  $conditions['ca_condition_date'] = array(
-    '#title' => t('Check the current date'),
-    '#description' => t('Used to determine if the action should be performed on the current date.'),
-    '#category' => t('Drupal'),
-    '#callback' => 'ca_condition_date',
-    '#arguments' => array(),
-  );
-
-  $conditions['node_field_comparison'] = array(
-    '#title' => t('Compare a node field value'),
-    '#description' => t('Returns TRUE if the node field selected below compares to the value entered as specified by the operator.'),
-    '#category' => t('Node'),
-    '#callback' => 'ca_condition_node_field_comparison',
-    '#arguments' => array(
-      'node' => array('#entity' => 'node'),
-    ),
-  );
-
-  $conditions['ca_condition_custom_php'] = array(
-    '#title' => t('Execute custom PHP code'),
-    '#description' => t('Returns whatever your custom PHP code returns.'),
-    '#category' => t('System'),
-    '#callback' => 'ca_condition_custom_php',
-    '#arguments' => array(
-      'arguments' => array('#entity' => 'arguments', '#title' => t('Arguments')),
-    ),
-  );
-
-  $conditions['ca_condition_user_roles'] = array(
-    '#title' => t("Check the user's roles"),
-    '#category' => t('User'),
-    '#description' => t('Returns TRUE if the user roles match your settings.'),
-    '#callback' => 'ca_condition_user_roles',
-    '#arguments' => array(
-      'account' => array('#entity' => 'user', '#title' => t('User')),
-    ),
-  );
-
-  return $conditions;
-}
-
-/**
- * Implement hook_ca_action().
- *
- * Demonstrates defining an action for predicates to use; primarily specifies a
- * callback function to perform the action and an array that specifies arguments
- * and their data types.
- */
-function ca_ca_action() {
-  $actions['ca_drupal_set_message'] = array(
-    '#title' => t('Display a message to the user'),
-    '#category' => t('Drupal'),
-    '#callback' => 'ca_action_drupal_set_message',
-    '#arguments' => array(),
-  );
-
-  $actions['ca_action_custom_php'] = array(
-    '#title' => t('Execute custom PHP code'),
-    '#category' => t('System'),
-    '#callback' => 'ca_action_custom_php',
-    '#arguments' => array(
-      'arguments' => array('#entity' => 'arguments', '#title' => t('Arguments')),
-    ),
-  );
-
-  return $actions;
-}
-
-/**
- * Check that the current time is within a specified range.
- *
- * @see ca_condition_date_form()
- */
-function ca_condition_date($settings) {
-  $set_date_start = gmmktime(0, 0, 0, $settings['date']['month'], $settings['date']['day'], $settings['date']['year']);
-  $set_date_end = gmmktime(23, 59, 59, $settings['date']['month'], $settings['date']['day'], $settings['date']['year']);
-
-  switch ($settings['operator']) {
-    case 'before':
-      return REQUEST_TIME < $set_date_start;
-    case 'only':
-      return ($set_date_start < REQUEST_TIME) && (REQUEST_TIME < $set_date_end);
-    case 'after':
-      return $set_date_end < REQUEST_TIME;
-    default:
-      return FALSE;
-  }
-}
-
-/**
- * @see ca_condition_date()
- */
-function ca_condition_date_form($form_state, $settings = array()) {
-  $form = array();
-
-  $form['operator'] = array(
-    '#type' => 'radios',
-    '#title' => t('Comparison'),
-    '#options' => array(
-      'before' => t('Before'),
-      'only' => t('Only'),
-      'after' => t('After'),
-    ),
-    '#default_value' => $settings['operator'],
-    '#description' => t('Example: "The current date is before the date below."'),
-  );
-
-  $form['date'] = array(
-    '#type' => 'date',
-    '#title' => t('Date'),
-    '#default_value' => $settings['date'],
-    '#description' => t('When the predicate is evaluated, the current date is compared to this date.'),
-  );
-
-  return $form;
-}
-
-/**
- * Compare a node field to a specified value using an operator list.
- *
- * @see ca_condition_node_field_comparison_form()
- */
-function ca_condition_node_field_comparison($node, $settings) {
-  // Convert the node to an array.
-  $node_array = (array) $node;
-
-  // Store the value of the field we're comparing.
-  $field_value = $node_array[$settings['field']];
-
-  // Return the result based on the operator.
-  switch ($settings['operator']) {
-    case 'equal':
-      if ($field_value == $settings['value']) {
-        return TRUE;
-      }
-      break;
-
-    case 'not':
-      if ($field_value != $settings['value']) {
-        return TRUE;
-      }
-      break;
-
-    case 'greater':
-      if ($field_value > $settings['value']) {
-        return TRUE;
-      }
-      break;
-
-    case 'less':
-      if ($field_value < $settings['value']) {
-        return TRUE;
-      }
-      break;
-
-    case 'greater_equal':
-      if ($field_value >= $settings['value']) {
-        return TRUE;
-      }
-      break;
-
-    case 'less_equal':
-      if ($field_value <= $settings['value']) {
-        return TRUE;
-      }
-      break;
-
-    case 'begins':
-      if (strpos($field_value, $settings['value']) === 0) {
-        return TRUE;
-      }
-      break;
-
-    case 'ends':
-      if (substr($field_value, -1 * strlen($settings['value'])) === $settings['value']) {
-        return TRUE;
-      }
-      break;
-
-    case 'contains':
-      if (strpos($field_value, $settings['value']) !== FALSE) {
-        return TRUE;
-      }
-      break;
-
-    case 'yes':
-      if ($field_value) {
-        return TRUE;
-      }
-      break;
-
-    case 'no':
-      if (!$field_value) {
-        return TRUE;
-      }
-      break;
-  }
-
-  return FALSE;
-}
-
-/**
- * @see ca_condition_node_field_comparision()
- */
-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;
-}
-
-/**
- * Display a message to the user.
- *
- * @see ca_action_drupal_set_message_form()
- */
-function ca_action_drupal_set_message($settings) {
-  // Filter the text using the default format.
-  $message = check_markup($settings['message_text'], $settings['message_text_format']);
-
-  // Return if there's nothing to display.
-  if (empty($message) || empty($settings['message_text'])) {
-    return;
-  }
-
-  // Make sure we have a valid message type.
-  if ($settings['message_type'] == 'error') {
-    $type = $settings['message_type'];
-  }
-  else {
-    $type = 'status';
-  }
-
-  // Output the message using the Drupal message API.
-  drupal_set_message($message, $type);
-}
-
-/**
- * @see ca_action_drupal_set_message()
- */
-function ca_action_drupal_set_message_form($form_state, $settings = array()) {
-  $form = array();
-
-  $form['message_text'] = array(
-    '#type' => 'textarea',
-    '#title' => t('Message text'),
-    '#default_value' => $settings['message_text'],
-    '#text_format' => filter_default_format(),
-  );
-
-  $form['message_type'] = array(
-    '#type' => 'radios',
-    '#title' => t('Message type'),
-    '#options' => array(
-      'status' => t('Status'),
-      'error' => t('Error'),
-    ),
-    '#default_value' => isset($settings['message_type']) ? $settings['message_type'] : 'status',
-  );
-
-  return $form;
-}
-
-/**
- * Evaluate a custom PHP condition.
- *
- * @see ca_condition_custom_php_form()
- */
-function ca_condition_custom_php($arguments, $settings) {
-  return _ca_custom_php_eval($settings['php'], $arguments);
-}
-
-/**
- * @see ca_condition_custom_php()
- */
-function ca_condition_custom_php_form($form_state, $settings = array(), $arguments = array()) {
-  $form['variables'] = _ca_custom_php_variables_table($arguments);
-
-  $form['php'] = array(
-    '#type' => 'textarea',
-    '#title' => t('Custom PHP'),
-    '#description' => t('Enter the custom PHP to be evaluated when this condition is executed.  Should not include &lt;?php ?> delimiters.'),
-    '#default_value' => isset($settings['php']) ? $settings['php'] : '',
-  );
-
-  return $form;
-}
-
-/**
- * Check a user's roles.
- *
- * @see ca_condition_user_roles_form()
- */
-function ca_condition_user_roles($account, $settings) {
-  $settings['roles'] = array_filter($settings['roles']);
-
-  if ($settings['operator'] == 'AND') {
-    foreach ($settings['roles'] as $key) {
-      if (!isset($account->roles[$key])) {
-        return FALSE;
-      }
-    }
-    return TRUE;
-  }
-  else {
-    foreach ($settings['roles'] as $key) {
-      if (isset($account->roles[$key])) {
-        return TRUE;
-      }
-    }
-    return FALSE;
-  }
-}
-
-/**
- * @see ca_condition_user_roles()
- */
-function ca_condition_user_roles_form($form_state, $settings = array()) {
-  $form['operator'] = array(
-    '#type' => 'radios',
-    '#title' => t('Operator'),
-    '#description' => t('If you specify <em>AND</em> and want to check a custom role, remember to specify <em>authenticated user</em> where applicable.'),
-    '#options' => array(
-      'OR' => t('OR: If the user has any of these roles.'),
-      'AND' => t('AND: If the user has all of these roles.'),
-    ),
-    '#default_value' => isset($settings['operator']) ? $settings['operator'] : 'OR',
-  );
-  $form['roles'] = array(
-    '#type' => 'checkboxes',
-    '#title' => t('Roles'),
-    '#options' => user_roles(),
-    '#default_value' => isset($settings['roles']) ? $settings['roles'] : array(),
-  );
-
-  return $form;
-}
-
-/**
- * Perform a custom PHP action.
- *
- * @see ca_action_custom_php_form()
- */
-function ca_action_custom_php($arguments, $settings) {
-  _ca_custom_php_eval($settings['php'], $arguments);
-}
-
-/**
- * @see ca_action_custom_php()
- */
-function ca_action_custom_php_form($form_state, $settings = array(), $arguments = array()) {
-  $form['variables'] = _ca_custom_php_variables_table($arguments);
-
-  $form['php'] = array(
-    '#type' => 'textarea',
-    '#title' => t('Custom PHP'),
-    '#description' => t('Enter the custom PHP to be evaluated when this action is executed.  Should not include &lt;?php ?> delimiters.'),
-    '#default_value' => isset($settings['php']) ? $settings['php'] : '',
-  );
-
-  return $form;
-}
-
-/**
- * Return a fieldset used to display available variables for custom PHP
- * conditions and actions.
- */
-function _ca_custom_php_variables_table($arguments) {
-  $rows = array();
-
-  $header = array(t('Variable'), t('Type'), t('Description'));
-
-  // Translate the arguments into descriptive rows.
-  foreach ($arguments as $key => $value) {
-    $rows[] = array(check_plain('$' . $key), check_plain($value['#entity']), $value['#title']);
-  }
-
-  if (empty($rows)) {
-    $rows[] = array(array('data' => t('No variables available.'), 'colspan' => 3));
-  }
-
-  $fieldset = array(
-    '#type' => 'fieldset',
-    '#title' => t('Available PHP variables'),
-    '#description' => t('You may use these variables in your custom PHP.')
-                    . theme('table', array('header' => $header, 'rows' => $rows)),
-    '#collapsible' => TRUE,
-  );
-
-  return $fieldset;
-}
-
-/**
- * Evaluate a custom PHP condition or action with trigger arguments available
- * as variables.
- */
-function _ca_custom_php_eval($php, $arguments) {
-  $argument_data = array();
-
-  // Convert the arguments to an array of data that we can extract.
-  foreach ($arguments as $key => $value) {
-    $argument_data[$key] = $value['#data'];
-  }
-
-  extract($argument_data);
-  return eval($php);
-}

=== removed file 'ca/ca.css'
--- ca/ca.css	2009-02-02 18:37:10 +0000
+++ ca/ca.css	1970-01-01 00:00:00 +0000
@@ -1,21 +0,0 @@
-/* $Id$ */
-
-table.ca-predicate-trigger .col-title {
-  width: 70%;
-}
-
-table.ca-predicate-class .col-title {
-  width: 40%;
-}
-
-.ca-predicate-trigger tr, .ca-predicate-class tr {
-  vertical-align: top;
-}
-
-.ca-predicate-table-weight {
-  text-align: center;
-}
-
-.ca-predicate-table-ops {
-  white-space: nowrap;
-}

=== removed file 'ca/ca.info'
--- ca/ca.info	2010-02-02 15:41:04 +0000
+++ ca/ca.info	1970-01-01 00:00:00 +0000
@@ -1,9 +0,0 @@
-; $Id$
-name = Conditional Actions
-description = "REQUIRED. Create conditional action configurations for taxes, shipping, and more!"
-package = Ubercart - core
-core = 7.x
-files[] = ca.module
-files[] = ca.install
-files[] = ca.admin.inc
-files[] = ca.ca.inc

=== removed file 'ca/ca.install'
--- ca/ca.install	2010-03-03 15:47:24 +0000
+++ ca/ca.install	1970-01-01 00:00:00 +0000
@@ -1,94 +0,0 @@
-<?php
-// $Id$
-
-/**
- * @file
- * Install hooks for ca.module.
- */
-
-/**
- * Implement hook_schema().
- */
-function ca_schema() {
-  $schema = array();
-
-  $schema['ca_predicates'] = array(
-    'fields' => array(
-      'pid' => array(
-        'type' => 'varchar',
-        'length' => 255,
-        'not null' => TRUE,
-        'default' => '',
-      ),
-      'title' => array(
-        'type' => 'varchar',
-        'length' => 255,
-        'not null' => TRUE,
-        'default' => '',
-      ),
-      'description' => array(
-        'type' => 'text',
-      ),
-      'class' => array(
-        'type' => 'varchar',
-        'length' => 255,
-        'not null' => TRUE,
-        'default' => '',
-      ),
-      'status' => array(
-        'type' => 'int',
-        'size' => 'tiny',
-        'unsigned' => TRUE,
-        'not null' => TRUE,
-        'default' => 0,
-      ),
-      'weight' => array(
-        'type' => 'int',
-        'size' => 'small',
-        'not null' => TRUE,
-        'default' => 0,
-      ),
-      'uid' => array(
-        'type' => 'int',
-        'unsigned' => TRUE,
-        'not null' => TRUE,
-        'default' => 0,
-      ),
-      'ca_trigger' => array(
-        'type' => 'varchar',
-        'length' => 255,
-        'not null' => TRUE,
-        'default' => '',
-      ),
-      'conditions' => array(
-        'type' => 'text',
-        'size' => 'big',
-        'serialize' => TRUE,
-      ),
-      'actions' => array(
-        'type' => 'text',
-        'size' => 'big',
-        'serialize' => TRUE,
-      ),
-      'created' => array(
-        'type' => 'int',
-        'not null' => TRUE,
-        'default' => 0,
-      ),
-      'modified' => array(
-        'type' => 'int',
-        'not null' => TRUE,
-        'default' => 0,
-      ),
-    ),
-    'indexes' => array(
-      'ca_predicates_class' => array('class'),
-      'ca_predicates_status' => array('status'),
-      'ca_predicates_ca_trigger' => array('ca_trigger'),
-    ),
-    'primary key' => array('pid'),
-  );
-
-  return $schema;
-}
-

=== removed file 'ca/ca.js'
--- ca/ca.js	2010-02-09 21:05:11 +0000
+++ ca/ca.js	1970-01-01 00:00:00 +0000
@@ -1,20 +0,0 @@
-// $Id$
-(function($) {
-
-/**
- * @file
- *   Adds some helper JS to the conditional actions forms.
- */
-
-/**
- * Add confirmation prompts to remove buttons.
- */
-Drupal.behaviors.caRemoveConfirm = {
-  attach: function(context, settings) {
-    $('.ca-remove-confirm:not(.caRemoveConfirm-processed)', context).addClass('caRemoveConfirm-processed').click(function() {
-      return confirm(Drupal.t('Are you sure you want to remove this item?'));
-    });
-  }
-}
-
-})(jQuery);

=== removed file 'ca/ca.module'
--- ca/ca.module	2010-05-21 14:03:12 +0000
+++ ca/ca.module	1970-01-01 00:00:00 +0000
@@ -1,1034 +0,0 @@
-<?php
-// $Id$
-
-/**
- * @file
- * This is a demonstration module for the new conditional actions API.
- */
-
-/**
- * The Drupal menu path to Conditional Actions pages.
- */
-define('CA_UI_PATH', 'admin/store/ca');
-
-require_once('ca.ca.inc');
-
-/*******************************************************************************
- * Drupal Hooks
- ******************************************************************************/
-
-/**
- * Implement hook_menu().
- */
-function ca_menu() {
-  $items = array();
-
-  $items[CA_UI_PATH] = array(
-    'title' => 'Conditional actions',
-    'description' => 'Administer the predicates setup to automate your store.',
-    'page callback' => 'ca_admin',
-    'access arguments' => array('administer conditional actions'),
-    'file' => 'ca.admin.inc',
-    'weight' => 5,
-  );
-  $items[CA_UI_PATH . '/overview'] = array(
-    'title' => 'Overview',
-    'weight' => 0,
-    'type' => MENU_DEFAULT_LOCAL_TASK,
-  );
-  $items[CA_UI_PATH . '/overview/trigger'] = array(
-    'title' => 'By trigger',
-    'description' => 'Administer the predicates setup to automate your store.',
-    'weight' => 0,
-    'type' => MENU_DEFAULT_LOCAL_TASK,
-  );
-  $items[CA_UI_PATH . '/overview/class'] = array(
-    'title' => 'By class',
-    'description' => 'Administer the predicates setup to automate your store.',
-    'page callback' => 'ca_admin',
-    'page arguments' => array('class'),
-    'access arguments' => array('administer conditional actions'),
-    'type' => MENU_LOCAL_TASK,
-    'weight' => 5,
-    'file' => 'ca.admin.inc',
-  );
-  $items[CA_UI_PATH . '/add'] = array(
-    'title' => 'Add a predicate',
-    'description' => 'Allows an administrator to create a new predicate.',
-    'page callback' => 'drupal_get_form',
-    'page arguments' => array('ca_predicate_meta_form', '0'),
-    'access arguments' => array('administer conditional actions'),
-    'type' => MENU_LOCAL_TASK,
-    'weight' => 5,
-    'file' => 'ca.admin.inc',
-  );
-  $items[CA_UI_PATH . '/convert'] = array(
-    'title' => 'Convert configurations',
-    'description' => 'Convert Workflow-ng configurations into Conditional Actions predicates.',
-    'page callback' => 'drupal_get_form',
-    'page arguments' => array('ca_conversion_form'),
-    'access callback' => 'ca_convert_configurations_access',
-    'type' => MENU_LOCAL_TASK,
-    'weight' => 10,
-    'file' => 'ca.admin.inc',
-  );
-  $items[CA_UI_PATH . '/%/edit'] = array(
-    'title' => 'Edit predicate',
-    'description' => "Edit a predicate's meta data, conditions, and actions.",
-    'page callback' => 'drupal_get_form',
-    'page arguments' => array('ca_predicate_meta_form', 3),
-    'access arguments' => array('administer conditional actions'),
-    'file' => 'ca.admin.inc',
-    'type' => MENU_CALLBACK,
-  );
-  $items[CA_UI_PATH . '/%/edit/meta'] = array(
-    'title' => 'Meta data',
-    'description' => 'Edit the meta data for a predicate like title, trigger, etc.',
-    'page callback' => 'drupal_get_form',
-    'page arguments' => array('ca_predicate_meta_form', 3),
-    'access arguments' => array('administer conditional actions'),
-    'file' => 'ca.admin.inc',
-    'type' => MENU_DEFAULT_LOCAL_TASK,
-    'weight' => -10,
-  );
-  $items[CA_UI_PATH . '/%/edit/conditions'] = array(
-    'title' => 'Conditions',
-    'description' => 'Edit the conditions for a predicate.',
-    'page callback' => 'drupal_get_form',
-    'page arguments' => array('ca_conditions_form', 3),
-    'access arguments' => array('administer conditional actions'),
-    'file' => 'ca.admin.inc',
-    'type' => MENU_LOCAL_TASK,
-    'weight' => -5,
-  );
-  $items[CA_UI_PATH . '/%/edit/actions'] = array(
-    'title' => 'Actions',
-    'description' => 'Edit the actions for a predicate.',
-    'page callback' => 'drupal_get_form',
-    'page arguments' => array('ca_actions_form', 3),
-    'access arguments' => array('administer conditional actions'),
-    'file' => 'ca.admin.inc',
-    'type' => MENU_LOCAL_TASK,
-    'weight' => 0,
-  );
-  $items[CA_UI_PATH . '/%/reset'] = array(
-    'title' => 'Reset a predicate',
-    'page callback' => 'drupal_get_form',
-    'page arguments' => array('ca_predicate_delete_form', 3),
-    'access arguments' => array('administer conditional actions'),
-    'file' => 'ca.admin.inc',
-    'type' => MENU_CALLBACK,
-  );
-  $items[CA_UI_PATH . '/%/delete'] = array(
-    'title' => 'Delete a predicate',
-    'page callback' => 'drupal_get_form',
-    'page arguments' => array('ca_predicate_delete_form', 3),
-    'access arguments' => array('administer conditional actions'),
-    'file' => 'ca.admin.inc',
-    'type' => MENU_CALLBACK,
-  );
-
-  return $items;
-}
-
-/**
- * Determine access to the configuration conversion form.
- */
-function ca_convert_configurations_access() {
-  return user_access('administer conditional actions') && variable_get('ca_show_conversion_tab', TRUE);
-}
-
-/**
- * Implement hook_permission().
- */
-function ca_permission() {
-  return array(
-    'administer conditional actions' => array(
-      'title' => t('Administer conditional actions'),
-    )
-  );
-}
-
-
-/*******************************************************************************
- * Module and Helper Functions
- ******************************************************************************/
-
-/**
- * Pull a trigger and evaluate any predicates associated with that trigger.
- *
- * @param ...
- *   Accepts a variable number of arguments. The first should always be the
- *   string name of the trigger to pull with any additional arguments being
- *   the arguments expected by the trigger and used for evaluation.
- * @return
- *   TRUE or FALSE indicating if at least one predicate was evaluated.
- */
-function ca_pull_trigger() {
-  $args = func_get_args();
-  $trigger = array_shift($args);
-
-  // Load the data for the specified trigger.
-  $trigger_data = ca_load_trigger($trigger);
-
-  // Fail if the specified trigger doesn't exist.
-  if (!$trigger_data) {
-    return FALSE;
-  }
-
-  // Load any predicates associated with the trigger.
-  $predicates = ca_load_trigger_predicates($trigger);
-
-  // Fail if we didn't find any predicates.
-  if (!$predicates || count($predicates) == 0) {
-    return FALSE;
-  }
-
-  // Prepare the arguments for evaluation.
-  $arguments = ca_parse_trigger_args($trigger_data, $args);
-
-  // Fail if we didn't receive the right type of or enough arguments.
-  if (!$arguments) {
-    return FALSE;
-  }
-
-  // Loop through the predicates and evaluate them one by one.
-  foreach ($predicates as $pid => $predicate) {
-    // If all of a predicate's conditions evaluate to TRUE...
-    if (ca_evaluate_conditions($predicate, $arguments)) {
-      // Then perform its actions.
-      ca_perform_actions($predicate, $arguments);
-    }
-  }
-
-  return TRUE;
-}
-
-/**
- * Parse the argument array into a CA friendly array for the trigger.
- *
- * @param $trigger
- *   The name of the trigger for which we are parsing the arguments.
- * @param $args
- *   An array of arguments to check against the expected arguments.
- * @return
- *   The array of arguments keyed according to the trigger's argument names.
- */
-function ca_parse_trigger_args($trigger, $args) {
-  // Fail if we didn't receive enough arguments for this trigger.
-  if (count($args) < count($trigger['#arguments'])) {
-    return FALSE;
-  }
-
-  // Load all the entity information.
-  $entities = module_invoke_all('ca_entity');
-
-  // Loop through the expected arguments.
-  foreach ($trigger['#arguments'] as $key => $value) {
-    // Grab for comparison the next argument passed to the trigger.
-    $arg = array_shift($args);
-
-    // Check the type and fail if it is incorrect.
-    if (gettype($arg) != $entities[$value['#entity']]['#type']) {
-      return FALSE;
-    }
-
-    // Add the entity to the arguments array along with its meta data.
-    $arguments[$key] = array(
-      '#entity' => $value['#entity'],
-      '#title' => $value['#title'],
-      '#data' => $arg,
-    );
-  }
-
-  return $arguments;
-}
-
-/**
- * Load predicates based on the specified parameters.
- *
- * @param $trigger
- *   The name of the trigger for which to search when loading the predicates.
- * @param $all
- *   FALSE by default, specifies whether we want to load all possible predicates
- *   or only those that are active (status > 0).
- * @return
- *   An array of predicates.
- */
-function ca_load_trigger_predicates($trigger, $all = FALSE) {
-  // Load all the module defined predicates.
-  $predicates = module_invoke_all('ca_predicate');
-
-  // Loop through the module defined predicates to prepare the data - unsets
-  // inactive predicates if $all == FALSE and adds a default weight if need be.
-  foreach ($predicates as $key => $value) {
-    // Unset the predicate if it doesn't use the specified trigger.
-    if ($value['#trigger'] != $trigger) {
-      unset($predicates[$key]);
-      continue;
-    }
-
-    if (!$all && $value['#status'] <= 0) {
-      unset($predicates[$key]);
-    }
-    elseif (!isset($value['#weight'])) {
-      $predicates[$key]['#weight'] = 0;
-    }
-  }
-
-  // Load and loop through the predicates from the database for this trigger.
-  $result = db_query("SELECT * FROM {ca_predicates} WHERE ca_trigger = :trigger", array(':trigger' => $trigger), array('fetch' => PDO::FETCH_ASSOC));
-  foreach ($result as $data) {
-    // Module defined predicates have string IDs.  When a user modifies one of
-    // these, we unset the module defined predicate and reconsider adding it in.
-    if (!is_numeric($data['pid'])) {
-      unset($predicates[$data['pid']]);
-    }
-
-    // Add predicates from the database to our return array if $all == TRUE or
-    // if the predicate is active.
-    if ($all || $data['status'] > 0) {
-      $predicate = ca_prepare_db_predicate($data);
-
-      // Set the actions' weight if necessary and sort actions by their weight.
-      for ($i = 0; $i < count($predicate['#actions']); $i++) {
-        if (!isset($predicate['#actions'][$i]['#weight'])) {
-          $predicate['#actions'][$i]['#weight'] = 0;
-        }
-      }
-      usort($predicate['#actions'], 'ca_weight_sort');
-
-      $predicates[$data['pid']] = $predicate;
-    }
-  }
-
-  uasort($predicates, 'ca_weight_sort');
-
-  return $predicates;
-}
-
-/**
- * Prepare predicate data from the database into a full predicate array.
- *
- * @param $data
- *   An array of data representing a row in the predicates table.
- * @return
- *   A predicate array.
- */
-function ca_prepare_db_predicate($data) {
-  $predicate = array();
-
-  foreach ($data as $key => $value) {
-    switch ($key) {
-      // Condition and action data needs to be unserialized.
-      case 'conditions':
-      case 'actions':
-        $predicate['#' . $key] = unserialize($value);
-        break;
-      case 'ca_trigger':
-        $predicate['#trigger'] = $value;
-        break;
-      default:
-        $predicate['#' . $key] = $value;
-        break;
-    }
-  }
-
-  return $predicate;
-}
-
-/**
- * Evaluate a predicate's conditions.
- *
- * @param $predicate
- *   A fully loaded predicate array.
- * @param $arguments
- *   The array of parsed arguments for the trigger.
- * @return
- *   TRUE or FALSE indicating the success or failure of the evaluation.
- */
-function ca_evaluate_conditions($predicate, $arguments) {
-  // Automatically pass if there are no conditions.
-  if (empty($predicate['#conditions'])) {
-    return TRUE;
-  }
-
-  // Load the data for the conditions as defined by modules.
-  $condition_data = module_invoke_all('ca_condition');
-
-  // Recurse through the predicate's conditions for evaluation.
-  $result = _ca_evaluate_conditions_tree($predicate['#conditions'], $arguments, $condition_data);
-
-  if (is_null($result)) {
-    $result = FALSE;
-  }
-
-  return $result;
-}
-
-/**
- * Recursively evaluate conditions to accommodate nested logical groups.
- */
-function _ca_evaluate_conditions_tree($condition, $arguments, $condition_data) {
-  if (isset($condition['#operator']) && is_array($condition['#conditions'])) {
-    // Default to TRUE for cases of empty conditions arrays.
-    $result = TRUE;
-
-    foreach ($condition['#conditions'] as $sub_condition) {
-      $result = _ca_evaluate_conditions_tree($sub_condition, $arguments, $condition_data);
-
-      // Invalid conditions return NULL. Skip it and go to the next one.
-      if (is_null($result)) {
-        continue;
-      }
-      // Save the processors! Apply Boolean shortcutting if we can.
-      if ($condition['#operator'] == 'OR' && $result) {
-        return TRUE;
-      }
-      elseif ($condition['#operator'] == 'AND' && !$result) {
-        return FALSE;
-      }
-    }
-    return $result;
-  }
-  else {
-    return _ca_evaluate_condition($condition, $arguments, $condition_data);
-  }
-}
-
-/**
- * Evaluate a single condition.
- */
-function _ca_evaluate_condition($condition, $arguments, $condition_data) {
-  $args = array();
-
-  // Make sure the condition tree is sane.
-  if (!is_array($condition_data[$condition['#name']])) {
-    return NULL;
-  }
-
-  // Get the callback function for the current condition.
-  $callback = $condition_data[$condition['#name']]['#callback'];
-
-  // Skip this condition if the function does not exist.
-  if (!function_exists($callback)) {
-    return NULL;
-  }
-
-  // Loop through the expected arguments for a condition.
-  // Cast to an array to accommodate conditions that need no arguments.
-  foreach ((array) $condition_data[$condition['#name']]['#arguments'] as $key => $value) {
-    // Using the argument map for the condition on this predicate, fetch the
-    // argument that was passed to the trigger that matches to the argument
-    // needed to evaluate this condition.
-    if (isset($condition['#argument_map'][$key])) {
-      if ($value['#entity'] == 'arguments') {
-        $args[] = $arguments;
-      }
-      else {
-        $args[] = $arguments[$condition['#argument_map'][$key]]['#data'];
-      }
-    }
-    else {
-      // Skip this condition of the predicate didn't map the arguments needed.
-      return NULL;
-    }
-  }
-
-  // Add the condition settings to the argument list.
-  $args[] = $condition['#settings'];
-
-  // Call the condition's function with the appropriate arguments.
-  $result = call_user_func_array($callback, $args);
-
-  // If the negate operator is TRUE, then switch the result!
-  if ($condition['#settings']['negate']) {
-    $result = !$result;
-  }
-
-  return $result;
-}
-
-/**
- * Perform a predicate's actions in order, preserving changes to the arguments.
- *
- * @param $predicate
- *   A fully loaded predicate array.
- * @param $arguments
- *   The array of parsed arguments for the trigger.
- * @return
- *   An array of results, if any, that were returned by the actions.
- */
-function ca_perform_actions($predicate, $arguments) {
-  // Exit now if we don't have any actions.
-  if (count($predicate['#actions']) == 0) {
-    return;
-  }
-
-  $results = array();
-
-  // Load the data for the actions as defined by modules.
-  $action_data = module_invoke_all('ca_action');
-
-  foreach ($predicate['#actions'] as $i => $action) {
-    $args = array();
-
-    // Get the callback function for the current action.
-    $callback = $action_data[$action['#name']]['#callback'];
-
-    // Do not perform the action if the function does not exist.
-    if (!function_exists($callback)) {
-      continue;
-    }
-
-    // Loop through the expected arguments for an action.
-    foreach ($action_data[$action['#name']]['#arguments'] as $key => $value) {
-      // Using the argument map for the action on this predicate, fetch the
-      // argument that was passed to the trigger that matches to the argument
-      // needed to perform this action.
-      if (isset($action['#argument_map'][$key])) {
-        // Adding the arguments as references so action functions can update the
-        // arguments here when they make changes to the argument data.
-        if ($value['#entity'] == 'arguments') {
-          $args[] = &$arguments;
-        }
-        else {
-          $args[] = &$arguments[$action['#argument_map'][$key]]['#data'];
-        }
-      }
-      else {
-        // Skip this action of the predicate didn't map the arguments needed.
-        continue 2;
-      }
-    }
-
-    // Add the condition settings to the argument list.
-    $args[] = is_array($action['#settings']) ? $action['#settings'] : array();
-
-    // Call the action's function with the appropriate arguments.
-    $results[$i] = call_user_func_array($callback, $args);
-  }
-
-  return $results;
-}
-
-/**
- * Load triggers defined in modules via hook_ca_trigger().
- *
- * @param $trigger
- *   Defaults to 'all'; may instead be the name of the trigger to load.
- * @return
- *   An array of data for the specified trigger or an array of all the trigger
- *   data if 'all' was specified.  Returns FALSE if a specified trigger is
- *   non-existent.
- */
-function ca_load_trigger($trigger = 'all') {
-  static $triggers;
-
-  // Load the triggers defined in enabled modules to a cached variable.
-  if (empty($triggers)) {
-    $triggers = module_invoke_all('ca_trigger');
-  }
-
-  // Return the whole array if the trigger specified is 'all'.
-  if ($trigger === 'all') {
-    return $triggers;
-  }
-
-  // If the specified trigger is non-existent, return FALSE.
-  if (!isset($triggers[$trigger])) {
-    return FALSE;
-  }
-
-  return $triggers[$trigger];
-}
-
-/**
- * Return a trigger's arguments formatted for select element options.
- *
- * @param $trigger
- *   The name of the trigger to load arguments for.
- * @param $entity
- *   The name of the entity type we must restrict our returned arguments to.
- * @return
- *   An array of arguments in FAPI options format.
- */
-function ca_load_trigger_arguments($trigger, $entity) {
-  static $arguments = array();
-
-  // Load the arguments if we can't find a cached version.
-  if (!isset($arguments[$trigger][$entity])) {
-    $arguments[$trigger][$entity] = array();
-
-    // Handle the arguments entity specially, as it should never be specified
-    // in a trigger.
-    if ($entity == 'arguments') {
-      $arguments[$trigger][$entity]['arguments'] = t('Arguments');
-    }
-    else {
-      // Load the trigger data.
-      $trigger_data = ca_load_trigger($trigger);
-
-      // Add the trigger's arguments to the options array if the entity matches.
-      foreach ((array) $trigger_data['#arguments'] as $key => $value) {
-        if ($value['#entity'] == $entity) {
-          $arguments[$trigger][$entity][$key] = $value['#title'];
-        }
-      }
-    }
-  }
-
-  return $arguments[$trigger][$entity];
-}
-
-/**
- * Load conditions defined in modules via hook_ca_condition().
- *
- * @param $condition
- *   Defaults to 'all'; may instead be the name of the condition to load.
- * @return
- *   An array of data for the specified condition or an array of all the
- *     condition data if 'all' was specified.  Returns FALSE if a specified
- *     condition is non-existent.
- */
-function ca_load_condition($condition = 'all') {
-  static $conditions;
-
-  // Load the conditions defined in enabled modules to a cached variable.
-  if (empty($conditions)) {
-    $conditions = module_invoke_all('ca_condition');
-  }
-
-  // Return the whole array if the trigger specified is 'all'.
-  if ($condition === 'all') {
-    return $conditions;
-  }
-
-  // If the specified trigger is non-existent, return FALSE.
-  if (!isset($conditions[$condition])) {
-    return FALSE;
-  }
-
-  return $conditions[$condition];
-}
-
-/**
- * Return an array of conditions available for the specified trigger.
- *
- * @param $trigger
- *   The name of a trigger to find conditions for; if left empty, the function
- *   returns conditions for the previously specified trigger.
- * @return
- *   A nested array of names/titles for the conditions available for the
- *   trigger; in the format required by select elements in FAPI.
- */
-function ca_load_trigger_conditions($trigger = '') {
-  static $options = array();
-
-  if (!empty($trigger)) {
-    // Load the specified trigger.
-    $trigger = ca_load_trigger($trigger);
-    $trigger_entities = array();
-
-    // Organize trigger arguments by entity.
-    foreach ($trigger['#arguments'] as $argument) {
-      $trigger_entities[$argument['#entity']] = $argument;
-    }
-
-    // Load and loop through all the conditions defined by modules.
-    $conditions = ca_load_condition();
-
-    foreach ($conditions as $name => $condition) {
-      // Check through each argument needed for the condition.
-      // Cast to an array to accommodate conditions that need no arguments.
-      foreach ((array) $condition['#arguments'] as $argument) {
-        $entity = $argument['#entity'];
-        // If the condition requires an entity the trigger doesn't provide,
-        // then skip to the next condition.
-        if ($entity != 'arguments' && !$trigger_entities[$entity]) {
-          continue 2;
-        }
-      }
-
-      // Getting this far means that all of the condition's arguments have
-      // the same entity types as the trigger's. Add it to the options,
-      // and group them by category for usability.
-      $options[$condition['#category']][$name] = $condition['#title'];
-    }
-
-    // Alphabetically sort the groups and their options.
-    foreach ($options as $group => $conditions) {
-      asort($conditions);
-      $options[$group] = $conditions;
-    }
-    ksort($options);
-  }
-
-  return $options;
-}
-
-/**
- * Load actions defined in modules via hook_ca_action().
- *
- * @param $action
- *   Defaults to 'all'; may instead be the name of the action to load.
- * @return
- *   An array of data for the specified action or an array of all the action
- *   data if 'all' was specified.  Returns FALSE if a specified action is
- *   non-existent.
- */
-function ca_load_action($action = 'all') {
-  static $actions;
-
-  // Load the actions defined in enabled modules to a cached variable.
-  if (empty($actions)) {
-    $actions = module_invoke_all('ca_action');
-  }
-
-  // Return the whole array if the trigger specified is 'all'.
-  if ($action === 'all') {
-    return $actions;
-  }
-
-  // If the specified trigger is non-existent, return FALSE.
-  if (!isset($actions[$action])) {
-    return FALSE;
-  }
-
-  return $actions[$action];
-}
-
-/**
- * Return an array of actions available for the specified trigger.
- *
- * @param $trigger
- *   The name of a trigger to find actions for; if left empty, the function
- *   returns conditions for the previously specified trigger.
- * @return
- *   A nested array of names/titles for the actions available for the trigger;
- *   in the format required by select elements in FAPI.
- */
-function ca_load_trigger_actions($trigger = '') {
-  static $options = array();
-
-  if (!empty($trigger)) {
-    // Load the specified trigger.
-    $trigger = ca_load_trigger($trigger);
-    $trigger_entities = array();
-
-    // Organize trigger arguments by entity.
-    foreach ($trigger['#arguments'] as $argument) {
-      $trigger_entities[$argument['#entity']] = $argument;
-    }
-
-    // Load and loop through all the actions defined by modules.
-    $actions = ca_load_action();
-
-    foreach ($actions as $name => $action) {
-      // Check through each argument needed for the condition.
-      foreach ($action['#arguments'] as $argument) {
-        $entity = $argument['#entity'];
-        // If the action requires an entity the trigger doesn't provide,
-        // then skip to the next action.
-        if ($entity != 'arguments' && !$trigger_entities[$entity]) {
-          continue 2;
-        }
-      }
-
-      // Getting this far means that all of the condition's arguments have
-      // the same entity types as the trigger's. Add it to the options,
-      // and group them by category for usability.
-      $options[$action['#category']][$name] = $action['#title'];
-    }
-
-    // Alphabetically sort the groups and their options.
-    foreach ($options as $group => $actions) {
-      asort($actions);
-      $options[$group] = $actions;
-    }
-    ksort($options);
-  }
-
-  return $options;
-}
-
-/**
- * Return a default conditions array for use on new predicates or in the UI.
- */
-function ca_new_conditions() {
-  return array(
-    '#operator' => 'AND',
-    '#conditions' => array(
-      array(
-        '#operator' => 'AND',
-        '#conditions' => array(),
-      ),
-    ),
-  );
-}
-
-/**
- * Add a new condition group to a predicate.
- *
- * @param $pid
- *   The ID of the predicate to add the condition group to.
- * @return
- *   An array representing the full, updated predicate.
- */
-function ca_add_condition_group($pid) {
-  // Load the predicate.
-  $predicate = ca_load_predicate($pid);
-
-  // Add the condition group to the conditions array in the appropriate place.
-  if (empty($predicate['#conditions'])) {
-    $predicate['#conditions'] = ca_new_conditions();
-  }
-  else {
-    $predicate['#conditions']['#conditions'][] = array(
-      '#operator' => 'AND',
-      '#conditions' => array(),
-    );
-  }
-
-  // Save the changes.
-  ca_save_predicate($predicate);
-
-  return $predicate;
-}
-
-/**
- * Remove a condition group from a predicate.
- *
- * @param $pid
- *   The ID of the predicate to remove the condition group from.
- * @param $group_key
- *   The key of the condition group to remove.
- * @return
- *   An array representing the full, updated predicate.
- */
-function ca_remove_condition_group($pid, $group_key) {
-  // Load the predicate as it is now.
-  $predicate = ca_load_predicate($pid);
-
-  // Update, save, and return the predicate.
-  unset($predicate['#conditions']['#conditions'][$group_key]);
-  ca_save_predicate($predicate);
-
-  return $predicate;
-}
-
-/**
- * Add a new condition to a predicate.
- *
- * @param $pid
- *   The ID of the predicate to add the condition to.
- * @param $name
- *   The name of the condition to add.
- * @param $group_key
- *   The key of the condition group we're adding the condition to.
- * @param $mark_expanded
- *   If set to TRUE marks the condition so that it will be expanded next time it
- *   displays in the UI so the user can adjust its settings.
- * @return
- *   An array representing the full, updated predicate.
- */
-function ca_add_condition($pid, $name, $group_key, $mark_expanded = TRUE) {
-  // Load the predicate.
-  $predicate = ca_load_predicate($pid);
-
-  // Load the condition we want to add to the predicate.
-  $data = ca_load_condition($name);
-
-  // If the condition exists...
-  if ($data) {
-    // Build the condition array.
-    $condition = array(
-      '#name' => $name,
-      '#title' => $data['#title'],
-      '#argument_map' => array(),
-      '#settings' => array(),
-    );
-
-    // Mark it for expansion in the form if specified.
-    if ($mark_expanded) {
-      $condition['#expanded'] = TRUE;
-    }
-
-    // Add the condition to the predicate.
-    $predicate['#conditions']['#conditions'][$group_key]['#conditions'][] = $condition;
-  }
-
-  ca_save_predicate($predicate);
-
-  return $predicate;
-}
-
-/**
- * Remove a condition from a predicate.
- *
- * @param $pid
- *   The ID of the predicate to remove the condition group from.
- * @param $group_key
- *   The key of the condition group the condition is in.
- * @param $cond_key
- *   The key of the condition to remove.
- * @return
- *   An array representing the full, updated predicate.
- */
-function ca_remove_condition($pid, $group_key, $cond_key) {
-  // Load the predicate as it is now.
-  $predicate = ca_load_predicate($pid);
-
-  // Update, save, and return the predicate.
-  unset($predicate['#conditions']['#conditions'][$group_key]['#conditions'][$cond_key]);
-  ca_save_predicate($predicate);
-
-  return $predicate;
-}
-
-/**
- * Add a new action to a predicate.
- *
- * @param $pid
- *   The ID of the predicate to add the action to.
- * @param $name
- *   The name of the action to add.
- * @return
- *   An array representing the full, updated predicate.
- */
-function ca_add_action($pid, $name) {
-  // Load the predicate as it is now.
-  $predicate = ca_load_predicate($pid);
-
-  // Load the action.
-  $action = ca_load_action($name);
-
-  // Abort if it did not exist.
-  if (empty($action)) {
-    return $predicate;
-  }
-
-  // Add the name to the action array so it's saved in the predicate.
-  $action['#name'] = $name;
-
-  // Add the action to the predicate's actions array.
-  $predicate['#actions'][] = $action;
-
-  // Save and return the updated predicate.
-  ca_save_predicate($predicate);
-
-  return $predicate;
-}
-
-/**
- * Remove an action from a predicate.
- *
- * @param $pid
- *   The ID of the predicate to remove the action from.
- * @param $index
- *   The index of the action to remove.
- * @return
- *   An array representing the full, updated predicate.
- */
-function ca_remove_action($pid, $index) {
-  $actions = array();
-
-  // Load the predicate as it is now.
-  $predicate = ca_load_predicate($pid);
-
-  // Build a new actions array, leaving out the one marked for removal.
-  foreach ($predicate['#actions'] as $key => $action) {
-    if ($key != $index) {
-      $actions[] = $action;
-    }
-  }
-
-  // Update, save, and return the predicate.
-  $predicate['#actions'] = $actions;
-  ca_save_predicate($predicate);
-
-  return $predicate;
-}
-
-/**
- * Load a predicate by its ID.
- *
- * @param $pid
- *   The ID of the predicate to load.
- * @return
- *   A fully loaded predicate array.
- */
-function ca_load_predicate($pid) {
-  $predicate = array();
-
-  // First attempt to load the predicate from the database.
-  $result = db_query("SELECT * FROM {ca_predicates} WHERE pid = :pid", array(':pid' => $pid));
-  if ($predicate = $result->fetchAssoc()) {
-    $predicate = ca_prepare_db_predicate($predicate);
-  }
-  else {
-    // Otherwise look for it in the module defined predicates.
-    $predicates = module_invoke_all('ca_predicate');
-
-    if (!empty($predicates[$pid])) {
-      $predicate = $predicates[$pid];
-    }
-  }
-
-  // Add the pid to the predicate so it can be resaved later.
-  if (!empty($predicate)) {
-    $predicate['#pid'] = $pid;
-  }
-
-  return $predicate;
-}
-
-/**
- * Save a predicate array to the database.
- *
- * @param $predicate
- *   A fully loaded predicate array.
- */
-function ca_save_predicate($predicate) {
-  db_merge('ca_predicates')
-    ->key(array('pid' => $predicate['#pid']))
-    ->fields(array(
-      'title' => (string) $predicate['#title'],
-      'description' => (string) $predicate['#description'],
-      'class' => (string) $predicate['#class'],
-      'status' => (int) $predicate['#status'],
-      'weight' => (int) $predicate['#weight'],
-      'uid' => (int) $predicate['#uid'],
-      'ca_trigger' => (string) $predicate['#trigger'],
-      'conditions' => serialize($predicate['#conditions']),
-      'actions' => serialize($predicate['#actions']),
-      'created' => REQUEST_TIME,
-      'modified' => REQUEST_TIME,
-    ))
-    ->updateExcept('created')
-    ->execute();
-}
-
-/**
- * Delete a predicate from the database.
- *
- * @param $pid
- *   The ID of the predicate to delete.
- */
-function ca_delete_predicate($pid) {
-  db_delete('ca_predicates')
-    ->condition('pid', $pid)
-    ->execute();
-}
-
-/**
- * Compare two conditional action arrays to sort them by #weight.
- */
-function ca_weight_sort($a, $b) {
-  if ($a['#weight'] == $b['#weight']) {
-    return 0;
-  }
-
-  return ($a['#weight'] > $b['#weight']) ? 1 : -1;
-}
-

=== modified file 'uc_roles/uc_roles.rules.inc'
--- uc_roles/uc_roles.rules.inc	2010-06-25 15:12:46 +0000
+++ uc_roles/uc_roles.rules.inc	2010-06-29 17:48:20 +0000
@@ -82,7 +82,7 @@
 function uc_roles_rules_action_info() {
   // Renew a role expiration.
   $actions['uc_roles_order_renew'] = array(
-    'lable' => t('Renew the roles on an order.'),
+    'label' => t('Renew the roles on an order.'),
     'group' => t('Renewal'),
     'base' => 'uc_roles_action_order_renew',
     'parameter' => array(

=== added file 'uc_store/includes/ca.inc'
--- uc_store/includes/ca.inc	1970-01-01 00:00:00 +0000
+++ uc_store/includes/ca.inc	2010-06-30 20:26:34 +0000
@@ -0,0 +1,536 @@
+<?php
+// $Id$
+
+/**
+ * Base helper function to convert CA predicates to Rules configurations.
+ */
+function ca_convert_predicate($predicate) {
+  // Convert event names to corresponding triggers.
+  if ($predicate->ca_trigger == 'calculate_taxes') {
+    return ca_extract_conditions($predicate, $predicate->pid);
+  }
+  elseif (strpos($predicate->ca_trigger, 'get_quote_from_') === 0) {
+    return ca_extract_conditions($predicate, $predicate->ca_trigger);
+  }
+
+  $rule = rules_reaction_rule();
+  if (is_numeric($predicate->pid)) {
+    $rule->name = $predicate->ca_trigger . '_' . $predicate->pid;
+  }
+  else {
+    $rule->name = $predicate->pid;
+  }
+  $rule->label = $predicate->title;
+  $rule->active = (bool) $predicate->status;
+  $rule->event($predicate->ca_trigger);
+
+  ca_add_conditions($rule, $predicate->conditions['#conditions']);
+  ca_add_actions($rule, $predicate->actions);
+
+  $rule->save();
+}
+
+/**
+ * Save the conditions of the predicate as a separate component.
+ *
+ * @param $predicate
+ *   An object row from {ca_predicates}.
+ * @param $name
+ *   The name to give the Rules component.
+ */
+function ca_extract_conditions($predicate, $name) {
+  $component = rules_and(array('order' => array('uc_order', 'label' => t('Order'))));
+  $component->name = $name;
+  $component->label = t('@title conditions', array('@title' => $predicate->title));
+
+  // CA predicates always have an AND at the root level.
+  ca_add_conditions($component, $predicate->conditions['#conditions']);
+
+  $component->save();
+}
+
+/**
+ * Read a predicate's conditions array and add them to a component.
+ *
+ * @param &$component
+ *   A RulesConditionContainer or a Rule to receive conditions.
+ * @param $conditions
+ *   A predicate's array of conditions.
+ */
+function ca_add_conditions(&$component, $conditions) {
+  foreach ($conditions as $condition) {
+    // Handle condition containers.
+    if (isset($condition['#conditions'])) {
+      switch ($condition['#operator']) {
+        case 'AND':
+          $sub_tree = rules_and();
+          break;
+        case 'OR':
+          $sub_tree = rules_or();
+          break;
+      }
+
+      // Recurse.
+      ca_add_conditions($sub_tree, $condition['#conditions']);
+
+      if ($sub_tree->getIterator()->hasChildren()) {
+        $component->condition($sub_tree);
+      }
+    }
+    // Handle individual conditions.
+    else {
+      // Handle certain conditions as a generic "data_is" condition.
+      $map = ca_data_map();
+      if (isset($map[$condition['#name']])) {
+        $name = 'data_is';
+      }
+      else {
+        $name = $condition['#name'];
+      }
+
+      $settings = array();
+      // The argument maps are like data selectors pointing to event variables.
+      foreach ($condition['#argument_map'] as $key => $value) {
+        if ($name == 'data_is') {
+          $settings['data:select'] = $map[$condition['#name']]['data'];
+        }
+        // Special case: parameter changed, but doesn't use 'data_is'.
+        elseif ($name == 'uc_attribute_ordered_product_option' && $key == 'order') {
+          $settings['product:select'] = $value;
+        }
+        else {
+          $key .= ':select';
+          $settings[$key] = $value;
+        }
+      }
+
+      $negate = FALSE;
+      foreach ($condition['#settings'] as $key => $value) {
+        // Save negation for later.
+        if ($key == 'negate') {
+          $negate = TRUE;
+          continue;
+        }
+
+        if ($condition['#name'] == 'ca_condition_date' && $key == 'date') {
+          $settings['date'] = $settings['date']['year'] . '/' . $settings['date']['month'] . '/'. $settings['date']['day'];
+        }
+        else {
+          $settings[$key] = $value;
+        }
+      }
+
+      if ($name == 'data_is') {
+        $settings['#info'] = $map[$condition['#name']]['#info'];
+
+        // data_is doesn't handle multiple values. Use a condition container.
+        if (count($settings[$map[$condition['#name']]['value']]) > 1) {
+          if (isset($map[$condition['#name']]['op']) && $settings[$map[$condition['#name']]['op']] == 'AND') {
+            $rules_condition = rules_and();
+          }
+          else {
+            $rules_condition = rules_or();
+          }
+
+          foreach ($settings[$map[$condition['#name']]['value']] as $value) {
+            $rules_condition->condition('data_is', array('data:select' => $settings['data:select'], 'op' => 'contains', 'value' => $value, '#info' => $settings['#info']));
+          }
+        }
+        elseif (is_array($settings[$map[$condition['#name']]['value']])) {
+          $rules_condition = rules_condition('data_is', array('data:select' => $settings['data:select'], 'op' => 'contains', 'value' => $settings[$map[$condition['#name']]['value']], '#info' => $settings['#info']));
+        }
+        else {
+          // Translate operator settings.
+          if (isset($map[$condition['#name']]['op'])) {
+            switch ($settings[$map[$condition['#name']]['op']]) {
+              case 'before':
+              case 'less':
+                $ops = '<';
+                break;
+              case 'less_equal':
+                $ops = array('<', '==');
+                break;
+              case 'only':
+              case 'equal':
+                $ops = '==';
+                break;
+              case 'not':
+                $negate = !$negate;
+                $settings['operator'] = '==';
+                break;
+              case 'after':
+              case 'greater':
+                $ops = '>';
+                break;
+              case 'greater_equal':
+                $ops = array('>', '==');
+                break;
+              case 'begins':
+              case 'contains':
+              case 'ends':
+                $settings['operator'] = 'contains';
+                break;
+              case 'yes':
+                $settings['operator'] = '==';
+                $settings['value'] = TRUE;
+                break;
+              case 'no':
+                $settings['operator'] = '==';
+                $settings['value'] = FALSE;
+                break;
+            }
+
+            if ($condition['#name'] == 'node_field_comparison') {
+              switch ($settings['field']) {
+                case 'nid':
+                case 'vid':
+                case 'uid':
+                  $type = 'integer';
+                  break;
+                case 'type':
+                case 'title':
+                  $type = 'text';
+                  break;
+                case 'status':
+                case 'promote':
+                case 'sticky':
+                  $type = 'boolean';
+                  break;
+              }
+
+              $settings = array(
+                'data:select' => array_shift($settings) . ':' . $settings['field'],
+                'op' => $settings['operator'],
+                'value' => $settings['value'],
+                '#info' => array(
+                  'parameter' => array(
+                    'value' => array(
+                      'type' => $type,
+                    ),
+                  ),
+                ),
+              );
+            }
+
+            // data_is only provides <, =, and > for numeric data. Use two
+            // separate conditions for <= and >= cases.
+            if (is_array($ops)) {
+              $data_condition = data_or();
+              foreach ($ops as $op) {
+                $data_condition->condition('data_is', array('data:select' => $settings['data:select'], 'op' => $op, 'value' => $settings[$map[$condition['#name']]['value']], '#info' => $settings['#info']));
+              }
+
+              $rules_condition = rules_condition($data_condition);
+            }
+            else {
+              $rules_condition = rules_condition('data_is', array('data:select' => $settings['data:select'], 'op' => $ops, 'value' => $settings[$map[$condition['#name']]['value']], '#info' => $settings['#info']));
+            }
+          }
+          // Standard data_is check that 'data' is equal to 'value'.
+          else {
+            $rules_condition = rules_condition('data_is', array('data:select' => $settings['data:select'], 'value' => $settings[$map[$condition['#name']]['value']], '#info' => $settings['#info']));
+          }
+        }
+      }
+      else {
+        if ($name == 'ca_condition_custom_php') {
+          $name = 'php_eval';
+          $settings = array('code' => $settings['php']);
+        }
+
+        $rules_condition = rules_condition($name, $settings);
+      }
+
+      if ($negate) {
+        $rules_condition->negate();
+      }
+
+      $component->condition($rules_condition);
+    }
+  }
+}
+
+/**
+ * Read a predicate's actions array and add them to a Rule.
+ *
+ * @param Rule &$rule
+ *   The configuration to receive actions.
+ * @param $actions
+ *   The predicate's actions array.
+ */
+function ca_add_actions(&$rule, $actions) {
+  foreach ($actions as $action) {
+    $settings = array();
+    // The argument maps are like data selectors pointing to event variables.
+    foreach ($action['#argument_map'] as $key => $value) {
+      $key .= ':select';
+      $settings[$key] = $value;
+    }
+
+    foreach ($action['#settings'] as $key => $value) {
+      $settings[$key] = $value;
+    }
+
+    switch ($action['#name']) {
+      case 'ca_drupal_set_message':
+        $name = 'drupal_message';
+        $settings = array(
+          'message' => $settings['message_text'],
+          'error' => $settings['message_type'] == 'error',
+        );
+        break;
+      case 'ca_action_custom_php':
+        $name = 'php_eval';
+        $settings = array('code' => $settings['php']);
+        break;
+      default:
+        $name = $action['#name'];
+        break;
+    }
+    $rule->action($name, $settings);
+  }
+}
+
+/**
+ * Map obsolete conditions to correct settings for 'data_is'.
+ */
+function ca_data_map() {
+  return array(
+    'ca_condition_date' => array(
+      'data' => 'system:date', // @todo: use the correct selector
+      'op' => 'operator',
+      'value' => 'date',
+      '#info' => array(
+        'parameter' => array(
+          'value' => array(
+            'type' => 'date',
+          ),
+        ),
+      ),
+    ),
+    'ca_condition_user_roles' => array(
+      'data' => 'user:roles',
+      'value' => 'roles',
+      'op' => 'operator',
+      '#info' => array(
+        'parameter' => array(
+          'value' => array(
+            'type' => 'list<integer>',
+            'options list' => 'entity_metadata_user_roles',
+          ),
+        ),
+      ),
+    ),
+    'node_field_comparison' => array(
+      'data' => '*',
+      'op' => 'operator',
+      'value' => 'value',
+      '#info' => array(
+        'parameter' => array(
+          'value' => array(
+            'type' => '*',
+          ),
+        ),
+      ),
+    ),
+    'uc_cart_condition_product_class' => array(
+      'data' => 'product:type',
+      'value' => 'class',
+      '#info' => array(
+        'parameter' => array(
+          'value' => array(
+            'type' => 'list<text>',
+            'options list' => 'node_type_get_names',
+          ),
+        ),
+      ),
+    ),
+    'uc_quote_condition_product_shipping_type' => array(
+      'data' => 'product:shipping-type',
+      'value' => 'type',
+      '#info' => array(
+        'parameter' => array(
+          'value' => array(
+            'type' => 'text',
+            'options list' => 'uc_quote_shipping_type_options',
+          ),
+        ),
+      ),
+    ),
+    'uc_order_condition_payment_method' => array(
+      'data' => 'order:payment-method',
+      'value' => 'payment_method',
+      '#info' => array(
+        'parameter' => array(
+          'value' => array(
+            'type' => 'text',
+          ),
+        ),
+      ),
+    ),
+    'uc_order_status_condition' => array(
+      'data' => 'order:order-status',
+      'value' => 'order_status',
+      '#info' => array(
+        'parameter' => array(
+          'value' => array(
+            'type' => 'text',
+            'options list' => 'uc_order_status_list',
+          ),
+        ),
+      ),
+    ),
+    'uc_order_condition_total' => array(
+      'data' => 'order:order-total',
+      'value' => 'order_total_value',
+      'op' => 'order_total_comparison',
+      '#info' => array(
+        'parameter' => array(
+          'value' => array(
+            'type' => 'decimal',
+          ),
+        ),
+      ),
+    ),
+    'uc_order_condition_delivery_postal_code' => array(
+      'data' => 'order:delivery-address:postal-code',
+      'value' => 'pattern',
+      '#info' => array(
+        'parameter' => array(
+          'value' => array(
+            'type' => 'text',
+          ),
+        ),
+      ),
+    ),
+    'uc_order_condition_delivery_zone' => array(
+      'data' => 'order:delivery-address:zone',
+      'value' => 'zones',
+      '#info' => array(
+        'parameter' => array(
+          'value' => array(
+            'type' => 'list<integer>',
+            'options list' => 'uc_zone_option_list',
+          ),
+        ),
+      ),
+    ),
+    'uc_order_condition_delivery_country' => array(
+      'data' => 'order:delivery-address:country',
+      'value' => 'countries',
+      '#info' => array(
+        'parameter' => array(
+          'value' => array(
+            'type' => 'list<integer>',
+            'options list' => 'uc_country_option_list',
+          ),
+        ),
+      ),
+    ),
+    'uc_order_condition_billing_postal_code' => array(
+      'data' => 'order:billing-address:postal-code',
+      'value' => 'pattern',
+      '#info' => array(
+        'parameter' => array(
+          'value' => array(
+            'type' => 'text',
+          ),
+        ),
+      ),
+    ),
+    'uc_order_condition_billing_zone' => array(
+      'data' => 'order:billing-address:zone',
+      'value' => 'zones',
+      '#info' => array(
+        'parameter' => array(
+          'value' => array(
+            'type' => 'list<integer>',
+            'options list' => 'uc_zone_option_list',
+          ),
+        ),
+      ),
+    ),
+    'uc_order_condition_billing_country' => array(
+      'data' => 'order:billing-address:country',
+      'value' => 'countries',
+      '#info' => array(
+        'parameter' => array(
+          'value' => array(
+            'type' => 'list<integer>',
+            'options list' => 'uc_country_option_list',
+          ),
+        ),
+      ),
+    ),
+    'uc_order_condition_user_name' => array(
+      'data' => 'user:name',
+      'value' => 'name',
+      '#info' => array(
+        'parameter' => array(
+          'value' => array(
+            'type' => 'text',
+          ),
+        ),
+      ),
+    ),
+    'uc_order_condition_user_email' => array(
+      'data' => 'user:mail',
+      'value' => 'mail',
+      '#info' => array(
+        'parameter' => array(
+          'value' => array(
+            'type' => 'text',
+          ),
+        ),
+      ),
+    ),
+    'uc_order_condition_user_created' => array(
+      'data' => 'user:created',
+      'value' => 'created',
+      'op' => 'operator',
+      '#info' => array(
+        'parameter' => array(
+          'value' => array(
+            'type' => 'date',
+          ),
+        ),
+      ),
+    ),
+    'uc_order_condition_user_login' => array(
+      'data' => 'user:login',
+      'value' => 'login',
+      'op' => 'operator',
+      '#info' => array(
+        'parameter' => array(
+          'value' => array(
+            'type' => 'date',
+          ),
+        ),
+      ),
+    ),
+    'uc_order_condition_user_language' => array(
+      'data' => 'user:language',
+      'value' => 'language',
+      '#info' => array(
+        'parameter' => array(
+          'value' => array(
+            'type' => 'text',
+          ),
+        ),
+      ),
+    ),
+    'uc_order_condition_user_roles' => array(
+      'data' => 'user:roles',
+      'value' => 'roles',
+      'op' => 'operator',
+      '#info' => array(
+        'parameter' => array(
+          'value' => array(
+            'type' => 'list<integer>',
+            'options list' => 'entity_metadata_user_roles',
+          ),
+        ),
+      ),
+    ),
+  );
+}

=== modified file 'uc_store/uc_store.install'
--- uc_store/uc_store.install	2010-04-01 18:42:54 +0000
+++ uc_store/uc_store.install	2010-06-28 19:00:11 +0000
@@ -157,3 +157,22 @@
   variable_del('uc_footer_message');
 }
 
+/**
+ * Convert Condtional Actions predicates to Rules configurations.
+ */
+function uc_store_update_7000() {
+  if (db_table_exists('ca_predicates')) {
+    module_load_include('inc', 'uc_store', 'includes/ca');
+
+    $predicates = db_query("SELECT * FROM {ca_predicates}");
+    foreach ($predicates as $predicate) {
+      $predicate->conditions = unserialize($predicate->conditions);
+      $predicate->actions = unserialize($predicate->actions);
+
+      ca_convert_predicate($predicate);
+    }
+
+    return t('Conditional actions predicates have been converted to Rules configurations. Review their settings to ensure that they will function as intend. <strong>IMPORTANT:</strong> Tokens in any conditions or actions will need to be updated.');
+  }
+}
+

=== modified file 'uc_taxes/uc_taxes.admin.inc'
--- uc_taxes/uc_taxes.admin.inc	2010-06-10 19:18:33 +0000
+++ uc_taxes/uc_taxes.admin.inc	2010-06-28 21:01:51 +0000
@@ -141,7 +141,9 @@
 
   if (module_exists('rules')) {
     $conditions = rules_config_load('uc_taxes_' . $rate->id);
-    $conditions->form($form, $form_state);
+    if ($conditions) {
+      $conditions->form($form, $form_state);
+    }
   }
 
   $form['submit'] = array(

