From 5027e075d75f33ce0f529ff2d8459c471d18f8b8 Mon Sep 17 00:00:00 2001 From: nathan Date: Mon, 26 Sep 2022 15:16:38 -0600 Subject: [PATCH] Allow groups to have lavatars --- api/src/Accounts.php | 7 +++---- api/src/Contacts.php | 13 +++++++++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/api/src/Accounts.php b/api/src/Accounts.php index de217e2c8d..ae18fdf508 100644 --- a/api/src/Accounts.php +++ b/api/src/Accounts.php @@ -441,12 +441,11 @@ class Accounts $accounts[] = [ 'value' => $account['account_id'], 'label' => $displayName, - ]+($account['account_id'] <= 0 ? [] : [ // there is currently no avatar for groups, no need to ask server about it - 'icon' => Framework::link('/api/avatar.php', [ + 'icon' => Framework::link('/api/avatar.php', [ 'account_id' => $account['account_id'], - 'modified' => $account['account_modified'], + 'modified' => $account['account_modified'], ]), - ]); + ]; } else { diff --git a/api/src/Contacts.php b/api/src/Contacts.php index 9d0969fdc4..683bee170f 100755 --- a/api/src/Contacts.php +++ b/api/src/Contacts.php @@ -2710,7 +2710,8 @@ class Contacts extends Contacts\Storage if (substr($contact_id,0,8) == 'account:') { - $contact_id = $GLOBALS['egw']->accounts->id2name(substr($contact_id,8),'person_id'); + $id = substr($contact_id, 8); + $contact_id = $GLOBALS['egw']->accounts->id2name(substr($contact_id, 8), 'person_id'); } $contact = $this->read($contact_id); @@ -2720,7 +2721,15 @@ class Contacts extends Contacts\Storage !(($contact['files'] & \EGroupware\Api\Contacts::FILES_BIT_PHOTO) && // new SQL in VFS ($size = filesize($url= \EGroupware\Api\Link::vfs_path('addressbook', $contact_id, \EGroupware\Api\Contacts::FILES_PHOTO))))) { - if (is_array($contact)) + if(!$contact_id && $id < 0) + { + $group = $GLOBALS['egw']->accounts->read($id); + $contact = array( + 'id' => $id, + 'n_given' => $group['account_firstname'] + ); + } + if(is_array($contact)) { header('Content-type: image/jpeg'); $contact['jpegphoto'] = \EGroupware\Api\avatar::lavatar(array(