function _adsense_choose_client in Google AdSense integration 5
1 call to _adsense_choose_client()
File
- ./
adsense.module, line 1564
Code
function _adsense_choose_client($uid) {
$revenue_enable = variable_get(ADSENSE_REVENUE_ENABLE, 0);
$percent_author = variable_get(ADSENSE_PERCENTAGE_AUTHOR, 0);
$percent_referral = variable_get(ADSENSE_PERCENTAGE_REFER, 0);
$site_client = _adsense_get_site_owner_client_id();
$author_client = _adsense_get_profile_client_id($uid);
$referral_client = _adsense_get_profile_client_id(_adsense_get_referral_uid($uid));
if (!$revenue_enable) {
return $site_client;
}
if (!$percent_author || !$author_client) {
return $site_client;
}
// Toss the dice and see who gets their ad displayed
$random = mt_rand(1, 100);
if ($random <= $percent_author) {
$client = $author_client;
}
elseif ($random <= $percent_author + $percent_referral) {
$client = $referral_client;
}
else {
$client = $site_client;
}
// Last check to see that we have a valid client
if (!$client) {
$client = $site_client;
}
return $client;
}