function ad_weight_probability_ad_build_cache in Advertisement 5.2
Same name and namespace in other branches
- 6.3 weight/probability/ad_weight_probability.module \ad_weight_probability_ad_build_cache()
- 6.2 weight/probability/ad_weight_probability.module \ad_weight_probability_ad_build_cache()
- 7 weight/probability/ad_weight_probability.module \ad_weight_probability_ad_build_cache()
Implementation of hook_ad_build_cache().
File
- weight/
probability/ ad_weight_probability.module, line 67 - A plug in for the ad.module, allowing an admin to set the probability that a given advertisement will be displayed.
Code
function ad_weight_probability_ad_build_cache() {
$cache = array();
$active = db_query("SELECT a.aid, p.probability FROM {ads} a LEFT JOIN {ad_weight_probability} p ON a.aid = p.aid WHERE adstatus = 'active'");
while ($ad = db_fetch_object($active)) {
$probability = $ad->probability ? $ad->probability : AD_PROBABILITY_DEFAULT;
$ads[$ad->aid] = $probability;
}
$cache['weight']['probability'] = $ads;
$cache['weight']['hook_weight'] = array(
'weight' => 10,
'file' => drupal_get_path('module', 'ad_weight_probability') . '/ad_weight_probability.inc',
'function' => 'ad_weight_probability_cache_filter',
);
return $cache;
}