You are here

function pay_transaction::valid_action in Pay 7

Same name and namespace in other branches
  1. 6 includes/handlers/pay_transaction.inc \pay_transaction::valid_action()

Determine whether an action is valid and appropriate for this transaction.

2 calls to pay_transaction::valid_action()
pay_transaction::available_actions in includes/handlers/pay_transaction.inc
Return an array of actions that are available for this transaction in its current state.
pay_transaction::do_action in includes/handlers/pay_transaction.inc
Perform an action on this transaction.

File

includes/handlers/pay_transaction.inc, line 162
A base class for payment transactions.

Class

pay_transaction
@file A base class for payment transactions.

Code

function valid_action($action) {
  $valid = TRUE;

  // Special-case 'delete' pseudo-action.
  if ($action == 'delete') {
    return user_access('administer pay');
  }

  // Is it defined in our list of valid_actions?
  if (!($info = $this
    ->valid_actions($action))) {
    return FALSE;
  }

  // Is the current workflow state compatible with this action?
  if (!in_array($this
    ->state(), $info['valid states'])) {
    return FALSE;
  }

  // Query each payment method in this transaction's history for validity.
  foreach ($this
    ->pay_method_activities() as $pmid => $history) {
    $pay_method = pay_method_load($pmid);
    if (!method_exists($pay_method, $info['callback'])) {
      $valid = FALSE;
    }
    $valid = $valid && $pay_method
      ->valid_action($action, $this, $history);
  }
  return $valid;
}