Commit e842c5d3 authored by jaapjansma's avatar jaapjansma

Merge branch 'whitespace_cleanup' into 'master'

Whitespace cleanup

See merge request !25
parents f4c43221 48ec3afb
......@@ -5,15 +5,15 @@ 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(
$loader->setModules(array('form_processor'));
$loader->setPageName('civicrm/admin/formprocessor');
\Civi::resources()->addSetting(array(
'crmApp' => array(
'defaultRoute' => 'formprocessors',
),
));
$loader->load();
parent::run();
$loader->load();
parent::run();
}
}
......@@ -7,10 +7,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,7 +26,7 @@ class CRM_FormProcessor_BAO_FormProcessorDefaultDataAction extends CRM_FormProce
}
}
}
$action->orderBy('weight');
$action->orderBy('weight');
$action->find();
while ($action->fetch()) {
$row = array();
......@@ -63,8 +63,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 +75,14 @@ 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'])) {
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 +91,31 @@ 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->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);
}
$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,21 +125,21 @@ 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
......@@ -155,7 +155,7 @@ class CRM_FormProcessor_BAO_FormProcessorDefaultDataAction extends CRM_FormProce
}
}
/**
/**
* Public function to generate name from title
*
* @param $title
......@@ -168,30 +168,30 @@ class CRM_FormProcessor_BAO_FormProcessorDefaultDataAction extends CRM_FormProce
$nameString = implode('_', $titleParts);
return substr($nameString, 0, 80);
}
/**
* Returns whether the name is valid or not
*
* @param string $name
/**
* 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) {
* @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;
}
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
......@@ -8,7 +8,7 @@ use CRM_FormProcessor_ExtensionUtil as E;
*/
class CRM_FormProcessor_BAO_FormProcessorDefaultDataInput extends CRM_FormProcessor_DAO_FormProcessorDefaultDataInput {
/**
/**
* Function to get values
*
* @return array $result found rows with data
......@@ -31,24 +31,24 @@ class CRM_FormProcessor_BAO_FormProcessorDefaultDataInput extends CRM_FormProces
$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')));
$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')));
$result[$row['id']] = $row;
} else {
......@@ -74,7 +74,7 @@ class CRM_FormProcessor_BAO_FormProcessorDefaultDataInput extends CRM_FormProces
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', 'FormProcessorDefaultDataInput', $params['id'], $params);
}
else {
......@@ -88,13 +88,13 @@ 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);
}
$input->save();
self::storeValues($input, $result);
if (!empty($params['id'])) {
if (!empty($params['id'])) {
CRM_Utils_Hook::post('edit', 'FormProcessorDefaultDataInput', $input->id, $input);
}
else {
......@@ -117,21 +117,21 @@ class CRM_FormProcessor_BAO_FormProcessorDefaultDataInput extends CRM_FormProces
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
......
......@@ -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
......@@ -31,25 +31,25 @@ class CRM_FormProcessor_BAO_FormProcessorInput extends CRM_FormProcessor_DAO_For
$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')));
$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')));
$result[$row['id']] = $row;
} else {
//invalid input because no there is no form processor
......@@ -61,8 +61,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 +73,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 +88,25 @@ 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);
}
$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,22 +116,22 @@ 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
......@@ -186,6 +186,6 @@ class CRM_FormProcessor_BAO_FormProcessorInput extends CRM_FormProcessor_DAO_For
$count = CRM_Core_DAO::singleValueQuery($sql, $params);
return ($count > 0) ? FALSE : TRUE;
}
}
\ No newline at end of file
......@@ -8,7 +8,7 @@
static $importingFormProcessors = array();
/**
/**
* Function to get values
*
* @return array $result found rows with data
......@@ -30,10 +30,10 @@
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)));
$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)));
if (isset($row['output_handler_configuration']) && is_string($row['output_handler_configuration'])) {
$row['output_handler_configuration'] = json_decode($row['output_handler_configuration'], true);
}
......@@ -54,19 +54,19 @@
}
}
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['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();
}
$result[$row['id']] = $row;
}
return $result;
}
/**
/**
* Function to add or update a FormProcessorInstance
*
* @param array $params
......@@ -103,12 +103,12 @@
$formProcessorInstance->name = CRM_FormProcessor_BAO_FormProcessorInstance::buildNameFromLabel($formProcessorInstance->title);
}
}
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 (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);
}
$formProcessorInstance->save();
self::storeValues($formProcessorInstance, $result);
......@@ -123,7 +123,7 @@
return $result;
}
/**
/**
* Function to delete a FormProcessorInstance with id
*
* @param int $id
......@@ -138,12 +138,12 @@
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);
$formProcessorInstance = new CRM_FormProcessor_BAO_FormProcessorInstance();
$formProcessorInstance->id = $id;
......@@ -159,7 +159,7 @@
return;
}
/**
/**
* Public function to generate name from label
*
* @param $label
......@@ -173,28 +173,28 @@
return substr($nameString, 0, 80);
}
/**
</