You are here

function userpoints_transaction_load in User Points 7

Same name and namespace in other branches
  1. 7.2 userpoints.module \userpoints_transaction_load()

Load a userpoints transaction.

Parameters

$txn_id: Userpoints transaction Id.

Return value

A loaded userpoints transaction object.

5 calls to userpoints_transaction_load()
MigrateDestinationUserpoints::rollback in ./userpoints.migrate.inc
Delete the provided userpoint transaction.
UserpointsAdminTestCase::testAddEditPoints in tests/userpoints_api.test
userpoints_menu_local_tasks_alter in ./userpoints.module
Implements hook_menu_local_tasks_alter().
userpoints_view_transaction in ./userpoints.pages.inc
Menu callback; display details about a specific transaction.
_userpoints_transaction in ./userpoints.module
Adds the points to the txn table.

File

./userpoints.module, line 1862

Code

function userpoints_transaction_load($txn_id) {
  if (!empty($txn_id)) {
    $transaction = db_query('SELECT * from {userpoints_txn} WHERE txn_id = :txn', array(
      ':txn' => $txn_id,
    ))
      ->fetchObject();
  }
  if (empty($transaction)) {
    return FALSE;
  }

  // Load corresponding user object.
  $transaction->user = user_load($transaction->uid);

  // Load category.
  $categories = userpoints_get_categories();
  $transaction->category = isset($categories[$transaction->tid]) ? $categories[$transaction->tid] : $categories[userpoints_get_default_tid()];
  return $transaction;
}