summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2012-03-05 19:59:07 +0000
committeralecpl <alec@alec.pl>2012-03-05 19:59:07 +0000
commit053538bf60e354a64664fb9a992cbbda37d70f76 (patch)
tree764ebf819debced16b472f754bbf04a54c5b3b06
parentb1a8dabb1fcea27e19d71dda138191dea3dc529f (diff)
- Merge r5966 from trunk (#1488375)
-rw-r--r--CHANGELOG1
-rw-r--r--program/steps/addressbook/delete.inc3
-rw-r--r--program/steps/addressbook/export.inc3
-rw-r--r--program/steps/addressbook/func.inc18
-rw-r--r--program/steps/addressbook/list.inc2
-rw-r--r--program/steps/addressbook/search.inc3
-rw-r--r--program/steps/addressbook/undo.inc7
7 files changed, 26 insertions, 11 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 721904fce..d1ddab964 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
CHANGELOG Roundcube Webmail
===========================
+- Fix duplicate names handling in addressbook searches (#1488375)
- Fix displaying of HTML messages from Disqus (#1488372)
- Disable E_STRICT warnings on PHP 5.4
- Prevent from folder selection on virtual folder collapsing (#1488346)
diff --git a/program/steps/addressbook/delete.inc b/program/steps/addressbook/delete.inc
index 222535cf3..baddd2b71 100644
--- a/program/steps/addressbook/delete.inc
+++ b/program/steps/addressbook/delete.inc
@@ -69,6 +69,7 @@ $page = isset($_SESSION['page']) ? $_SESSION['page'] : 1;
// update saved search after data changed
if (($search_request = $_REQUEST['_search']) && isset($_SESSION['search'][$search_request])) {
+ $sort_col = $RCMAIL->config->get('addressbook_sort_col', 'name');
$search = (array)$_SESSION['search'][$search_request];
$records = array();
@@ -91,7 +92,7 @@ if (($search_request = $_REQUEST['_search']) && isset($_SESSION['search'][$searc
while ($row = $result->next()) {
$row['sourceid'] = $s;
- $key = $row['name'] . ':' . $row['sourceid'];
+ $key = rcmail_contact_key($row, $sort_col);
$records[$key] = $row;
}
unset($result);
diff --git a/program/steps/addressbook/export.inc b/program/steps/addressbook/export.inc
index 8ba1c08b6..988dabf51 100644
--- a/program/steps/addressbook/export.inc
+++ b/program/steps/addressbook/export.inc
@@ -24,6 +24,7 @@
// Use search result
if (!empty($_REQUEST['_search']) && isset($_SESSION['search'][$_REQUEST['_search']]))
{
+ $sort_col = $RCMAIL->config->get('addressbook_sort_col', 'name');
$search = (array)$_SESSION['search'][$_REQUEST['_search']];
$records = array();
@@ -41,7 +42,7 @@ if (!empty($_REQUEST['_search']) && isset($_SESSION['search'][$_REQUEST['_search
while ($row = $result->next()) {
$row['sourceid'] = $s;
- $key = $row['name'] . ':' . $row['sourceid'];
+ $key = rcmail_contact_key($row, $sort_col);
$records[$key] = $row;
}
unset($result);
diff --git a/program/steps/addressbook/func.inc b/program/steps/addressbook/func.inc
index caf964db7..ec97e819f 100644
--- a/program/steps/addressbook/func.inc
+++ b/program/steps/addressbook/func.inc
@@ -728,6 +728,24 @@ function rcmail_format_date_col($val)
}
+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
*
diff --git a/program/steps/addressbook/list.inc b/program/steps/addressbook/list.inc
index 71196b4bb..18b626d8b 100644
--- a/program/steps/addressbook/list.inc
+++ b/program/steps/addressbook/list.inc
@@ -47,7 +47,7 @@ if (!empty($_REQUEST['_search']) && isset($_SESSION['search'][$_REQUEST['_search
while ($row = $result->next()) {
$row['sourceid'] = $s;
- $key = $row[$sort_col] . ':' . $row['sourceid'];
+ $key = rcmail_contact_key($row, $sort_col);
$records[$key] = $row;
}
unset($result);
diff --git a/program/steps/addressbook/search.inc b/program/steps/addressbook/search.inc
index 172286171..9415de4ee 100644
--- a/program/steps/addressbook/search.inc
+++ b/program/steps/addressbook/search.inc
@@ -144,6 +144,7 @@ function rcmail_contact_search()
$sources = $RCMAIL->get_address_sources();
$search_set = array();
$records = array();
+ $sort_col = $RCMAIL->config->get('addressbook_sort_col', 'name');
foreach ($sources as $s) {
$source = $RCMAIL->get_address_book($s['id']);
@@ -182,7 +183,7 @@ function rcmail_contact_search()
while ($row = $result->next()) {
$row['sourceid'] = $s['id'];
- $key = $row['name'] . ':' . $row['sourceid'];
+ $key = rcmail_contact_key($row, $sort_col);
$records[$key] = $row;
}
diff --git a/program/steps/addressbook/undo.inc b/program/steps/addressbook/undo.inc
index 936f11086..590ed5a43 100644
--- a/program/steps/addressbook/undo.inc
+++ b/program/steps/addressbook/undo.inc
@@ -65,13 +65,6 @@ if ($delcnt && ($search_request = $_REQUEST['_search']) && isset($_SESSION['sear
continue;
}
- while ($row = $result->next()) {
- $row['sourceid'] = $s;
- $key = $row['name'] . ':' . $row['sourceid'];
- $records[$key] = $row;
- }
- unset($result);
-
$search[$s] = $source->get_search_set();
}