Merged in release/3.3.3 (pull request #6763)

Release/3.3.3

Approved-by: Paula Quispe <paula.quispe@processmaker.com>
This commit is contained in:
Paula Quispe
2019-01-25 13:58:33 +00:00
22 changed files with 330 additions and 245 deletions

View File

@@ -315,7 +315,7 @@ class Calendar extends CalendarDefinition
* @param string(32) $proUid
* @param string(32) $tasUid
*/
function Calendar ($userUid = NULL, $proUid = NULL, $tasUid = NULL)
function __construct($userUid = NULL, $proUid = NULL, $tasUid = NULL)
{
$this->userUid = $userUid;
$this->proUid = $proUid;

View File

@@ -3536,22 +3536,28 @@ class Cases
$executedOn = $oPMScript->getExecutionOriginForAStep($stepType, $stepUidObj, $triggerType);
$oPMScript->setExecutedOn($executedOn);
$oPMScript->execute();
$varsChanged = $oPMScript->getVarsChanged();
$appDataAfterTrigger = $oPMScript->aFields;
//Get the key and values changed
$fieldsTrigger = $this->findKeysAndValues($appDataAfterTrigger, $varsChanged);
//We will be load the last appData
/**
* This section of code its related to the route the case with parallel task in the same time
* @link https://processmaker.atlassian.net/browse/PMC-2
*/
if ($oPMScript->executedOn() === $oPMScript::AFTER_ROUTING) {
//Get the variables changed with the trigger
$fieldsTrigger = arrayDiffRecursive($appDataAfterTrigger, $fieldsCase);
//We will be load the last appData because:
//Other thread execution can be changed the variables
$appUid = !empty($fieldsCase['APPLICATION']) ? $fieldsCase['APPLICATION'] : '';
if (!empty($appUid)) {
//Update $fieldsCase with the last appData
$fieldsCase = $this->loadCase($appUid)['APP_DATA'];
}
//Merge the appData with variables changed
$fieldsCase = array_merge($fieldsCase, $fieldsTrigger);
} else {
$fieldsCase = $appDataAfterTrigger;
}
//Merge the current appData with variables changed
$fieldsCase = array_merge($fieldsCase, $fieldsTrigger);
//Register the time execution
$this->arrayTriggerExecutionTime[$trigger['TRI_UID']] = $oPMScript->scriptExecutionTime;

View File

@@ -194,7 +194,7 @@ class DbConnections
$conf = Propel::getConfiguration();
// Iterate through the datasources of configuration, and only care about workflow, rbac or rp. Remove anything else.
foreach ($conf['datasources'] as $key => $val) {
if (!in_array($key, ['workflow', 'rbac', 'rp'])) {
if (!in_array($key, ['workflow', 'rbac', 'rp', 'dbarray'])) {
unset($conf['datasources'][$key]);
}
}

View File

@@ -253,14 +253,7 @@ class Net
break;
case 'mssql':
//todo
if (!extension_loaded('sqlsrv')) {
if ($this->db_instance != "") {
$link = @mssql_connect($this->ip . "\\" . $this->db_instance, $this->db_user, $this->db_passwd);
} else {
$port = (($this->db_port == "") || ($this->db_port == 0) || ($this->db_port == 1433)) ? "" : ":" . $this->db_port;
$link = @mssql_connect($this->ip . $port, $this->db_user, $this->db_passwd);
}
} else {
if (extension_loaded('sqlsrv')) {
if ($this->db_instance != "") {
$server = $this->ip . "\\" . $this->db_instance;
} else {
@@ -274,6 +267,13 @@ class Net
'Database' => $this->db_sourcename
];
$link = @sqlsrv_connect($server, $opt);
} else {
if ($this->db_instance != "") {
$link = @mssql_connect($this->ip . "\\" . $this->db_instance, $this->db_user, $this->db_passwd);
} else {
$port = (($this->db_port == "") || ($this->db_port == 0) || ($this->db_port == 1433)) ? "" : ":" . $this->db_port;
$link = @mssql_connect($this->ip . $port, $this->db_user, $this->db_passwd);
}
}
if ($link) {
@@ -397,14 +397,7 @@ class Net
}
break;
case 'mssql':
if (!extension_loaded('sqlsrv')) {
if ($this->db_instance != "") {
$link = @mssql_connect($this->ip . "\\" . $this->db_instance, $this->db_user, $this->db_passwd);
} else {
$port = (($this->db_port == "") || ($this->db_port == 0) || ($this->db_port == 1433)) ? "" : ":" . $this->db_port;
$link = @mssql_connect($this->ip . $port, $this->db_user, $this->db_passwd);
}
} else {
if (extension_loaded('sqlsrv')) {
if ($this->db_instance != "") {
$server = $this->ip . "\\" . $this->db_instance;
} else {
@@ -418,6 +411,13 @@ class Net
'Database' => $this->db_sourcename
];
$link = $db = @sqlsrv_connect($server, $opt);
} else {
if ($this->db_instance != "") {
$link = @mssql_connect($this->ip . "\\" . $this->db_instance, $this->db_user, $this->db_passwd);
} else {
$port = (($this->db_port == "") || ($this->db_port == 0) || ($this->db_port == 1433)) ? "" : ":" . $this->db_port;
$link = @mssql_connect($this->ip . $port, $this->db_user, $this->db_passwd);
}
}
if ($link) {
if (!extension_loaded('sqlsrv')) {

View File

@@ -65,6 +65,8 @@ class PmDynaform
}
$this->record["DYN_CONTENT"] = G::json_encode($json);
}
//to do, this line should be removed. Related to PMC-196.
$this->record['DYN_CONTENT'] = G::fixStringCorrupted($this->record['DYN_CONTENT']);
}
public function getDynaformTitle($idDynaform)

View File

@@ -304,7 +304,7 @@ class PMScript
public function executeAndCatchErrors($sScript, $sCode)
{
ob_start('handleFatalErrors');
set_error_handler('handleErrors');
set_error_handler('handleErrors', ini_get('error_reporting'));
$_SESSION['_CODE_'] = $sCode;
$_SESSION['_DATA_TRIGGER_'] = $this->dataTrigger;
$_SESSION['_DATA_TRIGGER_']['_EXECUTION_TIME_'] = microtime(true);
@@ -464,6 +464,8 @@ class PMScript
$sScript = "try {\n" . $sScript . "\n} catch (Exception \$oException) {\n " . " \$this->aFields['__ERROR__'] = utf8_encode(\$oException->getMessage());\n}";
$this->executeAndCatchErrors($sScript, $this->sScript);
//We get the affected_fields only if has the prefix
//@see https://wiki.processmaker.com/3.2/Triggers#Typing_rules_for_Case_Variables
$this->setVarsChanged($this->affected_fields);
$this->aFields["__VAR_CHANGED__"] = implode(",", $this->affected_fields);
for ($i = 0; $i < count($this->affected_fields); $i ++) {

View File

@@ -318,8 +318,8 @@ try {
try {
if(top.opener) {
top.opener.location.reload();
top.close();
}
top.close();
} catch(e) {
}
</script>";

View File

@@ -9,6 +9,8 @@ $oHeadPublisher->addContent("cases/main"); //Adding a html file .html.
$keyMem = "USER_PREFERENCES" . $_SESSION["USER_LOGGED"];
$memcache = PMmemcached::getSingleton(config("system.workspace"));
$openCaseIE = false;
if (($arrayConfig = $memcache->get($keyMem)) === false) {
$conf->loadConfig($x, "USER_PREFERENCES", "", "", $_SESSION["USER_LOGGED"], "");
$arrayConfig = $conf->aConfig;
@@ -86,6 +88,7 @@ if (isset($_SESSION['__OPEN_APPLICATION_UID__'])) {
if (count($arrayDelIndex) === 1) {
//We will to open the case: one thread
$openCaseIE = true;
$defaultOption = '../cases/open?APP_UID=' . $openAppUid . '&DEL_INDEX=' . $arrayDelIndex[0] . '&action=' . $action;
} else {
//We will to show the list: more than one thread
@@ -117,6 +120,7 @@ $urlProxy = 'casesMenuLoader?action=getAllCountersEnterprise&r=';
$oHeadPublisher->assign('regionTreePanel', $regionTreePanel);
$oHeadPublisher->assign('regionDebug', $regionDebug);
$oHeadPublisher->assign('openCaseIE', $openCaseIE);
$oHeadPublisher->assign("defaultOption", $defaultOption); //User menu permissions
$oHeadPublisher->assign('urlProxy', $urlProxy); //sending the urlProxy to make
$oHeadPublisher->assign("_nodeId", isset($confDefaultOption) ? $confDefaultOption : "PM_USERS"); //User menu permissions
@@ -162,4 +166,4 @@ function getAuthorizationCode($client)
return $code;
}
/*----------------------------------********---------------------------------*/
/*----------------------------------********---------------------------------*/

View File

@@ -966,9 +966,10 @@ class DynaForm
if ($record['DYN_VERSION'] === 0) {
$record['DYN_VERSION'] = 1;
}
//to do, this line should be removed. Related to PMC-196.
$record['DYN_CONTENT'] = G::fixStringCorrupted($record['DYN_CONTENT']);
$record['DYN_CONTENT'] = preg_replace_callback("/\\\\u([a-f0-9]{4})/", function ($m) {
return "iconv('UCS-4LE','UTF-8',pack('V', hexdec('U$m[1]')))";
return iconv('UCS-4LE', 'UTF-8', pack('V', hexdec('U' . $m[1])));
}, $record['DYN_CONTENT']);
return array(
@@ -977,7 +978,7 @@ class DynaForm
$this->getFieldNameByFormatFieldName('DYN_DESCRIPTION') => $record['DYN_DESCRIPTION'] . '',
$this->getFieldNameByFormatFieldName('DYN_TYPE') => $record['DYN_TYPE'] . '',
$this->getFieldNameByFormatFieldName('DYN_CONTENT') => $record['DYN_CONTENT'] . '',
$this->getFieldNameByFormatFieldName('DYN_VERSION') => (int)$record['DYN_VERSION'],
$this->getFieldNameByFormatFieldName('DYN_VERSION') => (int) $record['DYN_VERSION'],
$this->getFieldNameByFormatFieldName('DYN_UPDATE_DATE') => $record['DYN_UPDATE_DATE']
);
} catch (\Exception $e) {

View File

@@ -400,6 +400,37 @@ function verifyCsrfToken($request)
}
}
/**
* Get the difference between to multidimensional array
*
* @param array $array1
* @param array $array2
*
* @return array
*/
function arrayDiffRecursive(array $array1, array $array2)
{
$difference = [];
foreach ($array1 as $key => $value) {
if (is_array($value)) {
if (!isset($array2[$key])) {
$difference[$key] = $value;
} elseif (!is_array($array2[$key])) {
$difference[$key] = $value;
} else {
$new_diff = arrayDiffRecursive($value, $array2[$key]);
if (!empty($new_diff)) {
$difference[$key] = $new_diff;
}
}
} elseif (!isset($array2[$key]) || $array2[$key] != $value) {
$difference[$key] = $value;
}
}
return $difference;
}
/**
* Get the current user CSRF token.
*

View File

@@ -1,16 +1,18 @@
var PANEL_EAST_OPEN = false;
var centerPanel;
var setFlag;
var flagRefresh = true;
var debugVarTpl = new Ext.Template('<span style="font-size:11">{value}</span>');
var detailsText = '<i></i>';
var debugTriggersDetailTpl = new Ext.Template('<pre style="font-size:10px"><code>{code}</code></pre>');
var propStore;
var triggerStore;
var result;
var _action = '';
var PANEL_EAST_OPEN = false,
centerPanel,
setFlag,
flagRefresh = true,
debugVarTpl = new Ext.Template('<span style="font-size:11">{value}</span>'),
detailsText = '<i></i>',
debugTriggersDetailTpl = new Ext.Template('<pre style="font-size:10px"><code>{code}</code></pre>'),
propStore,
triggerStore,
result,
_action = '',
//@var treeMenuItemsLoaded -> added to flag the "treeMenuItems" tree, to ensure that its onload event is executed just once
var treeMenuItemsLoaded = false;
treeMenuItemsLoaded = false,
loader,
_BROWSER;
debugVarTpl.compile();
debugTriggersDetailTpl.compile();
@@ -97,34 +99,56 @@ Ext.onReady(function(){
'render': function(tp){}
}
});
var loader = treeMenuItems.getLoader();
loader.on("load", function() {
// it was added since the feature to reload a specific node of tree is now working
if (! treeMenuItemsLoaded) { // this section of code should be executed once
document.getElementById('casesSubFrame').src = defaultOption;
// check if a case was open directly
if (defaultOption.indexOf('open') > -1) {
//if it is, then update cases trees
updateCasesTree();
}
if(_nodeId !== ''){
treePanel1 = Ext.getCmp('tree-panel');
if(treePanel1)
node = treePanel1.getNodeById(_nodeId);
if(node) {
node.select();
if (_nodeId === 'CASES_START_CASE') {
updateCasesTree();
}
/**
* Gets the user client browser and its version
* @return (object)
*/
function getBrowserClient() {
var browsers = ["opera", "msie", "firefox", "opera", "safari", "trident"],
infoBrowser = navigator.userAgent.toLowerCase(),
versionBrowser,
currentBrowser = "";
for (var i = 0; i < browsers.length; i++) {
if ((currentBrowser === "") && (infoBrowser.indexOf(browsers[i]) !== -1)) {
currentBrowser = browsers[i];
versionBrowser = String(parseFloat(infoBrowser.substr(infoBrowser.indexOf(browsers[i]) + browsers[i].length + 1)));
return {name: currentBrowser, browser: currentBrowser, version: versionBrowser}
}
}
}
treeMenuItemsLoaded = true;
return false;
}
});
_BROWSER = getBrowserClient();
loader = treeMenuItems.getLoader();
loader.on("load", function () {
var treePanel1,
node;
// it was added since the feature to reload a specific node of tree is now working
if (!treeMenuItemsLoaded) { // this section of code should be executed once
if ((_BROWSER.name === "msie" || _BROWSER.name === "trident") && openCaseIE) {
parent.window.location.href = defaultOption;
} else {
document.getElementById('casesSubFrame').src = defaultOption;
// check if a case was open directly
if (defaultOption.indexOf('open') > -1) {
//if it is, then update cases trees
updateCasesTree();
}
if (_nodeId !== '') {
treePanel1 = Ext.getCmp('tree-panel');
if (treePanel1) {
node = treePanel1.getNodeById(_nodeId);
}
if (node) {
node.select();
if (_nodeId === 'CASES_START_CASE') {
updateCasesTree();
}
}
}
}
treeMenuItemsLoaded = true;
}
});
// set the root node
var root = new Ext.tree.AsyncTreeNode({
@@ -649,7 +673,7 @@ Ext.app.menuLoader = Ext.extend(Ext.ux.tree.XmlTreeLoader, {
//}
}else if(attr.title){
attr.text = Ext.util.Format.htmlDecode(attr.title);
if( attr.cases_count )
attr.text += ' (<label id="NOTIFIER_'+attr.id+'">' + attr.cases_count + '</label>)';

View File

@@ -32,13 +32,14 @@ function formatAMPM(date, initVal) {
return strTime;
};
function isBrowserIE(){
if ( (navigator.userAgent.indexOf("MSIE")!=-1) || (navigator.userAgent.indexOf("Trident")!=-1) ){
return true;
} else {
return false;
}
};
/**
* Verify if the browser is Internet Explorer
* @return {boolean}
*/
function isBrowserIE() {
var browserAgent = navigator.userAgent.toLowerCase();
return (browserAgent.indexOf("msie") !== -1) || (browserAgent.indexOf("trident") !== -1);
}
Ext.onReady(function(){
openToRevisePanel = function() {
@@ -157,7 +158,7 @@ Ext.onReady(function(){
tb.add(menu);
}
}
var olink = document.location.href;
if(olink.search("gmail") != -1){
Ext.getCmp('stepsMenu').hide();
@@ -229,7 +230,7 @@ Ext.onReady(function(){
if (node.attributes.url) {
//Set load event
if (navigator.userAgent.toLowerCase().indexOf("msie") != -1) {
if (navigator.userAgent.toLowerCase().indexOf("msie") !== -1 || navigator.userAgent.toLowerCase().indexOf("trident") !== -1) {
document.getElementById("openCaseFrame").onreadystatechange = function ()
{
if (document.getElementById("openCaseFrame").readyState == "complete") {