Add user placeholders into placeholder dialog

This commit is contained in:
nathan 2021-09-22 11:15:49 -06:00
parent 9239b86cd9
commit 704b6c6dc2
3 changed files with 43 additions and 27 deletions

View File

@ -273,7 +273,7 @@ class Merge extends Api\Storage\Merge
*
* Placeholders are grouped logically. Group key should have a user-friendly translation.
*/
public function get_placeholder_list()
public function get_placeholder_list($prefix = '')
{
$placeholders = [];
$group = 'contact';
@ -302,21 +302,21 @@ class Merge extends Api\Storage\Merge
case 'url':
$group = 'details';
}
$placeholders[$group]["{{" . $name . "}}"] = $label;
$placeholders[$group]["{{" . ($prefix ? $prefix . '/' : '') . $name . "}}"] = $label;
if($name == 'cat_id')
{
$placeholders[$group]["{{" . $name . "}}"] = lang('Category path');
$placeholders[$group]["{{" . ($prefix ? $prefix . '/' : '') . $name . "}}"] = lang('Category path');
}
}
// Correctly formatted address by country / preference
$placeholders['business']["{{adr_one_formatted}}"] = "Formatted business address";
$placeholders['private']["{{adr_two_formatted}}"] = "Formatted private address";
$placeholders['business']['{{' . ($prefix ? $prefix . '/' : '') . 'adr_one_formatted}}'] = "Formatted business address";
$placeholders['private']['{{' . ($prefix ? $prefix . '/' : '') . 'adr_two_formatted}}'] = "Formatted private address";
$group = 'customfields';
foreach($this->contacts->customfields as $name => $field)
{
$placeholders[$group]["{{" . $name . "}}"] = $field['label'];
$placeholders[$group]["{{" . ($prefix ? $prefix . '/' : '') . $name . "}}"] = $field['label'];
}
return $placeholders;
}

View File

@ -64,7 +64,7 @@ class Placeholder extends Etemplate\Widget
if(is_null($apps))
{
$apps = ['addressbook'];
$apps = ['addressbook', 'user'];
}
foreach($apps as $appname)
@ -73,7 +73,7 @@ class Placeholder extends Etemplate\Widget
switch($appname)
{
case 'user':
$list = $merge->get_user_replacement_list();
$list = $merge->get_user_placeholder_list();
break;
default:
$list = $merge->get_placeholder_list();

View File

@ -2590,34 +2590,50 @@ abstract class Merge
{
return array(
// Link to current entry
'link' => lang('URL of current record'),
'link/href' => lang('HTML link to the current record'),
'link/title' => lang('Link title of current record'),
'link' => lang('URL of current record'),
'link/href' => lang('HTML link to the current record'),
'link/title' => lang('Link title of current record'),
// Link system - linked entries
'links' => lang('Titles of any entries linked to the current record, excluding attached files'),
'links/href' => lang('HTML links to any entries linked to the current record, excluding attached files'),
'links/url' => lang('URLs of any entries linked to the current record, excluding attached files'),
'attachments' => lang('List of files linked to the current record'),
'links_attachments' => lang('Links and attached files'),
'links/[appname]' => lang('Links to specified application. Example: {{links/infolog}}'),
'links' => lang('Titles of any entries linked to the current record, excluding attached files'),
'links/href' => lang('HTML links to any entries linked to the current record, excluding attached files'),
'links/url' => lang('URLs of any entries linked to the current record, excluding attached files'),
'attachments' => lang('List of files linked to the current record'),
'links_attachments' => lang('Links and attached files'),
'links/[appname]' => lang('Links to specified application. Example: {{links/infolog}}'),
// General information
'date' => lang('Date'),
'user/n_fn' => lang('Name of current user, all other contact fields are valid too'),
'user/account_lid' => lang('Username'),
'date' => lang('Date'),
'user/n_fn' => lang('Name of current user, all other contact fields are valid too'),
'user/account_lid' => lang('Username'),
// Merge control
'pagerepeat' => lang('For serial letter use this tag. Put the content, you want to repeat between two Tags.'),
'label' => lang('Use this tag for addresslabels. Put the content, you want to repeat, between two tags.'),
'labelplacement' => lang('Tag to mark positions for address labels'),
'pagerepeat' => lang('For serial letter use this tag. Put the content, you want to repeat between two Tags.'),
'label' => lang('Use this tag for addresslabels. Put the content, you want to repeat, between two tags.'),
'labelplacement' => lang('Tag to mark positions for address labels'),
// Commands
'IF fieldname' => lang('Example {{IF n_prefix~Mr~Hello Mr.~Hello Ms.}} - search the field "n_prefix", for "Mr", if found, write Hello Mr., else write Hello Ms.'),
'NELF' => lang('Example {{NELF role}} - if field role is not empty, you will get a new line with the value of field role'),
'NENVLF' => lang('Example {{NENVLF role}} - if field role is not empty, set a LF without any value of the field'),
'LETTERPREFIX' => lang('Example {{LETTERPREFIX}} - Gives a letter prefix without double spaces, if the title is emty for example'),
'IF fieldname' => lang('Example {{IF n_prefix~Mr~Hello Mr.~Hello Ms.}} - search the field "n_prefix", for "Mr", if found, write Hello Mr., else write Hello Ms.'),
'NELF' => lang('Example {{NELF role}} - if field role is not empty, you will get a new line with the value of field role'),
'NENVLF' => lang('Example {{NENVLF role}} - if field role is not empty, set a LF without any value of the field'),
'LETTERPREFIX' => lang('Example {{LETTERPREFIX}} - Gives a letter prefix without double spaces, if the title is emty for example'),
'LETTERPREFIXCUSTOM' => lang('Example {{LETTERPREFIXCUSTOM n_prefix title n_family}} - Example: Mr Dr. James Miller'),
);
}
/**
* Get a list of placeholders for the current user
*/
public function get_user_placeholder_list($prefix = '')
{
$contacts = new Api\Contacts\Merge();
$replacements = $contacts->get_placeholder_list(($prefix ? $prefix . '/' : '') . 'user');
unset($replacements['details']['{{' . ($prefix ? $prefix . '/' : '') . 'user/account_id}}']);
$replacements['account'] = [
'{{' . ($prefix ? $prefix . '/' : '') . 'user/account_id}}' => 'Account ID',
'{{' . ($prefix ? $prefix . '/' : '') . 'user/account_lid}}' => 'Login ID'
];
return $replacements;
}
}