Skip to content
Snippets Groups Projects
Commit 5408c319 authored by jaapjansma's avatar jaapjansma
Browse files

fixed merge conflict

parents 0e63e91a 66a62d12
No related branches found
No related tags found
No related merge requests found
Showing
with 148 additions and 9 deletions
...@@ -3,7 +3,9 @@ Version 1.3 ...@@ -3,7 +3,9 @@ Version 1.3
* Implemented the help text of an action on the edit action screen. * Implemented the help text of an action on the edit action screen.
* Changed the implementation of the civicrm_container hook. * Changed the implementation of the civicrm_container hook.
* Fix for converting Title into Name * Added a File type for handling the upload of files.
* Fix for converting Title into Name.
* Fixed issue with updating status with overridden.
Version 1.2 Version 1.2
=========== ===========
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
*/ */
class CRM_FormProcessor_BAO_FormProcessorInstance extends CRM_FormProcessor_DAO_FormProcessorInstance { class CRM_FormProcessor_BAO_FormProcessorInstance extends CRM_FormProcessor_DAO_FormProcessorInstance {
static $importingFormProcessors = array();
/** /**
* Function to get values * Function to get values
...@@ -252,5 +254,34 @@ ...@@ -252,5 +254,34 @@
$params[3] = array($source_file, 'String'); $params[3] = array($source_file, 'String');
CRM_Core_DAO::executeQuery($sql, $params); CRM_Core_DAO::executeQuery($sql, $params);
} }
/**
* Update the status from in code to overriden when a form processor has been changed
*
* @param $formProcessorId
*/
public static function updateAndChekStatus($formProcessorId) {
$sql = "SELECT `status`, `name` FROM `civicrm_form_processor_instance` WHERE `id` = %1";
$params[1] = array($formProcessorId, 'Integer');
$dao = CRM_Core_DAO::executeQuery($sql, $params);
if ($dao->fetch()) {
if (!in_array($dao->name, self::$importingFormProcessors) && $dao->status == CRM_FormProcessor_Status::IN_CODE) {
$sql = "UPDATE `civicrm_form_processor_instance` SET `status` = %2 WHERE `id` = %1";
$params[1] = array($formProcessorId, 'String');
$params[2] = array(CRM_FormProcessor_Status::OVERRIDDEN, 'Integer');
CRM_Core_DAO::executeQuery($sql, $params);
}
}
}
/**
* Store the form processor name so we know that we are importing this form processor
* and should not update its status on the way.
*
* @param $formProcessorName
*/
public static function setFormProcessorToImportingState($formProcessorName) {
self::$importingFormProcessors[] = $formProcessorName;
}
} }
<?php
/**
* @author Jaap Jansma <jaap.jansma@civicoop.org>
* @license AGPL-3.0
*/
namespace Civi\FormProcessor\API;
use Throwable;
class Exception extends \Exception {
public function __construct($actionName, Throwable $previous = NULL) {
$message = "Action ".$actionName." failed.";
if ($previous) {
$message .= " Caused by ".$previous->getMessage();
}
parent::__construct($message, null, $previous);
}
}
\ No newline at end of file
...@@ -204,9 +204,13 @@ ...@@ -204,9 +204,13 @@
} else { } else {
// There is no delay. Execute the action immediately // There is no delay. Execute the action immediately
// Now execute the action // Now execute the action
$outputBag = $actionClass->execute($mappedParameterBag, $mappedConditionParameterBag, $mappedConditionOutputParameterBag); try {
// Add the output of the action to the data bag of this action. $outputBag = $actionClass->execute($mappedParameterBag, $mappedConditionParameterBag, $mappedConditionOutputParameterBag);
$dataBag->setActionDataFromActionProviderParameterBag($objAction, $outputBag); // Add the output of the action to the data bag of this action.
$dataBag->setActionDataFromActionProviderParameterBag($objAction, $outputBag);
} catch (\Exception $e) {
throw new Exception($action['title'], $e);
}
} }
} }
......
...@@ -177,11 +177,14 @@ ...@@ -177,11 +177,14 @@
$condition = \CRM_FormProcessor_Condition::getConditionClass($action['condition_configuration']); $condition = \CRM_FormProcessor_Condition::getConditionClass($action['condition_configuration']);
$actionClass->setCondition($condition); $actionClass->setCondition($condition);
// Now execute the action try {
$outputBag = $actionClass->execute($mappedParameterBag, $mappedConditionParameterBag, $mappedConditionOutputParameterBag); // Now execute the action
$outputBag = $actionClass->execute($mappedParameterBag, $mappedConditionParameterBag, $mappedConditionOutputParameterBag);
// Add the output of the action to the data bag of this action. // Add the output of the action to the data bag of this action.
$dataBag->setActionDataFromActionProviderParameterBag($objAction, $outputBag); $dataBag->setActionDataFromActionProviderParameterBag($objAction, $outputBag);
} catch (\Exception $e) {
throw new Exception($action['title'], $e);
}
} }
$return = array(); $return = array();
......
...@@ -73,6 +73,8 @@ class ExportToJson { ...@@ -73,6 +73,8 @@ class ExportToJson {
$status = \CRM_FormProcessor_BAO_FormProcessorInstance::getStatus($data['name']); $status = \CRM_FormProcessor_BAO_FormProcessorInstance::getStatus($data['name']);
$new_status = null; $new_status = null;
$new_id = null; $new_id = null;
\CRM_FormProcessor_BAO_FormProcessorInstance::setFormProcessorToImportingState($data['name']);
switch ($status) { switch ($status) {
case \CRM_FormProcessor_Status::IN_DATABASE: case \CRM_FormProcessor_Status::IN_DATABASE:
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
$this->addType(new MailingGroupType('MailingGroup', E::ts('Mailing Group'))); $this->addType(new MailingGroupType('MailingGroup', E::ts('Mailing Group')));
$this->addType(new ParticipantStatusType('ParticipantStatusType', E::ts('Participant Status'))); $this->addType(new ParticipantStatusType('ParticipantStatusType', E::ts('Participant Status')));
$this->addType(new CampaignType('CampaignType', E::ts('Campaign'))); $this->addType(new CampaignType('CampaignType', E::ts('Campaign')));
$this->addType(new FileType('file', E::ts('File')));
} }
/** /**
......
<?php
/**
* @author Jaap Jansma (CiviCooP) <jaap.jansma@civicoop.org>
* @license http://www.gnu.org/licenses/agpl-3.0.html
*/
namespace Civi\FormProcessor\Type;
use \Civi\FormProcessor\Type\GenericType;
use \Civi\FormProcessor\Config\Specification;
use \Civi\FormProcessor\Config\SpecificationBag;
use \CRM_FormProcessor_ExtensionUtil as E;
class FileType extends GenericType {
/**
* Get the configuration specification.
*
* The configuration is
* format: a string containing the input format.
* see for valid formats http://nl1.php.net/manual/en/datetime.createfromformat.php#refsect1-datetime.createfromformat-parameters
*
* @return SpecificationBag
*/
public function getConfigurationSpecification() {
return new SpecificationBag(array());
}
public function validateValue($value, $allValues=array()) {
if (!is_array($value)) {
return false;
}
if (!isset($value['id'])) {
if (!isset($value['name']) || !isset($value['mime_type']) || !isset($value['content'])) {
return false;
}
}
return true;
}
/**
* Returns the type number from CRM_Utils_Type
*/
public function getCrmType() {
return \CRM_Utils_Type::T_BLOB;
}
}
\ No newline at end of file
...@@ -82,6 +82,7 @@ function _civicrm_api3_form_processor_action_create_spec(&$spec) { ...@@ -82,6 +82,7 @@ function _civicrm_api3_form_processor_action_create_spec(&$spec) {
*/ */
function civicrm_api3_form_processor_action_create($params) { function civicrm_api3_form_processor_action_create($params) {
$returnValue = CRM_FormProcessor_BAO_FormProcessorAction::add($params); $returnValue = CRM_FormProcessor_BAO_FormProcessorAction::add($params);
CRM_FormProcessor_BAO_FormProcessorInstance::updateAndChekStatus($returnValue['form_processor_instance_id']);
$returnValues[$returnValue['id']] = $returnValue; $returnValues[$returnValue['id']] = $returnValue;
return civicrm_api3_create_success($returnValues, $params, 'FormProcessorAction', 'Create'); return civicrm_api3_create_success($returnValues, $params, 'FormProcessorAction', 'Create');
} }
......
...@@ -31,6 +31,8 @@ function civicrm_api3_form_processor_action_Delete($params) { ...@@ -31,6 +31,8 @@ function civicrm_api3_form_processor_action_Delete($params) {
if (!array_key_exists('id', $params) || empty($params['id'])) { if (!array_key_exists('id', $params) || empty($params['id'])) {
throw new API_Exception('Parameter id is mandatory and can not be empty in ' . __METHOD__, 0010); throw new API_Exception('Parameter id is mandatory and can not be empty in ' . __METHOD__, 0010);
} else { } else {
$formProcessorId = civicrm_api3('FormProcessorAction', 'getvalue', array('id' => $params['id'], 'return' => 'form_processor_instance_id'));
CRM_FormProcessor_BAO_FormProcessorInstance::updateAndChekStatus($formProcessorId);
return civicrm_api3_create_success(CRM_FormProcessor_BAO_FormProcessorAction::deleteWithId($params['id']), $params, 'FormProcessorAction', 'Delete'); return civicrm_api3_create_success(CRM_FormProcessor_BAO_FormProcessorAction::deleteWithId($params['id']), $params, 'FormProcessorAction', 'Delete');
} }
} }
......
...@@ -66,6 +66,7 @@ function _civicrm_api3_form_processor_default_data_action_create_spec(&$spec) { ...@@ -66,6 +66,7 @@ function _civicrm_api3_form_processor_default_data_action_create_spec(&$spec) {
*/ */
function civicrm_api3_form_processor_default_data_action_create($params) { function civicrm_api3_form_processor_default_data_action_create($params) {
$returnValue = CRM_FormProcessor_BAO_FormProcessorDefaultDataAction::add($params); $returnValue = CRM_FormProcessor_BAO_FormProcessorDefaultDataAction::add($params);
CRM_FormProcessor_BAO_FormProcessorInstance::updateAndChekStatus($returnValue['form_processor_instance_id']);
$returnValues[$returnValue['id']] = $returnValue; $returnValues[$returnValue['id']] = $returnValue;
return civicrm_api3_create_success($returnValues, $params, 'FormProcessorDefaultDataAction', 'Create'); return civicrm_api3_create_success($returnValues, $params, 'FormProcessorDefaultDataAction', 'Create');
} }
......
...@@ -31,6 +31,8 @@ function civicrm_api3_form_processor_default_data_action_Delete($params) { ...@@ -31,6 +31,8 @@ function civicrm_api3_form_processor_default_data_action_Delete($params) {
if (!array_key_exists('id', $params) || empty($params['id'])) { if (!array_key_exists('id', $params) || empty($params['id'])) {
throw new API_Exception('Parameter id is mandatory and can not be empty in ' . __METHOD__, 0010); throw new API_Exception('Parameter id is mandatory and can not be empty in ' . __METHOD__, 0010);
} else { } else {
$formProcessorId = civicrm_api3('FormProcessorDefaultDataAction', 'getvalue', array('id' => $params['id'], 'return' => 'form_processor_instance_id'));
CRM_FormProcessor_BAO_FormProcessorInstance::updateAndChekStatus($formProcessorId);
return civicrm_api3_create_success(CRM_FormProcessor_BAO_FormProcessorDefaultDataAction::deleteWithId($params['id']), $params, 'FormProcessorDefaultDataAction', 'Delete'); return civicrm_api3_create_success(CRM_FormProcessor_BAO_FormProcessorDefaultDataAction::deleteWithId($params['id']), $params, 'FormProcessorDefaultDataAction', 'Delete');
} }
} }
......
...@@ -62,6 +62,7 @@ function _civicrm_api3_form_processor_default_data_input_create_spec(&$spec) { ...@@ -62,6 +62,7 @@ function _civicrm_api3_form_processor_default_data_input_create_spec(&$spec) {
*/ */
function civicrm_api3_form_processor_default_data_input_create($params) { function civicrm_api3_form_processor_default_data_input_create($params) {
$returnValue = CRM_FormProcessor_BAO_FormProcessorDefaultDataInput::add($params); $returnValue = CRM_FormProcessor_BAO_FormProcessorDefaultDataInput::add($params);
CRM_FormProcessor_BAO_FormProcessorInstance::updateAndChekStatus($returnValue['form_processor_instance_id']);
$returnValues[$returnValue['id']] = $returnValue; $returnValues[$returnValue['id']] = $returnValue;
return civicrm_api3_create_success($returnValues, $params, 'FormProcessorDefaultDataInput', 'Create'); return civicrm_api3_create_success($returnValues, $params, 'FormProcessorDefaultDataInput', 'Create');
} }
......
...@@ -31,6 +31,8 @@ function civicrm_api3_form_processor_default_data_input_Delete($params) { ...@@ -31,6 +31,8 @@ function civicrm_api3_form_processor_default_data_input_Delete($params) {
if (!array_key_exists('id', $params) || empty($params['id'])) { if (!array_key_exists('id', $params) || empty($params['id'])) {
throw new API_Exception('Parameter id is mandatory and can not be empty in ' . __METHOD__, 0010); throw new API_Exception('Parameter id is mandatory and can not be empty in ' . __METHOD__, 0010);
} else { } else {
$formProcessorId = civicrm_api3('FormProcessorDefaultDataInput', 'getvalue', array('id' => $params['id'], 'return' => 'form_processor_instance_id'));
CRM_FormProcessor_BAO_FormProcessorInstance::updateAndChekStatus($formProcessorId);
return civicrm_api3_create_success(CRM_FormProcessor_BAO_FormProcessorDefaultDataInput::deleteWithId($params['id']), $params, 'FormProcessorDefaultDataInput', 'Delete'); return civicrm_api3_create_success(CRM_FormProcessor_BAO_FormProcessorDefaultDataInput::deleteWithId($params['id']), $params, 'FormProcessorDefaultDataInput', 'Delete');
} }
} }
......
...@@ -67,6 +67,7 @@ function _civicrm_api3_form_processor_input_create_spec(&$spec) { ...@@ -67,6 +67,7 @@ function _civicrm_api3_form_processor_input_create_spec(&$spec) {
*/ */
function civicrm_api3_form_processor_input_create($params) { function civicrm_api3_form_processor_input_create($params) {
$returnValue = CRM_FormProcessor_BAO_FormProcessorInput::add($params); $returnValue = CRM_FormProcessor_BAO_FormProcessorInput::add($params);
CRM_FormProcessor_BAO_FormProcessorInstance::updateAndChekStatus($returnValue['form_processor_instance_id']);
$returnValues[$returnValue['id']] = $returnValue; $returnValues[$returnValue['id']] = $returnValue;
return civicrm_api3_create_success($returnValues, $params, 'FormProcessorInput', 'Create'); return civicrm_api3_create_success($returnValues, $params, 'FormProcessorInput', 'Create');
} }
......
...@@ -31,6 +31,8 @@ function civicrm_api3_form_processor_input_Delete($params) { ...@@ -31,6 +31,8 @@ function civicrm_api3_form_processor_input_Delete($params) {
if (!array_key_exists('id', $params) || empty($params['id'])) { if (!array_key_exists('id', $params) || empty($params['id'])) {
throw new API_Exception('Parameter id is mandatory and can not be empty in ' . __METHOD__, 0010); throw new API_Exception('Parameter id is mandatory and can not be empty in ' . __METHOD__, 0010);
} else { } else {
$formProcessorId = civicrm_api3('FormProcessorInput', 'getvalue', array('id' => $params['id'], 'return' => 'form_processor_instance_id'));
CRM_FormProcessor_BAO_FormProcessorInstance::updateAndChekStatus($formProcessorId);
return civicrm_api3_create_success(CRM_FormProcessor_BAO_FormProcessorInput::deleteWithId($params['id']), $params, 'FormProcessorInput', 'Delete'); return civicrm_api3_create_success(CRM_FormProcessor_BAO_FormProcessorInput::deleteWithId($params['id']), $params, 'FormProcessorInput', 'Delete');
} }
} }
......
...@@ -101,6 +101,7 @@ function civicrm_api3_form_processor_instance_create($params) { ...@@ -101,6 +101,7 @@ function civicrm_api3_form_processor_instance_create($params) {
} }
$returnValue = CRM_FormProcessor_BAO_FormProcessorInstance::add($params); $returnValue = CRM_FormProcessor_BAO_FormProcessorInstance::add($params);
CRM_FormProcessor_BAO_FormProcessorInstance::updateAndChekStatus($returnValue['id']);
$returnValues[$returnValue['id']] = $returnValue; $returnValues[$returnValue['id']] = $returnValue;
return civicrm_api3_create_success($returnValues, $params, 'FormProcessorInstance', 'Create'); return civicrm_api3_create_success($returnValues, $params, 'FormProcessorInstance', 'Create');
} }
......
...@@ -50,6 +50,10 @@ function _civicrm_api3_form_processor_validation_create_spec(&$spec) { ...@@ -50,6 +50,10 @@ function _civicrm_api3_form_processor_validation_create_spec(&$spec) {
*/ */
function civicrm_api3_form_processor_validation_create($params) { function civicrm_api3_form_processor_validation_create($params) {
$returnValue = CRM_FormProcessor_BAO_FormProcessorValidation::add($params); $returnValue = CRM_FormProcessor_BAO_FormProcessorValidation::add($params);
$formProcessorId = civicrm_api3($params['entity'], 'getvalue', array('id' => $params['entity_id'], 'return' => 'form_processor_instance_id'));
CRM_FormProcessor_BAO_FormProcessorInstance::updateAndChekStatus($formProcessorId);
$returnValues[$returnValue['id']] = $returnValue; $returnValues[$returnValue['id']] = $returnValue;
return civicrm_api3_create_success($returnValues, $params, 'FormProcessorValidation', 'Create'); return civicrm_api3_create_success($returnValues, $params, 'FormProcessorValidation', 'Create');
} }
......
...@@ -31,6 +31,11 @@ function civicrm_api3_form_processor_validation_Delete($params) { ...@@ -31,6 +31,11 @@ function civicrm_api3_form_processor_validation_Delete($params) {
if (!array_key_exists('id', $params) || empty($params['id'])) { if (!array_key_exists('id', $params) || empty($params['id'])) {
throw new API_Exception('Parameter id is mandatory and can not be empty in ' . __METHOD__, 0010); throw new API_Exception('Parameter id is mandatory and can not be empty in ' . __METHOD__, 0010);
} else { } else {
$validation = civicrm_api3('FormProcessorValidation', 'getsingle', array('id' => $params['id']));
$formProcessorId = civicrm_api3($validation['entity'], 'getvalue', array('id' => $validation['entity_id'], 'return' => 'form_processor_instance_id'));
CRM_FormProcessor_BAO_FormProcessorInstance::updateAndChekStatus($formProcessorId);
return civicrm_api3_create_success(CRM_FormProcessor_BAO_FormProcessorValidation::deleteWithId($params['id']), $params, 'FormProcessorValidation', 'Delete'); return civicrm_api3_create_success(CRM_FormProcessor_BAO_FormProcessorValidation::deleteWithId($params['id']), $params, 'FormProcessorValidation', 'Delete');
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment