diff --git a/workflow/engine/classes/class.pmDynaform.php b/workflow/engine/classes/class.pmDynaform.php index 7df0110d1..a334cf880 100644 --- a/workflow/engine/classes/class.pmDynaform.php +++ b/workflow/engine/classes/class.pmDynaform.php @@ -681,7 +681,7 @@ class pmDynaform $this->fields["APP_DATA"] = $dataGridEnvironment; $dataGridEnvironment = []; } - if (isset($this->fields["APP_DATA"][$json->name])) { + if (isset($this->fields["APP_DATA"][$json->name]) && is_array($this->fields["APP_DATA"][$json->name])) { //rows $rows = $this->fields["APP_DATA"][$json->name]; foreach ($rows as $keyRow => $row) { @@ -926,8 +926,7 @@ class pmDynaform $where = ""; if (!empty($parsed["WHERE"])) { $where = "WHERE "; - $dt = ($parsed['WHERE'][0]['expr_type'] == 'expression') ? $parsed['WHERE'][0]['sub_tree'] : - $parsed["WHERE"]; + $dt = ($parsed['WHERE'][0]['expr_type'] == 'expression') ? $parsed['WHERE'][0]['sub_tree'] : $parsed["WHERE"]; $nw = count($dt); //reserved word: OFFSET if ($dt[$nw - 2]["base_expr"] === "OFFSET") { @@ -953,7 +952,8 @@ class pmDynaform $groupBy = "GROUP BY "; $dt = $parsed["GROUP"]; foreach ($dt as $key => $value) { - $groupBy .= $value["base_expr"] . ", "; + $search = preg_replace("/ ASC$/i", "", $value["base_expr"]); + $groupBy .= $search . ", "; } $groupBy = rtrim($groupBy, ", "); } @@ -974,10 +974,10 @@ class pmDynaform $orderBy = "ORDER BY "; $dt = $parsed["ORDER"]; foreach ($dt as $key => $value) { - $orderBy .= $value["base_expr"] . ", "; + $search = preg_replace("/ ASC$/i", "", $value["base_expr"]); + $orderBy .= $search . " " . $value["direction"] . ", "; } $orderBy = rtrim($orderBy, ", "); - $orderBy .= " " . $value["direction"]; } $orderBy = trim($orderBy); diff --git a/workflow/engine/classes/model/AppDocument.php b/workflow/engine/classes/model/AppDocument.php index a3e326d75..7e9eb6075 100644 --- a/workflow/engine/classes/model/AppDocument.php +++ b/workflow/engine/classes/model/AppDocument.php @@ -369,7 +369,7 @@ class AppDocument extends BaseAppDocument if ($sValue !== null && ! is_string( $sValue )) { $sValue = (string) $sValue; } - if ($this->app_doc_title !== $sValue || $sValue === '') { + if (in_array(AppDocumentPeer::APP_DOC_TITLE, $this->modifiedColumns) || $sValue === '') { try { $this->app_doc_title = $sValue; $iResult = Content::addContent( 'APP_DOC_TITLE', $this->getDocVersion(), $this->getAppDocUid(), (defined( 'SYS_LANG' ) ? SYS_LANG : 'en'), $this->app_doc_title ); @@ -411,7 +411,7 @@ class AppDocument extends BaseAppDocument if ($sValue !== null && ! is_string( $sValue )) { $sValue = (string) $sValue; } - if ($this->app_doc_comment !== $sValue || $sValue === '') { + if (in_array(AppDocumentPeer::APP_DOC_COMMENT, $this->modifiedColumns) || $sValue === '') { try { $this->app_doc_comment = $sValue; $iResult = Content::addContent( 'APP_DOC_COMMENT', $this->getDocVersion(), $this->getAppDocUid(), (defined( 'SYS_LANG' ) ? SYS_LANG : 'en'), $this->app_doc_comment ); @@ -453,7 +453,7 @@ class AppDocument extends BaseAppDocument if ($sValue !== null && ! is_string( $sValue )) { $sValue = (string) $sValue; } - if ($this->app_doc_filename !== $sValue || $sValue === '') { + if (in_array(AppDocumentPeer::APP_DOC_FILENAME, $this->modifiedColumns) || $sValue === '') { try { $this->app_doc_filename = $sValue; $iResult = Content::addContent( 'APP_DOC_FILENAME', $this->getDocVersion(), $this->getAppDocUid(), (defined( 'SYS_LANG' ) ? SYS_LANG : 'en'), $this->app_doc_filename ); diff --git a/workflow/engine/classes/model/Application.php b/workflow/engine/classes/model/Application.php index 9fad21d8a..1159ea10e 100644 --- a/workflow/engine/classes/model/Application.php +++ b/workflow/engine/classes/model/Application.php @@ -89,7 +89,7 @@ class Application extends BaseApplication $v = (string) $v; } - if ($this->app_title_content !== $v || $v === '') { + if (in_array(ApplicationPeer::APP_TITLE, $this->modifiedColumns) || $v === '') { $this->app_title_content = $v; $lang = defined('SYS_LANG')? SYS_LANG : 'en'; $res = Content::addContent('APP_TITLE', '', $this->getAppUid(), $lang, $this->app_title_content); @@ -130,7 +130,7 @@ class Application extends BaseApplication $v = (string) $v; } - if ($this->app_description_content !== $v || $v === '') { + if (in_array(ApplicationPeer::APP_DESCRIPTION, $this->modifiedColumns) || $v === '') { $this->app_description_content = $v; $lang = defined('SYS_LANG')? SYS_LANG : 'en'; $res = Content::addContent('APP_DESCRIPTION', '', $this->getAppUid(), $lang, $this->app_description_content); @@ -252,14 +252,11 @@ class Application extends BaseApplication if ($this->validate()) { $con->begin(); - $res = $this->save(); - $con->commit(); - $this->setAppTitleContent('#' . $maxNumber); $this->setAppDescriptionContent(''); //to do: ID_CASE in translation $this->setAppTitle(G::LoadTranslation('ID_CASE') . $maxNumber); //Content::insertContent('APP_PROC_CODE', '', $this->getAppUid(), $lang, ''); - + $res = $this->save(); $con->commit(); return $this->getAppUid(); diff --git a/workflow/engine/classes/model/Department.php b/workflow/engine/classes/model/Department.php index 2661f00b4..7c11bde98 100644 --- a/workflow/engine/classes/model/Department.php +++ b/workflow/engine/classes/model/Department.php @@ -167,7 +167,7 @@ class Department extends BaseDepartment $v = (string) $v; } - if ($this->depo_title !== $v || $v === '') { + if (in_array(DepartmentPeer::DEP_TITLE, $this->modifiedColumns) || $v === '') { $this->depo_title = $v; $lang = defined( 'SYS_LANG' ) ? SYS_LANG : 'en'; $res = Content::addContent( 'DEPO_TITLE', '', $this->getDepUid(), $lang, $this->depo_title ); diff --git a/workflow/engine/classes/model/Dynaform.php b/workflow/engine/classes/model/Dynaform.php index d60f63763..b5d0e8927 100644 --- a/workflow/engine/classes/model/Dynaform.php +++ b/workflow/engine/classes/model/Dynaform.php @@ -82,7 +82,7 @@ class Dynaform extends BaseDynaform $v = (string) $v; } - if ($this->dyn_title_content !== $v || $v === '') { + if (in_array(DynaformPeer::DYN_TITLE, $this->modifiedColumns) || $v === '') { $this->dyn_title_content = $v; $lang = defined( 'SYS_LANG' ) ? SYS_LANG : 'en'; @@ -131,7 +131,7 @@ class Dynaform extends BaseDynaform $v = (string) $v; } - if ($this->dyn_description !== $v || $v === '') { + if (in_array(DynaformPeer::DYN_DESCRIPTION, $this->modifiedColumns) || $v === '') { $this->dyn_description = $v; $lang = defined( 'SYS_LANG' ) ? SYS_LANG : 'en'; @@ -209,9 +209,9 @@ class Dynaform extends BaseDynaform $this->setDynVersion( $aData['DYN_VERSION'] ); if ($this->validate()) { $con->begin(); - $res = $this->save(); $this->setDynTitleContent( $dynTitle ); $this->setDynDescriptionContent( $dynDescription ); + $res = $this->save(); $con->commit(); //Add Audit Log diff --git a/workflow/engine/classes/model/Groupwf.php b/workflow/engine/classes/model/Groupwf.php index 888c176d8..dd2d826e1 100644 --- a/workflow/engine/classes/model/Groupwf.php +++ b/workflow/engine/classes/model/Groupwf.php @@ -60,7 +60,8 @@ class Groupwf extends BaseGroupwf $v = (string) $v; } - if ($this->grp_title_content !== $v || $v === '') { + if (in_array(GroupwfPeer::GRP_TITLE, $this->modifiedColumns) !== $v || $v + === '') { $this->grp_title_content = $v; $lang = defined( 'SYS_LANG' ) ? SYS_LANG : 'en'; $res = Content::addContent( 'GRP_TITLE', '', $this->getGrpUid(), $lang, $this->grp_title_content ); @@ -105,14 +106,12 @@ class Groupwf extends BaseGroupwf if ($this->validate()) { $con->begin(); - $res = $this->save(); - if (isset( $aData['GRP_TITLE'] )) { $this->setGrpTitleContent( $aData['GRP_TITLE'] ); } else { $this->setGrpTitleContent( 'Default Group Title' ); } - + $res = $this->save(); $con->commit(); return $this->getGrpUid(); } else { diff --git a/workflow/engine/classes/model/InputDocument.php b/workflow/engine/classes/model/InputDocument.php index 1556a6ff7..e990e5308 100644 --- a/workflow/engine/classes/model/InputDocument.php +++ b/workflow/engine/classes/model/InputDocument.php @@ -316,7 +316,7 @@ class InputDocument extends BaseInputDocument if ($sValue !== null && ! is_string( $sValue )) { $sValue = (string) $sValue; } - if ($this->inp_doc_title_content !== $sValue || $sValue === '') { + if (in_array(InputDocumentPeer::INP_DOC_TITLE, $this->modifiedColumns) || $sValue === '') { try { $this->inp_doc_title_content = $sValue; @@ -356,7 +356,7 @@ class InputDocument extends BaseInputDocument if ($sValue !== null && ! is_string( $sValue )) { $sValue = (string) $sValue; } - if ($this->inp_doc_description_content !== $sValue || $sValue === '') { + if (in_array(InputDocumentPeer::INP_DOC_DESCRIPTION, $this->modifiedColumns) || $sValue === '') { try { $this->inp_doc_description_content = $sValue; diff --git a/workflow/engine/classes/model/OutputDocument.php b/workflow/engine/classes/model/OutputDocument.php index 40241b448..f11cab900 100644 --- a/workflow/engine/classes/model/OutputDocument.php +++ b/workflow/engine/classes/model/OutputDocument.php @@ -364,8 +364,7 @@ class OutputDocument extends BaseOutputDocument if ($sValue !== null && !is_string($sValue)) { $sValue = (string) $sValue; } - - if ($this->out_doc_title !== $sValue || $sValue === '') { + if (in_array(OutputDocumentPeer::OUT_DOC_TITLE, $this->modifiedColumns) || $sValue === '') { try { $this->out_doc_title = $sValue; @@ -411,7 +410,7 @@ class OutputDocument extends BaseOutputDocument $sValue = (string) $sValue; } - if ($this->out_doc_description !== $sValue || $sValue === '') { + if (in_array(OutputDocumentPeer::OUT_DOC_DESCRIPTION, $this->modifiedColumns) || $sValue === '') { try { $this->out_doc_description = $sValue; @@ -457,7 +456,7 @@ class OutputDocument extends BaseOutputDocument $sValue = (string) $sValue; } - if ($this->out_doc_filename !== $sValue || $sValue === '') { + if (in_array(OutputDocumentPeer::OUT_DOC_FILENAME, $this->modifiedColumns) || $sValue === '') { try { $this->out_doc_filename = $sValue; @@ -503,7 +502,7 @@ class OutputDocument extends BaseOutputDocument $sValue = (string) $sValue; } - if ($this->out_doc_template !== $sValue || $sValue === '') { + if (in_array(OutputDocumentPeer::OUT_DOC_TEMPLATE, $this->modifiedColumns) || $sValue === '') { try { $this->out_doc_template = $sValue; diff --git a/workflow/engine/classes/model/Process.php b/workflow/engine/classes/model/Process.php index 40911c226..e0d0f9ee0 100644 --- a/workflow/engine/classes/model/Process.php +++ b/workflow/engine/classes/model/Process.php @@ -83,7 +83,7 @@ class Process extends BaseProcess $v = (string) $v; } - if ($this->pro_title_content !== $v || $v === '') { + if (in_array(ProcessPeer::PRO_TITLE, $this->modifiedColumns) || $v === '') { $this->pro_title_content = $v; $lang = defined( 'SYS_LANG' ) ? SYS_LANG : 'en'; @@ -132,7 +132,7 @@ class Process extends BaseProcess $v = (string) $v; } - if ($this->pro_description_content !== $v || $v === '') { + if (in_array(ProcessPeer::PRO_DESCRIPTION, $this->modifiedColumns) || $v === '') { $this->pro_description_content = $v; $lang = defined( 'SYS_LANG' ) ? SYS_LANG : 'en'; @@ -198,7 +198,6 @@ class Process extends BaseProcess if ($this->validate()) { $con->begin(); - $res = $this->save(); if (isset( $aData['PRO_TITLE'] )) { $this->setProTitleContent( $aData['PRO_TITLE'] ); @@ -212,6 +211,7 @@ class Process extends BaseProcess $this->setProDescriptionContent( 'Default Process Description' ); } + $res = $this->save(); $con->commit(); $this->memcachedDelete(); @@ -445,7 +445,6 @@ class Process extends BaseProcess $this->setProDynaforms( isset( $aData['PRO_DYNAFORMS'] ) ? (is_array( $aData['PRO_DYNAFORMS'] ) ? serialize( $aData['PRO_DYNAFORMS'] ) : $aData['PRO_DYNAFORMS']) : '' ); if ($this->validate()) { $con->begin(); - $res = $this->save(); if (isset( $aData['PRO_TITLE'] ) && trim( $aData['PRO_TITLE'] ) != '') { $this->setProTitleContent( $aData['PRO_TITLE'] ); @@ -457,6 +456,8 @@ class Process extends BaseProcess } else { $this->setProDescriptionContent( 'Default Process Description' ); } + + $res = $this->save(); $con->commit(); $this->memcachedDelete(); diff --git a/workflow/engine/classes/model/ReportTable.php b/workflow/engine/classes/model/ReportTable.php index 86c6ffcff..9645180f5 100644 --- a/workflow/engine/classes/model/ReportTable.php +++ b/workflow/engine/classes/model/ReportTable.php @@ -71,7 +71,7 @@ class ReportTable extends BaseReportTable } $v = isset( $v ) ? ((string) $v) : ''; $lang = defined( 'SYS_LANG' ) ? SYS_LANG : 'en'; - if ($this->rep_tab_title !== $v || $v === "") { + if (in_array(ReportTablePeer::REP_TAB_TITLE, $this->modifiedColumns) || $v === "") { $this->rep_tab_title = $v; $res = Content::addContent( 'REP_TAB_TITLE', '', $this->getRepTabUid(), $lang, $this->rep_tab_title ); return $res; diff --git a/workflow/engine/classes/model/Task.php b/workflow/engine/classes/model/Task.php index 890f1a86d..2e72dc8a7 100644 --- a/workflow/engine/classes/model/Task.php +++ b/workflow/engine/classes/model/Task.php @@ -53,7 +53,7 @@ class Task extends BaseTask $v = isset($v)? ((string)$v) : ''; $lang = defined('SYS_LANG')? SYS_LANG : 'en'; - if ($this->tas_title_content !== $v || $v === "") { + if (in_array(TaskPeer::TAS_TITLE, $this->modifiedColumns) || $v === "") { $this->tas_title_content = $v; $res = Content::addContent('TAS_TITLE', '', $this->getTasUid(), $lang, $this->tas_title_content); @@ -101,7 +101,7 @@ class Task extends BaseTask $v = isset($v)? ((string)$v) : ''; $lang = defined('SYS_LANG')? SYS_LANG : 'en'; - if ($this->tas_description_content !== $v || $v === "") { + if (in_array(TaskPeer::TAS_DESCRIPTION, $this->modifiedColumns) || $v === "") { $this->tas_description_content = $v; $res = Content::addContent('TAS_DESCRIPTION', '', $this->getTasUid(), $lang, $this->tas_description_content); @@ -149,7 +149,7 @@ class Task extends BaseTask $v = isset($v)? ((string)$v) : ''; $lang = defined('SYS_LANG')? SYS_LANG : 'en'; - if ($this->tas_def_title_content !== $v || $v === "") { + if (in_array(TaskPeer::TAS_DEF_TITLE, $this->modifiedColumns) || $v === "") { $this->tas_def_title_content = $v; $res = Content::addContent('TAS_DEF_TITLE', '', $this->getTasUid(), $lang, $this->tas_def_title_content); @@ -197,7 +197,7 @@ class Task extends BaseTask $v = isset($v)? ((string)$v) : ''; $lang = defined('SYS_LANG')? SYS_LANG : 'en'; - if ($this->tas_def_description_content !== $v || $v === "") { + if (in_array(TaskPeer::TAS_DEF_DESCRIPTION, $this->modifiedColumns) || $v === "") { $this->tas_def_description_content = $v; $res = Content::addContent('TAS_DEF_DESCRIPTION', '', $this->getTasUid(), $lang, $v); @@ -244,7 +244,7 @@ class Task extends BaseTask $v = isset($v)? ((string)$v) : ''; $lang = defined('SYS_LANG')? SYS_LANG : 'en'; - if ($this->tas_def_proc_code_content !== $v || $v === "") { + if (in_array(TaskPeer::TAS_DEF_PROC_CODE, $this->modifiedColumns) || $v === "") { $this->tas_def_proc_code_content = $v; $res = Content::addContent('TAS_DEF_PROC_CODE', '', $this->getTasUid(), $lang, $this->tas_def_proc_code_content); @@ -291,7 +291,7 @@ class Task extends BaseTask $v = isset($v)? ((string)$v) : ''; $lang = defined('SYS_LANG')? SYS_LANG : 'en'; - if ($this->tas_def_message_content !== $v || $v === "") { + if (in_array(TaskPeer::TAS_DEF_MESSAGE, $this->modifiedColumns) || $v === "") { $this->tas_def_message_content = $v; $res = Content::addContent('TAS_DEF_MESSAGE', '', $this->getTasUid(), $lang, $this->tas_def_message_content); @@ -339,7 +339,7 @@ class Task extends BaseTask $v = isset($v)? ((string)$v) : ''; $lang = defined('SYS_LANG')? SYS_LANG : 'en'; - if ($this->tas_def_subject_message_content !== $v || $v === "") { + if (in_array(TaskPeer::TAS_DEF_SUBJECT_MESSAGE, $this->modifiedColumns) || $v === "") { $this->tas_def_subject_message_content = $v; $res = Content::addContent('TAS_DEF_SUBJECT_MESSAGE', '', $this->getTasUid(), $lang, $v); diff --git a/workflow/engine/classes/model/Triggers.php b/workflow/engine/classes/model/Triggers.php index 0c7e3619b..b7eeb7bf6 100644 --- a/workflow/engine/classes/model/Triggers.php +++ b/workflow/engine/classes/model/Triggers.php @@ -76,7 +76,7 @@ class Triggers extends BaseTriggers } $v=isset($v)?((string)$v):''; $lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en'; - if ($this->tri_title_content !== $v || $v==="") { + if (in_array(TriggersPeer::TRI_TITLE, $this->modifiedColumns) || $v==="") { $this->tri_title_content = $v; $res = Content::addContent( 'TRI_TITLE', '', $this->getTriUid(), $lang, $this->tri_title_content ); return $res; @@ -112,7 +112,7 @@ class Triggers extends BaseTriggers } $v=isset($v)?((string)$v):''; $lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en'; - if ($this->tri_description !== $v || $v==="") { + if (in_array(TriggersPeer::TRI_DESCRIPTION, $this->modifiedColumns) || $v==="") { $this->tri_description = $v; $res = Content::addContent( 'TRI_DESCRIPTION', '', $this->getTriUid(), $lang, $this->tri_description ); return $res; @@ -169,9 +169,9 @@ class Triggers extends BaseTriggers } else { $this->setTriParam( $aData['TRI_PARAM'] ); } - $result=$this->save(); $this->setTriTitleContent($triTitle); $this->setTriDescriptionContent($triDescription); + $result = $this->save(); $con->commit(); //Add Audit Log $description = "Trigger Name: ".$aData['TRI_TITLE'].", Trigger Uid: ".$triggerUid; diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/GranularImporter.php b/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/GranularImporter.php index d6603d417..80b6aba72 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/GranularImporter.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/GranularImporter.php @@ -14,6 +14,7 @@ class GranularImporter protected $factory; protected $data; + protected $regeneratedUids; /** * GranularImporter constructor. */ @@ -140,7 +141,8 @@ class GranularImporter :$data['tables']['workflow']['process'][0]['PRO_UID']; $objectList[$nameObject] = []; $objectList[$nameObject]['metadata'] = [ - 'PRJ_UID' => $prjUID + 'PRJ_UID' => $prjUID, + 'REGENERATED_UIDS' => $this->regeneratedUids ]; foreach ($data['tables']['plugins'] as $pluginKey => $pluginTable) { $key = explode(".", $pluginKey); @@ -328,6 +330,7 @@ class GranularImporter $newData['tables']['workflow'] = $arrayWorkflowTables; $newData['tables']['plugins'] = isset($data["tables"]["plugins"]) ? $data["tables"]["plugins"] : []; $newData['files']['workflow'] = $arrayWorkflowFiles; + $this->regeneratedUids = $result; return array( 'data' => $newData,