SF.net SVN: postfixadmin:[1303] trunk
Brought to you by:
christian_boltz,
gingerdog
From: <chr...@us...> - 2011-12-20 23:07:40
|
Revision: 1303 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=1303&view=rev Author: christian_boltz Date: 2011-12-20 23:07:34 +0000 (Tue, 20 Dec 2011) Log Message: ----------- 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 Modified Paths: -------------- trunk/config.inc.php trunk/model/AdminHandler.php trunk/model/AliasdomainHandler.php trunk/model/DomainHandler.php trunk/model/PFAHandler.php Modified: trunk/config.inc.php =================================================================== --- trunk/config.inc.php 2011-12-20 16:46:08 UTC (rev 1302) +++ trunk/config.inc.php 2011-12-20 23:07:34 UTC (rev 1303) @@ -230,7 +230,45 @@ } */ +/* + *_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. $CONF['aliases'] = '10'; Modified: trunk/model/AdminHandler.php =================================================================== --- trunk/model/AdminHandler.php 2011-12-20 16:46:08 UTC (rev 1302) +++ trunk/model/AdminHandler.php 2011-12-20 23:07:34 UTC (rev 1303) @@ -81,8 +81,6 @@ '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. Modified: trunk/model/AliasdomainHandler.php =================================================================== --- trunk/model/AliasdomainHandler.php 2011-12-20 16:46:08 UTC (rev 1302) +++ trunk/model/AliasdomainHandler.php 2011-12-20 23:07:34 UTC (rev 1303) @@ -49,8 +49,6 @@ $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) { Modified: trunk/model/DomainHandler.php =================================================================== --- trunk/model/DomainHandler.php 2011-12-20 16:46:08 UTC (rev 1302) +++ trunk/model/DomainHandler.php 2011-12-20 23:07:34 UTC (rev 1303) @@ -76,8 +76,6 @@ '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. Modified: trunk/model/PFAHandler.php =================================================================== --- trunk/model/PFAHandler.php 2011-12-20 16:46:08 UTC (rev 1302) +++ trunk/model/PFAHandler.php 2011-12-20 23:07:34 UTC (rev 1303) @@ -40,6 +40,12 @@ } $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(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |