summaryrefslogtreecommitdiff
path: root/program
diff options
context:
space:
mode:
Diffstat (limited to 'program')
-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
6 files changed, 25 insertions, 11 deletions
diff --git a/program/steps/addressbook/delete.inc b/program/steps/addressbook/delete.inc
index beba1ae73..f19dcf482 100644
--- a/program/steps/addressbook/delete.inc
+++ b/program/steps/addressbook/delete.inc
@@ -72,6 +72,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();
@@ -94,7 +95,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 0fe193bf2..c0dbd8bf1 100644
--- a/program/steps/addressbook/export.inc
+++ b/program/steps/addressbook/export.inc
@@ -27,6 +27,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();
@@ -44,7 +45,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 f261527e4..84796baee 100644
--- a/program/steps/addressbook/func.inc
+++ b/program/steps/addressbook/func.inc
@@ -729,6 +729,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 de7149bce..91852a421 100644
--- a/program/steps/addressbook/list.inc
+++ b/program/steps/addressbook/list.inc
@@ -50,7 +50,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 54d2c4dab..2c6548184 100644
--- a/program/steps/addressbook/search.inc
+++ b/program/steps/addressbook/search.inc
@@ -147,6 +147,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']);
@@ -185,7 +186,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 88701a4e6..4283ed185 100644
--- a/program/steps/addressbook/undo.inc
+++ b/program/steps/addressbook/undo.inc
@@ -68,13 +68,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();
}