diff --git a/appinfo/ocsmsapp.php b/appinfo/ocsmsapp.php index 4ebad1a..d1f7ea5 100644 --- a/appinfo/ocsmsapp.php +++ b/appinfo/ocsmsapp.php @@ -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); diff --git a/controller/smscontroller.php b/controller/smscontroller.php index d36acbc..c5f6925 100644 --- a/controller/smscontroller.php +++ b/controller/smscontroller.php @@ -111,6 +111,7 @@ class SmsController extends Controller { $phoneList = $this->smsMapper->getLastMessageTimestampForAllPhonesNumbers($this->userId); $contactsSrc = $this->app->getContacts(); $contacts = array(); + $photos = $this->app->getContactPhotos(); $countPhone = count($phoneList); foreach ($phoneList as $number => $ts) { @@ -126,7 +127,7 @@ class SmsController extends Controller { } } $lastRead = $this->smsMapper->getLastReadDate($this->userId); - return new JSONResponse(array("phonelist" => $phoneList, "contacts" => $contacts, "lastRead" => $lastRead)); + return new JSONResponse(array("phonelist" => $phoneList, "contacts" => $contacts, "lastRead" => $lastRead, "photos" => $photos)); } /** diff --git a/css/style.css b/css/style.css index 26d3c55..5f10bcd 100644 --- a/css/style.css +++ b/css/style.css @@ -38,7 +38,6 @@ } #app-mailbox-peers li > a { display: block; - width: 100%; overflow: hidden; -moz-box-sizing: border-box; box-sizing: border-box; white-space: nowrap; @@ -124,3 +123,11 @@ .msg-spacer { clear: both; } + +.ocsms-plavatar { + width: 40px; + height: 40px; + float: left; + background-size: 40px; + background-repeat: no-repeat; +} diff --git a/js/script.js b/js/script.js index bafcb0b..0a33512 100644 --- a/js/script.js +++ b/js/script.js @@ -289,7 +289,12 @@ function fetchInitialPeerList(jsondata) { peerLabel = fn; } if ($.inArray(peerLabel, bufferedContacts) == -1) { - peerListBuf += '