function simplenews_build_subscription_filter_query in Simplenews 5
Same name and namespace in other branches
- 6.2 includes/simplenews.admin.inc \simplenews_build_subscription_filter_query()
- 6 simplenews.admin.inc \simplenews_build_subscription_filter_query()
- 7.2 includes/simplenews.admin.inc \simplenews_build_subscription_filter_query()
- 7 includes/simplenews.admin.inc \simplenews_build_subscription_filter_query()
Build query for subscription filters based on session var content.
Return value
array of SQL query parts array('where' => $where, 'join' => $join, 'args' => $args)
1 call to simplenews_build_subscription_filter_query()
File
- ./
simplenews.module, line 1810
Code
function simplenews_build_subscription_filter_query() {
// Variables $args and $join are currently not used but left in for future extensions
$where = $args = array();
$join = '';
// Build query
foreach ($_SESSION['simplenews_subscriptions_filter'] as $key => $value) {
switch ($key) {
case 'newsletter':
list($key, $value) = explode('-', $value, 2);
if ($key != 'all') {
$where[] = 's.' . $key . ' = ' . $value;
}
break;
case 'email':
if (!empty($value)) {
$where[] = 'ss.mail LIKE "%%' . db_escape_string($value) . '%%"';
}
break;
}
$args[] = $value;
}
// All conditions are combined with AND
$where = empty($where) ? '' : ' AND ' . implode(' AND ', $where);
return array(
'where' => $where,
'join' => $join,
'args' => $args,
);
}