Make $struct in the *Handler classes customizeable

config.inc.php:
- add $CONF['*_struct_hook'] to modify $struct in the *Handler classes

PFAHandler.php:
- call $CONF['*_struct_hook'] hook

AdminHandler.php, AliasdomainHandler.php, DomainHandler.php:
- remove now outdated TODO notes


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1303 a1433add-5e2c-0410-b055-b7f2511e0802
pull/2/head
Christian Boltz 13 years ago
parent 6eb7e9f794
commit 18b8564b64

@ -230,6 +230,44 @@ function maildir_name_hook($domain, $user) {
}
*/
/*
*_struct_hook - change, add or remove fields
If you need additional fields or want to change or remove existing fields,
you can write a hook function to modify $struct in the *Handler classes.
The edit form will automatically be updated according to the modified
$struct. The list page is not yet updated automatically.
You can define one hook function per class, named like the primary database
table of that class.
The hook function is called with $struct as parameter and must return the
modified $struct.
Note: Adding a field to $struct adds the handling of this field in
PostfixAdmin, but it does not create it in the database. You have to do
that yourself.
Please follow the naming policy for custom database fields and tables on
http://sourceforge.net/apps/mediawiki/postfixadmin/index.php?title=Custom_fields
to avoid clashes with future versions of PostfixAdmin.
See initStruct() in the *Handler class for the default $struct.
See pacol() in functions.inc.php for the available flags on each column.
Example:
function x_struct_admin_modify($struct) {
$struct['superadmin']['editable'] = 0; # make the 'superadmin' flag read-only
$struct['superadmin']['display_in_form'] = 0; # don't display the 'superadmin' flag in edit form
$struct['x_newfield'] = pacol( [...] ); # additional field 'x_newfield'
return $struct; # important!
}
$CONF['admin_struct_hook'] = 'x_struct_admin_modify';
*/
$CONF['admin_struct_hook'] = '';
$CONF['domain_struct_hook'] = '';
$CONF['alias_domain_struct_hook'] = '';
// Default Domain Values
// Specify your default values below. Quota in MB.

@ -81,8 +81,6 @@ class AdminHandler extends PFAHandler {
'created' => pacol( 0, 0, 1, 'ts', 'created' , '' ),
'modified' => pacol( 0, 0, 1, 'ts', 'pAdminList_domain_modified' , '' ), # obsoletes pAdminList_admin_modified
);
# TODO: hook to modify $this->struct
}
# messages used in various functions.

@ -49,8 +49,6 @@ class AliasdomainHandler extends PFAHandler {
$keys = array_keys($this->struct['alias_domain']['options']);
unset ($this->struct['target_domain']['options'][$keys[0]]);
}
# TODO: hook to modify $this->struct
}
public function init($id) {

@ -76,8 +76,6 @@ class DomainHandler extends PFAHandler {
'created' => pacol( 0, 0, 1, 'ts', 'created' , '' ),
'modified' => pacol( 0, 0, 1, 'ts', 'pAdminList_domain_modified' , '' ),
);
# TODO: hook to modify $this->struct
}
# messages used in various functions.

@ -40,6 +40,12 @@ class PFAHandler {
}
$this->initStruct();
$struct_hook = Config::read($this->db_table . '_struct_hook');
if ( $struct_hook != 'NO' && function_exists($struct_hook) ) {
$this->struct = $struct_hook($this->struct);
}
$this->initMsg();
}

Loading…
Cancel
Save