From f412d41a9bf95ab2386382a9e6330383418ad1a1 Mon Sep 17 00:00:00 2001 From: babelouest Date: Mon, 10 Feb 2014 15:16:43 -0500 Subject: [PATCH] apparently it works -ish --- lib/backend/database.php | 2 ++ lib/backend/ldap.php | 29 +++++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/lib/backend/database.php b/lib/backend/database.php index 29afaed2..30a9e278 100644 --- a/lib/backend/database.php +++ b/lib/backend/database.php @@ -496,6 +496,7 @@ class Database extends AbstractBackend { * @return string|bool The identifier for the new contact or false on error. */ public function createContact($addressbookid, $contact, array $options = array()) { + error_log("db create power ! $addressbookid - " . $contact->serialize()); $qname = 'createcontact'; $uri = isset($options['uri']) ? $options['uri'] : null; @@ -570,6 +571,7 @@ class Database extends AbstractBackend { * @return bool */ public function updateContact($addressbookid, $id, $contact, array $options = array()) { + error_log("db update power ! $addressbookid, $id - " . $contact->serialize()); $noCollection = isset($options['noCollection']) ? $options['noCollection'] : false; $isBatch = isset($options['isBatch']) ? $options['isBatch'] : false; $qname = 'updatecontact'; diff --git a/lib/backend/ldap.php b/lib/backend/ldap.php index 89c402d3..b093ae69 100644 --- a/lib/backend/ldap.php +++ b/lib/backend/ldap.php @@ -533,6 +533,7 @@ class Ldap extends AbstractBackend { * @return string|bool The identifier for the new contact or false on error. */ public function createContact($addressbookid, $contact, array $options = array()) { + error_log("access create"+$this->debug_string_backtrace()); $uri = isset($options['uri']) ? $options['uri'] : null; @@ -584,8 +585,16 @@ class Ldap extends AbstractBackend { * @return bool */ public function updateContact($addressbookid, $id, $carddata, array $options = array()) { - error_log("goat power ! $addressbookid, $id, $carddata"); - $vcard = \Sabre\VObject\Reader::read($carddata); + if(!$carddata instanceof VCard) { + try { + $vcard = \Sabre\VObject\Reader::read($carddata->serialize()); + } catch(\Exception $e) { + \OCP\Util::writeLog('contacts', __METHOD__.', exception: '.$e->getMessage(), \OCP\Util::ERROR); + return false; + } + } else { + $vcard = $carddata; + } if (!is_array($id)) { $a_ids = array($id); @@ -651,4 +660,20 @@ class Ldap extends AbstractBackend { } } + // Please remove this + public function debug_string_backtrace() { + ob_start(); + debug_print_backtrace(); + $trace = ob_get_contents(); + ob_end_clean(); + + // Remove first item from backtrace as it's this function which + // is redundant. + $trace = preg_replace ('/^#0\s+' . __FUNCTION__ . "[^\n]*\n/", '', $trace, 1); + + // Renumber backtrace items. + $trace = preg_replace ('/^#(\d+)/me', '\'#\' . ($1 - 1)', $trace); + + return $trace; + } }