diff --git a/workflow/engine/methods/processes/processes_Import_Ajax.php b/workflow/engine/methods/processes/processes_Import_Ajax.php index 8f089e75d..4c38068de 100644 --- a/workflow/engine/methods/processes/processes_Import_Ajax.php +++ b/workflow/engine/methods/processes/processes_Import_Ajax.php @@ -26,11 +26,11 @@ use \ProcessMaker\Importer\XmlImporter; ini_set("max_execution_time", 0); $affectedGroups = array(); +$granularImport = false; +$objectImport = array(); if (isset($_FILES["PROCESS_FILENAME"]["name"]) && (preg_match("/^(?:pm|pmx)$/", pathinfo($_FILES["PROCESS_FILENAME"]["name"], PATHINFO_EXTENSION)))) { $import = new XmlImporter(); - $granularImport = false; - $objectImport = array(); $data = $import->load($_FILES["PROCESS_FILENAME"]["tmp_name"]); if (version_compare($data['version'], '3.0', '>') && isset($_POST['objectsToImport']) && $_POST['objectsToImport'] === '') { @@ -185,21 +185,8 @@ if (isset($_FILES["PROCESS_FILENAME"]) && } catch (Exception $e) { switch (get_class($e)) { case 'ProcessMaker\BusinessModel\Migrator\ImportException': - $result = array( - "success" => true, - "catchMessage" => $e->getNameException() . ' ' . $e->getMessage(), - "ExistProcessInDatabase" => '', - "ExistGroupsInDatabase" => '', - "notExistProcessInDatabase" => '', - "affectedGroups" => '', - "sNewProUid" => '', - "project_type" => 'bpmn', - "isGranularImport" => false, - "objectGranularImport" => '', - "proFileName" => $_FILES["PROCESS_FILENAME"]["name"], - "groupBeforeAccion" => 'uploadFileNewProcess', - "importOption" => 0 - ); + $result = $e->getNameException(); + die($result); break; default: $groupsExists = ($e->getCode() == XmlImporter::IMPORT_STAT_GROUP_ALREADY_EXISTS) ? 1 : 0; @@ -225,8 +212,8 @@ if (isset($_FILES["PROCESS_FILENAME"]) && "affectedGroups" => !empty($affectedGroups) ? $affectedGroups : '', "sNewProUid" => '', "project_type" => 'bpmn', - "isGranularImport" => false, - "objectGranularImport" => '', + "isGranularImport" => $granularImport, + "objectGranularImport" => $objectImport, "proFileName" => $_FILES["PROCESS_FILENAME"]["name"], "groupBeforeAccion" => 'uploadFileNewProcess', "importOption" => 0 @@ -299,20 +286,8 @@ if (isset($_POST["PRO_FILENAME"]) && } catch (Exception $e) { switch (get_class($e)) { case 'ProcessMaker\BusinessModel\Migrator\ImportException': - $result = array( - "success" => true, - "catchMessage" => $e->getNameException() . ' ' . $e->getMessage(), - "ExistProcessInDatabase" => '', - "ExistGroupsInDatabase" => '', - "affectedGroups" => '', - "sNewProUid" => '', - "project_type" => 'bpmn', - "isGranularImport" => false, - "objectGranularImport" => '', - "proFileName" => $_POST["PRO_FILENAME"], - "groupBeforeAccion" => "uploadFileNewProcess", - "importOption" => (isset($_POST["IMPORT_OPTION"])) ? (int)($_POST["IMPORT_OPTION"]) : 0 - ); + $result = $e->getNameException(); + die($result); break; default: $groupsExists = ($e->getCode() == XmlImporter::IMPORT_STAT_GROUP_ALREADY_EXISTS) ? 1 : 0; @@ -333,8 +308,8 @@ if (isset($_POST["PRO_FILENAME"]) && "affectedGroups" => !empty($affectedGroups) ? $affectedGroups : '', "sNewProUid" => '', "project_type" => 'bpmn', - "isGranularImport" => false, - "objectGranularImport" => '', + "isGranularImport" => $granularImport, + "objectGranularImport" => $objectImport, "proFileName" => $_POST["PRO_FILENAME"], "groupBeforeAccion" => "uploadFileNewProcess", "importOption" => (isset($_POST["IMPORT_OPTION"])) ? (int)($_POST["IMPORT_OPTION"]) : 0 diff --git a/workflow/engine/templates/processes/main.js b/workflow/engine/templates/processes/main.js index 49d669766..d78f2fbcd 100755 --- a/workflow/engine/templates/processes/main.js +++ b/workflow/engine/templates/processes/main.js @@ -1413,7 +1413,8 @@ importProcessExistGroup = function() } }, failure: function(o, resp) { - var msg = resp.result.msg ? resp.result.msg : resp.response.responseText; + var msg = resp.result ? resp.result.msg : resp.response.responseText; + importProcessGlobal.objectsToImport = ""; w.close(); Ext.MessageBox.show({ title : _('ID_ERROR'), @@ -1613,7 +1614,8 @@ importProcessExistProcess = function() } }, failure : function(o, resp) { - var msg = resp.result.msg ? resp.result.msg : resp.response.responseText; + var msg = resp.result ? resp.result.msg : resp.response.responseText; + importProcessGlobal.objectsToImport = ""; w.close(); Ext.MessageBox.show({ title : _('ID_ERROR'),