This commit is contained in:
dheeyi
2016-03-22 16:32:33 -04:00
parent aa5524c49d
commit b3fa77ef52
7 changed files with 49 additions and 23 deletions

View File

@@ -3925,7 +3925,7 @@ class Processes
* @param array $arrayData * @param array $arrayData
* @throws Exception * @throws Exception
*/ */
public function updateFilesManager(array $arrayData) public function updateFilesManager($processUid, array $arrayData)
{ {
try { try {
$filesManager = new \ProcessMaker\BusinessModel\FilesManager(); $filesManager = new \ProcessMaker\BusinessModel\FilesManager();

View File

@@ -27,7 +27,12 @@ class AssignmentRulesMigrator implements Importable, Exportable
// TODO: Implement beforeImport() method. // TODO: Implement beforeImport() method.
} }
public function import($data) /**
* @param $data
* @param $replace
* @throws ImportException
*/
public function import($data, $replace)
{ {
try { try {
$this->processes->createTaskRows($data); $this->processes->createTaskRows($data);

View File

@@ -29,29 +29,33 @@ class FilesMigrator implements Importable, Exportable
// TODO: Implement beforeImport() method. // TODO: Implement beforeImport() method.
} }
public function import($data) public function import($data, $replace)
{ {
try { try {
$aTable = $data['TABLE']; $aTable = $data['TABLE'];
foreach ($aTable as $value) { foreach ($aTable as $value) {
if($value['PRF_EDITABLE'] !== 1){ if ($value['PRF_EDITABLE'] !== 1) {
$this->processes->createFilesManager($value['PRO_UID'],array($value)); if ($replace) {
$this->processes->createFilesManager($value['PRO_UID'], array($value));
} else {
$this->processes->updateFilesManager($value['PRO_UID'], array($value));
}
} }
} }
$aPath = $data['PATH']; $aPath = $data['PATH'];
foreach ($aPath as $target => $files) { foreach ($aPath as $target => $files) {
$basePath = PATH_DATA . 'sites' . PATH_SEP . SYS_SYS . PATH_SEP . 'public' . PATH_SEP; $basePath = PATH_DATA . 'sites' . PATH_SEP . SYS_SYS . PATH_SEP . 'public' . PATH_SEP;
if(strtoupper($target) === 'PUBLIC'){ if (strtoupper($target) === 'PUBLIC') {
foreach ($files as $file) { foreach ($files as $file) {
$filename = $basePath . ((isset($file["file_path"]))? $file["file_path"] : $file["filepath"]); $filename = $basePath . ((isset($file["file_path"])) ? $file["file_path"] : $file["filepath"]);
$path = dirname($filename); $path = dirname($filename);
if (!is_dir($path)) { if (!is_dir($path)) {
Util\Common::mk_dir($path, 0775); Util\Common::mk_dir($path, 0775);
} }
file_put_contents($filename, $file["file_content"]); file_put_contents($filename, $file["file_content"]);
chmod($filename, 0775); chmod($filename, 0775);
} }
} }
} }

View File

@@ -81,7 +81,7 @@ class ProcessDefinitionMigrator implements Importable, Exportable
$oData->tasks = $this->processes->getTaskRows($prj_uid); $oData->tasks = $this->processes->getTaskRows($prj_uid);
$oDataTask = new \StdClass(); $oDataTask = new \StdClass();
$oDataTask->taskusers = $this->getTaskUserRows( $oData->tasks ); $oDataTask->taskusers = $this->getTaskUserRows($oData->tasks);
$oData->routes = $this->processes->getRouteRows($prj_uid); $oData->routes = $this->processes->getRouteRows($prj_uid);
$oData->lanes = $this->processes->getLaneRows($prj_uid); $oData->lanes = $this->processes->getLaneRows($prj_uid);

View File

@@ -27,22 +27,30 @@ class TemplatesMigrator implements Importable, Exportable
// TODO: Implement beforeImport() method. // TODO: Implement beforeImport() method.
} }
public function import($data) /**
* @param $data
* @param $replace
* @throws ImportException
*/
public function import($data, $replace)
{ {
try { try {
//TABLE
$aTable = $data['TABLE']; $aTable = $data['TABLE'];
foreach ($aTable as $value) { foreach ($aTable as $value) {
if($value['PRF_EDITABLE'] === 1){ if ($value['PRF_EDITABLE'] === 1) {
$this->processes->createFilesManager($value['PRO_UID'],array($value)); if ($replace) {
$this->processes->createFilesManager($value['PRO_UID'], array($value));
} else {
$this->processes->updateFilesManager($value['PRO_UID'], array($value));
}
} }
} }
$aPath = $data['PATH']; $aPath = $data['PATH'];
foreach ($aPath as $target => $files) { foreach ($aPath as $target => $files) {
$basePath = PATH_DATA . 'sites' . PATH_SEP . SYS_SYS . PATH_SEP . 'mailTemplates' . PATH_SEP; $basePath = PATH_DATA . 'sites' . PATH_SEP . SYS_SYS . PATH_SEP . 'mailTemplates' . PATH_SEP;
if(strtoupper($target) === 'TEMPLATES'){ if (strtoupper($target) === 'TEMPLATES') {
foreach ($files as $file) { foreach ($files as $file) {
$filename = $basePath . ((isset($file["file_path"]))? $file["file_path"] : $file["filepath"]); $filename = $basePath . ((isset($file["file_path"])) ? $file["file_path"] : $file["filepath"]);
$path = dirname($filename); $path = dirname($filename);
if (!is_dir($path)) { if (!is_dir($path)) {

View File

@@ -27,10 +27,18 @@ class TriggersMigrator implements Importable, Exportable
// TODO: Implement beforeImport() method. // TODO: Implement beforeImport() method.
} }
public function import($data) /**
* @param $data
* @param $replace
*/
public function import($data, $replace)
{ {
try { try {
$this->processes->createTriggerRows($data); if ($replace) {
$this->processes->createTriggerRows($data);
} else {
$this->processes->updateTriggerRows($data);
}
} catch (\Exception $e) { } catch (\Exception $e) {
\Logger::log($e->getMessage()); \Logger::log($e->getMessage());
throwException(new ImportException($e->getMessage())); throwException(new ImportException($e->getMessage()));

View File

@@ -29,8 +29,9 @@ class VariablesMigrator implements Importable, Exportable
} }
/** /**
* Imports the process variables
* @param $data * @param $data
* @param $replace
* @throws ImportException
*/ */
public function import($data, $replace) public function import($data, $replace)
{ {