PMCORE-2974 Review the WARNING in the file workflow/engine/methods/triggers/triggers_WizardSave.php
This commit is contained in:
@@ -1,46 +1,26 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* triggers_WizardSave.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*/
|
||||
if (($RBAC_Response = $RBAC->userCanAccess("PM_FACTORY")) != 1) {
|
||||
return $RBAC_Response;
|
||||
}
|
||||
require_once ('classes/model/Triggers.php');
|
||||
$oTrigger = new Triggers();
|
||||
if (!class_exists('Triggers')) {
|
||||
require_once ('classes/model/Triggers.php');
|
||||
}
|
||||
$triggers = new Triggers();
|
||||
|
||||
$oProcessMap = new ProcessMap(new DBConnection());
|
||||
$processMap = new ProcessMap(new DBConnection());
|
||||
|
||||
$aDataTriggers = $_POST;
|
||||
$post = $_POST;
|
||||
|
||||
$aInfoFunction = explode(",", $aDataTriggers['ALLFUNCTION']);
|
||||
$aInfoFunctionType = explode(",", $aDataTriggers['ALLFUNCTION_TYPE']);
|
||||
$allFunction = explode(",", $post['ALLFUNCTION']);
|
||||
$allFunctionType = explode(",", $post['ALLFUNCTION_TYPE']);
|
||||
|
||||
$sPMfunction = "
|
||||
$template = "
|
||||
/***************************************************
|
||||
*
|
||||
* Generated by ProcessMaker Trigger Wizard
|
||||
* Library: " . $aDataTriggers['LIBRARY_NAME'] . "
|
||||
* Method: " . $aDataTriggers['PMFUNTION_LABEL'] . "
|
||||
* Library: " . $post['LIBRARY_NAME'] . "
|
||||
* Method: " . $post['PMFUNTION_LABEL'] . "
|
||||
* Date: " . date("Y-m-d H:i:s") . "
|
||||
*
|
||||
* ProcessMaker " . date("Y") . "
|
||||
@@ -49,65 +29,69 @@ $sPMfunction = "
|
||||
|
||||
";
|
||||
|
||||
$methodParamsFinal = array();
|
||||
$params = [];
|
||||
//Generate params to send
|
||||
$i = 0;
|
||||
foreach ($aInfoFunction as $k => $v) {
|
||||
foreach ($allFunction as $k => $v) {
|
||||
if ($v != '') {
|
||||
|
||||
$sOptionTrigger = trim(str_replace("$", "", $v));
|
||||
if (strstr($sOptionTrigger, "=")) {
|
||||
$aOptionParameters = explode("=", $sOptionTrigger);
|
||||
$sOptionTrigger = trim($aOptionParameters[0]);
|
||||
$key = trim(str_replace("$", "", $v));
|
||||
if (strstr($key, "=")) {
|
||||
$parameter = explode("=", $key);
|
||||
$key = trim($parameter[0]);
|
||||
}
|
||||
if ($aDataTriggers[$sOptionTrigger] != '') {
|
||||
if ($post[$key] != '') {
|
||||
|
||||
if ((strstr($aDataTriggers[$sOptionTrigger], "@@")) || ($aDataTriggers['PMFUNTION_NAME'] == 'evaluateFunction' && $k == 0 && strstr($aDataTriggers[$sOptionTrigger], "@="))) {
|
||||
$option = trim($aDataTriggers[$sOptionTrigger]);
|
||||
if ((strstr($post[$key], "@@")) || ($post['PMFUNTION_NAME'] == 'evaluateFunction' && $k == 0 && strstr($post[$key], "@="))) {
|
||||
$option = trim($post[$key]);
|
||||
} else {
|
||||
|
||||
$aDataTriggers[$sOptionTrigger] = (strstr($aDataTriggers[$sOptionTrigger], 'array')) ? str_replace("'", '"', $aDataTriggers[$sOptionTrigger]) : str_replace("'", "\'", $aDataTriggers[$sOptionTrigger]);
|
||||
switch (trim($aInfoFunctionType[$i])) {
|
||||
$post[$key] = strstr($post[$key], 'array') !== false ? str_replace("'", '"', $post[$key]) : str_replace("'", "\'", $post[$key]);
|
||||
switch (trim($allFunctionType[$i])) {
|
||||
case 'boolean':
|
||||
$option = $aDataTriggers[$sOptionTrigger];
|
||||
$option = $post[$key];
|
||||
break;
|
||||
case 'int':
|
||||
$option = intval($aDataTriggers[$sOptionTrigger]);
|
||||
$option = intval($post[$key]);
|
||||
break;
|
||||
case 'float':
|
||||
case 'real':
|
||||
case 'double':
|
||||
$option = floatval($aDataTriggers[$sOptionTrigger]);
|
||||
$option = floatval($post[$key]);
|
||||
break;
|
||||
default:
|
||||
$option = (is_numeric($aDataTriggers[$sOptionTrigger]) || is_bool($aDataTriggers[$sOptionTrigger]) ) ? trim($aDataTriggers[$sOptionTrigger]) : (strstr($aDataTriggers[$sOptionTrigger], "'.array.'")) ? trim($aDataTriggers[$sOptionTrigger]) : '"' . trim($aDataTriggers[$sOptionTrigger]) . '"';
|
||||
if (is_numeric($post[$key]) || is_bool($post[$key]) || (strstr($post[$key], "'.array.'") !== false)) {
|
||||
$option = trim($post[$key]);
|
||||
} else {
|
||||
$option = '"' . trim($post[$key]) . '"';
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$option = "''";
|
||||
}
|
||||
$methodParamsFinal[] = $option;
|
||||
$params[] = $option;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
//G::pr($methodParamsFinal);die;
|
||||
$sPMfunction .= (isset($aDataTriggers['TRI_ANSWER']) && $aDataTriggers['TRI_ANSWER'] != '') ? $aDataTriggers['TRI_ANSWER'] . " = " : "";
|
||||
$sPMfunction .= $aDataTriggers['PMFUNTION_NAME'] . " (" . implode(",", $methodParamsFinal) . ");";
|
||||
|
||||
$template .= (isset($post['TRI_ANSWER']) && $post['TRI_ANSWER'] != '') ? $post['TRI_ANSWER'] . " = " : "";
|
||||
$template .= $post['PMFUNTION_NAME'] . " (" . implode(",", $params) . ");";
|
||||
|
||||
//Create Trigger
|
||||
$aDataTriggers['TRI_WEBBOT'] = $sPMfunction;
|
||||
$aDataTriggersParams = array();
|
||||
$aDataTriggersParams['hash'] = G::encryptOld($sPMfunction);
|
||||
$aDataTriggersParams['params'] = $aDataTriggers;
|
||||
$post['TRI_WEBBOT'] = $template;
|
||||
$postParams = [];
|
||||
$postParams['hash'] = G::encryptOld($template);
|
||||
$postParams['params'] = $post;
|
||||
|
||||
$aDataTriggers['TRI_PARAM'] = serialize($aDataTriggersParams);
|
||||
$oTrigger->create($aDataTriggers);
|
||||
$post['TRI_PARAM'] = serialize($postParams);
|
||||
$triggers->create($post);
|
||||
|
||||
//Update Info
|
||||
$aDataTriggers['TRI_UID'] = $oTrigger->getTriUid();
|
||||
$oTrigger->update($aDataTriggers);
|
||||
$post['TRI_UID'] = $triggers->getTriUid();
|
||||
$triggers->update($post);
|
||||
|
||||
//Update Trigger Array
|
||||
$oProcessMap->triggersList($aDataTriggers['PRO_UID']);
|
||||
$processMap->triggersList($post['PRO_UID']);
|
||||
|
||||
|
||||
@@ -1,48 +1,26 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* triggers_WizardUpdate.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*/
|
||||
if (($RBAC_Response = $RBAC->userCanAccess("PM_FACTORY")) != 1) {
|
||||
return $RBAC_Response;
|
||||
}
|
||||
if (!class_exists('Triggers')) {
|
||||
require_once ('classes/model/Triggers.php');
|
||||
}
|
||||
$oTrigger = new Triggers();
|
||||
$triggers = new Triggers();
|
||||
|
||||
$oProcessMap = new ProcessMap(new DBConnection());
|
||||
$processMap = new ProcessMap(new DBConnection());
|
||||
|
||||
$aDataTriggers = $_POST;
|
||||
$triUid = $_POST['TRI_UID'];
|
||||
$post = $_POST;
|
||||
|
||||
$aInfoFunction = explode(",", $aDataTriggers['ALLFUNCTION']);
|
||||
$aInfoFunctionType = explode(",", $aDataTriggers['ALLFUNCTION_TYPE']);
|
||||
$sPMfunction = "
|
||||
$allFunction = explode(",", $post['ALLFUNCTION']);
|
||||
$allFunctionType = explode(",", $post['ALLFUNCTION_TYPE']);
|
||||
|
||||
$template = "
|
||||
/***************************************************
|
||||
*
|
||||
* Generated by ProcessMaker Trigger Wizard
|
||||
* Library: " . $aDataTriggers['LIBRARY_NAME'] . "
|
||||
* Method: " . $aDataTriggers['PMFUNTION_LABEL'] . "
|
||||
* Library: " . $post['LIBRARY_NAME'] . "
|
||||
* Method: " . $post['PMFUNTION_LABEL'] . "
|
||||
* Date: " . date("Y-m-d H:i:s") . "
|
||||
*
|
||||
* ProcessMaker " . date("Y") . "
|
||||
@@ -51,68 +29,69 @@ $sPMfunction = "
|
||||
|
||||
";
|
||||
|
||||
|
||||
$methodParamsFinal = array();
|
||||
$params = [];
|
||||
//Generate params to send
|
||||
$i = 0;
|
||||
foreach ($aInfoFunction as $k => $v) {
|
||||
foreach ($allFunction as $k => $v) {
|
||||
if ($v != '') {
|
||||
|
||||
$sOptionTrigger = trim(str_replace("$", "", $v));
|
||||
if (strstr($sOptionTrigger, "=")) {
|
||||
$aOptionParameters = explode("=", $sOptionTrigger);
|
||||
$sOptionTrigger = trim($aOptionParameters[0]);
|
||||
$key = trim(str_replace("$", "", $v));
|
||||
if (strstr($key, "=")) {
|
||||
$parameter = explode("=", $key);
|
||||
$key = trim($parameter[0]);
|
||||
}
|
||||
if ($aDataTriggers[$sOptionTrigger] != '') {
|
||||
if ($post[$key] != '') {
|
||||
|
||||
if ((strstr($aDataTriggers[$sOptionTrigger], "@@")) || ($aDataTriggers['PMFUNTION_NAME'] == 'evaluateFunction' && $k == 0 && strstr($aDataTriggers[$sOptionTrigger], "@="))) {
|
||||
$option = $aDataTriggers[$sOptionTrigger];
|
||||
if ((strstr($post[$key], "@@")) || ($post['PMFUNTION_NAME'] == 'evaluateFunction' && $k == 0 && strstr($post[$key], "@="))) {
|
||||
$option = trim($post[$key]);
|
||||
} else {
|
||||
|
||||
$aDataTriggers[$sOptionTrigger] = (strstr($aDataTriggers[$sOptionTrigger], 'array')) ? str_replace("'", '"', $aDataTriggers[$sOptionTrigger]) : str_replace("'", "\'", $aDataTriggers[$sOptionTrigger]);
|
||||
switch (trim($aInfoFunctionType[$i])) {
|
||||
$post[$key] = strstr($post[$key], 'array') !== false ? str_replace("'", '"', $post[$key]) : str_replace("'", "\'", $post[$key]);
|
||||
switch (trim($allFunctionType[$i])) {
|
||||
case 'boolean':
|
||||
$option = $aDataTriggers[$sOptionTrigger];
|
||||
$option = $post[$key];
|
||||
break;
|
||||
case 'int':
|
||||
$option = intval($aDataTriggers[$sOptionTrigger]);
|
||||
$option = intval($post[$key]);
|
||||
break;
|
||||
case 'float':
|
||||
case 'real':
|
||||
case 'double':
|
||||
$option = floatval($aDataTriggers[$sOptionTrigger]);
|
||||
$option = floatval($post[$key]);
|
||||
break;
|
||||
default:
|
||||
$option = (is_numeric($aDataTriggers[$sOptionTrigger]) || is_bool($aDataTriggers[$sOptionTrigger]) ) ? trim($aDataTriggers[$sOptionTrigger]) : (strstr($aDataTriggers[$sOptionTrigger], "array")) ? trim($aDataTriggers[$sOptionTrigger]) : '"' . trim($aDataTriggers[$sOptionTrigger]) . '"';
|
||||
if (is_numeric($post[$key]) || is_bool($post[$key]) || (strstr($post[$key], "array") !== false)) {
|
||||
$option = trim($post[$key]);
|
||||
} else {
|
||||
$option = '"' . trim($post[$key]) . '"';
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$option = "' '";
|
||||
}
|
||||
$methodParamsFinal[] = $option;
|
||||
$params[] = $option;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
$sPMfunction .= (isset($aDataTriggers['TRI_ANSWER']) && $aDataTriggers['TRI_ANSWER'] != '') ? $aDataTriggers['TRI_ANSWER'] . " = " : "";
|
||||
$sPMfunction .= $aDataTriggers['PMFUNTION_NAME'] . " (" . implode(",", $methodParamsFinal) . ");";
|
||||
$template .= (isset($post['TRI_ANSWER']) && $post['TRI_ANSWER'] != '') ? $post['TRI_ANSWER'] . " = " : "";
|
||||
$template .= $post['PMFUNTION_NAME'] . " (" . implode(",", $params) . ");";
|
||||
|
||||
//Create Trigger
|
||||
$aDataTriggers['TRI_WEBBOT'] = $sPMfunction;
|
||||
$aDataTriggersParams = array();
|
||||
$aDataTriggersParams['hash'] = G::encryptOld($sPMfunction);
|
||||
$aDataTriggersParams['params'] = $aDataTriggers;
|
||||
$post['TRI_WEBBOT'] = $template;
|
||||
$postParams = [];
|
||||
$postParams['hash'] = G::encryptOld($template);
|
||||
$postParams['params'] = $post;
|
||||
|
||||
$post['TRI_PARAM'] = serialize($postParams);
|
||||
$triggers->load($_POST['TRI_UID']);
|
||||
|
||||
$aDataTriggers['TRI_PARAM'] = serialize($aDataTriggersParams);
|
||||
//$oTrigger->create ( $aDataTriggers );
|
||||
$aDataTriggerLoaded = $oTrigger->load($triUid);
|
||||
//var_dump($aDataTriggerLoaded);
|
||||
//die;
|
||||
//Update Info
|
||||
$aDataTriggers['TRI_UID'] = $oTrigger->getTriUid();
|
||||
$oTrigger->update($aDataTriggers);
|
||||
$post['TRI_UID'] = $triggers->getTriUid();
|
||||
$triggers->update($post);
|
||||
|
||||
//Update Trigger Array
|
||||
$oProcessMap->triggersList($aDataTriggers['PRO_UID']);
|
||||
$processMap->triggersList($post['PRO_UID']);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user