diff options
author | icewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-03-12 15:01:23 +0000 |
---|---|---|
committer | icewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-03-12 15:01:23 +0000 |
commit | a530bcee3645c07c0ca50e478392122e53d7e1ec (patch) | |
tree | b6c80bd4dd280f46f495c7f65e50def99bedeb44 /engine/lib | |
parent | 686ecfb0289cf8cb7008a64fa3484de0eaba2eb1 (diff) | |
download | elgg-a530bcee3645c07c0ca50e478392122e53d7e1ec.tar.gz elgg-a530bcee3645c07c0ca50e478392122e53d7e1ec.tar.bz2 |
Marcus Povey <marcus@dushka.co.uk>
* Multiple searches.
git-svn-id: https://code.elgg.org/elgg/trunk@189 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib')
-rw-r--r-- | engine/lib/metadata.php | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/engine/lib/metadata.php b/engine/lib/metadata.php index dc657ec34..202ef60ad 100644 --- a/engine/lib/metadata.php +++ b/engine/lib/metadata.php @@ -242,6 +242,9 @@ * * @param int $entity_id * @param string $entity_type + * @param string $entity_subtype + * @param mixed $name Either a string or an array of terms. + * @param mixed $value Either a string or an array of terms. * @param int $owner_id * @param string $order_by * @param int $limit @@ -255,8 +258,15 @@ $entity_id = (int)$entity_id; $entity_type = sanitise_string(trim($entity_type)); $entity_subtype = sanitise_string($entity_subtype); - $name = sanitise_string(trim($name)); - $value = get_metastring_id($value); + + if (!is_array($name)) + $name = sanitise_string($name); + if (!is_array($value)) + $value = get_metastring_id($value); + + if ((is_array($name)) && (is_array($value)) && (count($name)!=count($value))) + throw new InvalidParameterException("Name and value arrays not equal."); + $value_type = sanitise_string(trim($value_type)); $owner_id = (int)$owner_id; $order_by = sanitise_string($order_by); @@ -278,10 +288,16 @@ if ($owner_id != 0) $where[] = "o.owner_id=$owner_id"; - if ($name != "") + if (is_array($name)) { + foreach ($name as $n) + $where[]= "o.name='$n'"; + } else if ($name != "") $where[] = "o.name='$name'"; - - if ($value != "") + + if (is_array($value)) { + foreach ($value as $v) + $where[]= "o.value='$v'"; + } else if ($value != "") $where[] = "o.value='$value'"; if ($value_type != "") @@ -314,6 +330,9 @@ * * @param int $entity_id * @param string $entity_type + * @param string $entity_subtype + * @param mixed $name Either a string or an array of terms. + * @param mixed $value Either a string or an array of terms. * @param int $owner_id * @param string $order_by * @param int $limit |