allow users to configure a closure (anonymous function) as a *_struct_hook config setting as well

previously we required a named function, see #1069
This commit is contained in:
David Goodwin committed 2026-07-05 20:06:17 +01:00
1 parent 1b3db6bbd3
commit 97e17c41c1
2 files changed
+7 -1

No files matched your search

+5
View File
@@ -372,6 +372,11 @@ function maildir_name_hook($domain, $user) {
return $struct; # important!
}
$CONF['admin_struct_hook'] = 'x_struct_admin_modify';
You can also use e.g.
$CONF['admin_struct_hook'] = function($struct) { // logic
return $struct; }
);
*/
$CONF['admin_struct_hook'] = '';
$CONF['domain_struct_hook'] = '';
+2 -1
View File
@@ -239,8 +239,9 @@ abstract class PFAHandler
);
}
// default *_struct_hooks are empty strings
$struct_hook = Config::read($this->db_table . '_struct_hook');
if (!empty($struct_hook) && is_string($struct_hook) && $struct_hook != 'NO' && function_exists($struct_hook)) {
if (!empty($struct_hook) && $struct_hook != 'NO' && is_callable($struct_hook)) {
$this->struct = $struct_hook($this->struct);
}