Move rcmail_contact_key() to rcube_addressbook::compose_contact_key()

pull/57/merge
Thomas Bruederli 12 years ago
parent 1730cf8d7b
commit 13dc9f2c86

@ -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);

@ -61,7 +61,7 @@ if (!empty($_REQUEST['_search']) && isset($_SESSION['search'][$_REQUEST['_search
}
$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 @@ else if (!empty($_REQUEST['_cid'])) {
}
$record['sourceid'] = $s;
$key = rcmail_contact_key($record, $sort_col);
$key = rcube_addressbook::compose_contact_key($record, $sort_col);
$records[$key] = $record;
}
}

@ -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