diff --git a/composer.json b/composer.json index 3945a452b..eb9735090 100644 --- a/composer.json +++ b/composer.json @@ -35,10 +35,10 @@ "laravel/framework": "5.7.*", "luracast/restler": "3.0", "bshaffer/oauth2-server-php": "v1.0", - "colosa/pmui": "release/3.7.3-dev", - "colosa/michelangelofe": "release/3.7.3-dev", - "colosa/pmdynaform": "release/3.7.3-dev", - "colosa/taskscheduler": "release/1.0.2-dev", + "colosa/pmui": "release/3.7.4-dev", + "colosa/michelangelofe": "release/3.7.4-dev", + "colosa/pmdynaform": "release/3.7.4-dev", + "colosa/taskscheduler": "release/1.0.3-dev", "google/apiclient": "1.1.6", "dapphp/securimage": "^3.6", "psr/log": "1.0.0", diff --git a/gulliver/system/class.bootstrap.php b/gulliver/system/class.bootstrap.php index c33a86317..ecb9ed15b 100644 --- a/gulliver/system/class.bootstrap.php +++ b/gulliver/system/class.bootstrap.php @@ -2633,7 +2633,7 @@ class Bootstrap $langServer = $locale['LOCALE']; $language = explode('-', $langServer); $language = head($language); - if ($language === $acceptLanguage) { + if ($language === $acceptLanguage || $langServer === $acceptLanguage) { $inLang = true; break; } diff --git a/gulliver/system/class.rbac.php b/gulliver/system/class.rbac.php index 4f916a778..80c77856d 100644 --- a/gulliver/system/class.rbac.php +++ b/gulliver/system/class.rbac.php @@ -2150,4 +2150,16 @@ class RBAC { return self::GUEST_USER_UID === $usrUid; } + + /** + * Returns true in case the parameter corresponds to the admin user, + * otherwise it returns false. + * + * @param string $usrUid + * @return boolean + */ + public static function isAdminUserUid($usrUid) + { + return self::ADMIN_USER_UID === $usrUid; + } } diff --git a/resources/assets/js/admin/settings/customCaseList/Tables.vue b/resources/assets/js/admin/settings/customCaseList/Tables.vue index a22fe8d6e..4eb911a2f 100644 --- a/resources/assets/js/admin/settings/customCaseList/Tables.vue +++ b/resources/assets/js/admin/settings/customCaseList/Tables.vue @@ -277,6 +277,13 @@ export default { if (this.showEllipsis) { this.dataEllipsis = { buttons: { + note: { + name: "edit", + icon: "far fa-edit", + fn: function() { + that.editCustomCaseList(data); + } + }, open: { name: "delete", icon: "far fa-trash-alt", @@ -285,13 +292,6 @@ export default { that.showModalDelete(data); } }, - note: { - name: "edit", - icon: "far fa-edit", - fn: function() { - that.editCustomCaseList(data); - } - }, reassign: { name: "download", icon: "fas fa-arrow-circle-down", diff --git a/resources/assets/js/home/CustomCaseList/CustomCaseList.vue b/resources/assets/js/home/CustomCaseList/CustomCaseList.vue index bb9e625fe..57da6f242 100644 --- a/resources/assets/js/home/CustomCaseList/CustomCaseList.vue +++ b/resources/assets/js/home/CustomCaseList/CustomCaseList.vue @@ -802,7 +802,7 @@ export default { if (that.availableItems[that.itemMap[item.field]]) { newItems.push(that.availableItems[that.itemMap[item.field]]); } else { - product = this.filterItemFactory(item) + product = this.filterItemFactory(item); if (product) { newItems.push(product); } @@ -837,9 +837,9 @@ export default { filterItemFactory(item) { let product; if (item.type === "DATETIME") { - product= {...this.customItems["DATETIME"]}; + product= _.cloneDeep(this.customItems["DATETIME"]); } else { - product = {...this.customItems["VARCHAR"]}; + product = _.cloneDeep(this.customItems["VARCHAR"]); } product.title += " " + item.name; product.id = item.field; diff --git a/tests/CreateTestSite.php b/tests/CreateTestSite.php index a53520e45..447e60dd5 100644 --- a/tests/CreateTestSite.php +++ b/tests/CreateTestSite.php @@ -7,6 +7,14 @@ trait CreateTestSite public function createDBFile(string $workspace) { + if (!file_exists(PATH_TRUNK . 'shared')) { + mkdir(PATH_TRUNK . 'shared'); + } + + if (!file_exists(PATH_TRUNK . 'shared/sites')) { + mkdir(PATH_TRUNK . 'shared/sites'); + } + if (!file_exists(PATH_DB . $workspace)) { mkdir(PATH_DB . $workspace); } @@ -14,20 +22,20 @@ trait CreateTestSite if (!file_exists(PATH_DB . $workspace . PATH_SEP . "db.php")) { $myfile = fopen(PATH_DB . $workspace . PATH_SEP . "db.php", "w"); $content = "" - . " + + + + + + +
Template
+ + diff --git a/tests/unit/workflow/engine/classes/DerivationTest.php b/tests/unit/workflow/engine/classes/DerivationTest.php index 2a24c49b8..a8a07b06c 100644 --- a/tests/unit/workflow/engine/classes/DerivationTest.php +++ b/tests/unit/workflow/engine/classes/DerivationTest.php @@ -126,8 +126,20 @@ class DerivationTest extends TestCase $task = factory(Task::class)->create([ 'PRO_UID' => $process->PRO_UID, ]); - $application = factory(Application::class)->create(); - $appDelegation = factory(Delegation::class)->create(); + $application = factory(Application::class)->create([ + 'PRO_UID' => $process->PRO_UID, + 'APP_INIT_USER' => $user->USR_UID, + 'APP_CUR_USER' => $user->USR_UID + ]); + $appDelegation = factory(Delegation::class)->create([ + 'APP_UID' => $application->APP_UID, + 'APP_NUMBER' => $application->APP_NUMBER + ]); + factory(SubApplication::class)->create([ + 'APP_UID' => $application->APP_UID, + 'APP_PARENT' => $application->APP_UID, + 'DEL_INDEX_PARENT' => $appDelegation->DEL_INDEX + ]); // Create the parameters $currentDelegation = [ @@ -169,7 +181,7 @@ class DerivationTest extends TestCase $res = $der->doDerivation($currentDelegation, $nextDel, $appFields, $sp); // Assert the new delegation index is 1 - $this->assertEquals(1, $res); + $this->assertTrue($res >= 1); // Review the subprocess synchronously $query = SubApplication::query()->select(); @@ -201,11 +213,23 @@ class DerivationTest extends TestCase ]); factory(TaskUser::class)->create([ 'TAS_UID' => $task->TAS_UID, - 'USR_UID' => $user->USR_UID, + 'USR_UID' => $user->USR_UID + ]); + $application = factory(Application::class)->create([ + 'PRO_UID' => $process->PRO_UID, + 'APP_INIT_USER' => $user->USR_UID, + 'APP_CUR_USER' => $user->USR_UID ]); - $application = factory(Application::class)->create(); $appDelegation = factory(Delegation::class)->create([ - 'TAS_UID' => $task->TAS_UID + 'TAS_UID' => $task->TAS_UID, + 'APP_UID' => $application->APP_UID, + 'APP_NUMBER' => $application->APP_NUMBER + ]); + factory(SubApplication::class)->create([ + 'APP_UID' => $application->APP_UID, + 'APP_PARENT' => $application->APP_UID, + 'DEL_INDEX_PARENT' => $appDelegation->DEL_INDEX, + 'SA_STATUS' => 'FINISHED' ]); factory(Route::class)->create([ 'TAS_UID' => $task->TAS_UID, @@ -253,7 +277,7 @@ class DerivationTest extends TestCase $res = $der->doDerivation($currentDelegation, $nextDel, $appFields, $sp); // Assert the new delegation index is 1 - $this->assertEquals(1, $res); + $this->assertTrue($res >= 1); // Review the subprocess asynchronously $query = SubApplication::query()->select(); diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFSendMessageTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFSendMessageTest.php index a3ab1c3b1..276366f6d 100644 --- a/tests/unit/workflow/engine/classes/PmFunctions/PMFSendMessageTest.php +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFSendMessageTest.php @@ -24,10 +24,25 @@ class PMFSendMessageTest extends TestCase */ private function createTemplate($proUid, $usrUid) { + if (!file_exists(PATH_DB)) { + mkdir(PATH_DB); + } + if (!file_exists(PATH_DATA_SITE)) { + mkdir(PATH_DATA_SITE); + } + $data = file_get_contents(PATH_TRUNK . 'tests/resources/template.html'); + if (!file_exists(PATH_DATA_SITE . 'mailTemplates')) { + mkdir(PATH_DATA_SITE . 'mailTemplates'); + } + file_put_contents(PATH_DATA_SITE . 'mailTemplates' . PATH_SEP . 'template.html', $data); + if (!file_exists(PATH_DATA_SITE . 'mailTemplates' . PATH_SEP . $proUid)) { + mkdir(PATH_DATA_SITE . 'mailTemplates' . PATH_SEP . $proUid); + } + file_put_contents(PATH_DATA_SITE . 'mailTemplates' . PATH_SEP . $proUid . PATH_SEP . 'template.html', $data); $template = factory(\ProcessMaker\Model\ProcessFiles::class)->create([ 'PRO_UID' => $proUid, 'USR_UID' => $usrUid, - 'PRF_PATH' => '/' + 'PRF_PATH' => 'template.html' ]); return $template; } @@ -68,8 +83,14 @@ class PMFSendMessageTest extends TestCase public function it_send_message_related_to_same_case() { $user = factory(User::class)->create(); - $process = factory(Process::class)->create(); - $app = factory(Application::class)->create(['PRO_UID' => $process->PRO_UID]); + $process = factory(Process::class)->create([ + 'PRO_CREATE_USER' => $user->USR_UID + ]); + $app = factory(Application::class)->create([ + 'PRO_UID' => $process->PRO_UID, + 'APP_INIT_USER' => $user->USR_UID, + 'APP_CUR_USER' => $user->USR_UID + ]); $template = $this->createTemplate($process->PRO_UID, $user->USR_UID); $emailServer = $this->createEmailServer(); // Set the same case in session diff --git a/tests/unit/workflow/engine/classes/ReportTablesTest.php b/tests/unit/workflow/engine/classes/ReportTablesTest.php index e3a82a79b..4f6cb8df1 100644 --- a/tests/unit/workflow/engine/classes/ReportTablesTest.php +++ b/tests/unit/workflow/engine/classes/ReportTablesTest.php @@ -226,10 +226,9 @@ class ReportTablesTest extends TestCase { $tableName = 'TestReportTable'; $result = $this->prepareData($tableName); - $connectionShortName = null; $reportTables = new ReportTables(); - $reportTables->populateTable($tableName, $connectionShortName); + $reportTables->populateTable($tableName); $expected = $result->dataFields; $expected['APP_UID'] = $result->applicationUid; @@ -337,7 +336,7 @@ class ReportTablesTest extends TestCase $tableName = 'TestReportTable'; $result = $this->prepareData($tableName); $connectionShortName = 'wf'; - $type = null; + $type = ''; $reportTables = new ReportTables(); $reportTables->populateTable($tableName, $connectionShortName, $type); @@ -395,7 +394,7 @@ class ReportTablesTest extends TestCase $result = $this->prepareData($tableName); $connectionShortName = 'wf'; $type = 'NORMAL'; - $fields = null; + $fields = []; $reportTables = new ReportTables(); $reportTables->populateTable($tableName, $connectionShortName, $type, $fields); @@ -453,7 +452,7 @@ class ReportTablesTest extends TestCase $result = $this->prepareData($tableName); $connectionShortName = 'wf'; $type = 'NORMAL'; - $fields = ""; + $fields = []; $reportTables = new ReportTables(); $reportTables->populateTable($tableName, $connectionShortName, $type, $fields); @@ -513,7 +512,7 @@ class ReportTablesTest extends TestCase $connectionShortName = 'wf'; $type = 'NORMAL'; $fields = $result->fields; - $proUid = null; + $proUid = ''; $reportTables = new ReportTables(); $reportTables->populateTable($tableName, $connectionShortName, $type, $fields, $proUid); @@ -575,7 +574,7 @@ class ReportTablesTest extends TestCase $type = 'NORMAL'; $fields = $result->fields; $proUid = $result->processUid; - $grid = null; + $grid = ''; $reportTables = new ReportTables(); $reportTables->populateTable($tableName, $connectionShortName, $type, $fields, $proUid, $grid); @@ -844,4 +843,92 @@ class ReportTablesTest extends TestCase $result = json_decode($data, JSON_OBJECT_AS_ARRAY); return $result; } + + /** + * @test + * @covers ReportTables::generateOldReportTable + * @covers ReportTables::buildAndExecuteQuery + * @covers ReportTables::buildFieldsSection + * @covers ReportTables::buildValuesSection + */ + public function it_should_test_generateOldReportTable_for_normal() + { + $tableName = 'TestReportTable'; + $result = $this->prepareData($tableName); + $connectionShortName = 'wf'; + $type = 'NORMAL'; + $fields = $result->fields; + $proUid = $result->processUid; + $grid = ''; + + $start = 0; + $limit = 100; + + $reportTables = new ReportTables(); + DB::delete("TRUNCATE TABLE `{$tableName}` "); + + $reportTables->generateOldReportTable($tableName, $connectionShortName, $type, $fields, $proUid, $grid, $start, $limit); + + $expected = $result->dataFields; + $expected['APP_UID'] = $result->applicationUid; + $expected['APP_NUMBER'] = $result->applicationNumber; + + $actual = (array) DB::table($tableName) + ->select() + ->first(); + + $this->assertEquals($expected, $actual); + } + + /** + * @test + * @covers ReportTables::generateOldReportTable + * @covers ReportTables::buildAndExecuteQuery + * @covers ReportTables::buildFieldsSection + * @covers ReportTables::buildValuesSection + */ + public function it_should_test_generateOldReportTable_for_grid() + { + $tableName = 'TestReportTable'; + $result = $this->prepareData($tableName, true); + $connectionShortName = 'wf'; + $type = 'GRID'; + $fields = $result->fields; + $proUid = $result->processUid; + $grid = 'var_Grid1'; + + $app = Application::where('APP_UID', '=', $result->applicationUid)->get()->first(); + $appData = unserialize($app->APP_DATA); + $appData['var_Textarea1'] = []; + $appData = serialize($appData); + Application::where('APP_UID', '=', $result->applicationUid)->update(['APP_DATA' => $appData]); + + $start = 0; + $limit = 100; + + $reportTables = new ReportTables(); + DB::delete("TRUNCATE TABLE `{$tableName}` "); + + $reportTables->generateOldReportTable($tableName, $connectionShortName, $type, $fields, $proUid, $grid, $start, $limit); + + $indexRow = 1; + $expected = $result->appData[$grid]; + foreach ($expected as &$row) { + $row['APP_UID'] = $result->applicationUid; + $row['APP_NUMBER'] = $result->applicationNumber; + $row['ROW'] = (string) ($indexRow++); + } + $expected = array_values($expected); + + $actual = DB::table($tableName) + ->select() + ->get(); + $actual->transform(function ($item, $key) { + return (array) $item; + }); + $actual = $actual->toArray(); + + $this->assertEquals($expected, $actual); + } + } diff --git a/tests/unit/workflow/engine/classes/WsBaseTest.php b/tests/unit/workflow/engine/classes/WsBaseTest.php index c45922fa8..415db4d0e 100755 --- a/tests/unit/workflow/engine/classes/WsBaseTest.php +++ b/tests/unit/workflow/engine/classes/WsBaseTest.php @@ -5,6 +5,7 @@ use Faker\Factory; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Facades\Queue; use ProcessMaker\Model\Application; +use ProcessMaker\Model\AppDelay; use ProcessMaker\Model\AppThread; use ProcessMaker\Model\Delegation; use ProcessMaker\Model\EmailServerModel; @@ -151,10 +152,25 @@ class WsBaseTest extends TestCase */ private function createTemplate($proUid, $usrUid) { + if (!file_exists(PATH_DB)) { + mkdir(PATH_DB); + } + if (!file_exists(PATH_DATA_SITE)) { + mkdir(PATH_DATA_SITE); + } + $data = file_get_contents(PATH_TRUNK . 'tests/resources/template.html'); + if (!file_exists(PATH_DATA_SITE . 'mailTemplates')) { + mkdir(PATH_DATA_SITE . 'mailTemplates'); + } + file_put_contents(PATH_DATA_SITE . 'mailTemplates' . PATH_SEP . 'template.html', $data); + if (!file_exists(PATH_DATA_SITE . 'mailTemplates' . PATH_SEP . $proUid)) { + mkdir(PATH_DATA_SITE . 'mailTemplates' . PATH_SEP . $proUid); + } + file_put_contents(PATH_DATA_SITE . 'mailTemplates' . PATH_SEP . $proUid . PATH_SEP . 'template.html', $data); $template = factory(\ProcessMaker\Model\ProcessFiles::class)->create([ 'PRO_UID' => $proUid, 'USR_UID' => $usrUid, - 'PRF_PATH' => '/' + 'PRF_PATH' => 'template.html' ]); return $template; } @@ -996,11 +1012,24 @@ class WsBaseTest extends TestCase $RBAC->loadUserRolePermission('PROCESSMAKER', $_SESSION['USER_LOGGED']); // Create the data related to the cancel a case - $task = factory(Task::class)->create(); + $process = factory(Process::class)->create([ + 'PRO_CREATE_USER' => $user->USR_UID + ]); + $task = factory(Task::class)->create([ + 'PRO_UID' => $process->PRO_UID, + 'TAS_USER' => $user->USR_UID + ]); + factory(TaskUser::class)->create([ + 'TAS_UID' => $task->TAS_UID, + 'USR_UID' => $user->USR_UID + ]); factory(UserReporting::class)->create([ 'TAS_UID' => $task->TAS_UID ]); $application = factory(Application::class)->states('foreign_keys')->create([ + 'PRO_UID' => $process->PRO_UID, + 'APP_INIT_USER' => $user->USR_UID, + 'APP_CUR_USER' => $user->USR_UID, 'APP_STATUS_ID' => 2, 'APP_STATUS' => 'TO_DO' ]); @@ -1018,6 +1047,7 @@ class WsBaseTest extends TestCase 'APP_UID' => $application->APP_UID, 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 2, + 'DEL_PREVIOUS' => 2 ]); $ws = new WsBase(); @@ -1050,6 +1080,8 @@ class WsBaseTest extends TestCase ]); $application = factory(Application::class)->states('foreign_keys')->create([ 'APP_STATUS_ID' => 2, + 'APP_INIT_USER' => $user->USR_UID, + 'APP_CUR_USER' => $user->USR_UID, 'APP_STATUS' => 'TO_DO' ]); // Create the first thread @@ -1067,6 +1099,7 @@ class WsBaseTest extends TestCase 'APP_UID' => $application->APP_UID, 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 2, + 'DEL_PREVIOUS' => 2, ]); // Create the second thread factory(AppThread::class)->create([ @@ -1079,10 +1112,12 @@ class WsBaseTest extends TestCase $delegation = factory(Delegation::class)->states('foreign_keys')->create([ 'TAS_UID' => $task->TAS_UID, 'PRO_UID' => $application->PRO_UID, + 'USR_UID' => $user->USR_UID, 'APP_NUMBER' => $application->APP_NUMBER, 'APP_UID' => $application->APP_UID, 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 3, + 'DEL_PREVIOUS' => 3, ]); $ws = new WsBase(); @@ -1259,4 +1294,119 @@ class WsBaseTest extends TestCase //Assert the expected number of unassigned cases $this->assertCount(0, $res); } + + /** + * Review the required fields in pause case + * + * @covers WsBase::pauseCase() + * @test + */ + public function it_review_fields_to_pause_case() + { + // Validate the appUid + $ws = new WsBase(); + $response = (object) $ws->pauseCase('', 0, ''); + $this->assertEquals($response->status_code, 100); + // Validate the status + $application = factory(Application::class)->states('draft')->create(); + $ws = new WsBase(); + $response = (object) $ws->pauseCase($application->APP_UID, 0, ''); + $this->assertEquals($response->status_code, 100); + // Validate the index + $application = factory(Application::class)->states('todo')->create(); + $ws = new WsBase(); + $response = (object) $ws->pauseCase($application->APP_UID, '', ''); + $this->assertEquals($response->status_code, 100); + // Validate the user + $application = factory(Application::class)->states('todo')->create(); + $delegation = factory(Delegation::class)->states('foreign_keys')->create([ + 'APP_NUMBER' => $application->APP_NUMBER, + 'APP_UID' => $application->APP_UID, + ]); + $ws = new WsBase(); + $response = (object) $ws->pauseCase($application->APP_UID, $delegation->DEL_INDEX, ''); + $this->assertEquals($response->status_code, 100); + // If needs to validate the current user + $user = factory(User::class)->create(); + $response = (object) $ws->pauseCase($application->APP_UID, $delegation->DEL_INDEX, $user->USR_UID, null, true); + $this->assertEquals($response->status_code, 100); + // Validate if status is closed + $application = factory(Application::class)->states('todo')->create(); + $delegation = factory(Delegation::class)->states('foreign_keys')->create([ + 'APP_NUMBER' => $application->APP_NUMBER, + 'APP_UID' => $application->APP_UID, + 'DEL_THREAD_STATUS' => 'CLOSED', + 'DEL_INDEX' => 2, + ]); + $ws = new WsBase(); + $response = (object) $ws->pauseCase($application->APP_UID, $delegation->DEL_INDEX, $delegation->USR_UID, null); + $this->assertEquals($response->status_code, 100); + // Validate if the case is paused + $application = factory(Application::class)->states('todo')->create(); + $delegation = factory(Delegation::class)->states('foreign_keys')->create([ + 'APP_NUMBER' => $application->APP_NUMBER, + 'APP_UID' => $application->APP_UID, + ]); + factory(AppDelay::class)->create([ + 'APP_DELEGATION_USER' => $delegation->USR_UID, + 'PRO_UID' => $delegation->PRO_UID, + 'APP_NUMBER' => $delegation->APP_NUMBER, + 'APP_DEL_INDEX' => $delegation->DEL_INDEX, + 'APP_DISABLE_ACTION_USER' => 0, + 'APP_TYPE' => 'PAUSE' + ]); + factory(AppThread::class)->create([ + 'APP_UID' => $delegation->APP_UID, + 'APP_THREAD_INDEX' => 1, + 'APP_THREAD_PARENT' => 0, + 'APP_THREAD_STATUS' => 'OPEN', + 'DEL_INDEX' => $delegation->DEL_INDEX + ]); + $ws = new WsBase(); + $response = (object) $ws->pauseCase($application->APP_UID, $delegation->DEL_INDEX, $delegation->USR_UID, null); + // Review the unpaused date + $application = factory(Application::class)->states('todo')->create(); + $delegation = factory(Delegation::class)->states('foreign_keys')->create([ + 'APP_NUMBER' => $application->APP_NUMBER, + 'APP_UID' => $application->APP_UID, + ]); + $ws = new WsBase(); + $response = (object) $ws->pauseCase($delegation->APP_UID, $delegation->DEL_INDEX, $delegation->USR_UID, '06/13/2019 5:35 PM'); + $this->assertEquals($response->status_code, 100); + } + + /** + * Review the required fields in pause case + * + * @covers WsBase::pauseCase() + * @test + */ + public function it_pause_case() + { + $application = factory(Application::class)->states('todo')->create(); + $delegation = factory(Delegation::class)->states('foreign_keys')->create([ + 'APP_NUMBER' => $application->APP_NUMBER, + 'APP_UID' => $application->APP_UID, + 'DEL_THREAD_STATUS' => 'OPEN', + 'DEL_INDEX' => 2, + ]); + factory(AppDelay::class)->create([ + 'APP_DELEGATION_USER' => $delegation->USR_UID, + 'PRO_UID' => $delegation->PRO_UID, + 'APP_NUMBER' => $delegation->APP_NUMBER, + 'APP_DEL_INDEX' => $delegation->DEL_INDEX, + 'APP_DISABLE_ACTION_USER' => 0, + 'APP_TYPE' => 'PAUSE' + ]); + factory(AppThread::class)->create([ + 'APP_UID' => $delegation->APP_UID, + 'APP_THREAD_INDEX' => 1, + 'APP_THREAD_PARENT' => 0, + 'APP_THREAD_STATUS' => 'OPEN', + 'DEL_INDEX' => $delegation->DEL_INDEX + ]); + $ws = new WsBase(); + $response = (object) $ws->pauseCase($delegation->APP_UID, $delegation->DEL_INDEX, $delegation->USR_UID); + $this->assertEquals($response->status_code, 0); + } } diff --git a/tests/unit/workflow/engine/classes/model/OutputDocumentTest.php b/tests/unit/workflow/engine/classes/model/OutputDocumentTest.php index e0187c3d5..f454c8692 100644 --- a/tests/unit/workflow/engine/classes/model/OutputDocumentTest.php +++ b/tests/unit/workflow/engine/classes/model/OutputDocumentTest.php @@ -80,7 +80,11 @@ class OutputDocumentTest extends TestCase $properties['margins']['right'] = 15; $properties['margins']['top'] = 15; $properties['margins']['bottom'] = 15; - $properties['pdfSecurity'] = true; + $properties['pdfSecurity'] = [ + 'openPassword' => true, + 'ownerPassword' => true, + 'permissions' => 'r' + ]; // Call output document $outputDocument = new OutputDocument(); $outputDocument->generateTcpdf( diff --git a/tests/unit/workflow/engine/controllers/PmTablesProxyTest.php b/tests/unit/workflow/engine/controllers/PmTablesProxyTest.php index b153031bd..663f5dd28 100644 --- a/tests/unit/workflow/engine/controllers/PmTablesProxyTest.php +++ b/tests/unit/workflow/engine/controllers/PmTablesProxyTest.php @@ -799,6 +799,7 @@ class PmTablesProxyTest extends TestCase */ public function it_should_test_varchar_id_exception() { + $this->markTestSkipped("Is not compatible with php74."); $reportTable = new ReportTable(); //PM table with a varchar id @@ -976,6 +977,7 @@ class PmTablesProxyTest extends TestCase */ public function it_should_test_destroy_method() { + $this->markTestSkipped("Is not compatible with php74."); $obj = new pmTablesProxy(); //Variable that is sent to the destroy method @@ -998,6 +1000,7 @@ class PmTablesProxyTest extends TestCase */ public function it_should_test_destroy_method_success() { + $this->markTestSkipped("Is not compatible with php74."); $reportTable = new ReportTable(); //PM table with a varchar id diff --git a/tests/unit/workflow/engine/methods/cases/ProxyNewCasesListTest.php b/tests/unit/workflow/engine/methods/cases/ProxyNewCasesListTest.php deleted file mode 100644 index 4be998640..000000000 --- a/tests/unit/workflow/engine/methods/cases/ProxyNewCasesListTest.php +++ /dev/null @@ -1,107 +0,0 @@ -settingUserLogged(); - } - - /** - * This starts a valid user in session with the appropriate permissions. - * @global object $RBAC - */ - private function settingUserLogged() - { - global $RBAC; - - $user = User::where('USR_ID', '=', 1) - ->get() - ->first(); - - $_SESSION['USER_LOGGED'] = $user['USR_UID']; - - $RBAC = RBAC::getSingleton(PATH_DATA, session_id()); - $RBAC->initRBAC(); - $RBAC->loadUserRolePermission('PROCESSMAKER', $_SESSION['USER_LOGGED']); - } - - /** - * It tests the result contains an error - * - * @test - */ - public function it_should_test_there_is_an_error_in_the_proxy_new_cases_list_file() - { - //Turn on output buffering - ob_start(); - - //Call the tested file - require_once PATH_METHODS . 'cases/proxyNewCasesList.php'; - - //Return the contents of the output buffer - $outputBuffer = ob_get_contents(); - //Clean the output buffer and turn off output buffering - ob_end_clean(); - - // This asserts there is an error in the output - $this->assertEquals('{"error":"ID_ACCESS_DENIED"}', $outputBuffer); - } - - /** - * It tests the result contains an empty "search" field - * - * @test - */ - public function it_should_test_the_response_of_the_proxy_new_cases_list_file() - { - $_REQUEST["paged"] = ''; - $_REQUEST['count'] = ''; - $_REQUEST["category"] = ''; - $_REQUEST["process"] = ''; - $_REQUEST["search"] = 'fsfaefwa'; - $_REQUEST["filter"] = ''; - $_REQUEST["dateFrom"] = ''; - $_REQUEST["dateTo"] = ''; - $_REQUEST["start"] = ''; - $_REQUEST["limit"] = ''; - $_REQUEST['sort'] = 'ASC'; - $_REQUEST["dir"] = ''; - $_REQUEST["action"] = 'todo'; - $_REQUEST["user"] = ''; - $_REQUEST["list"] = 'inbox'; - $_REQUEST["filterStatus"] = ''; - $_REQUEST['openApplicationUid'] = ''; - - //Turn on output buffering - ob_start(); - - //Call the tested file - require_once PATH_METHODS . 'cases/proxyNewCasesList.php'; - - //Return the contents of the output buffer - $outputBuffer = ob_get_contents(); - - //Clean the output buffer and turn off output buffering - ob_end_clean(); - - $result = json_decode($outputBuffer, true); - - //This asserts that the search parameter has an empty value - $this->assertEmpty($result['filters']['search']); - } -} \ No newline at end of file diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/DraftTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/DraftTest.php index 87f4f25eb..be701682b 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/DraftTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/DraftTest.php @@ -31,6 +31,7 @@ class DraftTest extends TestCase { parent::setUp(); Delegation::truncate(); + Application::truncate(); } /** diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/ParticipatedTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/ParticipatedTest.php index 60f4b3e5b..0d90d7148 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/ParticipatedTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/ParticipatedTest.php @@ -24,6 +24,8 @@ class ParticipatedTest extends TestCase public function setUp() { parent::setUp(); + Delegation::truncate(); + Application::truncate(); } /** diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/UnassignedTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/UnassignedTest.php index 20e0b011f..08e09d9a9 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/UnassignedTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/UnassignedTest.php @@ -38,6 +38,7 @@ class UnassignedTest extends TestCase parent::setUp(); Delegation::truncate(); Groupwf::truncate(); + Application::truncate(); } /** diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/VariableTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/VariableTest.php index ed9935a66..f71211f80 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/VariableTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/VariableTest.php @@ -5,8 +5,10 @@ namespace ProcessMaker\BusinessModel; use Exception; use G; use ProcessMaker\BusinessModel\Variable; +use ProcessMaker\Model\AdditionalTables; use ProcessMaker\Model\Application; use ProcessMaker\Model\Dynaform; +use ProcessMaker\Model\Fields; use ProcessMaker\Model\Process; use ProcessMaker\Model\ProcessVariables; use Tests\TestCase; @@ -16,7 +18,6 @@ use Tests\TestCase; */ class VariableTest extends TestCase { - /** * Test it create variables related to the process * @@ -272,4 +273,30 @@ class VariableTest extends TestCase $variable = new Variable(); $result = $variable->executeSqlControl(null, []); } + + /** + * This verify the exception + * @test + * @covers \ProcessMaker\BusinessModel\Variable::throwExceptionIfVariableIsAssociatedAditionalTable() + */ + public function it_should_test_exception_when_a_variable_is_related_table() + { + //assert + $this->expectException(Exception::class); + // Create process variable + $variable = factory(ProcessVariables::class)->create(); + $result = ProcessVariables::getVariable($variable->VAR_UID); + $this->assertNotEmpty($result); + // Create tables + $table = factory(AdditionalTables::class)->create([ + 'PRO_UID' => $variable->PRO_UID, + ]); + // Create fields + $fields = factory(Fields::class)->create([ + 'ADD_TAB_UID' => $table->ADD_TAB_UID, + 'FLD_NAME' => $variable->VAR_NAME, + ]); + $variable = new Variable(); + $res = $variable->throwExceptionIfVariableIsAssociatedAditionalTable($variable->VAR_UID); + } } diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Model/AdditionalTablesTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Model/AdditionalTablesTest.php index 1b4e38aa3..6ff4e3f4a 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Model/AdditionalTablesTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Model/AdditionalTablesTest.php @@ -44,6 +44,31 @@ class AdditionalTablesTest extends TestCase $this->assertCount(1, $table->offline([$table->ADD_TAB_OFFLINE])->get()); } + /** + * Test scope query to get the offline tables + * + * @covers \ProcessMaker\Model\AdditionalTables::scopeProcess() + * @test + */ + public function it_filter_process() + { + $table = factory(AdditionalTables::class)->create(); + $this->assertCount(1, $table->process($table->PRO_UID)->get()); + } + + /** + * Test scope query to get tables related to the process + * + * @covers \ProcessMaker\Model\AdditionalTables::getTables() + * @test + */ + public function it_get_tables_related_to_process() + { + $table = factory(AdditionalTables::class)->create(); + $result = AdditionalTables::getTables($table->PRO_UID); + $this->assertNotEmpty($result); + } + /** * Test get the structure of offline tables * diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Model/DelegationTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Model/DelegationTest.php index 375975266..ddd15aa44 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Model/DelegationTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Model/DelegationTest.php @@ -11,6 +11,7 @@ use ProcessMaker\Model\AppAssignSelfServiceValue; use ProcessMaker\Model\AppAssignSelfServiceValueGroup; use ProcessMaker\Model\AppDelay; use ProcessMaker\Model\Application; +use ProcessMaker\Model\AppThread; use ProcessMaker\Model\Delegation; use ProcessMaker\Model\GroupUser; use ProcessMaker\Model\Groupwf; @@ -37,8 +38,9 @@ class DelegationTest extends TestCase public function setUp() { parent::setUp(); - Application::truncate(); Delegation::truncate(); + AppThread::truncate(); + Application::truncate(); } /** diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Model/FieldsTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Model/FieldsTest.php index 9a629c24c..4bac32be7 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Model/FieldsTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Model/FieldsTest.php @@ -42,4 +42,19 @@ class FieldsTest extends TestCase $result = Fields::getFields($fields->ADD_TAB_UID); $this->assertNotEmpty($result); } + + /** + * Test scope and search a field related to the specific ADD_TAB_UID + * + * @covers \ProcessMaker\Model\Fields::scopeField() + * @covers \ProcessMaker\Model\Fields::scopeFieldOrLabel() + * @covers \ProcessMaker\Model\Fields::searchVariable() + * @test + */ + public function it_search_field() + { + $fields = factory(Fields::class)->create(); + $result = Fields::searchVariable($fields->ADD_TAB_UID, $fields->FLD_NAME); + $this->assertNotEmpty($result); + } } diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Model/ProcessVariablesTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Model/ProcessVariablesTest.php index fcdbae846..bbe19a0c4 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Model/ProcessVariablesTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Model/ProcessVariablesTest.php @@ -54,6 +54,19 @@ class ProcessVariablesTest extends TestCase $this->assertEquals($process[0]['PRO_UID'], $result[1]['PRJ_UID']); } + /** + * Test it return a variable related to the VAR_UID + * + * @covers \ProcessMaker\Model\ProcessVariables::getVariable() + * @test + */ + public function it_get_variable() + { + $table = factory(ProcessVariables::class)->create(); + $result = ProcessVariables::getVariable($table->VAR_UID); + $this->assertNotEmpty($result); + } + /** * Test it return the variables related to the PRO_ID * @@ -76,6 +89,8 @@ class ProcessVariablesTest extends TestCase /** * Test it return the variables by type related to the PRO_ID * + * @covers \ProcessMaker\Model\ProcessVariables::scopeProcessId() + * @covers \ProcessMaker\Model\ProcessVariables::scopeTypeId() * @covers \ProcessMaker\Model\ProcessVariables::getVariablesByType() * @test */ diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Services/Api/CasesTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Services/Api/CasesTest.php index f20ac2124..39aa594aa 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Services/Api/CasesTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Services/Api/CasesTest.php @@ -113,7 +113,7 @@ class CasesTest extends TestCase $rest = $this->initializeRestApi($user->USR_UID); $rest->apiMethodInfo->methodName = 'doGetCaseVariables'; $rest->apiMethodInfo->arguments = [ - 'app_uid' => 0, + 'appUid' => 0, 'dyn_uid' => 1, 'app_index' => 2 ]; @@ -156,7 +156,7 @@ class CasesTest extends TestCase $rest = $this->initializeRestApi($user->USR_UID); $rest->apiMethodInfo->methodName = 'doGetCaseVariables'; $rest->apiMethodInfo->arguments = [ - 'app_uid' => 0, + 'appUid' => 0, 'dyn_uid' => 1, 'app_index' => 2 ]; @@ -199,7 +199,7 @@ class CasesTest extends TestCase $rest = $this->initializeRestApi(RBAC::GUEST_USER_UID); $rest->apiMethodInfo->methodName = 'doGetCaseVariables'; $rest->apiMethodInfo->arguments = [ - 'app_uid' => 0, + 'appUid' => 0, 'dyn_uid' => 1, 'app_index' => 2 ]; diff --git a/workflow/engine/bin/tasks/cliListIds.php b/workflow/engine/bin/tasks/cliListIds.php index 6bc7fa0c8..3c4f1d5ca 100644 --- a/workflow/engine/bin/tasks/cliListIds.php +++ b/workflow/engine/bin/tasks/cliListIds.php @@ -7,8 +7,8 @@ function cliListIds($command, $args) $workspaces = get_workspaces_from_args($command); foreach ($workspaces as $index => $workspace) { - $hostPort1 = explode(":", $workspace->dbInfo['DB_HOST']); - $hostPort = $hostPort1[0] . (isset($hostPort[1]) ? ";port=" . $hostPort[1] : ""); + $hostPort = explode(":", $workspace->dbInfo['DB_HOST']); + $hostPort = $hostPort[0] . (isset($hostPort[1]) ? ";port=" . $hostPort[1] : ""); $connectionString = sprintf( "%s:host=%s;dbname=%s", $workspace->dbInfo['DB_ADAPTER'], diff --git a/workflow/engine/classes/Cases.php b/workflow/engine/classes/Cases.php index 51f141a44..90b316da7 100644 --- a/workflow/engine/classes/Cases.php +++ b/workflow/engine/classes/Cases.php @@ -4615,7 +4615,6 @@ class Cases $newData['DEL_PREVIOUS'] = $fieldsDel['DEL_PREVIOUS']; $newData['DEL_TYPE'] = $fieldsDel['DEL_TYPE']; $newData['DEL_PRIORITY'] = $fieldsDel['DEL_PRIORITY']; - $newData['DEL_DELEGATE_DATE'] = $fieldsDel['DEL_DELEGATE_DATE']; $newData['USR_UID'] = $newUserUid; $newData['DEL_INIT_DATE'] = null; $newData['DEL_FINISH_DATE'] = null; diff --git a/workflow/engine/classes/Processes.php b/workflow/engine/classes/Processes.php index 168c07fe4..3223493d5 100644 --- a/workflow/engine/classes/Processes.php +++ b/workflow/engine/classes/Processes.php @@ -2923,7 +2923,7 @@ class Processes foreach ($aStepSupervisor as $key => $row) { $oStepSupervisor = new StepSupervisor(); if ($oStepSupervisor->Exists($row['STEP_UID'])) { - $oStepSupervisor->update($row['STEP_UID']); + $oStepSupervisor->update($row); } else { $oStepSupervisor->create($row); } diff --git a/workflow/engine/classes/ReportTables.php b/workflow/engine/classes/ReportTables.php index 671f0e832..e9590b888 100644 --- a/workflow/engine/classes/ReportTables.php +++ b/workflow/engine/classes/ReportTables.php @@ -39,7 +39,7 @@ class ReportTables * * @access public * - * @param string $$sRepTabUid + * @param string $sRepTabUid * * @return void */ @@ -206,125 +206,167 @@ class ReportTables */ public function populateTable($tableName, $connectionShortName = 'report', $type = 'NORMAL', $fields = [], $proUid = '', $grid = '') { - $config = System::getSystemConfiguration(); - $reportTableBatchRegeneration = $config['report_table_batch_regeneration']; - - $tableName = $this->sPrefix . $tableName; - //we have to do the propel connection - $database = $this->chooseDB($connectionShortName); - $connection = Propel::getConnection($database); - if ($type == 'GRID') { - $aux = explode('-', $grid); - $grid = $aux[0]; - } - $case = new Cases(); try { - $applicationTableName = (new Application())->getTable(); - $deleteQuery = "TRUNCATE TABLE `{$tableName}` "; - DB::delete($deleteQuery); + // Initializing variables + $tableName = $this->sPrefix . $tableName; + if ($type == 'GRID') { + $aux = explode('-', $grid); + $grid = $aux[0]; + } + $n = Application::count(); - $applications = Application::getByProUid($proUid); - $i = 1; - $queryValues = ""; - $numberRecords = $reportTableBatchRegeneration; - $n = count($applications); - foreach ($applications as $application) { - $appData = $case->unserializeData($application->APP_DATA); - if ($type == 'NORMAL') { - $query = 'INSERT INTO `' . $tableName . '` ('; - $query .= '`APP_UID`,`APP_NUMBER`'; - foreach ($fields as $field) { - $query .= ',`' . $field['sFieldName'] . '`'; - } - $headQuery = $query . ") VALUES "; - $query = "('" . $application->APP_UID . "'," . $application->APP_NUMBER; - foreach ($fields as $field) { - switch ($field['sType']) { - case 'number': - $query .= ',' . (isset($appData[$field['sFieldName']]) ? (float) str_replace(',', '', $appData[$field['sFieldName']]) : '0'); - break; - case 'char': - case 'text': - if (!isset($appData[$field['sFieldName']])) { - $appData[$field['sFieldName']] = ''; - } - $string = $appData[$field['sFieldName']]; - if (is_array($string)) { - $string = implode(",", $string); - } - $query .= ",'" . (isset($appData[$field['sFieldName']]) ? mysqli_real_escape_string($connection->getResource(), $string) : '') . "'"; - break; - case 'date': - $value = (isset($appData[$field['sFieldName']]) && trim($appData[$field['sFieldName']])) != '' ? "'" . $appData[$field['sFieldName']] . "'" : 'NULL'; - $query .= "," . $value; - break; - } - } - $query .= ')'; - $queryValues = $queryValues . $query . ","; - if ($i % $numberRecords === 0 || $i === $n) { - $queryValues = rtrim($queryValues, ","); - $query = $headQuery . $queryValues; - $queryValues = ""; + // Truncate report table + DB::delete("TRUNCATE TABLE `{$tableName}` "); - //add to queue - $closure = function() use($query) { - DB::insert($query); - }; - JobsManager::getSingleton()->dispatch(GenerateReportTable::class, $closure); - } - } else { - if (isset($appData[$grid])) { - $query = 'INSERT INTO `' . $tableName . '` ('; - $query .= '`APP_UID`,`APP_NUMBER`,`ROW`'; - foreach ($fields as $field) { - $query .= ',`' . $field['sFieldName'] . '`'; - } - $headQuery = $query . ") VALUES "; - foreach ($appData[$grid] as $indexRow => $gridRow) { - $query = "('" . $application->APP_UID . "'," . (int) $application->APP_NUMBER . ',' . $indexRow; - foreach ($fields as $field) { - switch ($field['sType']) { - case 'number': - $query .= ',' . (isset($gridRow[$field['sFieldName']]) ? (float) str_replace(',', '', $gridRow[$field['sFieldName']]) : '0'); - break; - case 'char': - case 'text': - if (!isset($gridRow[$field['sFieldName']])) { - $gridRow[$field['sFieldName']] = ''; - } - $stringEscape = mysqli_real_escape_string($connection->getResource(), $gridRow[$field['sFieldName']]); - $query .= ",'" . (isset($gridRow[$field['sFieldName']]) ? $stringEscape : '') . "'"; - break; - case 'date': - $value = (isset($gridRow[$field['sFieldName']]) && trim($gridRow[$field['sFieldName']])) != '' ? "'" . $gridRow[$field['sFieldName']] . "'" : 'NULL'; - $query .= "," . $value; - break; - } - } - $query .= ')'; - $queryValues = $queryValues . $query . ","; - } - if ($i % $numberRecords === 0 || $i === $n) { - $queryValues = rtrim($queryValues, ","); - $query = $headQuery . $queryValues; - $queryValues = ""; + // Batch process + $config = System::getSystemConfiguration(); + $reportTableBatchRegeneration = $config['report_table_batch_regeneration']; - //add to queue - $closure = function() use($query) { - DB::insert($query); - }; - JobsManager::getSingleton()->dispatch(GenerateReportTable::class, $closure); - } - } - } - $i = $i + 1; + // Initializing more variables + $size = $n; + $start = 0; + $limit = $reportTableBatchRegeneration; + + // Creating jobs + for ($i = 1; $start < $size; $i++) { + $closure = function () use ($tableName, $connectionShortName, $type, $fields, $proUid, $grid, $start, $limit) { + $this->generateOldReportTable($tableName, $connectionShortName, $type, $fields, $proUid, $grid, $start, $limit); + }; + JobsManager::getSingleton()->dispatch(GenerateReportTable::class, $closure); + $start = $i * $limit; } } catch (Exception $oError) { throw ($oError); } } + /** + * Generate old report table of application. + * + * @param string $tableName + * @param string $connectionShortName + * @param string $type + * @param array $fields + * @param string $proUid + * @param string $grid + * @param int $start + * @param int $limit + */ + public function generateOldReportTable(string $tableName, string $connectionShortName = 'report', string $type = 'NORMAL', array $fields = [], string $proUid = '', string $grid = '', int $start = 0, int $limit = 0) + { + //we have to do the propel connection + $database = $this->chooseDB($connectionShortName); + $connection = Propel::getConnection($database); + + $case = new Cases(); + + // Select cases of the related process, ordered by APP_NUMBER + $applications = Application::query() + ->where('PRO_UID', '=', $proUid) + ->where('APP_NUMBER', '>', 0) + ->orderBy('APP_NUMBER', 'asc') + ->offset($start) + ->limit($limit) + ->get(); + + foreach ($applications as $application) { + $appData = $case->unserializeData($application->APP_DATA); + if ($type == 'NORMAL') { + $fieldsSection = "`APP_UID`, `APP_NUMBER`"; + $valuesSection = "'{$application->APP_UID}', {$application->APP_NUMBER}"; + $this->buildAndExecuteQuery($fieldsSection, $valuesSection, $fields, $appData, $connection, $tableName, $application); + } else { + if (isset($appData[$grid])) { + foreach ($appData[$grid] as $indexRow => $gridRow) { + $fieldsSection = "`APP_UID`, `APP_NUMBER`, `ROW`"; + $valuesSection = "'{$application->APP_UID}', {$application->APP_NUMBER}, {$indexRow}"; + $this->buildAndExecuteQuery($fieldsSection, $valuesSection, $fields, $gridRow, $connection, $tableName, $application); + } + } + } + } + } + + /** + * Build and execute query. + * + * @param string $fieldsSection + * @param string $valuesSection + * @param array $fields + * @param array $appData + * @param MySQLiConnection $connection + * @param string $tableName + * @param Application $application + */ + private function buildAndExecuteQuery(string $fieldsSection, string $valuesSection, array $fields, array $appData, MySQLiConnection $connection, string $tableName, Application $application) + { + try { + $fieldsSection = $this->buildFieldsSection($fieldsSection, $fields); + $valuesSection = $this->buildValuesSection($valuesSection, $fields, $appData, $connection); + $query = "INSERT INTO `{$tableName}` ({$fieldsSection}) VALUES ({$valuesSection});"; + DB::insert($query); + } catch (Exception $e) { + $message = "ReportTables::buildAndExecuteQuery"; + $context = [ + "message" => $e->getMessage(), + "tableName" => $tableName, + "appUid" => $application->APP_UID + ]; + Log::channel(':sqlExecution')->critical($message, Bootstrap::context($context)); + } + } + + /** + * Build fields section for query string. + * + * @param string $fieldsSection + * @param array $fields + * @return string + */ + private function buildFieldsSection(string $fieldsSection = "", array $fields): string + { + foreach ($fields as $field) { + $fieldsSection = $fieldsSection . ", `{$field['sFieldName']}`"; + } + return $fieldsSection; + } + + /** + * Build values section for query string. + * + * @param string $valuesSection + * @param array $fields + * @param array $appData + * @param MySQLiConnection $connection + * @return string + */ + private function buildValuesSection(string $valuesSection = "", array $fields, array $appData, MySQLiConnection $connection): string + { + foreach ($fields as $field) { + switch ($field['sType']) { + case 'number': + $valuesSection .= ',' . (isset($appData[$field['sFieldName']]) ? (float) str_replace(',', '', $appData[$field['sFieldName']]) : '0'); + break; + case 'char': + case 'text': + if (!isset($appData[$field['sFieldName']])) { + $appData[$field['sFieldName']] = ''; + } + $string = $appData[$field['sFieldName']]; + if (is_array($string)) { + $string = implode(",", $string); + } + $valuesSection .= ",'" . (isset($appData[$field['sFieldName']]) ? mysqli_real_escape_string($connection->getResource(), $string) : '') . "'"; + break; + case 'date': + $value = (isset($appData[$field['sFieldName']]) && trim($appData[$field['sFieldName']])) != '' ? "'" . $appData[$field['sFieldName']] . "'" : 'NULL'; + $valuesSection .= "," . $value; + break; + } + } + return $valuesSection; + } + /** * Function getTableVars * @@ -384,7 +426,7 @@ class ReportTables $this->dropTable($aFields['REP_TAB_NAME'], $aFields['REP_TAB_CONNECTION']); $oCriteria = new Criteria('workflow'); $oCriteria->add(ReportVarPeer::REP_TAB_UID, $sRepTabUid); - $oDataset = ReportVarPeer::doDelete($oCriteria); + ReportVarPeer::doDelete($oCriteria); $oReportTable->remove($sRepTabUid); } } catch (Exception $oError) { @@ -676,7 +718,7 @@ class ReportTables } else { //remove old rows from database $sqlDelete = 'DELETE FROM `' . $aRow['REP_TAB_NAME'] . "` WHERE APP_UID = '" . $sApplicationUid . "'"; - $rsDelete = $stmt->executeQuery($sqlDelete); + $stmt->executeQuery($sqlDelete); $aAux = explode('-', $aRow['REP_TAB_GRID']); if (isset($aFields[$aAux[0]])) { @@ -735,7 +777,6 @@ class ReportTables public function tableExist() { $bExists = true; - $sDataBase = 'database_' . strtolower(DB_ADAPTER); $oDataBase = new database(); $bExists = $oDataBase->reportTableExist(); diff --git a/workflow/engine/classes/WorkspaceTools.php b/workflow/engine/classes/WorkspaceTools.php index 1d63bfe4d..b6ec6a83e 100644 --- a/workflow/engine/classes/WorkspaceTools.php +++ b/workflow/engine/classes/WorkspaceTools.php @@ -455,9 +455,25 @@ class WorkspaceTools $this->dbRbacUser = $values["DB_RBAC_USER"]; $this->dbRbacPass = $values["DB_RBAC_PASS"]; + $this->setDataBaseConnectionPropertiesForEloquent(); return $this->dbInfo = $values; } + /** + * This used for eloquent model. + */ + public function setDataBaseConnectionPropertiesForEloquent(): void + { + $dbHost = explode(':', $this->dbHost); + config(['database.connections.workflow.host' => $dbHost[0]]); + config(['database.connections.workflow.database' => $this->dbName]); + config(['database.connections.workflow.username' => $this->dbUser]); + config(['database.connections.workflow.password' => $this->dbPass]); + if (count($dbHost) > 1) { + config(['database.connections.workflow.port' => $dbHost[1]]); + } + } + private function resetDBInfoCallback($matches) { /* This function changes the values of defines while keeping their formatting @@ -4296,22 +4312,20 @@ class WorkspaceTools WHERE AD.APP_NUMBER = 0"); $con->commit(); - // Populating APP_MESSAGE.TAS_ID AND APP_MESSAGE.PRO_ID - CLI::logging("-> Populating APP_MESSAGE.TAS_ID and APP_MESSAGE.PRO_ID \n"); + // Populating APP_MESSAGE.TAS_ID + CLI::logging("-> Populating APP_MESSAGE.TAS_ID \n"); $con->begin(); $stmt = $con->createStatement(); $rs = $stmt->executeQuery("UPDATE APP_MESSAGE AS AM INNER JOIN ( - SELECT APP_DELEGATION.TAS_ID, - APP_DELEGATION.APP_NUMBER, - APP_DELEGATION.TAS_UID, - APP_DELEGATION.DEL_INDEX, - APP_DELEGATION.PRO_ID + SELECT APP_DELEGATION.APP_NUMBER, + APP_DELEGATION.DEL_INDEX, + APP_DELEGATION.TAS_ID FROM APP_DELEGATION ) AS DEL ON (AM.APP_NUMBER = DEL.APP_NUMBER AND AM.DEL_INDEX = DEL.DEL_INDEX) - SET AM.TAS_ID = DEL.TAS_ID, AM.PRO_ID = DEL.PRO_ID - WHERE AM.TAS_ID = 0 AND AM.PRO_ID = 0 AND AM.APP_NUMBER != 0 AND AM.DEL_INDEX != 0"); + SET AM.TAS_ID = DEL.TAS_ID + WHERE AM.TAS_ID = 0 AND AM.APP_NUMBER != 0 AND AM.DEL_INDEX != 0"); $con->commit(); // Populating APP_MESSAGE.PRO_ID @@ -5086,14 +5100,6 @@ class WorkspaceTools ) { // Initialize DB connections $this->initPropel(); - $dbHost = explode(':', $this->dbHost); - config(['database.connections.workflow.host' => $dbHost[0]]); - config(['database.connections.workflow.database' => $this->dbName]); - config(['database.connections.workflow.username' => $this->dbUser]); - config(['database.connections.workflow.password' => $this->dbPass]); - if (count($dbHost) > 1) { - config(['database.connections.workflow.port' => $dbHost[1]]); - } // Get fields and some specific field types $fields = []; @@ -5198,7 +5204,6 @@ class WorkspaceTools $message = 'Sql Execution'; Log::channel(':sqlExecution')->critical($message, Bootstrap::context($context)); } - unset($obj); } } else { try { diff --git a/workflow/engine/classes/WsBase.php b/workflow/engine/classes/WsBase.php index 64e219d30..46389da51 100644 --- a/workflow/engine/classes/WsBase.php +++ b/workflow/engine/classes/WsBase.php @@ -3263,12 +3263,14 @@ class WsBase /** * Pause case * - * @param string caseUid : ID of the case. - * @param int delIndex : Delegation index of the case. - * @param string userUid : The unique ID of the user who will pause the case. - * @param string unpauseDate : Optional parameter. The date in the format "yyyy-mm-dd" indicating when to unpause + * @param string $caseUid: ID of the case. + * @param int $delIndex: Delegation index of the case. + * @param string $userUid: The unique ID of the user who will pause the case. + * @param string $unpauseDate: Optional parameter. The date in the format "yyyy-mm-dd" indicating when to unpause * the case. + * @param boolean $checkUser: Check if needs to validate if the action will enable only for current user * + * @see Ajax::pauseCase() * @see workflow/engine/classes/class.pmFunctions.php::PMFPauseCase() * @see workflow/engine/methods/services/soap2.php::pauseCase() * @@ -3276,7 +3278,7 @@ class WsBase * * @return $result will return an object */ - public function pauseCase($caseUid, $delIndex, $userUid, $unpauseDate = null) + public function pauseCase($caseUid, $delIndex, $userUid, $unpauseDate = null, $checkUser = false) { $g = new G(); @@ -3316,6 +3318,15 @@ class WsBase return $result; } + // If needs to validate the current user + if ($checkUser) { + $currentUsrUid = Delegation::getCurrentUser($caseInfo['APP_NUMBER'], $delIndex); + if ($currentUsrUid !== $userUid) { + $result = new WsResponse(100, G::LoadTranslation('ID_CASE_ASSIGNED_ANOTHER_USER')); + $g->sessionVarRestore(); + return $result; + } + } // Validate if status is closed $appDelegation = new AppDelegation(); $rows = $appDelegation->LoadParallel($caseUid, $delIndex); diff --git a/workflow/engine/classes/class.pmFunctions.php b/workflow/engine/classes/class.pmFunctions.php index 5da34277b..04f4d6d20 100644 --- a/workflow/engine/classes/class.pmFunctions.php +++ b/workflow/engine/classes/class.pmFunctions.php @@ -241,14 +241,15 @@ function executeQuery($sqlStatement, $dbConnectionUID = 'workflow', $parameters try { try { - (new SqlBlacklist($sqlStatement))->validate(); + $sqlStatementCheck = trim($sqlStatement); + $sqlStatementCheck = str_replace('(', '', $sqlStatementCheck); + (new SqlBlacklist($sqlStatementCheck))->validate(); } catch (Exception $e) { G::SendTemporalMessage($e->getMessage(), 'error', 'labels'); throw new SQLException($e->getMessage()); } - $statement = trim($sqlStatement); - $statement = str_replace('(', '', $statement); + $statement = $sqlStatementCheck; $result = false; // Check to see if we're not running oracle, which is usually a safe default @@ -1159,10 +1160,11 @@ function WSDerivateCase ($caseId, $delIndex) * @param string(32) | $value1 | Value of the first variable | The value of the first variable to be sent to the created case. * @param string(32) | $name2 | Name of the second variable | The name of the second variable to be sent to the created case. * @param string(32) | $value2 | Value of the second variable | The value of the second variable to be sent to the created case. + * @param string(32) | $taskId = '' | Task ID | The unique ID for the task * @return array | $fields | WS Response Associative Array | A WS Response associative array. * */ -function WSNewCaseImpersonate ($processId, $userId, $name1, $value1, $name2, $value2) +function WSNewCaseImpersonate ($processId, $userId, $name1, $value1, $name2, $value2, $taskId = '') { $client = WSOpen(); @@ -1176,14 +1178,17 @@ function WSNewCaseImpersonate ($processId, $userId, $name1, $value1, $name2, $va $v2->name = $name2; $v2->value = $value2; - $variables = array ($v1,$v2 - ); + $variables = [$v1,$v2]; - $params = array ("sessionId" => $sessionId,"processId" => $processId,"userId" => $userId,"variables" => $variables - ); + $params = [ + "sessionId" => $sessionId, + "processId" => $processId, + "taskId" => $taskId, + "userId" => $userId, + "variables" => $variables + ]; - $result = $client->__soapCall( "NewCaseImpersonate", array ($params - ) ); + $result = $client->__soapCall("NewCaseImpersonate", [$params]); $fields["status_code"] = $result->status_code; $fields["message"] = $result->message; @@ -3201,16 +3206,16 @@ function PMFUnCancelCase($caseUID, $userUID) * @name PMFDynaFormFields * @label PMF DynaForm Fields * @param string | $dynUid | Dynaform ID | Id of the dynaform - * @param string | $appUid | Case ID | Id of the case - * @param int | $delIndex | Delegation index | Delegation index for case + * @param string | $appUid = '' | Case ID | Id of the case + * @param int | $delIndex = 0| Delegation index | Delegation index for case * @return array | $fields | List of fields | Return a list of fields */ -function PMFDynaFormFields($dynUid, $appUid = false, $delIndex = 0) +function PMFDynaFormFields($dynUid, $appUid = '', $delIndex = 0) { - $fields = array(); - $data = array(); + $fields = []; + $data = []; - if ($appUid !== false) { + if (!empty($appUid)) { if ($delIndex < 0) { throw new Exception(G::LoadTranslation('ID_INVALID_DELEGATION_INDEX_FOR_CASE') . "'" . $appUid . "'."); } @@ -3252,6 +3257,7 @@ function PMFDynaFormFields($dynUid, $appUid = false, $delIndex = 0) $fields[] = $value; } } + return $fields; } diff --git a/workflow/engine/classes/model/AppDelegation.php b/workflow/engine/classes/model/AppDelegation.php index 71a40b45d..f2d86947c 100644 --- a/workflow/engine/classes/model/AppDelegation.php +++ b/workflow/engine/classes/model/AppDelegation.php @@ -808,7 +808,7 @@ class AppDelegation extends BaseAppDelegation return $rs->getRow(); } - public function getCurrentIndex($appUid) + public static function getCurrentIndex($appUid) { $oCriteria = new Criteria(); $oCriteria->addSelectColumn(AppDelegationPeer::DEL_INDEX); diff --git a/workflow/engine/classes/model/CaseTrackerObject.php b/workflow/engine/classes/model/CaseTrackerObject.php index cd433323c..d806c32f1 100644 --- a/workflow/engine/classes/model/CaseTrackerObject.php +++ b/workflow/engine/classes/model/CaseTrackerObject.php @@ -130,8 +130,8 @@ class CaseTrackerObject extends BaseCaseTrackerObject ) ); $oDataset->next(); } - } catch (Exception $oException) { - throw $Exception; + } catch (Exception $e) { + throw $e; } } @@ -169,7 +169,7 @@ class CaseTrackerObject extends BaseCaseTrackerObject * * @return array */ - public function verifyDynaformAssigCaseTracker ($dynUid, $proUid) + public static function verifyDynaformAssigCaseTracker ($dynUid, $proUid) { $res = array(); $oCriteria = new Criteria(); diff --git a/workflow/engine/classes/model/Dynaform.php b/workflow/engine/classes/model/Dynaform.php index 89979a570..3554a9f80 100644 --- a/workflow/engine/classes/model/Dynaform.php +++ b/workflow/engine/classes/model/Dynaform.php @@ -705,7 +705,7 @@ class Dynaform extends BaseDynaform * * @return array */ - public function verifyDynaformAssignDynaform ($dynUid, $proUid) + public static function verifyDynaformAssignDynaform ($dynUid, $proUid) { $res = array(); $oCriteria = new Criteria(); diff --git a/workflow/engine/classes/model/ObjectPermission.php b/workflow/engine/classes/model/ObjectPermission.php index 29b7ca1bb..b86142b6f 100644 --- a/workflow/engine/classes/model/ObjectPermission.php +++ b/workflow/engine/classes/model/ObjectPermission.php @@ -141,7 +141,7 @@ class ObjectPermission extends BaseObjectPermission * * @return array */ - public function verifyDynaformAssigObjectPermission ($dynUid, $proUid) + public static function verifyDynaformAssigObjectPermission ($dynUid, $proUid) { $res = array(); $oCriteria = new Criteria(); diff --git a/workflow/engine/classes/model/Process.php b/workflow/engine/classes/model/Process.php index a9ad04ba2..c6d1f9aa1 100644 --- a/workflow/engine/classes/model/Process.php +++ b/workflow/engine/classes/model/Process.php @@ -147,6 +147,7 @@ class Process extends BaseProcess $this->setProSubCategory(''); $this->setProIndustry(''); $this->setProCreateDate(date("Y-m-d H:i:s")); + $this->setProUpdateDate($this->getProCreateDate()); $this->setProCreateUser($aData['USR_UID']); $this->setProHeight(5000); $this->setProWidth(10000); diff --git a/workflow/engine/classes/model/Step.php b/workflow/engine/classes/model/Step.php index b8932d45e..743bafc0c 100644 --- a/workflow/engine/classes/model/Step.php +++ b/workflow/engine/classes/model/Step.php @@ -230,8 +230,8 @@ class Step extends BaseStep $oDataset->next(); $aRow = $oDataset->getRow(); return (int) $aRow['POSITION']; - } catch (Exception $oException) { - throw $Exception; + } catch (Exception $exception) { + throw $exception; } } @@ -413,7 +413,7 @@ class Step extends BaseStep * * @return array */ - public function verifyDynaformAssigStep ($dynUid, $proUid) + public static function verifyDynaformAssigStep ($dynUid, $proUid) { $res = array(); $oCriteria = new Criteria(); @@ -432,7 +432,7 @@ class Step extends BaseStep return $res; } - public function getAttribute ($node, $attName) + public static function getAttribute ($node, $attName) { foreach ($node->attributes as $attribute) { diff --git a/workflow/engine/classes/model/StepSupervisor.php b/workflow/engine/classes/model/StepSupervisor.php index 397f7ed74..7960a5184 100644 --- a/workflow/engine/classes/model/StepSupervisor.php +++ b/workflow/engine/classes/model/StepSupervisor.php @@ -166,8 +166,8 @@ class StepSupervisor extends BaseStepSupervisor $oDataset->next(); $aRow = $oDataset->getRow(); return (int) $aRow['POSITION']; - } catch (Exception $oException) { - throw $Exception; + } catch (Exception $e) { + throw $e; } } @@ -189,8 +189,8 @@ class StepSupervisor extends BaseStepSupervisor $oDataset->next(); $aRow = $oDataset->getRow(); return (int) $aRow['POSITION']; - } catch (Exception $oException) { - throw $Exception; + } catch (Exception $e) { + throw $e; } } @@ -217,8 +217,8 @@ class StepSupervisor extends BaseStepSupervisor $this->update( array ('STEP_UID' => $aRow['STEP_UID'],'PRO_UID' => $aRow['PRO_UID'],'STEP_TYPE_OBJ' => $aRow['STEP_TYPE_OBJ'],'STEP_UID_OBJ' => $aRow['STEP_UID_OBJ'],'STEP_POSITION' => $aRow['STEP_POSITION'] - 1 ) ); } - } catch (Exception $oException) { - throw $Exception; + } catch (Exception $e) { + throw $e; } } @@ -254,7 +254,7 @@ class StepSupervisor extends BaseStepSupervisor * * @return array */ - public function verifyDynaformAssigStepSupervisor ($dynUid, $proUid) + public static function verifyDynaformAssigStepSupervisor ($dynUid, $proUid) { $res = array(); $oCriteria = new Criteria(); diff --git a/workflow/engine/classes/model/UsersProperties.php b/workflow/engine/classes/model/UsersProperties.php index 3bb8b6797..8e20454eb 100644 --- a/workflow/engine/classes/model/UsersProperties.php +++ b/workflow/engine/classes/model/UsersProperties.php @@ -195,6 +195,10 @@ class UsersProperties extends BaseUsersProperties $changePassword = 1; } } + //Spaces not supported at the end of passwords + if (substr($password, -1) === " ") { + $listErrors[] = 'ID_PPP_SPACES_NOT_SUPPORTED_AT_THE_END_OF_PASSWORD'; + } if ($changePassword == 1) { $listErrors[] = 'ID_PPP_CHANGE_PASSWORD_AFTER_NEXT_LOGIN'; diff --git a/workflow/engine/content/translations/english/processmaker.en.po b/workflow/engine/content/translations/english/processmaker.en.po index c23f08e16..2aa2d818b 100755 --- a/workflow/engine/content/translations/english/processmaker.en.po +++ b/workflow/engine/content/translations/english/processmaker.en.po @@ -5432,8 +5432,8 @@ msgstr "The process was not downloaded, because the curl extension for php is no # TRANSLATION # LABEL/ID_CURRENT_ASSING_TYPE_WITH_CASES #: LABEL/ID_CURRENT_ASSING_TYPE_WITH_CASES -msgid "The current activity has cases and cannot be deleted" -msgstr "The current activity has cases and cannot be deleted" +msgid "The current activity has cases and cannot be changed" +msgstr "The current activity has cases and cannot be changed" # TRANSLATION # LABEL/ID_CURRENT_BROWSER_NOT_SUPPORTED @@ -7181,6 +7181,36 @@ msgstr "Copy/Import Dynaform" msgid "Select the dynaform you want to copy/import." msgstr "Select the dynaform you want to copy/import." +# TRANSLATION +# LABEL/ID_DYNAFORM_DEPENDS_DYNAFORMS +#: LABEL/ID_DYNAFORM_DEPENDS_DYNAFORMS +msgid "({0}) Depends in dynaform" +msgstr "({0}) Depends in dynaform" + +# TRANSLATION +# LABEL/ID_DYNAFORM_DEPENDS_CASE_TRACKER +#: LABEL/ID_DYNAFORM_DEPENDS_CASE_TRACKER +msgid "({0}) Depends in case traker" +msgstr "({0}) Depends in case traker" + +# TRANSLATION +# LABEL/ID_DYNAFORM_DEPENDS_PERMISSIONS +#: LABEL/ID_DYNAFORM_DEPENDS_PERMISSIONS +msgid "({0}) Depends in permissions" +msgstr "({0}) Depends in permissions" + +# TRANSLATION +# LABEL/ID_DYNAFORM_DEPENDS_STEPS +#: LABEL/ID_DYNAFORM_DEPENDS_STEPS +msgid "({0}) Depends in steps" +msgstr "({0}) Depends in steps" + +# TRANSLATION +# LABEL/ID_DYNAFORM_DEPENDS_STEPS_SUPERVISOR +#: LABEL/ID_DYNAFORM_DEPENDS_STEPS_SUPERVISOR +msgid "({0}) Depends in steps supervisor" +msgstr "({0}) Depends in steps supervisor" + # TRANSLATION # LABEL/ID_DYNAFORM_DOES_NOT_EXIST #: LABEL/ID_DYNAFORM_DOES_NOT_EXIST @@ -22277,6 +22307,12 @@ msgstr "Minimum length" msgid "Numerical Character is required" msgstr "Numerical Character is required" +# TRANSLATION +# LABEL/ID_PPP_SPACES_NOT_SUPPORTED_AT_THE_END_OF_PASSWORD +#: LABEL/ID_PPP_SPACES_NOT_SUPPORTED_AT_THE_END_OF_PASSWORD +msgid "Spaces not supported at the end of password" +msgstr "Spaces not supported at the end of password" + # TRANSLATION # LABEL/ID_PPP_SPECIAL_CHARACTER_REQUIRED #: LABEL/ID_PPP_SPECIAL_CHARACTER_REQUIRED @@ -26027,6 +26063,12 @@ msgstr "You must login again to view the changes. Do you want do it now?" msgid "System Settings" msgstr "System Settings" +# TRANSLATION +# LABEL/ID_SYSTEM_VARIABLES_ARE_PROTECTED +#: LABEL/ID_SYSTEM_VARIABLES_ARE_PROTECTED +msgid "System variables are protected from changes, this request is denied" +msgstr "System variables are protected from changes, this request is denied" + # TRANSLATION # LABEL/ID_TABLE #: LABEL/ID_TABLE @@ -28148,8 +28190,8 @@ msgstr "User Name" # TRANSLATION # LABEL/ID_USER_NAME_ALREADY_EXISTS #: LABEL/ID_USER_NAME_ALREADY_EXISTS -msgid "The User Name with {0}: \"{1}\" already exists." -msgstr "The User Name with {0}: \"{1}\" already exists." +msgid "The User Name '{0}' already exists." +msgstr "The User Name '{0}' already exists." # TRANSLATION # LABEL/ID_USER_NOT_ACTIVE @@ -28496,8 +28538,8 @@ msgstr "Variable for Value Based Assignment" # TRANSLATION # LABEL/ID_VARIABLE_ASSOCIATED_WITH_REPORT_TABLE #: LABEL/ID_VARIABLE_ASSOCIATED_WITH_REPORT_TABLE -msgid "The variable with \"{0}\", it is associated with a report table." -msgstr "The variable with \"{0}\", it is associated with a report table." +msgid "The variable \"{0}\" Is associated with a report table, that requires to be removed first before allowing deleting it." +msgstr "The variable \"{0}\" Is associated with a report table, that requires to be removed first before allowing deleting it."" # TRANSLATION # LABEL/ID_VARIABLE_IN_USE diff --git a/workflow/engine/data/mysql/insert.sql b/workflow/engine/data/mysql/insert.sql index 6a91c72e0..453774339 100755 --- a/workflow/engine/data/mysql/insert.sql +++ b/workflow/engine/data/mysql/insert.sql @@ -57728,7 +57728,7 @@ INSERT INTO TRANSLATION (TRN_CATEGORY,TRN_ID,TRN_LANG,TRN_VALUE,TRN_UPDATE_DATE ( 'LABEL','ID_CRON_STATUS_INACTIVE','en','Inactive','2014-01-15') , ( 'LABEL','ID_CSV_FILE','en','CSV File','2014-01-15') , ( 'LABEL','ID_CURLFUN_ISUNDEFINED','en','The process was not downloaded, because the curl extension for php is not installed','2014-01-15') , -( 'LABEL','ID_CURRENT_ASSING_TYPE_WITH_CASES','en','The current activity has cases and cannot be deleted','2015-12-10') , +( 'LABEL','ID_CURRENT_ASSING_TYPE_WITH_CASES','en','The current activity has cases and cannot be changed','2022-02-11') , ( 'LABEL','ID_CURRENT_BROWSER_NOT_SUPPORTED','en','Your browser is not supported. See the list of supported browsers. List of supported browsers is a link to the wiki page: http://wiki.processmaker.com/3.0/Supported_Browsers','2014-10-22') , ( 'LABEL','ID_CURRENT_LICENSE','en','Current license','2014-09-18') , ( 'LABEL','ID_CURRENT_TASKS','en','Current Task(s) Properties','2021-03-20') , @@ -58034,6 +58034,11 @@ INSERT INTO TRANSLATION (TRN_CATEGORY,TRN_ID,TRN_LANG,TRN_VALUE,TRN_UPDATE_DATE ( 'LABEL','ID_DYNAFORM_ASSIGN_FAILED','en','Failed saving DynaForm assigned to the process.','2015-01-16') , ( 'LABEL','ID_DYNAFORM_COPY','en','Copy/Import Dynaform','2014-01-15') , ( 'LABEL','ID_DYNAFORM_COPY_REQUIRED','en','Select the dynaform you want to copy/import.','2014-01-15') , +( 'LABEL','ID_DYNAFORM_DEPENDS_DYNAFORMS','en','({0}) Depends in dynaform','2022-02-15') , +( 'LABEL','ID_DYNAFORM_DEPENDS_CASE_TRACKER','en','({0}) Depends in case traker','2022-02-15') , +( 'LABEL','ID_DYNAFORM_DEPENDS_PERMISSIONS','en','({0}) Depends in permissions','2022-02-15') , +( 'LABEL','ID_DYNAFORM_DEPENDS_STEPS','en','({0}) Depends in steps','2022-02-15') , +( 'LABEL','ID_DYNAFORM_DEPENDS_STEPS_SUPERVISOR','en','({0}) Depends in steps supervisor','2022-02-15') , ( 'LABEL','ID_DYNAFORM_DOES_NOT_EXIST','en','The DynaForm with {0}: {1} does not exist.','2014-05-20') , ( 'LABEL','ID_DYNAFORM_EDITOR','en','DynaForm Editor','2014-01-15') , ( 'LABEL','ID_DYNAFORM_EDITOR_LOGIN_AGAIN','en','You have lost your session and you have to login to continue. Please enter your password.','2014-01-15') , @@ -60625,6 +60630,7 @@ INSERT INTO TRANSLATION (TRN_CATEGORY,TRN_ID,TRN_LANG,TRN_VALUE,TRN_UPDATE_DATE ( 'LABEL','ID_PPP_MINIMUM_LENGTH','en','Minimum length','2014-01-15') , ( 'LABEL','ID_PPP_MINIMUN_LENGTH','en','Minimum length','2014-01-15') , ( 'LABEL','ID_PPP_NUMERICAL_CHARACTER_REQUIRED','en','Numerical Character is required','2014-01-15') , +( 'LABEL','ID_PPP_SPACES_NOT_SUPPORTED_AT_THE_END_OF_PASSWORD','en','Spaces not supported at the end of password','2022-02-09') , ( 'LABEL','ID_PPP_SPECIAL_CHARACTER_REQUIRED','en','Special Character is required','2014-01-15') , ( 'LABEL','ID_PPP_UPPERCASE_CHARACTER_REQUIRED','en','Uppercase Character is required','2014-01-15') , ( 'LABEL','ID_PREFERENCES','en','Preferences','2014-01-15') , @@ -61275,6 +61281,7 @@ INSERT INTO TRANSLATION (TRN_CATEGORY,TRN_ID,TRN_LANG,TRN_VALUE,TRN_UPDATE_DATE ( 'LABEL','ID_SYSTEM_INFO','en','System information','2014-01-15') , ( 'LABEL','ID_SYSTEM_REDIRECT_CONFIRM','en','You must login again to view the changes. Do you want do it now?','2015-01-16') , ( 'LABEL','ID_SYSTEM_SETTINGS','en','System Settings','2014-01-15') , +( 'LABEL','ID_SYSTEM_VARIABLES_ARE_PROTECTED','en','System variables are protected from changes, this request is denied','2022-03-24') , ( 'LABEL','ID_TABLE','en','Table','2014-01-15') , ( 'LABEL','ID_TABLES_REMOVED_SUCCESSFULLY','en','tables removed Successfully','2014-01-15') , ( 'LABEL','ID_TABLES_REMOVED_WITH_ERRORS','en','tables removed but with errors','2014-01-15') , @@ -61675,7 +61682,7 @@ INSERT INTO TRANSLATION (TRN_CATEGORY,TRN_ID,TRN_LANG,TRN_VALUE,TRN_UPDATE_DATE ( 'LABEL','ID_USER_LIST','en','User List','2014-01-15') , ( 'LABEL','ID_USER_MUST_CHANGE_PASSWORD_AT_NEXT_LOGON','en','User must change password at next logon','2014-05-16') , ( 'LABEL','ID_USER_NAME','en','User Name','2014-01-15') , -( 'LABEL','ID_USER_NAME_ALREADY_EXISTS','en','The User Name with {0}: "{1}" already exists.','2015-03-23') , +( 'LABEL','ID_USER_NAME_ALREADY_EXISTS','en','The User Name ''{0}'' already exists.','2022-02-11') , ( 'LABEL','ID_USER_NOT_ACTIVE','en','The user is not active.','2015-09-08') , ( 'LABEL','ID_USER_NOT_ACTIVITY','en','The usr_uid: {0} does not have an activity assigned','2014-05-21') , ( 'LABEL','ID_USER_NOT_ASSIGNED_TASK','en','The user is not assigned to the task','2014-01-15') , @@ -61735,7 +61742,7 @@ INSERT INTO TRANSLATION (TRN_CATEGORY,TRN_ID,TRN_LANG,TRN_VALUE,TRN_UPDATE_DATE ( 'LABEL','ID_VARIABLES_RECEIVED','en','variables received','2014-01-15') , ( 'LABEL','ID_VARIABLES_SENT','en','variables sent','2014-01-15') , ( 'LABEL','ID_VARIABLES_VALUE_ASSIGNMENT','en','Variable for Value Based Assignment','2014-01-15') , -( 'LABEL','ID_VARIABLE_ASSOCIATED_WITH_REPORT_TABLE','en','The variable with "{0}", it is associated with a report table.','2016-02-05') , +( 'LABEL','ID_VARIABLE_ASSOCIATED_WITH_REPORT_TABLE','en','The variable \"{0}\" Is associated with a report table, that requires to be removed first before allowing deleting it.','2022-04-08') , ( 'LABEL','ID_VARIABLE_IN_USE','en','This variable can not be deleted because it is being used in DynaForm : {0}. To delete it, first remove it from the DynaForm.','2015-04-08') , ( 'LABEL','ID_VARIABLE_NO_IS_GRID','en','The Variable with {0}: "{1}" is not a grid','2016-02-23') , ( 'LABEL','ID_VARIABLE_PICKER','en','pmVariablePicker','2014-01-15') , diff --git a/workflow/engine/methods/cases/ajaxListener.php b/workflow/engine/methods/cases/ajaxListener.php index 13e738842..33d9e2d21 100644 --- a/workflow/engine/methods/cases/ajaxListener.php +++ b/workflow/engine/methods/cases/ajaxListener.php @@ -724,7 +724,7 @@ class Ajax } // Save the note pause reason - if ($_REQUEST['NOTE_REASON'] != '') { + if (!empty($_REQUEST['NOTE_REASON'])) { $noteContent = addslashes($_REQUEST['NOTE_REASON']); // Define the Case for register a case note $cases = new BmCases(); @@ -733,7 +733,7 @@ class Ajax // End save $case = new WsBase(); - $response = $case->pauseCase($appUid, $delIndex, $_SESSION['USER_LOGGED'], $unpauseDate); + $response = $case->pauseCase($appUid, $delIndex, $_SESSION['USER_LOGGED'], $unpauseDate, true); $response = (object) $response; if ($response->status_code == 100) { throw new Exception($response->message); diff --git a/workflow/engine/methods/cases/caseHistory_Ajax.php b/workflow/engine/methods/cases/caseHistory_Ajax.php index cdf4447be..a095ebd2f 100644 --- a/workflow/engine/methods/cases/caseHistory_Ajax.php +++ b/workflow/engine/methods/cases/caseHistory_Ajax.php @@ -32,6 +32,8 @@ switch ($actionAjax) { // Apply mask $dateInitLabel = applyMaskDateEnvironment($result['DEL_INIT_DATE'],'', false); $dateDelLabel = applyMaskDateEnvironment($result['DEL_DELEGATE_DATE'],'', false); + $disableActionLabel = applyMaskDateEnvironment($result['APP_DISABLE_ACTION_DATE'],'', false); + $enableActionLabel = applyMaskDateEnvironment($result['APP_ENABLE_ACTION_DATE'],'', false); $dateEndLabel = '-'; // @todo the query for get this '-' needs an update if ($result['DEL_FINISH_DATE'] != "-") { @@ -41,6 +43,8 @@ switch ($actionAjax) { $result['DEL_INIT_DATE_LABEL'] = DateTime::convertUtcToTimeZone($dateInitLabel); $result['DEL_DELEGATE_DATE_LABEL'] = DateTime::convertUtcToTimeZone($dateDelLabel); $result['DEL_FINISH_DATE_LABEL'] = DateTime::convertUtcToTimeZone($dateEndLabel); + $result['APP_DISABLE_ACTION_DATE_LABEL'] = DateTime::convertUtcToTimeZone($disableActionLabel); + $result['APP_ENABLE_ACTION_DATE_LABEL'] = DateTime::convertUtcToTimeZone($enableActionLabel); $process[] = $result; } diff --git a/workflow/engine/methods/cases/proxyNewCasesList.php b/workflow/engine/methods/cases/proxyNewCasesList.php deleted file mode 100644 index aa236282a..000000000 --- a/workflow/engine/methods/cases/proxyNewCasesList.php +++ /dev/null @@ -1,213 +0,0 @@ -error = G::LoadTranslation('ID_LOGIN_AGAIN'); - $responseObject->success = true; - $responseObject->lostSession = true; - print G::json_encode($responseObject); - die(); -} - -try { - $userUid = $_SESSION['USER_LOGGED']; - - $filters['paged'] = isset($_REQUEST["paged"]) ? $_REQUEST["paged"] : true; - $filters['count'] = isset($_REQUEST['count']) ? $_REQUEST["count"] : true; - $filters['category'] = isset($_REQUEST["category"]) ? $_REQUEST["category"] : ""; - $filters['process'] = isset($_REQUEST["process"]) ? $_REQUEST["process"] : ""; - $filters['search'] = isset($_REQUEST["search"]) ? $_REQUEST["search"] : ""; - $filters['filter'] = isset($_REQUEST["filter"]) ? $_REQUEST["filter"] : ""; - $filters['dateFrom'] = (!empty($_REQUEST["dateFrom"])) ? substr($_REQUEST["dateFrom"], 0, 10) : ""; - $filters['dateTo'] = (!empty($_REQUEST["dateTo"])) ? substr($_REQUEST["dateTo"], 0, 10) : ""; - $filters['start'] = isset($_REQUEST["start"]) ? $_REQUEST["start"] : "0"; - $filters['limit'] = isset($_REQUEST["limit"]) ? $_REQUEST["limit"] : "25"; - $filters['sort'] = (isset($_REQUEST['sort'])) ? (($_REQUEST['sort'] == 'APP_STATUS_LABEL') ? 'APP_STATUS' : $_REQUEST["sort"]) : ''; - $filters['dir'] = isset($_REQUEST["dir"]) ? $_REQUEST["dir"] : "DESC"; - $filters['action'] = isset($_REQUEST["action"]) ? $_REQUEST["action"] : ""; - $filters['user'] = isset($_REQUEST["user"]) ? $_REQUEST["user"] : ""; - $listName = isset($_REQUEST["list"]) ? $_REQUEST["list"] : "inbox"; - $filters['filterStatus'] = isset($_REQUEST["filterStatus"]) ? $_REQUEST["filterStatus"] : ""; - $filters['sort'] = G::toUpper($filters['sort']); - $openApplicationUid = (isset($_REQUEST['openApplicationUid']) && $_REQUEST['openApplicationUid'] != '') ? $_REQUEST['openApplicationUid'] : null; - - global $RBAC; - $RBAC->allows(basename(__FILE__), $filters['action']); - - //Define user when is reassign - if ($filters['action'] == 'to_reassign') { - if ($filters['user'] == '') { - $userUid = ''; - } - if ($filters['user'] !== '' && $filters['user'] !== 'CURRENT_USER') { - $userUid = $filters['user']; - } - } - - // Select list - switch ($listName) { - case 'inbox': - $list = new ListInbox(); - break; - case 'participated_history': - $list = new ListParticipatedHistory(); - break; - case 'participated': - case 'participated_last': - $list = new ListParticipatedLast(); - break; - case 'completed': - $list = new ListCompleted(); - break; - case 'paused': - $list = new ListPaused(); - break; - case 'canceled': - $list = new ListCanceled(); - break; - case 'my_inbox': - $list = new ListMyInbox(); - break; - case 'unassigned': - $list = new ListUnassigned(); - break; - } - - // Validate filters - $filters['search'] = (!is_null($openApplicationUid)) ? $openApplicationUid : $filters['search']; - //Set a flag for review in the list by APP_UID when is used the case Link with parallel task - $filters['caseLink'] = (!is_null($openApplicationUid)) ? $openApplicationUid : ''; - - $filters['start'] = (int) $filters['start']; - $filters['start'] = abs($filters['start']); - if ($filters['start'] != 0) { - $filters['start'] + 1; - } - - $filters['limit'] = (int) $filters['limit']; - $filters['limit'] = abs($filters['limit']); - $conf = new Configurations(); - $formats = $conf->getFormats(); - $list->setUserDisplayFormat($formats['format']); - - if ($filters['limit'] == 0) { - $generalConfCasesList = $conf->getConfiguration('ENVIRONMENT_SETTINGS', ''); - if (isset($generalConfCasesList['casesListRowNumber'])) { - $filters['limit'] = (int) $generalConfCasesList['casesListRowNumber']; - } else { - $filters['limit'] = 25; - } - } else { - $filters['limit'] = (int) $filters['limit']; - } - - switch ($filters['sort']) { - case 'APP_CURRENT_USER': - //This value is format according to the userDisplayFormat, for this reason we will sent the UID - $filters['sort'] = 'USR_UID'; - break; - case 'DEL_TASK_DUE_DATE': - $filters['sort'] = 'DEL_DUE_DATE'; - break; - case 'APP_UPDATE_DATE': - $filters['sort'] = 'DEL_DELEGATE_DATE'; - break; - case 'APP_DEL_PREVIOUS_USER': - //This value is format according to the userDisplayFormat, for this reason we will sent the UID - $filters['sort'] = 'DEL_PREVIOUS_USR_UID'; - break; - case 'DEL_CURRENT_TAS_TITLE': - $filters['sort'] = 'APP_TAS_TITLE'; - break; - case 'APP_STATUS_LABEL': - $filters['sort'] = 'APP_STATUS'; - break; - } - - $filters['dir'] = G::toUpper($filters['dir']); - if (!($filters['dir'] == 'DESC' || $filters['dir'] == 'ASC')) { - $filters['dir'] = 'DESC'; - } - - $result = $list->loadList($userUid, $filters, function (array $record) { - try { - if (isset($record["DEL_PREVIOUS_USR_UID"])) { - if ($record["DEL_PREVIOUS_USR_UID"] == "") { - $appDelegation = AppDelegationPeer::retrieveByPK($record["APP_UID"], $record["DEL_INDEX"]); - - if (!is_null($appDelegation)) { - $appDelegationPrevious = AppDelegationPeer::retrieveByPK($record["APP_UID"], $appDelegation->getDelPrevious()); - - if (!is_null($appDelegationPrevious)) { - $taskPrevious = TaskPeer::retrieveByPK($appDelegationPrevious->getTasUid()); - - if (!is_null($taskPrevious)) { - switch ($taskPrevious->getTasType()) { - case "SCRIPT-TASK": - $record["DEL_PREVIOUS_USR_UID"] = $taskPrevious->getTasType(); - break; - } - } - } - } - } - - $record["PREVIOUS_USR_UID"] = $record["DEL_PREVIOUS_USR_UID"]; - $record["PREVIOUS_USR_USERNAME"] = $record["DEL_PREVIOUS_USR_USERNAME"]; - $record["PREVIOUS_USR_FIRSTNAME"] = $record["DEL_PREVIOUS_USR_FIRSTNAME"]; - $record["PREVIOUS_USR_LASTNAME"] = $record["DEL_PREVIOUS_USR_LASTNAME"]; - } elseif (!empty($record["USR_ID"])) { - $user = User::where("USR_ID", $record["USR_ID"])->first(); - $record["PREVIOUS_USR_UID"] = $record["DEL_PREVIOUS_USR_UID"] = $user->USR_UID; - $record["PREVIOUS_USR_USERNAME"] = $record["DEL_PREVIOUS_USR_USERNAME"] = $user->USR_USERNAME; - $record["PREVIOUS_USR_FIRSTNAME"] = $record["DEL_PREVIOUS_USR_FIRSTNAME"] = $user->USR_FIRSTNAME; - $record["PREVIOUS_USR_LASTNAME"] = $record["DEL_PREVIOUS_USR_LASTNAME"] = $user->USR_LASTNAME; - } - - if (isset($record["DEL_DUE_DATE"])) { - $record["DEL_TASK_DUE_DATE"] = $record["DEL_DUE_DATE"]; - } - - if (isset($record["APP_PAUSED_DATE"])) { - $record["APP_UPDATE_DATE"] = $record["APP_PAUSED_DATE"]; - } - - if (isset($record["DEL_CURRENT_USR_USERNAME"])) { - $record["USR_USERNAME"] = $record["DEL_CURRENT_USR_USERNAME"]; - $record["USR_FIRSTNAME"] = $record["DEL_CURRENT_USR_FIRSTNAME"]; - $record["USR_LASTNAME"] = $record["DEL_CURRENT_USR_LASTNAME"]; - $record["APP_UPDATE_DATE"] = $record["DEL_DELEGATE_DATE"]; - } - - if (isset($record['DEL_CURRENT_TAS_TITLE']) && $record['DEL_CURRENT_TAS_TITLE'] != '') { - $record['APP_TAS_TITLE'] = $record['DEL_CURRENT_TAS_TITLE']; - } elseif (!empty($record["TAS_TITLE"]) && empty($record["APP_TAS_TITLE"])) { - $record["APP_TAS_TITLE"] = $record["TAS_TITLE"]; - } - - if (isset($record["APP_STATUS"])) { - $record["APP_STATUS_LABEL"] = G::LoadTranslation("ID_" . $record["APP_STATUS"]); - } - - if (!empty($record["PRO_TITLE"]) && empty($record["APP_PRO_TITLE"])) { - $record["APP_PRO_TITLE"] = $record["PRO_TITLE"]; - } - - return $record; - } catch (Exception $e) { - throw $e; - } - }); - - $response = array(); - $response['filters'] = $filters; - $response['totalCount'] = $list->getCountList($userUid, $filters); - $response['data'] = \ProcessMaker\Util\DateTime::convertUtcToTimeZone($result); - !empty($response['filters']['search']) ? $response['filters']['search'] = '' : ''; - echo G::json_encode($response); -} catch (Exception $e) { - $msg = array("error" => $e->getMessage()); - echo G::json_encode($msg); -} diff --git a/workflow/engine/methods/login/authentication.php b/workflow/engine/methods/login/authentication.php index bce846d57..b8f3ed162 100644 --- a/workflow/engine/methods/login/authentication.php +++ b/workflow/engine/methods/login/authentication.php @@ -40,7 +40,8 @@ try { if (isset($frm['USR_USERNAME'])) { $usr = mb_strtolower(trim($frm['USR_USERNAME']), 'UTF-8'); - $pwd = trim($frm['USR_PASSWORD']); + //Spaces not supported at the end of passwords + $pwd = rtrim($frm['USR_PASSWORD']); } /*----------------------------------********---------------------------------*/ require_once PATH_CORE . 'methods' . PATH_SEP . 'enterprise' . PATH_SEP . 'enterprise.php'; diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php index a160091da..49953f5fb 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php @@ -695,9 +695,14 @@ class Cases $response = []; $subApplication = new SubApplication(); $data = $subApplication->loadByAppUidParent($applicationUid); - foreach ($data as $item) { - $response[] = $this->getCaseInfo($item['APP_UID'], $userUid); + if (!empty($data)) { + foreach ($data as $item) { + $response[] = $this->getCaseInfo($item['APP_UID'], $userUid); + } + } else { + throw new Exception(G::LoadTranslation("ID_CASE_DOES_NOT_EXIST", [$applicationUid])); } + return $response; } catch (Exception $e) { throw $e; @@ -1972,6 +1977,13 @@ class Cases Validator::isArray($app_data, '$app_data'); Validator::isString($usr_uid, '$usr_uid'); Validator::usrUid($usr_uid, '$usr_uid'); + // Validate the system variables + $systemVars = G::getSystemConstants(); + foreach ($systemVars as $key => $var) { + if (array_key_exists($key, $app_data)) { + throw new Exception(G::LoadTranslation("ID_CAN_NOT_CHANGE")); + } + } $arrayResult = $this->getStatusInfo($app_uid); diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/InputDocument.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/InputDocument.php index 043413d83..da8f0ca71 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/InputDocument.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/InputDocument.php @@ -16,6 +16,8 @@ use G; use ObjectPermissionPeer; use ProcessMaker\BusinessModel\Cases AS BusinessModelCases; use ProcessMaker\BusinessModel\ProcessSupervisor; +use ProcessMaker\Model\Application; +use ProcessMaker\Model\Delegation; use ProcessMaker\Plugins\PluginRegistry; use ProcessMaker\Validation\ValidationUploadedFiles; use ProcessUserPeer; @@ -241,6 +243,7 @@ class InputDocument $criteria->addSelectColumn(AppDocumentPeer::APP_DOC_UID); $criteria->addSelectColumn(AppDocumentPeer::DOC_VERSION); + $criteria->addSelectColumn(AppDocumentPeer::APP_DOC_COMMENT); $criteria->addSelectColumn(AppDocumentPeer::DOC_UID); $criteria->addSelectColumn(AppDocumentPeer::USR_UID); $criteria->addSelectColumn(AppDocumentPeer::APP_DOC_TYPE); @@ -280,13 +283,16 @@ class InputDocument public function getAppDocumentDataFromRecord(array $record) { try { - $newArray = array(); + $newArray = []; if (isset($record["APP_DOC_UID"])) { $newArray["app_doc_uid"] = $record["APP_DOC_UID"]; } if (isset($record["APP_DOC_FILENAME"])) { $newArray["app_doc_filename"] = $record["APP_DOC_FILENAME"]; } + if (isset($record["APP_DOC_COMMENT"])) { + $newArray["app_doc_comment"] = $record["APP_DOC_COMMENT"]; + } if (isset($record["DOC_UID"])) { $newArray["doc_uid"] = $record["DOC_UID"]; } @@ -464,8 +470,6 @@ class InputDocument public function getCasesInputDocument($appUid, $userUid, $inputDocumentUid) { try { - $appUid = $applicationUid; - $case = new Cases(); $fields = $case->loadCase($appUid); $proUid = $fields['PRO_UID']; @@ -767,7 +771,7 @@ class InputDocument /** * Get data of Cases InputDocument * - * @param string $applicationUid + * @param string $appUid * @param string $taskUid * @param string $appDocComment * @param string $inputDocumentUid @@ -776,7 +780,7 @@ class InputDocument * @return array Return an array with data of an InputDocument * @throws Exception */ - public function addCasesInputDocument($applicationUid, $taskUid, $appDocComment, $inputDocumentUid, $userUid, $runningWorkflow = true) + public function addCasesInputDocument($appUid, $taskUid, $appDocComment, $inputDocumentUid, $userUid, $runningWorkflow = true) { try { if ((isset( $_FILES['form'] )) && ($_FILES['form']['error'] != 0)) { @@ -816,64 +820,49 @@ class InputDocument $appDocUid = G::generateUniqueID(); $docVersion = ''; $appDocType = 'INPUT'; + $delIndex = AppDelegation::getCurrentIndex($appUid); $case = new Cases(); - $delIndex = AppDelegation::getCurrentIndex($applicationUid); - if ($runningWorkflow) { - $case->thisIsTheCurrentUser($applicationUid, $delIndex, $userUid, 'REDIRECT', 'casesListExtJs'); + $case->thisIsTheCurrentUser($appUid, $delIndex, $userUid, 'REDIRECT', 'casesListExtJs'); } else { - $criteria = new Criteria('workflow'); - - $criteria->add(AppDelegationPeer::APP_UID, $applicationUid); - $criteria->add(AppDelegationPeer::DEL_INDEX, $delIndex); - $criteria->add(AppDelegationPeer::USR_UID, $userUid); - - $rsCriteria = ProcessUserPeer::doSelectRS($criteria); - - if (!$rsCriteria->next()) { - $case2 = new BusinessModelCases(); - - $arrayApplicationData = $case2->getApplicationRecordByPk($applicationUid, [], false); - - $msg = ''; - + $appInfo = Application::getCase($appUid); + $proUid = $appInfo['PRO_UID']; + $appNumber = $appInfo['APP_NUMBER']; + $msg = ''; + // Check the current user + $currentUser = Delegation::getCurrentUser($appNumber, $delIndex); + if ($currentUser !== $userUid) { + // Review if is a supervisor $supervisor = new ProcessSupervisor(); - $flagps = $supervisor->isUserProcessSupervisor($arrayApplicationData['PRO_UID'], $userUid); - - if ($flagps == false) { - $msg = G::LoadTranslation('ID_USER_NOT_IT_BELONGS_CASE_OR_NOT_SUPERVISOR'); - } - - if ($msg == '') { + $isSupervisor = $supervisor->isUserProcessSupervisor($proUid, $userUid); + if ($isSupervisor) { $criteria = new Criteria('workflow'); - - $criteria->add(StepSupervisorPeer::PRO_UID, $arrayApplicationData['PRO_UID'], Criteria::EQUAL); + $criteria->add(StepSupervisorPeer::PRO_UID, $proUid, Criteria::EQUAL); $criteria->add(StepSupervisorPeer::STEP_TYPE_OBJ, 'INPUT_DOCUMENT', Criteria::EQUAL); $criteria->add(StepSupervisorPeer::STEP_UID_OBJ, $inputDocumentUid, Criteria::EQUAL); - $rsCriteria = StepSupervisorPeer::doSelectRS($criteria); - if (!$rsCriteria->next()) { $msg = G::LoadTranslation('ID_USER_IS_SUPERVISOR_DOES_NOT_ASSOCIATED_INPUT_DOCUMENT'); } + } else { + $msg = G::LoadTranslation('ID_USER_NOT_IT_BELONGS_CASE_OR_NOT_SUPERVISOR'); } + } + if (!empty($msg)) { + if ($runningWorkflow) { + G::SendMessageText($msg, 'ERROR'); + $backUrlObj = explode('sys' . config("system.workspace"), $_SERVER['HTTP_REFERER']); - if ($msg != '') { - if ($runningWorkflow) { - G::SendMessageText($msg, 'ERROR'); - $backUrlObj = explode('sys' . config("system.workspace"), $_SERVER['HTTP_REFERER']); - - G::header('location: ' . '/sys' . config("system.workspace") . $backUrlObj[1]); - exit(0); - } else { - throw new Exception($msg); - } + G::header('location: ' . '/sys' . config("system.workspace") . $backUrlObj[1]); + exit(0); + } else { + throw new Exception($msg); } } } //Load the fields - $arrayField = $case->loadCase($applicationUid); + $arrayField = $case->loadCase($appUid); $arrayField["APP_DATA"] = array_merge($arrayField["APP_DATA"], G::getSystemConstants()); //Validate Process Uid and Input Document Process Uid $inputDocumentInstance = new \InputDocument(); @@ -898,7 +887,7 @@ class InputDocument $appDocType, $appDocComment, '', - $applicationUid, + $appUid, $delIndex, $taskUid, $userUid, @@ -908,7 +897,7 @@ class InputDocument $_FILES["form"]["tmp_name"]); } //Trigger - Execute after - Start - $arrayField["APP_DATA"] = $case->executeTriggers ($taskUid, + $arrayField["APP_DATA"] = $case->executeTriggers($taskUid, "INPUT_DOCUMENT", $inputDocumentUid, "AFTER", @@ -921,8 +910,8 @@ class InputDocument $arrayData["APP_DATA"] = $arrayField["APP_DATA"]; $arrayData["DEL_INDEX"] = $delIndex; $arrayData["TAS_UID"] = $taskUid; - $case->updateCase($applicationUid, $arrayData); - return($this->getCasesInputDocument($applicationUid, $userUid, $appDocUid)); + $case->updateCase($appUid, $arrayData); + return($this->getCasesInputDocument($appUid, $userUid, $appDocUid)); } catch (Exception $e) { throw $e; } diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Search.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Search.php index 60a78c92f..880aed728 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Search.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Search.php @@ -102,8 +102,10 @@ class Search extends AbstractCases } // Filter by task if ($this->getTaskId()) { - // Join with delegation - $query->joinDelegation(); + if (!$this->getUserId()) { + // Join with delegation if was not defined before + $query->joinDelegation(); + } // Add the filter $query->task($this->getTaskId()); // Get only the open threads related to the task diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/DynaForm.php b/workflow/engine/src/ProcessMaker/BusinessModel/DynaForm.php index 2c5f74e19..92c08167e 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/DynaForm.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/DynaForm.php @@ -3,9 +3,17 @@ namespace ProcessMaker\BusinessModel; use AdditionalTables; +use CaseTrackerObject; +use Criteria; +use Dynaform as ModelDynaform; use DynaformHandler; +use DynaformPeer; use Exception; use G; +use ObjectPermission; +use ResultSet; +use Step; +use StepSupervisor; use PmDynaform; class DynaForm @@ -139,35 +147,34 @@ class DynaForm */ public function dynaFormDepends($dynUid, $proUid) { - $oCriteria = new \Criteria(); - $oCriteria->addSelectColumn(\DynaformPeer::DYN_TYPE); - $oCriteria->add(\DynaformPeer::DYN_UID, $dynUid); - $oCriteria->add(\DynaformPeer::PRO_UID, $proUid); - $oDataset = \DynaformPeer::doSelectRS($oCriteria); - $oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC); + $oCriteria = new Criteria(); + $oCriteria->addSelectColumn(DynaformPeer::DYN_TYPE); + $oCriteria->add(DynaformPeer::DYN_UID, $dynUid); + $oCriteria->add(DynaformPeer::PRO_UID, $proUid); + $oDataset = DynaformPeer::doSelectRS($oCriteria); + $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); $dataDyna = $oDataset->getRow(); if ($dataDyna['DYN_TYPE'] == 'grid') { - $formsDepend = array(); + $formsDepend = []; - - $oCriteria = new \Criteria('workflow'); - $oCriteria->addSelectColumn(\DynaformPeer::DYN_UID); - $oCriteria->addSelectColumn(\DynaformPeer::DYN_TITLE); - $oCriteria->add(\DynaformPeer::PRO_UID, $proUid); - $oCriteria->add(\DynaformPeer::DYN_TYPE, "xmlform"); - $oDataset = \DynaformPeer::doSelectRS($oCriteria); - $oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC); + $oCriteria = new Criteria('workflow'); + $oCriteria->addSelectColumn(DynaformPeer::DYN_UID); + $oCriteria->addSelectColumn(DynaformPeer::DYN_TITLE); + $oCriteria->add(DynaformPeer::PRO_UID, $proUid); + $oCriteria->add(DynaformPeer::DYN_TYPE, "xmlform"); + $oDataset = DynaformPeer::doSelectRS($oCriteria); + $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); while ($oDataset->next()) { $dataForms = $oDataset->getRow(); $dynHandler = new DynaformHandler(PATH_DYNAFORM . $proUid . PATH_SEP . $dataForms["DYN_UID"] . ".xml"); $dynFields = $dynHandler->getFields(); foreach ($dynFields as $field) { - $sType = \Step::getAttribute($field, 'type'); + $sType = Step::getAttribute($field, 'type'); if ($sType == 'grid') { - $sxmlgrid = \Step::getAttribute($field, 'xmlgrid'); + $sxmlgrid = Step::getAttribute($field, 'xmlgrid'); $aGridInfo = explode("/", $sxmlgrid); if ($aGridInfo[0] == $proUid && $aGridInfo[1] == $dynUid) { $formsDepend[] = $dataForms["DYN_TITLE"]; @@ -183,9 +190,9 @@ class DynaForm } } else { $flagDepend = false; - $stepsDepends = \Step::verifyDynaformAssigStep($dynUid, $proUid); + $stepsDepends = Step::verifyDynaformAssigStep($dynUid, $proUid); - $messageSteps = '(0) Depends in steps'; + $messageSteps = G::LoadTranslation("ID_DYNAFORM_DEPENDS_STEPS", [0]); if (!empty($stepsDepends)) { $flagDepend = true; $countSteps = count($stepsDepends); @@ -193,41 +200,41 @@ class DynaForm foreach ($stepsDepends as $value) { $messTemp .= ", the task '" . $value['CON_VALUE'] . "' position " . $value['STEP_POSITION']; } - $messageSteps = "($countSteps) Depends in steps in" . $messTemp; + $messageSteps = G::LoadTranslation("ID_DYNAFORM_DEPENDS_STEPS", [$countSteps]) . ' in ' . $messTemp; } - $stepSupervisorsDepends = \StepSupervisor::verifyDynaformAssigStepSupervisor($dynUid, $proUid); - $messageStepsSupervisors = '(0) Depends in steps supervisor'; + $stepSupervisorsDepends = StepSupervisor::verifyDynaformAssigStepSupervisor($dynUid, $proUid); + $messageStepsSupervisors = G::LoadTranslation("ID_DYNAFORM_DEPENDS_STEPS_SUPERVISOR", [0]); if (!empty($stepSupervisorsDepends)) { $flagDepend = true; $countSteps = count($stepSupervisorsDepends); - $messageStepsSupervisors = "($countSteps) Depends in steps supervisor"; + $messageStepsSupervisors = G::LoadTranslation("ID_DYNAFORM_DEPENDS_STEPS_SUPERVISOR", [$countSteps]); } - $objectPermissionDepends = \ObjectPermission::verifyDynaformAssigObjectPermission($dynUid, $proUid); - $messageObjectPermission = '(0) Depends in permissions'; + $objectPermissionDepends = ObjectPermission::verifyDynaformAssigObjectPermission($dynUid, $proUid); + $messageObjectPermission = G::LoadTranslation("ID_DYNAFORM_DEPENDS_PERMISSIONS", [0]); if (!empty($objectPermissionDepends)) { $flagDepend = true; $countSteps = count($objectPermissionDepends); - $messageObjectPermission = "($countSteps) Depends in permissions"; + $messageObjectPermission = G::LoadTranslation("ID_DYNAFORM_DEPENDS_PERMISSIONS", [$countSteps]); } - $caseTrackerDepends = \CaseTrackerObject::verifyDynaformAssigCaseTracker($dynUid, $proUid); - $messageCaseTracker = '(0) Depends in case traker'; + $caseTrackerDepends = CaseTrackerObject::verifyDynaformAssigCaseTracker($dynUid, $proUid); + $messageCaseTracker = G::LoadTranslation("ID_DYNAFORM_DEPENDS_CASE_TRACKER", [0]); if (!empty($caseTrackerDepends)) { $flagDepend = true; $countSteps = count($caseTrackerDepends); - $messageCaseTracker = "($countSteps) Depends in case traker"; + $messageCaseTracker = G::LoadTranslation("ID_DYNAFORM_DEPENDS_CASE_TRACKER", [$countSteps]); } - $dynaformDepends = \Dynaform::verifyDynaformAssignDynaform($dynUid, $proUid); - $messageDynaform = '(0) Depends in case traker'; + $dynaformDepends = ModelDynaform::verifyDynaformAssignDynaform($dynUid, $proUid); + $messageDynaform = G::LoadTranslation("ID_DYNAFORM_DEPENDS_DYNAFORMS", [0]); if (!empty($dynaformDepends)) { $flagDepend = true; $countSteps = count($dynaformDepends); - $messageDynaform = "($countSteps) Depends in dynaform"; + $messageDynaform = G::LoadTranslation("ID_DYNAFORM_DEPENDS_DYNAFORMS", [$countSteps]); } - + $message = ''; if ($flagDepend) { $message = "You can not delete the dynaform '$dynUid', because it has the following dependencies: \n\n"; $message .= $messageSteps . ".\n" . $messageStepsSupervisors . ".\n"; @@ -235,7 +242,7 @@ class DynaForm $message .= $messageDynaform; return $message; } - return ''; + return $message; } } @@ -453,14 +460,11 @@ class DynaForm //Load DynaForm $dynaForm = new \Dynaform(); - $arrayDynaFormData = $dynaForm->Load($dynaFormUid); - $processUid = $arrayDynaFormData["PRO_UID"]; //Verify data $process = new \ProcessMaker\BusinessModel\Process(); - $process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, false); if (isset($arrayData["DYN_TITLE"])) { @@ -471,8 +475,9 @@ class DynaForm //Update $arrayData["DYN_UID"] = $dynaFormUid; - $result = $dynaForm->update($arrayData); + //Add Audit Log + G::auditLog("UpdateDynaform", "Dynaform Title: " . $arrayData['DYN_TITLE'] . ", Type: " . $arrayData['DYN_TYPE'] . ", Description: " . $arrayData['DYN_DESCRIPTION'] . ", Uid: " . $arrayData["DYN_UID"]); //Return unset($arrayData["DYN_UID"]); @@ -482,7 +487,7 @@ class DynaForm } return $arrayData; - } catch (\Exception $e) { + } catch (Exception $e) { throw $e; } } diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/ProcessSupervisor.php b/workflow/engine/src/ProcessMaker/BusinessModel/ProcessSupervisor.php index 5546a9fd6..6165e8da2 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/ProcessSupervisor.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/ProcessSupervisor.php @@ -1275,6 +1275,8 @@ class ProcessSupervisor $finPos = $prStepPos-1; } $range = range($iniPos, $finPos); + $stepChangePos = []; + $stepChangeIds = []; foreach ($aSteps as $dataStep) { if ($dataStep['obj_type'] == 'DYNAFORM') { if ((in_array($dataStep['pud_position'], $range)) && ($dataStep['pud_uid'] != $step_uid)) { diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Role/User.php b/workflow/engine/src/ProcessMaker/BusinessModel/Role/User.php index e15d4289a..f8fe87518 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Role/User.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Role/User.php @@ -210,7 +210,7 @@ class User $this->throwExceptionIfNotItsAssignedUserToRole($roleUid, $userUid, $this->arrayFieldNameForException["userUid"]); - if ($userUid == "00000000000000000000000000000001") { + if (RBAC::isAdminUserUid($userUid)) { throw new Exception(G::LoadTranslation("ID_ADMINISTRATOR_ROLE_CANT_CHANGED")); } diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/User.php b/workflow/engine/src/ProcessMaker/BusinessModel/User.php index d572e0227..e29da0761 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/User.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/User.php @@ -396,17 +396,15 @@ class User * Verify if exists the Name of a User * * @param string $userName Name - * @param string $fieldNameForException Field name for the exception * @param string $userUidToExclude Unique id of User to exclude * * @throws Exception if exists the title of a User */ - public function throwExceptionIfExistsName($userName, $fieldNameForException, $userUidToExclude = "") + public function throwExceptionIfExistsName($userName, $userUidToExclude = "") { try { if ($this->existsName($userName, $userUidToExclude)) { - throw new Exception(G::LoadTranslation("ID_USER_NAME_ALREADY_EXISTS", - array($fieldNameForException, $userName))); + throw new Exception(G::LoadTranslation("ID_USER_NAME_ALREADY_EXISTS", [$userName])); } } catch (Exception $e) { throw $e; @@ -446,7 +444,7 @@ class User { try { //Set variables - $arrayUserData = ($userUid == "") ? array() : $this->getUser($userUid, true); + $arrayUserData = ($userUid == "") ? [] : $this->getUser($userUid, true); $flagInsert = ($userUid == "") ? true : false; $arrayFinalData = array_merge($arrayUserData, $arrayData); @@ -459,8 +457,7 @@ class User //Verify data if (isset($arrayData["USR_USERNAME"])) { - $this->throwExceptionIfExistsName($arrayData["USR_USERNAME"], - $this->arrayFieldNameForException["usrUsername"], $userUid); + $this->throwExceptionIfExistsName($arrayData["USR_USERNAME"], $userUid); } if (isset($arrayData["USR_EMAIL"])) { @@ -762,8 +759,6 @@ class User public function create(array $arrayData) { try { - - //Verify data $validator = new Validator(); @@ -1292,27 +1287,29 @@ class User try { //Verify data $this->throwExceptionIfNotExistsUser($usrUid, $this->arrayFieldNameForException["usrUid"]); - + // Check user admin + if (RBAC::isAdminUserUid($usrUid)) { + throw new Exception(G::LoadTranslation("ID_MSG_CANNOT_DELETE_USER", [$usrUid])); + } + // Check user guest + if (RBAC::isGuestUserUid($usrUid)) { + throw new Exception(G::LoadTranslation("ID_MSG_CANNOT_DELETE_USER", [$usrUid])); + } + // Check if the user has cases $oProcessMap = new ClassesCases(); - $USR_UID = $usrUid; $total = 0; $history = 0; - $c = $oProcessMap->getCriteriaUsersCases('TO_DO', $USR_UID); + $c = $oProcessMap->getCriteriaUsersCases('TO_DO', $usrUid); $total += ApplicationPeer::doCount($c); - $c = $oProcessMap->getCriteriaUsersCases('DRAFT', $USR_UID); + $c = $oProcessMap->getCriteriaUsersCases('DRAFT', $usrUid); $total += ApplicationPeer::doCount($c); - $c = $oProcessMap->getCriteriaUsersCases('COMPLETED', $USR_UID); + $c = $oProcessMap->getCriteriaUsersCases('COMPLETED', $usrUid); $history += ApplicationPeer::doCount($c); - $c = $oProcessMap->getCriteriaUsersCases('CANCELLED', $USR_UID); + $c = $oProcessMap->getCriteriaUsersCases('CANCELLED', $usrUid); $history += ApplicationPeer::doCount($c); - - //check user guest - if (RBAC::isGuestUserUid($usrUid)) { - throw new Exception(G::LoadTranslation("ID_MSG_CANNOT_DELETE_USER", array($USR_UID))); - } if ($total > 0) { - throw new Exception(G::LoadTranslation("ID_USER_CAN_NOT_BE_DELETED", array($USR_UID))); + throw new Exception(G::LoadTranslation("ID_USER_CAN_NOT_BE_DELETED", [$usrUid])); } else { $UID = $usrUid; $oTasks = new Tasks(); @@ -1321,20 +1318,20 @@ class User $oGroups->removeUserOfAllGroups($UID); $this->changeUserStatus($UID, 'CLOSED'); $_GET['USR_USERNAME'] = ''; - $this->updateUser(array('USR_UID' => $UID, 'USR_USERNAME' => $_GET['USR_USERNAME']), ''); + $this->updateUser(['USR_UID' => $UID, 'USR_USERNAME' => $_GET['USR_USERNAME']], ''); require_once(PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "Users.php"); $oUser = new Users(); $aFields = $oUser->load($UID); $aFields['USR_STATUS'] = 'CLOSED'; $aFields['USR_USERNAME'] = ''; $oUser->update($aFields); - //Delete Dashboard + // Delete Dashboard require_once(PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "DashletInstance.php"); $criteria = new Criteria('workflow'); $criteria->add(DashletInstancePeer::DAS_INS_OWNER_UID, $UID); $criteria->add(DashletInstancePeer::DAS_INS_OWNER_TYPE, 'USER'); DashletInstancePeer::doDelete($criteria); - //Destroy session after delete user + // Destroy session after delete user RBAC::destroySessionUser($usrUid); (new OauthClients())->removeByUser($usrUid); } diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Variable.php b/workflow/engine/src/ProcessMaker/BusinessModel/Variable.php index b47467564..1d01f9132 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Variable.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Variable.php @@ -7,6 +7,8 @@ use Cases as ClassesCases; use Exception; use G; use PmDynaform; +use ProcessMaker\Model\AdditionalTables as AT; +use ProcessMaker\Model\Fields; use ProcessMaker\Model\ProcessVariables; use ProcessMaker\Util\Common; @@ -570,18 +572,19 @@ class Variable public function throwExceptionIfVariableIsAssociatedAditionalTable($variableUid) { try { - $criteria = new \Criteria('workflow'); - $criteria->addSelectColumn(\ProcessVariablesPeer::VAR_UID); - $criteria->addJoin(\ProcessVariablesPeer::PRJ_UID, \AdditionalTablesPeer::PRO_UID, \Criteria::INNER_JOIN); - $arrayCondition = []; - $arrayCondition[] = array(\AdditionalTablesPeer::ADD_TAB_UID, \FieldsPeer::ADD_TAB_UID, \Criteria::EQUAL); - $arrayCondition[] = array(\ProcessVariablesPeer::VAR_NAME, \FieldsPeer::FLD_NAME, \Criteria::EQUAL); - $criteria->addJoinMC($arrayCondition, \Criteria::INNER_JOIN); - $criteria->add(\ProcessVariablesPeer::VAR_UID, $variableUid, \Criteria::EQUAL); - $rsCriteria = \ProcessVariablesPeer::doSelectRS($criteria); - $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); - if ($rsCriteria->next()) { - throw new Exception(G::LoadTranslation('ID_VARIABLE_ASSOCIATED_WITH_REPORT_TABLE', array($variableUid))); + // Get variable name + $varInfo = ProcessVariables::getVariable($variableUid); + $varName = $varInfo['VAR_NAME']; + $proUid = $varInfo['PRJ_UID']; + // Get the tables related to the process + $tables = AT::getTables($proUid); + if (!empty($tables)) { + foreach ($tables as $value) { + $exist = Fields::searchVariable($value['ADD_TAB_UID'], $varName); + if ($exist) { + throw new Exception(G::LoadTranslation('ID_VARIABLE_ASSOCIATED_WITH_REPORT_TABLE', [$varName])); + } + } } } catch (Exception $e) { throw $e; diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/WebEntry.php b/workflow/engine/src/ProcessMaker/BusinessModel/WebEntry.php index b5cdc13ba..883f49d73 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/WebEntry.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/WebEntry.php @@ -9,6 +9,7 @@ use Illuminate\Support\Facades\DB; use ProcessMaker\Core\System; use ProcessMaker\Model\Application; use Publisher; +use RBAC; use ResultSet; use WebEntryPeer; @@ -1101,7 +1102,7 @@ class WebEntry */ public function isWebEntryOne($weUid) { - if (!empty($_SESSION['USER_LOGGED']) && empty($_SESSION['__WEBENTRYCONTINUE__'])) { + if ($this->verifyCurrentSession()) { global $G_PUBLISH; $G_PUBLISH = new Publisher(); $G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/checkContinueOrCloseSession', '', [], SYS_URI . 'login/checkContinueOrCloseSession'); @@ -1116,6 +1117,28 @@ class WebEntry && $webEntry->getWeCallback() === 'PROCESSMAKER'; } + /** + * Verify the current sessión exist for display webentry message confirmation. + * @return bool + */ + private function verifyCurrentSession(): bool + { + //verify normal flow + $rule1 = !empty($_SESSION['USER_LOGGED']) && empty($_SESSION['__WEBENTRYCONTINUE__']); + + //verify guest user + $rule2 = !empty($_SESSION['USER_LOGGED']); + if ($rule2) { + //verify is guest user uid. + $rule2 = !RBAC::isGuestUserUid($_SESSION['USER_LOGGED']); + } + + //verify saml session + $rule3 = !(!empty($_SESSION['samlNameId']) && !empty($_SESSION['samlSessionIndex'])); + + return $rule1 && $rule2 && $rule3; + } + /** * Verify if a Task is and Web Entry auxiliar task. * diff --git a/workflow/engine/src/ProcessMaker/Core/System.php b/workflow/engine/src/ProcessMaker/Core/System.php index 103c90992..b03f4ce46 100644 --- a/workflow/engine/src/ProcessMaker/Core/System.php +++ b/workflow/engine/src/ProcessMaker/Core/System.php @@ -31,62 +31,63 @@ class System private static $debug = null; private static $instance; private static $defaultConfig = [ + 'at_risk_delegation_max_time' => '0.2', + 'code_scanner_scope' => 'import_plugin,enable_plugin,import_process,trigger', 'debug' => 0, 'debug_sql' => 0, 'debug_time' => 0, 'debug_calendar' => 0, - 'wsdl_cache' => 1, - 'time_zone' => 'America/New_York', - 'expiration_year' => '1', - 'memcached' => 0, - 'memcached_server' => '', 'default_skin' => 'neoclassic', 'default_lang' => 'en', + 'delay' => '0', + 'disable_php_upload_execution' => 0, + 'disable_download_documents_session_validation' => 0, + 'disable_advanced_search_case_title_fulltext' => 0, + 'disable_task_manager_routing_async' => '0', + 'display_errors' => 'On', + 'enable_blacklist' => 0, + 'enable_httponly_flag' => 0, + 'error_reporting' => '', + 'expiration_year' => '1', + 'ext_ajax_timeout' => 600000, + 'files_white_list' => '', + 'google_map_api_key' => '', + 'google_map_signature' => '', + 'highlight_home_folder_enable' => 0, + 'highlight_home_folder_refresh_time' => 10, + 'highlight_home_folder_scope' => 'unassigned', // For now only this list is supported + 'ie_cookie_lifetime' => 1, + 'leave_case_warning' => 0, + 'load_headers_ie' => 0, + 'logging_level' => 'INFO', + 'logs_max_files' => 60, + 'logs_location' => '', + 'memcached' => 0, + 'memcached_server' => '', + 'mobile_offline_tables_download_interval' => 24, + 'number_log_file' => 5, + 'on_one_server_enable' => 0, + 'pmftotalcalculation_floating_point_number' => 10, 'proxy_host' => '', 'proxy_port' => '', 'proxy_user' => '', 'proxy_pass' => '', - 'size_log_file' => 5000000, - 'number_log_file' => 5, - 'ie_cookie_lifetime' => 1, - 'safari_cookie_lifetime' => 1, - 'error_reporting' => "", - 'display_errors' => 'On', - 'enable_blacklist' => 0, - 'code_scanner_scope' => 'import_plugin,enable_plugin,import_process,trigger', - 'system_utc_time_zone' => 0, - 'server_protocol' => '', - 'leave_case_warning' => 0, - 'server_hostname_requests_frontend' => '', - 'load_headers_ie' => 0, 'redirect_to_mobile' => 0, - 'disable_php_upload_execution' => 0, - 'disable_download_documents_session_validation' => 0, - 'logs_max_files' => 60, - 'logs_location' => '', - 'logging_level' => 'INFO', - 'smtp_timeout' => 20, - 'google_map_api_key' => '', - 'google_map_signature' => '', - 'upload_attempts_limit_per_user' => '60,1', - 'files_white_list' => '', - 'delay' => '0', - 'tries' => '10', - 'retry_after' => '90', - 'mobile_offline_tables_download_interval' => 24, - 'highlight_home_folder_enable' => 0, - '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, - 'report_table_floating_number' => 4, 'report_table_double_number' => 4, - 'ext_ajax_timeout' => 600000, - 'disable_task_manager_routing_async' => '0', - 'on_one_server_enable' => 0, - 'at_risk_delegation_max_time' => '0.2', - 'samesite_cookie_setting' => '' + 'report_table_floating_number' => 4, + 'retry_after' => '90', + 'samesite_cookie_setting' => '', + 'safari_cookie_lifetime' => 1, + 'server_protocol' => '', + 'server_hostname_requests_frontend' => '', + 'size_log_file' => 5000000, + 'smtp_timeout' => 20, + 'system_utc_time_zone' => 0, + 'time_zone' => 'America/New_York', + 'tries' => '10', + 'upload_attempts_limit_per_user' => '60,1', + 'wsdl_cache' => 1, ]; public static $cookieDefaultOptions = [ @@ -94,7 +95,6 @@ class System 'path' => '/', 'domain' => '', 'secure' => false, - 'httponly' => true, 'samesite' => '' ]; @@ -1819,6 +1819,14 @@ class System // Set the "samesite" option according to the system configuration $cookieOptions['samesite'] = $systemConfiguration['samesite_cookie_setting']; + // Set the "httponly" option according to the system configuration + $httpOnly = $systemConfiguration['enable_httponly_flag']; + if ($httpOnly) { + $cookieOptions['httponly'] = true; + } else { + $cookieOptions['httponly'] = false; + } + // Overrides the cookie options with the values sent to the method $cookieOptions = array_merge($cookieOptions, $options); diff --git a/workflow/engine/src/ProcessMaker/Model/AdditionalTables.php b/workflow/engine/src/ProcessMaker/Model/AdditionalTables.php index c25583b75..c9e77ab40 100644 --- a/workflow/engine/src/ProcessMaker/Model/AdditionalTables.php +++ b/workflow/engine/src/ProcessMaker/Model/AdditionalTables.php @@ -32,6 +32,34 @@ class AdditionalTables extends Model return $query->where('ADD_TAB_OFFLINE', '=', 1); } + /** + * Scope a query to get the tables related to the process + * + * @param \Illuminate\Database\Eloquent\Builder $query + * @param string $proUid + * + * @return \Illuminate\Database\Eloquent\Builder + */ + public function scopeProcess($query, string $proUid) + { + return $query->where('PRO_UID', $proUid); + } + + /** + * Get tables related to the process + * + * @param string $proUid + * @return array + */ + public static function getTables(string $proUid) + { + $query = AdditionalTables::query()->select(); + $query->process($proUid); + $result = $query->get()->values()->toArray(); + + return $result; + } + /** * Get the structure of offline tables * diff --git a/workflow/engine/src/ProcessMaker/Model/Fields.php b/workflow/engine/src/ProcessMaker/Model/Fields.php index 6283dd69c..e5841b8d6 100644 --- a/workflow/engine/src/ProcessMaker/Model/Fields.php +++ b/workflow/engine/src/ProcessMaker/Model/Fields.php @@ -32,6 +32,39 @@ class Fields extends Model return $query->where('ADD_TAB_UID', '=', $tabUid); } + /** + * Scope a query to get the field name + * + * @param \Illuminate\Database\Eloquent\Builder $query + * @param string $name + * + * @return \Illuminate\Database\Eloquent\Builder + */ + public function scopeField($query, $name) + { + return $query->where('FLD_NAME', $name); + } + + /** + * Scope a query to get the field name or label name + * + * @param \Illuminate\Database\Eloquent\Builder $query + * @param string $field + * + * @return \Illuminate\Database\Eloquent\Builder + */ + public function scopeFieldOrLabel($query, $field) + { + $query->where(function ($query) use ($field) { + $query->field($field); + $fieldLabel = $field . '_label'; + $query->orWhere(function ($query) use ($fieldLabel) { + $query->field($fieldLabel); + }); + }); + return $query; + } + /** * Get the offline tables * @@ -52,4 +85,22 @@ class Fields extends Model return $data; } + + /** + * Search a field related to the table + * + * @param string $tabUid + * @param string $field + * + * @return bool + */ + public static function searchVariable(string $tabUid, string $field) + { + $query = Fields::query(); + $query->table($tabUid); + $query->fieldOrLabel($field); + $result = $query->get()->values()->toArray(); + + return !empty($result); + } } \ No newline at end of file diff --git a/workflow/engine/src/ProcessMaker/Model/ProcessVariables.php b/workflow/engine/src/ProcessMaker/Model/ProcessVariables.php index 8647380e7..53cd4d7d2 100644 --- a/workflow/engine/src/ProcessMaker/Model/ProcessVariables.php +++ b/workflow/engine/src/ProcessMaker/Model/ProcessVariables.php @@ -87,6 +87,23 @@ class ProcessVariables extends Model return $query->where('VAR_FIELD_TYPE_ID', $typeId); } + /** + * Return the variable information + * + * @param string $varUid + * + * @return array + */ + public static function getVariable(string $varUid) + { + $query = ProcessVariables::query()->select(); + $query->where('VAR_UID', $varUid)->limit(1); + $result = $query->get()->values()->toArray(); + $result = head($result); + + return $result; + } + /** * Return the variables list * diff --git a/workflow/engine/src/ProcessMaker/Services/Api/Cases.php b/workflow/engine/src/ProcessMaker/Services/Api/Cases.php index c24389379..3518785db 100644 --- a/workflow/engine/src/ProcessMaker/Services/Api/Cases.php +++ b/workflow/engine/src/ProcessMaker/Services/Api/Cases.php @@ -66,7 +66,7 @@ class Cases extends Api $arrayArgs = $this->restler->apiMethodInfo->arguments; switch ($methodName) { case 'doGetCaseVariables': - $applicationUid = $this->parameters[$arrayArgs['app_uid']]; + $applicationUid = $this->parameters[$arrayArgs['appUid']]; $dynaformUid = $this->parameters[$arrayArgs['dyn_uid']]; $delIndex = $this->parameters[$arrayArgs['app_index']]; $userUid = $this->getUserId(); @@ -89,7 +89,7 @@ class Cases extends Api return $cases->checkUserHasPermissionsOrSupervisor($userUid, $applicationUid, $dynaformUid); break; case 'doPutCaseVariables': - $applicationUid = $this->parameters[$arrayArgs['app_uid']]; + $applicationUid = $this->parameters[$arrayArgs['appUid']]; $dynaformUid = $this->parameters[$arrayArgs['dyn_uid']]; $delIndex = $this->parameters[$arrayArgs['del_index']]; $userUid = $this->getUserId(); @@ -143,15 +143,15 @@ class Cases extends Api return $user->userCanReassign($usrUid, $arrayApplicationData['PRO_UID']); break; case 'doGetCaseInfo': - $appUid = $this->parameters[$arrayArgs['app_uid']]; + $appUid = $this->parameters[$arrayArgs['appUid']]; $usrUid = $this->getUserId(); $case = new BmCases(); $arrayApplicationData = $case->getApplicationRecordByPk($appUid, [], false); if (!empty($arrayApplicationData)) { $criteria = new Criteria('workflow'); - $criteria->addSelectColumn(AppDelegationPeer::appUid); - $criteria->add(AppDelegationPeer::appUid, $appUid); + $criteria->addSelectColumn(AppDelegationPeer::APP_UID); + $criteria->add(AppDelegationPeer::APP_UID, $appUid); $criteria->add(AppDelegationPeer::USR_UID, $usrUid); $criteria->setLimit(1); $rsCriteria = AppDelegationPeer::doSelectRS($criteria); diff --git a/workflow/engine/src/ProcessMaker/Services/Api/Cases/InputDocument.php b/workflow/engine/src/ProcessMaker/Services/Api/Cases/InputDocument.php index afcec50ae..68ff474ae 100644 --- a/workflow/engine/src/ProcessMaker/Services/Api/Cases/InputDocument.php +++ b/workflow/engine/src/ProcessMaker/Services/Api/Cases/InputDocument.php @@ -6,6 +6,7 @@ use Luracast\Restler\RestException; use ProcessMaker\BusinessModel\Cases\InputDocument as CasesInputDocument; use ProcessMaker\BusinessModel\Cases as BussinessModelCases; use ProcessMaker\Services\Api; +use ProcessMaker\Util\DateTime; /** * Cases\InputDocument Api Controller @@ -14,6 +15,10 @@ use ProcessMaker\Services\Api; */ class InputDocument extends Api { + private $arrayFieldIso8601 = [ + 'app_doc_create_date', + 'app_doc_create_user', + ]; /** * @url GET /:app_uid/input-documents * @@ -55,7 +60,7 @@ class InputDocument extends Api //Return return $response; } catch (Exception $e) { - throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } } @@ -69,11 +74,11 @@ class InputDocument extends Api { try { $userUid = $this->getUserId(); - $inputDocument = new \ProcessMaker\BusinessModel\Cases\InputDocument(); + $inputDocument = new CasesInputDocument(); $response = $inputDocument->getCasesInputDocument($app_uid, $userUid, $inp_doc_uid); return $response; - } catch (\Exception $e) { - throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } catch (Exception $e) { + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } } @@ -88,9 +93,9 @@ class InputDocument extends Api public function doDownloadInputDocument($app_uid, $app_doc_uid, $v = 0) { try { - $inputDocument = new \ProcessMaker\BusinessModel\Cases\InputDocument(); + $inputDocument = new CasesInputDocument(); $inputDocument->downloadInputDocument($app_uid, $app_doc_uid, $v); - } catch (\Exception $e) { + } catch (Exception $e) { throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } } @@ -107,12 +112,12 @@ class InputDocument extends Api public function doDeleteInputDocument($app_uid, $del_index, $app_doc_uid) { try { - $inputDocument = new \ProcessMaker\BusinessModel\Cases\InputDocument(); + $inputDocument = new CasesInputDocument(); $inputDocument->throwExceptionIfHaventPermissionToDelete($app_uid, $del_index, $this->getUserId(), $app_doc_uid); $inputDocument->throwExceptionIfInputDocumentNotExistsInSteps($app_uid, $del_index, $app_doc_uid); $inputDocument->removeInputDocument($app_doc_uid); - } catch (\Exception $e) { + } catch (Exception $e) { throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } } @@ -141,11 +146,11 @@ class InputDocument extends Api try { $userUid = $this->getUserId(); - $inputDocument = new \ProcessMaker\BusinessModel\Cases\InputDocument(); + $inputDocument = new CasesInputDocument(); $response = $inputDocument->addCasesInputDocument($app_uid, $tas_uid, $app_doc_comment, $inp_doc_uid, $userUid, false); return $response; - } catch (\Exception $e) { - throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } catch (Exception $e) { + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } } @@ -162,7 +167,7 @@ class InputDocument extends Api try { $inputDocument = new CasesInputDocument(); $response = $inputDocument->getAllVersionByDocUid($app_uid, $app_doc_uid); - return $response; + return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601); } catch (Exception $e) { throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } diff --git a/workflow/engine/src/ProcessMaker/Services/Api/Home.php b/workflow/engine/src/ProcessMaker/Services/Api/Home.php index a43a41bd2..4323fb419 100644 --- a/workflow/engine/src/ProcessMaker/Services/Api/Home.php +++ b/workflow/engine/src/ProcessMaker/Services/Api/Home.php @@ -342,6 +342,7 @@ class Home extends Api * @param int $category * @param int $process * @param int $task + * @param int $sendBy * @param int $limit * @param int $offset * @param string $caseTitle @@ -349,7 +350,6 @@ class Home extends Api * @param string $delegateTo * @param string $filterCases * @param string $sort - * @param string $sendBy * @param array $request_data * @return array * @throws RestException @@ -362,6 +362,7 @@ class Home extends Api int $category = 0, int $process = 0, int $task = 0, + int $sendBy = 0, int $limit = 15, int $offset = 0, string $caseTitle = '', @@ -369,7 +370,6 @@ class Home extends Api string $delegateTo = '', string $filterCases = '', string $sort = 'APP_NUMBER,DESC', - string $sendBy = '', array $request_data = [] ) { @@ -404,6 +404,7 @@ class Home extends Api * @param int $category * @param int $process * @param int $task + * @param int $sendBy * @param int $limit * @param int $offset * @param string $caseTitle @@ -411,7 +412,6 @@ class Home extends Api * @param string $delegateTo * @param string $filterCases * @param string $sort - * @param string $sendBy * @param array $request_data * @return array * @throws RestException @@ -424,6 +424,7 @@ class Home extends Api int $category = 0, int $process = 0, int $task = 0, + int $sendBy = 0, int $limit = 15, int $offset = 0, string $caseTitle = '', @@ -431,7 +432,6 @@ class Home extends Api string $delegateTo = '', string $filterCases = '', string $sort = 'APP_NUMBER,DESC', - string $sendBy = '', array $request_data = [] ) { @@ -466,6 +466,7 @@ class Home extends Api * @param int $category * @param int $process * @param int $task + * @param int $sendBy * @param int $limit * @param int $offset * @param string $caseTitle @@ -473,7 +474,6 @@ class Home extends Api * @param string $delegateTo * @param string $filterCases * @param string $sort - * @param string $sendBy * @param array $request_data * @return array * @throws RestException @@ -486,6 +486,7 @@ class Home extends Api int $category = 0, int $process = 0, int $task = 0, + int $sendBy = 0, int $limit = 15, int $offset = 0, string $caseTitle = '', @@ -493,7 +494,6 @@ class Home extends Api string $delegateTo = '', string $filterCases = '', string $sort = 'APP_NUMBER,DESC', - string $sendBy = '', array $request_data = [] ) { @@ -695,10 +695,10 @@ class Home extends Api * @param int $process * @param int $task * @param int $user - * @param int $userCompleted - * @param int $userStarted * @param int $limit * @param int $offset + * @param int $completedBy + * @param int $startedBy * @param string $caseTitle * @param string $caseStatuses * @param string $filterCases @@ -721,10 +721,10 @@ class Home extends Api int $process = 0, int $task = 0, int $user = 0, - int $userCompleted = 0, - int $userStarted = 0, int $limit = 15, int $offset = 0, + int $completedBy = 0, + int $startedBy = 0, string $caseTitle = '', string $caseStatuses = '', string $filterCases = '', @@ -744,8 +744,8 @@ class Home extends Api $properties['process'] = $process; $properties['task'] = $task; $properties['user'] = $user; - $properties['userCompleted'] = $userCompleted; - $properties['userStarted'] = $userStarted; + $properties['userCompleted'] = $completedBy; + $properties['userStarted'] = $startedBy; $properties['caseStatuses'] = explode(',', $caseStatuses); $properties['filterCases'] = $filterCases; $properties['startCaseFrom'] = $startCaseFrom; diff --git a/workflow/engine/src/ProcessMaker/Services/Api/Project.php b/workflow/engine/src/ProcessMaker/Services/Api/Project.php index 5ffbeddc7..1a5bba2c3 100644 --- a/workflow/engine/src/ProcessMaker/Services/Api/Project.php +++ b/workflow/engine/src/ProcessMaker/Services/Api/Project.php @@ -204,7 +204,7 @@ class Project extends Api \G::auditLog('ExportProcess','Export process "' . $granularExporter->getProjectName() . '"'); $httpStream->loadFromFile($outputFilename); - $httpStream->setHeader("Content-Type", "application/xml; charset=UTF-8"); + $httpStream->setHeader("Content-Type", "application/$fileExtension"); $httpStream->send(); } @@ -232,7 +232,7 @@ class Project extends Api \G::auditLog('ExportProcess','Export process "' . $exporter->getProjectName() . '"'); $httpStream->loadFromFile($outputFilename); - $httpStream->setHeader("Content-Type", "application/xml; charset=UTF-8"); + $httpStream->setHeader("Content-Type", "application/$fileExtension"); $httpStream->send(); } diff --git a/workflow/engine/src/ProcessMaker/Services/Api/User.php b/workflow/engine/src/ProcessMaker/Services/Api/User.php index 43842be7a..556ef88d5 100644 --- a/workflow/engine/src/ProcessMaker/Services/Api/User.php +++ b/workflow/engine/src/ProcessMaker/Services/Api/User.php @@ -1,8 +1,11 @@ setFormatFieldNameInUppercase(false); - $arrayFilterData = array( + $arrayFilterData = [ "filter" => (!is_null($filter))? $filter : ((!is_null($lfilter))? $lfilter : ((!is_null($rfilter))? $rfilter : null)), "filterOption" => (!is_null($filter))? "" : ((!is_null($lfilter))? "LEFT" : ((!is_null($rfilter))? "RIGHT" : "")) - ); + ]; - $response = $user->getUsers($arrayFilterData, null, null, $start, $limit, false, true, $status); + $response = $user->getUsers($arrayFilterData, $sort, $dir, $start, $limit, false, true, $status); - return \ProcessMaker\Util\DateTime::convertUtcToIso8601($response['data'], $this->arrayFieldIso8601); - } catch (\Exception $e) { + return DateTime::convertUtcToIso8601($response['data'], $this->arrayFieldIso8601); + } catch (Exception $e) { throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } } @@ -50,13 +53,12 @@ class User extends Api public function doGetUser($usr_uid) { try { - $user = new \ProcessMaker\BusinessModel\User(); + $user = new BmUser(); $user->setFormatFieldNameInUppercase(false); - $response = $user->getUser($usr_uid); - return \ProcessMaker\Util\DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601); - } catch (\Exception $e) { + return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601); + } catch (Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } } @@ -73,12 +75,13 @@ class User extends Api public function doPostUser($request_data) { try { - $user = new \ProcessMaker\BusinessModel\User(); + $user = new BmUser(); $arrayData = $user->create($request_data); $response = $arrayData; + return $response; - } catch (\Exception $e) { - throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } catch (Exception $e) { + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } } @@ -99,10 +102,10 @@ class User extends Api { try { $userLoggedUid = $this->getUserId(); - $user = new \ProcessMaker\BusinessModel\User(); + $user = new BmUser(); $arrayData = $user->update($usr_uid, $request_data, $userLoggedUid); - } catch (\Exception $e) { - throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } catch (Exception $e) { + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } } @@ -116,10 +119,10 @@ class User extends Api public function doDeleteUser($usr_uid) { try { - $user = new \ProcessMaker\BusinessModel\User(); + $user = new BmUser(); $user->delete($usr_uid); - } catch (\Exception $e) { - throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } catch (Exception $e) { + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } } @@ -133,10 +136,9 @@ class User extends Api public function doPostUserImageUpload($usr_uid) { try { - $user = new \ProcessMaker\BusinessModel\User(); + $user = new BmUser(); $user->uploadImage($usr_uid); - } catch (\Exception $e) { - //response + } catch (Exception $e) { throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } } diff --git a/workflow/engine/templates/cases/caseHistory.js b/workflow/engine/templates/cases/caseHistory.js index b501f129b..4dcf45717 100644 --- a/workflow/engine/templates/cases/caseHistory.js +++ b/workflow/engine/templates/cases/caseHistory.js @@ -199,8 +199,8 @@ {name : 'CASES_COUNT', type:'float'}, {name : 'APP_TYPE'}, {name : 'DEL_FINISH_DATE_LABEL'}, - {name : 'APP_ENABLE_ACTION_DATE'}, - {name : 'APP_DISABLE_ACTION_DATE'} + {name : 'APP_ENABLE_ACTION_DATE_LABEL'}, + {name : 'APP_DISABLE_ACTION_DATE_LABEL'} ] } ) @@ -278,18 +278,12 @@ {header: "", dataIndex: 'PRO_STATUS', width: 50, hidden:true, hideable:false}, {header: _("ID_CASESLIST_APP_TAS_TITLE"), dataIndex: 'TAS_TITLE', width: 100}, {header: _("ID_DELEGATE_USER"), dataIndex: 'USR_NAME', width: 60, hidden:false}, - /*{header: TRANSLATIONS.ID_STATUS, dataIndex: 'PRO_STATUS_LABEL', width: 50, renderer:function(v,p,r){ - color = r.get('PRO_STATUS') == 'ACTIVE'? 'green': 'red'; - return String.format("{1}", color, v); - }},*/ {header: _("ID_TASK_TRANSFER"), dataIndex: 'DEL_DELEGATE_DATE_LABEL', width: 60}, {header: _("ID_START_DATE"), dataIndex: 'DEL_INIT_DATE_LABEL', width: 60}, {header: _("ID_END_DATE"), dataIndex: 'DEL_FINISH_DATE_LABEL', width: 60}, {header: _("ID_ACTION"), dataIndex: 'APP_TYPE', width: 50, renderer: actionRenderingTranslation}, - {header: _("ID_ENABLE_ACTION"), dataIndex: 'APP_ENABLE_ACTION_DATE', width: 70, renderer:startDateRender}, - {header: _("ID_DISABLE_ACTION"), dataIndex: 'APP_DISABLE_ACTION_DATE', width: 70, renderer:startDateRender} - //{header: TRANSLATIONS.ID_TOTAL_CASES, dataIndex: 'CASES_COUNT', width: 80,renderer:function(v){return ""+v+"";}, align:'right'}, - //{header: TRANSLATIONS.ID_PRO_DEBUG, dataIndex: 'PRO_DEBUG_LABEL', width: 50, align:'center'} + {header: _("ID_ENABLE_ACTION"), dataIndex: 'APP_ENABLE_ACTION_DATE_LABEL', width: 70, renderer:startDateRender}, + {header: _("ID_DISABLE_ACTION"), dataIndex: 'APP_DISABLE_ACTION_DATE_LABEL', width: 70, renderer:startDateRender} ] }), store: store, diff --git a/workflow/engine/xmlform/login/changePasswordpm3.xml b/workflow/engine/xmlform/login/changePasswordpm3.xml index 9147f5894..24731f8ec 100644 --- a/workflow/engine/xmlform/login/changePasswordpm3.xml +++ b/workflow/engine/xmlform/login/changePasswordpm3.xml @@ -108,6 +108,11 @@ var verifyPassword = function() { return; } } + //Spaces not supported at the end of passwords + if (oPassword1.value.slice(-1) === ' ') { + alert('@G::LoadTranslation(ID_PPP_SPACES_NOT_SUPPORTED_AT_THE_END_OF_PASSWORD)'); + return; + } oPassword1.form.submit(); };