function userpoints_list_users in User Points 7.2
Same name and namespace in other branches
- 5.3 userpoints.module \userpoints_list_users()
- 5 userpoints.module \userpoints_list_users()
- 5.2 userpoints.module \userpoints_list_users()
- 6 userpoints.module \userpoints_list_users()
- 7 userpoints.pages.inc \userpoints_list_users()
Lists the users and their point totals by all or by category.
1 string reference to 'userpoints_list_users'
- userpoints_menu in ./
userpoints.module - Implements hook_menu().
File
- ./
userpoints.pages.inc, line 145 - Menu callbacks for userpoints.module.
Code
function userpoints_list_users($form, &$form_state, $tid = NULL) {
// If this is an AJAX request, update $_GET['q'] so that table sorting and
// similar links are using the correct base path.
if ($_GET['q'] == 'system/ajax') {
$_GET['q'] = 'userpoints';
}
$header = userpoints_get_list_header();
$query = db_select('userpoints', 'p')
->extend('PagerDefault')
->extend('TableSort')
->fields('p', array(
'uid',
'points',
'tid',
))
->fields('u', array(
'name',
))
->groupBy('p.uid')
->groupBy('u.name')
->groupBy('p.points')
->groupBy('p.tid')
->orderByHeader($header)
->limit(variable_get(USERPOINTS_REPORT_USERCOUNT, 30));
$query
->join('users', 'u', 'p.uid = u.uid');
if (module_exists('taxonomy')) {
$query
->groupBy('t.name');
$query
->leftJoin('taxonomy_term_data', 't', 'p.tid = t.tid');
}
$values = userpoints_filter_parse_input($form_state, $tid);
$active_category = userpoints_filter_query($query, $values);
if (isset($active_category)) {
drupal_set_title(t('All points (%category category)', userpoints_translation() + array(
'%category' => $active_category,
)), PASS_THROUGH);
}
else {
drupal_set_title(t('All points'));
}
if (variable_get(USERPOINTS_REPORT_DISPLAYZERO, 1) == 0) {
// The user would NOT like to see users with zero points.
$query
->condition('p.points', 0, '<>');
}
$rows = array();
foreach ($query
->execute() as $data) {
$rows[] = userpoints_get_list_row($data);
}
$output = array();
$output['form'] = userpoints_filter_form(NULL, $values);
$output['list'] = array(
'#type' => 'container',
'#id' => 'userpoints_list_wrapper',
);
$output['list']['table'] = array(
'#theme' => 'table',
'#header' => $header,
'#rows' => $rows,
);
$output['list']['pager'] = array(
'#theme' => 'pager',
);
// Allow other modules and themes to customize the result.
drupal_alter('userpoints_list', $output);
return $output;
}