aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/river.php
diff options
context:
space:
mode:
authorDanny Navarro <j@dannynavarro.net>2011-11-17 14:17:24 +0100
committercash <cash.costello@gmail.com>2011-11-23 11:58:08 -0500
commit583e52700ca5c7ed1d0dd58054dbd08208c0c158 (patch)
treeb7c0559f80b43e39a5233225289c024856403947 /engine/lib/river.php
parentddd7872bdfb68369d0e0e1b0401a8640b08bfc7c (diff)
downloadelgg-583e52700ca5c7ed1d0dd58054dbd08208c0c158.tar.gz
elgg-583e52700ca5c7ed1d0dd58054dbd08208c0c158.tar.bz2
Refs #3496 improving type/subtype handling for the river
Diffstat (limited to 'engine/lib/river.php')
-rw-r--r--engine/lib/river.php18
1 files changed, 13 insertions, 5 deletions
diff --git a/engine/lib/river.php b/engine/lib/river.php
index 309aeb30f..02d52dea1 100644
--- a/engine/lib/river.php
+++ b/engine/lib/river.php
@@ -447,7 +447,8 @@ function elgg_get_river_type_subtype_where_sql($table, $types, $subtypes, $pairs
return '';
}
- $wheres = array();
+ $types_wheres = array();
+ $subtypes_wheres = array();
// if no pairs, use types and subtypes
if (!is_array($pairs)) {
@@ -457,7 +458,7 @@ function elgg_get_river_type_subtype_where_sql($table, $types, $subtypes, $pairs
}
foreach ($types as $type) {
$type = sanitise_string($type);
- $wheres[] = "({$table}.type = '$type')";
+ $types_wheres[] = "({$table}.type = '$type')";
}
}
@@ -467,13 +468,20 @@ function elgg_get_river_type_subtype_where_sql($table, $types, $subtypes, $pairs
}
foreach ($subtypes as $subtype) {
$subtype = sanitise_string($subtype);
- $wheres[] = "({$table}.subtype = '$subtype')";
+ $subtypes_wheres[] = "({$table}.subtype = '$subtype')";
}
}
- if (is_array($wheres) && count($wheres)) {
- $wheres = array(implode(' OR ', $wheres));
+ if (is_array($types_wheres) && count($types_wheres)) {
+ $types_wheres = array(implode(' OR ', $types_wheres));
}
+
+ if (is_array($subtypes_wheres) && count($subtypes_wheres)) {
+ $subtypes_wheres = array(implode(' OR ', $subtypes_wheres));
+ }
+
+ $wheres = array(implode(' AND ', array_merge($types_wheres, $subtypes_wheres)));
+
} else {
// using type/subtype pairs
foreach ($pairs as $paired_type => $paired_subtypes) {