1
0
mirror of https://github.com/nerzhul/ocsms.git synced 2025-06-07 07:56:23 +00:00

Avoid problem with duplicates numbers on conversations (spaces and no spaces)

This commit is contained in:
Loic Blot 2014-10-23 08:58:16 +00:00
parent 714f0c0d9e
commit a09faa67ad

View File

@ -124,6 +124,9 @@ class SmsController extends Controller {
$phoneNumbers = array();
$msgCount = 0;
// This table will be used to avoid duplicates
$noSpacesPhones = array();
// Contact resolved
if ($contactName != "" && isset($iContacts[$contactName])) {
$ctPn = count($iContacts[$contactName]);
@ -138,7 +141,11 @@ class SmsController extends Controller {
$msgCount += $this->smsMapper->countMessagesForPhoneNumber($this->userId, $fmtPN);
$phoneNumbers[] = $fmtPN;
$fmtPNNoSpaces = preg_replace("#[ ]#","", $fmtPN);
if (!in_array($fmtPNNoSpaces, $noSpacesPhones)) {
$phoneNumbers[] = $fmtPN;
$noSpacesPhones[] = $fmtPNNoSpaces;
}
}
}
else {
@ -148,7 +155,11 @@ class SmsController extends Controller {
$messages = $this->smsMapper->getAllMessagesForPhoneNumber($this->userId, $fmtPN, $lastDate);
$msgCount = $this->smsMapper->countMessagesForPhoneNumber($this->userId, $fmtPN);
$phoneNumbers[] = $fmtPN;
$fmtPNNoSpaces = preg_replace("#[ ]#","", $fmtPN);
if (!in_array($fmtPNNoSpaces, $noSpacesPhones)) {
$phoneNumbers[] = $fmtPN;
$noSpacesPhones[] = $fmtPNNoSpaces;
}
}
// Order by id (date)