You are here

function UserpointsTransaction::setStatus in User Points 7.2

Set the status for a transaction.

There are helper functions available to set the status of a transaction to a specific status, e. g. UserpointsTransaction::pending(). It is recommended to use these instead.

Parameters

$status: One of the following constants: UserpointsTransaction::STATUS_APPROVED, UserpointsTransaction::STATUS_DECLINED, UserpointsTransaction::STATUS_PENDING.

Return value

UserpointsTransaction

See also

UserpointsTransaction::pending()

UserpointsTransaction::approve()

UserpointsTransaction::decline()

3 calls to UserpointsTransaction::setStatus()
UserpointsTransaction::approve in ./userpoints.transaction.inc
Mark this transaction as approved.
UserpointsTransaction::decline in ./userpoints.transaction.inc
Mark this transaction as declined.
UserpointsTransaction::pending in ./userpoints.transaction.inc
Mark this transaction as pending.

File

./userpoints.transaction.inc, line 255
Contains the UserpointsTransaction and related classes.

Class

UserpointsTransaction
A Userpoints transaction.

Code

function setStatus($status) {
  $this
    ->checkChange();

  // Check allowed values.
  if (!in_array($status, array(
    UserpointsTransaction::STATUS_APPROVED,
    UserpointsTransaction::STATUS_DECLINED,
    UserpointsTransaction::STATUS_PENDING,
  ))) {
    $this
      ->abort();
    throw new UserpointsChangeException(t('Invalid status'));
  }
  if ($this->txn_id > 0) {

    // Preserve the original status to be able to check if changes in this
    // transaction are still allowed.
    $this->orig_status = $this
      ->getStatus();
  }
  $this->status = $status;
  return $this;
}