Add contact label preference in order to control displayed info for To/Cc/Bcc addresses when composing an email

This commit is contained in:
Hadi Nategh 2021-03-03 13:07:05 +01:00
parent f410c8fffe
commit d004c2dd36
2 changed files with 38 additions and 4 deletions

View File

@ -3585,6 +3585,9 @@ class mail_compose
$contacts_obj = new Api\Contacts();
$results = array();
$mailPrefs = $GLOBALS['egw_info']['user']['preferences']['mail'];
$contactLabelPref = !is_array($mailPrefs['contactLabel']) && !empty($mailPrefs['contactLabel']) ?
explode(',', $mailPrefs['contactLabel']) : $mailPrefs['contactLabel'];
// Add some matching mailing lists, and some groups, limited by config
if($include_lists)
@ -3655,10 +3658,10 @@ class mail_compose
if (method_exists($contacts_obj,'search'))
{
$contact['n_fn']='';
if (!empty($contact['n_prefix'])) $contact['n_fn'] = $contact['n_prefix'];
if (!empty($contact['n_given'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_given'];
if (!empty($contact['n_family'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_family'];
if (!empty($contact['org_name'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').'('.$contact['org_name'].')';
if (!empty($contact['n_prefix']) && (empty($contactLabelPref) || in_array('n_prefix', $contactLabelPref))) $contact['n_fn'] = $contact['n_prefix'];
if (!empty($contact['n_given']) && (empty($contactLabelPref) || in_array('n_given', $contactLabelPref))) $contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_given'];
if (!empty($contact['n_family']) && (empty($contactLabelPref) || in_array('n_family', $contactLabelPref))) $contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_family'];
if (!empty($contact['org_name']) && (empty($contactLabelPref) || in_array('org_name', $contactLabelPref))) $contact['n_fn'] .= ($contact['n_fn']?' ':'').'('.$contact['org_name'].')';
$contact['n_fn'] = str_replace(array(',','@'),' ',$contact['n_fn']);
}
else

View File

@ -451,6 +451,37 @@ class mail_hooks
8 => lang('Ident name')
),
'default' => 7
),
'contactLabel' => array(
'type' => 'taglist',
'label' => 'Contact label',
'help' => 'Defines what to show as contact label for added contact into To/Cc/Bcc when composing an email. Default is firstname lastname and empty means include eveything available.',
'name' => 'contactLabel',
'values' => '',
'attributes' => array(
'allowFreeEntries' => false,
'editModeEnabled' => false,
'autocomplete_url' => ' ',
'select_options' => array (
'n_prefix' => array (
'id' => 'n_prefix',
'label' => lang('Prefix'),
),
'n_given' => array (
'id' => 'n_given',
'label' => lang('First name')
),
'n_family' => array(
'id' => 'n_family',
'label' => lang('Last name')
),
'org_name' => array(
'id' => 'org_name',
'label' => lang('Organisation')
)
)
),
'default' => ['n_given','n_family']
)
);
if (!$GLOBALS['egw_info']['apps']['stylite']) unset($settingsArray['attachVCardAtCompose']);