# Module HowTo - Configuration options

There might be situations where you want to give the user the possibility to make general settings which are not useful to place on the account detail pages or profile editor.
Therefore LAM allows the modules to define their own configuration options. E.g. the posixAccount module uses this to define the ranges for the UIDs.
LAM will display your configuration options only if the user also selected your module.

## 1. Defining configuration options

First you have to define what options you want to offer the user. LAM will display all options in one fieldset for each module. Please notice that there will be no separation on account types if you module is suitable for different account types.
The configuration options are specified with get_configOptions() or meta['config_options'].
Example:
The posixGroup module offers three configuration options. The min/maximum values for GIDs and the password hash type.

/** * Returns meta data that is interpreted by parent class * * @return array array with meta data */ function get_metaData() { $return = array(); // configuration options $return['config_options']['group'] = array( array( array('kind' => 'text', 'text' => '<b>' . _('Minimum GID number') . " *: </b>"), array('kind' => 'input', 'name' => 'posixGroup_minGID', 'type' => 'text', 'size' => '10', 'maxlength' => '255'), array('kind' => 'text', 'value' => '&nbsp;'), array('kind' => 'text', 'text' => '<b>' . _('Maximum GID number') . " *: </b>"), array('kind' => 'input', 'name' => 'posixGroup_maxGID', 'type' => 'text', 'size' => '10', 'maxlength' => '255'), array('kind' => 'help', 'value' => 'minMaxGID')), array( array('kind' => 'text', 'text' => '<b>' . _("Password hash type") . ': &nbsp;</b>'), array('kind' => 'select', 'name' => 'posixGroup_pwdHash', 'size' => '1', 'options' => array("CRYPT", "SHA", "SSHA", "MD5", "SMD5", "PLAIN"), 'options_selected' => array('SSHA')), array('kind' => 'text', 'value' => '&nbsp;'), array('kind' => 'text', 'value' => '&nbsp;'), array('kind' => 'text', 'value' => '&nbsp;'), array('kind' => 'help', 'value' => 'pwdHash')) ); [...]

The min/maximum GID numbers are defined with simple text boxes. The password hash is selected with a drop down box and SSHA as default value.
You should make sure that the column count (here: 6) is the same for each row. Otherwise the configuration page might be badly rendered by the browser.

## 2. Checking user input

Probably you also want to check if the input data is syntactically correct.
The baseModule already provides different checks which can be activated with meta data. However you can also do the checking in the module.
Implementing the function check_configOptions() in your module will allow you to do the checks yourself. Basic checks can be defined with meta['config_checks'].
Example:
The posixGroup module only needs to check if the GID numbers are correct. The password hash type needs not to be checked as it is a selection.

/** * Returns meta data that is interpreted by parent class * * @return array array with meta data */ function get_metaData() { $return = array(); // configuration checks $return['config_checks']['group']['posixGroup_minGID'] = array ( 'type' => 'ext_preg', 'regex' => 'digit', 'required' => true, 'required_message' => $this->messages['gidNumber'][5], 'error_message' => $this->messages['gidNumber'][5]); $return['config_checks']['group']['posixGroup_maxGID'] = array ( 'type' => 'ext_preg', 'regex' => 'digit', 'required' => true, 'required_message' => $this->messages['gidNumber'][6], 'error_message' => $this->messages['gidNumber'][6]); $return['config_checks']['group']['cmpGID'] = array ( 'type' => 'int_greater', 'cmp_name1' => 'posixGroup_maxGID', 'cmp_name2' => 'posixGroup_minGID', 'error_message' => $this->messages['gidNumber'][7]); [...]

The type "ext_preg" means that the baseModule will use the get_preg() function in lib/account.inc for the syntax check. This function already contains regular expressions for the most common cases.
To check if the minimum GID is smaller than the maximum GID we define a check for the nonexistant option "cmpGID" and define it as optional. This will do the comparison check.