Commit 2370f01b authored by jaapjansma's avatar jaapjansma

Fixed issue with cloning a data processor

parent 9d91593f
# Version 1.8.0 (not yet released)
* Fixed issue with cloning data processors.
# Version 1.7.0
* Fixed #35: Custom Fields on a tab are also available as field now.
......
......@@ -75,50 +75,13 @@ class CRM_Dataprocessor_Form_CloneDataProcessor extends CRM_Core_Form {
public function postProcess() {
$session = CRM_Core_Session::singleton();
$values = $this->exportValues();
$params = clone $this->dataProcessor;
unset($params['id']);
$params['name'] = $values['name'];
$params['title'] = $values['title'];
$params['description'] = $values['description'];
$params['is_active'] = !empty($values['is_active']) ? 1 : 0;
$result = civicrm_api3('DataProcessor', 'create', $params);
$newId = $result['id'];
$sources = civicrm_api3('DataProcessorSource', 'get', array('data_processor_id' => $this->dataProcessorId, 'options' => array('limit' => 0)));
$dataProcessor['data_sources'] = array();
foreach($sources['values'] as $i => $datasource) {
unset($datasource['id']);
unset($datasource['data_processor_id']);
$datasource['data_processor_id'] = $newId;
civicrm_api3('DataProcessorSource', 'create', $datasource);
}
$filters = civicrm_api3('DataProcessorFilter', 'get', array('data_processor_id' => $this->dataProcessorId, 'options' => array('limit' => 0)));
$dataProcessor['filters'] = array();
foreach($filters['values'] as $i => $filter) {
unset($filter['id']);
unset($filter['data_processor_id']);
$filter['data_processor_id'] = $newId;
civicrm_api3('DataProcessorFilter', 'create', $filter);
}
$fields = civicrm_api3('DataProcessorField', 'get', array('data_processor_id' => $this->dataProcessorId, 'options' => array('limit' => 0)));
$dataProcessor['fields'] = array();
foreach($fields['values'] as $i => $field) {
unset($field['id']);
unset($field['data_processor_id']);
$field['data_processor_id'] = $newId;
civicrm_api3('DataProcessorField', 'create', $field);
}
$outputs = $outputs = civicrm_api3('DataProcessorOutput', 'get', array('data_processor_id' => $this->dataProcessorId, 'options' => array('limit' => 0)));
$dataProcessor['outputs'] = array();
foreach($outputs['values'] as $i => $output) {
unset($output['id']);
unset($output['data_processor_id']);
$output['data_processor_id'] = $newId;
civicrm_api3('DataProcessorOutput', 'create', $output);
}
$redirectUrl = CRM_Utils_System::url('civicrm/dataprocessor/form/edit', array('reset' => 1, 'action' => 'update', 'id' => $result['id']));
$dataProcessor = CRM_Dataprocessor_Utils_Importer::export($this->dataProcessorId);
$dataProcessor['name'] = $values['name'];
$dataProcessor['title'] = $values['title'];
$dataProcessor['description'] = $values['description'];
$dataProcessor['is_active'] = !empty($values['is_active']) ? 1 : 0;
$newId = CRM_Dataprocessor_Utils_Importer::importDataProcessor($dataProcessor, null, null, CRM_Dataprocessor_Status::STATUS_IN_DATABASE);
$redirectUrl = CRM_Utils_System::url('civicrm/dataprocessor/form/edit', array('reset' => 1, 'action' => 'update', 'id' => $newId));
CRM_Utils_System::redirect($redirectUrl);
}
......
......@@ -159,8 +159,9 @@ class CRM_Dataprocessor_Utils_Importer {
* Import a data processor
*
* @param $data
* @param $filename
* @param $data_processor_id
* @param string|null $filename
* @param int|null $data_processor_id
* @param int
*
* @return mixed
* @throws \Exception
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment