From 60dabb35aed6689dd6b50cb885b3dbbf5504ef1f Mon Sep 17 00:00:00 2001 From: Aleksander Machniak <alec@alec.pl> Date: Sun, 17 Feb 2013 10:26:29 -0500 Subject: [PATCH] - Fix regression in handling LDAP contact identifiers (#1488959) --- program/steps/addressbook/func.inc | 23 +++++++++++++++-------- 1 files changed, 15 insertions(+), 8 deletions(-) diff --git a/program/steps/addressbook/func.inc b/program/steps/addressbook/func.inc index 7fb862d..aad849f 100644 --- a/program/steps/addressbook/func.inc +++ b/program/steps/addressbook/func.inc @@ -755,20 +755,27 @@ return array(); } - $cid = explode(',', $cid); - $result = array(); + $cid = explode(',', $cid); + $got_source = strlen($source); + $result = array(); // create per-source contact IDs array foreach ($cid as $id) { - // get source from decoded ID - if ($sep = strrpos($id, '-')) { - $contact_id = substr($id, 0, $sep); - $source_id = substr($id, $sep+1); - if (strlen($source_id)) { - $result[(string)$source_id][] = $contact_id; + // extract source ID from contact ID (it's there in search mode) + // see #1488959 and #1488862 for reference + if (!$got_source) { + if ($sep = strrpos($id, '-')) { + $contact_id = substr($id, 0, $sep); + $source_id = (string) substr($id, $sep+1); + if (strlen($source_id)) { + $result[$source_id][] = $contact_id; + } } } else { + if (substr($id, -($got_source+1)) == "-$source") { + $id = substr($id, 0, -($got_source+1)); + } $result[$source][] = $id; } } -- Gitblit v1.9.1