From e1ee71873a436b60f4171e4e0b41d2f4e83549b5 Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Mon, 13 Aug 2018 11:56:05 +0200 Subject: [PATCH] Implements lavatar and replace default photo avatar with generated lavatar --- addressbook/inc/class.addressbook_ui.inc.php | 11 ++++++++++- api/src/Contacts.php | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/addressbook/inc/class.addressbook_ui.inc.php b/addressbook/inc/class.addressbook_ui.inc.php index bf754a5361..e24140103f 100644 --- a/addressbook/inc/class.addressbook_ui.inc.php +++ b/addressbook/inc/class.addressbook_ui.inc.php @@ -2510,7 +2510,7 @@ window.egw_LAB.wait(function() { // Enable history $this->setup_history($content, $sel_options); - $content['photo'] = $this->photo_src($content['id'],$content['jpegphoto'],'photo',$content['etag']); + $content['photo'] = $this->photo_src($content['id'],$content['jpegphoto'],'',$content['etag']); if ($content['private']) $content['owner'] .= 'p'; @@ -3204,6 +3204,15 @@ window.egw_LAB.wait(function() { !(($contact['files'] & Api\Contacts::FILES_BIT_PHOTO) && // new SQL in VFS ($size = filesize($url=Api\Link::vfs_path('addressbook', $contact_id, Api\Contacts::FILES_PHOTO))))) { + if (is_array($contact)) + { + echo Api\avatar::lavatar(array( + 'id' => $contact['id'], + 'firstname' => $contact['n_given'], + 'lastname' => $contact['n_family']) + ); + exit(); + } Egw::redirect(Api\Image::find('addressbook','photo')); } // use an etag over the image mapp diff --git a/api/src/Contacts.php b/api/src/Contacts.php index cc45a06bae..222bf6b1f1 100755 --- a/api/src/Contacts.php +++ b/api/src/Contacts.php @@ -764,7 +764,7 @@ class Contacts extends Contacts\Storage function photo_src($id,$jpeg,$default='',$etag=null) { //error_log(__METHOD__."($id, ..., etag=$etag) ". function_backtrace()); - return $jpeg ? array( + return $jpeg || !$default ? array( 'menuaction' => 'addressbook.addressbook_ui.photo', 'contact_id' => $id, )+(isset($etag) ? array(