You are here

function UserpointsTransaction::getTableRow in User Points 7.2

Returns a single row for a transaction listing.

Parameters

$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().

File

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

Class

UserpointsTransaction
A Userpoints transaction.

Code

function getTableRow($settings = array()) {
  $settings += array(
    'show_user' => TRUE,
    'show_status' => TRUE,
  );
  $stati = userpoints_txn_status();
  $css_stati = array(
    UserpointsTransaction::STATUS_APPROVED => 'approved',
    UserpointsTransaction::STATUS_DECLINED => 'declined',
    UserpointsTransaction::STATUS_PENDING => 'pending',
  );
  $row = array(
    'class' => array(
      'userpoints-transaction-row-status-' . $css_stati[$this
        ->getStatus()],
      'userpoints-transaction-row-category-' . $this
        ->getTid(),
    ),
  );
  if ($settings['show_user']) {
    $row['data'][] = array(
      'data' => theme('username', array(
        'account' => $this
          ->getUser(),
      )),
      'class' => array(
        'userpoints-transactions-field-user',
      ),
    );
  }
  $row['data'][] = array(
    'data' => theme('userpoints_points', array(
      'points' => $this
        ->getPoints(),
    )),
    'class' => array(
      'userpoints-transactions-field-points',
      'userpoints-transaction-points-' . ($this
        ->getPoints() > 0 ? 'positive' : 'negative'),
    ),
  );
  $categories = userpoints_get_categories();
  if (count($categories) > 1) {
    $row['data'][] = array(
      'data' => $this
        ->getCategory(),
      'class' => array(
        'userpoints-transactions-field-category',
      ),
    );
  }
  $row['data'][] = array(
    'data' => format_date($this
      ->getTimestamp(), 'small'),
    'class' => array(
      'userpoints-transactions-field-timestamp',
    ),
  );
  $row['data'][] = array(
    'data' => $this
      ->getReason(),
    'class' => array(
      'userpoints-transactions-field-reason',
    ),
  );
  if ($settings['show_status']) {
    $row['data'][] = array(
      'data' => $stati[$this
        ->getStatus()],
      'class' => array(
        'userpoints-transactions-field-status',
      ),
    );
  }
  $row['data'][] = array(
    'data' => $this
      ->getActions(),
    'class' => array(
      'userpoints-transactions-field-actions',
    ),
  );
  return $row;
}