diff options
author | Aleksander Machniak <alec@alec.pl> | 2012-12-14 19:41:07 +0100 |
---|---|---|
committer | Aleksander Machniak <alec@alec.pl> | 2012-12-14 19:41:07 +0100 |
commit | ff4a92c8e2f11711975f9697a057cd96ce370bc5 (patch) | |
tree | 79324bb25d30baa933603fbe4b0b18a2a0e6af8a /program/steps/addressbook/func.inc | |
parent | 5c421d9927c973049bfaea69609cdf760f8f7332 (diff) |
Fix contact copy/add-to-group operations on search result (#1488862)
Diffstat (limited to 'program/steps/addressbook/func.inc')
-rw-r--r-- | program/steps/addressbook/func.inc | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/program/steps/addressbook/func.inc b/program/steps/addressbook/func.inc index fded9a819..2f47483de 100644 --- a/program/steps/addressbook/func.inc +++ b/program/steps/addressbook/func.inc @@ -756,7 +756,7 @@ function rcmail_contact_key($row, $sort_col) * * @return array List of contact IDs per-source */ -function rcmail_get_cids() +function rcmail_get_cids($filter = null) { // contact ID (or comma-separated list of IDs) is provided in two // forms. If _source is an empty string then the ID is a string @@ -765,24 +765,25 @@ function rcmail_get_cids() $cid = get_input_value('_cid', RCUBE_INPUT_GPC); $source = (string) get_input_value('_source', RCUBE_INPUT_GPC); + if (is_array($cid)) { + return $cid; + } + if (!preg_match('/^[a-zA-Z0-9\+\/=_-]+(,[a-zA-Z0-9\+\/=_-]+)*$/', $cid)) { return array(); } - $cid = explode(',', $cid); - $got_source = strlen($source); - $result = array(); + $cid = explode(',', $cid); + $result = array(); // create per-source contact IDs array foreach ($cid as $id) { - // if _source is not specified we'll find it from decoded ID - if (!$got_source) { - 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; - } + // 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; } } else { @@ -790,9 +791,10 @@ function rcmail_get_cids() } } - return $result; + return $filter !== null ? $result[$filter] : $result; } + // register UI objects $OUTPUT->add_handlers(array( 'directorylist' => 'rcmail_directory_list', |