function _ip_login_set_user_range in IP Login 6.2
Same name and namespace in other branches
- 7.2 ip_login.module \_ip_login_set_user_range()
Sets the IP range match string for a user.
If $ip_range is NULL, any IP Login record for this user is removed. Otherwise a row is inserted or updated.
Parameters
$uid: The user ID
$ip_range: IP range match string
Return value
TRUE If an update occured sucessfully.
2 calls to _ip_login_set_user_range()
- ip_login_update_6200 in ./
ip_login.install - Drupal 6.x-1x to 2x (Profile field -> IP Login User table) update.
- ip_login_user in ./
ip_login.module - Implementation of hook_user().
File
- ./
ip_login.module, line 616 - Allow user login by IP addresses, ranges or wildcards.
Code
function _ip_login_set_user_range($uid, $ip_range = NULL) {
if (isset($uid) && is_numeric($uid)) {
if (is_null($ip_range) || empty($ip_range)) {
// null ip range = delete row
return db_query("DELETE FROM {ip_login_user} WHERE uid = %d", $uid);
}
else {
if (is_null(_ip_login_get_user_range($uid))) {
// no range presently = insert row
return db_query("INSERT INTO {ip_login_user} (`uid`, `ip_match`) VALUES (%d, '%s')", $uid, $ip_range);
}
else {
return db_query("UPDATE {ip_login_user} SET `ip_match` = '%s' WHERE `uid` = %d", $ip_range, $uid);
}
}
}
return FALSE;
}