function _referral_user_save in User Referral 6
Same name and namespace in other branches
- 5 referral.module \_referral_user_save()
- 7 referral.module \_referral_user_save()
1 call to _referral_user_save()
File
- ./
referral.module, line 167
Code
function _referral_user_save($uid) {
if (!isset($_COOKIE[REFERRAL_COOKIE])) {
return;
}
// Retrieve referral info from the cookie
$cookie = unserialize($_COOKIE[REFERRAL_COOKIE]);
if (empty($cookie)) {
// Nothing to do ...
return;
}
db_query("INSERT INTO {referral} (uid, referral_uid, created, host, http_referer) VALUES (%d, %d, %d, '%s', '%s')", $uid, $cookie['uid'], $cookie['timestamp'], $cookie['ip'], $cookie['referer']);
if (!db_affected_rows()) {
watchdog('referral', 'INSERT of referral data failed.', array(), WATCHDOG_ERROR);
return;
}
// Invoke other modules hooks ...
module_invoke_all('referral', $uid, $cookie['uid']);
}