function vtGetExpressionListJson($adb, $request)
{
    $moduleName = $request['modulename'];
    $ee = new VTModuleExpressionsManager($adb);
    $arr = $ee->expressionsForModule($moduleName);
    echo Zend_Json::encode($arr);
}
function vtJsonFields($adb, $request)
{
    $moduleName = $request['modulename'];
    $mem = new VTModuleExpressionsManager($adb);
    $expressionFields = $mem->expressionFields($moduleName);
    $fields = $mem->fields($moduleName);
    echo Zend_Json::encode(array('exprFields' => $expressionFields, 'moduleFields' => $fields));
}
function vtDeleteExpressionJson($adb, $request)
{
    $moduleName = $request['modulename'];
    $fieldName = $request['fieldname'];
    $mem = new VTModuleExpressionsManager($adb);
    $me = $mem->retrieve($moduleName);
    $me->remove($fieldName);
    $mem->save($me);
    echo Zend_Json::encode(array('status' => 'success'));
}
function vtSaveExpressionJson($adb, $request)
{
    $moduleName = $request['modulename'];
    $fieldName = $request['fieldname'];
    $expression = $request['expression'];
    $mem = new VTModuleExpressionsManager($adb);
    $me = $mem->retrieve($moduleName);
    $me->add($fieldName, $expression);
    if ($me->state == 'savable') {
        $mem->save($me);
        echo Zend_Json::encode(array('status' => 'success'));
    } else {
        echo Zend_Json::encode(array('status' => 'fail', 'message' => $me->message));
    }
}
function vtJsonFields($adb, $request)
{
    $mem = new VTModuleExpressionsManager($adb);
    $functions = $mem->expressionFunctions();
    echo Zend_Json::encode($functions);
}