From 13dc9f2c862668554d87dcbf95f2f7bbaf221bf3 Mon Sep 17 00:00:00 2001
From: Thomas Bruederli <thomas@roundcube.net>
Date: Fri, 25 Jan 2013 08:15:12 -0500
Subject: [PATCH] Move rcmail_contact_key() to rcube_addressbook::compose_contact_key()
---
program/steps/addressbook/list.inc | 2 +-
program/lib/Roundcube/rcube_addressbook.php | 16 ++++++++++++++++
program/steps/addressbook/func.inc | 18 ------------------
program/steps/addressbook/delete.inc | 2 +-
program/steps/addressbook/export.inc | 4 ++--
program/steps/addressbook/search.inc | 2 +-
6 files changed, 21 insertions(+), 23 deletions(-)
diff --git a/program/lib/Roundcube/rcube_addressbook.php b/program/lib/Roundcube/rcube_addressbook.php
index 4210627..cbc3c67 100644
--- a/program/lib/Roundcube/rcube_addressbook.php
+++ b/program/lib/Roundcube/rcube_addressbook.php
@@ -524,6 +524,22 @@
}
/**
+ * Create a unique key for sorting contacts
+ */
+ public static function compose_contact_key($contact, $sort_col)
+ {
+ $key = $contact[$sort_col] . ':' . $row['sourceid'];
+
+ // add email to a key to not skip contacts with the same name (#1488375)
+ if (!empty($contact['email'])) {
+ $key .= ':' . implode(':', (array)$contact['email']);
+ }
+
+ return $key;
+ }
+
+
+ /**
* Compare search value with contact data
*
* @param string $colname Data name
diff --git a/program/steps/addressbook/delete.inc b/program/steps/addressbook/delete.inc
index 81b8a09..5611858 100644
--- a/program/steps/addressbook/delete.inc
+++ b/program/steps/addressbook/delete.inc
@@ -93,7 +93,7 @@
while ($row = $result->next()) {
$row['sourceid'] = $s;
- $key = rcmail_contact_key($row, $sort_col);
+ $key = rcube_addressbook::compose_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 fc9f23f..15bf8b0 100644
--- a/program/steps/addressbook/export.inc
+++ b/program/steps/addressbook/export.inc
@@ -61,7 +61,7 @@
}
$record['sourceid'] = $s;
- $key = rcmail_contact_key($record, $sort_col);
+ $key = rcube_addressbook::compose_contact_key($record, $sort_col);
$records[$key] = $record;
}
@@ -109,7 +109,7 @@
}
$record['sourceid'] = $s;
- $key = rcmail_contact_key($record, $sort_col);
+ $key = rcube_addressbook::compose_contact_key($record, $sort_col);
$records[$key] = $record;
}
}
diff --git a/program/steps/addressbook/func.inc b/program/steps/addressbook/func.inc
index 2f47483..7fb862d 100644
--- a/program/steps/addressbook/func.inc
+++ b/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
*
diff --git a/program/steps/addressbook/list.inc b/program/steps/addressbook/list.inc
index 06a1e10..1bb2865 100644
--- a/program/steps/addressbook/list.inc
+++ b/program/steps/addressbook/list.inc
@@ -49,7 +49,7 @@
while ($row = $result->next()) {
$row['sourceid'] = $s;
- $key = rcmail_contact_key($row, $sort_col);
+ $key = rcube_addressbook::compose_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 bbd9b9a..d153c25 100644
--- a/program/steps/addressbook/search.inc
+++ b/program/steps/addressbook/search.inc
@@ -184,7 +184,7 @@
while ($row = $result->next()) {
$row['sourceid'] = $s['id'];
- $key = rcmail_contact_key($row, $sort_col);
+ $key = rcube_addressbook::compose_contact_key($row, $sort_col);
$records[$key] = $row;
}
--
Gitblit v1.9.1