function adserve_cache_id in Advertisement 7
Same name and namespace in other branches
- 5.2 adcache.inc \adserve_cache_id()
- 6.3 adcache.inc \adserve_cache_id()
- 6.2 adcache.inc \adserve_cache_id()
Default function for retrieving list of ids.
File
- ./
adcache.inc, line 215
Code
function adserve_cache_id($type, $id) {
_debug_echo("adserve_cache_id: type({$type}) id({$id})");
switch ($type) {
case 'nids':
$result = db_query("SELECT aid FROM {ads} WHERE adstatus = 'active' AND aid IN (:aid)", array(
':aid' => $id,
));
_debug_echo("adserve_cache_id: SELECT aid FROM {ads} WHERE adstatus = 'active' AND aid IN ({$id})");
break;
case 'tids':
$result = db_query("SELECT a.aid FROM {ads} a INNER JOIN {taxonomy_index} n ON a.aid = n.nid WHERE a.adstatus = 'active' AND n.tid IN (:tid)", array(
':tid' => $id,
));
_debug_echo("adserve_cache_id: SELECT a.aid FROM {ads} a INNER JOIN {taxonomy_index} n ON a.aid = n.nid WHERE a.adstatus = 'active' AND n.tid IN ({$id})");
break;
case 'default':
$result = db_query("SELECT a.aid FROM {ads} a LEFT JOIN {taxonomy_index} n ON a.aid = n.nid WHERE a.adstatus = 'active' AND n.tid IS NULL");
_debug_echo("adserve_cache_id: SELECT a.aid FROM {ads} a LEFT JOIN {taxonomy_index} n ON a.aid = n.nid WHERE a.adstatus = 'active' AND n.tid IS NULL");
break;
default:
_debug_echo("adserve_cache_id: unsupported type '{$type}'.");
}
$ids = array();
if (isset($result)) {
while ($ad = $result
->fetch()) {
// perform node access check
$node = node_load($ad->aid);
if (node_access('view', $node) !== FALSE) {
$ids[$ad->aid] = $ad->aid;
}
else {
_debug_echo("adserve_cache_id: Ad '{$ad->aid}' failed access check.");
}
}
}
return $ids;
}