You are here

function userpoints_get_transaction_header in User Points 7

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

Returns a table header 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

Table header definition for theme_table() and TableSort.

2 calls to userpoints_get_transaction_header()
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 1929

Code

function userpoints_get_transaction_header($settings) {
  $settings += array(
    'show_category' => count(userpoints_get_categories()) > 1,
    'show_user' => TRUE,
    'show_status' => TRUE,
  );
  $header = array();
  if ($settings['show_user']) {
    $header[] = array(
      'data' => t('User'),
      'field' => 'uid',
      'class' => array(
        'userpoints-transactions-header-status',
      ),
    );
  }
  $header[] = array(
    'data' => t('!Points', userpoints_translation()),
    'field' => 'points',
    'class' => array(
      'userpoints-transactions-header-points',
    ),
  );

  // Only display category if there is more than one category. In contrast to
  // the filter, this is not specific for the categories. If there are
  // categories, we want tell the user in which he has points, even if he
  // only has points in a single category.
  if ($settings['show_category']) {
    $header[] = array(
      'data' => t('Category'),
      'field' => 't.name',
      'class' => array(
        'userpoints-transactions-header-category',
      ),
    );
  }
  $header[] = array(
    'data' => t('Date'),
    'field' => 'time_stamp',
    'sort' => 'desc',
    'class' => array(
      'userpoints-transactions-header-timestamp',
    ),
  );
  $header[] = array(
    'data' => t('Reason'),
    'class' => array(
      'userpoints-transactions-header-reason',
    ),
  );
  if ($settings['show_status']) {
    $header[] = array(
      'data' => t('Status'),
      'field' => 'status',
      'class' => array(
        'userpoints-transactions-header-status',
      ),
    );
  }
  $header[] = array(
    'data' => t('Actions'),
    'class' => array(
      'userpoints-transactions-header-actions',
    ),
  );
  return $header;
}