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) {
|
||||
$phoneNb = preg_replace("#[ ]#", "/", $rawPhone);
|
||||
$phoneNbNoSpaces = preg_replace("#[ ]#", "", $rawPhone);
|
||||
|
||||
self::$contacts[$phoneNb] = $contactName;
|
||||
self::$contacts[$phoneNbNoSpaces] = $contactName;
|
||||
|
||||
if (!isset(self::$contactsInverted[$contactName])) {
|
||||
self::$contactsInverted[$contactName] = array();
|
||||
}
|
||||
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) {
|
||||
$contacts = $this->app->getContacts();
|
||||
$iContacts = $this->app->getInvertedContacts();
|
||||
$contactName = "";
|
||||
|
||||
// Add slashes to index properly
|
||||
@ -123,8 +124,6 @@ class SmsController extends Controller {
|
||||
$phoneNumbers = array();
|
||||
$msgCount = 0;
|
||||
|
||||
$iContacts = $this->app->getInvertedContacts();
|
||||
|
||||
// Contact resolved
|
||||
if ($contactName != "" && isset($iContacts[$contactName])) {
|
||||
$ctPn = count($iContacts[$contactName]);
|
||||
@ -133,23 +132,39 @@ class SmsController extends Controller {
|
||||
for ($i=0; $i < $ctPn; $i++) {
|
||||
// Remove slashes
|
||||
$fmtPN = preg_replace("#[/]#"," ", $iContacts[$contactName][$i]);
|
||||
$fmtPN2 = preg_replace("#[/]#","", $iContacts[$contactName][$i]);
|
||||
|
||||
$messages = $messages +
|
||||
$this->smsMapper->getAllMessagesForPhoneNumber($this->userId, $fmtPN, $lastDate);
|
||||
|
||||
$msgCount += $this->smsMapper->countMessagesForPhoneNumber($this->userId, $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 {
|
||||
// remove slashes
|
||||
$fmtPN = preg_replace("#[/]#"," ", $phoneNumber);
|
||||
$fmtPN2 = preg_replace("#[/]#","", $phoneNumber);
|
||||
|
||||
$messages = $this->smsMapper->getAllMessagesForPhoneNumber($this->userId, $fmtPN, $lastDate);
|
||||
$msgCount = $this->smsMapper->countMessagesForPhoneNumber($this->userId, $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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user