function heartbeat_api_most_active_users in Heartbeat 7
API function to retrieve the most active users.
Parameters
String $language: The language for the activity.
Integer $count: The count number / limit.
1 call to heartbeat_api_most_active_users()
- heartbeat_block_view in ./
heartbeat.module - Implements hook_block_view().
File
- ./
heartbeat.module, line 813 - Module file for heartbeat activity. Basic hook implementations and helper functions will be found here.
Code
function heartbeat_api_most_active_users($view_mode, $count = 5, $language = NULL) {
/*if (!isset($language)) {
$language = $GLOBALS['language']->language;
}*/
$uids = array();
$result = db_query_range("SELECT uid, COUNT(uaid) AS 'count' FROM {heartbeat_activity} WHERE uid > 0 GROUP BY uid ORDER BY count DESC ", 0, $count);
foreach ($result as $row) {
$uids[$row->uid] = $row->count;
}
$accounts = user_load_multiple(array_keys($uids));
$users = array();
foreach ($accounts as $account) {
$users[$account->uid . '_' . $uids[$account->uid]] = user_view($account, $view_mode, $language);
}
return $users;
}