2012-10-18 14:32:01 -04:00
|
|
|
<?php
|
2013-03-14 12:36:34 -04:00
|
|
|
|
|
|
|
|
if (($RBAC_Response = $RBAC->userCanAccess("PM_FACTORY")) != 1) {
|
2012-10-18 14:32:01 -04:00
|
|
|
return $RBAC_Response;
|
|
|
|
|
}
|
2021-04-16 13:15:09 -04:00
|
|
|
if (!class_exists('Triggers')) {
|
|
|
|
|
require_once ('classes/model/Triggers.php');
|
|
|
|
|
}
|
|
|
|
|
$triggers = new Triggers();
|
2012-10-18 14:32:01 -04:00
|
|
|
|
2022-06-30 18:01:35 -04:00
|
|
|
$processMap = new ProcessMap();
|
2012-10-18 14:32:01 -04:00
|
|
|
|
2021-04-16 13:15:09 -04:00
|
|
|
$post = $_POST;
|
2012-10-18 14:32:01 -04:00
|
|
|
|
2021-04-16 13:15:09 -04:00
|
|
|
$allFunction = explode(",", $post['ALLFUNCTION']);
|
|
|
|
|
$allFunctionType = explode(",", $post['ALLFUNCTION_TYPE']);
|
2012-10-18 14:32:01 -04:00
|
|
|
|
2021-04-16 13:15:09 -04:00
|
|
|
$template = "
|
2012-10-18 14:32:01 -04:00
|
|
|
/***************************************************
|
|
|
|
|
*
|
|
|
|
|
* Generated by ProcessMaker Trigger Wizard
|
2021-04-16 13:15:09 -04:00
|
|
|
* Library: " . $post['LIBRARY_NAME'] . "
|
|
|
|
|
* Method: " . $post['PMFUNTION_LABEL'] . "
|
2013-03-14 12:36:34 -04:00
|
|
|
* Date: " . date("Y-m-d H:i:s") . "
|
2012-10-18 14:32:01 -04:00
|
|
|
*
|
2013-03-14 12:36:34 -04:00
|
|
|
* ProcessMaker " . date("Y") . "
|
2012-10-18 14:32:01 -04:00
|
|
|
*
|
|
|
|
|
****************************************************/
|
|
|
|
|
|
|
|
|
|
";
|
|
|
|
|
|
2021-04-16 13:15:09 -04:00
|
|
|
$params = [];
|
2012-10-18 14:32:01 -04:00
|
|
|
//Generate params to send
|
2013-01-29 17:07:22 -04:00
|
|
|
$i = 0;
|
2021-04-16 13:15:09 -04:00
|
|
|
foreach ($allFunction as $k => $v) {
|
2012-10-18 14:32:01 -04:00
|
|
|
if ($v != '') {
|
|
|
|
|
|
2021-04-16 13:15:09 -04:00
|
|
|
$key = trim(str_replace("$", "", $v));
|
|
|
|
|
if (strstr($key, "=")) {
|
|
|
|
|
$parameter = explode("=", $key);
|
|
|
|
|
$key = trim($parameter[0]);
|
2012-10-18 14:32:01 -04:00
|
|
|
}
|
2021-04-16 13:15:09 -04:00
|
|
|
if ($post[$key] != '') {
|
2012-10-18 14:32:01 -04:00
|
|
|
|
2021-04-16 13:15:09 -04:00
|
|
|
if ((strstr($post[$key], "@@")) || ($post['PMFUNTION_NAME'] == 'evaluateFunction' && $k == 0 && strstr($post[$key], "@="))) {
|
|
|
|
|
$option = trim($post[$key]);
|
2012-10-18 14:32:01 -04:00
|
|
|
} else {
|
2013-01-29 17:07:22 -04:00
|
|
|
|
2021-04-16 13:15:09 -04:00
|
|
|
$post[$key] = strstr($post[$key], 'array') !== false ? str_replace("'", '"', $post[$key]) : str_replace("'", "\'", $post[$key]);
|
|
|
|
|
switch (trim($allFunctionType[$i])) {
|
2013-03-14 12:36:34 -04:00
|
|
|
case 'boolean':
|
2021-04-16 13:15:09 -04:00
|
|
|
$option = $post[$key];
|
2013-03-14 12:36:34 -04:00
|
|
|
break;
|
|
|
|
|
case 'int':
|
2021-04-16 13:15:09 -04:00
|
|
|
$option = intval($post[$key]);
|
2013-03-14 12:36:34 -04:00
|
|
|
break;
|
|
|
|
|
case 'float':
|
|
|
|
|
case 'real':
|
|
|
|
|
case 'double':
|
2021-04-16 13:15:09 -04:00
|
|
|
$option = floatval($post[$key]);
|
2013-03-14 12:36:34 -04:00
|
|
|
break;
|
|
|
|
|
default:
|
2021-04-16 13:15:09 -04:00
|
|
|
if (is_numeric($post[$key]) || is_bool($post[$key]) || (strstr($post[$key], "'.array.'") !== false)) {
|
|
|
|
|
$option = trim($post[$key]);
|
|
|
|
|
} else {
|
|
|
|
|
$option = '"' . trim($post[$key]) . '"';
|
|
|
|
|
}
|
2013-03-14 12:36:34 -04:00
|
|
|
break;
|
2013-01-29 17:07:22 -04:00
|
|
|
}
|
2012-10-18 14:32:01 -04:00
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$option = "''";
|
|
|
|
|
}
|
2021-04-16 13:15:09 -04:00
|
|
|
$params[] = $option;
|
2012-10-18 14:32:01 -04:00
|
|
|
}
|
2013-03-14 12:36:34 -04:00
|
|
|
$i++;
|
2012-10-18 14:32:01 -04:00
|
|
|
}
|
2021-04-16 13:15:09 -04:00
|
|
|
|
|
|
|
|
$template .= (isset($post['TRI_ANSWER']) && $post['TRI_ANSWER'] != '') ? $post['TRI_ANSWER'] . " = " : "";
|
|
|
|
|
$template .= $post['PMFUNTION_NAME'] . " (" . implode(",", $params) . ");";
|
2012-10-18 14:32:01 -04:00
|
|
|
|
|
|
|
|
//Create Trigger
|
2021-04-16 13:15:09 -04:00
|
|
|
$post['TRI_WEBBOT'] = $template;
|
|
|
|
|
$postParams = [];
|
|
|
|
|
$postParams['hash'] = G::encryptOld($template);
|
|
|
|
|
$postParams['params'] = $post;
|
2012-10-18 14:32:01 -04:00
|
|
|
|
2021-04-16 13:15:09 -04:00
|
|
|
$post['TRI_PARAM'] = serialize($postParams);
|
|
|
|
|
$triggers->create($post);
|
2012-10-18 14:32:01 -04:00
|
|
|
|
|
|
|
|
//Update Info
|
2021-04-16 13:15:09 -04:00
|
|
|
$post['TRI_UID'] = $triggers->getTriUid();
|
|
|
|
|
$triggers->update($post);
|
2012-10-18 14:32:01 -04:00
|
|
|
|
|
|
|
|
//Update Trigger Array
|
2021-04-16 13:15:09 -04:00
|
|
|
$processMap->triggersList($post['PRO_UID']);
|
2012-10-18 14:32:01 -04:00
|
|
|
|