1
0
mirror of https://github.com/nextcloud/ocsms.git synced 2026-08-11 16:32:55 +00:00

pushPhoneNumberToCache. This permit to fix problems with phone numbers with dashes and parenthesis

This commit is contained in:
Loic Blot
2014-11-05 11:08:59 +00:00
parent cc8d5ac50a
commit 66859a4940
2 changed files with 63 additions and 9 deletions
+7 -7
View File
@@ -127,7 +127,7 @@ class SmsController extends Controller {
$msgCount = 0;
// This table will be used to avoid duplicates
$noSpacesPhones = array();
$cleanedPhones = array();
// Contact resolved
if ($contactName != "" && isset($iContacts[$contactName])) {
@@ -143,10 +143,10 @@ class SmsController extends Controller {
$msgCount += $this->smsMapper->countMessagesForPhoneNumber($this->userId, $fmtPN);
$fmtPNNoSpaces = preg_replace("#[ ]#","", $fmtPN);
if (!in_array($fmtPNNoSpaces, $noSpacesPhones)) {
$fmtPNCleaned = preg_replace("#[ ]|-|\(|\)]#","", $fmtPN);
if (!in_array($fmtPNCleaned, $cleanedPhones)) {
$phoneNumbers[] = $fmtPN;
$noSpacesPhones[] = $fmtPNNoSpaces;
$cleanedPhones[] = $fmtPNCleaned;
}
}
}
@@ -157,10 +157,10 @@ class SmsController extends Controller {
$messages = $this->smsMapper->getAllMessagesForPhoneNumber($this->userId, $fmtPN, $lastDate);
$msgCount = $this->smsMapper->countMessagesForPhoneNumber($this->userId, $fmtPN);
$fmtPNNoSpaces = preg_replace("#[ ]#","", $fmtPN);
if (!in_array($fmtPNNoSpaces, $noSpacesPhones)) {
$fmtPNCleaned = preg_replace("#[ ]|-|\(|\)]#","", $fmtPN);
if (!in_array($fmtPNCleaned, $cleanedPhones)) {
$phoneNumbers[] = $fmtPN;
$noSpacesPhones[] = $fmtPNNoSpaces;
$cleanedPhones[] = $fmtPNCleaned;
}
}