1
0
mirror of https://github.com/nerzhul/ocsms.git synced 2025-06-07 16:06:15 +00:00

Contact names are now get with peerlist

This commit is contained in:
Loic Blot 2014-10-05 08:54:44 +00:00
parent 4c9b653018
commit 71d6ed693b
3 changed files with 28 additions and 6 deletions

View File

@ -87,9 +87,17 @@ class OcSmsApp extends App {
$result = $cm->search('',array('FN'));
foreach ($result as $r) {
if (isset ($r["TEL"])) {
self::$contacts[$r["TEL"]] = $r["FN"];
$phoneId = preg_replace("#[ ]#", "", $r["TEL"]);
self::$contacts[$phoneId] = $r["FN"];
$phoneIds = $r["TEL"];
if (is_array($phoneIds)) {
$countPhone = count($phoneIds);
for ($i=0; $i<$countPhone; $i++) {
$phoneNb = preg_replace("#[ ]#", "", $phoneIds[$i]);
self::$contacts[$phoneNb] = $r["FN"];
}
}
else {
self::$contacts[$phoneIds] = $r["FN"];
}
}
}
}

View File

@ -71,8 +71,17 @@ class SmsController extends Controller {
*/
public function retrieveAllPeers () {
$phoneList = $this->smsMapper->getAllPeersPhoneNumbers($this->userId);
$contactsSrc = $this->app->getContacts();
$contacts = array();
$countPhone = count($phoneList);
for ($i=0; $i < $countPhone; $i++) {
if (isset($contactsSrc[$phoneList[$i]])) {
$contacts[$phoneList[$i]] = $contactsSrc[$phoneList[$i]];
}
}
// @ TODO: filter correctly
return new JSONResponse(array("phonelist" => $phoneList));
return new JSONResponse(array("phonelist" => $phoneList, "contacts" => $contacts));
}
/**
@ -81,8 +90,14 @@ class SmsController extends Controller {
*/
public function getConversation ($phoneNumber, $lastDate = 0) {
$messages = $this->smsMapper->getAllMessagesForPhoneNumber($this->userId, $phoneNumber, $lastDate);
$contacts = $this->app->getContacts();
$contactName = "";
if (isset($contacts[$phoneNumber])) {
$contactName = $contacts[$phoneNumber];
}
// @ TODO: filter correctly
return new JSONResponse(array("conversation" => $messages, "contacts" => $this->app->getContacts()));
return new JSONResponse(array("conversation" => $messages, "contactName" => $contactName));
}
/**

View File

@ -14,7 +14,6 @@ var selectedConversation = null;
var curPhoneNumber = null;
var lastMsgDate = 0;
// Source: http://www.sitepoint.com/url-parameters-jquery/
$.urlParam = function(name){
var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href);
if (results == null) {