Aleksander Machniak
2013-02-17 60dabb35aed6689dd6b50cb885b3dbbf5504ef1f
program/steps/addressbook/func.inc
@@ -733,24 +733,6 @@
}
function rcmail_contact_key($row, $sort_col)
{
    $key = $row[$sort_col] . ':' . $row['sourceid'];
    // add email to a key to not skip contacts with the same name (#1488375)
    if (!empty($row['email'])) {
         if (is_array($row['email'])) {
             $key .= ':' . implode(':', $row['email']);
         }
         else {
             $key .= ':' . $row['email'];
         }
     }
     return $key;
}
/**
 * Returns contact ID(s) and source(s) from GET/POST data
 *
@@ -773,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;
        }
    }