function _simpleads_ads_listing_query in SimpleAds 7
Helper function. Build query to get the list of ads for the Ads Listing page.
Parameters
array $filter:
Return value
query
1 call to _simpleads_ads_listing_query()
- _simpleads_listing in ./
simpleads.stat.inc - Callback for Ads Listing page.
File
- includes/
simpleads.helper.inc, line 390 - SimpleAds Helper functions.
Code
function _simpleads_ads_listing_query($filter = array()) {
if ($filter['adgroup'] == '') {
$query = db_select('node', 'n')
->extend('PagerDefault')
->limit($filter['adsperpage']);
$query
->fields('n', array(
'nid',
));
$query
->condition('n.type', 'simpleads');
if ($filter['adstatus'] != '') {
$query
->condition('n.status', $filter['adstatus']);
}
$results = $query
->execute();
}
else {
$query = db_select('node', 'n')
->extend('PagerDefault')
->limit($filter['adsperpage']);
$query
->leftJoin('taxonomy_index', 'ti', 'ti.nid = n.nid');
$query
->fields('n', array(
'nid',
));
$query
->addTag('node_access');
$query
->condition('n.type', 'simpleads');
if (isset($filter['adgroup'])) {
$query
->condition('ti.tid', $filter['adgroup']);
}
if ($filter['adstatus'] != '') {
$query
->condition('n.status', $filter['adstatus']);
}
$results = $query
->execute();
}
return $results;
}