Allow groups to have lavatars

This commit is contained in:
nathan 2022-09-26 15:16:38 -06:00
parent 7e25d8fdda
commit 5027e075d7
2 changed files with 14 additions and 6 deletions

View File

@ -441,12 +441,11 @@ class Accounts
$accounts[] = [ $accounts[] = [
'value' => $account['account_id'], 'value' => $account['account_id'],
'label' => $displayName, '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'], 'account_id' => $account['account_id'],
'modified' => $account['account_modified'], 'modified' => $account['account_modified'],
]), ]),
]); ];
} }
else else
{ {

View File

@ -2710,7 +2710,8 @@ class Contacts extends Contacts\Storage
if (substr($contact_id,0,8) == 'account:') 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); $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 !(($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))))) ($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'); header('Content-type: image/jpeg');
$contact['jpegphoto'] = \EGroupware\Api\avatar::lavatar(array( $contact['jpegphoto'] = \EGroupware\Api\avatar::lavatar(array(