From 715fe92da4d890fdb32cd7ee722857f3f0eb6346 Mon Sep 17 00:00:00 2001 From: Deon George Date: Thu, 17 Jul 2025 21:57:57 +0800 Subject: [PATCH] Fix for template autoFill processing with "k" tokens, the attribute wasnt being selected to parse. Fixes #363 --- app/Classes/Template.php | 1 + templates/mail_account.json | 48 +++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 templates/mail_account.json diff --git a/app/Classes/Template.php b/app/Classes/Template.php index 8798bb7f..debd24da 100644 --- a/app/Classes/Template.php +++ b/app/Classes/Template.php @@ -415,6 +415,7 @@ class Template preg_match_all('/(\d+)/',trim($match_subst),$substrarray); $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'); } else { diff --git a/templates/mail_account.json b/templates/mail_account.json new file mode 100644 index 00000000..6481ee01 --- /dev/null +++ b/templates/mail_account.json @@ -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 + } + } +}