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-28 21:44:01 -0500
commitd9e595ec0e44a4143c5e50eac8a8f83d66c03569 (patch)
treec404956b02170207c8f097291249c59673fbd0ce /engine/lib/river.php
parent09947a95e3fbd60d72203b487239ad305d2a529a (diff)
downloadelgg-d9e595ec0e44a4143c5e50eac8a8f83d66c03569.tar.gz
elgg-d9e595ec0e44a4143c5e50eac8a8f83d66c03569.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) {