Commit e842c5d3 authored by jaapjansma's avatar jaapjansma
Browse files

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 { ...@@ -5,15 +5,15 @@ class CRM_Admin_Page_AutomationFormProcessor extends CRM_Core_Page {
public function run() { public function run() {
$loader = new \Civi\Angular\AngularLoader(); $loader = new \Civi\Angular\AngularLoader();
$loader->setModules(array('form_processor')); $loader->setModules(array('form_processor'));
$loader->setPageName('civicrm/admin/formprocessor'); $loader->setPageName('civicrm/admin/formprocessor');
\Civi::resources()->addSetting(array( \Civi::resources()->addSetting(array(
'crmApp' => array( 'crmApp' => array(
'defaultRoute' => 'formprocessors', 'defaultRoute' => 'formprocessors',
), ),
)); ));
$loader->load(); $loader->load();
parent::run(); parent::run();
} }
} }
...@@ -7,10 +7,10 @@ use CRM_FormProcessor_ExtensionUtil as E; ...@@ -7,10 +7,10 @@ use CRM_FormProcessor_ExtensionUtil as E;
* @license http://www.gnu.org/licenses/agpl-3.0.html * @license http://www.gnu.org/licenses/agpl-3.0.html
*/ */
class CRM_FormProcessor_BAO_FormProcessorDefaultDataAction extends CRM_FormProcessor_DAO_FormProcessorDefaultDataAction { class CRM_FormProcessor_BAO_FormProcessorDefaultDataAction extends CRM_FormProcessor_DAO_FormProcessorDefaultDataAction {
/** /**
* Function to get values * Function to get values
* *
* @return array $result found rows with data * @return array $result found rows with data
* @access public * @access public
* @static * @static
...@@ -26,7 +26,7 @@ class CRM_FormProcessor_BAO_FormProcessorDefaultDataAction extends CRM_FormProce ...@@ -26,7 +26,7 @@ class CRM_FormProcessor_BAO_FormProcessorDefaultDataAction extends CRM_FormProce
} }
} }
} }
$action->orderBy('weight'); $action->orderBy('weight');
$action->find(); $action->find();
while ($action->fetch()) { while ($action->fetch()) {
$row = array(); $row = array();
...@@ -63,8 +63,8 @@ class CRM_FormProcessor_BAO_FormProcessorDefaultDataAction extends CRM_FormProce ...@@ -63,8 +63,8 @@ class CRM_FormProcessor_BAO_FormProcessorDefaultDataAction extends CRM_FormProce
/** /**
* Function to add or update form processor action * Function to add or update form processor action
* *
* @param array $params * @param array $params
* @return array $result * @return array $result
* @access public * @access public
* @throws Exception when params is empty * @throws Exception when params is empty
...@@ -75,14 +75,14 @@ class CRM_FormProcessor_BAO_FormProcessorDefaultDataAction extends CRM_FormProce ...@@ -75,14 +75,14 @@ class CRM_FormProcessor_BAO_FormProcessorDefaultDataAction extends CRM_FormProce
if (empty($params)) { if (empty($params)) {
throw new Exception('Params can not be empty when adding or updating a form processor action'); 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); CRM_Utils_Hook::pre('edit', 'FormProcessorDefaultDataAction', $params['id'], $params);
} }
else { else {
CRM_Utils_Hook::pre('create', 'FormProcessorDefaultDataAction', NULL, $params); CRM_Utils_Hook::pre('create', 'FormProcessorDefaultDataAction', NULL, $params);
} }
$action = new CRM_FormProcessor_BAO_FormProcessorDefaultDataAction(); $action = new CRM_FormProcessor_BAO_FormProcessorDefaultDataAction();
$fields = self::fields(); $fields = self::fields();
foreach ($params as $key => $value) { foreach ($params as $key => $value) {
...@@ -91,31 +91,31 @@ class CRM_FormProcessor_BAO_FormProcessorDefaultDataAction extends CRM_FormProce ...@@ -91,31 +91,31 @@ class CRM_FormProcessor_BAO_FormProcessorDefaultDataAction extends CRM_FormProce
} }
} }
if (is_array($action->configuration)) { if (is_array($action->configuration)) {
$action->configuration = json_encode($action->configuration); $action->configuration = json_encode($action->configuration);
} }
if (is_array($action->mapping)) { if (is_array($action->mapping)) {
$action->mapping = json_encode($action->mapping); $action->mapping = json_encode($action->mapping);
} }
if (is_array($action->condition_configuration)) { if (is_array($action->condition_configuration)) {
$action->condition_configuration = json_encode($action->condition_configuration); $action->condition_configuration = json_encode($action->condition_configuration);
} }
$action->save(); $action->save();
self::storeValues($action, $result); self::storeValues($action, $result);
if (!empty($params['id'])) { if (!empty($params['id'])) {
CRM_Utils_Hook::post('edit', 'FormProcessorDefaultDataAction', $action->id, $action); CRM_Utils_Hook::post('edit', 'FormProcessorDefaultDataAction', $action->id, $action);
} }
else { else {
CRM_Utils_Hook::post('create', 'FormProcessorDefaultDataAction', $action->id, $action); CRM_Utils_Hook::post('create', 'FormProcessorDefaultDataAction', $action->id, $action);
} }
return $result; return $result;
} }
/** /**
* Function to delete a form processor action with id * Function to delete a form processor action with id
* *
* @param int $id * @param int $id
* @throws Exception when $id is empty * @throws Exception when $id is empty
* @access public * @access public
...@@ -125,21 +125,21 @@ class CRM_FormProcessor_BAO_FormProcessorDefaultDataAction extends CRM_FormProce ...@@ -125,21 +125,21 @@ class CRM_FormProcessor_BAO_FormProcessorDefaultDataAction extends CRM_FormProce
if (empty($id)) { if (empty($id)) {
throw new Exception('id can not be empty when attempting to delete a form processor action'); 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 = new CRM_FormProcessor_BAO_FormProcessorDefaultDataAction();
$action->id = $id; $action->id = $id;
if ($action->find(true)) { if ($action->find(true)) {
$action->delete(); $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; return;
} }
/** /**
* Function to delete all actions with a form processor instance id * Function to delete all actions with a form processor instance id
* *
* @param int $formProcessorInstanceId * @param int $formProcessorInstanceId
...@@ -155,7 +155,7 @@ class CRM_FormProcessor_BAO_FormProcessorDefaultDataAction extends CRM_FormProce ...@@ -155,7 +155,7 @@ class CRM_FormProcessor_BAO_FormProcessorDefaultDataAction extends CRM_FormProce
} }
} }
/** /**
* Public function to generate name from title * Public function to generate name from title
* *
* @param $title * @param $title
...@@ -168,30 +168,30 @@ class CRM_FormProcessor_BAO_FormProcessorDefaultDataAction extends CRM_FormProce ...@@ -168,30 +168,30 @@ class CRM_FormProcessor_BAO_FormProcessorDefaultDataAction extends CRM_FormProce
$nameString = implode('_', $titleParts); $nameString = implode('_', $titleParts);
return substr($nameString, 0, 80); return substr($nameString, 0, 80);
} }
/** /**
* Returns whether the name is valid or not * Returns whether the name is valid or not
* *
* @param string $name * @param string $name
* @param int $form_processor_instance_id * @param int $form_processor_instance_id
* @param int $id optional * @param int $id optional
* @return bool * @return bool
* @static * @static
*/ */
public static function isNameValid($name, $form_processor_instance_id, $id=null) { public static function isNameValid($name, $form_processor_instance_id, $id=null) {
if (empty($form_processor_instance_id)) { if (empty($form_processor_instance_id)) {
return true; return true;
} }
$sql = "SELECT COUNT(*) FROM `civicrm_form_processor_default_data_action` WHERE `name` = %1 AND `form_processor_instance_id` = %2"; $sql = "SELECT COUNT(*) FROM `civicrm_form_processor_default_data_action` WHERE `name` = %1 AND `form_processor_instance_id` = %2";
$params[1] = [$name, 'String']; $params[1] = [$name, 'String'];
$params[2] = [$form_processor_instance_id, 'Integer']; $params[2] = [$form_processor_instance_id, 'Integer'];
if ($id) { if ($id) {
$sql .= " AND `id` != %3"; $sql .= " AND `id` != %3";
$params[3] = array($id, 'Integer'); $params[3] = array($id, 'Integer');
} }
$count = CRM_Core_DAO::singleValueQuery($sql, $params); $count = CRM_Core_DAO::singleValueQuery($sql, $params);
return ($count > 0) ? false : true; return ($count > 0) ? false : true;
} }
} }
\ No newline at end of file
...@@ -8,7 +8,7 @@ use CRM_FormProcessor_ExtensionUtil as E; ...@@ -8,7 +8,7 @@ use CRM_FormProcessor_ExtensionUtil as E;
*/ */
class CRM_FormProcessor_BAO_FormProcessorDefaultDataInput extends CRM_FormProcessor_DAO_FormProcessorDefaultDataInput { class CRM_FormProcessor_BAO_FormProcessorDefaultDataInput extends CRM_FormProcessor_DAO_FormProcessorDefaultDataInput {
/** /**
* Function to get values * Function to get values
* *
* @return array $result found rows with data * @return array $result found rows with data
...@@ -31,24 +31,24 @@ class CRM_FormProcessor_BAO_FormProcessorDefaultDataInput extends CRM_FormProces ...@@ -31,24 +31,24 @@ class CRM_FormProcessor_BAO_FormProcessorDefaultDataInput extends CRM_FormProces
$row = array(); $row = array();
self::storeValues($input, $row); self::storeValues($input, $row);
if (!empty($row['form_processor_instance_id'])) { if (!empty($row['form_processor_instance_id'])) {
$type = \Civi::service('form_processor_type_factory')->getTypeByName($row['type']); $type = \Civi::service('form_processor_type_factory')->getTypeByName($row['type']);
if ($type) { if ($type) {
$configuration = $type->getDefaultConfiguration(); $configuration = $type->getDefaultConfiguration();
if (isset($row['configuration']) && is_string($row['configuration'])) { if (isset($row['configuration']) && is_string($row['configuration'])) {
$row['configuration'] = json_decode($row['configuration'], true); $row['configuration'] = json_decode($row['configuration'], true);
} }
if (empty($row['configuration']) || !is_array($row['configuration'])) { if (empty($row['configuration']) || !is_array($row['configuration'])) {
$row['configuration'] = array(); $row['configuration'] = array();
} }
foreach($row['configuration'] as $name => $value) { foreach($row['configuration'] as $name => $value) {
$configuration->set($name, $value); $configuration->set($name, $value);
} }
$type->setConfiguration($configuration); $type->setConfiguration($configuration);
$row['type'] = $type; $row['type'] = $type;
} }
$row['validators'] = array_values(CRM_FormProcessor_BAO_FormProcessorValidation::getValues(array('entity_id' => $input->id, 'entity' => 'FormProcessorDefaultDataInput'))); $row['validators'] = array_values(CRM_FormProcessor_BAO_FormProcessorValidation::getValues(array('entity_id' => $input->id, 'entity' => 'FormProcessorDefaultDataInput')));
$result[$row['id']] = $row; $result[$row['id']] = $row;
} else { } else {
...@@ -74,7 +74,7 @@ class CRM_FormProcessor_BAO_FormProcessorDefaultDataInput extends CRM_FormProces ...@@ -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'); 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); CRM_Utils_Hook::pre('edit', 'FormProcessorDefaultDataInput', $params['id'], $params);
} }
else { else {
...@@ -88,13 +88,13 @@ class CRM_FormProcessor_BAO_FormProcessorDefaultDataInput extends CRM_FormProces ...@@ -88,13 +88,13 @@ class CRM_FormProcessor_BAO_FormProcessorDefaultDataInput extends CRM_FormProces
$input->$key = $value; $input->$key = $value;
} }
} }
if (is_array($input->configuration)) { if (is_array($input->configuration)) {
$input->configuration = json_encode($input->configuration); $input->configuration = json_encode($input->configuration);
} }
$input->save(); $input->save();
self::storeValues($input, $result); self::storeValues($input, $result);
if (!empty($params['id'])) { if (!empty($params['id'])) {
CRM_Utils_Hook::post('edit', 'FormProcessorDefaultDataInput', $input->id, $input); CRM_Utils_Hook::post('edit', 'FormProcessorDefaultDataInput', $input->id, $input);
} }
else { else {
...@@ -117,21 +117,21 @@ class CRM_FormProcessor_BAO_FormProcessorDefaultDataInput extends CRM_FormProces ...@@ -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'); 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 = new CRM_FormProcessor_BAO_FormProcessorDefaultDataInput();
$input->id = $id; $input->id = $id;
if ($input->find(true)) { if ($input->find(true)) {
CRM_FormProcessor_BAO_FormProcessorValidation::deleteWithEntityId('FormProcessorDefaultDataInput', $input->id); CRM_FormProcessor_BAO_FormProcessorValidation::deleteWithEntityId('FormProcessorDefaultDataInput', $input->id);
$input->delete(); $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; return;
} }
/** /**
* Function to delete all inputs with a form processor instance id * Function to delete all inputs with a form processor instance id
* *
* @param int $formProcessorInstanceId * @param int $formProcessorInstanceId
......
...@@ -7,10 +7,10 @@ use CRM_FormProcessor_ExtensionUtil as E; ...@@ -7,10 +7,10 @@ use CRM_FormProcessor_ExtensionUtil as E;
* @license http://www.gnu.org/licenses/agpl-3.0.html * @license http://www.gnu.org/licenses/agpl-3.0.html
*/ */
class CRM_FormProcessor_BAO_FormProcessorInput extends CRM_FormProcessor_DAO_FormProcessorInput { class CRM_FormProcessor_BAO_FormProcessorInput extends CRM_FormProcessor_DAO_FormProcessorInput {
/** /**
* Function to get values * Function to get values
* *
* @return array $result found rows with data * @return array $result found rows with data
* @access public * @access public
* @static * @static
...@@ -31,25 +31,25 @@ class CRM_FormProcessor_BAO_FormProcessorInput extends CRM_FormProcessor_DAO_For ...@@ -31,25 +31,25 @@ class CRM_FormProcessor_BAO_FormProcessorInput extends CRM_FormProcessor_DAO_For
$row = array(); $row = array();
self::storeValues($input, $row); self::storeValues($input, $row);
if (!empty($row['form_processor_instance_id'])) { if (!empty($row['form_processor_instance_id'])) {
$type = \Civi::service('form_processor_type_factory')->getTypeByName($row['type']); $type = \Civi::service('form_processor_type_factory')->getTypeByName($row['type']);
if ($type) { if ($type) {
$configuration = $type->getDefaultConfiguration(); $configuration = $type->getDefaultConfiguration();
if (isset($row['configuration']) && is_string($row['configuration'])) { if (isset($row['configuration']) && is_string($row['configuration'])) {
$row['configuration'] = json_decode($row['configuration'], true); $row['configuration'] = json_decode($row['configuration'], true);
} }
if (empty($row['configuration']) || !is_array($row['configuration'])) { if (empty($row['configuration']) || !is_array($row['configuration'])) {
$row['configuration'] = array(); $row['configuration'] = array();
} }
foreach($row['configuration'] as $name => $value) { foreach($row['configuration'] as $name => $value) {
$configuration->set($name, $value); $configuration->set($name, $value);
} }
$type->setConfiguration($configuration); $type->setConfiguration($configuration);
$row['type'] = $type; $row['type'] = $type;
} }
$row['validators'] = array_values(CRM_FormProcessor_BAO_FormProcessorValidation::getValues(array('entity_id' => $input->id, 'entity' => 'FormProcessorInput'))); $row['validators'] = array_values(CRM_FormProcessor_BAO_FormProcessorValidation::getValues(array('entity_id' => $input->id, 'entity' => 'FormProcessorInput')));
$result[$row['id']] = $row; $result[$row['id']] = $row;
} else { } else {
//invalid input because no there is no form processor //invalid input because no there is no form processor
...@@ -61,8 +61,8 @@ class CRM_FormProcessor_BAO_FormProcessorInput extends CRM_FormProcessor_DAO_For ...@@ -61,8 +61,8 @@ class CRM_FormProcessor_BAO_FormProcessorInput extends CRM_FormProcessor_DAO_For
/** /**
* Function to add or update form processor input * Function to add or update form processor input
* *
* @param array $params * @param array $params
* @return array $result * @return array $result
* @access public * @access public
* @throws Exception when params is empty * @throws Exception when params is empty
...@@ -73,14 +73,14 @@ class CRM_FormProcessor_BAO_FormProcessorInput extends CRM_FormProcessor_DAO_For ...@@ -73,14 +73,14 @@ class CRM_FormProcessor_BAO_FormProcessorInput extends CRM_FormProcessor_DAO_For
if (empty($params)) { if (empty($params)) {
throw new Exception('Params can not be empty when adding or updating a form processor input'); 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); CRM_Utils_Hook::pre('edit', 'FormProcessorInput', $params['id'], $params);
} }
else { else {
CRM_Utils_Hook::pre('create', 'FormProcessorInput', NULL, $params); CRM_Utils_Hook::pre('create', 'FormProcessorInput', NULL, $params);
} }
$input = new CRM_FormProcessor_BAO_FormProcessorInput(); $input = new CRM_FormProcessor_BAO_FormProcessorInput();
$fields = self::fields(); $fields = self::fields();
foreach ($params as $key => $value) { foreach ($params as $key => $value) {
...@@ -88,25 +88,25 @@ class CRM_FormProcessor_BAO_FormProcessorInput extends CRM_FormProcessor_DAO_For ...@@ -88,25 +88,25 @@ class CRM_FormProcessor_BAO_FormProcessorInput extends CRM_FormProcessor_DAO_For
$input->$key = $value; $input->$key = $value;
} }
} }
if (is_array($input->configuration)) { if (is_array($input->configuration)) {
$input->configuration = json_encode($input->configuration); $input->configuration = json_encode($input->configuration);
} }
$input->save(); $input->save();
self::storeValues($input, $result); self::storeValues($input, $result);
if (!empty($params['id'])) { if (!empty($params['id'])) {
CRM_Utils_Hook::post('edit', 'FormProcessorInput', $input->id, $input); CRM_Utils_Hook::post('edit', 'FormProcessorInput', $input->id, $input);
} }
else { else {
CRM_Utils_Hook::post('create', 'FormProcessorInput', $input->id, $input); CRM_Utils_Hook::post('create', 'FormProcessorInput', $input->id, $input);
} }
return $result; return $result;
} }
/** /**
* Function to delete a form processor input with id * Function to delete a form processor input with id
* *
* @param int $id * @param int $id
* @throws Exception when $id is empty * @throws Exception when $id is empty
* @access public * @access public
...@@ -116,22 +116,22 @@ class CRM_FormProcessor_BAO_FormProcessorInput extends CRM_FormProcessor_DAO_For ...@@ -116,22 +116,22 @@ class CRM_FormProcessor_BAO_FormProcessorInput extends CRM_FormProcessor_DAO_For
if (empty($id)) { if (empty($id)) {
throw new Exception('id can not be empty when attempting to delete a form processor input'); 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 = new CRM_FormProcessor_BAO_FormProcessorInput();
$input->id = $id; $input->id = $id;
if ($input->find(true)) { if ($input->find(true)) {
CRM_FormProcessor_BAO_FormProcessorValidation::deleteWithEntityId('FormProcessorInput', $input->id); CRM_FormProcessor_BAO_FormProcessorValidation::deleteWithEntityId('FormProcessorInput', $input->id);
$input->delete(); $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; return;
} }
/** /**
* Function to delete all inputs with a form processor instance id * Function to delete all inputs with a form processor instance id
*