Merged in bugfix/PMC-985 (pull request #6988)
PMC-985 Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
20
database/factories/BpmnProjectFactory.php
Normal file
20
database/factories/BpmnProjectFactory.php
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Faker\Generator as Faker;
|
||||||
|
|
||||||
|
$factory->define(\ProcessMaker\Model\BpmnProject::class, function (Faker $faker) {
|
||||||
|
return [
|
||||||
|
'PRJ_UID' => G::generateUniqueID(),
|
||||||
|
'PRJ_NAME' => '',
|
||||||
|
'PRJ_DESCRIPTION' => $faker->text,
|
||||||
|
'PRJ_EXPRESION_LANGUAGE' => '',
|
||||||
|
'PRJ_TYPE_LANGUAGE' => '',
|
||||||
|
'PRJ_EXPORTER' => '',
|
||||||
|
'PRJ_EXPORTER_VERSION' => '',
|
||||||
|
'PRJ_CREATE_DATE' => new \Carbon\Carbon(2030, 1, 1),
|
||||||
|
'PRJ_UPDATE_DATE' => new \Carbon\Carbon(2030, 1, 1),
|
||||||
|
'PRJ_AUTHOR' => '',
|
||||||
|
'PRJ_AUTHOR_VERSION' => '',
|
||||||
|
'PRJ_ORIGINAL_SOURCE' => '',
|
||||||
|
];
|
||||||
|
});
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Faker\Generator as Faker;
|
use Faker\Generator as Faker;
|
||||||
|
|
||||||
$factory->define(\ProcessMaker\Model\User::class, function(Faker $faker) {
|
$factory->define(\ProcessMaker\Model\User::class, function (Faker $faker) {
|
||||||
return [
|
return [
|
||||||
'USR_UID' => G::generateUniqueID(),
|
'USR_UID' => G::generateUniqueID(),
|
||||||
'USR_USERNAME' => $faker->unique()->userName,
|
'USR_USERNAME' => $faker->unique()->userName,
|
||||||
@@ -9,11 +10,12 @@ $factory->define(\ProcessMaker\Model\User::class, function(Faker $faker) {
|
|||||||
'USR_FIRSTNAME' => $faker->firstName,
|
'USR_FIRSTNAME' => $faker->firstName,
|
||||||
'USR_LASTNAME' => $faker->lastName,
|
'USR_LASTNAME' => $faker->lastName,
|
||||||
'USR_EMAIL' => $faker->unique()->email,
|
'USR_EMAIL' => $faker->unique()->email,
|
||||||
'USR_DUE_DATE' => new \Carbon\Carbon(2030,1,1),
|
'USR_DUE_DATE' => new \Carbon\Carbon(2030, 1, 1),
|
||||||
'USR_STATUS' => 'ACTIVE',
|
'USR_STATUS' => 'ACTIVE',
|
||||||
'USR_ROLE' => $faker->randomElement(['PROCESSMAKER_ADMIN', 'PROCESSMAKER_OPERATOR']),
|
'USR_ROLE' => $faker->randomElement(['PROCESSMAKER_ADMIN', 'PROCESSMAKER_OPERATOR']),
|
||||||
'USR_UX' => 'NORMAL',
|
'USR_UX' => 'NORMAL',
|
||||||
'USR_TIME_ZONE' => 'America/Anguilla',
|
'USR_TIME_ZONE' => 'America/Anguilla',
|
||||||
'USR_DEFAULT_LANG' => 'en',
|
'USR_DEFAULT_LANG' => 'en',
|
||||||
|
'USR_LAST_LOGIN' => new \Carbon\Carbon(2019, 1, 1)
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
4
tests/bootstrap.php
Normal file → Executable file
4
tests/bootstrap.php
Normal file → Executable file
@@ -35,6 +35,10 @@ define('PMTABLE_KEY', 'pmtable');
|
|||||||
define('PATH_WORKFLOW_MYSQL_DATA', PATH_TRUNK . '/workflow/engine/data/mysql/');
|
define('PATH_WORKFLOW_MYSQL_DATA', PATH_TRUNK . '/workflow/engine/data/mysql/');
|
||||||
define('PATH_RBAC_MYSQL_DATA', PATH_TRUNK . '/rbac/engine/data/mysql/');
|
define('PATH_RBAC_MYSQL_DATA', PATH_TRUNK . '/rbac/engine/data/mysql/');
|
||||||
define('PATH_LANGUAGECONT', PATH_DATA . '/META-INF/');
|
define('PATH_LANGUAGECONT', PATH_DATA . '/META-INF/');
|
||||||
|
define('PM_NEW_PROCESS_SAVE', 1006);
|
||||||
|
define('PATH_DATA_SITE', PATH_DATA . 'sites/' . SYS_SYS . '/');
|
||||||
|
define("PATH_DATA_MAILTEMPLATES", PATH_DATA_SITE . "mailTemplates/");
|
||||||
|
define('PATH_DATA_PUBLIC', PATH_DATA_SITE . 'public/');
|
||||||
define('DB_ADAPTER', 'mysql');
|
define('DB_ADAPTER', 'mysql');
|
||||||
define('PATH_RBAC_HOME', PATH_TRUNK . '/rbac/');
|
define('PATH_RBAC_HOME', PATH_TRUNK . '/rbac/');
|
||||||
define('PATH_RBAC', PATH_RBAC_HOME . 'engine/classes/');
|
define('PATH_RBAC', PATH_RBAC_HOME . 'engine/classes/');
|
||||||
|
|||||||
@@ -0,0 +1,538 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\unit\workflow\engine\src\ProcessMaker\Importer;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
|
use ProcessMaker\Importer\Importer;
|
||||||
|
use ProcessMaker\Model\BpmnProject;
|
||||||
|
use ProcessMaker\Model\Process;
|
||||||
|
use ReflectionClass;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class ImporterTest extends TestCase
|
||||||
|
{
|
||||||
|
use DatabaseTransactions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Declared to avoid the incompatibility exception
|
||||||
|
*/
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets protected property on an object using reflection
|
||||||
|
*
|
||||||
|
* @param object $object
|
||||||
|
* @param string $property
|
||||||
|
* @param array $value
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
private function setProtectedProperty($object, $property, $value)
|
||||||
|
{
|
||||||
|
$reflection = new ReflectionClass($object);
|
||||||
|
$reflection_property = $reflection->getProperty($property);
|
||||||
|
$reflection_property->setAccessible(true);
|
||||||
|
$reflection_property->setValue($object, $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the import method when importing a process with a new uid
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_should_test_the_import_method_when_importing_a_process_with_a_new_uid()
|
||||||
|
{
|
||||||
|
// Create the existing process
|
||||||
|
$process = factory(Process::class)->create(
|
||||||
|
['PRO_CREATE_DATE' => '2019-07-10 10:00:00']
|
||||||
|
);
|
||||||
|
|
||||||
|
// Mock the abstract class
|
||||||
|
$importer = $this
|
||||||
|
->getMockBuilder('ProcessMaker\Importer\Importer')
|
||||||
|
->getMockForAbstractClass();
|
||||||
|
|
||||||
|
// create the array that will be passed to the load method
|
||||||
|
$array = [];
|
||||||
|
|
||||||
|
$array["files"]["workflow"] = [];
|
||||||
|
|
||||||
|
$array['tables'] = [
|
||||||
|
'bpmn' =>
|
||||||
|
[
|
||||||
|
'activity' =>
|
||||||
|
[],
|
||||||
|
'artifact' =>
|
||||||
|
[],
|
||||||
|
'bound' =>
|
||||||
|
[],
|
||||||
|
'data' =>
|
||||||
|
[],
|
||||||
|
'diagram' =>
|
||||||
|
[
|
||||||
|
0 =>
|
||||||
|
[
|
||||||
|
'dia_uid' => '9367735405d247f616ed440021337333',
|
||||||
|
'prj_uid' => $process['PRO_UID'],
|
||||||
|
'dia_name' => 'Custom',
|
||||||
|
'dia_is_closable' => '0',
|
||||||
|
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'documentation' =>
|
||||||
|
[],
|
||||||
|
'event' =>
|
||||||
|
[],
|
||||||
|
'extension' =>
|
||||||
|
[],
|
||||||
|
'flow' =>
|
||||||
|
[],
|
||||||
|
'gateway' =>
|
||||||
|
[],
|
||||||
|
'lane' =>
|
||||||
|
[],
|
||||||
|
'laneset' =>
|
||||||
|
[],
|
||||||
|
'participant' =>
|
||||||
|
[],
|
||||||
|
'process' =>
|
||||||
|
[
|
||||||
|
0 =>
|
||||||
|
[
|
||||||
|
'pro_uid' => '3209565785d247f618b6235074913840',
|
||||||
|
'prj_uid' => $process['PRO_UID'],
|
||||||
|
'dia_uid' => '9367735405d247f616ed440021337333',
|
||||||
|
'pro_name' => 'Custom',
|
||||||
|
'pro_type' => 'NONE',
|
||||||
|
'pro_is_executable' => '0',
|
||||||
|
'pro_is_closed' => '0',
|
||||||
|
'pro_is_subprocess' => '0',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'project' =>
|
||||||
|
[
|
||||||
|
0 =>
|
||||||
|
[
|
||||||
|
'prj_uid' => $process['PRO_UID'],
|
||||||
|
'prj_name' => 'Custom',
|
||||||
|
'prj_description' => '',
|
||||||
|
'prj_target_namespace' => '',
|
||||||
|
'prj_expresion_language' => '',
|
||||||
|
'prj_type_language' => '',
|
||||||
|
'prj_exporter' => '',
|
||||||
|
'prj_exporter_version' => '',
|
||||||
|
'prj_create_date' => '2019-07-09 11:49:53',
|
||||||
|
'prj_update_date' => '',
|
||||||
|
'prj_author' => '00000000000000000000000000000001',
|
||||||
|
'prj_author_version' => '',
|
||||||
|
'prj_original_source' => '',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'workflow' =>
|
||||||
|
[
|
||||||
|
'stepSupervisor' =>
|
||||||
|
[],
|
||||||
|
'processUser' =>
|
||||||
|
[],
|
||||||
|
'groupwfs' =>
|
||||||
|
[],
|
||||||
|
'objectPermissions' =>
|
||||||
|
[],
|
||||||
|
'dbconnections' =>
|
||||||
|
[],
|
||||||
|
'filesManager' =>
|
||||||
|
[],
|
||||||
|
'reportTablesDefinition' =>
|
||||||
|
[],
|
||||||
|
'reportTablesFields' =>
|
||||||
|
[],
|
||||||
|
'steptriggers' =>
|
||||||
|
[],
|
||||||
|
'triggers' =>
|
||||||
|
[],
|
||||||
|
'steps' =>
|
||||||
|
[],
|
||||||
|
'outputs' =>
|
||||||
|
[],
|
||||||
|
'inputs' =>
|
||||||
|
[],
|
||||||
|
'dynaforms' =>
|
||||||
|
[],
|
||||||
|
'processVariables' =>
|
||||||
|
[],
|
||||||
|
'tasks' =>
|
||||||
|
[],
|
||||||
|
'taskusers' =>
|
||||||
|
[],
|
||||||
|
'routes' =>
|
||||||
|
[],
|
||||||
|
'lanes' =>
|
||||||
|
[],
|
||||||
|
'gateways' =>
|
||||||
|
[],
|
||||||
|
'subProcess' =>
|
||||||
|
[],
|
||||||
|
'caseTracker' =>
|
||||||
|
[],
|
||||||
|
'caseTrackerObject' =>
|
||||||
|
[],
|
||||||
|
'stage' =>
|
||||||
|
[],
|
||||||
|
'fieldCondition' =>
|
||||||
|
[],
|
||||||
|
'event' =>
|
||||||
|
[],
|
||||||
|
'caseScheduler' =>
|
||||||
|
[],
|
||||||
|
'processCategory' =>
|
||||||
|
[],
|
||||||
|
'taskExtraProperties' =>
|
||||||
|
[],
|
||||||
|
'webEntry' =>
|
||||||
|
[],
|
||||||
|
'webEntryEvent' =>
|
||||||
|
[],
|
||||||
|
'messageType' =>
|
||||||
|
[],
|
||||||
|
'messageTypeVariable' =>
|
||||||
|
[],
|
||||||
|
'messageEventDefinition' =>
|
||||||
|
[],
|
||||||
|
'scriptTask' =>
|
||||||
|
[],
|
||||||
|
'timerEvent' =>
|
||||||
|
[],
|
||||||
|
'emailEvent' =>
|
||||||
|
[],
|
||||||
|
'abeConfiguration' =>
|
||||||
|
[],
|
||||||
|
'process' =>
|
||||||
|
[
|
||||||
|
0 =>
|
||||||
|
[
|
||||||
|
'PRO_UID' => $process['PRO_UID'],
|
||||||
|
'PRO_TITLE' => 'Custom',
|
||||||
|
'PRO_DESCRIPTION' => '',
|
||||||
|
'PRO_PARENT' => $process['PRO_UID'],
|
||||||
|
'PRO_TIME' => '1',
|
||||||
|
'PRO_TIMEUNIT' => 'DAYS',
|
||||||
|
'PRO_STATUS' => 'ACTIVE',
|
||||||
|
'PRO_TYPE_DAY' => '',
|
||||||
|
'PRO_TYPE' => 'NORMAL',
|
||||||
|
'PRO_ASSIGNMENT' => 'FALSE',
|
||||||
|
'PRO_SHOW_MAP' => '0',
|
||||||
|
'PRO_SHOW_MESSAGE' => '0',
|
||||||
|
'PRO_SUBPROCESS' => '0',
|
||||||
|
'PRO_TRI_CREATE' => '',
|
||||||
|
'PRO_TRI_OPEN' => '',
|
||||||
|
'PRO_TRI_DELETED' => '',
|
||||||
|
'PRO_TRI_CANCELED' => '',
|
||||||
|
'PRO_TRI_PAUSED' => '',
|
||||||
|
'PRO_TRI_REASSIGNED' => '',
|
||||||
|
'PRO_TRI_UNPAUSED' => '',
|
||||||
|
'PRO_TYPE_PROCESS' => 'PUBLIC',
|
||||||
|
'PRO_SHOW_DELEGATE' => '0',
|
||||||
|
'PRO_SHOW_DYNAFORM' => '0',
|
||||||
|
'PRO_CATEGORY' => '',
|
||||||
|
'PRO_SUB_CATEGORY' => '',
|
||||||
|
'PRO_INDUSTRY' => '0',
|
||||||
|
'PRO_UPDATE_DATE' => '',
|
||||||
|
'PRO_CREATE_DATE' => '2019-07-09 11:49:53',
|
||||||
|
'PRO_CREATE_USER' => '00000000000000000000000000000001',
|
||||||
|
'PRO_HEIGHT' => '5000',
|
||||||
|
'PRO_WIDTH' => '10000',
|
||||||
|
'PRO_TITLE_X' => '0',
|
||||||
|
'PRO_TITLE_Y' => '0',
|
||||||
|
'PRO_DEBUG' => '0',
|
||||||
|
'PRO_DYNAFORMS' => '',
|
||||||
|
'PRO_DERIVATION_SCREEN_TPL' => '',
|
||||||
|
'PRO_COST' => '0',
|
||||||
|
'PRO_UNIT_COST' => '',
|
||||||
|
'PRO_ITEE' => '1',
|
||||||
|
'PRO_ACTION_DONE' => '',
|
||||||
|
'PRO_CATEGORY_LABEL' => 'No Category',
|
||||||
|
'PRO_BPMN' => '1',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'reportTables' =>
|
||||||
|
[],
|
||||||
|
'reportTablesVars' =>
|
||||||
|
[],
|
||||||
|
],
|
||||||
|
'plugins' =>
|
||||||
|
[],
|
||||||
|
];
|
||||||
|
|
||||||
|
// Mock the load method
|
||||||
|
$importer->method("load")
|
||||||
|
->willReturn($array);
|
||||||
|
|
||||||
|
// Call the import method
|
||||||
|
$res = $importer->import(Importer::IMPORT_OPTION_KEEP_WITHOUT_CHANGING_AND_CREATE_NEW,
|
||||||
|
Importer::GROUP_IMPORT_OPTION_CREATE_NEW, true);
|
||||||
|
|
||||||
|
// Query the new process created
|
||||||
|
$query = Process::query();
|
||||||
|
$query->select()->where('PRO_UID', $res);
|
||||||
|
$result = $query->get()->values()->toArray();
|
||||||
|
|
||||||
|
// Assert the created date is the same as the updated date
|
||||||
|
$this->assertEquals($result[0]['PRO_CREATE_DATE'], $result[0]['PRO_UPDATE_DATE']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the import method when importing a process with a new uid
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_should_test_the_import_method_when_importing_a_process_without_change_the_uid()
|
||||||
|
{
|
||||||
|
// Create the existing process
|
||||||
|
$process = factory(Process::class)->create(
|
||||||
|
['PRO_CREATE_DATE' => '2019-07-10 10:00:00']
|
||||||
|
);
|
||||||
|
factory(BpmnProject::class)->create(
|
||||||
|
['PRJ_UID' => $process['PRO_UID']]
|
||||||
|
);
|
||||||
|
|
||||||
|
// Mock the abstract class
|
||||||
|
$importer = $this
|
||||||
|
->getMockBuilder('ProcessMaker\Importer\Importer')
|
||||||
|
->getMockForAbstractClass();
|
||||||
|
|
||||||
|
// create the array that will be passed to the load method
|
||||||
|
$array = [];
|
||||||
|
|
||||||
|
$array["files"]["workflow"] = [];
|
||||||
|
|
||||||
|
$array['tables'] = [
|
||||||
|
'bpmn' =>
|
||||||
|
[
|
||||||
|
'activity' =>
|
||||||
|
[],
|
||||||
|
'artifact' =>
|
||||||
|
[],
|
||||||
|
'bound' =>
|
||||||
|
[],
|
||||||
|
'data' =>
|
||||||
|
[],
|
||||||
|
'diagram' =>
|
||||||
|
[
|
||||||
|
0 =>
|
||||||
|
[
|
||||||
|
'dia_uid' => '9367735405d247f616ed440021337333',
|
||||||
|
'prj_uid' => $process['PRO_UID'],
|
||||||
|
'dia_name' => 'Custom',
|
||||||
|
'dia_is_closable' => '0',
|
||||||
|
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'documentation' =>
|
||||||
|
[],
|
||||||
|
'event' =>
|
||||||
|
[],
|
||||||
|
'extension' =>
|
||||||
|
[],
|
||||||
|
'flow' =>
|
||||||
|
[],
|
||||||
|
'gateway' =>
|
||||||
|
[],
|
||||||
|
'lane' =>
|
||||||
|
[],
|
||||||
|
'laneset' =>
|
||||||
|
[],
|
||||||
|
'participant' =>
|
||||||
|
[],
|
||||||
|
'process' =>
|
||||||
|
[
|
||||||
|
0 =>
|
||||||
|
[
|
||||||
|
'pro_uid' => '3209565785d247f618b6235074913840',
|
||||||
|
'prj_uid' => $process['PRO_UID'],
|
||||||
|
'dia_uid' => '9367735405d247f616ed440021337333',
|
||||||
|
'pro_name' => 'Custom',
|
||||||
|
'pro_type' => 'NONE',
|
||||||
|
'pro_is_executable' => '0',
|
||||||
|
'pro_is_closed' => '0',
|
||||||
|
'pro_is_subprocess' => '0',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'project' =>
|
||||||
|
[
|
||||||
|
0 =>
|
||||||
|
[
|
||||||
|
'prj_uid' => $process['PRO_UID'],
|
||||||
|
'prj_name' => 'Custom',
|
||||||
|
'prj_description' => '',
|
||||||
|
'prj_target_namespace' => '',
|
||||||
|
'prj_expresion_language' => '',
|
||||||
|
'prj_type_language' => '',
|
||||||
|
'prj_exporter' => '',
|
||||||
|
'prj_exporter_version' => '',
|
||||||
|
'prj_create_date' => '2019-07-09 11:49:53',
|
||||||
|
'prj_update_date' => '',
|
||||||
|
'prj_author' => '00000000000000000000000000000001',
|
||||||
|
'prj_author_version' => '',
|
||||||
|
'prj_original_source' => '',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'workflow' =>
|
||||||
|
[
|
||||||
|
'stepSupervisor' =>
|
||||||
|
[],
|
||||||
|
'processUser' =>
|
||||||
|
[],
|
||||||
|
'groupwfs' =>
|
||||||
|
[],
|
||||||
|
'objectPermissions' =>
|
||||||
|
[],
|
||||||
|
'dbconnections' =>
|
||||||
|
[],
|
||||||
|
'filesManager' =>
|
||||||
|
[],
|
||||||
|
'reportTablesDefinition' =>
|
||||||
|
[],
|
||||||
|
'reportTablesFields' =>
|
||||||
|
[],
|
||||||
|
'steptriggers' =>
|
||||||
|
[],
|
||||||
|
'triggers' =>
|
||||||
|
[],
|
||||||
|
'steps' =>
|
||||||
|
[],
|
||||||
|
'outputs' =>
|
||||||
|
[],
|
||||||
|
'inputs' =>
|
||||||
|
[],
|
||||||
|
'dynaforms' =>
|
||||||
|
[],
|
||||||
|
'processVariables' =>
|
||||||
|
[],
|
||||||
|
'tasks' =>
|
||||||
|
[],
|
||||||
|
'taskusers' =>
|
||||||
|
[],
|
||||||
|
'routes' =>
|
||||||
|
[],
|
||||||
|
'lanes' =>
|
||||||
|
[],
|
||||||
|
'gateways' =>
|
||||||
|
[],
|
||||||
|
'subProcess' =>
|
||||||
|
[],
|
||||||
|
'caseTracker' =>
|
||||||
|
[],
|
||||||
|
'caseTrackerObject' =>
|
||||||
|
[],
|
||||||
|
'stage' =>
|
||||||
|
[],
|
||||||
|
'fieldCondition' =>
|
||||||
|
[],
|
||||||
|
'event' =>
|
||||||
|
[],
|
||||||
|
'caseScheduler' =>
|
||||||
|
[],
|
||||||
|
'processCategory' =>
|
||||||
|
[],
|
||||||
|
'taskExtraProperties' =>
|
||||||
|
[],
|
||||||
|
'webEntry' =>
|
||||||
|
[],
|
||||||
|
'webEntryEvent' =>
|
||||||
|
[],
|
||||||
|
'messageType' =>
|
||||||
|
[],
|
||||||
|
'messageTypeVariable' =>
|
||||||
|
[],
|
||||||
|
'messageEventDefinition' =>
|
||||||
|
[],
|
||||||
|
'scriptTask' =>
|
||||||
|
[],
|
||||||
|
'timerEvent' =>
|
||||||
|
[],
|
||||||
|
'emailEvent' =>
|
||||||
|
[],
|
||||||
|
'abeConfiguration' =>
|
||||||
|
[],
|
||||||
|
'process' =>
|
||||||
|
[
|
||||||
|
0 =>
|
||||||
|
[
|
||||||
|
'PRO_UID' => $process['PRO_UID'],
|
||||||
|
'PRO_TITLE' => 'Custom',
|
||||||
|
'PRO_DESCRIPTION' => '',
|
||||||
|
'PRO_PARENT' => $process['PRO_UID'],
|
||||||
|
'PRO_TIME' => '1',
|
||||||
|
'PRO_TIMEUNIT' => 'DAYS',
|
||||||
|
'PRO_STATUS' => 'ACTIVE',
|
||||||
|
'PRO_TYPE_DAY' => '',
|
||||||
|
'PRO_TYPE' => 'NORMAL',
|
||||||
|
'PRO_ASSIGNMENT' => 'FALSE',
|
||||||
|
'PRO_SHOW_MAP' => '0',
|
||||||
|
'PRO_SHOW_MESSAGE' => '0',
|
||||||
|
'PRO_SUBPROCESS' => '0',
|
||||||
|
'PRO_TRI_CREATE' => '',
|
||||||
|
'PRO_TRI_OPEN' => '',
|
||||||
|
'PRO_TRI_DELETED' => '',
|
||||||
|
'PRO_TRI_CANCELED' => '',
|
||||||
|
'PRO_TRI_PAUSED' => '',
|
||||||
|
'PRO_TRI_REASSIGNED' => '',
|
||||||
|
'PRO_TRI_UNPAUSED' => '',
|
||||||
|
'PRO_TYPE_PROCESS' => 'PUBLIC',
|
||||||
|
'PRO_SHOW_DELEGATE' => '0',
|
||||||
|
'PRO_SHOW_DYNAFORM' => '0',
|
||||||
|
'PRO_CATEGORY' => '',
|
||||||
|
'PRO_SUB_CATEGORY' => '',
|
||||||
|
'PRO_INDUSTRY' => '0',
|
||||||
|
'PRO_UPDATE_DATE' => '',
|
||||||
|
'PRO_CREATE_DATE' => '2019-07-09 11:49:53',
|
||||||
|
'PRO_CREATE_USER' => '00000000000000000000000000000001',
|
||||||
|
'PRO_HEIGHT' => '5000',
|
||||||
|
'PRO_WIDTH' => '10000',
|
||||||
|
'PRO_TITLE_X' => '0',
|
||||||
|
'PRO_TITLE_Y' => '0',
|
||||||
|
'PRO_DEBUG' => '0',
|
||||||
|
'PRO_DYNAFORMS' => '',
|
||||||
|
'PRO_DERIVATION_SCREEN_TPL' => '',
|
||||||
|
'PRO_COST' => '0',
|
||||||
|
'PRO_UNIT_COST' => '',
|
||||||
|
'PRO_ITEE' => '1',
|
||||||
|
'PRO_ACTION_DONE' => '',
|
||||||
|
'PRO_CATEGORY_LABEL' => 'No Category',
|
||||||
|
'PRO_BPMN' => '1',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'reportTables' =>
|
||||||
|
[],
|
||||||
|
'reportTablesVars' =>
|
||||||
|
[],
|
||||||
|
],
|
||||||
|
'plugins' =>
|
||||||
|
[],
|
||||||
|
];
|
||||||
|
|
||||||
|
// Mock the load method
|
||||||
|
$importer->method("load")
|
||||||
|
->willReturn($array);
|
||||||
|
|
||||||
|
// Call the setProtectedProperty method
|
||||||
|
$this->setProtectedProperty($importer, 'metadata', ['uid' => $process['PRO_UID']]);
|
||||||
|
|
||||||
|
// Call the import method
|
||||||
|
$res = $importer->import(Importer::IMPORT_OPTION_OVERWRITE,
|
||||||
|
Importer::GROUP_IMPORT_OPTION_CREATE_NEW, false);
|
||||||
|
|
||||||
|
// Query the new process created
|
||||||
|
$query = Process::query();
|
||||||
|
$query->select()->where('PRO_UID', $res);
|
||||||
|
$result = $query->get()->values()->toArray();
|
||||||
|
|
||||||
|
// Assert the created date is the same as the updated date
|
||||||
|
$this->assertNotEquals($result[0]['PRO_CREATE_DATE'], $result[0]['PRO_UPDATE_DATE']);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\unit\workflow\engine\src\ProcessMaker\Model;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
|
use ProcessMaker\Model\User;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class UserTest extends TestCase
|
||||||
|
{
|
||||||
|
use DatabaseTransactions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the users filters scope with the usr uid filter
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_should_test_the_users_filters_scope_with_usr_uid()
|
||||||
|
{
|
||||||
|
$user = factory(User::class, 4)->create();
|
||||||
|
$filters = ['USR_UID' => $user[0]['USR_UID']];
|
||||||
|
|
||||||
|
$userQuery = User::query()->select();
|
||||||
|
$userQuery->userFilters($filters);
|
||||||
|
$result = $userQuery->get()->values()->toArray();
|
||||||
|
|
||||||
|
// Assert the expected numbers of rows in the result
|
||||||
|
$this->assertCount(1, $result);
|
||||||
|
|
||||||
|
// Assert the filter has been set successful
|
||||||
|
$this->assertEquals($user[0]['USR_UID'], $result[0]['USR_UID']);
|
||||||
|
$this->assertNotEquals($user[1]['USR_UID'], $result[0]['USR_UID']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the users filters scope with the usr id filter
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_should_test_the_users_filters_scope_with_usr_id()
|
||||||
|
{
|
||||||
|
$user = factory(User::class, 4)->create();
|
||||||
|
$filters = ['USR_ID' => $user[0]['USR_ID']];
|
||||||
|
$userQuery = User::query()->select();
|
||||||
|
$userQuery->userFilters($filters);
|
||||||
|
|
||||||
|
$result = $userQuery->get()->values()->toArray();
|
||||||
|
|
||||||
|
// Assert the expected numbers of rows in the result
|
||||||
|
$this->assertCount(1, $result);
|
||||||
|
|
||||||
|
// Assert the filter has been set successful
|
||||||
|
$this->assertEquals($user[0]['USR_ID'], $result[0]['USR_ID']);
|
||||||
|
$this->assertNotEquals($user[1]['USR_ID'], $result[0]['USR_ID']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the exception in the users filters scope
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_should_test_the_exception_in_users_filters_scope()
|
||||||
|
{
|
||||||
|
factory(User::class, 4)->create();
|
||||||
|
$filters = [];
|
||||||
|
$userQuery = User::query()->select();
|
||||||
|
|
||||||
|
//Expect an exception message
|
||||||
|
$this->expectExceptionMessage("There are no filter for loading a user model");
|
||||||
|
|
||||||
|
//Call the userFilters scope
|
||||||
|
$userQuery->userFilters($filters);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\unit\workflow\src\ProcessMaker\Util\Helpers;
|
||||||
|
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class ChangeAbbreviationOfDirectives extends TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Provider to define different types of configurations in the php.ini and the result expected
|
||||||
|
*/
|
||||||
|
public function provider()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
['1024K','1024KB'],
|
||||||
|
['600M','600MB'],
|
||||||
|
['5G','5GB'],
|
||||||
|
['10T','10Bytes'],
|
||||||
|
['250','250Bytes']
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the function is changed correctly the possibles directives defined in the php.ini
|
||||||
|
*
|
||||||
|
* @link https://www.php.net/manual/es/faq.using.php#faq.using.shorthandbytes
|
||||||
|
*
|
||||||
|
* @param string $configuration
|
||||||
|
* @param string $expected
|
||||||
|
*
|
||||||
|
* @dataProvider provider
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_should_change_abbreviation_of_directives($configuration, $expected)
|
||||||
|
{
|
||||||
|
$this->assertEquals($expected, changeAbbreviationOfDirectives($configuration));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\unit\workflow\engine\src\ProcessMaker\Util\Helpers;
|
||||||
|
|
||||||
|
use ProcessMaker\Model\User;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class UpdateUserLastLoginTest extends TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* It tests the updateUserLastLogin function
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_should_test_the_update_last_login_date_function_when_it_does_not_fail()
|
||||||
|
{
|
||||||
|
$user = factory(User::class)->create();
|
||||||
|
|
||||||
|
$userLog = ['USR_UID' => $user['USR_UID'], 'LOG_INIT_DATE' => date('Y-m-d H:i:s')];
|
||||||
|
|
||||||
|
// Call the updateUserLastLogin function
|
||||||
|
$result = updateUserLastLogin($userLog);
|
||||||
|
|
||||||
|
// Asserts the update has been successful
|
||||||
|
$this->assertEquals(1, $result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* It tests the updateUserLastLogin function exception
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_should_test_the_update_last_login_date_function_when_it_fails()
|
||||||
|
{
|
||||||
|
$user = factory(User::class)->create();
|
||||||
|
|
||||||
|
$userLog = ['USR_UID' => $user['USR_UID']];
|
||||||
|
|
||||||
|
// Assert the expected exception
|
||||||
|
$this->expectExceptionMessage("Undefined index: LOG_INIT_DATE");
|
||||||
|
|
||||||
|
// Call the updateUserLastLogin function
|
||||||
|
updateUserLastLogin($userLog);
|
||||||
|
|
||||||
|
$userLog = null;
|
||||||
|
|
||||||
|
// Assert the expected exception
|
||||||
|
$this->expectExceptionMessage("There are no filter for loading a user model");
|
||||||
|
|
||||||
|
// Call the updateUserLastLogin function
|
||||||
|
updateUserLastLogin($userLog);
|
||||||
|
|
||||||
|
$userLog = '';
|
||||||
|
|
||||||
|
// Assert the expected exception
|
||||||
|
$this->expectExceptionMessage("Illegal string offset 'USR_UID'");
|
||||||
|
|
||||||
|
// Call the updateUserLastLogin function
|
||||||
|
updateUserLastLogin($userLog);
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because one or more lines are too long
@@ -18338,8 +18338,8 @@ msgstr "MEMBER OF"
|
|||||||
# TRANSLATION
|
# TRANSLATION
|
||||||
# LABEL/ID_MEMORY_LIMIT
|
# LABEL/ID_MEMORY_LIMIT
|
||||||
#: LABEL/ID_MEMORY_LIMIT
|
#: LABEL/ID_MEMORY_LIMIT
|
||||||
msgid "Memory Limit (Mb)"
|
msgid "Memory Limit (MB)"
|
||||||
msgstr "Memory Limit (Mb)"
|
msgstr "Memory Limit (MB)"
|
||||||
|
|
||||||
# TRANSLATION
|
# TRANSLATION
|
||||||
# LABEL/ID_MEMORY_LIMIT_VALIDATE
|
# LABEL/ID_MEMORY_LIMIT_VALIDATE
|
||||||
@@ -21470,8 +21470,8 @@ msgstr "LDAP is optional"
|
|||||||
# TRANSLATION
|
# TRANSLATION
|
||||||
# LABEL/ID_PROCESSMAKER_REQUIREMENTS_MEMORYLIMIT
|
# LABEL/ID_PROCESSMAKER_REQUIREMENTS_MEMORYLIMIT
|
||||||
#: LABEL/ID_PROCESSMAKER_REQUIREMENTS_MEMORYLIMIT
|
#: LABEL/ID_PROCESSMAKER_REQUIREMENTS_MEMORYLIMIT
|
||||||
msgid "Memory Limit >= 80M"
|
msgid "Memory Limit >= 80MB"
|
||||||
msgstr "Memory Limit >= 80M"
|
msgstr "Memory Limit >= 80MB"
|
||||||
|
|
||||||
# TRANSLATION
|
# TRANSLATION
|
||||||
# LABEL/ID_PROCESSMAKER_REQUIREMENTS_MSSQL
|
# LABEL/ID_PROCESSMAKER_REQUIREMENTS_MSSQL
|
||||||
|
|||||||
2
workflow/engine/controllers/InstallerModule.php
Normal file → Executable file
2
workflow/engine/controllers/InstallerModule.php
Normal file → Executable file
@@ -295,7 +295,7 @@ class InstallerModule extends Controller
|
|||||||
|
|
||||||
// memory limit verification
|
// memory limit verification
|
||||||
$memory = (int)ini_get('memory_limit');
|
$memory = (int)ini_get('memory_limit');
|
||||||
$info->memory->version = $memory . 'M';
|
$info->memory->version = changeAbbreviationOfDirectives(ini_get('memory_limit'));
|
||||||
$info->memory->result = $memory > 255;
|
$info->memory->result = $memory > 255;
|
||||||
|
|
||||||
return $info;
|
return $info;
|
||||||
|
|||||||
@@ -59918,7 +59918,7 @@ INSERT INTO TRANSLATION (TRN_CATEGORY,TRN_ID,TRN_LANG,TRN_VALUE,TRN_UPDATE_DATE
|
|||||||
( 'LABEL','ID_MEMBER','en','Member','2014-01-15') ,
|
( 'LABEL','ID_MEMBER','en','Member','2014-01-15') ,
|
||||||
( 'LABEL','ID_MEMBERS','en','Members','2014-01-15') ,
|
( 'LABEL','ID_MEMBERS','en','Members','2014-01-15') ,
|
||||||
( 'LABEL','ID_MEMBER_OF','en','MEMBER OF','2014-01-15') ,
|
( 'LABEL','ID_MEMBER_OF','en','MEMBER OF','2014-01-15') ,
|
||||||
( 'LABEL','ID_MEMORY_LIMIT','en','Memory Limit (Mb)','2014-01-15') ,
|
( 'LABEL','ID_MEMORY_LIMIT','en','Memory Limit (MB)','2014-01-15') ,
|
||||||
( 'LABEL','ID_MEMORY_LIMIT_VALIDATE','en','Memory Limit value has to be either a positive integer or -1','2017-04-05') ,
|
( 'LABEL','ID_MEMORY_LIMIT_VALIDATE','en','Memory Limit value has to be either a positive integer or -1','2017-04-05') ,
|
||||||
( 'LABEL','ID_MENU_NAME','en','Enterprise Manager','2014-10-17') ,
|
( 'LABEL','ID_MENU_NAME','en','Enterprise Manager','2014-10-17') ,
|
||||||
( 'LABEL','ID_MESSAGE','en','Message','2014-01-15') ,
|
( 'LABEL','ID_MESSAGE','en','Message','2014-01-15') ,
|
||||||
@@ -60455,7 +60455,7 @@ INSERT INTO TRANSLATION (TRN_CATEGORY,TRN_ID,TRN_LANG,TRN_VALUE,TRN_UPDATE_DATE
|
|||||||
( 'LABEL','ID_PROCESSMAKER_REQUIREMENTS_GD','en','GD Support','2014-01-15') ,
|
( 'LABEL','ID_PROCESSMAKER_REQUIREMENTS_GD','en','GD Support','2014-01-15') ,
|
||||||
( 'LABEL','ID_PROCESSMAKER_REQUIREMENTS_LDAP','en','LDAP Support (*)','2014-01-15') ,
|
( 'LABEL','ID_PROCESSMAKER_REQUIREMENTS_LDAP','en','LDAP Support (*)','2014-01-15') ,
|
||||||
( 'LABEL','ID_PROCESSMAKER_REQUIREMENTS_LDAP_OPTIONAL','en','LDAP is optional','2014-01-15') ,
|
( 'LABEL','ID_PROCESSMAKER_REQUIREMENTS_LDAP_OPTIONAL','en','LDAP is optional','2014-01-15') ,
|
||||||
( 'LABEL','ID_PROCESSMAKER_REQUIREMENTS_MEMORYLIMIT','en','Memory Limit >= 80M','2014-01-15') ,
|
( 'LABEL','ID_PROCESSMAKER_REQUIREMENTS_MEMORYLIMIT','en','Memory Limit >= 80MB','2014-01-15') ,
|
||||||
( 'LABEL','ID_PROCESSMAKER_REQUIREMENTS_MSSQL','en','MSSQL Support (*)','2014-01-15') ,
|
( 'LABEL','ID_PROCESSMAKER_REQUIREMENTS_MSSQL','en','MSSQL Support (*)','2014-01-15') ,
|
||||||
( 'LABEL','ID_PROCESSMAKER_REQUIREMENTS_MULTIBYTESTRING','en','Multibyte Strings Support','2014-01-15') ,
|
( 'LABEL','ID_PROCESSMAKER_REQUIREMENTS_MULTIBYTESTRING','en','Multibyte Strings Support','2014-01-15') ,
|
||||||
( 'LABEL','ID_PROCESSMAKER_REQUIREMENTS_MYSQL','en','MySQL Support','2014-01-15') ,
|
( 'LABEL','ID_PROCESSMAKER_REQUIREMENTS_MYSQL','en','MySQL Support','2014-01-15') ,
|
||||||
|
|||||||
@@ -326,6 +326,8 @@ try {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($RBAC->singleSignOn) {
|
if ($RBAC->singleSignOn) {
|
||||||
|
// Update the User's last login date
|
||||||
|
updateUserLastLogin($aLog);
|
||||||
G::header('Location: ' . $sLocation);
|
G::header('Location: ' . $sLocation);
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
@@ -336,6 +338,8 @@ try {
|
|||||||
if ($changePassword === true) {
|
if ($changePassword === true) {
|
||||||
$user = new User();
|
$user = new User();
|
||||||
$currentUser = $user->changePassword($_SESSION['USER_LOGGED'], $_POST['form']['USR_PASSWORD']);
|
$currentUser = $user->changePassword($_SESSION['USER_LOGGED'], $_POST['form']['USR_PASSWORD']);
|
||||||
|
// Update the User's last login date
|
||||||
|
updateUserLastLogin($aLog);
|
||||||
G::header('Location: ' . $currentUser["__REDIRECT_PATH__"]);
|
G::header('Location: ' . $currentUser["__REDIRECT_PATH__"]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -394,6 +398,9 @@ try {
|
|||||||
setcookie("PM-TabPrimary", 101010010, time() + (24 * 60 * 60), '/');
|
setcookie("PM-TabPrimary", 101010010, time() + (24 * 60 * 60), '/');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update the User's last login date
|
||||||
|
updateUserLastLogin($aLog);
|
||||||
|
|
||||||
$oPluginRegistry = PluginRegistry::loadSingleton();
|
$oPluginRegistry = PluginRegistry::loadSingleton();
|
||||||
if ($oPluginRegistry->existsTrigger ( PM_AFTER_LOGIN )) {
|
if ($oPluginRegistry->existsTrigger ( PM_AFTER_LOGIN )) {
|
||||||
$oPluginRegistry->executeTriggers ( PM_AFTER_LOGIN , $_SESSION['USER_LOGGED'] );
|
$oPluginRegistry->executeTriggers ( PM_AFTER_LOGIN , $_SESSION['USER_LOGGED'] );
|
||||||
|
|||||||
@@ -116,12 +116,6 @@ if (isset($_SESSION['USER_LOGGED'])) {
|
|||||||
$aLog['USR_UID'] = $aRow['USR_UID'];
|
$aLog['USR_UID'] = $aRow['USR_UID'];
|
||||||
|
|
||||||
$weblog->update($aLog);
|
$weblog->update($aLog);
|
||||||
|
|
||||||
$aLog = array();
|
|
||||||
$aLog['USR_UID'] = $aRow['USR_UID'];
|
|
||||||
$aLog['USR_LAST_LOGIN'] = $endDate;
|
|
||||||
$user = new Users();
|
|
||||||
$aUser = $user->update($aLog);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
5
workflow/engine/methods/users/usersEdit.php
Normal file → Executable file
5
workflow/engine/methods/users/usersEdit.php
Normal file → Executable file
@@ -19,6 +19,9 @@ $mul = substr($UPLOAD_MAX_SIZE, - 1);
|
|||||||
$mul = ($mul == 'M' ? 1048576 : ($mul == 'K' ? 1024 : ($mul == 'G' ? 1073741824 : 1)));
|
$mul = ($mul == 'M' ? 1048576 : ($mul == 'K' ? 1024 : ($mul == 'G' ? 1073741824 : 1)));
|
||||||
$uploadMaxSize = (int) $UPLOAD_MAX_SIZE * $mul;
|
$uploadMaxSize = (int) $UPLOAD_MAX_SIZE * $mul;
|
||||||
|
|
||||||
|
//We need to use the following abbreviations: Bytes, KB, MB, GB
|
||||||
|
$maxFileSize = changeAbbreviationOfDirectives(ini_get('upload_max_filesize'));
|
||||||
|
|
||||||
if ($postMaxSize < $uploadMaxSize) {
|
if ($postMaxSize < $uploadMaxSize) {
|
||||||
$uploadMaxSize = $postMaxSize;
|
$uploadMaxSize = $postMaxSize;
|
||||||
}
|
}
|
||||||
@@ -46,7 +49,7 @@ $oHeadPublisher = headPublisher::getSingleton();
|
|||||||
$oHeadPublisher->addExtJsScript('users/users', true); //adding a javascript file .js
|
$oHeadPublisher->addExtJsScript('users/users', true); //adding a javascript file .js
|
||||||
$oHeadPublisher->assign('USR_UID', $_GET['USR_UID']);
|
$oHeadPublisher->assign('USR_UID', $_GET['USR_UID']);
|
||||||
$oHeadPublisher->assign('MODE', $_GET['MODE']);
|
$oHeadPublisher->assign('MODE', $_GET['MODE']);
|
||||||
$oHeadPublisher->assign('MAX_FILES_SIZE', ' (' . $UPLOAD_MAX_SIZE . ') ');
|
$oHeadPublisher->assign('MAX_FILES_SIZE', ' (' . $maxFileSize . ') ');
|
||||||
$oHeadPublisher->assign('SYSTEM_TIME_ZONE', $arraySystemConfiguration['time_zone']);
|
$oHeadPublisher->assign('SYSTEM_TIME_ZONE', $arraySystemConfiguration['time_zone']);
|
||||||
$oHeadPublisher->assign('TIME_ZONE_DATA', array_map(function ($value) {
|
$oHeadPublisher->assign('TIME_ZONE_DATA', array_map(function ($value) {
|
||||||
return [$value, $value];
|
return [$value, $value];
|
||||||
|
|||||||
5
workflow/engine/methods/users/usersInit.php
Normal file → Executable file
5
workflow/engine/methods/users/usersInit.php
Normal file → Executable file
@@ -27,6 +27,9 @@ $mul = substr($UPLOAD_MAX_SIZE, - 1);
|
|||||||
$mul = ($mul == 'M' ? 1048576 : ($mul == 'K' ? 1024 : ($mul == 'G' ? 1073741824 : 1)));
|
$mul = ($mul == 'M' ? 1048576 : ($mul == 'K' ? 1024 : ($mul == 'G' ? 1073741824 : 1)));
|
||||||
$uploadMaxSize = (int) $UPLOAD_MAX_SIZE * $mul;
|
$uploadMaxSize = (int) $UPLOAD_MAX_SIZE * $mul;
|
||||||
|
|
||||||
|
//We need to use the following abbreviations: Bytes, KB, MB, GB
|
||||||
|
$maxFileSize = changeAbbreviationOfDirectives(ini_get('upload_max_filesize'));
|
||||||
|
|
||||||
if ($postMaxSize < $uploadMaxSize) {
|
if ($postMaxSize < $uploadMaxSize) {
|
||||||
$uploadMaxSize = $postMaxSize;
|
$uploadMaxSize = $postMaxSize;
|
||||||
}
|
}
|
||||||
@@ -58,7 +61,7 @@ $oHeadPublisher->assign('infoMode', true);
|
|||||||
$oHeadPublisher->assign('EDITPROFILE', 1);
|
$oHeadPublisher->assign('EDITPROFILE', 1);
|
||||||
$oHeadPublisher->assign('canEdit', $canEdit);
|
$oHeadPublisher->assign('canEdit', $canEdit);
|
||||||
$oHeadPublisher->assign('canEditCalendar', $canEditCalendar);
|
$oHeadPublisher->assign('canEditCalendar', $canEditCalendar);
|
||||||
$oHeadPublisher->assign('MAX_FILES_SIZE', ' (' . $UPLOAD_MAX_SIZE . ') ');
|
$oHeadPublisher->assign('MAX_FILES_SIZE', ' (' . $maxFileSize . ') ');
|
||||||
$oHeadPublisher->assign('MODE', '');
|
$oHeadPublisher->assign('MODE', '');
|
||||||
$oHeadPublisher->assign('SYSTEM_TIME_ZONE', $arraySystemConfiguration['time_zone']);
|
$oHeadPublisher->assign('SYSTEM_TIME_ZONE', $arraySystemConfiguration['time_zone']);
|
||||||
$oHeadPublisher->assign('TIME_ZONE_DATA', array_map(function ($value) {
|
$oHeadPublisher->assign('TIME_ZONE_DATA', array_map(function ($value) {
|
||||||
|
|||||||
5
workflow/engine/methods/users/usersNew.php
Normal file → Executable file
5
workflow/engine/methods/users/usersNew.php
Normal file → Executable file
@@ -16,6 +16,9 @@ $mul = substr($UPLOAD_MAX_SIZE, - 1);
|
|||||||
$mul = ($mul == 'M' ? 1048576 : ($mul == 'K' ? 1024 : ($mul == 'G' ? 1073741824 : 1)));
|
$mul = ($mul == 'M' ? 1048576 : ($mul == 'K' ? 1024 : ($mul == 'G' ? 1073741824 : 1)));
|
||||||
$uploadMaxSize = (int) $UPLOAD_MAX_SIZE * $mul;
|
$uploadMaxSize = (int) $UPLOAD_MAX_SIZE * $mul;
|
||||||
|
|
||||||
|
//We need to use the following abbreviations: Bytes, KB, MB, GB
|
||||||
|
$maxFileSize = changeAbbreviationOfDirectives(ini_get('upload_max_filesize'));
|
||||||
|
|
||||||
if ($postMaxSize < $uploadMaxSize) {
|
if ($postMaxSize < $uploadMaxSize) {
|
||||||
$uploadMaxSize = $postMaxSize;
|
$uploadMaxSize = $postMaxSize;
|
||||||
}
|
}
|
||||||
@@ -44,7 +47,7 @@ $oHeadPublisher = headPublisher::getSingleton();
|
|||||||
$oHeadPublisher->addExtJsScript('users/users', true); //adding a javascript file .js
|
$oHeadPublisher->addExtJsScript('users/users', true); //adding a javascript file .js
|
||||||
$oHeadPublisher->assign('USR_UID', '');
|
$oHeadPublisher->assign('USR_UID', '');
|
||||||
$oHeadPublisher->assign('MODE', $_GET['MODE']);
|
$oHeadPublisher->assign('MODE', $_GET['MODE']);
|
||||||
$oHeadPublisher->assign('MAX_FILES_SIZE', ' (' . $UPLOAD_MAX_SIZE . ') ');
|
$oHeadPublisher->assign('MAX_FILES_SIZE', ' (' . $maxFileSize . ') ');
|
||||||
$oHeadPublisher->assign('SYSTEM_TIME_ZONE', $arraySystemConfiguration['time_zone']);
|
$oHeadPublisher->assign('SYSTEM_TIME_ZONE', $arraySystemConfiguration['time_zone']);
|
||||||
$oHeadPublisher->assign('TIME_ZONE_DATA', array_map(function ($value) {
|
$oHeadPublisher->assign('TIME_ZONE_DATA', array_map(function ($value) {
|
||||||
return [$value, $value];
|
return [$value, $value];
|
||||||
|
|||||||
@@ -196,7 +196,7 @@ class FilesLogs extends Files
|
|||||||
*/
|
*/
|
||||||
private function size($size, $format = null)
|
private function size($size, $format = null)
|
||||||
{
|
{
|
||||||
$sizes = ['Bytes', 'Kbytes', 'Mbytes', 'Gbytes', 'Tbytes', 'Pbytes', 'Ebytes', 'Zbytes', 'Ybytes'];
|
$sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
||||||
if ($format === null) {
|
if ($format === null) {
|
||||||
$format = ' % 01.2f % s';
|
$format = ' % 01.2f % s';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ abstract class Importer
|
|||||||
public function import($option = self::IMPORT_OPTION_CREATE_NEW, $optionGroup = self::GROUP_IMPORT_OPTION_CREATE_NEW, $generateUidFromJs = null, $objectsToImport = '')
|
public function import($option = self::IMPORT_OPTION_CREATE_NEW, $optionGroup = self::GROUP_IMPORT_OPTION_CREATE_NEW, $generateUidFromJs = null, $objectsToImport = '')
|
||||||
{
|
{
|
||||||
$this->prepare();
|
$this->prepare();
|
||||||
|
$keepCreateDate = false;
|
||||||
//Verify data
|
//Verify data
|
||||||
switch ($option) {
|
switch ($option) {
|
||||||
case self::IMPORT_OPTION_CREATE_NEW:
|
case self::IMPORT_OPTION_CREATE_NEW:
|
||||||
@@ -126,6 +127,7 @@ abstract class Importer
|
|||||||
case self::IMPORT_OPTION_DISABLE_AND_CREATE_NEW:
|
case self::IMPORT_OPTION_DISABLE_AND_CREATE_NEW:
|
||||||
break;
|
break;
|
||||||
case self::IMPORT_OPTION_KEEP_WITHOUT_CHANGING_AND_CREATE_NEW:
|
case self::IMPORT_OPTION_KEEP_WITHOUT_CHANGING_AND_CREATE_NEW:
|
||||||
|
$keepCreateDate = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -258,12 +260,15 @@ abstract class Importer
|
|||||||
$this->importData["tables"]["workflow"]["process"] = $this->importData["tables"]["workflow"]["process"][0];
|
$this->importData["tables"]["workflow"]["process"] = $this->importData["tables"]["workflow"]["process"][0];
|
||||||
|
|
||||||
//Import
|
//Import
|
||||||
if(!empty($generateUidFromJs)) {
|
if (!empty($generateUidFromJs)) {
|
||||||
$generateUid = $generateUidFromJs;
|
$generateUid = $generateUidFromJs;
|
||||||
}
|
}
|
||||||
/*----------------------------------********---------------------------------*/
|
/*----------------------------------********---------------------------------*/
|
||||||
//Granular Import
|
//Granular Import
|
||||||
try {
|
try {
|
||||||
|
if ($generateUidFromJs || $keepCreateDate) {
|
||||||
|
unset($this->importData["tables"]["workflow"]["process"]["PRO_CREATE_DATE"]);
|
||||||
|
}
|
||||||
if ($objectsToImport !== '') {
|
if ($objectsToImport !== '') {
|
||||||
$granularObj = new \ProcessMaker\BusinessModel\Migrator\GranularImporter();
|
$granularObj = new \ProcessMaker\BusinessModel\Migrator\GranularImporter();
|
||||||
$newObjectArray = $objectsToImport;
|
$newObjectArray = $objectsToImport;
|
||||||
@@ -651,7 +656,9 @@ abstract class Importer
|
|||||||
}
|
}
|
||||||
|
|
||||||
unset($arrayWorkflowTables["process"]["PRO_CREATE_USER"]);
|
unset($arrayWorkflowTables["process"]["PRO_CREATE_USER"]);
|
||||||
unset($arrayWorkflowTables["process"]["PRO_CREATE_DATE"]);
|
if ($generateUid) {
|
||||||
|
unset($arrayWorkflowTables["process"]["PRO_CREATE_DATE"]);
|
||||||
|
}
|
||||||
unset($arrayWorkflowTables["process"]["PRO_UPDATE_DATE"]);
|
unset($arrayWorkflowTables["process"]["PRO_UPDATE_DATE"]);
|
||||||
|
|
||||||
if ($flagDeleteCategory) {
|
if ($flagDeleteCategory) {
|
||||||
|
|||||||
14
workflow/engine/src/ProcessMaker/Model/BpmnProject.php
Normal file
14
workflow/engine/src/ProcessMaker/Model/BpmnProject.php
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace ProcessMaker\Model;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class BpmnProject extends Model
|
||||||
|
{
|
||||||
|
// Set our table name
|
||||||
|
protected $table = 'BPMN_PROJECT';
|
||||||
|
protected $primaryKey = 'PRJ_UID';
|
||||||
|
// We do not have create/update timestamps for this table
|
||||||
|
public $timestamps = false;
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace ProcessMaker\Model;
|
namespace ProcessMaker\Model;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Exception;
|
||||||
|
|
||||||
class User extends Model
|
class User extends Model
|
||||||
{
|
{
|
||||||
@@ -39,4 +40,26 @@ class User extends Model
|
|||||||
{
|
{
|
||||||
return User::find($usrUid)->groups()->get();
|
return User::find($usrUid)->groups()->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scope for the specified user
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Database\Eloquent\Builder $query @param \Illuminate\Database\Eloquent\Builder $query
|
||||||
|
* @param array $filters
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Builder
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function scopeUserFilters($query, array $filters)
|
||||||
|
{
|
||||||
|
if (!empty($filters['USR_ID'])) {
|
||||||
|
$query->where('USR_ID', $filters['USR_ID']);
|
||||||
|
} elseif (!empty($filters['USR_UID'])) {
|
||||||
|
$query->where('USR_UID', $filters['USR_UID']);
|
||||||
|
} else {
|
||||||
|
throw new Exception("There are no filter for loading a user model");
|
||||||
|
}
|
||||||
|
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
50
workflow/engine/src/ProcessMaker/Util/helpers.php
Normal file → Executable file
50
workflow/engine/src/ProcessMaker/Util/helpers.php
Normal file → Executable file
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
use Illuminate\Session\TokenMismatchException;
|
use Illuminate\Session\TokenMismatchException;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
use ProcessMaker\Model\User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We will send a case note in the actions by email
|
* We will send a case note in the actions by email
|
||||||
@@ -450,6 +451,29 @@ function replacePrefixes($outDocFilename, $prefix = '@=')
|
|||||||
return $outDocFile;
|
return $outDocFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change the abbreviation of directives used in the php.ini configuration
|
||||||
|
*
|
||||||
|
* @param string $size
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function changeAbbreviationOfDirectives($size)
|
||||||
|
{
|
||||||
|
$sizeValue = (int)$size;
|
||||||
|
|
||||||
|
switch (substr($size, -1)) {
|
||||||
|
case 'K':
|
||||||
|
return $sizeValue . 'KB';
|
||||||
|
case 'M':
|
||||||
|
return $sizeValue . 'MB';
|
||||||
|
case 'G':
|
||||||
|
return $sizeValue . 'GB';
|
||||||
|
default:
|
||||||
|
return $sizeValue . 'Bytes';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encoding header filename used in Content-Disposition
|
* Encoding header filename used in Content-Disposition
|
||||||
*
|
*
|
||||||
@@ -493,3 +517,29 @@ if (!function_exists('set_magic_quotes_runtime')) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the USER table with the last login date
|
||||||
|
*
|
||||||
|
* @param array $userLog
|
||||||
|
* @return int
|
||||||
|
* @throws Exception
|
||||||
|
*
|
||||||
|
* @see workflow/engine/methods/login/authentication.php
|
||||||
|
*/
|
||||||
|
function updateUserLastLogin($userLog, $keyLastLogin = 'LOG_INIT_DATE')
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$filters = [];
|
||||||
|
$filters['USR_UID'] = $userLog['USR_UID'];
|
||||||
|
|
||||||
|
$user = User::query();
|
||||||
|
$user->userFilters($filters);
|
||||||
|
$res = $user->update(['USR_LAST_LOGIN' => $userLog[$keyLastLogin]]);
|
||||||
|
|
||||||
|
return $res;
|
||||||
|
} catch (Exception $e) {
|
||||||
|
throw new Exception($e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user