Mantis Logo
Mantis Manual
Manual
Development

Contributing
Coding Guidelines
CVS
Localization
Database
Roadmap
Configuration Variables


Partner Links


Configuration Variables
Last Modified: April 17, 2005 13:04PM
(1.0.0)
Description

Using Configuration Variables

Configuration variables are used to customize the operation and appearance
of MantisBT. They can take on any form (number, string, array or other valid
PHP structure).

The value of a config must be retrieved using config_get( variable_name_string ).
The function can also have optional parameters giving the default value,
specific project, and specific user. The return value will be "mixed", a
number, string, array, or object.

Adding Configuration Variables

When adding a configuration variable, there are three things to do:
  1. write the code that uses the variable
    All access to variables should be through config_get(). For example,
    $t_my_config = config_get( 'my_config' );
    All code will then use $t_my_config.

  2. define a default value for the variable
    The default value for the variable should be defined in "config_defaults_inc.php".
    This default will be used if nothing else can be found. Note that you can leave
    the variable undefined and use the default capabilities of config_get(). For
    example:
    $t_my_config = config_get( 'my_config', 0 );
    will set $t_my_config to 0 if it is not defined anywhere. This is more flexible,
    byt requires more care in coding as en error will result of the variable
    is not defined anywhere.

    Variables that are strings can be defined in terms of other configuration
    variables. The notation "%config%" is used to implement this. For example:

    If "table_prefix" = 'mantis', then 'test_table' = '%table_prefix%_test'
    will evaluate to 'mantis_test'.

  3. write code so that the user/administrator can view/change the variable
    For example, see code in manage_config_email_page.php and
    manage_config_email_set.php.

    The view page should have two purposes. For those with appropriate access,
    the page should have the options that the config variable could be set to.
    For those with lower priviledges, the page should display the configuration.
    In addition, a dropdown can be displayed to change who can adjust the
    configuration. This page should also display the context (specific project or
    user) for which the settings are being made.

    These pages are connected to the system through the function
    print_manage_config_menu() in core/html_api.php. This will create a second
    level configure menu.

    Once the new settings are created in the form, the form is submitted to the
    'set' page. This will validate and save the configurations.

Other Developer Notes
  • where variables are known to be site wide (global), you can use config_get_global()
    instead of config_get. This bypassed the table lookup.
  • some variables are known to be site wide (for example, table names). These are
    listed in a site wide configuration variable $g_global_settings. This is an
    array of patterns (PCRE) that are compared against the requested variable.
    If there is a match, the table lookup is bypassed.




User Contributed Notes
Configuration Variables
Add Notes About Notes
There are no user contributed notes for this page.
Last updated: Thu, 15 May 2008 - 12:04:03

Mantis @ SourceForge