mirror of
https://github.com/nerzhul/ocsms.git
synced 2025-06-08 16:36:25 +00:00
Definitively resolve spaces issue
This commit is contained in:
parent
1e21406f76
commit
8d28751d94
@ -127,11 +127,18 @@ class OcSmsApp extends App {
|
|||||||
|
|
||||||
private function pushPhoneNumberToCache($rawPhone, $contactName) {
|
private function pushPhoneNumberToCache($rawPhone, $contactName) {
|
||||||
$phoneNb = preg_replace("#[ ]#", "/", $rawPhone);
|
$phoneNb = preg_replace("#[ ]#", "/", $rawPhone);
|
||||||
|
$phoneNbNoSpaces = preg_replace("#[ ]#", "", $rawPhone);
|
||||||
|
|
||||||
self::$contacts[$phoneNb] = $contactName;
|
self::$contacts[$phoneNb] = $contactName;
|
||||||
|
self::$contacts[$phoneNbNoSpaces] = $contactName;
|
||||||
|
|
||||||
if (!isset(self::$contactsInverted[$contactName])) {
|
if (!isset(self::$contactsInverted[$contactName])) {
|
||||||
self::$contactsInverted[$contactName] = array();
|
self::$contactsInverted[$contactName] = array();
|
||||||
}
|
}
|
||||||
array_push(self::$contactsInverted[$contactName], $phoneNb);
|
array_push(self::$contactsInverted[$contactName], $phoneNb);
|
||||||
|
|
||||||
|
if ($phoneNb != $phoneNbNoSpaces) {
|
||||||
|
array_push(self::$contactsInverted[$contactName], $phoneNbNoSpaces);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,6 +111,7 @@ class SmsController extends Controller {
|
|||||||
*/
|
*/
|
||||||
public function getConversation ($phoneNumber, $lastDate = 0) {
|
public function getConversation ($phoneNumber, $lastDate = 0) {
|
||||||
$contacts = $this->app->getContacts();
|
$contacts = $this->app->getContacts();
|
||||||
|
$iContacts = $this->app->getInvertedContacts();
|
||||||
$contactName = "";
|
$contactName = "";
|
||||||
|
|
||||||
// Add slashes to index properly
|
// Add slashes to index properly
|
||||||
@ -123,8 +124,6 @@ class SmsController extends Controller {
|
|||||||
$phoneNumbers = array();
|
$phoneNumbers = array();
|
||||||
$msgCount = 0;
|
$msgCount = 0;
|
||||||
|
|
||||||
$iContacts = $this->app->getInvertedContacts();
|
|
||||||
|
|
||||||
// Contact resolved
|
// Contact resolved
|
||||||
if ($contactName != "" && isset($iContacts[$contactName])) {
|
if ($contactName != "" && isset($iContacts[$contactName])) {
|
||||||
$ctPn = count($iContacts[$contactName]);
|
$ctPn = count($iContacts[$contactName]);
|
||||||
@ -133,23 +132,39 @@ class SmsController extends Controller {
|
|||||||
for ($i=0; $i < $ctPn; $i++) {
|
for ($i=0; $i < $ctPn; $i++) {
|
||||||
// Remove slashes
|
// Remove slashes
|
||||||
$fmtPN = preg_replace("#[/]#"," ", $iContacts[$contactName][$i]);
|
$fmtPN = preg_replace("#[/]#"," ", $iContacts[$contactName][$i]);
|
||||||
|
$fmtPN2 = preg_replace("#[/]#","", $iContacts[$contactName][$i]);
|
||||||
|
|
||||||
$messages = $messages +
|
$messages = $messages +
|
||||||
$this->smsMapper->getAllMessagesForPhoneNumber($this->userId, $fmtPN, $lastDate);
|
$this->smsMapper->getAllMessagesForPhoneNumber($this->userId, $fmtPN, $lastDate);
|
||||||
|
|
||||||
|
$msgCount += $this->smsMapper->countMessagesForPhoneNumber($this->userId, $fmtPN);
|
||||||
|
|
||||||
$phoneNumbers[] = $fmtPN;
|
$phoneNumbers[] = $fmtPN;
|
||||||
|
|
||||||
$msgCount += $this->smsMapper->countMessagesForPhoneNumber($this->userId, $fmtPN);
|
if ($fmtPN != $fmtPN2) {
|
||||||
|
$messages = $messages +
|
||||||
|
$this->smsMapper->getAllMessagesForPhoneNumber($this->userId, $fmtPN2, $lastDate);
|
||||||
|
|
||||||
|
$msgCount += $this->smsMapper->countMessagesForPhoneNumber($this->userId, $fmtPN2);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// remove slashes
|
// remove slashes
|
||||||
$fmtPN = preg_replace("#[/]#"," ", $phoneNumber);
|
$fmtPN = preg_replace("#[/]#"," ", $phoneNumber);
|
||||||
|
$fmtPN2 = preg_replace("#[/]#","", $phoneNumber);
|
||||||
|
|
||||||
$messages = $this->smsMapper->getAllMessagesForPhoneNumber($this->userId, $fmtPN, $lastDate);
|
$messages = $this->smsMapper->getAllMessagesForPhoneNumber($this->userId, $fmtPN, $lastDate);
|
||||||
$msgCount = $this->smsMapper->countMessagesForPhoneNumber($this->userId, $fmtPN);
|
$msgCount = $this->smsMapper->countMessagesForPhoneNumber($this->userId, $fmtPN);
|
||||||
|
|
||||||
$phoneNumbers[] = $fmtPN;
|
$phoneNumbers[] = $fmtPN;
|
||||||
|
|
||||||
|
if ($fmtPN != $fmtPN2) {
|
||||||
|
$messages = $messages +
|
||||||
|
$this->smsMapper->getAllMessagesForPhoneNumber($this->userId, $fmtPN2, $lastDate);
|
||||||
|
$msgCount += $this->smsMapper->countMessagesForPhoneNumber($this->userId, $fmtPN2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Order by id (date)
|
// Order by id (date)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user