You are here

function userpoints_get_transaction_row in User Points 7

Returns a single row for a transaction listing.

Parameters

$transaction: Transaction object.

$settings: Array with settings about which column shall be displayed. All settings default to TRUE.

  • show_category, show category column.
  • show_user, show user column.
  • show_status, show status column.

Return value

A table row array for use with theme_table().

2 calls to userpoints_get_transaction_row()
userpoints_admin_transactions in ./userpoints.admin.inc
Displays a list of transactions.
userpoints_list_transactions in ./userpoints.pages.inc
Displays a detailed transaction report for an individual user.

File

./userpoints.module, line 2007

Code

function userpoints_get_transaction_row($transaction, $settings = array()) {
  $settings += array(
    'show_user' => TRUE,
    'show_status' => TRUE,
  );
  $stati = userpoints_txn_status();
  $css_stati = array(
    USERPOINTS_TXN_STATUS_APPROVED => 'approved',
    USERPOINTS_TXN_STATUS_DECLINED => 'declined',
    USERPOINTS_TXN_STATUS_PENDING => 'pending',
  );
  $row = array(
    'class' => array(
      'userpoints-transaction-row-status-' . $css_stati[$transaction->status],
      'userpoints-transaction-row-category-' . $transaction->tid,
    ),
  );
  if ($settings['show_user']) {
    $row['data'][] = array(
      'data' => theme('username', array(
        'account' => user_load($transaction->uid),
      )),
      'class' => array(
        'userpoints-transactions-field-user',
      ),
    );
  }
  $row['data'][] = array(
    'data' => $transaction->points,
    'class' => array(
      'userpoints-transactions-field-points',
      'userpoints-transaction-points-' . ($transaction->points > 0 ? 'positive' : 'negative'),
    ),
  );
  $categories = userpoints_get_categories();
  if (count($categories) > 1) {
    $row['data'][] = array(
      'data' => isset($categories[$transaction->tid]) ? $categories[$transaction->tid] : $categories[0],
      'class' => array(
        'userpoints-transactions-field-category',
      ),
    );
  }
  $row['data'][] = array(
    'data' => format_date($transaction->time_stamp, 'small'),
    'class' => array(
      'userpoints-transactions-field-timestamp',
    ),
  );
  $row['data'][] = array(
    'data' => userpoints_create_description($transaction),
    'class' => array(
      'userpoints-transactions-field-reason',
    ),
  );
  if ($settings['show_status']) {
    $row['data'][] = array(
      'data' => $stati[$transaction->status],
      'class' => array(
        'userpoints-transactions-field-status',
      ),
    );
  }
  $row['data'][] = array(
    'data' => userpoints_get_transaction_actions($transaction),
    'class' => array(
      'userpoints-transactions-field-actions',
    ),
  );
  return $row;
}