FreePBX API: Feature codes API
The feature codes API allows modules to create feature codes that are configured from the feature codes admin screen.
freepbx/trunk/amp_conf/htdocs/admin/featurecodes.class.php
Functions
Constructor
featurecode($modulename, $featurename)
eg.
$fcc = new featurecode('pbdirectory', 'app-pbdirectory');
update()
Saves changes to the database
setDescription($description)
Sets the description for this featurecode, shows up in feature code admin GUI.
getDescription()
Gets the current description
setDefault($deafultcode, $defaultenabled = false)
Sets the default. This is the value used until the user configures the code, or if the use default option is checked in the admin GUI.
The optional $defaultenabled parameter controls if the feature code is enabled or disabled by default (added in r2630)
getCodeActive()
Returns the code if it's been set, or (empty string) if it's not active.
getCode()
Returns the code as set by the user, or the default code. This function pays no attention to if it's active or not.
isEnabled()
Returns a boolean indicating if this code is enabled or not.
Example usage
To create the feature code, you have to create a new featurecode object:
install.php:
// Enable phonebook directory as a feature code
$fcc = new featurecode('pbdirectory', 'app-pbdirectory');
$fcc->setDescription('Phonebook dial-by-name directory');
$fcc->setDefault('411');
$fcc->update();
unset($fcc);
To actually use this code in the dialplan, you have t oread it again with featurecode::getCodeActive()
functions.inc.php, module_get_config():
$fcc = new featurecode('pbdirectory', 'app-pbdirectory');
$code = $fcc->getCodeActive();
unset($fcc);
if (!empty($code)) {
$ext->add('app-pbdirectory', $code, '', new ext_answer());
$ext->add('app-pbdirectory', $code, '', new ext_wait(1));
$ext->add('app-pbdirectory', $code, '', new ext_goto(1,'pbdirectory'));
}
