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.

 

 

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)

$set['defaultval'] =& $set['value'];

Name

Friendly Short Description (REQUIRED)

$set['name'] = 'Allow PRI Discrete Channels';

Description

Long Description for Tooltip (REQUIRED)

$set['description'] = 'DAHDi trunk configuration is normally done using groups for PRI configuration. If there is a need to configure trunks to specific channels, setting this to true will allow each channel to be configured. This can be useful when troubleshooting a PRI and trying to isolate a bad B Channel.';

Category

Category of the setting (REQUIRED)

$set['category'] = 'DAHDi Configuration Module';

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

$set['type'] = CONF_TYPE_BOOL;

Options

Category of the setting (REQUIRED if using _SELECT or _FSELECT)

$set['options'] = array('option1','option2');

Read Only

Setting is Ready Only. default: false (OPTIONAL)

$set['readonly'] = false;

Hidden

Setting is Hidden. default: false (OPTIONAL)

$set['readonly'] = false;

Level

 Visual level of setting, value can be used again. default: 0 (OPTIONAL)

$set['level'] = 1;

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)

$set['module'] = 'dahdiconfig';

Empty OK

If setting can be blank. default: true (OPTIONAL)

$set['emptyok'] = false;

Add The Advanced Setting

//function define_conf_setting($keyword,$vars,$commit=false) $freepbx_conf->define_conf_setting('UNQUIECONSTANTNAME',$set,true);

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()

if ($freepbx_conf->conf_setting_exists('UNQUIECONSTANTNAME')) {     $freepbx_conf->set_conf_values(array('UNQUIECONSTANTNAME' => true), true); }

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

$freepbx_conf->get_conf_setting('UNQUIECONSTANTNAME',true);

Get Default Value from install time

$freepbx_conf->get_conf_default_setting('UNQUIECONSTANTNAME');

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

$freepbx_conf->get('UNQUIECONSTANTNAME',true);