ca_pull_trigger

Versions
6
ca_pull_trigger()

Pull a trigger and evaluate any predicates associated with that trigger.

Parameters

... 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 value

TRUE or FALSE indicating if at least one predicate was evaluated.

▾ 13 functions call ca_pull_trigger()

hook_line_item_alter in contributions/ubercart/docs/hooks.php
Alter a line item on an order when the order is loaded.
uc_cart_complete_sale in contributions/ubercart/uc_cart/uc_cart.module
Complete a sale, including adjusting order status and creating user account.
uc_file_action_order_renew in contributions/ubercart/uc_file/uc_file.ca.inc
Renew an orders product files.
uc_order_update_status in contributions/ubercart/uc_order/uc_order.module
Update an order's status as long as no one objects.
uc_order_view_update_form_submit in contributions/ubercart/uc_order/uc_order.order_pane.inc
See also uc_order_view_update_form()
uc_payment_enter in contributions/ubercart/payment/uc_payment/uc_payment.module
Enter a payment for an order.
uc_recurring_expire in contributions/uc_recurring/uc_recurring.module
Process a fee expiration.
uc_recurring_fee_cancel in contributions/uc_recurring/uc_recurring.module
Wrapper function to cancel a user's recurring fee.
uc_recurring_fee_cancel in contributions/uc_recurring/uc_recurring.module
Wrapper function to cancel a user's recurring fee.
uc_recurring_renew in contributions/uc_recurring/uc_recurring.module
Process a renewal, either from the cron job or manually from a fee handler.
uc_roles_action_order_renew in contributions/ubercart/uc_roles/uc_roles.ca.inc
Renew an orders product roles.
uc_roles_cron in contributions/ubercart/uc_roles/uc_roles.module
Implementation of hook_cron().
uc_shipping_shipment_save in contributions/ubercart/shipping/uc_shipping/uc_shipping.module
Save a shipment.

Code

contributions/ubercart/ca/ca.module, line 162

<?php
function ca_pull_trigger() {
  // Trigger actions can pull other triggers. Lock predicates when they are
  // marked for evaluation so they can't be evaluated again.
  static $locked;

  $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) {
    // Prevent the predicate from being evaluated if it already has been with
    // the same arguments.
    $key = $pid . serialize($arguments);
    if (!isset($locked[$key])) {
      // 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);
      }
    }
    $locked[$key] = TRUE;
  }

  return TRUE;
}
?>

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.