Move rcmail_contact_key() to rcube_addressbook::compose_contact_key()

pull/88/head
Thomas Bruederli 12 years ago
parent 7f693b6565
commit c4a1d3fe5d

@ -523,6 +523,22 @@ abstract class rcube_addressbook
return $fn;
}
/**
* 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
*

@ -93,7 +93,7 @@ if (($search_request = $_REQUEST['_search']) && isset($_SESSION['search'][$searc
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);

@ -42,7 +42,7 @@ if (!empty($_REQUEST['_search']) && isset($_SESSION['search'][$_REQUEST['_search
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);

@ -733,24 +733,6 @@ 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
*

@ -49,7 +49,7 @@ if (!empty($_REQUEST['_search']) && isset($_SESSION['search'][$_REQUEST['_search
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);

@ -184,7 +184,7 @@ function rcmail_contact_search()
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;
}

Loading…
Cancel
Save