$option = $_POST['form']['IMPORT_OPTION']; $filename = $_POST['form']['PRO_FILENAME']; $ObjUid = $_POST['form']['OBJ_UID']; $path = PATH_DOCUMENT . 'input' . PATH_SEP; $oData = $oProcess->getProcessData($path . $filename); $Fields['PRO_FILENAME'] = $filename; $sProUid = $oData->process['PRO_UID']; $oData->process['PRO_UID_OLD'] = $sProUid; // code added by gustavo cruz gustavo-at-colosa-dot-com // evaluate actions or import options switch ($action) { case "none": $groupsDuplicated = $oProcess->checkExistingGroups($oData->groupwfs); break; case "rename": $oData->groupwfs = $oProcess->renameExistingGroups($oData->groupwfs); $groupsDuplicated = $oProcess->checkExistingGroups($oData->groupwfs); break; case "merge": $oBaseGroup = $oData->groupwfs; $oNewGroup = $oProcess->mergeExistingGroups($oData->groupwfs); $oData->groupwfs = $oNewGroup; $oData->taskusers = $oProcess->mergeExistingUsers($oBaseGroup, $oNewGroup, $oData->taskusers); break; default: $groupsDuplicated = $oProcess->checkExistingGroups($oData->groupwfs); break; } // if there are duplicated groups render the group importing options if (isset($groupsDuplicated) && $groupsDuplicated > 0) { $Fields['PRO_FILENAME'] = $filename;
public function import($option = self::IMPORT_OPTION_CREATE_NEW, $optionGroup = self::GROUP_IMPORT_OPTION_CREATE_NEW) { $this->prepare(); //Verify data switch ($option) { case self::IMPORT_OPTION_CREATE_NEW: if ($this->targetExists()) { throw new \Exception( \G::LoadTranslation( "ID_IMPORTER_PROJECT_ALREADY_EXISTS_SET_ACTION_TO_CONTINUE", array(implode( "|", array( self::IMPORT_OPTION_CREATE_NEW, self::IMPORT_OPTION_OVERWRITE, self::IMPORT_OPTION_DISABLE_AND_CREATE_NEW, self::IMPORT_OPTION_KEEP_WITHOUT_CHANGING_AND_CREATE_NEW ) )) ), self::IMPORT_STAT_TARGET_ALREADY_EXISTS ); } break; case self::IMPORT_OPTION_OVERWRITE: break; case self::IMPORT_OPTION_DISABLE_AND_CREATE_NEW: break; case self::IMPORT_OPTION_KEEP_WITHOUT_CHANGING_AND_CREATE_NEW: break; } $processes = new \Processes(); switch ($optionGroup) { case self::GROUP_IMPORT_OPTION_CREATE_NEW: $arrayAux = $processes->checkExistingGroups($this->importData["tables"]["workflow"]["groupwfs"]); if (is_array($arrayAux) && count($arrayAux) > 0) { throw new \Exception( \G::LoadTranslation( "ID_IMPORTER_GROUP_ALREADY_EXISTS_SET_ACTION_TO_CONTINUE", array(implode( "|", array( self::GROUP_IMPORT_OPTION_CREATE_NEW, self::GROUP_IMPORT_OPTION_RENAME, self::GROUP_IMPORT_OPTION_MERGE_PREEXISTENT ) )) ), self::IMPORT_STAT_GROUP_ALREADY_EXISTS ); } break; case self::GROUP_IMPORT_OPTION_RENAME: $arrayAux = $processes->renameExistingGroups($this->importData["tables"]["workflow"]["groupwfs"]); if (is_array($arrayAux) && count($arrayAux) > 0) { $this->importData["tables"]["workflow"]["groupwfs"] = $arrayAux; } break; case self::GROUP_IMPORT_OPTION_MERGE_PREEXISTENT: $this->importData["tables"]["workflow"] = (array)($processes->groupwfsUpdateUidByDatabase((object)($this->importData["tables"]["workflow"]))); break; } //Import $name = $this->importData["tables"]["bpmn"]["project"][0]["prj_name"]; switch ($option) { case self::IMPORT_OPTION_CREATE_NEW: //Shouldn't generate new UID for all objects $generateUid = false; break; case self::IMPORT_OPTION_OVERWRITE: //Shouldn't generate new UID for all objects $this->removeProject(); $generateUid = false; break; case self::IMPORT_OPTION_DISABLE_AND_CREATE_NEW: //Should generate new UID for all objects $this->disableProject(); $name = "New - " . $name . " - " . date("M d, H:i"); $generateUid = true; break; case self::IMPORT_OPTION_KEEP_WITHOUT_CHANGING_AND_CREATE_NEW: //Should generate new UID for all objects $name = \G::LoadTranslation("ID_COPY_OF") . " - " . $name . " - " . date("M d, H:i"); $generateUid = true; break; } $this->importData["tables"]["bpmn"]["project"][0]["prj_name"] = $name; $this->importData["tables"]["bpmn"]["diagram"][0]["dia_name"] = $name; $this->importData["tables"]["bpmn"]["process"][0]["pro_name"] = $name; $this->importData["tables"]["workflow"]["process"][0]["PRO_TITLE"] = $name; if ($this->importData["tables"]["workflow"]["process"][0]["PRO_UPDATE_DATE"] . "" == "") { $this->importData["tables"]["workflow"]["process"][0]["PRO_UPDATE_DATE"] = null; } $this->importData["tables"]["workflow"]["process"] = $this->importData["tables"]["workflow"]["process"][0]; //Import $result = $this->doImport($generateUid); //Return return $result; }