Menu

Custom_fields

Development (3)
Christian Boltz

From time to time we get requests for adding some fields in PostfixAdmin. Many of them are specific for one user and therefore don't end up in the official code.

This page describes what you can do yourself.

Policy for database changes

This policy is important to avoid that your custom fields conflict with any fields, tables or indexes we might add in future versions of PostfixAdmin.

Additional fields in existing tables

  • you can use any fieldname starting with "x_"
  • you can create indexes if needed - also prefix them with x_ (or tablename_x_ for PostgreSQL)
  • avoid creating unique indexes and foreign keys if possible (they could make scheme changes difficult)

Additional tables

  • use a table name starting with "x_"
  • within that table, you can use any field and index names you want
  • you might want to have the fields "created", "modified" and "active" (which exist in most PostfixAdmin tables)
  • you may also create unique keys inside your tables
  • if you use PostgreSQL, names for indexes and unique keys must start with "x_" (better: "x_tablename_")
  • avoid foreign keys to PostfixAdmin's default tables if possible.

Integrating the additional fields in PostfixAdmin

PostfixAdmin >= 3.0

  • create the additional fields or tables in your database
  • write a *_struct_hook() function (see the x_struct_admin_modify() example in config.inc.php) to integrate your custom fields in PostfixAdmin
  • enable that function in $CONF[*_struct_hook]

You can also use a *_struct_hook() function to change or remove existing fields.

PostfixAdmin 2.3.x and older

  • create the additional fields or tables in your database
  • edit the PHP scripts and the templates to add your custom fields

Related

Wiki: Home

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.