You are here

function ca_load_predicate in Ubercart 6.2

Load a predicate by its ID.

Parameters

$pid: The ID of the predicate to load.

Return value

A fully loaded predicate array.

14 calls to ca_load_predicate()
ca_actions_form in ca/ca.admin.inc
Build a form for adding and editing actions on a predicate.
ca_actions_form_update_actions in ca/ca.admin.inc
Updates a predicate's actions based on the values from an actions form.
ca_add_action in ca/ca.module
Add a new action to a predicate.
ca_add_condition in ca/ca.module
Add a new condition to a predicate.
ca_add_condition_group in ca/ca.module
Add a new condition group to a predicate.

... See full list

File

ca/ca.module, line 960
This is a demonstration module for the new conditional actions API.

Code

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 = '%s'", $pid);
  if ($predicate = db_fetch_array($result)) {
    $predicate = ca_prepare_db_predicate($predicate);
  }
  else {

    // Otherwise look for it in the module defined predicates.
    $predicates = module_invoke_all('ca_predicate');
    drupal_alter('ca_predicate', $predicates);
    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;
}