From 96f2118a37e3ee63862925f7939fd3332f7cb487 Mon Sep 17 00:00:00 2001 From: "Michael J. Rubinsky" Date: Mon, 17 Jan 2011 16:26:36 -0500 Subject: [PATCH] allow the attributes filter to take an array of values to filter on. e.g., To return shares that have a slug of either $slug1 or $slug2: $shares->listShares($user, array('attributes' => array('slug' => arary($slug1, $slug2)))); --- framework/Share/lib/Horde/Share/Sql.php | 8 ++++++-- framework/Share/lib/Horde/Share/Sql/Hierarchical.php | 12 +++--------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/framework/Share/lib/Horde/Share/Sql.php b/framework/Share/lib/Horde/Share/Sql.php index 837a30d28..ab0bee353 100644 --- a/framework/Share/lib/Horde/Share/Sql.php +++ b/framework/Share/lib/Horde/Share/Sql.php @@ -359,7 +359,6 @@ class Horde_Share_Sql extends Horde_Share_Base 'sort_by' => null, 'direction' => 0), $params); - $key = md5(serialize(array($userid, $params))); if (!empty($this->_listcache[$key])) { return $this->_listcache[$key]; @@ -606,7 +605,12 @@ class Horde_Share_Sql extends Horde_Share_Base // Build attribute/key filter. $where = ' (' . $where . ') '; foreach ($attributes as $key => $value) { - $where .= ' AND ' . $key . ' = ' . $this->_db->quote($value); + if (is_array($value)) { + $value = array_map(array($this->_db, 'quote'), $value); + $where .= ' AND ' . $key . ' IN (' . implode(', ', $value) . ')'; + } else { + $where .= ' AND ' . $key . ' = ' . $this->_db->quote($value); + } } } elseif (!empty($attributes)) { // Restrict to shares owned by the user specified in the diff --git a/framework/Share/lib/Horde/Share/Sql/Hierarchical.php b/framework/Share/lib/Horde/Share/Sql/Hierarchical.php index eb39e9304..3cbcca93c 100644 --- a/framework/Share/lib/Horde/Share/Sql/Hierarchical.php +++ b/framework/Share/lib/Horde/Share/Sql/Hierarchical.php @@ -166,12 +166,6 @@ class Horde_Share_Sql_Hierarchical extends Horde_Share_Sql $attributes = null, $parent = null, $allLevels = true) { - if (is_object($parent)) { - $parent_id = $parent->getId(); - } else { - $parent_id = $parent; - } - $query = $where = ''; if (!is_null($perm)) { list($query, $where) = $this->_getUserAndGroupCriteria($userid, $perm); @@ -190,11 +184,11 @@ class Horde_Share_Sql_Hierarchical extends Horde_Share_Sql $where = ' (' . $where . ') '; } foreach ($attributes as $key => $value) { - $where .= ' AND ' . $key; if (is_array($value)) { - $where .= ' ' . $value[0]. ' ' . $this->_db->quote($value[1]); + $value = array_map(array($this->_db, 'quote'), $value); + $where .= ' AND ' . $key . ' IN (' . implode(', ', $value) . ')'; } else { - $where .= ' = ' . $this->_db->quote($value); + $where .= ' AND ' . $key . ' = ' . $this->_db->quote($value); } } } elseif (!empty($attributes)) { -- 2.11.0