1
0
mirror of https://github.com/nerzhul/ocsms.git synced 2025-06-10 01:16:12 +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

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);
}
}

View File

@ -94,8 +94,9 @@ class SmsController extends Controller {
$countPhone = count($phoneList);
for ($i=0; $i < $countPhone; $i++) {
if (isset($contactsSrc[$phoneList[$i]])) {
$contacts[$phoneList[$i]] = $contactsSrc[$phoneList[$i]];
$fmtPN = preg_replace("#[ ]#","/", $phoneList[$i]);
if (isset($contactsSrc[$fmtPN])) {
$contacts[$fmtPN] = $contactsSrc[$fmtPN];
}
}
// @ TODO: filter correctly

View File

@ -197,14 +197,14 @@ function fetchInitialPeerList(jsondata) {
var bufferedContacts = [];
$.each(jsondata['phonelist'], function(id, val) {
var fn, peerLabel;
if (typeof jsondata['contacts'][val] == 'undefined') {
var fn, peerLabel, idxVal;
idxVal = val.replace(/ /g,'/');
if (typeof jsondata['contacts'][idxVal] == 'undefined') {
fn = '';
peerLabel = val;
}
else {
fn = jsondata['contacts'][val];
fn = jsondata['contacts'][idxVal];
peerLabel = fn;
}
if ($.inArray(peerLabel, bufferedContacts) == -1) {