Conflicts

This commit is contained in:
Paula Quispe
2020-06-12 18:00:12 -04:00
31 changed files with 2396 additions and 67 deletions

View File

@@ -50,11 +50,10 @@ Internet Explorer 7 or later
|* PHP Configuration *|
-----------------------
In the PHP configuration file (php.ini), set the following settings:
memory_limit = 120M
memory_limit = 256M
file_uploads = On
short_open_tag = On
The memory_limit may be a minimum of 80MB, but it is recommended to set it to
120MB. If planning on uploading large Input Documents and attached files, then
If planning on uploading large Input Documents and attached files, then
increase the max_post_size and upload_max_filesize to larger than the default
2MB:
max_post_size = 2M

View File

@@ -6,9 +6,37 @@ use ProcessMaker\Model\ProcessVariables;
$factory->define(ProcessVariables::class, function (Faker $faker) {
return [
'VAR_UID' => G::generateUniqueID(),
'PRO_ID' => G::generateUniqueID(),
'PRJ_UID' => G::generateUniqueID(),
'VAR_NAME' => $faker->word,
'VAR_FIELD_TYPE' => G::generateUniqueID(),
'VAR_FIELD_TYPE_ID' => G::generateUniqueID(),
'VAR_FIELD_SIZE' => 10,
'VAR_LABEL' => 'string',
'VAR_DBCONNECTION' => 'workflow',
'VAR_SQL' => '',
'VAR_NULL' => 0,
'VAR_DEFAULT' => '',
'VAR_ACCEPTED_VALUES' => '[]',
'INP_DOC_UID' => ''
];
});
// Create a processVariables with the foreign keys
$factory->state(ProcessVariables::class, 'foreign_keys', function (Faker $faker) {
$types = ['string', 'integer', 'float', 'boolean', 'datetime', 'grid', 'array', 'file', 'multiplefile', 'object'];
$varType = $faker->randomElement($types);
$varTypeId = array_search($varType, $types) + 1;
// Create values in the foreign key relations
$process = factory(\ProcessMaker\Model\Process::class)->create();
return [
'VAR_UID' => G::generateUniqueID(),
'PRO_ID' => $process->PRO_ID,
'PRJ_UID' => $process->PRO_UID,
'VAR_NAME' => $faker->word,
'VAR_FIELD_TYPE' => $varType,
'VAR_FIELD_TYPE_ID' => $varTypeId,
'VAR_FIELD_SIZE' => 10,
'VAR_LABEL' => 'string',
'VAR_DBCONNECTION' => 'workflow',

View File

@@ -536,7 +536,6 @@ class WebApplication
ini_set('error_reporting', $arraySystemConfiguration['error_reporting']);
ini_set('short_open_tag', 'On'); //??
ini_set('default_charset', 'UTF-8'); //??
ini_set('memory_limit', $arraySystemConfiguration['memory_limit']);
ini_set('soap.wsdl_cache_enabled', $arraySystemConfiguration['wsdl_cache']);
ini_set('date.timezone', TIME_ZONE); //Set Time Zone

View File

@@ -3,7 +3,6 @@
/*** enable display_error On to caught even fatal errors ***/
ini_set('display_errors','On');
ini_set('error_reporting', E_ALL );
ini_set('memory_limit', '80M');
$path = Array();
$sf = $_SERVER['SCRIPT_FILENAME'];

View File

@@ -90,6 +90,10 @@
var evaluateFunctionFunction = [evaluateFunction+"($gridName,$Expression)"];
arrayFunctions[evaluateFunction] = evaluateFunctionFunction;
var PMFTotalCalculation = "PMFTotalCalculation";
var PMFTotalCalculationFunction = [PMFTotalCalculation + "($gridName, $field, 'function')"];
arrayFunctions[PMFTotalCalculation] = PMFTotalCalculationFunction;
var PMFTaskCase = "PMFTaskCase";
var PMFTaskCaseFunction = [PMFTaskCase+"($caseId)"];
arrayFunctions[PMFTaskCase] = PMFTaskCaseFunction;
@@ -219,7 +223,7 @@
arrayFunctions[PMFGetCaseNotes] = PMFGetCaseNotesFunction;
var phpPMFunctions = [formatDate,getCurrentDate,getCurrentTime,literalDate,capitalize,lowerCase,upperCase,userInfo,executeQuery,orderGrid,
evaluateFunction,PMFTaskCase,PMFTaskList,PMFUserList,PMFGroupList,PMFRoleList,PMFCaseList,PMFProcessList,PMFSendVariables,PMFDerivateCase,
evaluateFunction, PMFTotalCalculation, PMFTaskCase,PMFTaskList,PMFUserList,PMFGroupList,PMFRoleList,PMFCaseList,PMFProcessList,PMFSendVariables,PMFDerivateCase,
PMFNewCaseImpersonate,PMFNewCase,PMFPauseCase,PMFUnpauseCase,PMFAssignUserToGroup,PMFCreateUser,PMFUpdateUser,PMFInformationUser,
generateCode,setCaseTrackerCode,jumping,PMFRedirectToStep,pauseCase,PMFSendMessage,PMFgetLabelOption,PMFGenerateOutputDocument,
PMFGetUserEmailAddress,PMFGetNextAssignedUser,PMFDeleteCase,PMFCancelCase,PMFAddInputDocument,PMFAddCaseNote,PMFGetCaseNotes];

View File

@@ -436,7 +436,6 @@ class DataBaseMaintenance
*/
public function restoreFromSql($sqlFile, $type = 'file')
{
ini_set('memory_limit', '64M');
if ($type == 'file' && !is_file($sqlFile)) {
throw new Exception("the $sqlFile doesn't exist!");
}

View File

@@ -2750,11 +2750,6 @@ class G
if (!array_key_exists("channels", $imageInfo)) {
$imageInfo["channels"] = 3;
}
$memoryNeeded = Round(($imageInfo[0] * $imageInfo[1] * $imageInfo['bits'] * $imageInfo['channels'] + Pow(2, 16)) * 1.95) / (1024 * 1024);
if ($memoryNeeded < 80) {
$memoryNeeded = 80;
}
ini_set('memory_limit', intval($memoryNeeded) . 'M');
$functions = array(IMAGETYPE_GIF => array('imagecreatefromgif', 'imagegif'
), IMAGETYPE_JPEG => array('imagecreatefromjpeg', 'imagejpeg'), IMAGETYPE_PNG => array('imagecreatefrompng', 'imagepng'));

File diff suppressed because it is too large Load Diff

View File

@@ -984,6 +984,64 @@ class PmDynaformTest extends TestCase
// Compare the values
$this->assertEquals($dynaformTitle, $dynaform->DYN_TITLE);
}
/**
* This test should verify the setDependentOptionsForDatetime() method, to
* add the dependentOptions property to the datetime control.
* @test
* @covers PmDynaform::jsonr()
* @covers PmDynaform::setDependentOptionsForDatetime()
*/
public function it_should_test_dependent_options_for_datetime_control()
{
$pathData = PATH_TRUNK . "/tests/resources/dynaform1.json";
$data = file_get_contents($pathData);
$json = json_decode($data);
//assert for not contain property: dependentOptions
$result = json_decode(json_encode($json), JSON_OBJECT_AS_ARRAY);
$fn = function($item) use(&$fn) {
if (is_array($item)) {
if (isset($item['type']) && $item['type'] === 'datetime') {
$this->assertArrayNotHasKey('dependentOptions', $item);
}
array_map($fn, $item);
}
};
array_map($fn, $result);
//assert new property: dependentOptions
$dynaform = new PmDynaform();
$dynaform->jsonr($json);
$result = json_decode(json_encode($json), JSON_OBJECT_AS_ARRAY);
$fn = function($item) use(&$fn) {
if (is_array($item)) {
if (isset($item['type']) && $item['type'] === 'datetime') {
$this->assertArrayHasKey('dependentOptions', $item);
$this->assertArrayHasKey('minDate', $item['dependentOptions']);
$this->assertArrayHasKey('maxDate', $item['dependentOptions']);
$this->assertArrayHasKey('defaultDate', $item['dependentOptions']);
}
array_map($fn, $item);
}
};
array_map($fn, $result);
$dynaform = new PmDynaform();
$reflection = new ReflectionClass($dynaform);
$reflectionMethod = $reflection->getMethod('setDependentOptionsForDatetime');
$reflectionMethod->setAccessible(true);
$a = new stdClass();
$reflectionMethod->invokeArgs($dynaform, [&$a]);
$this->assertInstanceOf('ReflectionMethod', $reflectionMethod);
$a = new stdClass();
$a->type = 'suggest';
$reflectionMethod->invokeArgs($dynaform, [&$a]);
$this->assertInstanceOf('ReflectionMethod', $reflectionMethod);
}
}
// Dummy function used for the coverture

View File

@@ -0,0 +1,260 @@
<?php
namespace Tests\unit\workflow\engine\classes\PmFunctions;
use Faker\Factory;
use Tests\TestCase;
/**
* Test the PMFTotalCalculation() function
*
* @link https://wiki.processmaker.com/3.1/ProcessMaker_Functions#executeQuery.28.29
*/
class PMFTotalCalculationTest extends TestCase
{
/**
* This tests if the "PMFTotalCalculation" execute correctly the sum
* @test
*/
public function it_must_return_the_sum_of_the_method()
{
$grid = [
'1' => [
"field1" => "Value 1",
"field2" => 2
],
'2' => [
"field1" => "Value 2",
"field2" => 5
],
'3' => [
"field1" => "Value 3",
"field2" => 3
]
];
$field = "field2";
$this->assertEquals(10, PMFTotalCalculation($grid, $field, 'sum'));
}
/**
* This tests if the "PMFTotalCalculation" execute correctly the average
* @test
*/
public function it_must_return_the_average_of_the_method()
{
$grid = [
'1' => [
"field1" => "Value 1",
"field2" => 2
],
'2' => [
"field1" => "Value 2",
"field2" => 5
],
'3' => [
"field1" => "Value 3",
"field2" => 3
]
];
$this->assertEquals(3.3333333333, PMFTotalCalculation($grid, 'field2', 'average'));
}
/**
* This tests if the "PMFTotalCalculation" execute correctly the median
* @test
*/
public function it_must_return_the_median_of_the_method()
{
$grid1 = [
'1' => [
"field1" => "Value 1",
"field2" => 2
],
'2' => [
"field1" => "Value 2",
"field2" => 5
],
'3' => [
"field1" => "Value 3",
"field2" => 3
]
];
$grid2 = [
'1' => [
"field1" => "Value 1",
"field2" => 2
],
'2' => [
"field1" => "Value 2",
"field2" => 5
],
'3' => [
"field1" => "Value 3",
"field2" => 3
],
'4' => [
"field1" => "Value 3",
"field2" => 8
]
];
$this->assertEquals(3, PMFTotalCalculation($grid1, 'field2', 'median'));
$this->assertEquals(4, PMFTotalCalculation($grid2, 'field2', 'median'));
}
/**
* This tests if the "PMFTotalCalculation" execute correctly the minimum
* @test
*/
public function it_must_return_the_minimum_of_the_method()
{
$grid = [
'1' => [
"field1" => "Value 1",
"field2" => 5
],
'2' => [
"field1" => "Value 2",
"field2" => 2
],
'3' => [
"field1" => "Value 3",
"field2" => 3
]
];
$this->assertEquals(2, PMFTotalCalculation($grid, 'field2', 'minimum'));
}
/**
* This tests if the "PMFTotalCalculation" execute correctly the maximum
* @test
*/
public function it_must_return_the_maximum_of_the_method()
{
$grid = [
'1' => [
"field1" => "Value 1",
"field2" => 2
],
'2' => [
"field1" => "Value 2",
"field2" => 5
],
'3' => [
"field1" => "Value 3",
"field2" => 3
]
];
$this->assertEquals(5, PMFTotalCalculation($grid, 'field2', 'maximum'));
}
/**
* This tests if the "PMFTotalCalculation" execute correctly the standardDeviation
* @test
*/
public function it_must_return_the_standardDeviation_of_the_method()
{
$grid = [
'1' => [
"field1" => "Value 1",
"field2" => 25
],
'2' => [
"field1" => "Value 2",
"field2" => 40
],
'3' => [
"field1" => "Value 3",
"field2" => 10
]
];
$this->assertEquals(12.2474487139, PMFTotalCalculation($grid, 'field2', 'standardDeviation'));
}
/**
* This tests if the "PMFTotalCalculation" execute correctly the variance
* @test
*/
public function it_must_return_the_variance_of_the_method()
{
$grid = [
'1' => [
"field1" => "Value 1",
"field2" => 25
],
'2' => [
"field1" => "Value 2",
"field2" => 40
],
'3' => [
"field1" => "Value 3",
"field2" => 10
]
];
$this->assertEquals(150, PMFTotalCalculation($grid, 'field2', 'variance'));
}
/**
* This tests if the "PMFTotalCalculation" execute correctly the percentile
* @test
*/
public function it_must_return_the_percentile_of_the_method()
{
$grid = [
'1' => [
"field1" => "Value 1",
"field2" => 10
],
'2' => [
"field1" => "Value 2",
"field2" => 35
],
'3' => [
"field1" => "Value 3",
"field2" => 5
]
];
$expectedArray = [
"1" => 20,
"2" => 70,
"3" => 10,
];
$this->assertEquals($expectedArray, PMFTotalCalculation($grid, 'field2', 'percentile'));
}
/**
* This tests if the "PMFTotalCalculation" execute correctly the count
* @test
*/
public function it_must_return_the_count_of_the_method()
{
$grid = [
'1' => [
"field1" => "Value 1",
"field2" => 25
],
'2' => [
"field1" => "Value 2",
"field2" => 40
],
'3' => [
"field1" => "Value 3",
"field2" => 10
]
];
$this->assertEquals(3, PMFTotalCalculation($grid, 'field2', 'count'));
}
/**
* This tests if the "PMFTotalCalculation" execute correctly the count distinct
* @test
*/
public function it_must_return_the_count_distinct_of_the_method()
{
$grid = [
'1' => [
"field1" => "Value 1",
"field2" => 20
],
'2' => [
"field1" => "Value 2",
"field2" => 20
],
'3' => [
"field1" => "Value 3",
"field2" => 10
]
];
$this->assertEquals(2, PMFTotalCalculation($grid, 'field2', 'countDistinct'));
}
}

View File

@@ -188,4 +188,43 @@ class VariableTest extends TestCase
$this->assertArrayHasKey('var_accepted_values', $res, "The result does not contains 'var_accepted_values' as key");
$this->assertArrayHasKey('inp_doc_uid', $res, "The result does not contains 'inp_doc_uid' as key");
}
/**
* Test it return the variables by type related to the PRO_UID
*
* @covers \ProcessMaker\BusinessModel\Variable::getVariablesByType()
* @test
*/
public function it_list_variables_by_type_related_a_process()
{
$process = factory(Process::class)->create();
$varType = 'integer';
$varTypeId = 2;
for ($x = 1; $x <= 5; $x++) {
$processVar = factory(ProcessVariables::class)->states('foreign_keys')->create([
'PRO_ID' => $process->PRO_ID,
'PRJ_UID' => $process->PRO_UID,
'VAR_FIELD_TYPE' => $varType,
'VAR_FIELD_TYPE_ID' => $varTypeId,
'VAR_NAME' => 'varTestName' . $x,
]);
}
$variable = new Variable();
// Get all results
$res = $variable->getVariablesByType($process->PRO_UID, 2);
$this->assertEquals(5, count($res));
$res = head($res);
$this->assertArrayHasKey('value', $res, "The result does not contains 'value' as key");
// Get a specific start and limit
$res = $variable->getVariablesByType($process->PRO_UID, 2, 0, 2);
$this->assertNotEmpty($res);
$this->assertEquals(2, count($res));
// Get a specific search
$res = $variable->getVariablesByType($process->PRO_UID, 2, 0, 4, 'varTest');
$this->assertNotEmpty($res);
$this->assertEquals(4, count($res));
// When the search does not match
$res = $variable->getVariablesByType($process->PRO_UID, 2, null, null, 'other');
$this->assertEmpty($res);
}
}

View File

@@ -70,4 +70,41 @@ class ProcessVariablesTest extends TestCase
$result = ProcessVariables::getVariables($process->PRO_ID);
$this->assertNotEmpty($result);
}
/**
* Test it return the variables by type related to the PRO_ID
*
* @covers \ProcessMaker\Model\ProcessVariables::getVariablesByType()
* @test
*/
public function it_list_variables_type_by_process()
{
$process = factory(Process::class)->create();
$varType = 'integer';
$varTypeId = 2;
for ($x = 1; $x <= 5; $x++) {
$processVar = factory(ProcessVariables::class)->states('foreign_keys')->create([
'PRO_ID' => $process->PRO_ID,
'PRJ_UID' => $process->PRO_UID,
'VAR_FIELD_TYPE' => $varType,
'VAR_FIELD_TYPE_ID' => $varTypeId,
'VAR_NAME' => 'varTestName' . $x,
]);
}
$res = ProcessVariables::getVariablesByType($processVar->PRO_ID, 2, null, null, null);
$this->assertNotEmpty($res);
$this->assertEquals(5, count($res));
// Get a specific start and limit
$res = ProcessVariables::getVariablesByType($process->PRO_ID, 2, 0, 2);
$this->assertNotEmpty($res);
$this->assertEquals(2, count($res));
// Get a specific search
$res = ProcessVariables::getVariablesByType($process->PRO_ID, 2, 0, 4, 'varTest');
$this->assertNotEmpty($res);
$this->assertEquals(4, count($res));
// When the search does not match
$res = ProcessVariables::getVariablesByType($process->PRO_ID, 2, null, null, 'other');
$this->assertEmpty($res);
}
}

View File

@@ -1111,12 +1111,6 @@ class Phing {
ini_set('default_charset', 'iso-8859-1');
ini_set('register_globals', 'off');
ini_set('allow_call_time_pass_reference', 'on');
// should return memory limit in MB
$mem_limit = (int) ini_get('memory_limit');
if ($mem_limit < 32) {
ini_set('memory_limit', '32M'); // nore: this may need to be higher for many projects
}
}
/**

View File

@@ -36,7 +36,6 @@ class PmBootstrap extends Bootstrap
ini_set('error_reporting', $e_all);
ini_set('short_open_tag', 'On');
ini_set('default_charset', "UTF-8");
ini_set('memory_limit', $this->pmConfig['memory_limit']);
ini_set('soap.wsdl_cache_enabled', $this->pmConfig['wsdl_cache']);
ini_set('date.timezone', (isset($_SESSION['__SYSTEM_UTC_TIME_ZONE__']) && $_SESSION['__SYSTEM_UTC_TIME_ZONE__'])? 'UTC' : $this->pmConfig['time_zone']); //Set Time Zone

View File

@@ -101,7 +101,6 @@ try {
ini_set('error_reporting', $e_all);
ini_set('short_open_tag', 'On');
ini_set('default_charset', 'UTF-8');
ini_set('memory_limit', $arraySystemConfiguration['memory_limit']);
ini_set('soap.wsdl_cache_enabled', $arraySystemConfiguration['wsdl_cache']);
ini_set('date.timezone', $systemUtcTimeZone ? 'UTC' : $arraySystemConfiguration['time_zone']);

View File

@@ -95,7 +95,6 @@ try {
restore_error_handler();
// Do not change any of these settings directly, use env.ini instead
ini_set('memory_limit', $arraySystemConfiguration['memory_limit']);
ini_set('display_errors', $arraySystemConfiguration['debug']);
ini_set('error_reporting', $e_all);
ini_set('short_open_tag', 'On');

View File

@@ -87,8 +87,6 @@ if(count ($argv) > 3) {
$debug = 1;
ini_set ('display_errors', 1);
//error_reporting (E_ALL);
ini_set ('memory_limit', '256M'); // set enough memory for the script
$e_all = defined( 'E_DEPRECATED' ) ? E_ALL & ~ E_DEPRECATED : E_ALL;
$e_all = defined( 'E_STRICT' ) ? $e_all & ~ E_STRICT : $e_all;

View File

@@ -52,8 +52,6 @@ $debug = 1;//enable o disable notice, this mechanism is inherited from '/process
ini_set ('display_errors', 1);
ini_set ('memory_limit', '256M'); // set enough memory for the script
$e_all = defined( 'E_DEPRECATED' ) ? E_ALL & ~ E_DEPRECATED : E_ALL;
$e_all = defined( 'E_STRICT' ) ? $e_all & ~ E_STRICT : $e_all;
$e_all = $debug ? $e_all : $e_all & ~ E_NOTICE;

View File

@@ -29,6 +29,7 @@ class PmDynaform
public $lang = SYS_LANG;
public $translations = null;
public $onPropertyRead = "onPropertyReadFormInstance";
public $onAfterPropertyRead = "onAfterPropertyReadFormInstance";
public $pathRTLCss = '';
public $record = null;
public $records = null;
@@ -545,6 +546,7 @@ class PmDynaform
if (isset($this->fields["APP_DATA"][$json->name . "_label"])) {
$json->data->label = $this->fields["APP_DATA"][$json->name . "_label"];
}
$this->setDependentOptionsForDatetime($json, $this->fields);
}
if ($key === "type" && ($value === "file") && isset($this->fields["APP_DATA"]["APPLICATION"])) {
$oCriteriaAppDocument = new Criteria("workflow");
@@ -771,6 +773,11 @@ class PmDynaform
}
}
}
//read event after
$fn = $this->onAfterPropertyRead;
if (is_callable($fn) || function_exists($fn)) {
$fn($json, $key, $value);
}
}
}
}
@@ -2489,4 +2496,38 @@ class PmDynaform
$json->dataSchema[$key] = $columnsData;
}
}
/**
* Sets the dependentOptions property for datetime control, if it contains dependent fields.
* @param stdClass $json
* @param array $fields
* @return void
*/
private function setDependentOptionsForDatetime(stdClass &$json, array $fields = []): void
{
if (!isset($json->type)) {
return;
}
if ($json->type !== 'datetime') {
return;
}
$json->dependentOptions = '';
$backup = $this->onAfterPropertyRead;
$properties = [
'defaultDate' => $json->defaultDate,
'minDate' => $json->minDate,
'maxDate' => $json->maxDate
];
$this->onAfterPropertyRead = function(stdClass &$json, $key, $value) use($backup, $properties) {
if (isset($json->type) && $json->type === 'datetime' && $key === "dependentOptions") {
$json->dependentOptions = new stdClass();
foreach ($properties as $property => $value) {
if (is_string($value) && in_array(substr($value, 0, 2), self::$prefixs)) {
$json->dependentOptions->{$property} = $value;
}
}
$this->onAfterPropertyRead = $backup;
}
};
}
}

View File

@@ -459,6 +459,123 @@ function evaluateFunction($aGrid, $sExpresion)
return $aGrid;
}
/**
*
* @method
*
* Executes operations in the grid fields, such as sum, average, median, minimum, maximun,
* stantard deviation, variance, percentile, count, count distinct
*
* @name PMFTotalCalculation
* @label PMFTotalCalculation Function
* @link http://wiki.processmaker.com/index.php/ProcessMaker_Functions#PMFTotalCalculation.28.29
* @param array | $grid | Grid | The input grid.
* @param string (32) | $field | Name of field | The name of the field.
* @param string (32) | $function | Operation.
* @return int|float|array | $result | Result | Result according of the function
*
*/
function PMFTotalCalculation($grid, $field, $function)
{
$systemConfiguration = Bootstrap::getSystemConfiguration();
$floatPointNumber = $systemConfiguration['PMFTOTALCALCULATION_FLOATING_POINT_NUMBER'];
$function = strtolower($function);
$totalRows = count($grid);
$result = 0;
$sum = 0;
switch ($function) {
case "sum":
for ($i = 1; $i <= $totalRows; $i += 1) {
$result += $grid[$i][$field];
}
break;
case "average":
for ($i = 1; $i <= $totalRows; $i += 1) {
$result += $grid[$i][$field];
}
$result = $result / $totalRows;
break;
case "median":
$arrayAux = [];
for ($i = 1; $i <= $totalRows; $i += 1) {
$arrayAux[] = $grid[$i][$field];
}
sort($arrayAux);
$term = ($totalRows + 1) / 2;
if ($totalRows % 2 === 0) {
$term = floor($term);
$result = ($arrayAux[$term - 1] + $arrayAux[$term]) / 2;
} else {
$result = $arrayAux[$term - 1];
}
break;
case "minimum":
$result = $grid[1][$field];
for ($i = 2; $i <= $totalRows; $i += 1) {
if ($grid[$i][$field] < $result) {
$result = $grid[$i][$field];
}
}
break;
case "maximum":
$result = $grid[1][$field];
for ($i = 2; $i <= $totalRows; $i += 1) {
if ($grid[$i][$field] > $result) {
$result = $grid[$i][$field];
}
}
break;
case "standarddeviation":
$mean = 0;
for ($i = 1; $i <= $totalRows; $i += 1) {
$mean += $grid[$i][$field];
}
$mean = $mean / $totalRows;
for ($i = 1; $i <= $totalRows; $i += 1) {
$result += pow($grid[$i][$field] - $mean, 2);
}
$result = sqrt($result / $totalRows);
break;
case "variance":
$mean = 0;
for ($i = 1; $i <= $totalRows; $i += 1) {
$mean += $grid[$i][$field];
}
$mean = $mean / $totalRows;
for ($i = 1; $i <= $totalRows; $i += 1) {
$result += pow($grid[$i][$field] - $mean, 2);
}
$result = $result / $totalRows;
break;
case "percentile":
$result = [];
$arrayAux = [];
for ($i = 1; $i <= $totalRows; $i += 1) {
$sum += $grid[$i][$field];
$arrayAux[$i] = $grid[$i][$field];
}
for ($i = 1; $i <= count($arrayAux); $i += 1) {
$result[$i] = round(($arrayAux[$i] * 100) / $sum, $floatPointNumber);
}
break;
case "count":
$result = $totalRows;
break;
case "countdistinct":
$arrayAux = [];
for ($i = 1; $i <= $totalRows; $i += 1) {
$arrayAux[] = $grid[$i][$field];
}
$result = count(array_count_values($arrayAux));
break;
}
if ($function !== "percentile") {
return round($result, $floatPointNumber);
}
return $result;
}
/**
* Web Services Functions *
*/
@@ -960,9 +1077,8 @@ function PMFSendMessage(
$delIndex = 0,
$config = []
) {
ini_set ( "pcre.backtrack_limit", 1000000 );
ini_set ( 'memory_limit', '-1' );
@set_time_limit ( 100000 );
ini_set("pcre.backtrack_limit", 1000000);
@set_time_limit(100000);
global $oPMScript;

View File

@@ -1181,7 +1181,6 @@ class InstallerModule extends Controller
{
$filter = new InputFilter();
ini_set('max_execution_time', '0');
ini_set('memory_limit', '256M');
$serv = 'http://';
if (isset($_SERVER['HTTPS']) && !empty(trim($_SERVER['HTTPS']))) {

View File

@@ -65,11 +65,6 @@ class adminProxy extends HttpProxyController
$updatedConf['expiration_year'] = $httpData->expiration_year;
}
$httpData->memory_limit .= 'M';
if ($sysConf['memory_limit'] != $httpData->memory_limit) {
$updatedConf['memory_limit'] = $httpData->memory_limit;
}
if ($sysConf['proxy_host'] != $httpData->proxy_host) {
$updatedConf['proxy_host'] = $httpData->proxy_host;
}
@@ -126,7 +121,7 @@ class adminProxy extends HttpProxyController
$msg = ", Host -> " . $httpData->proxy_host . ", Port -> " . $httpData->proxy_port . ", User -> " . $httpData->proxy_user;
}
G::auditLog("UploadSystemSettings", "Time Zone -> " . $httpData->time_zone . ", Memory Limit -> " . $httpData->memory_limit . ", Cookie lifetime -> " . $httpData->max_life_time . ", Default Skin -> " . $httpData->default_skin . ", Default Language -> " . $httpData->default_lang . $msg);
G::auditLog("UploadSystemSettings", "Time Zone -> " . $httpData->time_zone . ", Cookie lifetime -> " . $httpData->max_life_time . ", Default Skin -> " . $httpData->default_skin . ", Default Language -> " . $httpData->default_lang . $msg);
}
public function uxUserUpdate($httpData)
@@ -1584,12 +1579,6 @@ class adminProxy extends HttpProxyController
*/
public static function validateDataSystemConf($httpData, $envFile)
{
if (!((is_numeric($httpData->memory_limit)) && ((int)$httpData->memory_limit == $httpData->memory_limit) &&
((int)$httpData->memory_limit >= -1))
) {
throw new Exception(G::LoadTranslation('ID_MEMORY_LIMIT_VALIDATE'));
}
if (!((is_numeric($httpData->max_life_time)) && ((int)$httpData->max_life_time == $httpData->max_life_time) &&
((int)$httpData->max_life_time > 0))
) {

View File

@@ -1178,10 +1178,12 @@ class DynaForm
}
foreach ($oldColumns as $oldColumn) {
if (strtolower(AdditionalTables::getPHPName($column->id)) === strtolower(AdditionalTables::getPHPName($oldColumn->id))) {
if (strtolower(AdditionalTables::getPHPName($column->var_name)) === strtolower(AdditionalTables::getPHPName($oldColumn->var_name))) {
$identicals[] = "'" . $column->id . "' - '" . $oldColumn->id . "'";
}
}
}
}
if (count($invalids) > 0) {
throw (new Exception(G::LoadTranslation("ID_GRID_VARIABLE_NAME_ERROR", [implode(', ', $invalids)])));

View File

@@ -26,6 +26,16 @@ class Variable
'object' => 10
];
/**
* Get the variables types accepted
*
* @return array
*/
public function getVariableTypes()
{
return $this->variableTypes;
}
/**
* Create Variable for a Process
*
@@ -355,6 +365,33 @@ class Variable
return $arrayVariables;
}
/**
* Get data of Variables related to the specific type
*
* @param string $processUid Unique id of Process
* @param int $typeVarId
* @param int $start
* @param int $limit
* @param string $search
* @param string $prefix
*
* @return array, return an array with varaibles filter by type
*/
public function getVariablesByType($processUid, $typeVarId = 0, $start = null, $limit = null, $search = null, $prefix = null)
{
//Verify data
$proId = Validator::proUid($processUid, '$prj_uid');
$variables = ProcessVariables::getVariablesByType($proId, $typeVarId, $start, $limit, $search);
$arrayVariables = [];
foreach ($variables as $var) {
$arrayVariables[] = [
'value' => is_null($prefix) ? $var['VAR_NAME'] : $prefix . $var['VAR_NAME'],
];
}
return $arrayVariables;
}
/**
* Verify field definition
*

View File

@@ -376,9 +376,7 @@ class Installer
}
//ACTIVE ENTERPRISE
ini_set('max_execution_time', '0');
ini_set('memory_limit', '256M');
$serv = 'http://';
if (isset($_SERVER['HTTPS']) && trim($_SERVER['HTTPS']) != '') {

View File

@@ -36,7 +36,6 @@ class System
'debug_time' => 0,
'debug_calendar' => 0,
'wsdl_cache' => 1,
'memory_limit' => "256M",
'time_zone' => 'America/New_York',
'expiration_year' => '1',
'memcached' => 0,
@@ -79,6 +78,7 @@ class System
'highlight_home_folder_refresh_time' => 10,
'highlight_home_folder_scope' => 'unassigned', // For now only this list is supported
'disable_advanced_search_case_title_fulltext' => 0,
'PMFTOTALCALCULATION_FLOATING_POINT_NUMBER' => 10,
'report_table_batch_regeneration' => 1000
];

View File

@@ -72,8 +72,21 @@ class ProcessVariables extends Model
*/
public function scopeProcessId($query, int $proId)
{
return $query->where('PRO_ID', $proId);
return $query->where('PROCESS_VARIABLES.PRO_ID', $proId);
}
/**
* Scope a query to filter a specific type for variable
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param int $typeId
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeTypeId($query, int $typeId)
{
return $query->where('VAR_FIELD_TYPE_ID', $typeId);
}
/**
* Return the variables list
*
@@ -96,4 +109,46 @@ class ProcessVariables extends Model
return $variablesList;
}
/**
* Return the variables list
*
* @param int $proId
* @param int $typeId
* @param int $start
* @param int $limit
* @param string $search
*
* @return array
*/
public static function getVariablesByType(int $proId, int $typeId = 0, $start = null, $limit = null, $search = null)
{
$query = ProcessVariables::query()->select();
$query->leftJoin('DB_SOURCE', function ($join) {
$join->on('DB_SOURCE.PRO_ID', '=', 'PROCESS_VARIABLES.PRO_ID');
});
$query->processId($proId);
// Check if we need to filter the type of variables
if ($typeId > 0) {
$query->typeId($typeId);
}
// search a specific variable name
if (!empty($search)) {
$query->where('VAR_NAME', 'LIKE', "${search}%");
}
// order by varNane
$query->orderBy('VAR_NAME', 'ASC');
// Check if we need to add a pagination
if(!is_null($start) && !is_null($limit)) {
$query->offset($start)->limit($limit);
}
// Get records
$results = $query->get();
$variablesList = [];
$results->each(function ($item, $key) use (&$variablesList) {
$variablesList[] = $item->toArray();
});
return $variablesList;
}
}

View File

@@ -1,8 +1,12 @@
<?php
namespace ProcessMaker\Services\Api\Project;
use \ProcessMaker\Services\Api;
use \Luracast\Restler\RestException;
use Exception;
use G;
use Luracast\Restler\RestException;
use ProcessMaker\BusinessModel\Variable as BmVariable;
use ProcessMaker\Services\Api;
/**
* Project\Variable Api Controller
*
@@ -28,6 +32,43 @@ class Variable extends Api
}
}
/**
* Get variables by type
*
* @url GET /:prj_uid/process-variables/:typeVariable/paged
*
* @param string $prj_uid {@min 32}{@max 32}
* @param string $typeVariable {@from path}
* @param int $start {@from path}
* @param int $limit {@from path}
* @param string $search {@from path}
*/
public function doGetVariablesByType($prj_uid, $typeVariable, $start = null, $limit = null, $search = null)
{
try {
$variable = new BmVariable();
$typesAccepted = $variable::$varTypesValues;
if (!empty($typesAccepted[$typeVariable])) {
$typeVatId = $typesAccepted[$typeVariable];
} else {
throw new Exception(G::LoadTranslation("ID_INVALID_VALUE_ONLY_ACCEPTS_VALUES", ['$typeVariable', implode(',', $variable->getVariableTypes())]));
}
// Review if the word has the prefix
$count = preg_match_all('/\@(?:([\@\%\#\?\$\=\&Qq\!])|([a-zA-Z\_][\w\-\>\:]*)\(((?:[^\\\\\)]*(?:[\\\\][\w\W])?)*)\))((?:\s*\[[\'"]?\w+[\'"]?\])+|\-\>([a-zA-Z\_]\w*))?/', $search, $match, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE);
// Check if the search has some prefix
$prefix = '';
if ($count) {
$prefix = substr($search,0,2);
$search = substr($search,2);
}
$response = $variable->getVariablesByType($prj_uid, $typeVatId, $start, $limit, $search, $prefix);
return $response;
} catch (Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
/**
* @url GET /:prj_uid/process-variable/:var_uid
*

View File

@@ -96,21 +96,6 @@ Ext.onReady(function(){
items: [
cmbTimeZone,
{
xtype: 'numberfield',
id: 'memory_limit',
name: 'memory_limit',
fieldLabel: _('ID_MEMORY_LIMIT'),
allowBlank: false,
allowDecimals: false,
minValue: -1,
autoCreate: {tag: "input", type: "text", autocomplete: "off", maxlength: 15},
value: sysConf.memory_limit,
listeners: {
change: function () {
changeSettings();
}
}
}, {
xtype: 'numberfield',
id: 'max_life_time',
name: 'max_life_time',

View File

@@ -52,7 +52,6 @@ $config = PmSystem::getSystemConfiguration();
$filter = new InputFilter();
$config['display_errors'] = $filter->validateInput($config['display_errors']);
$config['error_reporting'] = $filter->validateInput($config['error_reporting']);
$config['memory_limit'] = $filter->validateInput($config['memory_limit']);
$config['wsdl_cache'] = $filter->validateInput($config['wsdl_cache'], 'int');
$config['time_zone'] = $filter->validateInput($config['time_zone']);
// Do not change any of these settings directly, use env.ini instead
@@ -60,7 +59,6 @@ ini_set('display_errors', $filter->validateInput($config['display_errors']));
ini_set('error_reporting', $filter->validateInput($config['error_reporting']));
ini_set('short_open_tag', 'On');
ini_set('default_charset', "UTF-8");
ini_set('memory_limit', $filter->validateInput($config['memory_limit']));
ini_set('soap.wsdl_cache_enabled', $config['wsdl_cache']);
ini_set('date.timezone',
(isset($_SESSION['__SYSTEM_UTC_TIME_ZONE__']) && $_SESSION['__SYSTEM_UTC_TIME_ZONE__']) ? 'UTC' : $config['time_zone']); //Set Time Zone

View File

@@ -315,7 +315,6 @@ ini_set('display_errors', $config['display_errors']);
ini_set('error_reporting', $config['error_reporting']);
ini_set('short_open_tag', 'On');
ini_set('default_charset', "UTF-8");
ini_set('memory_limit', $config['memory_limit']);
ini_set('soap.wsdl_cache_enabled', $config['wsdl_cache']);
ini_set('date.timezone',
(isset($_SESSION['__SYSTEM_UTC_TIME_ZONE__']) && $_SESSION['__SYSTEM_UTC_TIME_ZONE__']) ? 'UTC' : $config['time_zone']); //Set Time Zone
@@ -572,7 +571,6 @@ ini_set('display_errors', $config['display_errors']);
ini_set('error_reporting', $config['error_reporting']);
ini_set('short_open_tag', 'On');
ini_set('default_charset', "UTF-8");
ini_set('memory_limit', $config['memory_limit']);
ini_set('soap.wsdl_cache_enabled', $config['wsdl_cache']);
ini_set('date.timezone', TIME_ZONE); //Set Time Zone