You are here

function user_stats_ip_address_update in User Stats 5

Same name and namespace in other branches
  1. 6 user_stats.module \user_stats_ip_address_update()
  2. 7 user_stats.module \user_stats_ip_address_update()

Manage the IP address of a given user.

Parameters

$user: User object whos IP address we are going to update.

$ip_address: IP address to assign to user.

3 calls to user_stats_ip_address_update()
user_stats_comment in ./user_stats.module
Implementation of hook_comment().
user_stats_nodeapi in ./user_stats.module
Implementation of hook_nodeapi().
user_stats_user in ./user_stats.module
Implementation of hook_user().

File

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

Code

function user_stats_ip_address_update(&$user, $ip_address) {
  profile_load_profile($user);
  if (isset($user->user_ip_address)) {
    $sql = "UPDATE {profile_values} SET value='%s' WHERE fid =\n      (SELECT fid FROM {profile_fields} WHERE name = 'user_ip_address')\n      AND uid=%d";
  }
  else {
    $sql = "INSERT INTO {profile_values} (fid, value, uid)\n      SELECT fid, '%s' AS value, %d AS uid FROM {profile_fields}\n      WHERE name='user_ip_address'";
  }
  db_query($sql, $ip_address, $user->uid);
}