function webform_access_token_info in Webform 6.x
Same name and namespace in other branches
- 8.5 modules/webform_access/webform_access.tokens.inc \webform_access_token_info()
Implements hook_token_info().
File
- modules/
webform_access/ webform_access.tokens.inc, line 14 - Builds placeholder replacement tokens for webform access type.
Code
function webform_access_token_info() {
$types = [];
$types['webform_access'] = [
'name' => t('Webform access'),
'description' => t("Tokens related to webform access group types. <em>This token is only available to a Webform email handler's 'To', 'CC', and 'BCC' email recipents.</em>"),
'needs-data' => 'webform_access',
];
$tokens = [];
$webform_access = [];
$webform_access_types = WebformAccessType::loadMultiple();
$webform_access['type'] = [
'name' => t('All users and custom email addresses'),
'description' => t('The email addresses of all <strong>users</strong> and <strong>custom email addresses</strong> assigned to the current webform.'),
];
$webform_access['users'] = [
'name' => t('All users'),
'description' => t('The email addresses of all <strong>users</strong> assigned to the current webform.'),
];
$webform_access['emails'] = [
'name' => t('All custom email addresses'),
'description' => t('The email addresses of all <strong>custom email addresses</strong> assigned to the current webform.'),
];
$webform_access['admins'] = [
'name' => t('All adminstrators'),
'description' => t('The email addresses of all <strong>administrators</strong> assigned to the current webform.'),
];
$webform_access['all'] = [
'name' => t('All users, custom email addresses, and administrators'),
'description' => t('The email addresses of all <strong>users</strong>, <strong>custom email addresses</strong>, and <strong>administrators</strong> assigned to the current webform.'),
];
foreach ($webform_access_types as $webform_access_type_name => $webform_access_type) {
$t_args = [
'@label' => $webform_access_type
->label(),
];
$webform_access["type:{$webform_access_type_name}"] = [
'name' => t('@label (Users and custom email addresses)', $t_args),
'description' => t('The email addresses of <strong>users</strong> and <strong>custom email addresses</strong> assigned to the %title access type for the current webform.', [
'%title' => $webform_access_type
->label(),
]),
];
$webform_access["type:{$webform_access_type_name}:users"] = [
'name' => t('@label (Users)', $t_args),
'description' => t('The email addresses of <strong>users</strong> assigned to the %title access type for the current webform.', [
'%title' => $webform_access_type
->label(),
]),
];
$webform_access["type:{$webform_access_type_name}:emails"] = [
'name' => t('@label (Custom email addresses)', $t_args),
'description' => t('The email addresses of <strong>custom email addresses</strong> assigned to the %title access type for the current webform.', [
'%title' => $webform_access_type
->label(),
]),
];
$webform_access["type:{$webform_access_type_name}:admins"] = [
'name' => t('@label (Adminstrators)', $t_args),
'description' => t('The email addresses of <strong>administrators</strong> assigned to the %title access type for the current webform.', [
'%title' => $webform_access_type
->label(),
]),
];
$webform_access["type:{$webform_access_type_name}:all"] = [
'name' => t('@label ((Users, custom email addresses, Adminstrators)', $t_args),
'description' => t('The email addresses of <strong>users</strong>, <strong>custom email addresses</strong>, and <strong>administrators</strong> assigned to the %title access type for the current webform.', [
'%title' => $webform_access_type
->label(),
]),
];
}
$tokens['webform_access'] = $webform_access;
/****************************************************************************/
return [
'types' => $types,
'tokens' => $tokens,
];
}