You are here

function user_stats_user_load in User Stats 5

Loads a user object. If possible this saves some memory and SQL overhead by only loading what's needed.

Parameters

$uid: User ID of the user to load.

Return value

Object representing the user.

4 calls to user_stats_user_load()
user_stats_comment in ./user_stats.module
Implementation of hook_comment().
user_stats_cron in ./user_stats.module
Implementation of hook_cron().
user_stats_nodeapi in ./user_stats.module
Implementation of hook_nodeapi().
_user_stats_user_cache in ./user_stats.module
User cache for optimisation, this needs to be a seperate function so cache can be flushed by user_stats_post_count_update below (and possibly other places).

File

./user_stats.module, line 892
User Stats provides commonly requested user statistics for themers. These are:

Code

function user_stats_user_load($uid) {
  if (module_exists('workflow_ng')) {

    // Workflow-ng requires a complete user object (with roles etc.)
    $user = user_load(array(
      'uid' => $uid,
    ));
  }
  else {
    $result = db_query('SELECT * FROM {users} u WHERE uid = %d', $uid);
    if (db_num_rows($result)) {
      $user = db_fetch_object($result);
      $user = drupal_unpack($user);
      profile_load_profile($user);
    }
    else {
      $user = FALSE;
    }
  }
  return $user;
}