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

Fix number with spaces issue into peerlist

* Also factorize one function
This commit is contained in:
Loic Blot
2014-10-22 12:38:36 +00:00
parent f94d3ea277
commit 621383e996
3 changed files with 19 additions and 18 deletions
+12 -12
View File
@@ -115,23 +115,23 @@ class OcSmsApp extends App {
if (is_array($phoneIds)) {
$countPhone = count($phoneIds);
for ($i=0; $i < $countPhone; $i++) {
$phoneNb = preg_replace("#[ ]#", "", $phoneIds[$i]);
self::$contacts[$phoneNb] = $r["FN"];
if (!isset(self::$contactsInverted[$r["FN"]])) {
self::$contactsInverted[$r["FN"]] = array();
}
array_push(self::$contactsInverted[$r["FN"]], $phoneNb);
$this->pushPhoneNumberToCache($phoneIds[$i], $r["FN"]);
}
}
else {
self::$contacts[$phoneIds] = $r["FN"];
if (!isset(self::$contactsInverted[$r["FN"]])) {
self::$contactsInverted[$r["FN"]] = array();
}
array_push(self::$contactsInverted[$r["FN"]], $phoneIds);
$this->pushPhoneNumberToCache($phoneIds, $r["FN"]);
}
}
}
}
private function pushPhoneNumberToCache($rawPhone, $contactName) {
$phoneNb = preg_replace("#[ ]#", "/", $rawPhone);
self::$contacts[$phoneNb] = $contactName;
if (!isset(self::$contactsInverted[$contactName])) {
self::$contactsInverted[$contactName] = array();
}
array_push(self::$contactsInverted[$contactName], $phoneNb);
}
}