function mongodb_watchdog_build_filter_query in MongoDB 7
Same name and namespace in other branches
- 6 mongodb_watchdog/mongodb_watchdog.admin.inc \mongodb_watchdog_build_filter_query()
Build a MongoDB query based on the selected filters.
Mongo Issue regarding the $in value
Mongo Issue regarding numeric keys on objects
Return value
array An array to build a MongoDB query.
File
- mongodb_watchdog/
mongodb_watchdog.admin.inc, line 472 - Settings for mongodb. Moved back to module file.
Code
function mongodb_watchdog_build_filter_query() {
if (empty($_SESSION['mongodb_watchdog_overview_filter'])) {
return array();
}
// Build query.
$types = $_SESSION['mongodb_watchdog_overview_filter']['type'] ? $_SESSION['mongodb_watchdog_overview_filter']['type'] : NULL;
$severities = $_SESSION['mongodb_watchdog_overview_filter']['severity'] ? $_SESSION['mongodb_watchdog_overview_filter']['severity'] : NULL;
$find = array();
if ($types) {
$find['type'] = array(
'$in' => array_values($types),
);
}
if ($severities) {
// MongoDB is picky about types, ensure the severities are all integers.
$find['severity'] = array(
'$in' => array_values(array_map('intval', $severities)),
);
}
return $find;
}