Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • colemanw/form-processor
  • extensions/form-processor
  • JonGold/form-processor
  • noah/form-processor
  • ErikHommel/form-processor
  • BjoernE/form-processor
  • kainuk/form-processor
  • homotechsual/form-processor
  • miloskroulik/form-processor
  • artfulrobot/form-processor
  • ufundo/form-processor
  • mattwire/form-processor
  • justinfreeman/form-processor
  • ayduns/form-processor
  • fsnet/form-processor
  • erikbrouwer/form-processor
  • BettyDolfing/form-processor
  • marsh/form-processor
  • Edselopez/form-processor
  • brienne/form-processor-brienne
  • TheSmammy/form-processor
  • dotu/form-processor
  • semseysandor/form-processor
  • agilewarefj/form-processor
  • seamuslee/form-processor
  • jaapjansma/form-processor
  • partners/civicoop/sol/form-processor
  • simon.hermann/form-processor
  • partners/ixiam/form-processor
29 results
Show changes
Commits on Source (770)
Showing
with 4744 additions and 933 deletions
Version 1.3
===========
* Implemented the help text of an action on the edit action screen.
* Changed the implementation of the civicrm_container hook.
* Added a File type for handling the upload of files.
* Fix for converting Title into Name.
* Fixed issue with updating status with overridden.
* Added getoptions to the FormProcessor and FormProcessorDefaults API.
* Added a type with a list of weekdays
* Added field type for time
* Added field type for formatted decimal numbers
Version 1.2
===========
* Implemented the refactored action provider
* Removed the action provider for default data actions, all actions are now available at the default data.
* Added a Campaign Type
* Fixed bug with checking if input/action name already exists
**Importanted notices when you are updating**
* You have also to update the action provider extension
* When you have a _Create/Update Group_ action in your form processor you have to check that form processor
because this action has been renamed in the action provider extension.
Version 2.4.2 (not yet released)
============
Version 2.4.1
============
* Fixed issue with the try out tab header
* Fixed issue with changing custom options at the Custom Options input type.
Version 2.4.0
============
* Added clone functionality.
Version 2.3.2
============
* Fixed issue with order of price set options.
* Added handling of a break exception.
Version 2.3.1
============
* Fixed regression bug #92: TypeError: array_merge
Version 2.3.0
============
* Improvement to calculation functionality.
Version 2.2.1
============
* Fixed regression issue around using validation in the calculation.
Version 2.2.0
============
* Make use of the parameters of the actions in validation and calcuation. See #89 and !87
* Fixed regression with multi-value parameter mappings.
* Fixed #88 Removing a condition from an action not possible. See !84
* Fixed #90: export and import of calucate actions
* Fixed #91: Performance issue when saving and editing a form processor. See !89
Version 2.1.6
============
* Fixed issue price set options field type and in form processor calculation.
Version 2.1.5
============
* Added Price Set Option Field Type
* Added default values for input configuration.
Version 2.1.4
============
* Fixed issue with action: Stop Execution. Which did not behave correctly anymore.
* Removed a htmlentities modifier (not supported by Smarty5)
Version 2.1.3
============
* Fix for issue #82. Configuration of actions with multiple options did not work correctly anymore. Such Contact: Update Subscriptions.
* Fixed issue with compatibility with Smarty5.
Version 2.1.2
============
* Fix for issue #83. Option Group type and normalizing values.
Version 2.1.1
============
* Fixed minor issue around calculations
Version 2.1.0
============
* Save form processor when checking or unchecking of retrieval of default data.
* Fixed you have unsaved changes messages upon saving a form processor.
* Fixed issue with Yes/No option list type and value label 0 for the No.
* Added error handling in Date input type.
* Added possibility to remove of leading and trailing spaces at short text types.
* Added Formatted Inputs back to the mapping.
* Replace jQuery by CRM.$ so it also works with Joomla (the name of a forms processor can now be edited in Joomla, just as in Drupal)
* Refactor of Runner so that the retrieval of defaults also executes delayed actions
* Enable parameters with NULL values (before this release they were removed)
* Make multiple values possible for country, useful for custom fields
Version 2.0.11
============
* Fixed regression issue from #79. Where editring default data actions gives a fatal error.
Version 2.0.10
============
* Fixed issue with saving delays on default data, calculation and validation.
* Fixed issue with try out and validation of required fields during load defaults.
* Fixed issue 79: make function to get provider in configurationaction public so can be picked up by form hooks
* Fixed PHP 7 compatability. See #78 and !77. Thanks to @dotu
* Fixed issue with retrieval of defaults.
Version 2.0.9
============
* Make OptionValueType resilient to null values. See #76
* Fixed issue with Try out and retrieving of defaults. Defaults where retrieved when the form was submitted. Now the defaults are retrieved when the button Load is pressed.
* Accept a Blob as a valid datatype.
* Report on an Error from an action in the same way as an exception.
* Updated docs with new screen prints and info on try-out, import, export, validation and calculation.
* Do not check include in formatted parameters as default
* Fixed issue with adding validations to inputs.
* Fixed error when hitting cancel on validator. See #74
Version 2.0.8
============
* Fix for issue with retrieval of defaults where not all custom fields are visible.
Version 2.0.7
============
* Fixed tryout functionality.
Version 2.0.6
============
* Fixed issue when an input type does not exists anymore.
Version 2.0.5
============
* Fix for #70: Adding Custom Options field does not save values. See !72
Version 2.0.4
============
* Fixed regression bug during import.
Version 2.0.3
============
* Fixed issue with redirect.
Version 2.0.2
============
* Fixed regression bug. See #67
Version 2.0.1
============
* Add addFormsProcessorType to TypeFactory. This makes it possible that extensions can add their own types to the forms processor.
Version 2.0.0
============
* Added Contact Entity Type. Which is compatibile for retrieving contact entities from form builder.
* Added API version 4 entities for the form processor database tables.
* Added Dynamic Inputs functionality.
* Added an Event Price Input type. This input shows a list of price options for a given event. This input could be populated with retrieval
of default data.
* Added Calculation functionality. So that a form processor can do calculations on the input data and return this
to the calling application. For example on your remote webform you have an event signup form at which one can register for an event
and provide how many people are coming. This calculation functionality can then be used to calculated the total amount due and show this
to the user.
* Added API for retrieving the possible output fields of a form processor. `FormProcessorInstance`.`get_output`
with parameter `form_processor_name` will give a list of fields outputted by the form processor.
* The output of Send Everything is also restructured. Instead of returning array into an array (e.g. action[get_contact][id] = 123 ) it is now
a one dimensional array (e.f. action.get_contact.id = 123)
* New user interface
......@@ -4,16 +4,26 @@ use CRM_FormProcessor_ExtensionUtil as E;
class CRM_Admin_Page_AutomationFormProcessor extends CRM_Core_Page {
public function run() {
$loader = new \Civi\Angular\AngularLoader();
$loader->setModules(array('form_processor'));
$loader->setPageName('civicrm/admin/formprocessor');
\Civi::resources()->addSetting(array(
'crmApp' => array(
'defaultRoute' => 'formprocessors',
),
));
$loader->load();
parent::run();
$civiVersion = CRM_Core_BAO_Domain::version();
$this->assign('legacyTags',FALSE);
if(version_compare($civiVersion,'5.39.0','>=')) {
Civi::service('angularjs.loader')
->addModules('form_processor')
->useApp(['defaultRoute' => 'formprocessors']);
} else {
$loader = new \Civi\Angular\AngularLoader();
$loader->setModules(array('form_processor'));
$loader->setPageName('civicrm/admin/formprocessor');
\Civi::resources()->addSetting(array(
'crmApp' => array(
'defaultRoute' => 'formprocessors',
),
));
$loader->load();
$this->assign('legacyTags',TRUE);
}
parent::run();
}
}
......@@ -33,7 +33,7 @@ class CRM_FormProcessor_BAO_FormProcessorAction extends CRM_FormProcessor_DAO_Fo
while ($action->fetch()) {
$row = [];
self::storeValues($action, $row);
if (!empty($row['form_processor_instance_id'])) {
if (!empty($row['form_processor_id'])) {
if (isset($row['configuration']) && is_string($row['configuration'])) {
$row['configuration'] = json_decode($row['configuration'], TRUE);
}
......@@ -91,6 +91,10 @@ class CRM_FormProcessor_BAO_FormProcessorAction extends CRM_FormProcessor_DAO_Fo
throw new Exception('Params can not be empty when adding or updating a form processor action');
}
if (empty($params['id']) && empty($params['weight'])) {
$params['weight'] = \CRM_Core_DAO::singleValueQuery("SELECT COUNT(*) + 1 FROM `".self::getTableName()."` WHERE `form_processor_id` = %1", [1=>[$params['form_processor_id'], 'Integer']]);
}
if (!empty($params['id'])) {
CRM_Utils_Hook::pre('edit', 'FormProcessorAction', $params['id'], $params);
}
......@@ -106,16 +110,23 @@ class CRM_FormProcessor_BAO_FormProcessorAction extends CRM_FormProcessor_DAO_Fo
}
}
if (is_array($action->configuration)) {
if (isset($action->configuration) && is_array($action->configuration)) {
$action->configuration = json_encode($action->configuration);
}
if (is_array($action->mapping)) {
if (isset ($action->mapping) && is_array($action->mapping)) {
$action->validateSavedMapping();
$action->mapping = json_encode($action->mapping);
}
if (is_array($action->condition_configuration)) {
$action->condition_configuration = json_encode($action->condition_configuration);
if (isset($action->condition_configuration) && is_array($action->condition_configuration)) {
// Delete condition if set to "No condition".
if ($action->condition_configuration['name']) {
$action->condition_configuration = json_encode($action->condition_configuration);
}
else {
$action->condition_configuration = '';
}
}
if (is_array($action->delay_configuration)) {
if (isset($action->delay_configuration) && is_array($action->delay_configuration)) {
$action->delay_configuration = json_encode($action->delay_configuration);
}
$action->save();
......@@ -161,14 +172,14 @@ class CRM_FormProcessor_BAO_FormProcessorAction extends CRM_FormProcessor_DAO_Fo
/**
* Function to delete all actions with a form processor instance id
*
* @param int $formProcessorInstanceId
* @param int $formProcessorId
*
* @access public
* @static
*/
public static function deleteWithFormProcessorInstanceId($formProcessorInstanceId) {
public static function deleteWithFormProcessorInstanceId(int $formProcessorId) {
$action = new CRM_FormProcessor_BAO_FormProcessorAction();
$action->form_processor_instance_id = $formProcessorInstanceId;
$action->form_processor_id = $formProcessorId;
$action->find(FALSE);
while ($action->fetch()) {
self::deleteWithId($action->id);
......@@ -176,44 +187,98 @@ class CRM_FormProcessor_BAO_FormProcessorAction extends CRM_FormProcessor_DAO_Fo
}
/**
* Public function to generate name from title
*
* @param $title
*
* @return string
* @access public
* @static
* Ensure that all the mapping values are valid (e.g. field exists, input exists) before writing to db.
*/
public static function buildNameFromTitle($title) {
$titleParts = explode(' ', strtolower($title));
$nameString = implode('_', $titleParts);
return substr($nameString, 0, 80);
private function validateSavedMapping() : void {
$actionProvider = form_processor_get_action_provider();
$actionClass = $actionProvider->getActionByName($this->type);
if (!$actionClass) {
// Action class could not be found.
// This could be the case during the import of a form processor
// with custom actions.
return;
}
$specificationBag = $actionClass->getParameterSpecification();
$validInputNames = array_column(CRM_FormProcessor_BAO_FormProcessorInput::getValues(['form_processor_id' => $this->form_processor_id]), 'name');
foreach ($this->mapping as $key => $value) {
// First make sure this mapping is still valid (e.g. field hasn't been deleted).
$spec = $specificationBag->getSpecificationByName($key);
if (!$spec) {
unset($this->mapping[$key]);
continue;
}
// Now make sure the inputs are still deleted (e.g. haven't been deleted).
if ($spec->isMultiple()) {
$valueArray = is_array($value) ? $value : explode(',', $value);
foreach ($valueArray as $k => $singleValue) {
$inputTypeAndName = explode('.', $singleValue);
if (!empty($inputTypeAndName[0]) && $inputTypeAndName[0] === 'input' && !empty($inputTypeAndName[1]) && !in_array($inputTypeAndName[1], $validInputNames)) {
unset($valueArray[$k]);
}
}
$this->mapping[$key] = $value;
}
elseif (!empty($value)) {
$inputTypeAndName = explode('.', $value);
if (!empty($inputTypeAndName[0]) && $inputTypeAndName[0] === 'input' && !empty($inputTypeAndName[1]) && !in_array($inputTypeAndName[1], $validInputNames)) {
$this->mapping[$key] = '';
}
}
}
}
public static function checkName($title, $form_processor_id, $id=null,$name=null): string {
if (!$name) {
$name = preg_replace('@[^a-z0-9_]+@','_',strtolower($title));
}
$name = preg_replace('@[^a-z0-9_]+@','_',strtolower($name));
$name_part = $name;
$sql = "SELECT COUNT(*) FROM `civicrm_form_processor_action` WHERE `name` = %1 AND `form_processor_id` = %2";
$sqlParams[1] = array($name, 'String');
$sqlParams[2] = array($form_processor_id, 'String');
if (isset($id)) {
$sql .= " AND `id` != %3";
$sqlParams[3] = array($id, 'Integer');
}
$i = 1;
while(CRM_Core_DAO::singleValueQuery($sql, $sqlParams) > 0) {
$i++;
$name = $name_part .'_'.$i;
$sqlParams[1] = array($name, 'String');
}
return $name;
}
/**
* Returns whether the name is valid or not
*
* @param string $name
* @param int $form_processor_instance_id
* @param int $id optional
* Returns an array with all the fields available for parameter mapping
*
* @return bool
* @static
* @param $form_processor_id
* @param int|null $id
* @param bool $onlyInputs
* @param bool $skipInputs
* @return array
*/
public static function isNameValid($name, $form_processor_instance_id, $id = NULL) {
if (empty($form_processor_instance_id)) {
return true;
}
$sql = "SELECT COUNT(*) FROM `civicrm_form_processor_action` WHERE `name` = %1 AND `form_processor_instance_id` = %2";
$params[1] = [$name, 'String'];
$params[2] = [$form_processor_instance_id, 'Integer'];
if ($id) {
$sql .= " AND `id` != %3";
$params[3] = [$id, 'Integer'];
public static function getFieldsForMapping($actionProvider, int $form_processor_id, int $id=null, $onlyInputs = false, $skipInputs = false): array {
$return = [];
if (!$skipInputs) {
$inputs = CRM_FormProcessor_BAO_FormProcessorInput::getValues(['form_processor_id' => $form_processor_id]);
$return = \Civi\FormProcessor\Runner::getFormProcessorInputMapping('input', $inputs);
}
$count = CRM_Core_DAO::singleValueQuery($sql, $params);
return ($count > 0) ? FALSE : TRUE;
}
$return = array_merge($return, \Civi\FormProcessor\Runner::getFormattedMapping());
if (!$onlyInputs) {
$validateActions = CRM_FormProcessor_BAO_FormProcessorValidateAction::getValues(['form_processor_id' => $form_processor_id]);
$calculateActions = CRM_FormProcessor_BAO_FormProcessorCalculateAction::getValues(['form_processor_id' => $form_processor_id]);
$actions = CRM_FormProcessor_BAO_FormProcessorAction::getValues(['form_processor_id' => $form_processor_id]);
$return = array_merge($return, \Civi\FormProcessor\Runner::getActionMapping('validation', E::ts('Validation Action'), $validateActions, $actionProvider, $id));
$return = array_merge($return, \Civi\FormProcessor\Runner::getActionMapping('calculation', E::ts('Calculation Action'), $calculateActions, $actionProvider, $id));
$return = array_merge($return, \Civi\FormProcessor\Runner::getActionMapping('action', E::ts('Action'), $actions, $actionProvider, $id));
}
return $return;
}
}
\ No newline at end of file
}
<?php
use CRM_FormProcessor_ExtensionUtil as E;
/**
* @author Jaap Jansma (CiviCooP) <jaap.jansma@civicoop.org>
* @license http://www.gnu.org/licenses/agpl-3.0.html
*/
class CRM_FormProcessor_BAO_FormProcessorCalculateAction extends CRM_FormProcessor_DAO_FormProcessorCalculateAction {
/**
* Function to get values
*
* @return array $result found rows with data
* @access public
* @static
*/
public static function getValues($params) {
$result = array();
$action = new CRM_FormProcessor_BAO_FormProcessorCalculateAction();
if (!empty($params)) {
$fields = self::fields();
foreach ($params as $key => $value) {
if (isset($fields[$key])) {
$action->$key = $value;
}
}
}
$action->orderBy('weight');
$action->find();
while ($action->fetch()) {
$row = array();
self::storeValues($action, $row);
if (!empty($row['form_processor_id'])) {
if (isset($row['configuration']) && is_string($row['configuration'])) {
$row['configuration'] = json_decode($row['configuration'], TRUE);
}
if (empty($row['configuration']) || !is_array($row['configuration'])) {
$row['configuration'] = array();
}
if (isset($row['mapping']) && is_string($row['mapping'])) {
$row['mapping'] = json_decode($row['mapping'], true);
}
if (empty($row['mapping']) || !is_array($row['mapping'])) {
$row['mapping'] = array();
}
if (isset($row['condition_configuration']) && is_string($row['condition_configuration'])) {
$row['condition_configuration'] = json_decode($row['condition_configuration'], TRUE);
}
if (empty($row['condition_configuration']) || !is_array($row['condition_configuration'])) {
$row['condition_configuration'] = null;
}
if (isset($row['delay_configuration']) && is_string($row['delay_configuration'])) {
$row['delay_configuration'] = json_decode($row['delay_configuration'], TRUE);
}
$result[$row['id']] = $row;
} else {
//invalid input because no there is no form processor
CRM_FormProcessor_BAO_FormProcessorCalculateAction::deleteWithId($row['id']);
}
}
return $result;
}
/**
* Function to add or update form processor action
*
* @param array $params
* @return array $result
* @access public
* @throws Exception when params is empty
* @static
*/
public static function add($params) {
$result = array();
if (empty($params)) {
throw new Exception('Params can not be empty when adding or updating a form processor action');
}
if (empty($params['id']) && empty($params['weight'])) {
$params['weight'] = \CRM_Core_DAO::singleValueQuery("SELECT COUNT(*) + 1 FROM `".self::getTableName()."` WHERE `form_processor_id` = %1", [1=>[$params['form_processor_id'], 'Integer']]);
}
if (!empty($params['id'])) {
CRM_Utils_Hook::pre('edit', 'FormProcessorCalculateAction', $params['id'], $params);
}
else {
CRM_Utils_Hook::pre('create', 'FormProcessorCalculateAction', NULL, $params);
}
$action = new CRM_FormProcessor_BAO_FormProcessorCalculateAction();
$fields = self::fields();
foreach ($params as $key => $value) {
if (isset($fields[$key])) {
$action->$key = $value;
}
}
if (isset($action->configuration) && is_array($action->configuration)) {
$action->configuration = json_encode($action->configuration);
}
if (isset ($action->mapping) && is_array($action->mapping)) {
$action->validateSavedMapping();
$action->mapping = json_encode($action->mapping);
}
if (isset($action->condition_configuration) && is_array($action->condition_configuration)) {
// Delete condition if set to "No condition".
if ($action->condition_configuration['name']) {
$action->condition_configuration = json_encode($action->condition_configuration);
}
else {
$action->condition_configuration = '';
}
}
if (isset($action->delay_configuration) && is_array($action->delay_configuration)) {
$action->delay_configuration = json_encode($action->delay_configuration);
}
$action->save();
self::storeValues($action, $result);
if (!empty($params['id'])) {
CRM_Utils_Hook::post('edit', 'FormProcessorCalculateAction', $action->id, $action);
}
else {
CRM_Utils_Hook::post('create', 'FormProcessorCalculateAction', $action->id, $action);
}
return $result;
}
/**
* Function to delete a form processor action with id
*
* @param int $id
* @throws Exception when $id is empty
* @access public
* @static
*/
public static function deleteWithId($id) {
if (empty($id)) {
throw new Exception('id can not be empty when attempting to delete a form processor action');
}
CRM_Utils_Hook::pre('delete', 'FormProcessorCalculateAction', $id, CRM_Core_DAO::$_nullArray);
$action = new CRM_FormProcessor_BAO_FormProcessorCalculateAction();
$action->id = $id;
if ($action->find(true)) {
$action->delete();
}
CRM_Utils_Hook::post('delete', 'FormProcessorCalculateAction', $id, CRM_Core_DAO::$_nullArray);
}
/**
* Function to delete all actions with a form processor instance id
*
* @param int $formProcessorId
* @access public
* @static
*/
public static function deleteWithFormProcessorInstanceId($formProcessorId) {
$action = new CRM_FormProcessor_BAO_FormProcessorCalculateAction();
$action->form_processor_id = $formProcessorId;
$action->find(FALSE);
while ($action->fetch()) {
self::deleteWithId($action->id);
}
}
public static function checkName($title, $form_processor_id, $id=null,$name=null): string {
if (!$name) {
$name = preg_replace('@[^a-z0-9_]+@','_',strtolower($title));
}
$name = preg_replace('@[^a-z0-9_]+@','_',strtolower($name));
$name_part = $name;
$sql = "SELECT COUNT(*) FROM `civicrm_form_processor_calculate_action` WHERE `name` = %1 AND `form_processor_id` = %2";
$sqlParams[1] = array($name, 'String');
$sqlParams[2] = array($form_processor_id, 'String');
if (isset($id)) {
$sql .= " AND `id` != %3";
$sqlParams[3] = array($id, 'Integer');
}
$i = 1;
while(CRM_Core_DAO::singleValueQuery($sql, $sqlParams) > 0) {
$i++;
$name = $name_part .'_'.$i;
$sqlParams[1] = array($name, 'String');
}
return $name;
}
/**
* Returns an array with all the fields available for parameter mapping
*
* @param $form_processor_id
* @param int|null $id
* @param bool $onlyInputs
* @param bool $skipInputs
* @return array
*/
public static function getFieldsForMapping($actionProvider, int $form_processor_id, int $id=null, $onlyInputs = false, $skipInputs = false): array {
$return = [];
if (!$skipInputs) {
$inputs = CRM_FormProcessor_BAO_FormProcessorInput::getValues(['form_processor_id' => $form_processor_id]);
$return = \Civi\FormProcessor\Runner::getFormProcessorInputMapping('input', $inputs);
}
$return = array_merge($return, \Civi\FormProcessor\Runner::getFormattedMapping());
if (!$onlyInputs) {
$validateActions = CRM_FormProcessor_BAO_FormProcessorValidateAction::getValues(['form_processor_id' => $form_processor_id]);
$calculateActions = CRM_FormProcessor_BAO_FormProcessorCalculateAction::getValues(['form_processor_id' => $form_processor_id]);
$return = array_merge($return, \Civi\FormProcessor\Runner::getActionMapping('validation', E::ts('Validation Action'), $validateActions, $actionProvider, $id));
$return = array_merge($return, \Civi\FormProcessor\Runner::getActionMapping('action', E::ts('Calculation Action'), $calculateActions, $actionProvider, $id));
}
return $return;
}
}
<?php
use Civi\ActionProvider\Parameter\SpecificationBag;
use Civi\ActionProvider\Parameter\SpecificationGroup;
use Civi\ActionProvider\Parameter\SpecificationInterface;
use CRM_FormProcessor_ExtensionUtil as E;
/**
......@@ -7,10 +10,10 @@ use CRM_FormProcessor_ExtensionUtil as E;
* @license http://www.gnu.org/licenses/agpl-3.0.html
*/
class CRM_FormProcessor_BAO_FormProcessorDefaultDataAction extends CRM_FormProcessor_DAO_FormProcessorDefaultDataAction {
/**
/**
* Function to get values
*
*
* @return array $result found rows with data
* @access public
* @static
......@@ -26,12 +29,12 @@ class CRM_FormProcessor_BAO_FormProcessorDefaultDataAction extends CRM_FormProce
}
}
}
$action->orderBy('weight');
$action->orderBy('weight');
$action->find();
while ($action->fetch()) {
$row = array();
self::storeValues($action, $row);
if (!empty($row['form_processor_instance_id'])) {
if (!empty($row['form_processor_id'])) {
if (isset($row['configuration']) && is_string($row['configuration'])) {
$row['configuration'] = json_decode($row['configuration'], TRUE);
}
......@@ -51,6 +54,9 @@ class CRM_FormProcessor_BAO_FormProcessorDefaultDataAction extends CRM_FormProce
if (empty($row['condition_configuration']) || !is_array($row['condition_configuration'])) {
$row['condition_configuration'] = null;
}
if (isset($row['delay_configuration']) && is_string($row['delay_configuration'])) {
$row['delay_configuration'] = json_decode($row['delay_configuration'], TRUE);
}
$result[$row['id']] = $row;
} else {
......@@ -63,8 +69,8 @@ class CRM_FormProcessor_BAO_FormProcessorDefaultDataAction extends CRM_FormProce
/**
* Function to add or update form processor action
*
* @param array $params
*
* @param array $params
* @return array $result
* @access public
* @throws Exception when params is empty
......@@ -75,14 +81,18 @@ class CRM_FormProcessor_BAO_FormProcessorDefaultDataAction extends CRM_FormProce
if (empty($params)) {
throw new Exception('Params can not be empty when adding or updating a form processor action');
}
if (!empty($params['id'])) {
if (empty($params['id']) && empty($params['weight'])) {
$params['weight'] = \CRM_Core_DAO::singleValueQuery("SELECT COUNT(*) + 1 FROM `".self::getTableName()."` WHERE `form_processor_id` = %1", [1=>[$params['form_processor_id'], 'Integer']]);
}
if (!empty($params['id'])) {
CRM_Utils_Hook::pre('edit', 'FormProcessorDefaultDataAction', $params['id'], $params);
}
else {
CRM_Utils_Hook::pre('create', 'FormProcessorDefaultDataAction', NULL, $params);
}
$action = new CRM_FormProcessor_BAO_FormProcessorDefaultDataAction();
$fields = self::fields();
foreach ($params as $key => $value) {
......@@ -91,31 +101,41 @@ class CRM_FormProcessor_BAO_FormProcessorDefaultDataAction extends CRM_FormProce
}
}
if (is_array($action->configuration)) {
$action->configuration = json_encode($action->configuration);
}
if (is_array($action->mapping)) {
$action->mapping = json_encode($action->mapping);
}
if (is_array($action->condition_configuration)) {
$action->condition_configuration = json_encode($action->condition_configuration);
if (isset($action->configuration) && is_array($action->configuration)) {
$action->configuration = json_encode($action->configuration);
}
if (isset ($action->mapping) && is_array($action->mapping)) {
$action->validateSavedMapping();
$action->mapping = json_encode($action->mapping);
}
if (isset($action->condition_configuration) && is_array($action->condition_configuration)) {
// Delete condition if set to "No condition".
if ($action->condition_configuration['name']) {
$action->condition_configuration = json_encode($action->condition_configuration);
}
else {
$action->condition_configuration = '';
}
}
if (isset($action->delay_configuration) && is_array($action->delay_configuration)) {
$action->delay_configuration = json_encode($action->delay_configuration);
}
$action->save();
self::storeValues($action, $result);
if (!empty($params['id'])) {
if (!empty($params['id'])) {
CRM_Utils_Hook::post('edit', 'FormProcessorDefaultDataAction', $action->id, $action);
}
else {
CRM_Utils_Hook::post('create', 'FormProcessorDefaultDataAction', $action->id, $action);
}
return $result;
}
/**
* Function to delete a form processor action with id
*
*
* @param int $id
* @throws Exception when $id is empty
* @access public
......@@ -125,73 +145,105 @@ class CRM_FormProcessor_BAO_FormProcessorDefaultDataAction extends CRM_FormProce
if (empty($id)) {
throw new Exception('id can not be empty when attempting to delete a form processor action');
}
CRM_Utils_Hook::pre('delete', 'FormProcessorDefaultDataAction', $id, CRM_Core_DAO::$_nullArray);
CRM_Utils_Hook::pre('delete', 'FormProcessorDefaultDataAction', $id, CRM_Core_DAO::$_nullArray);
$action = new CRM_FormProcessor_BAO_FormProcessorDefaultDataAction();
$action->id = $id;
if ($action->find(true)) {
$action->delete();
}
CRM_Utils_Hook::post('delete', 'FormProcessorDefaultDataAction', $id, CRM_Core_DAO::$_nullArray);
CRM_Utils_Hook::post('delete', 'FormProcessorDefaultDataAction', $id, CRM_Core_DAO::$_nullArray);
return;
}
/**
/**
* Function to delete all actions with a form processor instance id
*
* @param int $formProcessorInstanceId
* @param int $formProcessorId
* @access public
* @static
*/
public static function deleteWithFormProcessorInstanceId($formProcessorInstanceId) {
public static function deleteWithFormProcessorInstanceId($formProcessorId) {
$action = new CRM_FormProcessor_BAO_FormProcessorDefaultDataAction();
$action->form_processor_instance_id = $formProcessorInstanceId;
$action->form_processor_id = $formProcessorId;
$action->find(FALSE);
while ($action->fetch()) {
self::deleteWithId($action->id);
}
}
/**
* Public function to generate name from title
public static function checkName($title, $form_processor_id, $id=null,$name=null): string {
if (!$name) {
$name = preg_replace('@[^a-z0-9_]+@','_',strtolower($title));
}
$name = preg_replace('@[^a-z0-9_]+@','_',strtolower($name));
$name_part = $name;
$sql = "SELECT COUNT(*) FROM `civicrm_form_processor_default_data_action` WHERE `name` = %1 AND `form_processor_id` = %2";
$sqlParams[1] = array($name, 'String');
$sqlParams[2] = array($form_processor_id, 'String');
if (isset($id)) {
$sql .= " AND `id` != %3";
$sqlParams[3] = array($id, 'Integer');
}
$i = 1;
while(CRM_Core_DAO::singleValueQuery($sql, $sqlParams) > 0) {
$i++;
$name = $name_part .'_'.$i;
$sqlParams[1] = array($name, 'String');
}
return $name;
}
/**
* Returns an array with all the fields available for parameter mapping
*
* @param $title
* @return string
* @access public
* @static
* @param $form_processor_id
* @param int|null $id
* @param bool $onlyInputs
* @param bool $skipInputs
* @return array
*/
public static function buildNameFromTitle($title) {
$titleParts = explode(' ', strtolower($title));
$nameString = implode('_', $titleParts);
return substr($nameString, 0, 80);
public static function getFieldsForMapping($actionProvider, int $form_processor_id, int $id=null, $onlyInputs = false, $skipInputs = false): array {
$return = [];
if (!$skipInputs) {
$inputs = CRM_FormProcessor_BAO_FormProcessorDefaultDataInput::getValues(['form_processor_id' => $form_processor_id]);
$return = \Civi\FormProcessor\Runner::getFormProcessorInputMapping('input', $inputs);
}
$return = array_merge($return, \Civi\FormProcessor\Runner::getFormattedMapping());
if (!$onlyInputs) {
$actions = CRM_FormProcessor_BAO_FormProcessorDefaultDataAction::getValues(['form_processor_id' => $form_processor_id]);
$return = array_merge($return, \Civi\FormProcessor\Runner::getActionMapping('action', E::ts('Action'), $actions, $actionProvider, $id));
}
return $return;
}
/**
* Returns whether the name is valid or not
*
* @param string $name
* @param int $form_processor_instance_id
* @param int $id optional
* @return bool
* @static
*/
public static function isNameValid($name, $form_processor_instance_id, $id=null) {
if (empty($form_processor_instance_id)) {
return true;
}
$sql = "SELECT COUNT(*) FROM `civicrm_form_processor_default_data_action` WHERE `name` = %1 AND `form_processor_instance_id` = %2";
$params[1] = [$name, 'String'];
$params[2] = [$form_processor_instance_id, 'Integer'];
if ($id) {
$sql .= " AND `id` != %3";
$params[3] = array($id, 'Integer');
}
$count = CRM_Core_DAO::singleValueQuery($sql, $params);
return ($count > 0) ? false : true;
}
}
\ No newline at end of file
/**
* @param array $mapping
* @param string $namePrefix
* @param string $titlePrefix
* @param \Civi\ActionProvider\Parameter\SpecificationInterface $specification
*
* @return array
*/
public static function addFieldsFromSpecificationToMapping(array $mapping, string $namePrefix, string $titlePrefix, SpecificationInterface $specification): array {
if ($specification instanceof SpecificationGroup) {
foreach ($specification->getSpecificationBag() as $subSpec) {
$mapping = self::addFieldsFromSpecificationToMapping($mapping, $namePrefix, $titlePrefix, $subSpec);
}
} else {
$mapping[$namePrefix . $specification->getName()] = $titlePrefix . $specification->getTitle();
}
return $mapping;
}
}
......@@ -7,10 +7,10 @@ use CRM_FormProcessor_ExtensionUtil as E;
* @license http://www.gnu.org/licenses/agpl-3.0.html
*/
class CRM_FormProcessor_BAO_FormProcessorDefaultDataInput extends CRM_FormProcessor_DAO_FormProcessorDefaultDataInput {
/**
/**
* Function to get values
*
*
* @return array $result found rows with data
* @access public
* @static
......@@ -26,30 +26,44 @@ class CRM_FormProcessor_BAO_FormProcessorDefaultDataInput extends CRM_FormProces
}
}
}
$input->orderBy('weight');
$input->find();
while ($input->fetch()) {
$row = array();
self::storeValues($input, $row);
if (!empty($row['form_processor_instance_id'])) {
$type = \Civi::service('form_processor_type_factory')->getTypeByName($row['type']);
if ($type) {
$configuration = $type->getDefaultConfiguration();
if (isset($row['configuration']) && is_string($row['configuration'])) {
$row['configuration'] = json_decode($row['configuration'], true);
}
if (empty($row['configuration']) || !is_array($row['configuration'])) {
$row['configuration'] = array();
}
foreach($row['configuration'] as $name => $value) {
$configuration->set($name, $value);
}
$type->setConfiguration($configuration);
$row['type'] = $type;
}
$row['validators'] = array_values(CRM_FormProcessor_BAO_FormProcessorValidation::getValues(array('entity_id' => $input->id, 'entity' => 'FormProcessorDefaultDataInput')));
if (!empty($row['form_processor_id'])) {
$type = \Civi::service('form_processor_type_factory')->getTypeByName($row['type']);
if ($type) {
$configuration = $type->getDefaultConfiguration();
if (isset($row['configuration']) && is_string($row['configuration'])) {
$row['configuration'] = json_decode($row['configuration'], true);
}
if (empty($row['configuration']) || !is_array($row['configuration'])) {
$row['configuration'] = array();
}
foreach($row['configuration'] as $name => $value) {
$configuration->set($name, $value);
}
$type->setConfiguration($configuration);
$row['type'] = $type;
}
if (isset($row['parameter_mapping']) && is_string($row['parameter_mapping'])) {
$row['parameter_mapping'] = json_decode($row['parameter_mapping'], true);
}
if (empty($row['parameter_mapping']) || !is_array($row['parameter_mapping'])) {
$row['parameter_mapping'] = array();
}
if (isset($row['default_data_parameter_mapping']) && is_string($row['default_data_parameter_mapping'])) {
$row['default_data_parameter_mapping'] = json_decode($row['default_data_parameter_mapping'], true);
}
if (empty($row['default_data_parameter_mapping']) || !is_array($row['default_data_parameter_mapping'])) {
$row['default_data_parameter_mapping'] = array();
}
$row['validators'] = array_values(CRM_FormProcessor_BAO_FormProcessorValidation::getValues(array('entity_id' => $input->id, 'entity' => 'FormProcessorDefaultDataInput')));
$result[$row['id']] = $row;
} else {
//invalid input because no there is no form processor
......@@ -61,8 +75,8 @@ class CRM_FormProcessor_BAO_FormProcessorDefaultDataInput extends CRM_FormProces
/**
* Function to add or update form processor input
*
* @param array $params
*
* @param array $params
* @return array $result
* @access public
* @throws Exception when params is empty
......@@ -73,14 +87,18 @@ class CRM_FormProcessor_BAO_FormProcessorDefaultDataInput extends CRM_FormProces
if (empty($params)) {
throw new Exception('Params can not be empty when adding or updating a form processor input');
}
if (!empty($params['id'])) {
if (empty($params['id']) && empty($params['weight'])) {
$params['weight'] = \CRM_Core_DAO::singleValueQuery("SELECT COUNT(*) + 1 FROM `".self::getTableName()."` WHERE `form_processor_id` = %1", [1=>[$params['form_processor_id'], 'Integer']]);
}
if (!empty($params['id'])) {
CRM_Utils_Hook::pre('edit', 'FormProcessorDefaultDataInput', $params['id'], $params);
}
else {
CRM_Utils_Hook::pre('create', 'FormProcessorDefaultDataInput', NULL, $params);
}
$input = new CRM_FormProcessor_BAO_FormProcessorDefaultDataInput();
$fields = self::fields();
foreach ($params as $key => $value) {
......@@ -88,25 +106,31 @@ class CRM_FormProcessor_BAO_FormProcessorDefaultDataInput extends CRM_FormProces
$input->$key = $value;
}
}
if (is_array($input->configuration)) {
$input->configuration = json_encode($input->configuration);
}
if (is_array($input->configuration)) {
$input->configuration = json_encode($input->configuration);
}
if (is_array($input->parameter_mapping)) {
$input->parameter_mapping = json_encode($input->parameter_mapping);
}
if (is_array($input->default_data_parameter_mapping)) {
$input->default_data_parameter_mapping = json_encode($input->default_data_parameter_mapping);
}
$input->save();
self::storeValues($input, $result);
if (!empty($params['id'])) {
if (!empty($params['id'])) {
CRM_Utils_Hook::post('edit', 'FormProcessorDefaultDataInput', $input->id, $input);
}
else {
CRM_Utils_Hook::post('create', 'FormProcessorDefaultDataInput', $input->id, $input);
}
return $result;
}
/**
* Function to delete a form processor input with id
*
*
* @param int $id
* @throws Exception when $id is empty
* @access public
......@@ -116,61 +140,61 @@ class CRM_FormProcessor_BAO_FormProcessorDefaultDataInput extends CRM_FormProces
if (empty($id)) {
throw new Exception('id can not be empty when attempting to delete a form processor input');
}
CRM_Utils_Hook::pre('delete', 'FormProcessorDefaultDataInput', $id, CRM_Core_DAO::$_nullArray);
CRM_Utils_Hook::pre('delete', 'FormProcessorDefaultDataInput', $id, CRM_Core_DAO::$_nullArray);
$input = new CRM_FormProcessor_BAO_FormProcessorDefaultDataInput();
$input->id = $id;
if ($input->find(true)) {
CRM_FormProcessor_BAO_FormProcessorValidation::deleteWithEntityId('FormProcessorDefaultDataInput', $input->id);
CRM_FormProcessor_BAO_FormProcessorValidation::deleteWithEntityId('FormProcessorDefaultDataInput', $input->id);
$input->delete();
}
CRM_Utils_Hook::post('delete', 'FormProcessorDefaultDataInput', $id, CRM_Core_DAO::$_nullArray);
CRM_Utils_Hook::post('delete', 'FormProcessorDefaultDataInput', $id, CRM_Core_DAO::$_nullArray);
return;
}
/**
/**
* Function to delete all inputs with a form processor instance id
*
* @param int $formProcessorInstanceId
* @param int $formProcessorId
* @access public
* @static
*/
public static function deleteWithFormProcessorInstanceId($formProcessorInstanceId) {
public static function deleteWithFormProcessorInstanceId($formProcessorId) {
$input = new CRM_FormProcessor_BAO_FormProcessorDefaultDataInput();
$input->form_processor_instance_id = $formProcessorInstanceId;
$input->form_processor_id = $formProcessorId;
$input->find(FALSE);
while ($input->fetch()) {
self::deleteWithId($input->id);
}
}
/**
* Returns whether the name is valid or not
*
* @param string $name
* @param int $form_processor_instance_id
* @param int $id optional
*
* @return bool
* @static
*/
public static function isNameValid($name, $form_processor_instance_id, $id = NULL) {
if (empty($form_processor_instance_id)) {
return true;
}
$sql = "SELECT COUNT(*) FROM `civicrm_form_processor_default_data_input` WHERE `name` = %1 AND `form_processor_instance_id` = %2";
$params[1] = [$name, 'String'];
$params[2] = [$form_processor_instance_id, 'Integer'];
if ($id) {
public static function checkName($title, $form_processor_id, $id=null,$name=null): string {
if (!$name) {
$name = preg_replace('@[^a-z0-9_]+@','_',strtolower($title));
}
$name = preg_replace('@[^a-z0-9_]+@','_',strtolower($name));
$name_part = $name;
$sql = "SELECT COUNT(*) FROM `civicrm_form_processor_default_data_input` WHERE `name` = %1 AND `form_processor_id` = %2";
$sqlParams[1] = array($name, 'String');
$sqlParams[2] = array($form_processor_id, 'String');
if (isset($id)) {
$sql .= " AND `id` != %3";
$params[3] = [$id, 'Integer'];
$sqlParams[3] = array($id, 'Integer');
}
$count = CRM_Core_DAO::singleValueQuery($sql, $params);
return ($count > 0) ? FALSE : TRUE;
$i = 1;
while(CRM_Core_DAO::singleValueQuery($sql, $sqlParams) > 0) {
$i++;
$name = $name_part .'_'.$i;
$sqlParams[1] = array($name, 'String');
}
return $name;
}
}
\ No newline at end of file
}
......@@ -7,10 +7,10 @@ use CRM_FormProcessor_ExtensionUtil as E;
* @license http://www.gnu.org/licenses/agpl-3.0.html
*/
class CRM_FormProcessor_BAO_FormProcessorInput extends CRM_FormProcessor_DAO_FormProcessorInput {
/**
/**
* Function to get values
*
*
* @return array $result found rows with data
* @access public
* @static
......@@ -26,30 +26,44 @@ class CRM_FormProcessor_BAO_FormProcessorInput extends CRM_FormProcessor_DAO_For
}
}
}
$input->orderBy('weight');
$input->find();
while ($input->fetch()) {
$row = array();
self::storeValues($input, $row);
if (!empty($row['form_processor_instance_id'])) {
$type = \Civi::service('form_processor_type_factory')->getTypeByName($row['type']);
if ($type) {
$configuration = $type->getDefaultConfiguration();
if (isset($row['configuration']) && is_string($row['configuration'])) {
$row['configuration'] = json_decode($row['configuration'], true);
}
if (empty($row['configuration']) || !is_array($row['configuration'])) {
$row['configuration'] = array();
}
foreach($row['configuration'] as $name => $value) {
$configuration->set($name, $value);
}
$type->setConfiguration($configuration);
$row['type'] = $type;
}
$row['validators'] = array_values(CRM_FormProcessor_BAO_FormProcessorValidation::getValues(array('entity_id' => $input->id, 'entity' => 'FormProcessorInput')));
if (!empty($row['form_processor_id'])) {
$type = \Civi::service('form_processor_type_factory')->getTypeByName($row['type']);
if ($type) {
$configuration = $type->getDefaultConfiguration();
if (isset($row['configuration']) && is_string($row['configuration'])) {
$row['configuration'] = json_decode($row['configuration'], true);
}
if (empty($row['configuration']) || !is_array($row['configuration'])) {
$row['configuration'] = array();
}
foreach($row['configuration'] as $name => $value) {
$configuration->set($name, $value);
}
$type->setConfiguration($configuration);
$row['type'] = $type;
}
if (isset($row['parameter_mapping']) && is_string($row['parameter_mapping'])) {
$row['parameter_mapping'] = json_decode($row['parameter_mapping'], true);
}
if (empty($row['parameter_mapping']) || !is_array($row['parameter_mapping'])) {
$row['parameter_mapping'] = array();
}
if (isset($row['default_data_parameter_mapping']) && is_string($row['default_data_parameter_mapping'])) {
$row['default_data_parameter_mapping'] = json_decode($row['default_data_parameter_mapping'], true);
}
if (empty($row['default_data_parameter_mapping']) || !is_array($row['default_data_parameter_mapping'])) {
$row['default_data_parameter_mapping'] = array();
}
$row['validators'] = array_values(CRM_FormProcessor_BAO_FormProcessorValidation::getValues(array('entity_id' => $input->id, 'entity' => 'FormProcessorInput')));
$result[$row['id']] = $row;
} else {
//invalid input because no there is no form processor
......@@ -61,8 +75,8 @@ class CRM_FormProcessor_BAO_FormProcessorInput extends CRM_FormProcessor_DAO_For
/**
* Function to add or update form processor input
*
* @param array $params
*
* @param array $params
* @return array $result
* @access public
* @throws Exception when params is empty
......@@ -73,14 +87,14 @@ class CRM_FormProcessor_BAO_FormProcessorInput extends CRM_FormProcessor_DAO_For
if (empty($params)) {
throw new Exception('Params can not be empty when adding or updating a form processor input');
}
if (!empty($params['id'])) {
if (!empty($params['id'])) {
CRM_Utils_Hook::pre('edit', 'FormProcessorInput', $params['id'], $params);
}
else {
CRM_Utils_Hook::pre('create', 'FormProcessorInput', NULL, $params);
}
$input = new CRM_FormProcessor_BAO_FormProcessorInput();
$fields = self::fields();
foreach ($params as $key => $value) {
......@@ -88,25 +102,34 @@ class CRM_FormProcessor_BAO_FormProcessorInput extends CRM_FormProcessor_DAO_For
$input->$key = $value;
}
}
if (is_array($input->configuration)) {
$input->configuration = json_encode($input->configuration);
}
if (is_array($input->configuration)) {
$input->configuration = json_encode($input->configuration);
}
if (is_array($input->parameter_mapping)) {
$input->parameter_mapping = json_encode($input->parameter_mapping);
}
if (is_array($input->default_data_parameter_mapping)) {
$input->default_data_parameter_mapping = json_encode($input->default_data_parameter_mapping);
}
if (empty($params['id']) && empty($params['weight'])) {
$input->weight = \CRM_Core_DAO::singleValueQuery("SELECT COUNT(*) + 1 FROM `".self::getTableName()."` WHERE `form_processor_id` = %1", [1=>[$params['form_processor_id'], 'Integer']]);
}
$input->save();
self::storeValues($input, $result);
if (!empty($params['id'])) {
if (!empty($params['id'])) {
CRM_Utils_Hook::post('edit', 'FormProcessorInput', $input->id, $input);
}
else {
CRM_Utils_Hook::post('create', 'FormProcessorInput', $input->id, $input);
}
return $result;
}
/**
* Function to delete a form processor input with id
*
*
* @param int $id
* @throws Exception when $id is empty
* @access public
......@@ -116,76 +139,61 @@ class CRM_FormProcessor_BAO_FormProcessorInput extends CRM_FormProcessor_DAO_For
if (empty($id)) {
throw new Exception('id can not be empty when attempting to delete a form processor input');
}
CRM_Utils_Hook::pre('delete', 'FormProcessorInput', $id, CRM_Core_DAO::$_nullArray);
CRM_Utils_Hook::pre('delete', 'FormProcessorInput', $id, CRM_Core_DAO::$_nullArray);
$input = new CRM_FormProcessor_BAO_FormProcessorInput();
$input->id = $id;
if ($input->find(true)) {
CRM_FormProcessor_BAO_FormProcessorValidation::deleteWithEntityId('FormProcessorInput', $input->id);
CRM_FormProcessor_BAO_FormProcessorValidation::deleteWithEntityId('FormProcessorInput', $input->id);
$input->delete();
}
CRM_Utils_Hook::post('delete', 'FormProcessorInput', $id, CRM_Core_DAO::$_nullArray);
CRM_Utils_Hook::post('delete', 'FormProcessorInput', $id, CRM_Core_DAO::$_nullArray);
return;
}
/**
/**
* Function to delete all inputs with a form processor instance id
*
* @param int $formProcessorInstanceId
* @param int $formProcessorId
* @access public
* @static
*/
public static function deleteWithFormProcessorInstanceId($formProcessorInstanceId) {
public static function deleteWithFormProcessorInstanceId($formProcessorId) {
$input = new CRM_FormProcessor_BAO_FormProcessorInput();
$input->form_processor_instance_id = $formProcessorInstanceId;
$input->form_processor_id = $formProcessorId;
$input->find(FALSE);
while ($input->fetch()) {
self::deleteWithId($input->id);
}
}
/**
* Public function to generate name from title
*
* @param $title
*
* @return string
* @access public
* @static
*/
public static function buildNameFromTitle($title) {
$titleParts = explode(' ', strtolower($title));
$nameString = implode('_', $titleParts);
return substr($nameString, 0, 80);
}
public static function checkName($title, $form_processor_id, $id=null,$name=null): string {
if (!$name) {
$name = preg_replace('@[^a-z0-9_]+@','_',strtolower($title));
}
/**
* Returns whether the name is valid or not
*
* @param string $name
* @param int $form_processor_instance_id
* @param int $id optional
*
* @return bool
* @static
*/
public static function isNameValid($name, $form_processor_instance_id, $id = NULL) {
if (empty($form_processor_instance_id)) {
return true;
}
$sql = "SELECT COUNT(*) FROM `civicrm_form_processor_input` WHERE `name` = %1 AND `form_processor_instance_id` = %2";
$params[1] = [$name, 'String'];
$params[2] = [$form_processor_instance_id, 'Integer'];
if ($id) {
$name = preg_replace('@[^a-z0-9_]+@','_',strtolower($name));
$name_part = $name;
$sql = "SELECT COUNT(*) FROM `civicrm_form_processor_input` WHERE `name` = %1 AND `form_processor_id` = %2";
$sqlParams[1] = array($name, 'String');
$sqlParams[2] = array($form_processor_id, 'String');
if (isset($id)) {
$sql .= " AND `id` != %3";
$params[3] = [$id, 'Integer'];
$sqlParams[3] = array($id, 'Integer');
}
$i = 1;
while(CRM_Core_DAO::singleValueQuery($sql, $sqlParams) > 0) {
$i++;
$name = $name_part .'_'.$i;
$sqlParams[1] = array($name, 'String');
}
$count = CRM_Core_DAO::singleValueQuery($sql, $params);
return ($count > 0) ? FALSE : TRUE;
return $name;
}
}
\ No newline at end of file
}
<?php
use Civi\FormProcessor\Runner;
/**
* @author Jaap Jansma (CiviCooP) <jaap.jansma@civicoop.org>
* @license http://www.gnu.org/licenses/agpl-3.0.html
*/
class CRM_FormProcessor_BAO_FormProcessorInstance extends CRM_FormProcessor_DAO_FormProcessorInstance {
static $importingFormProcessors = array();
/**
/**
* Function to get values
*
*
* @return array $result found rows with data
* @access public
* @static
......@@ -29,45 +32,56 @@
$formProcessorInstance->find();
while ($formProcessorInstance->fetch()) {
$row = array();
self::storeValues($formProcessorInstance, $row);
$row['inputs'] = array_values(CRM_FormProcessor_BAO_FormProcessorInput::getValues(array('form_processor_instance_id' => $formProcessorInstance->id)));
$row['actions'] = array_values(CRM_FormProcessor_BAO_FormProcessorAction::getValues(array('form_processor_instance_id' => $formProcessorInstance->id)));
$row['default_data_inputs'] = array_values(CRM_FormProcessor_BAO_FormProcessorDefaultDataInput::getValues(array('form_processor_instance_id' => $formProcessorInstance->id)));
$row['default_data_actions'] = array_values(CRM_FormProcessor_BAO_FormProcessorDefaultDataAction::getValues(array('form_processor_instance_id' => $formProcessorInstance->id)));
$handler = \Civi::service('form_processor_output_handler_factory')->getHandlerByName($row['output_handler']);
if ($handler) {
$configuration = $handler->getDefaultConfiguration();
if (isset($row['output_handler_configuration']) && is_string($row['output_handler_configuration'])) {
$row['output_handler_configuration'] = json_decode($row['output_handler_configuration'], true);
}
if (empty($row['output_handler_configuration']) || !is_array($row['output_handler_configuration'])) {
$row['output_handler_configuration'] = array();
}
foreach($row['output_handler_configuration'] as $name => $value) {
$configuration->set($name, $value);
}
$handler->setConfiguration($configuration);
$row['output_handler'] = $handler;
}
if (isset($row['default_data_output_configuration']) && is_string($row['default_data_output_configuration'])) {
$row['default_data_output_configuration'] = json_decode($row['default_data_output_configuration'], true);
}
if (empty($row['default_data_output_configuration']) || !is_array($row['default_data_output_configuration'])) {
$row['default_data_output_configuration'] = array();
}
self::storeValues($formProcessorInstance, $row);
$row['inputs'] = array_values(CRM_FormProcessor_BAO_FormProcessorInput::getValues(array('form_processor_id' => $formProcessorInstance->id)));
$row['actions'] = array_values(CRM_FormProcessor_BAO_FormProcessorAction::getValues(array('form_processor_id' => $formProcessorInstance->id)));
$row['default_data_inputs'] = array_values(CRM_FormProcessor_BAO_FormProcessorDefaultDataInput::getValues(array('form_processor_id' => $formProcessorInstance->id)));
$row['default_data_actions'] = array_values(CRM_FormProcessor_BAO_FormProcessorDefaultDataAction::getValues(array('form_processor_id' => $formProcessorInstance->id)));
$row['validate_actions'] = array_values(CRM_FormProcessor_BAO_FormProcessorValidateAction::getValues(array('form_processor_id' => $formProcessorInstance->id)));
$row['validate_validators'] = array_values(CRM_FormProcessor_BAO_FormProcessorValidateValidator::getValues(array('form_processor_id' => $formProcessorInstance->id)));
$row['calculate_actions'] = array_values(CRM_FormProcessor_BAO_FormProcessorCalculateAction::getValues(array('form_processor_id' => $formProcessorInstance->id)));
if (isset($row['output_handler_configuration']) && is_string($row['output_handler_configuration'])) {
$row['output_handler_configuration'] = json_decode($row['output_handler_configuration'], true);
}
if (empty($row['output_handler_configuration']) || !is_array($row['output_handler_configuration'])) {
$row['output_handler_configuration'] = array();
}
$handler = null;
if ($row['output_handler']) {
$handler = \Civi::service('form_processor_output_handler_factory')->getHandlerByName($row['output_handler']);
if ($handler) {
$configuration = $handler->getDefaultConfiguration();
foreach ($row['output_handler_configuration'] as $name => $value) {
$configuration->set($name, $value);
}
$handler->setConfiguration($configuration);
$row['output_handler'] = $handler;
}
}
if (isset($row['default_data_output_configuration']) && is_string($row['default_data_output_configuration'])) {
$row['default_data_output_configuration'] = json_decode($row['default_data_output_configuration'], true);
}
if (empty($row['default_data_output_configuration']) || !is_array($row['default_data_output_configuration'])) {
$row['default_data_output_configuration'] = array();
}
if (isset($row['calculation_output_configuration']) && is_string($row['calculation_output_configuration'])) {
$row['calculation_output_configuration'] = json_decode($row['calculation_output_configuration'], true);
}
if (empty($row['calculation_output_configuration']) || !is_array($row['calculation_output_configuration'])) {
$row['calculation_output_configuration'] = array();
}
$result[$row['id']] = $row;
}
return $result;
}
/**
/**
* Function to add or update a FormProcessorInstance
*
* @param array $params
*
* @param array $params
* @return array $result
* @access public
* @throws Exception when params is empty
......@@ -76,7 +90,11 @@
public static function add($params) {
$result = array();
if (empty($params)) {
throw new Exception('Params can not be empty when adding or updating a civirule rule');
throw new Exception('Params can not be empty when adding or updating a formsprocessor instance');
}
if (empty($params['id']) && empty($params['permission'])) {
$params['permission'] = '';
}
if (!empty($params['id'])) {
......@@ -93,21 +111,21 @@
$formProcessorInstance->$key = $value;
}
}
if (!$formProcessorInstance->permission) {
$formProcessorInstance->permission = '';
}
if (!isset($formProcessorInstance->name) || empty($formProcessorInstance->name)) {
if (isset($formProcessorInstance->title)) {
$formProcessorInstance->name = CRM_FormProcessor_BAO_FormProcessorInstance::buildNameFromLabel($formProcessorInstance->title);
$formProcessorInstance->name = CRM_FormProcessor_BAO_FormProcessorInstance::checkName($formProcessorInstance->title, $formProcessorInstance->id);
}
}
if (is_array($formProcessorInstance->output_handler_configuration)) {
$formProcessorInstance->output_handler_configuration = json_encode($formProcessorInstance->output_handler_configuration);
}
if (is_array($formProcessorInstance->default_data_output_configuration)) {
$formProcessorInstance->default_data_output_configuration = json_encode($formProcessorInstance->default_data_output_configuration);
}
if (isset($formProcessorInstance->output_handler_configuration) && is_array($formProcessorInstance->output_handler_configuration)) {
$formProcessorInstance->output_handler_configuration = json_encode($formProcessorInstance->output_handler_configuration);
}
if (isset($formProcessorInstance->default_data_output_configuration) && is_array($formProcessorInstance->default_data_output_configuration)) {
$formProcessorInstance->default_data_output_configuration = json_encode($formProcessorInstance->default_data_output_configuration);
}
if (isset($formProcessorInstance->calculation_output_configuration) && is_array($formProcessorInstance->calculation_output_configuration)) {
$formProcessorInstance->calculation_output_configuration = json_encode($formProcessorInstance->calculation_output_configuration);
}
$formProcessorInstance->save();
self::storeValues($formProcessorInstance, $result);
......@@ -121,9 +139,9 @@
return $result;
}
/**
/**
* Function to delete a FormProcessorInstance with id
*
*
* @param int $id
* @throws Exception when $id is empty
* @access public
......@@ -136,66 +154,36 @@
CRM_Utils_Hook::pre('delete', 'FormProcessorInstance', $id, CRM_Core_DAO::$_nullArray);
// First delete all inputs
CRM_FormProcessor_BAO_FormProcessorInput::deleteWithFormProcessorInstanceId($id);
CRM_FormProcessor_BAO_FormProcessorDefaultDataInput::deleteWithFormProcessorInstanceId($id);
// And all actions
CRM_FormProcessor_BAO_FormProcessorAction::deleteWithFormProcessorInstanceId($id);
CRM_FormProcessor_BAO_FormProcessorDefaultDataAction::deleteWithFormProcessorInstanceId($id);
// First delete all inputs
CRM_FormProcessor_BAO_FormProcessorInput::deleteWithFormProcessorInstanceId($id);
CRM_FormProcessor_BAO_FormProcessorDefaultDataInput::deleteWithFormProcessorInstanceId($id);
// And all actions
CRM_FormProcessor_BAO_FormProcessorAction::deleteWithFormProcessorInstanceId($id);
CRM_FormProcessor_BAO_FormProcessorDefaultDataAction::deleteWithFormProcessorInstanceId($id);
CRM_FormProcessor_BAO_FormProcessorValidateAction::deleteWithFormProcessorInstanceId($id);
CRM_FormProcessor_BAO_FormProcessorValidateValidator::deleteWithFormProcessorInstanceId($id);
$formProcessorInstance = new CRM_FormProcessor_BAO_FormProcessorInstance();
$formProcessorInstance->id = $id;
$formProcessorInstance->delete();
if ($formProcessorInstance->find(TRUE)) {
if (!empty($formProcessorInstance->source_file)) {
\Civi\FormProcessor\Exporter\ExportToJson::deleteUploadedFile($formProcessorInstance->source_file);
}
$formProcessorInstance->delete();
}
CRM_Utils_Hook::post('delete', 'FormProcessorInstance', $id, CRM_Core_DAO::$_nullArray);
return;
}
/**
* Public function to generate name from label
*
* @param $label
* @return string
* @access public
* @static
*/
public static function buildNameFromLabel($label) {
$labelParts = explode(' ', strtolower($label));
$nameString = implode('_', $labelParts);
return substr($nameString, 0, 80);
}
/**
* Returns whether the name is valid or not
*
* @param string $name
* @param int $id optional
* @return bool
* @static
*/
public static function isNameValid($name, $id=null) {
$invalidNames = array('getactions', 'getfields');
if (in_array(strtolower($name), $invalidNames)) {
return false;
}
$sql = "SELECT COUNT(*) FROM `civicrm_form_processor_instance` WHERE `name` = %1";
$params[1] = array($name, 'String');
if ($id) {
$sql .= " AND `id` != %2";
$params[2] = array($id, 'Integer');
}
$count = CRM_Core_DAO::singleValueQuery($sql, $params);
return ($count > 0) ? false : true;
}
/**
* Returns the permission for the form processor. When no permission is required
* return an empty string.
*
*
* @param string $formProcessorName
* The name of the form processor.
* @return string
* @return string
* The required permission.
*/
public static function getPermission($formProcessorName) {
......@@ -204,14 +192,14 @@
$permission = CRM_Core_DAO::singleValueQuery($sql, $params);
return $permission;
}
/**
* Returns the id of the form processor.
*
*
* @param string $formProcessorName
* The name of the form processor.
* @return int
* The id of the form processor.
* The id of the form processor.
*/
public static function getId($formProcessorName) {
$sql = "SELECT `id` FROM `civicrm_form_processor_instance` WHERE `name` = %1";
......@@ -219,15 +207,33 @@
$id = CRM_Core_DAO::singleValueQuery($sql, $params);
return $id;
}
/**
* Returns the id of the form processor.
*
* @param int $formProcessorId
* The ID of the form processor.
* @return string
* The name of the form processor.
*/
public static function getName(int $formProcessorId) {
static $names = [];
if (!isset($names[$formProcessorId])) {
$sql = "SELECT `name` FROM `civicrm_form_processor_instance` WHERE `id` = %1";
$params[1] = array($formProcessorId, 'Integer');
$names[$formProcessorId] = CRM_Core_DAO::singleValueQuery($sql, $params);
}
return $names[$formProcessorId];
}
/**
* Returns the status of the form processor.
* @See CRM_FormProcessor_Status for possible values.
*
*
* @param string $formProcessorName
* The name of the form processor.
* @return int
* The status of the form processor.
* The status of the form processor.
*/
public static function getStatus($formProcessorName) {
$sql = "SELECT `status` FROM `civicrm_form_processor_instance` WHERE `name` = %1";
......@@ -235,17 +241,34 @@
$status = CRM_Core_DAO::singleValueQuery($sql, $params);
return $status;
}
/**
/**
* Returns the status of the form processor.
* @See CRM_FormProcessor_Status for possible values.
*
* @param string $formProcessorName
* The name of the form processor.
* @param integer $status
* The new status
*/
public static function setStatus($formProcessorName, $status) {
$sql = "UPDATE `civicrm_form_processor_instance` SET `status` = %1 WHERE `name` = %2";
$params[1] = array($status, 'Integer');
$params[2] = array($formProcessorName, 'String');
CRM_Core_DAO::executeQuery($sql, $params);
}
/**
* Updates the status and source file of the form processor.
* @See CRM_FormProcessor_Status for possible status values.
*
*
* @param string $formProcessorName
* The name of the form processor.
* @param int $status
* The status value.
* @param string $source_file
* The source file. Leave empty when status is IN_DATABASE.
* The source file. Leave empty when status is IN_DATABASE.
*/
public static function setStatusAndSourceFile($formProcessorName, $status, $source_file) {
$sql = "UPDATE `civicrm_form_processor_instance` SET `status` = %2, `source_file` = %3 WHERE `name` = %1";
......@@ -283,5 +306,148 @@
public static function setFormProcessorToImportingState($formProcessorName) {
self::$importingFormProcessors[] = $formProcessorName;
}
public static function checkName($title, $id=null,$name=null): string {
if (!$name) {
$name = preg_replace('@[^a-z0-9_]+@', '_', strtolower($title));
}
$name = preg_replace('@[^a-z0-9_]+@', '_', strtolower($name));
$name_part = $name;
$sql = "SELECT COUNT(*) FROM `civicrm_form_processor_instance` WHERE `name` = %1";
$sqlParams[1] = [$name, 'String'];
if (!empty($id)) {
$sql .= " AND `id` != %2";
$sqlParams[2] = [$id, 'Integer'];
}
$i = 1;
while (CRM_Core_DAO::singleValueQuery($sql, $sqlParams) > 0) {
$i++;
$name = $name_part . '_' . $i;
$sqlParams[1] = [$name, 'String'];
}
return $name;
}
/**
* Returns a list of inputs which are used as triggers for the calculation
*
* @param string $formProcessorName
*
* @return array
*/
public static function getCalculationTriggers(string $formProcessorName): array {
try {
$formProcessor = Runner::getFormProcessor($formProcessorName);
} catch (\Exception $e) {
return [];
}
$usedInputs = [];
$usedValidationInputs = [];
foreach($formProcessor['calculation_output_configuration'] as $key) {
if (strpos($key, 'input.') === 0 && !in_array($key, $usedInputs)) {
$usedInputs[] = substr($key, 6);
} elseif (strpos($key, 'validation.') === 0) {
$usedValidationInputs[] = substr($key, 11);
}
}
$usedValidationInputs = array_merge($usedValidationInputs, self::getInputParametersFromActions($formProcessor['calculate_actions'], 'validation'));
$usedInputs = array_merge($usedInputs, self::getInputParametersFromActions($formProcessor['calculate_actions'], 'input'));
if (count($usedValidationInputs)) {
$usedInputs = array_merge($usedInputs, self::getInputParametersFromActions($formProcessor['validate_actions'], 'input'));
}
return array_unique($usedInputs);
}
public static function getCalculationOutputs(string $formProcessorName): array {
try {
$formProcessor = Runner::getFormProcessor($formProcessorName);
} catch (\Exception $e) {
return [];
}
$usedOutputs = [];
foreach($formProcessor['calculation_output_configuration'] as $key => $v) {
if (strlen($v)) {
$usedOutputs[] = $key;
}
}
return array_unique($usedOutputs);
}
private static function getInputParametersFromActions(array $actions, string $type): array {
$usedInputs = [];
foreach($actions as $action) {
foreach($action['mapping'] as $key) {
if (is_array($key)) {
foreach ($key as $subkey) {
if ($r = self::isMappingToAnInput($subkey, $type)) {
$usedInputs[] = substr($r, strlen($type)+1);
}
}
} else {
if ($r = self::isMappingToAnInput($key, $type)) {
$usedInputs[] = substr($r, strlen($type)+1);
}
}
}
if (isset($action['condition_configuration']['parameter_mapping']) && is_array($action['condition_configuration']['parameter_mapping'])) {
foreach ($action['condition_configuration']['parameter_mapping'] as $key) {
if (is_array($key)) {
foreach ($key as $subkey) {
if (is_array($subkey) && isset($subkey['parameter_mapping']) && is_array($subkey['parameter_mapping'])) {
foreach ($subkey['parameter_mapping'] as $subsubkey) {
if ($r = self::isMappingToAnInput($subsubkey, $type)) {
$usedInputs[] = substr($r, strlen($type) + 1);
}
}
} else {
if ($r = self::isMappingToAnInput($subkey, $type)) {
$usedInputs[] = substr($r, strlen($type) + 1);
}
}
}
} else {
if ($r = self::isMappingToAnInput($key, $type)) {
$usedInputs[] = substr($r, strlen($type)+1);
}
}
}
}
if (isset($action['condition_configuration']['output_mapping']) && is_array($action['condition_configuration']['output_mapping'])) {
foreach ($action['condition_configuration']['output_mapping'] as $key) {
if (is_array($key)) {
foreach ($key as $subkey) {
if ($r = self::isMappingToAnInput($subkey, $type)) {
$usedInputs[] = substr($r, strlen($type)+1);
}
}
} else {
if ($r = self::isMappingToAnInput($key, $type)) {
$usedInputs[] = substr($r, strlen($type)+1);
}
}
}
}
}
return array_unique($usedInputs);
}
private static function isMappingToAnInput(string $key, string $type):? string {
if (is_array($key)) {
foreach ($key as $k) {
if ($r = self::isMappingToAnInput($k, $type)) {
return $r;
}
}
} elseif (strpos($key, $type.'.') === 0) {
return $key;
}
return null;
}
}
<?php
use CRM_FormProcessor_ExtensionUtil as E;
/**
* @author Jaap Jansma (CiviCooP) <jaap.jansma@civicoop.org>
* @license http://www.gnu.org/licenses/agpl-3.0.html
*/
class CRM_FormProcessor_BAO_FormProcessorValidateAction extends CRM_FormProcessor_DAO_FormProcessorValidateAction {
/**
* Function to get values
*
* @return array $result found rows with data
* @access public
* @static
*/
public static function getValues($params) {
$result = array();
$action = new CRM_FormProcessor_BAO_FormProcessorValidateAction();
if (!empty($params)) {
$fields = self::fields();
foreach ($params as $key => $value) {
if (isset($fields[$key])) {
$action->$key = $value;
}
}
}
$action->orderBy('weight');
$action->find();
while ($action->fetch()) {
$row = array();
self::storeValues($action, $row);
if (!empty($row['form_processor_id'])) {
if (isset($row['configuration']) && is_string($row['configuration'])) {
$row['configuration'] = json_decode($row['configuration'], TRUE);
}
if (empty($row['configuration']) || !is_array($row['configuration'])) {
$row['configuration'] = array();
}
if (isset($row['mapping']) && is_string($row['mapping'])) {
$row['mapping'] = json_decode($row['mapping'], true);
}
if (empty($row['mapping']) || !is_array($row['mapping'])) {
$row['mapping'] = array();
}
if (isset($row['condition_configuration']) && is_string($row['condition_configuration'])) {
$row['condition_configuration'] = json_decode($row['condition_configuration'], TRUE);
}
if (empty($row['condition_configuration']) || !is_array($row['condition_configuration'])) {
$row['condition_configuration'] = null;
}
if (isset($row['delay_configuration']) && is_string($row['delay_configuration'])) {
$row['delay_configuration'] = json_decode($row['delay_configuration'], TRUE);
}
$result[$row['id']] = $row;
} else {
//invalid input because no there is no form processor
CRM_FormProcessor_BAO_FormProcessorValidateAction::deleteWithId($row['id']);
}
}
return $result;
}
/**
* Function to add or update form processor action
*
* @param array $params
* @return array $result
* @access public
* @throws Exception when params is empty
* @static
*/
public static function add($params) {
$result = array();
if (empty($params)) {
throw new Exception('Params can not be empty when adding or updating a form processor action');
}
if (empty($params['id']) && empty($params['weight'])) {
$params['weight'] = \CRM_Core_DAO::singleValueQuery("SELECT COUNT(*) + 1 FROM `".self::getTableName()."` WHERE `form_processor_id` = %1", [1=>[$params['form_processor_id'], 'Integer']]);
}
if (!empty($params['id'])) {
CRM_Utils_Hook::pre('edit', 'FormProcessorValidateAction', $params['id'], $params);
}
else {
CRM_Utils_Hook::pre('create', 'FormProcessorValidateAction', NULL, $params);
}
$action = new CRM_FormProcessor_BAO_FormProcessorValidateAction();
$fields = self::fields();
foreach ($params as $key => $value) {
if (isset($fields[$key])) {
$action->$key = $value;
}
}
if (isset($action->configuration) && is_array($action->configuration)) {
$action->configuration = json_encode($action->configuration);
}
if (isset ($action->mapping) && is_array($action->mapping)) {
$action->validateSavedMapping();
$action->mapping = json_encode($action->mapping);
}
if (isset($action->condition_configuration) && is_array($action->condition_configuration)) {
// Delete condition if set to "No condition".
if ($action->condition_configuration['name']) {
$action->condition_configuration = json_encode($action->condition_configuration);
}
else {
$action->condition_configuration = '';
}
}
if (isset($action->delay_configuration) && is_array($action->delay_configuration)) {
$action->delay_configuration = json_encode($action->delay_configuration);
}
$action->save();
self::storeValues($action, $result);
if (!empty($params['id'])) {
CRM_Utils_Hook::post('edit', 'FormProcessorValidateAction', $action->id, $action);
}
else {
CRM_Utils_Hook::post('create', 'FormProcessorValidateAction', $action->id, $action);
}
return $result;
}
/**
* Function to delete a form processor action with id
*
* @param int $id
* @throws Exception when $id is empty
* @access public
* @static
*/
public static function deleteWithId($id) {
if (empty($id)) {
throw new Exception('id can not be empty when attempting to delete a form processor action');
}
CRM_Utils_Hook::pre('delete', 'FormProcessorValidateAction', $id, CRM_Core_DAO::$_nullArray);
$action = new CRM_FormProcessor_BAO_FormProcessorValidateAction();
$action->id = $id;
if ($action->find(true)) {
$action->delete();
}
CRM_Utils_Hook::post('delete', 'FormProcessorValidateAction', $id, CRM_Core_DAO::$_nullArray);
}
/**
* Function to delete all actions with a form processor instance id
*
* @param int $formProcessorId
* @access public
* @static
*/
public static function deleteWithFormProcessorInstanceId($formProcessorId) {
$action = new CRM_FormProcessor_BAO_FormProcessorValidateAction();
$action->form_processor_id = $formProcessorId;
$action->find(FALSE);
while ($action->fetch()) {
self::deleteWithId($action->id);
}
}
public static function checkName($title, $form_processor_id, $id=null,$name=null): string {
if (!$name) {
$name = preg_replace('@[^a-z0-9_]+@','_',strtolower($title));
}
$name = preg_replace('@[^a-z0-9_]+@','_',strtolower($name));
$name_part = $name;
$sql = "SELECT COUNT(*) FROM `civicrm_form_processor_validate_action` WHERE `name` = %1 AND `form_processor_id` = %2";
$sqlParams[1] = array($name, 'String');
$sqlParams[2] = array($form_processor_id, 'String');
if (isset($id)) {
$sql .= " AND `id` != %3";
$sqlParams[3] = array($id, 'Integer');
}
$i = 1;
while(CRM_Core_DAO::singleValueQuery($sql, $sqlParams) > 0) {
$i++;
$name = $name_part .'_'.$i;
$sqlParams[1] = array($name, 'String');
}
return $name;
}
/**
* Returns an array with all the fields available for parameter mapping
*
* @param $form_processor_id
* @param int|null $id
* @param bool $onlyInputs
* @return array
*/
public static function getFieldsForMapping($actionProvider, int $form_processor_id, int $id=null, $onlyInputs = false): array {
$inputs = CRM_FormProcessor_BAO_FormProcessorInput::getValues(array('form_processor_id' => $form_processor_id));
$return = \Civi\FormProcessor\Runner::getFormProcessorInputMapping('input', $inputs);
$return = array_merge($return, \Civi\FormProcessor\Runner::getFormattedMapping());
if (!$onlyInputs) {
$actions = CRM_FormProcessor_BAO_FormProcessorValidateAction::getValues(['form_processor_id' => $form_processor_id]);
$return = array_merge($return, \Civi\FormProcessor\Runner::getActionMapping('action', E::ts('Validation Action'), $actions, $actionProvider, $id));
}
return $return;
}
}
<?php
use CRM_FormProcessor_ExtensionUtil as E;
/**
* @author Jaap Jansma (CiviCooP) <jaap.jansma@civicoop.org>
* @license http://www.gnu.org/licenses/agpl-3.0.html
*/
class CRM_FormProcessor_BAO_FormProcessorValidateValidator extends CRM_FormProcessor_DAO_FormProcessorValidateValidator {
/**
* Function to get values
*
* @return array $result found rows with data
* @access public
* @static
*/
public static function getValues($params) {
$result = array();
$validator = new CRM_FormProcessor_BAO_FormProcessorValidateValidator();
if (!empty($params)) {
$fields = self::fields();
foreach ($params as $key => $value) {
if (isset($fields[$key])) {
$validator->$key = $value;
}
}
}
$validator->orderBy('weight');
$validator->find();
while ($validator->fetch()) {
$row = array();
self::storeValues($validator, $row);
if (!empty($row['form_processor_id'])) {
if (isset($row['configuration']) && is_string($row['configuration'])) {
$row['configuration'] = json_decode($row['configuration'], TRUE);
}
if (empty($row['configuration']) || !is_array($row['configuration'])) {
$row['configuration'] = array();
}
if (isset($row['mapping']) && is_string($row['mapping'])) {
$row['mapping'] = json_decode($row['mapping'], true);
}
if (empty($row['mapping']) || !is_array($row['mapping'])) {
$row['mapping'] = array();
}
if (isset($row['inputs']) && is_string($row['inputs'])) {
$row['inputs'] = json_decode($row['inputs'], TRUE);
}
if (empty($row['inputs']) || !is_array($row['inputs'])) {
$row['inputs'] = null;
}
$result[$row['id']] = $row;
} else {
//invalid input because no there is no form processor
CRM_FormProcessor_BAO_FormProcessorValidateAction::deleteWithId($row['id']);
}
}
return $result;
}
/**
* Function to add or update form processor action
*
* @param array $params
* @return array $result
* @access public
* @throws Exception when params is empty
* @static
*/
public static function add($params) {
$result = array();
if (empty($params)) {
throw new Exception('Params can not be empty when adding or updating a form processor action');
}
if (empty($params['id']) && empty($params['weight'])) {
$params['weight'] = \CRM_Core_DAO::singleValueQuery("SELECT COUNT(*) + 1 FROM `".self::getTableName()."` WHERE `form_processor_id` = %1", [1=>[$params['form_processor_id'], 'Integer']]);
}
if (!empty($params['id'])) {
CRM_Utils_Hook::pre('edit', 'FormProcessorValidateValidator', $params['id'], $params);
}
else {
CRM_Utils_Hook::pre('create', 'FormProcessorValidateValidator', NULL, $params);
}
$validator = new CRM_FormProcessor_BAO_FormProcessorValidateValidator();
$fields = self::fields();
foreach ($params as $key => $value) {
if (isset($fields[$key])) {
$validator->$key = $value;
}
}
if ($validator->configuration && is_array($validator->configuration)) {
$validator->configuration = json_encode($validator->configuration);
}
if ($validator->mapping && is_array($validator->mapping)) {
$validator->mapping = json_encode($validator->mapping);
}
if ($validator->inputs && is_array($validator->inputs)) {
$validator->inputs = json_encode($validator->inputs);
}
$validator->save();
self::storeValues($validator, $result);
if (!empty($params['id'])) {
CRM_Utils_Hook::post('edit', 'FormProcessorValidateValidator', $validator->id, $validator);
}
else {
CRM_Utils_Hook::post('create', 'FormProcessorValidateValidator', $validator->id, $validator);
}
return $result;
}
/**
* Function to delete a form processor action with id
*
* @param int $id
* @throws Exception when $id is empty
* @access public
* @static
*/
public static function deleteWithId($id) {
if (empty($id)) {
throw new Exception('id can not be empty when attempting to delete a form processor action');
}
CRM_Utils_Hook::pre('delete', 'FormProcessorValidateValidator', $id, CRM_Core_DAO::$_nullArray);
$validator = new CRM_FormProcessor_BAO_FormProcessorValidateValidator();
$validator->id = $id;
if ($validator->find(true)) {
$validator->delete();
}
CRM_Utils_Hook::post('delete', 'FormProcessorValidateValidator', $id, CRM_Core_DAO::$_nullArray);
}
/**
* Function to delete all actions with a form processor instance id
*
* @param int $formProcessorId
* @access public
* @static
*/
public static function deleteWithFormProcessorInstanceId($formProcessorId) {
$validator = new CRM_FormProcessor_BAO_FormProcessorValidateValidator();
$validator->form_processor_id = $formProcessorId;
$validator->find(FALSE);
while ($validator->fetch()) {
self::deleteWithId($validator->id);
}
}
public static function checkName($title, $form_processor_id, $id=null,$name=null): string {
if (!$name) {
$name = preg_replace('@[^a-z0-9_]+@','_',strtolower($title));
}
$name = preg_replace('@[^a-z0-9_]+@','_',strtolower($name));
$name_part = $name;
$sql = "SELECT COUNT(*) FROM `civicrm_form_processor_validate_validator` WHERE `name` = %1 AND `form_processor_id` = %2";
$sqlParams[1] = array($name, 'String');
$sqlParams[2] = array($form_processor_id, 'String');
if (isset($id)) {
$sql .= " AND `id` != %3";
$sqlParams[3] = array($id, 'Integer');
}
$i = 1;
while(CRM_Core_DAO::singleValueQuery($sql, $sqlParams) > 0) {
$i++;
$name = $name_part .'_'.$i;
$sqlParams[1] = array($name, 'String');
}
return $name;
}
}
......@@ -7,10 +7,10 @@ use CRM_FormProcessor_ExtensionUtil as E;
* @license http://www.gnu.org/licenses/agpl-3.0.html
*/
class CRM_FormProcessor_BAO_FormProcessorValidation extends CRM_FormProcessor_DAO_FormProcessorValidation {
/**
/**
* Function to get values
*
*
* @return array $result found rows with data
* @access public
* @static
......@@ -30,22 +30,22 @@ class CRM_FormProcessor_BAO_FormProcessorValidation extends CRM_FormProcessor_DA
while ($validation->fetch()) {
$row = array();
self::storeValues($validation, $row);
$validator = \Civi::service('form_processor_validation_factory')->getValidatorByName($row['validator']);
if ($validator) {
$configuration = $validator->getDefaultConfiguration();
if (isset($row['configuration']) && is_string($row['configuration'])) {
$row['configuration'] = json_decode($row['configuration'], true);
}
if (empty($row['configuration']) || !is_array($row['configuration'])) {
$row['configuration'] = array();
}
foreach($row['configuration'] as $name => $value) {
$configuration->set($name, $value);
}
$validator->setConfiguration($configuration);
$row['validator'] = $validator;
}
$validator = \Civi::service('form_processor_validation_factory')->getValidatorByName($row['validator']);
if ($validator) {
$configuration = $validator->getDefaultConfiguration();
if (isset($row['configuration']) && is_string($row['configuration'])) {
$row['configuration'] = json_decode($row['configuration'], true);
}
if (empty($row['configuration']) || !is_array($row['configuration'])) {
$row['configuration'] = array();
}
foreach($row['configuration'] as $name => $value) {
$configuration->set($name, $value);
}
$validator->setConfiguration($configuration);
$row['validator'] = $validator;
}
$result[$row['id']] = $row;
}
return $result;
......@@ -53,8 +53,8 @@ class CRM_FormProcessor_BAO_FormProcessorValidation extends CRM_FormProcessor_DA
/**
* Function to add or update form processor validation
*
* @param array $params
*
* @param array $params
* @return array $result
* @access public
* @throws Exception when params is empty
......@@ -65,14 +65,14 @@ class CRM_FormProcessor_BAO_FormProcessorValidation extends CRM_FormProcessor_DA
if (empty($params)) {
throw new Exception('Params can not be empty when adding or updating a form processor input validation');
}
if (!empty($params['id'])) {
if (!empty($params['id'])) {
CRM_Utils_Hook::pre('edit', 'FormProcessorValidation', $params['id'], $params);
}
else {
CRM_Utils_Hook::pre('create', 'FormProcessorValidation', NULL, $params);
}
$validation = new CRM_FormProcessor_BAO_FormProcessorValidation();
$fields = self::fields();
foreach ($params as $key => $value) {
......@@ -80,25 +80,25 @@ class CRM_FormProcessor_BAO_FormProcessorValidation extends CRM_FormProcessor_DA
$validation->$key = $value;
}
}
if (is_array($validation->configuration)) {
$validation->configuration = json_encode($validation->configuration);
}
if (is_array($validation->configuration)) {
$validation->configuration = json_encode($validation->configuration);
}
$validation->save();
self::storeValues($validation, $result);
if (!empty($params['id'])) {
if (!empty($params['id'])) {
CRM_Utils_Hook::post('edit', 'FormProcessorValidation', $validation->id, $validation);
}
else {
CRM_Utils_Hook::post('create', 'FormProcessorValidation', $validation->id, $validation);
}
return $result;
}
/**
* Function to delete a form processor validation with id
*
*
* @param int $id
* @throws Exception when $id is empty
* @access public
......@@ -108,21 +108,21 @@ class CRM_FormProcessor_BAO_FormProcessorValidation extends CRM_FormProcessor_DA
if (empty($id)) {
throw new Exception('id can not be empty when attempting to delete a form processor validation');
}
CRM_Utils_Hook::pre('delete', 'FormProcessorValidation', $id, CRM_Core_DAO::$_nullArray);
CRM_Utils_Hook::pre('delete', 'FormProcessorValidation', $id, CRM_Core_DAO::$_nullArray);
$validation = new CRM_FormProcessor_BAO_FormProcessorValidation();
$validation->id = $id;
if ($validation->find(true)) {
$validation->delete();
}
CRM_Utils_Hook::post('delete', 'FormProcessorValidation', $id, CRM_Core_DAO::$_nullArray);
CRM_Utils_Hook::post('delete', 'FormProcessorValidation', $id, CRM_Core_DAO::$_nullArray);
return;
}
/**
/**
* Function to delete all inputs with an entity_id
*
* @param int $formProcessorInputId
......@@ -132,12 +132,12 @@ class CRM_FormProcessor_BAO_FormProcessorValidation extends CRM_FormProcessor_DA
public static function deleteWithEntityId($entity, $entity_id) {
$validation = new CRM_FormProcessor_BAO_FormProcessorValidation();
$validation->entity = $entity;
$validation->entity_id = $entity_id;
$validation->entity_id = $entity_id;
$validation->find(FALSE);
while ($validation->fetch()) {
self::deleteWithId($validation->id);
}
}
}
\ No newline at end of file
......@@ -10,7 +10,7 @@ class CRM_FormProcessor_Condition {
* Returns null or a ActionProvider AbstractCondition class.
* @param $condition_configuration
*
* @return null
* @return \Civi\ActionProvider\Condition\AbstractCondition|null
*/
public static function getConditionClass($condition_configuration) {
if (!is_array($condition_configuration) || empty($condition_configuration) || !isset($condition_configuration['name'])) {
......@@ -36,4 +36,4 @@ class CRM_FormProcessor_Condition {
return null;
}
}
\ No newline at end of file
}
<?php
/**
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
*
* Generated from form-processor/xml/schema/CRM/FormProcessor/FormProcessorAction.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:acc86fd9300acd7b56ffd9ff5accdef4)
*/
use CRM_FormProcessor_ExtensionUtil as E;
/**
* @author Jaap Jansma (CiviCooP) <jaap.jansma@civicoop.org>
* @license http://www.gnu.org/licenses/agpl-3.0.html
* Database access object for the FormProcessorAction entity.
*/
class CRM_FormProcessor_DAO_FormProcessorAction extends CRM_Core_DAO {
const EXT = E::LONG_NAME;
const TABLE_ADDED = '';
/**
* Static instance to hold the table name.
*
* @var string
*/
public static $_tableName = 'civicrm_form_processor_action';
/**
* Field to show when displaying a record.
*
* @var string
*/
public static $_labelField = 'title';
/**
* static instance to hold the field values
* Should CiviCRM log any modifications to this table in the civicrm_log table.
*
* @var array
* @static
* @var bool
*/
public static $_log = TRUE;
/**
* Unique FormProcessorInput ID
*
* @var int|string|null
* (SQL type: int unsigned)
* Note that values will be retrieved from the database as a string.
*/
public $id;
/**
* FK to Form Processor
*
* @var int|string
* (SQL type: int unsigned)
* Note that values will be retrieved from the database as a string.
*/
public $form_processor_id;
/**
* @var int|string
* (SQL type: int)
* Note that values will be retrieved from the database as a string.
*/
public $weight;
/**
* @var string
* (SQL type: varchar(128))
* Note that values will be retrieved from the database as a string.
*/
public $title;
/**
* @var string
* (SQL type: varchar(80))
* Note that values will be retrieved from the database as a string.
*/
public $name;
/**
* @var string
* (SQL type: varchar(80))
* Note that values will be retrieved from the database as a string.
*/
public $type;
/**
* @var string
* (SQL type: longtext)
* Note that values will be retrieved from the database as a string.
*/
public $configuration;
/**
* @var string
* (SQL type: longtext)
* Note that values will be retrieved from the database as a string.
*/
public $mapping;
/**
* @var string
* (SQL type: longtext)
* Note that values will be retrieved from the database as a string.
*/
public $condition_configuration;
/**
* @var string
* (SQL type: varchar(255))
* Note that values will be retrieved from the database as a string.
*/
public $delay;
/**
* @var string
* (SQL type: longtext)
* Note that values will be retrieved from the database as a string.
*/
static $_fields = null;
static $_export = null;
public $delay_configuration;
/**
* empty definition for virtual function
* Class constructor.
*/
static function getTableName() {
return 'civicrm_form_processor_action';
public function __construct() {
$this->__table = 'civicrm_form_processor_action';
parent::__construct();
}
/**
* Returns localized title of this entity.
*
* @param bool $plural
* Whether to return the plural version of the title.
*/
public static function getEntityTitle($plural = FALSE) {
return $plural ? E::ts('Form Processor Actions') : E::ts('Form Processor Action');
}
/**
* returns all the column names of this table
* Returns all the column names of this table
*
* @access public
* @return array
*/
public static function &fields() {
if (!(self::$_fields)) {
self::$_fields = array(
'id' => array(
if (!isset(Civi::$statics[__CLASS__]['fields'])) {
Civi::$statics[__CLASS__]['fields'] = [
'id' => [
'name' => 'id',
'type' => CRM_Utils_Type::T_INT,
'title' => E::ts('ID'),
'description' => E::ts('Unique FormProcessorInput ID'),
'required' => TRUE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_action.id',
'table_name' => 'civicrm_form_processor_action',
'entity' => 'FormProcessorAction',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorAction',
'localizable' => 0,
'html' => [
'type' => 'Number',
],
'readonly' => TRUE,
'add' => NULL,
],
'form_processor_id' => [
'name' => 'form_processor_id',
'type' => CRM_Utils_Type::T_INT,
'required' => true
),
'form_processor_instance_id' => array(
'name' => 'form_processor_instance_id',
'title' => E::ts('Form Processor ID'),
'type' => CRM_Utils_Type::T_INT,
'required' => true,
'FKApiName' => 'FormProcessorInstance',
),
'weight' => array(
'description' => E::ts('FK to Form Processor'),
'required' => TRUE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_action.form_processor_id',
'table_name' => 'civicrm_form_processor_action',
'entity' => 'FormProcessorAction',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorAction',
'localizable' => 0,
'FKClassName' => 'CRM_FormProcessor_DAO_FormProcessorInstance',
'add' => NULL,
],
'weight' => [
'name' => 'weight',
'title' => E::ts('Weight'),
'type' => CRM_Utils_Type::T_INT,
'required' => true,
),
'name' => array(
'name' => 'name',
'title' => E::ts('Name'),
'type' => CRM_Utils_Type::T_STRING,
'maxlength' => 80,
) ,
'title' => array(
'title' => E::ts('Weight'),
'required' => TRUE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_action.weight',
'default' => '0',
'table_name' => 'civicrm_form_processor_action',
'entity' => 'FormProcessorAction',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorAction',
'localizable' => 0,
'add' => NULL,
],
'title' => [
'name' => 'title',
'type' => CRM_Utils_Type::T_STRING,
'title' => E::ts('Title'),
'required' => TRUE,
'maxlength' => 128,
'size' => CRM_Utils_Type::HUGE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_action.title',
'table_name' => 'civicrm_form_processor_action',
'entity' => 'FormProcessorAction',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorAction',
'localizable' => 0,
'add' => NULL,
],
'name' => [
'name' => 'name',
'type' => CRM_Utils_Type::T_STRING,
'title' => E::ts('Name'),
'required' => TRUE,
'maxlength' => 80,
'required' => true,
) ,
'type' => array(
'size' => CRM_Utils_Type::HUGE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_action.name',
'table_name' => 'civicrm_form_processor_action',
'entity' => 'FormProcessorAction',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorAction',
'localizable' => 0,
'add' => NULL,
],
'type' => [
'name' => 'type',
'title' => E::ts('Type'),
'type' => CRM_Utils_Type::T_STRING,
'title' => E::ts('Type'),
'required' => TRUE,
'maxlength' => 80,
'required' => true,
),
'configuration' => array(
'size' => CRM_Utils_Type::HUGE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_action.type',
'table_name' => 'civicrm_form_processor_action',
'entity' => 'FormProcessorAction',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorAction',
'localizable' => 0,
'add' => NULL,
],
'configuration' => [
'name' => 'configuration',
'type' => CRM_Utils_Type::T_LONGTEXT,
'title' => E::ts('Configuration'),
'type' => CRM_Utils_Type::T_TEXT,
),
'mapping' => array(
'required' => FALSE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_action.configuration',
'table_name' => 'civicrm_form_processor_action',
'entity' => 'FormProcessorAction',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorAction',
'localizable' => 0,
'serialize' => self::SERIALIZE_JSON,
'add' => NULL,
],
'mapping' => [
'name' => 'mapping',
'type' => CRM_Utils_Type::T_LONGTEXT,
'title' => E::ts('Mapping'),
'type' => CRM_Utils_Type::T_TEXT,
),
'condition_configuration' => array(
'required' => FALSE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_action.mapping',
'table_name' => 'civicrm_form_processor_action',
'entity' => 'FormProcessorAction',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorAction',
'localizable' => 0,
'serialize' => self::SERIALIZE_JSON,
'add' => NULL,
],
'condition_configuration' => [
'name' => 'condition_configuration',
'title' => E::ts('Condition configuration'),
'type' => CRM_Utils_Type::T_TEXT,
),
'delay' => array(
'type' => CRM_Utils_Type::T_LONGTEXT,
'title' => E::ts('Condition Configuration'),
'required' => FALSE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_action.condition_configuration',
'table_name' => 'civicrm_form_processor_action',
'entity' => 'FormProcessorAction',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorAction',
'localizable' => 0,
'serialize' => self::SERIALIZE_JSON,
'add' => NULL,
],
'delay' => [
'name' => 'delay',
'title' => E::ts('Delay'),
'type' => CRM_Utils_Type::T_STRING,
'title' => E::ts('Delay'),
'required' => FALSE,
'maxlength' => 255,
'required' => true,
),
'delay_configuration' => array(
'size' => CRM_Utils_Type::HUGE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_action.delay',
'table_name' => 'civicrm_form_processor_action',
'entity' => 'FormProcessorAction',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorAction',
'localizable' => 0,
'add' => NULL,
],
'delay_configuration' => [
'name' => 'delay_configuration',
'title' => E::ts('Delay configuration'),
'type' => CRM_Utils_Type::T_TEXT,
),
);
'type' => CRM_Utils_Type::T_LONGTEXT,
'title' => E::ts('Delay Configuration'),
'required' => FALSE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_action.delay_configuration',
'table_name' => 'civicrm_form_processor_action',
'entity' => 'FormProcessorAction',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorAction',
'localizable' => 0,
'serialize' => self::SERIALIZE_JSON,
'add' => NULL,
],
];
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
}
return self::$_fields;
return Civi::$statics[__CLASS__]['fields'];
}
/**
* Returns an array containing, for each field, the array key used for that
* field in self::$_fields.
* Returns the list of fields that can be imported
*
* @param bool $prefix
*
* @access public
* @return array
*/
public static function &fieldKeys() {
if (!(self::$_fieldKeys)) {
self::$_fieldKeys = array(
'id' => 'id',
'form_processor_instance_id' => 'form_processor_instance_id',
'weight' => 'weight',
'name' => 'name',
'title' => 'title',
'type' => 'type',
'configuration' => 'configuration',
'mapping' => 'mapping',
'condition_configuration' => 'condition_configuration',
'delay' => 'delay',
'delay_configuration' => 'delay_configuration',
);
}
return self::$_fieldKeys;
public static function &import($prefix = FALSE) {
$r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'form_processor_action', $prefix, []);
return $r;
}
/**
* returns the list of fields that can be exported
* Returns the list of fields that can be exported
*
* @access public
* return array
* @static
*/
static function &export($prefix = false)
{
if (!(self::$_export)) {
self::$_export = array();
$fields = self::fields();
foreach($fields as $name => $field) {
if (CRM_Utils_Array::value('export', $field)) {
if ($prefix) {
self::$_export['form_porcessor_action'] = & $fields[$name];
} else {
self::$_export[$name] = & $fields[$name];
}
}
}
}
return self::$_export;
* @param bool $prefix
*
* @return array
*/
public static function &export($prefix = FALSE) {
$r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'form_processor_action', $prefix, []);
return $r;
}
/**
* Returns the list of indices
*
* @param bool $localize
*
* @return array
*/
public static function indices($localize = TRUE) {
$indices = [];
return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
}
}
\ No newline at end of file
}
<?php
/**
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
*
* Generated from form-processor/xml/schema/CRM/FormProcessor/FormProcessorCalculateAction.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:bdbac7afc50a38c8ebe5c1b0074584fa)
*/
use CRM_FormProcessor_ExtensionUtil as E;
/**
* Database access object for the FormProcessorCalculateAction entity.
*/
class CRM_FormProcessor_DAO_FormProcessorCalculateAction extends CRM_Core_DAO {
const EXT = E::LONG_NAME;
const TABLE_ADDED = '';
/**
* Static instance to hold the table name.
*
* @var string
*/
public static $_tableName = 'civicrm_form_processor_calculate_action';
/**
* Field to show when displaying a record.
*
* @var string
*/
public static $_labelField = 'title';
/**
* Should CiviCRM log any modifications to this table in the civicrm_log table.
*
* @var bool
*/
public static $_log = TRUE;
/**
* Unique FormProcessorInput ID
*
* @var int|string|null
* (SQL type: int unsigned)
* Note that values will be retrieved from the database as a string.
*/
public $id;
/**
* FK to Form Processor
*
* @var int|string
* (SQL type: int unsigned)
* Note that values will be retrieved from the database as a string.
*/
public $form_processor_id;
/**
* @var int|string
* (SQL type: int)
* Note that values will be retrieved from the database as a string.
*/
public $weight;
/**
* @var string
* (SQL type: varchar(128))
* Note that values will be retrieved from the database as a string.
*/
public $title;
/**
* @var string
* (SQL type: varchar(80))
* Note that values will be retrieved from the database as a string.
*/
public $name;
/**
* @var string
* (SQL type: varchar(80))
* Note that values will be retrieved from the database as a string.
*/
public $type;
/**
* @var string
* (SQL type: longtext)
* Note that values will be retrieved from the database as a string.
*/
public $configuration;
/**
* @var string
* (SQL type: longtext)
* Note that values will be retrieved from the database as a string.
*/
public $mapping;
/**
* @var string
* (SQL type: longtext)
* Note that values will be retrieved from the database as a string.
*/
public $condition_configuration;
/**
* @var string
* (SQL type: varchar(255))
* Note that values will be retrieved from the database as a string.
*/
public $delay;
/**
* @var string
* (SQL type: longtext)
* Note that values will be retrieved from the database as a string.
*/
public $delay_configuration;
/**
* Class constructor.
*/
public function __construct() {
$this->__table = 'civicrm_form_processor_calculate_action';
parent::__construct();
}
/**
* Returns localized title of this entity.
*
* @param bool $plural
* Whether to return the plural version of the title.
*/
public static function getEntityTitle($plural = FALSE) {
return $plural ? E::ts('Form Processor Calculate Actions') : E::ts('Form Processor Calculate Action');
}
/**
* Returns all the column names of this table
*
* @return array
*/
public static function &fields() {
if (!isset(Civi::$statics[__CLASS__]['fields'])) {
Civi::$statics[__CLASS__]['fields'] = [
'id' => [
'name' => 'id',
'type' => CRM_Utils_Type::T_INT,
'title' => E::ts('ID'),
'description' => E::ts('Unique FormProcessorInput ID'),
'required' => TRUE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_calculate_action.id',
'table_name' => 'civicrm_form_processor_calculate_action',
'entity' => 'FormProcessorCalculateAction',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorCalculateAction',
'localizable' => 0,
'html' => [
'type' => 'Number',
],
'readonly' => TRUE,
'add' => NULL,
],
'form_processor_id' => [
'name' => 'form_processor_id',
'type' => CRM_Utils_Type::T_INT,
'title' => E::ts('Form Processor ID'),
'description' => E::ts('FK to Form Processor'),
'required' => TRUE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_calculate_action.form_processor_id',
'table_name' => 'civicrm_form_processor_calculate_action',
'entity' => 'FormProcessorCalculateAction',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorCalculateAction',
'localizable' => 0,
'FKClassName' => 'CRM_FormProcessor_DAO_FormProcessorInstance',
'add' => NULL,
],
'weight' => [
'name' => 'weight',
'type' => CRM_Utils_Type::T_INT,
'title' => E::ts('Weight'),
'required' => TRUE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_calculate_action.weight',
'default' => '0',
'table_name' => 'civicrm_form_processor_calculate_action',
'entity' => 'FormProcessorCalculateAction',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorCalculateAction',
'localizable' => 0,
'add' => NULL,
],
'title' => [
'name' => 'title',
'type' => CRM_Utils_Type::T_STRING,
'title' => E::ts('Title'),
'required' => TRUE,
'maxlength' => 128,
'size' => CRM_Utils_Type::HUGE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_calculate_action.title',
'table_name' => 'civicrm_form_processor_calculate_action',
'entity' => 'FormProcessorCalculateAction',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorCalculateAction',
'localizable' => 0,
'add' => NULL,
],
'name' => [
'name' => 'name',
'type' => CRM_Utils_Type::T_STRING,
'title' => E::ts('Name'),
'required' => TRUE,
'maxlength' => 80,
'size' => CRM_Utils_Type::HUGE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_calculate_action.name',
'table_name' => 'civicrm_form_processor_calculate_action',
'entity' => 'FormProcessorCalculateAction',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorCalculateAction',
'localizable' => 0,
'add' => NULL,
],
'type' => [
'name' => 'type',
'type' => CRM_Utils_Type::T_STRING,
'title' => E::ts('Type'),
'required' => TRUE,
'maxlength' => 80,
'size' => CRM_Utils_Type::HUGE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_calculate_action.type',
'table_name' => 'civicrm_form_processor_calculate_action',
'entity' => 'FormProcessorCalculateAction',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorCalculateAction',
'localizable' => 0,
'add' => NULL,
],
'configuration' => [
'name' => 'configuration',
'type' => CRM_Utils_Type::T_LONGTEXT,
'title' => E::ts('Configuration'),
'required' => FALSE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_calculate_action.configuration',
'table_name' => 'civicrm_form_processor_calculate_action',
'entity' => 'FormProcessorCalculateAction',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorCalculateAction',
'localizable' => 0,
'serialize' => self::SERIALIZE_JSON,
'add' => NULL,
],
'mapping' => [
'name' => 'mapping',
'type' => CRM_Utils_Type::T_LONGTEXT,
'title' => E::ts('Mapping'),
'required' => FALSE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_calculate_action.mapping',
'table_name' => 'civicrm_form_processor_calculate_action',
'entity' => 'FormProcessorCalculateAction',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorCalculateAction',
'localizable' => 0,
'serialize' => self::SERIALIZE_JSON,
'add' => NULL,
],
'condition_configuration' => [
'name' => 'condition_configuration',
'type' => CRM_Utils_Type::T_LONGTEXT,
'title' => E::ts('Condition Configuration'),
'required' => FALSE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_calculate_action.condition_configuration',
'table_name' => 'civicrm_form_processor_calculate_action',
'entity' => 'FormProcessorCalculateAction',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorCalculateAction',
'localizable' => 0,
'serialize' => self::SERIALIZE_JSON,
'add' => NULL,
],
'delay' => [
'name' => 'delay',
'type' => CRM_Utils_Type::T_STRING,
'title' => E::ts('Delay'),
'required' => FALSE,
'maxlength' => 255,
'size' => CRM_Utils_Type::HUGE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_calculate_action.delay',
'table_name' => 'civicrm_form_processor_calculate_action',
'entity' => 'FormProcessorCalculateAction',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorCalculateAction',
'localizable' => 0,
'add' => NULL,
],
'delay_configuration' => [
'name' => 'delay_configuration',
'type' => CRM_Utils_Type::T_LONGTEXT,
'title' => E::ts('Delay Configuration'),
'required' => FALSE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_calculate_action.delay_configuration',
'table_name' => 'civicrm_form_processor_calculate_action',
'entity' => 'FormProcessorCalculateAction',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorCalculateAction',
'localizable' => 0,
'serialize' => self::SERIALIZE_JSON,
'add' => NULL,
],
];
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
}
return Civi::$statics[__CLASS__]['fields'];
}
/**
* Returns the list of fields that can be imported
*
* @param bool $prefix
*
* @return array
*/
public static function &import($prefix = FALSE) {
$r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'form_processor_calculate_action', $prefix, []);
return $r;
}
/**
* Returns the list of fields that can be exported
*
* @param bool $prefix
*
* @return array
*/
public static function &export($prefix = FALSE) {
$r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'form_processor_calculate_action', $prefix, []);
return $r;
}
/**
* Returns the list of indices
*
* @param bool $localize
*
* @return array
*/
public static function indices($localize = TRUE) {
$indices = [];
return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
}
}
<?php
/**
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
*
* Generated from form-processor/xml/schema/CRM/FormProcessor/FormProcessorDefaultDataAction.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:b80ca6c85d07387461765ac9834c71f4)
*/
use CRM_FormProcessor_ExtensionUtil as E;
/**
* @author Jaap Jansma (CiviCooP) <jaap.jansma@civicoop.org>
* @license http://www.gnu.org/licenses/agpl-3.0.html
* Database access object for the FormProcessorDefaultDataAction entity.
*/
class CRM_FormProcessor_DAO_FormProcessorDefaultDataAction extends CRM_Core_DAO {
const EXT = E::LONG_NAME;
const TABLE_ADDED = '';
/**
* Static instance to hold the table name.
*
* @var string
*/
public static $_tableName = 'civicrm_form_processor_default_data_action';
/**
* Field to show when displaying a record.
*
* @var string
*/
public static $_labelField = 'title';
/**
* static instance to hold the field values
* Should CiviCRM log any modifications to this table in the civicrm_log table.
*
* @var array
* @static
* @var bool
*/
public static $_log = TRUE;
/**
* Unique FormProcessorInput ID
*
* @var int|string|null
* (SQL type: int unsigned)
* Note that values will be retrieved from the database as a string.
*/
public $id;
/**
* FK to Form Processor
*
* @var int|string
* (SQL type: int unsigned)
* Note that values will be retrieved from the database as a string.
*/
public $form_processor_id;
/**
* @var int|string
* (SQL type: int)
* Note that values will be retrieved from the database as a string.
*/
public $weight;
/**
* @var string
* (SQL type: varchar(128))
* Note that values will be retrieved from the database as a string.
*/
static $_fields = null;
static $_export = null;
public $title;
/**
* @var string
* (SQL type: varchar(80))
* Note that values will be retrieved from the database as a string.
*/
public $name;
/**
* @var string
* (SQL type: varchar(80))
* Note that values will be retrieved from the database as a string.
*/
public $type;
/**
* empty definition for virtual function
* @var string
* (SQL type: longtext)
* Note that values will be retrieved from the database as a string.
*/
static function getTableName() {
return 'civicrm_form_processor_default_data_action';
public $configuration;
/**
* @var string
* (SQL type: longtext)
* Note that values will be retrieved from the database as a string.
*/
public $mapping;
/**
* @var string
* (SQL type: longtext)
* Note that values will be retrieved from the database as a string.
*/
public $condition_configuration;
/**
* @var string
* (SQL type: varchar(255))
* Note that values will be retrieved from the database as a string.
*/
public $delay;
/**
* @var string
* (SQL type: longtext)
* Note that values will be retrieved from the database as a string.
*/
public $delay_configuration;
/**
* Class constructor.
*/
public function __construct() {
$this->__table = 'civicrm_form_processor_default_data_action';
parent::__construct();
}
/**
* Returns localized title of this entity.
*
* @param bool $plural
* Whether to return the plural version of the title.
*/
public static function getEntityTitle($plural = FALSE) {
return $plural ? E::ts('Form Processor Default Data Actions') : E::ts('Form Processor Default Data Action');
}
/**
* returns all the column names of this table
* Returns all the column names of this table
*
* @access public
* @return array
*/
public static function &fields() {
if (!(self::$_fields)) {
self::$_fields = array(
'id' => array(
if (!isset(Civi::$statics[__CLASS__]['fields'])) {
Civi::$statics[__CLASS__]['fields'] = [
'id' => [
'name' => 'id',
'type' => CRM_Utils_Type::T_INT,
'title' => E::ts('ID'),
'description' => E::ts('Unique FormProcessorInput ID'),
'required' => TRUE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_default_data_action.id',
'table_name' => 'civicrm_form_processor_default_data_action',
'entity' => 'FormProcessorDefaultDataAction',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorDefaultDataAction',
'localizable' => 0,
'html' => [
'type' => 'Number',
],
'readonly' => TRUE,
'add' => NULL,
],
'form_processor_id' => [
'name' => 'form_processor_id',
'type' => CRM_Utils_Type::T_INT,
'required' => true
),
'form_processor_instance_id' => array(
'name' => 'form_processor_instance_id',
'title' => E::ts('Form Processor ID'),
'type' => CRM_Utils_Type::T_INT,
'required' => true,
'FKApiName' => 'FormProcessorInstance',
),
'weight' => array(
'description' => E::ts('FK to Form Processor'),
'required' => TRUE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_default_data_action.form_processor_id',
'table_name' => 'civicrm_form_processor_default_data_action',
'entity' => 'FormProcessorDefaultDataAction',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorDefaultDataAction',
'localizable' => 0,
'FKClassName' => 'CRM_FormProcessor_DAO_FormProcessorInstance',
'add' => NULL,
],
'weight' => [
'name' => 'weight',
'title' => E::ts('Weight'),
'type' => CRM_Utils_Type::T_INT,
'required' => true,
),
'name' => array(
'name' => 'name',
'title' => E::ts('Name'),
'type' => CRM_Utils_Type::T_STRING,
'maxlength' => 80,
) ,
'title' => array(
'title' => E::ts('Weight'),
'required' => TRUE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_default_data_action.weight',
'default' => '0',
'table_name' => 'civicrm_form_processor_default_data_action',
'entity' => 'FormProcessorDefaultDataAction',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorDefaultDataAction',
'localizable' => 0,
'add' => NULL,
],
'title' => [
'name' => 'title',
'type' => CRM_Utils_Type::T_STRING,
'title' => E::ts('Title'),
'required' => TRUE,
'maxlength' => 128,
'size' => CRM_Utils_Type::HUGE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_default_data_action.title',
'table_name' => 'civicrm_form_processor_default_data_action',
'entity' => 'FormProcessorDefaultDataAction',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorDefaultDataAction',
'localizable' => 0,
'add' => NULL,
],
'name' => [
'name' => 'name',
'type' => CRM_Utils_Type::T_STRING,
'title' => E::ts('Name'),
'required' => TRUE,
'maxlength' => 80,
'required' => true,
) ,
'type' => array(
'size' => CRM_Utils_Type::HUGE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_default_data_action.name',
'table_name' => 'civicrm_form_processor_default_data_action',
'entity' => 'FormProcessorDefaultDataAction',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorDefaultDataAction',
'localizable' => 0,
'add' => NULL,
],
'type' => [
'name' => 'type',
'title' => E::ts('Type'),
'type' => CRM_Utils_Type::T_STRING,
'title' => E::ts('Type'),
'required' => TRUE,
'maxlength' => 80,
'required' => true,
),
'configuration' => array(
'size' => CRM_Utils_Type::HUGE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_default_data_action.type',
'table_name' => 'civicrm_form_processor_default_data_action',
'entity' => 'FormProcessorDefaultDataAction',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorDefaultDataAction',
'localizable' => 0,
'add' => NULL,
],
'configuration' => [
'name' => 'configuration',
'type' => CRM_Utils_Type::T_LONGTEXT,
'title' => E::ts('Configuration'),
'type' => CRM_Utils_Type::T_TEXT,
),
'mapping' => array(
'required' => FALSE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_default_data_action.configuration',
'table_name' => 'civicrm_form_processor_default_data_action',
'entity' => 'FormProcessorDefaultDataAction',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorDefaultDataAction',
'localizable' => 0,
'serialize' => self::SERIALIZE_JSON,
'add' => NULL,
],
'mapping' => [
'name' => 'mapping',
'type' => CRM_Utils_Type::T_LONGTEXT,
'title' => E::ts('Mapping'),
'type' => CRM_Utils_Type::T_TEXT,
),
'condition_configuration' => array(
'required' => FALSE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_default_data_action.mapping',
'table_name' => 'civicrm_form_processor_default_data_action',
'entity' => 'FormProcessorDefaultDataAction',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorDefaultDataAction',
'localizable' => 0,
'serialize' => self::SERIALIZE_JSON,
'add' => NULL,
],
'condition_configuration' => [
'name' => 'condition_configuration',
'title' => E::ts('Condition configuration'),
'type' => CRM_Utils_Type::T_TEXT,
)
);
'type' => CRM_Utils_Type::T_LONGTEXT,
'title' => E::ts('Condition Configuration'),
'required' => FALSE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_default_data_action.condition_configuration',
'table_name' => 'civicrm_form_processor_default_data_action',
'entity' => 'FormProcessorDefaultDataAction',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorDefaultDataAction',
'localizable' => 0,
'serialize' => self::SERIALIZE_JSON,
'add' => NULL,
],
'delay' => [
'name' => 'delay',
'type' => CRM_Utils_Type::T_STRING,
'title' => E::ts('Delay'),
'required' => FALSE,
'maxlength' => 255,
'size' => CRM_Utils_Type::HUGE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_default_data_action.delay',
'table_name' => 'civicrm_form_processor_default_data_action',
'entity' => 'FormProcessorDefaultDataAction',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorDefaultDataAction',
'localizable' => 0,
'add' => NULL,
],
'delay_configuration' => [
'name' => 'delay_configuration',
'type' => CRM_Utils_Type::T_LONGTEXT,
'title' => E::ts('Delay Configuration'),
'required' => FALSE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_default_data_action.delay_configuration',
'table_name' => 'civicrm_form_processor_default_data_action',
'entity' => 'FormProcessorDefaultDataAction',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorDefaultDataAction',
'localizable' => 0,
'serialize' => self::SERIALIZE_JSON,
'add' => NULL,
],
];
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
}
return self::$_fields;
return Civi::$statics[__CLASS__]['fields'];
}
/**
* Returns an array containing, for each field, the array key used for that
* field in self::$_fields.
* Returns the list of fields that can be imported
*
* @param bool $prefix
*
* @access public
* @return array
*/
public static function &fieldKeys() {
if (!(self::$_fieldKeys)) {
self::$_fieldKeys = array(
'id' => 'id',
'form_processor_instance_id' => 'form_processor_instance_id',
'weight' => 'weight',
'name' => 'name',
'title' => 'title',
'type' => 'type',
'configuration' => 'configuration',
'mapping' => 'mapping',
'condition_configuration' => 'condition_configuration',
);
}
return self::$_fieldKeys;
public static function &import($prefix = FALSE) {
$r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'form_processor_default_data_action', $prefix, []);
return $r;
}
/**
* returns the list of fields that can be exported
* Returns the list of fields that can be exported
*
* @access public
* return array
* @static
*/
static function &export($prefix = false)
{
if (!(self::$_export)) {
self::$_export = array();
$fields = self::fields();
foreach($fields as $name => $field) {
if (CRM_Utils_Array::value('export', $field)) {
if ($prefix) {
self::$_export['form_porcessor_default_dataaction'] = & $fields[$name];
} else {
self::$_export[$name] = & $fields[$name];
}
}
}
}
return self::$_export;
* @param bool $prefix
*
* @return array
*/
public static function &export($prefix = FALSE) {
$r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'form_processor_default_data_action', $prefix, []);
return $r;
}
/**
* Returns the list of indices
*
* @param bool $localize
*
* @return array
*/
public static function indices($localize = TRUE) {
$indices = [];
return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
}
}
\ No newline at end of file
}
<?php
/**
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
*
* Generated from form-processor/xml/schema/CRM/FormProcessor/FormProcessorDefaultDataInput.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:f17d098d588a2a0a57f87259d6866fd7)
*/
use CRM_FormProcessor_ExtensionUtil as E;
/**
* @author Jaap Jansma (CiviCooP) <jaap.jansma@civicoop.org>
* @license http://www.gnu.org/licenses/agpl-3.0.html
* Database access object for the FormProcessorDefaultDataInput entity.
*/
class CRM_FormProcessor_DAO_FormProcessorDefaultDataInput extends CRM_Core_DAO {
const EXT = E::LONG_NAME;
const TABLE_ADDED = '';
/**
* Static instance to hold the table name.
*
* @var string
*/
public static $_tableName = 'civicrm_form_processor_default_data_input';
/**
* Field to show when displaying a record.
*
* @var string
*/
public static $_labelField = 'title';
/**
* static instance to hold the field values
* Should CiviCRM log any modifications to this table in the civicrm_log table.
*
* @var array
* @static
* @var bool
*/
static $_fields = null;
static $_export = null;
public static $_log = TRUE;
/**
* Unique FormProcessorInput ID
*
* @var int|string|null
* (SQL type: int unsigned)
* Note that values will be retrieved from the database as a string.
*/
public $id;
/**
* FK to Form Processor
*
* @var int|string
* (SQL type: int unsigned)
* Note that values will be retrieved from the database as a string.
*/
public $form_processor_id;
/**
* @var int|string
* (SQL type: int)
* Note that values will be retrieved from the database as a string.
*/
public $weight;
/**
* @var bool|string
* (SQL type: tinyint)
* Note that values will be retrieved from the database as a string.
*/
public $include_formatted_params;
/**
* @var string
* (SQL type: varchar(128))
* Note that values will be retrieved from the database as a string.
*/
public $title;
/**
* @var string
* (SQL type: varchar(80))
* Note that values will be retrieved from the database as a string.
*/
public $name;
/**
* @var string
* (SQL type: varchar(80))
* Note that values will be retrieved from the database as a string.
*/
public $type;
/**
* @var bool|string
* (SQL type: tinyint)
* Note that values will be retrieved from the database as a string.
*/
public $is_required;
/**
* @var string
* (SQL type: varchar(256))
* Note that values will be retrieved from the database as a string.
*/
public $default_value;
/**
* empty definition for virtual function
* @var string
* (SQL type: longtext)
* Note that values will be retrieved from the database as a string.
*/
static function getTableName() {
return 'civicrm_form_processor_default_data_input';
public $configuration;
/**
* @var string
* (SQL type: longtext)
* Note that values will be retrieved from the database as a string.
*/
public $parameter_mapping;
/**
* @var string
* (SQL type: longtext)
* Note that values will be retrieved from the database as a string.
*/
public $default_data_parameter_mapping;
/**
* Class constructor.
*/
public function __construct() {
$this->__table = 'civicrm_form_processor_default_data_input';
parent::__construct();
}
/**
* Returns localized title of this entity.
*
* @param bool $plural
* Whether to return the plural version of the title.
*/
public static function getEntityTitle($plural = FALSE) {
return $plural ? E::ts('Form Processor Default Data Inputs') : E::ts('Form Processor Default Data Input');
}
/**
* returns all the column names of this table
* Returns all the column names of this table
*
* @access public
* @return array
*/
public static function &fields() {
if (!(self::$_fields)) {
self::$_fields = array(
'id' => array(
if (!isset(Civi::$statics[__CLASS__]['fields'])) {
Civi::$statics[__CLASS__]['fields'] = [
'id' => [
'name' => 'id',
'type' => CRM_Utils_Type::T_INT,
'title' => E::ts('ID'),
'description' => E::ts('Unique FormProcessorInput ID'),
'required' => TRUE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_default_data_input.id',
'table_name' => 'civicrm_form_processor_default_data_input',
'entity' => 'FormProcessorDefaultDataInput',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorDefaultDataInput',
'localizable' => 0,
'html' => [
'type' => 'Number',
],
'readonly' => TRUE,
'add' => NULL,
],
'form_processor_id' => [
'name' => 'form_processor_id',
'type' => CRM_Utils_Type::T_INT,
'required' => true
),
'form_processor_instance_id' => array(
'name' => 'form_processor_instance_id',
'title' => E::ts('Form Processor Instance ID'),
'title' => E::ts('Form Processor ID'),
'description' => E::ts('FK to Form Processor'),
'required' => TRUE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_default_data_input.form_processor_id',
'table_name' => 'civicrm_form_processor_default_data_input',
'entity' => 'FormProcessorDefaultDataInput',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorDefaultDataInput',
'localizable' => 0,
'FKClassName' => 'CRM_FormProcessor_DAO_FormProcessorInstance',
'add' => NULL,
],
'weight' => [
'name' => 'weight',
'type' => CRM_Utils_Type::T_INT,
'required' => true,
'FKApiName' => 'FormProcessorInstance',
),
'name' => array(
'title' => E::ts('Weight'),
'required' => TRUE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_default_data_input.weight',
'default' => '0',
'table_name' => 'civicrm_form_processor_default_data_input',
'entity' => 'FormProcessorDefaultDataInput',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorDefaultDataInput',
'localizable' => 0,
'add' => NULL,
],
'include_formatted_params' => [
'name' => 'include_formatted_params',
'type' => CRM_Utils_Type::T_BOOLEAN,
'title' => E::ts('Include in formatted params'),
'required' => FALSE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_default_data_input.include_formatted_params',
'default' => '1',
'table_name' => 'civicrm_form_processor_default_data_input',
'entity' => 'FormProcessorDefaultDataInput',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorDefaultDataInput',
'localizable' => 0,
'add' => NULL,
],
'title' => [
'name' => 'title',
'type' => CRM_Utils_Type::T_STRING,
'title' => E::ts('Title'),
'required' => FALSE,
'maxlength' => 128,
'size' => CRM_Utils_Type::HUGE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_default_data_input.title',
'table_name' => 'civicrm_form_processor_default_data_input',
'entity' => 'FormProcessorDefaultDataInput',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorDefaultDataInput',
'localizable' => 0,
'add' => NULL,
],
'name' => [
'name' => 'name',
'title' => E::ts('Name'),
'type' => CRM_Utils_Type::T_STRING,
'title' => E::ts('Name'),
'required' => TRUE,
'maxlength' => 80,
'required' => true,
) ,
'type' => array(
'size' => CRM_Utils_Type::HUGE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_default_data_input.name',
'table_name' => 'civicrm_form_processor_default_data_input',
'entity' => 'FormProcessorDefaultDataInput',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorDefaultDataInput',
'localizable' => 0,
'add' => NULL,
],
'type' => [
'name' => 'type',
'title' => E::ts('Type'),
'type' => CRM_Utils_Type::T_STRING,
'title' => E::ts('Type'),
'required' => TRUE,
'maxlength' => 80,
'required' => true,
),
'is_required' => array(
'size' => CRM_Utils_Type::HUGE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_default_data_input.type',
'table_name' => 'civicrm_form_processor_default_data_input',
'entity' => 'FormProcessorDefaultDataInput',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorDefaultDataInput',
'localizable' => 0,
'add' => NULL,
],
'is_required' => [
'name' => 'is_required',
'type' => CRM_Utils_Type::T_BOOLEAN,
'title' => E::ts('Is required'),
'type' => CRM_Utils_Type::T_INT,
),
'default_value' => array(
'required' => FALSE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_default_data_input.is_required',
'default' => '0',
'table_name' => 'civicrm_form_processor_default_data_input',
'entity' => 'FormProcessorDefaultDataInput',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorDefaultDataInput',
'localizable' => 0,
'add' => NULL,
],
'default_value' => [
'name' => 'default_value',
'title' => E::ts('Default Value'),
'type' => CRM_Utils_Type::T_STRING,
'title' => E::ts('Default Value'),
'required' => FALSE,
'maxlength' => 256,
'required' => true,
),
'configuration' => array(
'size' => CRM_Utils_Type::HUGE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_default_data_input.default_value',
'table_name' => 'civicrm_form_processor_default_data_input',
'entity' => 'FormProcessorDefaultDataInput',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorDefaultDataInput',
'localizable' => 0,
'add' => NULL,
],
'configuration' => [
'name' => 'configuration',
'type' => CRM_Utils_Type::T_LONGTEXT,
'title' => E::ts('Configuration'),
'type' => CRM_Utils_Type::T_TEXT,
),
);
'required' => FALSE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_default_data_input.configuration',
'table_name' => 'civicrm_form_processor_default_data_input',
'entity' => 'FormProcessorDefaultDataInput',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorDefaultDataInput',
'localizable' => 0,
'serialize' => self::SERIALIZE_JSON,
'add' => NULL,
],
'parameter_mapping' => [
'name' => 'parameter_mapping',
'type' => CRM_Utils_Type::T_LONGTEXT,
'title' => E::ts('Parameter Mapping'),
'required' => FALSE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_default_data_input.parameter_mapping',
'table_name' => 'civicrm_form_processor_default_data_input',
'entity' => 'FormProcessorDefaultDataInput',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorDefaultDataInput',
'localizable' => 0,
'serialize' => self::SERIALIZE_JSON,
'add' => NULL,
],
'default_data_parameter_mapping' => [
'name' => 'default_data_parameter_mapping',
'type' => CRM_Utils_Type::T_LONGTEXT,
'title' => E::ts('Default Data Parameter Mapping'),
'required' => FALSE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_default_data_input.default_data_parameter_mapping',
'table_name' => 'civicrm_form_processor_default_data_input',
'entity' => 'FormProcessorDefaultDataInput',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorDefaultDataInput',
'localizable' => 0,
'serialize' => self::SERIALIZE_JSON,
'add' => NULL,
],
];
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
}
return self::$_fields;
return Civi::$statics[__CLASS__]['fields'];
}
/**
* Returns an array containing, for each field, the array key used for that
* field in self::$_fields.
* Returns the list of fields that can be imported
*
* @param bool $prefix
*
* @access public
* @return array
*/
public static function &fieldKeys() {
if (!(self::$_fieldKeys)) {
self::$_fieldKeys = array(
'id' => 'id',
'form_processor_instance_id' => 'form_processor_instance_id',
'name' => 'name',
'type' => 'type',
'is_required' => 'is_required',
'default_value' => 'default_value',
'configuration' => 'configuration',
);
}
return self::$_fieldKeys;
public static function &import($prefix = FALSE) {
$r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'form_processor_default_data_input', $prefix, []);
return $r;
}
/**
* returns the list of fields that can be exported
* Returns the list of fields that can be exported
*
* @access public
* return array
* @static
*/
static function &export($prefix = false)
{
if (!(self::$_export)) {
self::$_export = array();
$fields = self::fields();
foreach($fields as $name => $field) {
if (CRM_Utils_Array::value('export', $field)) {
if ($prefix) {
self::$_export['form_processor_default_data_input'] = & $fields[$name];
} else {
self::$_export[$name] = & $fields[$name];
}
}
}
}
return self::$_export;
* @param bool $prefix
*
* @return array
*/
public static function &export($prefix = FALSE) {
$r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'form_processor_default_data_input', $prefix, []);
return $r;
}
/**
* Returns the list of indices
*
* @param bool $localize
*
* @return array
*/
public static function indices($localize = TRUE) {
$indices = [
'name_id_UNIQUE' => [
'name' => 'name_id_UNIQUE',
'field' => [
0 => 'form_processor_id',
1 => 'name',
],
'localizable' => FALSE,
'unique' => TRUE,
'sig' => 'civicrm_form_processor_default_data_input::1::form_processor_id::name',
],
];
return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
}
}
\ No newline at end of file
}
<?php
/**
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
*
* Generated from form-processor/xml/schema/CRM/FormProcessor/FormProcessorInput.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:a89955acb37e95214fa58b60b58d677f)
*/
use CRM_FormProcessor_ExtensionUtil as E;
/**
* @author Jaap Jansma (CiviCooP) <jaap.jansma@civicoop.org>
* @license http://www.gnu.org/licenses/agpl-3.0.html
* Database access object for the FormProcessorInput entity.
*/
class CRM_FormProcessor_DAO_FormProcessorInput extends CRM_Core_DAO {
const EXT = E::LONG_NAME;
const TABLE_ADDED = '';
/**
* Static instance to hold the table name.
*
* @var string
*/
public static $_tableName = 'civicrm_form_processor_input';
/**
* Field to show when displaying a record.
*
* @var string
*/
public static $_labelField = 'title';
/**
* static instance to hold the field values
* Should CiviCRM log any modifications to this table in the civicrm_log table.
*
* @var array
* @static
* @var bool
*/
public static $_log = TRUE;
/**
* Unique FormProcessorInput ID
*
* @var int|string|null
* (SQL type: int unsigned)
* Note that values will be retrieved from the database as a string.
*/
public $id;
/**
* FK to Form Processor
*
* @var int|string
* (SQL type: int unsigned)
* Note that values will be retrieved from the database as a string.
*/
public $form_processor_id;
/**
* @var int|string
* (SQL type: int)
* Note that values will be retrieved from the database as a string.
*/
public $weight;
/**
* @var bool|string
* (SQL type: tinyint)
* Note that values will be retrieved from the database as a string.
*/
public $include_formatted_params;
/**
* @var string
* (SQL type: varchar(128))
* Note that values will be retrieved from the database as a string.
*/
public $title;
/**
* @var string
* (SQL type: varchar(80))
* Note that values will be retrieved from the database as a string.
*/
public $name;
/**
* @var string
* (SQL type: varchar(80))
* Note that values will be retrieved from the database as a string.
*/
public $type;
/**
* @var bool|string
* (SQL type: tinyint)
* Note that values will be retrieved from the database as a string.
*/
public $is_required;
/**
* @var string
* (SQL type: varchar(256))
* Note that values will be retrieved from the database as a string.
*/
public $default_value;
/**
* @var string
* (SQL type: longtext)
* Note that values will be retrieved from the database as a string.
*/
public $configuration;
/**
* @var string
* (SQL type: longtext)
* Note that values will be retrieved from the database as a string.
*/
static $_fields = null;
static $_export = null;
public $parameter_mapping;
/**
* empty definition for virtual function
* @var string
* (SQL type: longtext)
* Note that values will be retrieved from the database as a string.
*/
static function getTableName() {
return 'civicrm_form_processor_input';
public $default_data_parameter_mapping;
/**
* Class constructor.
*/
public function __construct() {
$this->__table = 'civicrm_form_processor_input';
parent::__construct();
}
/**
* returns all the column names of this table
* Returns localized title of this entity.
*
* @param bool $plural
* Whether to return the plural version of the title.
*/
public static function getEntityTitle($plural = FALSE) {
return $plural ? E::ts('Form Processor Inputs') : E::ts('Form Processor Input');
}
/**
* Returns all the column names of this table
*
* @access public
* @return array
*/
public static function &fields() {
if (!(self::$_fields)) {
self::$_fields = array(
'id' => array(
if (!isset(Civi::$statics[__CLASS__]['fields'])) {
Civi::$statics[__CLASS__]['fields'] = [
'id' => [
'name' => 'id',
'type' => CRM_Utils_Type::T_INT,
'title' => E::ts('ID'),
'description' => E::ts('Unique FormProcessorInput ID'),
'required' => TRUE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_input.id',
'table_name' => 'civicrm_form_processor_input',
'entity' => 'FormProcessorInput',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorInput',
'localizable' => 0,
'html' => [
'type' => 'Number',
],
'readonly' => TRUE,
'add' => NULL,
],
'form_processor_id' => [
'name' => 'form_processor_id',
'type' => CRM_Utils_Type::T_INT,
'required' => true
),
'form_processor_instance_id' => array(
'name' => 'form_processor_instance_id',
'title' => E::ts('Form Processor Instance ID'),
'title' => E::ts('Form Processor ID'),
'description' => E::ts('FK to Form Processor'),
'required' => TRUE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_input.form_processor_id',
'table_name' => 'civicrm_form_processor_input',
'entity' => 'FormProcessorInput',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorInput',
'localizable' => 0,
'FKClassName' => 'CRM_FormProcessor_DAO_FormProcessorInstance',
'add' => NULL,
],
'weight' => [
'name' => 'weight',
'type' => CRM_Utils_Type::T_INT,
'required' => true,
'FKApiName' => 'FormProcessorInstance',
),
'title' => array(
'title' => E::ts('Weight'),
'required' => TRUE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_input.weight',
'default' => '0',
'table_name' => 'civicrm_form_processor_input',
'entity' => 'FormProcessorInput',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorInput',
'localizable' => 0,
'add' => NULL,
],
'include_formatted_params' => [
'name' => 'include_formatted_params',
'type' => CRM_Utils_Type::T_BOOLEAN,
'title' => E::ts('Include in formatted params'),
'required' => FALSE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_input.include_formatted_params',
'default' => '1',
'table_name' => 'civicrm_form_processor_input',
'entity' => 'FormProcessorInput',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorInput',
'localizable' => 0,
'add' => NULL,
],
'title' => [
'name' => 'title',
'title' => E::ts('Title'),
'type' => CRM_Utils_Type::T_STRING,
'title' => E::ts('Title'),
'required' => FALSE,
'maxlength' => 128,
'required' => true,
) ,
'name' => array(
'size' => CRM_Utils_Type::HUGE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_input.title',
'table_name' => 'civicrm_form_processor_input',
'entity' => 'FormProcessorInput',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorInput',
'localizable' => 0,
'add' => NULL,
],
'name' => [
'name' => 'name',
'title' => E::ts('Name'),
'type' => CRM_Utils_Type::T_STRING,
'title' => E::ts('Name'),
'required' => TRUE,
'maxlength' => 80,
'required' => true,
) ,
'type' => array(
'size' => CRM_Utils_Type::HUGE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_input.name',
'table_name' => 'civicrm_form_processor_input',
'entity' => 'FormProcessorInput',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorInput',
'localizable' => 0,
'add' => NULL,
],
'type' => [
'name' => 'type',
'title' => E::ts('Type'),
'type' => CRM_Utils_Type::T_STRING,
'title' => E::ts('Type'),
'required' => TRUE,
'maxlength' => 80,
'required' => true,
),
'is_required' => array(
'size' => CRM_Utils_Type::HUGE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_input.type',
'table_name' => 'civicrm_form_processor_input',
'entity' => 'FormProcessorInput',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorInput',
'localizable' => 0,
'add' => NULL,
],
'is_required' => [
'name' => 'is_required',
'type' => CRM_Utils_Type::T_BOOLEAN,
'title' => E::ts('Is required'),
'type' => CRM_Utils_Type::T_INT,
),
'default_value' => array(
'required' => FALSE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_input.is_required',
'default' => '0',
'table_name' => 'civicrm_form_processor_input',
'entity' => 'FormProcessorInput',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorInput',
'localizable' => 0,
'add' => NULL,
],
'default_value' => [
'name' => 'default_value',
'title' => E::ts('Default Value'),
'type' => CRM_Utils_Type::T_STRING,
'title' => E::ts('Default Value'),
'required' => FALSE,
'maxlength' => 256,
'required' => true,
),
'configuration' => array(
'size' => CRM_Utils_Type::HUGE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_input.default_value',
'table_name' => 'civicrm_form_processor_input',
'entity' => 'FormProcessorInput',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorInput',
'localizable' => 0,
'add' => NULL,
],
'configuration' => [
'name' => 'configuration',
'type' => CRM_Utils_Type::T_LONGTEXT,
'title' => E::ts('Configuration'),
'type' => CRM_Utils_Type::T_TEXT,
),
);
'required' => FALSE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_input.configuration',
'table_name' => 'civicrm_form_processor_input',
'entity' => 'FormProcessorInput',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorInput',
'localizable' => 0,
'serialize' => self::SERIALIZE_JSON,
'add' => NULL,
],
'parameter_mapping' => [
'name' => 'parameter_mapping',
'type' => CRM_Utils_Type::T_LONGTEXT,
'title' => E::ts('Parameter Mapping'),
'required' => FALSE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_input.parameter_mapping',
'table_name' => 'civicrm_form_processor_input',
'entity' => 'FormProcessorInput',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorInput',
'localizable' => 0,
'serialize' => self::SERIALIZE_JSON,
'add' => NULL,
],
'default_data_parameter_mapping' => [
'name' => 'default_data_parameter_mapping',
'type' => CRM_Utils_Type::T_LONGTEXT,
'title' => E::ts('Default Data Parameter Mapping'),
'required' => FALSE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_form_processor_input.default_data_parameter_mapping',
'table_name' => 'civicrm_form_processor_input',
'entity' => 'FormProcessorInput',
'bao' => 'CRM_FormProcessor_DAO_FormProcessorInput',
'localizable' => 0,
'serialize' => self::SERIALIZE_JSON,
'add' => NULL,
],
];
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
}
return self::$_fields;
return Civi::$statics[__CLASS__]['fields'];
}
/**
* Returns an array containing, for each field, the array key used for that
* field in self::$_fields.
* Returns the list of fields that can be imported
*
* @param bool $prefix
*
* @access public
* @return array
*/
public static function &fieldKeys() {
if (!(self::$_fieldKeys)) {
self::$_fieldKeys = array(
'id' => 'id',
'form_processor_instance_id' => 'form_processor_instance_id',
'title' => 'title',
'name' => 'name',
'type' => 'type',
'is_required' => 'is_required',
'default_value' => 'default_value',
'configuration' => 'configuration',
);
}
return self::$_fieldKeys;
public static function &import($prefix = FALSE) {
$r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'form_processor_input', $prefix, []);
return $r;
}
/**
* returns the list of fields that can be exported
* Returns the list of fields that can be exported
*
* @access public
* return array
* @static
*/
static function &export($prefix = false)
{
if (!(self::$_export)) {
self::$_export = array();
$fields = self::fields();
foreach($fields as $name => $field) {
if (CRM_Utils_Array::value('export', $field)) {
if ($prefix) {
self::$_export['form_processor_input'] = & $fields[$name];
} else {
self::$_export[$name] = & $fields[$name];
}
}
}
}
return self::$_export;
* @param bool $prefix
*
* @return array
*/
public static function &export($prefix = FALSE) {
$r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'form_processor_input', $prefix, []);
return $r;
}
/**
* Returns the list of indices
*
* @param bool $localize
*
* @return array
*/
public static function indices($localize = TRUE) {
$indices = [
'name_id_UNIQUE' => [
'name' => 'name_id_UNIQUE',
'field' => [
0 => 'form_processor_id',
1 => 'name',
],
'localizable' => FALSE,
'unique' => TRUE,
'sig' => 'civicrm_form_processor_input::1::form_processor_id::name',
],
];
return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
}
}
\ No newline at end of file
}
This diff is collapsed.
This diff is collapsed.