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

prepare contact/phone buffer

This commit is contained in:
Loïc Blot (@U-Exp) 2014-09-30 07:36:49 +02:00
parent edb098fad9
commit addc336d12

View File

@ -21,7 +21,7 @@ use \OCA\OcSms\Db\SmsMapper;
class Application extends App {
/**
* @var array used to cache the parsed contacts for every request
*/
@ -51,7 +51,7 @@ class Application extends App {
$container->registerService('Sms', function($c) {
return new Sms($c->query('ServerContainer')->getDb());
});
$container->registerService('SmsMapper', function($c) {
return new SmsMapper($c->query('ServerContainer')->getDb());
});
@ -62,7 +62,7 @@ class Application extends App {
$container->registerService('UserId', function($c) {
return \OCP\User::getUser();
});
/**
* Managers
*/
@ -70,14 +70,21 @@ class Application extends App {
return $c->getServer()->getContactsManager();
});
}
/**
/**
* Partially importe this function from owncloud Chat app
* https://github.com/owncloud/chat/blob/master/app/chat.php
*/
public function getContacts() {
// Only load contacts if they aren't in the buffer
if(count(self::$contacts) == 0){
if(count(self::$contacts) == 0) {
$cm = $this->c['ContactsManager'];
$result = $cm->search('',array('FN'));
foreach ($result as $r) {
if (isset $r["phone"]) {
self::$contacts[$r["phone"]] = $r["FN"];
}
}
}
}
}