You are here

function _referral_user_save in User Referral 6

Same name and namespace in other branches
  1. 5 referral.module \_referral_user_save()
  2. 7 referral.module \_referral_user_save()
1 call to _referral_user_save()
referral_user in ./referral.module

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']);
}