You are here

function userpoints_list_users in User Points 5

Same name and namespace in other branches
  1. 5.3 userpoints.module \userpoints_list_users()
  2. 5.2 userpoints.module \userpoints_list_users()
  3. 6 userpoints.module \userpoints_list_users()
  4. 7.2 userpoints.pages.inc \userpoints_list_users()
  5. 7 userpoints.pages.inc \userpoints_list_users()
1 string reference to 'userpoints_list_users'
userpoints_menu in ./userpoints.module
Implementation of hook_menu().

File

./userpoints.module, line 615

Code

function userpoints_list_users() {
  $sql = "SELECT p.uid, u.name, p.points\n    FROM {userpoints} p INNER JOIN {users} u USING (uid)";
  $sql_cnt = "SELECT COUNT(DISTINCT(uid)) FROM {userpoints}";
  $header = array(
    array(
      'data' => t('User'),
      'field' => 'u.name',
    ),
    array(
      'data' => t('!Points', userpoints_translation()),
      'field' => 'p.points',
      'sort' => 'desc',
    ),
  );
  $sql .= tablesort_sql($header);
  $result = pager_query($sql, 30, 0, $sql_cnt);
  while ($data = db_fetch_object($result)) {
    $rows[] = array(
      array(
        'data' => theme('username', $data),
      ),
      array(
        'data' => $data->points,
        'align' => 'right',
      ),
    );
  }
  $output = theme('table', $header, $rows);
  $output .= theme('pager', NULL, 30, 0);
  return $output;
}