You are here

function userpoints_service_index in User Points 7

Same name and namespace in other branches
  1. 7.2 userpoints_service/userpoints_service.inc \userpoints_service_index()

Return an array of paged userpoints list.

Parameters

$page: Page number of results to return (in pages of 20).

Return value

An array of userpoints objects.

1 string reference to 'userpoints_service_index'
userpoints_service_services_resources in ./userpoints_service.module
Implementation of hook_services_resources().

File

./userpoints_service.inc, line 26
Callbacks and access callbacks for userpoints services integration.

Code

function userpoints_service_index($page, $tid, $sort, $dir) {
  if (!in_array($sort, array(
    'points',
    'uid',
    'last_updated',
    'max_points',
  ))) {
    $sort = 'points';
  }
  if (strtoupper($dir) != 'ASC') {
    $dir = 'DESC';
  }
  $select = db_select('userpoints', 't')
    ->orderBy($sort, $dir);
  if ($tid != 'all') {
    if ($tid === NULL) {
      $tid = userpoints_get_default_tid();
    }
    $select
      ->condition('tid', $tid);
  }
  services_resource_build_index_query($select, $page, 'uid, points, max_points', array(), 20);
  $results = $select
    ->execute();
  return services_resource_build_index_list($results, 'userpoints', 'uid');
}