Fix for template autoFill processing with "k" tokens, the attribute wasnt being selected to parse. Fixes #363

This commit is contained in:
Deon George 2025-07-17 21:57:57 +08:00
parent d90bc32887
commit 715fe92da4
2 changed files with 49 additions and 0 deletions

View File

@ -415,6 +415,7 @@ class Template
preg_match_all('/(\d+)/',trim($match_subst),$substrarray); preg_match_all('/(\d+)/',trim($match_subst),$substrarray);
$delimiter = ($match_delim === '') ? ' ' : preg_quote($match_delim); $delimiter = ($match_delim === '') ? ' ' : preg_quote($match_delim);
$result .= sprintf("%s = get_attribute('%s');\n",$match_attr,$match_attr);
$result .= sprintf(" %s = %s.split('%s')[%s];\n",$match_attr,$match_attr,$delimiter,$substrarray[1][0] ?? '0'); $result .= sprintf(" %s = %s.split('%s')[%s];\n",$match_attr,$match_attr,$delimiter,$substrarray[1][0] ?? '0');
} else { } else {

View File

@ -0,0 +1,48 @@
{
"title": "Generic: Mail Account",
"description": "New Mail Account",
"enabled": true,
"icon": "fa-at",
"rdn": "cn",
"regexp": "/^ou=.+,?/",
"objectclasses": [
"inetOrgPerson"
],
"attributes": {
"mail": {
"display": "Email (mail)",
"order": 1,
"onchange": [
"=autoFill(cn;%mail|0-0/k|@%)",
"=autoFill(description;%mail|1-0/k|@%)"
]
},
"givenName": {
"display": "First Name",
"onchange": [
"=autoFill(cn;%givenName% %sn/U%)",
"=autoFill(uid;%givenName|0-1/l%%sn/l%)"
],
"order": 3
},
"sn": {
"display": "Last Name",
"onchange": [
"=autoFill(cn;%givenName% %sn/U%)",
"=autoFill(uid;%givenName|0-1/l%%sn/l%)"
],
"order": 4
},
"cn": {
"display": "Common Name",
"readonly": true,
"order": 2
},
"description": {
"display": "Description",
"order": 5
}
}
}