mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-07 08:34:42 +01:00
* Status, Addressbook: preference to use first letters of username for avatar instead of initials
This commit is contained in:
parent
16ba791902
commit
d31915df05
@ -2758,7 +2758,7 @@ class Contacts extends Contacts\Storage
|
||||
$email = strtolower(current(Mail::stripRFC822Addresses([$_GET['email']])));
|
||||
|
||||
if (!($contact = current($this->search(['contact_email' => $email, 'contact_email_home' => $email],
|
||||
['contact_id', 'email', 'email_home', 'n_fn', 'n_given', 'n_family', 'contact_files', 'etag'],
|
||||
['contact_id', 'email', 'email_home', 'n_fn', 'n_given', 'n_family', 'contact_files', 'etag', 'account_lid'],
|
||||
'contact_files & '.self::FILES_BIT_PHOTO.' DESC', '', '', false, 'OR', [0, 1]) ?: [])) ||
|
||||
!self::hasPhoto($contact))
|
||||
{
|
||||
@ -2785,12 +2785,17 @@ class Contacts extends Contacts\Storage
|
||||
}
|
||||
if(is_array($contact))
|
||||
{
|
||||
$use_account_lid = empty($contact['account_lid']) && empty($contact['account_id']) ? 0 :
|
||||
$GLOBALS['egw_info']['user']['preferences']['common']['avatar_display'] ?? 0;
|
||||
|
||||
header('Content-type: image/jpeg');
|
||||
$contact['jpegphoto'] = Contacts\Lavatar::generate(array(
|
||||
$contact['jpegphoto'] = Contacts\Lavatar::generate([
|
||||
'id' => $contact['id'],
|
||||
'firstname' => $contact['n_given'],
|
||||
'lastname' => $contact['n_family'])
|
||||
);
|
||||
'lastname' => $contact['n_family'],
|
||||
'account_lid' => $contact['account_lid'] ??
|
||||
(empty($contact['account_id']) ? null : Accounts::getInstance()->id2name($contact['account_id'])),
|
||||
], null, 128, $use_account_lid);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,8 @@ class Lavatar
|
||||
* array (
|
||||
* 'firstname' => [userFirstname],
|
||||
* 'lastname' => [userLastname],
|
||||
* 'id' => [user id]
|
||||
* 'id' => [user id],
|
||||
* 'account_lid' => [username],
|
||||
* )
|
||||
* @param array $_color = null an array of RGB color, default
|
||||
* is nul to get a random color from color library.
|
||||
@ -65,21 +66,27 @@ class Lavatar
|
||||
* 0 // BLUE
|
||||
* )
|
||||
* @param int $_size = 128 image size, default size is 128
|
||||
* @param int $use_account_lid 0: use initials, >0 use this number of chars from account_lid
|
||||
*/
|
||||
public static function generate($_content = null, $_color = null, $_size = 128)
|
||||
public static function generate($_content = null, $_color = null, $_size = 128, int $use_account_lid=0)
|
||||
{
|
||||
// firstname
|
||||
$firstname = isset($_content['firstname'])? $_content['firstname'] : '';
|
||||
//lastname
|
||||
$lastname = isset($_content['lastname'])? $_content['lastname'] : '';
|
||||
// id
|
||||
$id = isset($_content['id'])? $_content['id']: '';
|
||||
$firstname = $_content['firstname'] ?? '';
|
||||
$lastname = $_content['lastname'] ?? '';
|
||||
$id = $_content['id'] ?? '';
|
||||
$account_lid = $_content['account_lid'] ?? '#'.$_content['id'] ?? '';
|
||||
|
||||
// Array of RGB color as background color
|
||||
$bgcolor = $_color ? $_color : self::_getBgColor($firstname.$lastname.$id);
|
||||
|
||||
// Letters to be shown
|
||||
$text = strtoupper(mb_substr($firstname, 0, 1).mb_substr($lastname, 0, 1));
|
||||
if ($use_account_lid)
|
||||
{
|
||||
$text = mb_strtoupper(mb_substr($account_lid, 0, $use_account_lid));
|
||||
}
|
||||
else
|
||||
{
|
||||
$text = mb_strtoupper(mb_substr($firstname, 0, 1).mb_substr($lastname, 0, 1));
|
||||
}
|
||||
|
||||
//create an image
|
||||
$image = imagecreatetruecolor($_size, $_size);
|
||||
@ -93,7 +100,7 @@ class Lavatar
|
||||
// create a rectangle
|
||||
imagefilledrectangle($image, 0, 0, $_size, $_size, $bg);
|
||||
|
||||
$fontsize = $_size / self::$_FONT_SIZE_RATIO;
|
||||
$fontsize = $_size / (1.1*$use_account_lid ?: self::$_FONT_SIZE_RATIO);
|
||||
|
||||
$box = imagettfbbox($fontsize, 0, EGW_SERVER_ROOT.self::$_FONT_PATH, $text);
|
||||
|
||||
|
@ -322,6 +322,17 @@ class preferences_hooks
|
||||
'admin' => False,
|
||||
'default' => 'lastname',
|
||||
),
|
||||
'avatar_display' => [
|
||||
'type' => 'select',
|
||||
'label' => 'What to display for an avatar, if there is no photo',
|
||||
'name' => 'avatar_display',
|
||||
'values' => [
|
||||
'0' => lang('Use initials from first and last name'),
|
||||
'2' => lang('Use first %1 letters from username', 2),
|
||||
'3' => lang('Use first %1 letters from username', 3),
|
||||
'4' => lang('Use first %1 letters from username', 4),
|
||||
],
|
||||
],
|
||||
'show_currentusers' => array(
|
||||
'type' => 'check',
|
||||
'label' => 'Show number of current users',
|
||||
|
@ -202,7 +202,10 @@ two factor auth is already setup. preferences de 2-Faktor-Authentifizierung ist
|
||||
unit of displayed font sizes: either "px" as used eg. for web-pages or "pt" as used in text processing. preferences de Einheit für angezeigte Schriftgrößen: entweder "px" wie z.B. bei Webseiten verwendet oder "pt" wie in der Textverarbeitung üblich
|
||||
uppercase letters preferences de Großbuchstaben
|
||||
use default preferences de Vorgabe benutzen
|
||||
use first %1 letters from username preferences de Benutze die ersten %1 Buchstaben des Benutzernamens
|
||||
use initials from first and last name preferences de Benutzer die Initialen von Vor- und Nachnamen
|
||||
users choice preferences de Benutzerauswahl
|
||||
what to display for an avatar, if there is no photo preferences de Was soll als Avatar angezeigt werden, wenn es kein Foto gibt
|
||||
when you can select multiple options, should the option list stay open until you close it, or close after you pick an option. preferences de Wenn Sie mehrere Optionen auswählen können, soll die Optionsliste geöffnet bleiben, bis Sie sie schließen, oder geschlossen werden, nachdem Sie eine Option ausgewählt haben.
|
||||
when you say yes the home and logout buttons are presented as applications in the main top applcation bar. preferences de Wenn Sie hier Ja auswählen, werden in der Hauptnavigationsleiste oben zusätzlich Buttons für die Startseite und zum Abmelden angezeigt.
|
||||
which charset should be used for the csv export. the system default is the charset of this egroupware installation. addressbook de Wählen Sie hier den Zeichensatz für den CSV Import/Export. Der Standard-Zeichensatz ist der Zeichensatz Ihrer EGroupware Installation.
|
||||
|
@ -202,7 +202,10 @@ two factor auth is already setup. preferences en Two Factor Auth is already setu
|
||||
unit of displayed font sizes: either "px" as used eg. for web-pages or "pt" as used in text processing. preferences en Unit of displayed font sizes: either "px" as used eg. for web-pages or "pt" as used in text processing.
|
||||
uppercase letters preferences en uppercase letters
|
||||
use default preferences en Use default
|
||||
use first %1 letters from username preferences en Use first %1 letters from username
|
||||
use initials from first and last name preferences en Use initials from first and last name
|
||||
users choice preferences en Users choice
|
||||
what to display for an avatar, if there is no photo preferences en What to display for an avatar, if there is no photo
|
||||
when you can select multiple options, should the option list stay open until you close it, or close after you pick an option. preferences en When you can select multiple options, should the option list stay open until you close it, or close after you pick an option.
|
||||
when you say yes the home and logout buttons are presented as applications in the main top applcation bar. preferences en Show Home and Logout buttons as applications in the top bar.
|
||||
which charset should be used for the csv export. the system default is the charset of this egroupware installation. addressbook en Select character set for the CSV import/export.
|
||||
|
Loading…
Reference in New Issue
Block a user