From eafb68b32160c73646a6d067b9352d05ceaf5023 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak <alec@alec.pl> Date: Sun, 17 Feb 2013 10:23:30 -0500 Subject: [PATCH] - Fix regression in handling LDAP contact identifiers (#1488959) --- CHANGELOG | 1 + program/steps/addressbook/func.inc | 23 +++++++++++++++-------- program/js/app.js | 4 ++-- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index de14e44..d7c211d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ CHANGELOG Roundcube Webmail =========================== +- Fix regression in handling LDAP contact identifiers (#1488959) - Updated translations from Transifex - Fix buggy error template in a frame (#1488938) - Add addressbook widget on compose page in classic skin diff --git a/program/js/app.js b/program/js/app.js index 4ecbda7..65ad8a3 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -4225,7 +4225,7 @@ this.group_member_change('add', cid, dest, to.id); else { var lock = this.display_message(this.get_label('copyingcontact'), 'loading'), - post_data = {_cid: cid, _source: source, _to: dest, _togid: to.id, _gid: group}; + post_data = {_cid: cid, _source: this.env.source, _to: dest, _togid: to.id, _gid: group}; this.http_post('copy', post_data, lock); } @@ -4233,7 +4233,7 @@ // target is an addressbook else if (to.id != source) { var lock = this.display_message(this.get_label('copyingcontact'), 'loading'), - post_data = {_cid: cid, _source: source, _to: to.id, _gid: group}; + post_data = {_cid: cid, _source: this.env.source, _to: to.id, _gid: group}; this.http_post('copy', post_data, lock); } diff --git a/program/steps/addressbook/func.inc b/program/steps/addressbook/func.inc index f6d2ae5..9b01eba 100644 --- a/program/steps/addressbook/func.inc +++ b/program/steps/addressbook/func.inc @@ -769,20 +769,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