The article provides a guide on adding new expression functions inside the expression picker. Below you can find the necessary steps and considerations for integrating custom functions.
Note: Please consider the current implementations before proceeding.
The files you need to change are:
modules/com_vtiger_workflow/expression_functions/[file].php
Here, you have to define the logic of the function.
function __cb_functionname($arr) {
// Your Logic Here ...
}
__cb_
.$arr
, regardless of how many inputs your implementation actually has. As named, your input at this point is going to come as an array (of your parameters).strings.php
; if it's a math operation, it belongs to math.php
, etc. Your function can belong to any file in this directory, otherwise is highly advised to create a new one.modules/com_vtiger_workflow/expression_engine/VTExpressionEvaluater.inc
Here, you link the function with an abstract name. This referral name is going to be used in the expression picker.
$this->[category] = array(
...
'FunctionName' => '__cb_functionname'
)
modules/com_vtiger_workflow/expression_engine/VTExpressionsManager.inc
Here, you have to define the name and the declaration of the function as such:
public function expressionFunctions() {
global $adb;
return array(
...
'FunctionName' => 'FunctionName(parameters...)'
);
}
modules/com_vtiger_workflow/language/[lang].fndefs.php
This part has language support, and as such you would need to modify multiple files (ex. en_us.fndefs.php)
Here, you define the function help description as shown below.
Follow the previous examples, but the main line of logic is this:
'function name' => array( // see functions in modules/com_vtiger_workflow/expression_engine/VTExpressionsManager.inc
'name' => usually the same as the function name but may be different, will be shown to the user,
'desc' => description of the function,
'params' => parameters of the function, array(
array(
'name' => 'param name',
'type' => String | Boolean | Integer | Float | Date | DateTime | Multiple | Field,
'optional' => true/false,
'desc' => 'description of the parameter',
)
),
'categories' => array of categories the function belongs to
'examples' => array of one-line examples,
)
This is pretty much all you need. You can find an example commit here.