Merged in release/3.2 (pull request #5602)

Updating branch release/3.2.1 (third merge)

Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
Julio Cesar Laura Avendaño
2017-04-10 15:58:27 +00:00
16 changed files with 122 additions and 64 deletions

View File

@@ -49,6 +49,7 @@ class DataBaseMaintenance
protected $tmpDir;
protected $outfile;
protected $infile;
protected $isWindows;
/**
* __construct
@@ -64,7 +65,7 @@ class DataBaseMaintenance
$this->tmpDir = './';
$this->link = null;
$this->dbName = null;
$this->isWindows = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN';
if (isset( $host ) && isset( $user ) && isset( $passwd )) {
$this->host = $host;
$this->user = $user;
@@ -399,32 +400,88 @@ class DataBaseMaintenance
*/
function backupDataBase ($outfile)
{
$password = escapeshellarg($this->passwd);
//On Windows, escapeshellarg() instead replaces percent signs, exclamation
//marks (delayed variable substitution) and double quotes with spaces and
//adds double quotes around the string.
//See: http://php.net/manual/en/function.escapeshellarg.php
if ($this->isWindows) {
$password = $this->escapeshellargCustom($this->passwd);
}
$aHost = explode(':', $this->host);
$dbHost = $aHost[0];
if (isset($aHost[1])) {
$dbPort = $aHost[1];
$command = 'mysqldump'
. ' --user=' . $this->user
. ' --password=' . escapeshellarg($this->passwd)
. ' --host=' . $dbHost
. ' --port=' . $dbPort
. ' --opt'
. ' --skip-comments'
. ' ' . $this->dbName
. ' > ' . $outfile;
. ' --user=' . $this->user
. ' --password=' . $password
. ' --host=' . $dbHost
. ' --port=' . $dbPort
. ' --opt'
. ' --skip-comments'
. ' ' . $this->dbName
. ' > ' . $outfile;
} else {
$command = 'mysqldump'
. ' --host=' . $dbHost
. ' --user=' . $this->user
. ' --opt'
. ' --skip-comments'
. ' --password=' . escapeshellarg($this->passwd)
. ' ' . $this->dbName
. ' > ' . $outfile;
. ' --host=' . $dbHost
. ' --user=' . $this->user
. ' --opt'
. ' --skip-comments'
. ' --password=' . $password
. ' ' . $this->dbName
. ' > ' . $outfile;
}
shell_exec($command);
}
/**
* string escapeshellargCustom ( string $arg , character $quotes)
*
* escapeshellarg() adds single quotes around a string and quotes/escapes any
* existing single quotes allowing you to pass a string directly to a shell
* function and having it be treated as a single safe argument. This function
* should be used to escape individual arguments to shell functions coming
* from user input. The shell functions include exec(), system() and the
* backtick operator.
*
* On Windows, escapeshellarg() instead replaces percent signs, exclamation
* marks (delayed variable substitution) and double quotes with spaces and
* adds double quotes around the string.
*/
private function escapeshellargCustom($string, $quotes = "")
{
if ($quotes === "") {
$quotes = $this->isWindows ? "\"" : "'";
}
$n = strlen($string);
$special = ["!", "%", "\""];
$substring = "";
$result1 = [];
$result2 = [];
for ($i = 0; $i < $n; $i++) {
if (in_array($string[$i], $special, true)) {
$result2[] = $string[$i];
$result1[] = $substring;
$substring = "";
} else {
$substring = $substring . $string[$i];
}
}
$result1[] = $substring;
//Rebuild the password string
$n = count($result1);
for ($i = 0; $i < $n; $i++) {
$result1[$i] = trim(escapeshellarg($result1[$i]), $quotes);
if (isset($result2[$i])) {
$result1[$i] = $result1[$i] . $result2[$i];
}
}
//add simple quotes, see escapeshellarg function
$newString = $quotes . implode("", $result1) . $quotes;
return $newString;
}
/**
* restoreFromSql
*

View File

@@ -49,7 +49,7 @@ class p11835 extends patch
}
return patch::$isPathchable;
}
public static function pmVersion($version)
{
if (preg_match("/^\D*([\d\.]+)\D*$/", $version, $matches)) {

View File

@@ -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);

View File

@@ -5,7 +5,9 @@
*
* @author Alexandre Rosenfeld
*/
G::LoadSystem('dbMaintenance');
G::LoadClass("cli");
G::LoadClass("multipleFilesBackup");
/**
* class workspaceTools
*

View File

@@ -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 );

View File

@@ -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();

View File

@@ -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 );

View File

@@ -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

View File

@@ -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 {

View File

@@ -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;

View File

@@ -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;

View File

@@ -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();

View File

@@ -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;

View File

@@ -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);

View File

@@ -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;

View File

@@ -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,