From: Michael J. Rubinsky Date: Sun, 12 Dec 2010 03:26:15 +0000 (-0500) Subject: Need to check for blob_fields when returning search results too. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=4539100250a07d6b874de831f68466bdff1f3550;p=horde.git Need to check for blob_fields when returning search results too. Fixes activesync not being able to display contact photos sent from server. --- diff --git a/turba/lib/Driver.php b/turba/lib/Driver.php index 0c9c34510..67486d867 100644 --- a/turba/lib/Driver.php +++ b/turba/lib/Driver.php @@ -528,7 +528,7 @@ class Turba_Driver implements Countable } /* Retrieve the search results from the driver. */ - $objects = $this->_search($fields, $return_fields); + $objects = $this->_search($fields, $return_fields, $this->toDriverKeys($this->getBlobs())); return $this->_toTurbaObjects($objects, $sort_order); } @@ -2686,7 +2686,7 @@ class Turba_Driver implements Countable * @return array Hash containing the search results. * @throws Turba_Exception */ - protected function _search($criteria, $fields) + protected function _search($criteria, $fields, $blobFields = array()) { throw new Turba_Exception(_("Searching is not available.")); } @@ -2702,7 +2702,7 @@ class Turba_Driver implements Countable * @return array Hash containing the search results. * @throws Turba_Exception */ - protected function _read($key, $ids, $owner, $fields) + protected function _read($key, $ids, $owner, $fields, $blobFields = array()) { throw new Turba_Exception(_("Reading contacts is not available.")); } diff --git a/turba/lib/Driver/Facebook.php b/turba/lib/Driver/Facebook.php index d6f1f616f..6e2af8202 100644 --- a/turba/lib/Driver/Facebook.php +++ b/turba/lib/Driver/Facebook.php @@ -57,7 +57,7 @@ class Turba_Driver_Facebook extends Turba_Driver * @return array Hash containing the search results. * @throws Turba_Exception */ - protected function _search($criteria, $fields) + protected function _search($criteria, $fields, $blobFields = array()) { $results = $this->_getAddressBook($fields); diff --git a/turba/lib/Driver/Favourites.php b/turba/lib/Driver/Favourites.php index 6a8f47c0e..2468cf109 100644 --- a/turba/lib/Driver/Favourites.php +++ b/turba/lib/Driver/Favourites.php @@ -46,7 +46,7 @@ class Turba_Driver_Favourites extends Turba_Driver * @return array Hash containing the search results. * @throws Turba_Exception */ - protected function _search($criteria, $fields) + protected function _search($criteria, $fields, $blobFields = array()) { $results = array(); diff --git a/turba/lib/Driver/Group.php b/turba/lib/Driver/Group.php index ff6d091d1..fb8021b8a 100644 --- a/turba/lib/Driver/Group.php +++ b/turba/lib/Driver/Group.php @@ -60,7 +60,7 @@ class Turba_Driver_Group extends Turba_Driver * @return array Hash containing the search results. * @throws Turba_Exception */ - protected function _search($criteria, $fields) + protected function _search($criteria, $fields, $blobFields = array()) { $results = array(); diff --git a/turba/lib/Driver/Imsp.php b/turba/lib/Driver/Imsp.php index f1d1b4aec..ad8bfafe2 100644 --- a/turba/lib/Driver/Imsp.php +++ b/turba/lib/Driver/Imsp.php @@ -118,7 +118,7 @@ class Turba_Driver_Imsp extends Turba_Driver * * @return array Hash containing the search results. */ - protected function _search($criteria, $fields) + protected function _search($criteria, $fields, $blobFields = array()) { $query = $results = array(); diff --git a/turba/lib/Driver/Kolab.php b/turba/lib/Driver/Kolab.php index f58bf2f15..9acc76f33 100644 --- a/turba/lib/Driver/Kolab.php +++ b/turba/lib/Driver/Kolab.php @@ -61,7 +61,7 @@ class Turba_Driver_Kolab extends Turba_Driver * * @return Hash containing the search results. */ - protected function _search($criteria, $fields) + protected function _search($criteria, $fields, $blobFields = array()) { return $this->_wrapper->_search($criteria, $fields); } diff --git a/turba/lib/Driver/Ldap.php b/turba/lib/Driver/Ldap.php index 600f817f4..8b9d7e62b 100644 --- a/turba/lib/Driver/Ldap.php +++ b/turba/lib/Driver/Ldap.php @@ -147,7 +147,7 @@ class Turba_Driver_Ldap extends Turba_Driver * @return array Hash containing the search results. * @throws Turba_Exception */ - protected function _search($criteria, $fields) + protected function _search($criteria, $fields, $blobFields = array()) { /* Build the LDAP filter. */ $filter = ''; diff --git a/turba/lib/Driver/Prefs.php b/turba/lib/Driver/Prefs.php index 2879c8f37..670999aa3 100644 --- a/turba/lib/Driver/Prefs.php +++ b/turba/lib/Driver/Prefs.php @@ -24,7 +24,7 @@ class Turba_Driver_Prefs extends Turba_Driver * * @return array Hash containing the search results. */ - protected function _search($criteria, $fields) + protected function _search($criteria, $fields, $blobFields = array()) { return array_values($this->_getAddressBook()); } diff --git a/turba/lib/Driver/Share.php b/turba/lib/Driver/Share.php index bf3f8d35d..4bba41223 100644 --- a/turba/lib/Driver/Share.php +++ b/turba/lib/Driver/Share.php @@ -104,9 +104,9 @@ class Turba_Driver_Share extends Turba_Driver * @return array Hash containing the search results. * @throws Turba_Exception */ - protected function _search($criteria, $fields) + protected function _search($criteria, $fields, $blobFields = array()) { - return $this->_driver->_search($criteria, $fields); + return $this->_driver->_search($criteria, $fields, $blobFields); } /** diff --git a/turba/lib/Driver/Sql.php b/turba/lib/Driver/Sql.php index ee3ea661d..0ee20e6da 100644 --- a/turba/lib/Driver/Sql.php +++ b/turba/lib/Driver/Sql.php @@ -91,6 +91,7 @@ class Turba_Driver_Sql extends Turba_Driver * * @param array $criteria Array containing the search criteria. * @param array $fields List of fields to return. + * @param array $blobFields * @param array $appendWhere An additional where clause to append. * Array should contain 'sql' and 'params' * params are used as bind parameters. @@ -98,7 +99,7 @@ class Turba_Driver_Sql extends Turba_Driver * @return array Hash containing the search results. * @throws Turba_Exception */ - protected function _search($criteria, $fields, $appendWhere = array()) + protected function _search($criteria, $fields, $blobFields = array(), $appendWhere = array()) { /* Build the WHERE clause. */ $where = ''; @@ -151,12 +152,23 @@ class Turba_Driver_Sql extends Turba_Driver throw new Turba_Exception($row); } - $row = $this->_convertFromDriver($row); - $entry = array(); for ($i = 0; $i < $iMax; $i++) { $field = $fields[$i]; - $entry[$field] = $row[$i]; + if (isset($blobFields[$field])) { + switch ($this->_db->dbsyntax) { + case 'pgsql': + case 'mssql': + $entry[$field] = pack('H' . strlen($row[$i]), $row[$i]); + break; + + default: + $entry[$field] = $row[$i]; + break; + } + } else { + $entry[$field] = $this->_convertFromDriver($row[$i]); + } } $results[] = $entry; } @@ -750,7 +762,7 @@ class Turba_Driver_Sql extends Turba_Driver } } - return $this->_toTurbaObjects($this->_search($criteria, $fields, $where)); + return $this->_toTurbaObjects($this->_search($criteria, $fields, array(), $where)); } } diff --git a/turba/lib/Driver/Vbook.php b/turba/lib/Driver/Vbook.php index 437e6ad97..5b679a290 100644 --- a/turba/lib/Driver/Vbook.php +++ b/turba/lib/Driver/Vbook.php @@ -68,14 +68,14 @@ class Turba_Driver_Vbook extends Turba_Driver * @return array Hash containing the search results. * @throws Turba_Exception */ - protected function _search($criteria, $fields) + protected function _search($criteria, $fields, $blobFields = array()) { /* Add the passed in search criteria to the vbook criteria * (which need to be mapped from turba fields to * driver-specific fields). */ $criteria['AND'][] = $this->makeSearch($this->searchCriteria, 'AND', array()); - return $this->_driver->_search($criteria, $fields); + return $this->_driver->_search($criteria, $fields, $blobFields); } /**