Merged in bugfix/PMC-380 (pull request #6892)

PMC-380

Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
Andrea Adamczyk
2019-05-16 02:46:25 +00:00
committed by Julio Cesar Laura Avendaño
3 changed files with 599 additions and 37 deletions

View File

@@ -14,16 +14,26 @@ use Illuminate\Support\Facades\Schema;
/**
* @todo Migrate to configuration parameters
*/
define('PATH_CORE', 'workflow/engine/');
define('PATH_TRUNK', dirname(__DIR__));
define('PATH_CORE', PATH_TRUNK.'/workflow/engine/');
define('PATH_CONFIG', PATH_CORE . 'config/');
define('PATH_RBAC_CORE', 'rbac/engine/');
define('PATH_DB', 'shared/sites/');
define('PATH_DATA', 'shared/rbac/');
define('PATH_RBAC_CORE',dirname(__DIR__).'/rbac/engine/');
define('PATH_DB', dirname(__DIR__).'/shared/sites/');
define('PATH_DATA', dirname(__DIR__).'/shared/rbac/');
define('PATH_SEP', '/');
define('PATH_METHODS', 'workflow/engine/methods/');
define('PATH_METHODS', dirname(__DIR__).'/workflow/engine/methods/');
define('SYS_LANG', 'en');
define('DB_ADAPTER', 'mysql');
define('SYS_SKIN', 'neoclassic');
define('SYS_SYS', 'workflow');
define('PATH_WORKSPACE',PATH_TRUNK.'/shared/sites/' . SYS_SYS . '/');
define('PMTABLE_KEY','pmtable');
error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT);
//This path includes pmTable model classes
set_include_path(get_include_path() . PATH_SEPARATOR .dirname(__DIR__). "/shared/sites/".SYS_SYS."/");
// Setup basic app services
$app = require __DIR__ . '/../bootstrap/app.php';
@@ -41,7 +51,7 @@ config(['database.connections.testexternal' => [
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
'engine' => null
]]);
// Now, drop all test tables and repopulate with schema

File diff suppressed because it is too large Load Diff

View File

@@ -11,8 +11,9 @@ use ProcessMaker\Core\System;
use ProcessMaker\Validation\ExceptionRestApi;
use ProcessMaker\Validation\ValidationUploadedFiles;
header("Content-type: text/html;charset=utf-8");
require_once 'classes/model/AdditionalTables.php';
//We need to suppress the error for the unittest that use this function
@header("Content-type: text/html;charset=utf-8");
class pmTablesProxy extends HttpProxyController
{
@@ -404,7 +405,6 @@ class pmTablesProxy extends HttpProxyController
$this->className = $table['ADD_TAB_CLASS_NAME'];
$this->classPeerName = $this->className . 'Peer';
$sPath = PATH_DB . config("system.workspace") . PATH_SEP . 'classes' . PATH_SEP;
if (! file_exists( $sPath . $this->className . '.php' )) {
throw new Exception( 'Update:: ' . G::loadTranslation( 'ID_PMTABLE_CLASS_DOESNT_EXIST', $this->className ) );
}
@@ -427,7 +427,6 @@ class pmTablesProxy extends HttpProxyController
if ($result) {
G::auditLog("UpdateDataPmtable", "Table Name: ".$table['ADD_TAB_NAME']." Table ID: (".$table['ADD_TAB_UID'].") ");
}
$this->success = $result;
$this->message = $result ? G::loadTranslation( 'ID_UPDATED_SUCCESSFULLY' ) : G::loadTranslation( 'ID_UPDATE_FAILED' );
}
@@ -1094,32 +1093,38 @@ class pmTablesProxy extends HttpProxyController
/**
* Update data from a addTable record
*
* @param $row
* @param array $row
* @param array $primaryKeys
* @return boolean
* @throws Exception
*
* @see workflow/engine/controllers/pmTablesProxy::dataUpdate()
* @link https://wiki.processmaker.com/3.2/PM_Tables
*/
public function _dataUpdate ($row, $primaryKeys)
public function _dataUpdate($row, $primaryKeys)
{
$keys = G::decrypt( $row['__index__'], 'pmtable' );
$keys = explode( ',', $keys );
unset( $row['__index__'] );
$keys = G::decrypt($row['__index__'], 'pmtable');
$keys = explode(',', $keys);
unset($row['__index__']);
$params = array ();
$params = [];
foreach ($keys as $key) {
$params[] = is_numeric( $key ) ? $key : "'$key'";
$params[] = is_int($key) ? (int)$key : (string)$key;
}
$obj = null;
eval( '$obj = ' . $this->classPeerName . '::retrieveByPk(' . implode( ',', $params ) . ');' );
if (is_object( $obj )) {
$className = $this->classPeerName;
$obj = call_user_func_array($className . "::retrieveByPk", $params);
if (is_object($obj)) {
foreach ($row as $key => $value) {
// validation, don't modify primary keys
if (in_array( $key, $primaryKeys )) {
throw new Exception( G::loadTranslation( 'ID_DONT_MODIFY_PK_VALUE', array ($key
) ) );
if (in_array($key, $primaryKeys)) {
throw new Exception(G::loadTranslation('ID_DONT_MODIFY_PK_VALUE', [
$key
]));
}
$action = 'set' . AdditionalTables::getPHPName( $key );
$obj->$action( $value );
$action = 'set' . AdditionalTables::getPHPName($key);
$obj->$action($value);
}
if ($r = $obj->validate()) {
$obj->save();
@@ -1129,7 +1134,7 @@ class pmTablesProxy extends HttpProxyController
foreach ($obj->getValidationFailures() as $objValidationFailure) {
$msg .= $objValidationFailure->getMessage() . "\n";
}
throw new Exception( $msg );
throw new Exception($msg);
}
} else {
$result = false;
@@ -1141,22 +1146,25 @@ class pmTablesProxy extends HttpProxyController
/**
* Update data from a addTable record
*
* @param $row
* @param array $row
* @return boolean
* @see workflow/engine/controllers/pmTablesProxy::dataDestroy()
* @link https://wiki.processmaker.com/3.2/PM_Tables
*/
public function _dataDestroy ($row)
public function _dataDestroy($row)
{
$row = G::decrypt( $row, 'pmtable' );
$row = str_replace( '"', '', $row );
$keys = explode( ',', $row );
$params = array ();
$row = G::decrypt($row, 'pmtable');
$row = str_replace('"', '', $row);
$keys = explode(',', $row);
$params = [];
foreach ($keys as $key) {
$params[] = is_numeric( $key ) ? $key : "'$key'";
$params[] = is_int($key) ? (int)$key : (string)$key;
}
$obj = null;
eval( '$obj = ' . $this->classPeerName . '::retrieveByPk(' . implode( ',', $params ) . ');' );
$className = $this->classPeerName;
$obj = call_user_func_array($className . "::retrieveByPk", $params);
if (is_object( $obj )) {
if (is_object($obj)) {
$obj->delete();
return true;
} else {