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

Add contact photos into peerlist

Add some support into controller
This commit is contained in:
Loic Blot
2014-12-29 11:31:03 +00:00
parent 2fe4cc0ce0
commit da5447a51b
4 changed files with 33 additions and 10 deletions
+17 -7
View File
@@ -30,9 +30,10 @@ class OcSmsApp extends App {
/*
caching dosn´t work because on every call all will be reinstantiated
*/
private static $contacts; // dosn´t work
private static $contacts;
private static $contactPhotos;
private static $contactsInverted; // dosn´t work
private static $contactsInverted;
private $c;
@@ -85,7 +86,6 @@ class OcSmsApp extends App {
public function getContacts() {
// Only load contacts if they aren't in the buffer
// dosn´t work
if(count(self::$contacts) == 0) {
$this->loadContacts();
}
@@ -94,13 +94,20 @@ class OcSmsApp extends App {
public function getInvertedContacts() {
// Only load contacts if they aren't in the buffer
// dosn´t work
if(count(self::$contactsInverted) == 0) {
$this->loadContacts();
}
return self::$contactsInverted;
}
public function getContactPhotos() {
// Only load contacts if they aren't in the buffer
if(count(self::$contactPhotos) == 0) {
$this->loadContacts();
}
return self::$contactPhotos;
}
/**
* Partially importe this function from owncloud Chat app
* https://github.com/owncloud/chat/blob/master/app/chat.php
@@ -129,12 +136,15 @@ class OcSmsApp extends App {
$this->pushPhoneNumberToCache($phoneIds, $r["FN"]);
}
}
if (isset ($r["PHOTO"])) {
// Remove useless prefix
$photoURL = preg_replace("#VALUE=uri:#","",$r["PHOTO"]);
self::$contactPhotos[$r["FN"]] = $photoURL;
}
}
}
/*
all numbers will be formatted
*/
private function pushPhoneNumberToCache($rawPhone, $contactName) {
$phoneNb = PhoneNumberFormatter::format($rawPhone);