Advanced Settings Class
Advanced Settings Class
The advanced settings class allows modules to add and/or remove settings from the Advanced Settings Page. Adding and Removing Advanced Settings is extremely easy.
- 1 Advanced Settings Class
- 1.1 First Steps
- 1.2 Adding/Updating Settings Parameters and Initial Values
- 1.2.1 Value
- 1.2.2 Default Value
- 1.2.3 Name
- 1.2.4 Description
- 1.2.5 Category
- 1.2.6 Type
- 1.2.7 Options
- 1.2.8 Read Only
- 1.2.9 Hidden
- 1.2.10 Level
- 1.2.11 Module
- 1.2.12 Empty OK
- 1.2.13 Add The Advanced Setting
- 1.3 Changing User Defined Values
- 1.4 Getting Values
First Steps
Inside any module simply add:
$freepbx_conf =& freepbx_conf::create(); |
Adding/Updating Settings Parameters and Initial Values
For each setting we want to add we will reset the $set variable and add an array of specific details for that setting
$set = array(); |
Value
Value of the setting (REQUIRED)
$set['value'] = false; |
Default Value
Same as value (REQUIRED)
Name
Friendly Short Description (REQUIRED)
Description
Long Description for Tooltip (REQUIRED)
Category
Category of the setting (REQUIRED)
Type
type of setting. (REQUIRED)
Can be one of these values:
CONF_TYPE_BOOL (Boolean (true/false))
CONF_TYPE_INT (Integer Textbox)
CONF_TYPE_TEXT (Textbox)
CONF_TYPE_DIR (Directory Path Textbox)
CONF_TYPE_SELECT
CONF_TYPE_FSELECT
Options
Category of the setting (REQUIRED if using _SELECT or _FSELECT)
Read Only
Setting is Ready Only. default: false (OPTIONAL)
Hidden
Setting is Hidden. default: false (OPTIONAL)
Level
Visual level of setting, value can be used again. default: 0 (OPTIONAL)
Module
module name that owns the setting and if the setting should only exist when the module is installed. If set, uninstalling the module will automatically remove this. (OPTIONAL)
Empty OK
If setting can be blank. default: true (OPTIONAL)
Add The Advanced Setting
Changing User Defined Values
The second parameter of set_conf_values is a boolean which determines if the value is committed to the database or set temporarily, if set to false you will need to run $freepbx_conf->commit_conf_settings()
Getting Values
Get The User Defined Value (Depreciated in FreePBX 12)
If the second parameter is true it forces the actual database variable to be fetched instead of the in-ram variable
Get Default Value from install time
Get The User Defined Value in FreePBX 12 (The old way still works)
If the second parameter is true it forces the actual database variable to be fetched instead of the in-ram variable