diff --git a/database/factories/ProcessFactory.php b/database/factories/ProcessFactory.php index afdf407dc..99c42f5a0 100644 --- a/database/factories/ProcessFactory.php +++ b/database/factories/ProcessFactory.php @@ -10,7 +10,7 @@ $factory->define(\ProcessMaker\Model\Process::class, function (Faker $faker) { return [ 'PRO_UID' => G::generateUniqueID(), - 'PRO_ID' => $faker->unique()->numberBetween(1000), + 'PRO_ID' => $faker->unique()->numberBetween(2000), 'PRO_TITLE' => $faker->sentence(3), 'PRO_DESCRIPTION' => $faker->paragraph(3), 'PRO_PARENT' => G::generateUniqueID(), diff --git a/tests/unit/workflow/engine/classes/PmFunctions/CapitalizeTest.php b/tests/unit/workflow/engine/classes/PmFunctions/CapitalizeTest.php new file mode 100644 index 000000000..dcd89ce84 --- /dev/null +++ b/tests/unit/workflow/engine/classes/PmFunctions/CapitalizeTest.php @@ -0,0 +1,23 @@ +assertNotEmpty($result); + } +} diff --git a/tests/unit/workflow/engine/classes/PmFunctions/FormatDateTest.php b/tests/unit/workflow/engine/classes/PmFunctions/FormatDateTest.php new file mode 100644 index 000000000..03b8a0332 --- /dev/null +++ b/tests/unit/workflow/engine/classes/PmFunctions/FormatDateTest.php @@ -0,0 +1,34 @@ +assertNotEmpty($result); + } + + /** + * This tests the "formatDate" + * @test + */ + public function it_get_exceptions() + { + $this->expectException(Exception::class); + $result = formatDate(''); + } +} diff --git a/tests/unit/workflow/engine/classes/PmFunctions/GenerateCodeTest.php b/tests/unit/workflow/engine/classes/PmFunctions/GenerateCodeTest.php new file mode 100644 index 000000000..85282fb7f --- /dev/null +++ b/tests/unit/workflow/engine/classes/PmFunctions/GenerateCodeTest.php @@ -0,0 +1,23 @@ +assertNotEmpty($result); + } +} diff --git a/tests/unit/workflow/engine/classes/PmFunctions/GetCurrentDateTest.php b/tests/unit/workflow/engine/classes/PmFunctions/GetCurrentDateTest.php new file mode 100644 index 000000000..0131842a6 --- /dev/null +++ b/tests/unit/workflow/engine/classes/PmFunctions/GetCurrentDateTest.php @@ -0,0 +1,23 @@ +assertNotEmpty($result); + } +} diff --git a/tests/unit/workflow/engine/classes/PmFunctions/GetCurrentTimeTest.php b/tests/unit/workflow/engine/classes/PmFunctions/GetCurrentTimeTest.php new file mode 100644 index 000000000..660881e57 --- /dev/null +++ b/tests/unit/workflow/engine/classes/PmFunctions/GetCurrentTimeTest.php @@ -0,0 +1,23 @@ +assertNotEmpty($result); + } +} diff --git a/tests/unit/workflow/engine/classes/PmFunctions/LiteralDateTest.php b/tests/unit/workflow/engine/classes/PmFunctions/LiteralDateTest.php new file mode 100644 index 000000000..695dc9449 --- /dev/null +++ b/tests/unit/workflow/engine/classes/PmFunctions/LiteralDateTest.php @@ -0,0 +1,36 @@ +assertNotEmpty($result); + $result = literalDate(date('Y-m-d'), 'es'); + $this->assertNotEmpty($result); + } + + /** + * This tests the "literalDate" + * @test + */ + public function it_get_exceptions() + { + $this->expectException(Exception::class); + $result = literalDate(''); + } +} diff --git a/tests/unit/workflow/engine/classes/PmFunctions/LowerCaseTest.php b/tests/unit/workflow/engine/classes/PmFunctions/LowerCaseTest.php new file mode 100644 index 000000000..4522967c9 --- /dev/null +++ b/tests/unit/workflow/engine/classes/PmFunctions/LowerCaseTest.php @@ -0,0 +1,23 @@ +assertNotEmpty($result); + } +} diff --git a/tests/unit/workflow/engine/classes/PmFunctions/OrderGridTest.php b/tests/unit/workflow/engine/classes/PmFunctions/OrderGridTest.php new file mode 100644 index 000000000..b00447371 --- /dev/null +++ b/tests/unit/workflow/engine/classes/PmFunctions/OrderGridTest.php @@ -0,0 +1,30 @@ +assertNotEmpty($result); + $result = orderGrid($result, 'AGE', 'DESC'); + $this->assertNotEmpty($result); + } +} diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFAddCaseNoteTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFAddCaseNoteTest.php new file mode 100644 index 000000000..7a030d362 --- /dev/null +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFAddCaseNoteTest.php @@ -0,0 +1,32 @@ +states('foreign_keys')->create(); + // Force commit for propel + DB::commit(); + $result = PMFAddCaseNote($table->APP_UID, $table->PRO_UID, $table->TAS_UID, $table->USR_UID, 'note'); + $this->assertTrue($result >= 0); + } +} diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFAssignUserToGroupTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFAssignUserToGroupTest.php new file mode 100644 index 000000000..4a50e0ec5 --- /dev/null +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFAssignUserToGroupTest.php @@ -0,0 +1,42 @@ +create(); + factory(RbacUsers::class)->create([ + 'USR_UID' => $user->USR_UID, + 'USR_USERNAME' => $user->USR_USERNAME, + 'USR_FIRSTNAME' => $user->USR_FIRSTNAME, + 'USR_LASTNAME' => $user->USR_LASTNAME + ]); + // Create group + $group = factory(Groupwf::class)->create(); + DB::commit(); + $result = PMFAssignUserToGroup($user->USR_UID, $group->GRP_UID); + $this->assertNotEmpty($result); + } +} \ No newline at end of file diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFCaseInformationTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFCaseInformationTest.php index ed7752f3d..07b8f56e1 100644 --- a/tests/unit/workflow/engine/classes/PmFunctions/PMFCaseInformationTest.php +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFCaseInformationTest.php @@ -6,7 +6,6 @@ use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Facades\DB; use ProcessMaker\Model\Application; use ProcessMaker\Model\Delegation; -use RBAC; use Tests\TestCase; /** diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFCaseListTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFCaseListTest.php new file mode 100644 index 000000000..623592931 --- /dev/null +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFCaseListTest.php @@ -0,0 +1,36 @@ +states('foreign_keys')->create(); + factory(AppThread::class)->create([ + 'APP_THREAD_STATUS' => 'OPEN', + 'APP_UID' => $table->APP_UID + ]); + DB::commit(); + $result = PMFCaseList($table->USR_UID); + $this->assertNotEmpty($result); + } +} diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFCreateUserTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFCreateUserTest.php new file mode 100644 index 000000000..543a5f5ca --- /dev/null +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFCreateUserTest.php @@ -0,0 +1,39 @@ +create(); + factory(RbacUsers::class)->create([ + 'USR_UID' => $user->USR_UID, + 'USR_USERNAME' => $user->USR_USERNAME, + 'USR_FIRSTNAME' => $user->USR_FIRSTNAME, + 'USR_LASTNAME' => $user->USR_LASTNAME + ]); + DB::commit(); + $result = PMFCreateUser('jsmith', 'PaSsWoRd', 'John', 'Smith', 'jsmith@company.com', 'PROCESSMAKER_OPERATOR'); + $this->assertNotEmpty($result); + } +} diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFDeleteCaseTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFDeleteCaseTest.php new file mode 100644 index 000000000..ac923c6d8 --- /dev/null +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFDeleteCaseTest.php @@ -0,0 +1,37 @@ +expectException(Exception::class); + $table = factory(Delegation::class)->states('foreign_keys')->create(); + factory(Triggers::class)->create([ + 'PRO_UID' => $table->PRO_UID + ]); + // Force commit for propel + DB::commit(); + $result = PMFDeleteCase($table->APP_UID); + $this->assertEquals(0, $result); + } +} \ No newline at end of file diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFGetCaseNotesTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFGetCaseNotesTest.php new file mode 100644 index 000000000..8356e14ca --- /dev/null +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFGetCaseNotesTest.php @@ -0,0 +1,40 @@ +create(); + $table = factory(AppNotes::class)->create([ + 'USR_UID' => $user->USR_UID + ]); + // Force commit for propel + DB::commit(); + $result = PMFGetCaseNotes($table->APP_UID, 'array'); + $this->assertNotEmpty($result); + $result = PMFGetCaseNotes($table->APP_UID, 'object'); + $this->assertNotEmpty($result); + $result = PMFGetCaseNotes($table->APP_UID, 'string'); + $this->assertNotEmpty($result); + } +} diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFGetGroupNameTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFGetGroupNameTest.php new file mode 100644 index 000000000..02b8edf89 --- /dev/null +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFGetGroupNameTest.php @@ -0,0 +1,34 @@ +create(); + DB::commit(); + $result = PMFGetGroupName($group->GRP_TITLE, 'en'); + $this->assertFalse($result); + // When is empty + $result = PMFGetGroupName(''); + $this->assertFalse($result); + } +} diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFGetGroupUIDTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFGetGroupUIDTest.php new file mode 100644 index 000000000..b734415fd --- /dev/null +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFGetGroupUIDTest.php @@ -0,0 +1,29 @@ +create(); + $result = PMFGetGroupUID($group->GRP_UID); + $this->assertFalse($result); + } +} diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFGetGroupUsersTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFGetGroupUsersTest.php new file mode 100644 index 000000000..7158be644 --- /dev/null +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFGetGroupUsersTest.php @@ -0,0 +1,31 @@ +create(); + DB::commit(); + $result = PMFGetGroupUsers($group->GRP_UID); + $this->assertEmpty($result); + } +} diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFGetProcessUidByNameTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFGetProcessUidByNameTest.php new file mode 100644 index 000000000..3bf26bcdd --- /dev/null +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFGetProcessUidByNameTest.php @@ -0,0 +1,38 @@ +create(); + DB::commit(); + $result = PMFGetProcessUidByName($table->PRO_TITLE); + $this->assertNotEmpty($result); + // When a process was defined in the session + $result = PMFGetProcessUidByName(''); + $this->assertNotEmpty($result); + // When does not defined the session + $_SESSION['PROCESS'] = ''; + $result = PMFGetProcessUidByName(''); + $this->assertEmpty($result); + } +} diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFGetTaskNameTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFGetTaskNameTest.php new file mode 100644 index 000000000..298b91d4d --- /dev/null +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFGetTaskNameTest.php @@ -0,0 +1,34 @@ +create(); + DB::commit(); + $result = PMFGetTaskName($task->TAS_UID); + $this->assertNotEmpty($result); + // When is empty + $result = PMFGetTaskName(''); + $this->assertFalse($result); + } +} diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFGetTaskUIDTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFGetTaskUIDTest.php new file mode 100644 index 000000000..e1db6e911 --- /dev/null +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFGetTaskUIDTest.php @@ -0,0 +1,34 @@ +states('foreign_keys')->create(); + DB::commit(); + $result = PMFGetTaskUID($table->TAS_TITLE); + $this->assertFalse($result); + // When is empty + $result = PMFGetTaskUID($table->TAS_TITLE, $table->PRO_UID); + $this->assertNotEmpty($result); + } +} diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFGetUserEmailAddressTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFGetUserEmailAddressTest.php new file mode 100644 index 000000000..4750e1108 --- /dev/null +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFGetUserEmailAddressTest.php @@ -0,0 +1,30 @@ +create(); + DB::commit(); + $result = PMFGetUserEmailAddress([$user->USR_UID], null); + $this->assertNotEmpty($result); + } +} diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFGroupListTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFGroupListTest.php new file mode 100644 index 000000000..29ee9143c --- /dev/null +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFGroupListTest.php @@ -0,0 +1,31 @@ +create(); + DB::commit(); + $result = PMFGroupList(); + $this->assertNotEmpty($result); + } +} diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFInformationUserTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFInformationUserTest.php new file mode 100644 index 000000000..51606e76a --- /dev/null +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFInformationUserTest.php @@ -0,0 +1,32 @@ +create(); + DB::commit(); + $result = PMFInformationUser($user->USR_UID); + $this->assertNotEmpty($result); + } +} diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFNewCaseImpersonateTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFNewCaseImpersonateTest.php new file mode 100644 index 000000000..8766b32a8 --- /dev/null +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFNewCaseImpersonateTest.php @@ -0,0 +1,33 @@ +states('foreign_keys')->create(); + // Force commit for propel + DB::commit(); + $result = PMFNewCaseImpersonate($table->PRO_UID, $table->USR_UID, [], ''); + $this->assertEquals(0, $result); + } +} \ No newline at end of file diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFNewCaseTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFNewCaseTest.php new file mode 100644 index 000000000..76aafbfbf --- /dev/null +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFNewCaseTest.php @@ -0,0 +1,33 @@ +states('foreign_keys')->create(); + // Force commit for propel + DB::commit(); + $result = PMFNewCase($table->PRO_UID, $table->USR_UID, $table->TAS_UID, [], null); + $this->assertEquals(0, $result); + } +} \ No newline at end of file diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFNewUserTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFNewUserTest.php index 3d68233b4..085ae2ba2 100644 --- a/tests/unit/workflow/engine/classes/PmFunctions/PMFNewUserTest.php +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFNewUserTest.php @@ -2,6 +2,8 @@ namespace Tests\unit\workflow\engine\classes\PmFunctions; +use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Support\Facades\DB; use ProcessMaker\Model\GroupUser; use ProcessMaker\Model\Groupwf; use ProcessMaker\Model\RbacUsers; @@ -9,6 +11,9 @@ use ProcessMaker\Model\User; use RBAC; use Tests\TestCase; +/** + * Test the PMFNewUserTest() function + */ class PMFNewUserTest extends TestCase { /** @@ -53,10 +58,11 @@ class PMFNewUserTest extends TestCase $group = factory(Groupwf::class)->create(); + // Active $result = PMFNewUser("test", "Test123*", "test", "test", "test@test.com", "PROCESSMAKER_ADMIN", null, null, $group['GRP_UID']); $query = GroupUser::select(); - $r = $query->get()->values()->toArray(); + $r = $query->where('GRP_UID', $group['GRP_UID'])->get()->values()->toArray(); $this->assertEquals($r[0]['GRP_UID'], $result['groupUid']); $this->assertEquals($r[0]['USR_UID'], $result['userUid']); @@ -67,6 +73,14 @@ class PMFNewUserTest extends TestCase $this->assertNotEmpty($r); $this->assertEquals($result['userUid'], $r[0]['USR_UID']); $this->assertEquals($result['username'], $r[0]['USR_USERNAME']); + + // Vacation + $result = PMFNewUser("test11", "Test123*", "test", "test", "test@test.com", "PROCESSMAKER_ADMIN", null, 'VACATION', $group['GRP_UID']); + $this->assertEquals('VACATION', $result['status']); + + // Inactive + $result = PMFNewUser("test22", "Test123*", "test", "test", "test@test.com", "PROCESSMAKER_ADMIN", null, 'INACTIVE', $group['GRP_UID']); + $this->assertEquals('INACTIVE', $result['status']); } /** diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFProcessListTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFProcessListTest.php new file mode 100644 index 000000000..b15b437f8 --- /dev/null +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFProcessListTest.php @@ -0,0 +1,29 @@ +create(); + $result = PMFProcessList(); + $this->assertNotEmpty($result); + } +} diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFRemoveMaskTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFRemoveMaskTest.php new file mode 100644 index 000000000..5bef65f9b --- /dev/null +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFRemoveMaskTest.php @@ -0,0 +1,21 @@ +assertNotEmpty($result); + } +} diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFRemoveUsersFromGroupTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFRemoveUsersFromGroupTest.php new file mode 100644 index 000000000..5f84140a9 --- /dev/null +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFRemoveUsersFromGroupTest.php @@ -0,0 +1,39 @@ +create(); + $group = factory(Groupwf::class)->create(); + $groupUser = factory(GroupUser::class)->create([ + 'GRP_UID' => $group->GRP_UID, + 'GRP_ID' => $group->GRP_ID, + 'USR_UID' =>$user->USR_UID + ]); + DB::commit(); + $result = PMFRemoveUsersFromGroup($groupUser->GRP_UID, [$groupUser->USR_UID]); + $this->assertNotEmpty($result); + } +} diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFRemoveUsersToGroupTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFRemoveUsersToGroupTest.php new file mode 100644 index 000000000..3c35b59f7 --- /dev/null +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFRemoveUsersToGroupTest.php @@ -0,0 +1,39 @@ +create(); + $group = factory(Groupwf::class)->create(); + $groupUser = factory(GroupUser::class)->create([ + 'GRP_UID' => $group->GRP_UID, + 'GRP_ID' => $group->GRP_ID, + 'USR_UID' =>$user->USR_UID + ]); + DB::commit(); + $result = PMFRemoveUsersToGroup($groupUser->GRP_UID, [$groupUser->USR_UID]); + $this->assertNotEmpty($result); + } +} diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFRoleListTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFRoleListTest.php new file mode 100644 index 000000000..89d18e9ef --- /dev/null +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFRoleListTest.php @@ -0,0 +1,32 @@ +create(); + DB::commit(); + $result = PMFRoleList(); + $this->assertNotEmpty($result); + } +} diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFTaskCaseTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFTaskCaseTest.php new file mode 100644 index 000000000..dd0f4e639 --- /dev/null +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFTaskCaseTest.php @@ -0,0 +1,35 @@ +create(); + $table = factory(Delegation::class)->states('foreign_keys')->create([ + 'TAS_ID' => $task->TAS_ID, + 'TAS_UID' => $task->TAS_UID + ]); + DB::commit(); + $result = PMFTaskCase($table->APP_UID); + $this->assertNotEmpty($result); + } +} diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFTaskListTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFTaskListTest.php new file mode 100644 index 000000000..a06d5728f --- /dev/null +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFTaskListTest.php @@ -0,0 +1,42 @@ +create(); + // Create user + $user = factory(User::class)->create(); + // Assign a user in the task + factory(TaskUser::class)->create([ + 'TAS_UID' => $task->TAS_UID, + 'USR_UID' => $user->USR_UID, + 'TU_RELATION' => 1, //Related to the user + 'TU_TYPE' => 1 + ]); + DB::commit(); + $result = PMFTaskList($user->USR_UID); + $this->assertNotEmpty($result); + } +} diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFTasksListByProcessIdTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFTasksListByProcessIdTest.php new file mode 100644 index 000000000..81867df76 --- /dev/null +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFTasksListByProcessIdTest.php @@ -0,0 +1,31 @@ +create(); + DB::commit(); + $result = PMFTasksListByProcessId($task->PRO_UID); + $this->assertNotEmpty($result); + } +} diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFUnpauseCaseTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFUnpauseCaseTest.php new file mode 100644 index 000000000..5decfe3de --- /dev/null +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFUnpauseCaseTest.php @@ -0,0 +1,34 @@ +expectException(Exception::class); + $table = factory(Delegation::class)->states('foreign_keys')->create(); + // Force commit for propel + DB::commit(); + $result = PMFUnpauseCase($table->APP_UID, $table->DEL_INDEX, $table->USR_UID); + $this->assertEquals(0, $result); + } +} \ No newline at end of file diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFUpdateUserTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFUpdateUserTest.php new file mode 100644 index 000000000..284621bfc --- /dev/null +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFUpdateUserTest.php @@ -0,0 +1,32 @@ +create(); + DB::commit(); + $result = PMFUpdateUser($user->USR_UID, $user->USR_USERNAME, 'John A.'); + $this->assertEquals(0, $result); + } +} diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFUserListTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFUserListTest.php new file mode 100644 index 000000000..6f91b52e4 --- /dev/null +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFUserListTest.php @@ -0,0 +1,29 @@ +create(); + $result = PMFUserList(); + $this->assertNotEmpty($result); + } +} diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PmSqlEscapeTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PmSqlEscapeTest.php new file mode 100644 index 000000000..3401ec829 --- /dev/null +++ b/tests/unit/workflow/engine/classes/PmFunctions/PmSqlEscapeTest.php @@ -0,0 +1,22 @@ +assertEquals($result, $value); + } +} diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PmToFloatTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PmToFloatTest.php new file mode 100644 index 000000000..760b15b14 --- /dev/null +++ b/tests/unit/workflow/engine/classes/PmFunctions/PmToFloatTest.php @@ -0,0 +1,22 @@ +assertEquals($result, 1.2); + } +} diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PmToIntegerTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PmToIntegerTest.php new file mode 100644 index 000000000..178fa508b --- /dev/null +++ b/tests/unit/workflow/engine/classes/PmFunctions/PmToIntegerTest.php @@ -0,0 +1,22 @@ +assertEquals($result, 1); + } +} diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PmToStringTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PmToStringTest.php new file mode 100644 index 000000000..78d9c9135 --- /dev/null +++ b/tests/unit/workflow/engine/classes/PmFunctions/PmToStringTest.php @@ -0,0 +1,22 @@ +assertEquals($result, '1'); + } +} diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PmToUrlTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PmToUrlTest.php new file mode 100644 index 000000000..bd0929bcb --- /dev/null +++ b/tests/unit/workflow/engine/classes/PmFunctions/PmToUrlTest.php @@ -0,0 +1,22 @@ +assertEquals($result, $value); + } +} diff --git a/tests/unit/workflow/engine/classes/PmFunctions/UpperCaseTest.php b/tests/unit/workflow/engine/classes/PmFunctions/UpperCaseTest.php new file mode 100644 index 000000000..20099f61c --- /dev/null +++ b/tests/unit/workflow/engine/classes/PmFunctions/UpperCaseTest.php @@ -0,0 +1,21 @@ +assertNotEmpty($result); + } +} diff --git a/tests/unit/workflow/engine/classes/PmFunctions/UserInfoTest.php b/tests/unit/workflow/engine/classes/PmFunctions/UserInfoTest.php new file mode 100644 index 000000000..d95f74e1d --- /dev/null +++ b/tests/unit/workflow/engine/classes/PmFunctions/UserInfoTest.php @@ -0,0 +1,30 @@ +create(); + DB::commit(); + $result = userInfo($user->USR_UID); + $this->assertNotEmpty($result); + } +} diff --git a/workflow/engine/classes/Cases.php b/workflow/engine/classes/Cases.php index 90b316da7..5cb24f582 100644 --- a/workflow/engine/classes/Cases.php +++ b/workflow/engine/classes/Cases.php @@ -7079,7 +7079,7 @@ class Cases * @return array|stdclass|string * */ - public function getCaseNotes($applicationID, $type = 'array', $userUid = '') + public static function getCaseNotes($applicationID, $type = 'array', $userUid = '') { require_once("classes/model/AppNotes.php"); $appNotes = new AppNotes(); @@ -7108,6 +7108,7 @@ class Cases case 'object': $response = new stdclass(); foreach ($appNotes['array']['notes'] as $key => $value) { + $response->$key = new stdclass(); $response->$key->FULL_NAME = $value['USR_FIRSTNAME'] . " " . $value['USR_LASTNAME']; foreach ($value as $keys => $value) { if ($keys != 'USR_FIRSTNAME' && $keys != 'USR_LASTNAME' && $keys != 'USR_EMAIL') { diff --git a/workflow/engine/classes/WsBase.php b/workflow/engine/classes/WsBase.php index 46389da51..2a70c3401 100644 --- a/workflow/engine/classes/WsBase.php +++ b/workflow/engine/classes/WsBase.php @@ -1204,7 +1204,9 @@ class WsBase { try { global $RBAC; - + if (is_null($RBAC)) { + $RBAC = RBAC::getSingleton(); + } $RBAC->initRBAC(); if (empty($userName)) { @@ -1715,6 +1717,9 @@ class WsBase { try { global $RBAC; + if (is_null($RBAC)) { + $RBAC = RBAC::getSingleton(); + } $RBAC->initRBAC(); $user = $RBAC->verifyUserId($userId); diff --git a/workflow/engine/classes/class.pmFunctions.php b/workflow/engine/classes/class.pmFunctions.php index 04f4d6d20..f9490b3f7 100644 --- a/workflow/engine/classes/class.pmFunctions.php +++ b/workflow/engine/classes/class.pmFunctions.php @@ -39,9 +39,9 @@ use ProcessMaker\Validation\SqlBlacklist; * @return date | $date | Current Date (Y-m-d) | It returns the current date as a string value. * */ -function getCurrentDate () +function getCurrentDate() { - return G::CurDate( 'Y-m-d' ); + return G::CurDate('Y-m-d'); } /** @@ -58,9 +58,9 @@ function getCurrentDate () * @return time | $time | Current Time (H:i:s)| The function returns the current time as a string. * */ -function getCurrentTime () +function getCurrentTime() { - return G::CurDate( 'H:i:s' ); + return G::CurDate('H:i:s'); } /** @@ -96,9 +96,9 @@ function userInfo($userUid) * @return string | $TextC | Text Converted | Returns a string with the text converted into upper case letters. * */ -function upperCase ($sText) +function upperCase($sText) { - return G::toUpper( $sText ); + return G::toUpper($sText); } /** @@ -115,9 +115,9 @@ function upperCase ($sText) * @return string | $TextC | Text Converted | Returns a string with the text converted into lower case letters. * */ -function lowerCase ($sText) +function lowerCase($sText) { - return G::toLower( $sText ); + return G::toLower($sText); } /** @@ -135,9 +135,9 @@ function lowerCase ($sText) * @return string | $TextC | Text Converted | It returns the introduced text with the first letter capitalized in each word and the subsequent letters into lowercase letters * */ -function capitalize ($sText) +function capitalize($sText) { - return G::capitalizeWords( $sText ); + return G::capitalizeWords($sText); } /** @@ -156,13 +156,13 @@ function capitalize ($sText) * @return string | $formatDate | Date whit format | It returns the passed date according to the given date format. * */ -function formatDate ($date, $format = '', $lang = 'en') +function formatDate($date, $format = '', $lang = 'en') { - if (! isset( $date ) or $date == '') { - throw new Exception( 'function:formatDate::Bad param' ); + if (!isset($date) or $date == '') { + throw new Exception('function:formatDate::Bad param'); } try { - return G::getformatedDate( $date, $format, $lang ); + return G::getformatedDate($date, $format, $lang); } catch (Exception $oException) { throw $oException; } @@ -183,18 +183,18 @@ function formatDate ($date, $format = '', $lang = 'en') * @return string | $literaDate | Literal date | It returns the literal date as a string value. * */ -function literalDate ($date, $lang = 'en') +function literalDate($date, $lang = 'en') { - if (! isset( $date ) or $date == '') { - throw new Exception( 'function:formatDate::Bad param' ); + if (!isset($date) or $date == '') { + throw new Exception('function:formatDate::Bad param'); } try { switch ($lang) { case 'en': - $ret = G::getformatedDate( $date, 'M d,yyyy', $lang ); + $ret = G::getformatedDate($date, 'M d,yyyy', $lang); break; case 'es': - $ret = G::getformatedDate( $date, 'd de M de yyyy', $lang ); + $ret = G::getformatedDate($date, 'd de M de yyyy', $lang); break; } return $ret; @@ -238,7 +238,7 @@ function executeQuery($sqlStatement, $dbConnectionUID = 'workflow', $parameters $con = Propel::getConnection($dbConnectionUID); $con->begin(); } - + try { try { $sqlStatementCheck = trim($sqlStatement); @@ -260,8 +260,8 @@ function executeQuery($sqlStatement, $dbConnectionUID = 'workflow', $parameters $result = $con->select($sqlStatement); // Convert to 1 index key array of array results $result = collect($result)->map(function ($x) { - return (array) $x; - })->toArray(); + return (array) $x; + })->toArray(); array_unshift($result, []); unset($result[0]); break; @@ -327,15 +327,15 @@ function executeQuery($sqlStatement, $dbConnectionUID = 'workflow', $parameters * @return array | $dataM | Grid Sorted | Grid sorted * */ -function orderGrid ($dataM, $field, $ord = 'ASC') +function orderGrid($dataM, $field, $ord = 'ASC') { - if (! is_array( $dataM ) or ! isset( $field ) or $field == '') { - throw new Exception( 'function:orderGrid Error!, bad parameters found!' ); + if (!is_array($dataM) or !isset($field) or $field == '') { + throw new Exception('function:orderGrid Error!, bad parameters found!'); } - for ($i = 1; $i <= count( $dataM ) - 1; $i ++) { - for ($j = $i + 1; $j <= count( $dataM ); $j ++) { - if (strtoupper( $ord ) == 'ASC') { - if (strtolower( $dataM[$j][$field] ) < strtolower( $dataM[$i][$field] )) { + for ($i = 1; $i <= count($dataM) - 1; $i++) { + for ($j = $i + 1; $j <= count($dataM); $j++) { + if (strtoupper($ord) == 'ASC') { + if (strtolower($dataM[$j][$field]) < strtolower($dataM[$i][$field])) { $swap = $dataM[$i]; $dataM[$i] = $dataM[$j]; $dataM[$j] = $swap; @@ -376,7 +376,7 @@ function evaluateFunction($aGrid, $sExpresion) $pmScript->setScript($sExpresion); $pmScript->setExecutedOn(PMScript::EVALUATE_FUNCTION); - for ($i = 1; $i <= count($aGrid); $i ++) { + for ($i = 1; $i <= count($aGrid); $i++) { $aFields = $aGrid[$i]; $pmScript->setFields($aFields); @@ -536,19 +536,21 @@ function PMFTotalCalculation($grid, $field, $function) * @return string | $unique ID | Unique Id |The unique ID for the initiated session. * */ -function WSLogin ($user, $pass, $endpoint = "") +function WSLogin($user, $pass, $endpoint = "") { - $client = WSOpen( true ); + $client = WSOpen(true); - $params = array ("userid" => $user,"password" => $pass + $params = array( + "userid" => $user, "password" => $pass ); - $result = $client->__soapCall( "login", array ($params - ) ); + $result = $client->__soapCall("login", array( + $params + )); if ($result->status_code == 0) { if ($endpoint != "") { - if (isset( $_SESSION["WS_SESSION_ID"] )) { + if (isset($_SESSION["WS_SESSION_ID"])) { $_SESSION["WS_END_POINT"] = $endpoint; } } @@ -563,13 +565,13 @@ function WSLogin ($user, $pass, $endpoint = "") return $result->message; } else { - if (isset( $_SESSION["WS_SESSION_ID"] )) { - unset( $_SESSION["WS_SESSION_ID"] ); + if (isset($_SESSION["WS_SESSION_ID"])) { + unset($_SESSION["WS_SESSION_ID"]); } - $wp = (trim( $pass ) != "") ? "YES" : "NO"; + $wp = (trim($pass) != "") ? "YES" : "NO"; - throw new Exception( "WSAccess denied! for user $user with password $wp" ); + throw new Exception("WSAccess denied! for user $user with password $wp"); } } @@ -588,9 +590,9 @@ function WSLogin ($user, $pass, $endpoint = "") * @return Object Client | $client | SoapClient object | A SoapClient object. If unable to establish a connection, returns NULL. * */ -function WSOpen ($force = false) +function WSOpen($force = false) { - if (isset( $_SESSION["WS_SESSION_ID"] ) || $force) { + if (isset($_SESSION["WS_SESSION_ID"]) || $force) { $optionsHeaders = array( "cache_wsdl" => WSDL_CACHE_NONE, "soap_version" => SOAP_1_1, @@ -605,17 +607,17 @@ function WSOpen ($force = false) ) ); - if (! isset( $_SESSION["WS_END_POINT"] )) { + if (!isset($_SESSION["WS_END_POINT"])) { $defaultEndpoint = $_SERVER["REQUEST_SCHEME"] . "://" . $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . "/sys" . config("system.workspace") . "/en/classic/services/wsdl2"; } - $endpoint = isset( $_SESSION["WS_END_POINT"] ) ? $_SESSION["WS_END_POINT"] : $defaultEndpoint; + $endpoint = isset($_SESSION["WS_END_POINT"]) ? $_SESSION["WS_END_POINT"] : $defaultEndpoint; - $client = new SoapClient( $endpoint, $optionsHeaders); + $client = new SoapClient($endpoint, $optionsHeaders); return $client; } else { - throw new Exception( "WS session is not open" ); + throw new Exception("WS session is not open"); } } @@ -633,32 +635,36 @@ function WSOpen ($force = false) * @return array | $rows | Array of tasks open | An array of tasks in the indicated case which have open delegations. * */ -function WSTaskCase ($caseId) +function WSTaskCase($caseId) { $client = WSOpen(); $sessionId = $_SESSION["WS_SESSION_ID"]; - $params = array ("sessionId" => $sessionId,"caseId" => $caseId + $params = array( + "sessionId" => $sessionId, "caseId" => $caseId ); - $result = $client->__soapCall( "taskCase", array ($params - ) ); + $result = $client->__soapCall("taskCase", array( + $params + )); - $rows = array (); + $rows = []; $i = 0; - if (isset( $result->taskCases )) { + if (isset($result->taskCases)) { //Processing when it is an array - if (is_array( $result->taskCases )) { + if (is_array($result->taskCases)) { foreach ($result->taskCases as $key => $obj) { - $rows[$i] = array ("guid" => $obj->guid,"name" => $obj->name + $rows[$i] = array( + "guid" => $obj->guid, "name" => $obj->name ); $i = $i + 1; } } else { //Processing when it is an object //1 row - if (is_object( $result->taskCases )) { - $rows[$i] = array ("guid" => $result->taskCases->guid,"name" => $result->taskCases->name + if (is_object($result->taskCases)) { + $rows[$i] = array( + "guid" => $result->taskCases->guid, "name" => $result->taskCases->name ); $i = $i + 1; } @@ -682,32 +688,36 @@ function WSTaskCase ($caseId) * @return array | $rows |List of tasks | This function returns a list of tasks * */ -function WSTaskList () +function WSTaskList() { $client = WSOpen(); $sessionId = $_SESSION["WS_SESSION_ID"]; - $params = array ("sessionId" => $sessionId + $params = array( + "sessionId" => $sessionId ); - $result = $client->__soapCall( "TaskList", array ($params - ) ); + $result = $client->__soapCall("TaskList", array( + $params + )); - $rows = array (); + $rows = []; $i = 0; - if (isset( $result->tasks )) { + if (isset($result->tasks)) { //Processing when it is an array - if (is_array( $result->tasks )) { + if (is_array($result->tasks)) { foreach ($result->tasks as $key => $obj) { - $rows[$i] = array ("guid" => $obj->guid,"name" => $obj->name + $rows[$i] = array( + "guid" => $obj->guid, "name" => $obj->name ); $i = $i + 1; } } else { //Processing when it is an object //1 row - if (is_object( $result->tasks )) { - $rows[$i] = array ("guid" => $result->tasks->guid,"name" => $result->tasks->name + if (is_object($result->tasks)) { + $rows[$i] = array( + "guid" => $result->tasks->guid, "name" => $result->tasks->name ); $i = $i + 1; } @@ -730,32 +740,36 @@ function WSTaskList () * @return array | $rows | List | List of Active users in the workspace * */ -function WSUserList () +function WSUserList() { $client = WSOpen(); $sessionId = $_SESSION["WS_SESSION_ID"]; - $params = array ("sessionId" => $sessionId + $params = array( + "sessionId" => $sessionId ); - $result = $client->__soapCall( "UserList", array ($params - ) ); + $result = $client->__soapCall("UserList", array( + $params + )); - $rows = array (); + $rows = []; $i = 0; - if (isset( $result->users )) { + if (isset($result->users)) { //Processing when it is an array - if (is_array( $result->users )) { + if (is_array($result->users)) { foreach ($result->users as $key => $obj) { - $rows[$i] = array ("guid" => $obj->guid,"name" => $obj->name + $rows[$i] = array( + "guid" => $obj->guid, "name" => $obj->name ); $i = $i + 1; } } else { //Processing when it is an object //1 row - if (is_object( $result->users )) { - $rows[$i] = array ("guid" => $result->users->guid,"name" => $result->users->name + if (is_object($result->users)) { + $rows[$i] = array( + "guid" => $result->users->guid, "name" => $result->users->name ); $i = $i + 1; } @@ -778,32 +792,36 @@ function WSUserList () * @return array | $rows | List | List of active groups in the workspace * */ -function WSGroupList () +function WSGroupList() { $client = WSOpen(); $sessionId = $_SESSION["WS_SESSION_ID"]; - $params = array ("sessionId" => $sessionId + $params = array( + "sessionId" => $sessionId ); - $result = $client->__soapCall( "GroupList", array ($params - ) ); + $result = $client->__soapCall("GroupList", array( + $params + )); - $rows = array (); + $rows = []; $i = 0; - if (isset( $result->groups )) { + if (isset($result->groups)) { //Processing when it is an array - if (is_array( $result->groups )) { + if (is_array($result->groups)) { foreach ($result->groups as $key => $obj) { - $rows[$i] = array ("guid" => $obj->guid,"name" => $obj->name + $rows[$i] = array( + "guid" => $obj->guid, "name" => $obj->name ); $i = $i + 1; } } else { //Processing when it is an object //1 row - if (is_object( $result->groups )) { - $rows[$i] = array ("guid" => $result->groups->guid,"name" => $result->groups->name + if (is_object($result->groups)) { + $rows[$i] = array( + "guid" => $result->groups->guid, "name" => $result->groups->name ); $i = $i + 1; } @@ -826,32 +844,36 @@ function WSGroupList () * @return array | $rows | List | List of roles in the workspace * */ -function WSRoleList () +function WSRoleList() { $client = WSOpen(); $sessionId = $_SESSION["WS_SESSION_ID"]; - $params = array ("sessionId" => $sessionId + $params = array( + "sessionId" => $sessionId ); - $result = $client->__soapCall( "RoleList", array ($params - ) ); + $result = $client->__soapCall("RoleList", array( + $params + )); - $rows = array (); + $rows = []; $i = 0; - if (isset( $result->roles )) { + if (isset($result->roles)) { //Processing when it is an array - if (is_array( $result->roles )) { + if (is_array($result->roles)) { foreach ($result->roles as $key => $obj) { - $rows[$i] = array ("guid" => $obj->guid,"name" => $obj->name + $rows[$i] = array( + "guid" => $obj->guid, "name" => $obj->name ); $i = $i + 1; } } else { //Processing when it is an object //1 row - if (is_object( $result->roles )) { - $rows[$i] = array ("guid" => $result->roles->guid,"name" => $result->roles->name + if (is_object($result->roles)) { + $rows[$i] = array( + "guid" => $result->roles->guid, "name" => $result->roles->name ); $i = $i + 1; } @@ -875,32 +897,36 @@ function WSRoleList () * @return array | $rows | List of the cases |It returns a list of cases * */ -function WSCaseList () +function WSCaseList() { $client = WSOpen(); $sessionId = $_SESSION["WS_SESSION_ID"]; - $params = array ("sessionId" => $sessionId + $params = array( + "sessionId" => $sessionId ); - $result = $client->__soapCall( "CaseList", array ($params - ) ); + $result = $client->__soapCall("CaseList", array( + $params + )); - $rows = array (); + $rows = []; $i = 0; - if (isset( $result->cases )) { + if (isset($result->cases)) { //Processing when it is an array - if (is_array( $result->cases )) { + if (is_array($result->cases)) { foreach ($result->cases as $key => $obj) { - $rows[$i] = array ("guid" => $obj->guid,"name" => $obj->name + $rows[$i] = array( + "guid" => $obj->guid, "name" => $obj->name ); $i = $i + 1; } } else { //Processing when it is an object //1 row - if (is_object( $result->cases )) { - $rows[$i] = array ("guid" => $result->cases->guid,"name" => $result->cases->name + if (is_object($result->cases)) { + $rows[$i] = array( + "guid" => $result->cases->guid, "name" => $result->cases->name ); $i = $i + 1; } @@ -923,32 +949,36 @@ function WSCaseList () * @return array | $rows | List of processes | A list of processes * */ -function WSProcessList () +function WSProcessList() { $client = WSOpen(); $sessionId = $_SESSION["WS_SESSION_ID"]; - $params = array ("sessionId" => $sessionId + $params = array( + "sessionId" => $sessionId ); - $result = $client->__soapCall( "ProcessList", array ($params - ) ); + $result = $client->__soapCall("ProcessList", array( + $params + )); - $rows = array (); + $rows = []; $i = 0; - if (isset( $result->processes )) { + if (isset($result->processes)) { //Processing when it is an array - if (is_array( $result->processes )) { + if (is_array($result->processes)) { foreach ($result->processes as $key => $obj) { - $rows[$i] = array ("guid" => $obj->guid,"name" => $obj->name + $rows[$i] = array( + "guid" => $obj->guid, "name" => $obj->name ); $i = $i + 1; } } else { //Processing when it is an object //1 row - if (is_object( $result->processes )) { - $rows[$i] = array ("guid" => $result->processes->guid,"name" => $result->processes->name + if (is_object($result->processes)) { + $rows[$i] = array( + "guid" => $result->processes->guid, "name" => $result->processes->name ); $i = $i + 1; } @@ -971,7 +1001,7 @@ function WSProcessList () * */ //private function to get current email configuration -function getEmailConfiguration () +function getEmailConfiguration() { return System::getEmailConfiguration(); } @@ -1079,7 +1109,7 @@ function PMFSendMessage( * @return array | $fields | WS Response Associative Array: | The function returns a WS Response associative array. * */ -function WSSendVariables ($caseId, $name1, $value1, $name2, $value2) +function WSSendVariables($caseId, $name1, $value1, $name2, $value2) { $client = WSOpen(); @@ -1093,14 +1123,17 @@ function WSSendVariables ($caseId, $name1, $value1, $name2, $value2) $v2->name = $name2; $v2->value = $value2; - $variables = array ($v1,$v2 + $variables = array( + $v1, $v2 ); - $params = array ("sessionId" => $sessionId,"caseId" => $caseId,"variables" => $variables + $params = array( + "sessionId" => $sessionId, "caseId" => $caseId, "variables" => $variables ); - $result = $client->__soapCall( "SendVariables", array ($params - ) ); + $result = $client->__soapCall("SendVariables", array( + $params + )); $fields["status_code"] = $result->status_code; $fields["message"] = $result->message; @@ -1125,17 +1158,19 @@ function WSSendVariables ($caseId, $name1, $value1, $name2, $value2) * @return array | $fields | WS Response Associative Array | A WS Response associative array. * */ -function WSDerivateCase ($caseId, $delIndex) +function WSDerivateCase($caseId, $delIndex) { $client = WSOpen(); $sessionId = $_SESSION["WS_SESSION_ID"]; - $params = array ("sessionId" => $sessionId,"caseId" => $caseId,"delIndex" => $delIndex + $params = array( + "sessionId" => $sessionId, "caseId" => $caseId, "delIndex" => $delIndex ); - $result = $client->__soapCall( "DerivateCase", array ($params - ) ); + $result = $client->__soapCall("DerivateCase", array( + $params + )); $fields["status_code"] = $result->status_code; $fields["message"] = $result->message; @@ -1164,7 +1199,7 @@ function WSDerivateCase ($caseId, $delIndex) * @return array | $fields | WS Response Associative Array | A WS Response associative array. * */ -function WSNewCaseImpersonate ($processId, $userId, $name1, $value1, $name2, $value2, $taskId = '') +function WSNewCaseImpersonate($processId, $userId, $name1, $value1, $name2, $value2, $taskId = '') { $client = WSOpen(); @@ -1178,7 +1213,7 @@ function WSNewCaseImpersonate ($processId, $userId, $name1, $value1, $name2, $va $v2->name = $name2; $v2->value = $value2; - $variables = [$v1,$v2]; + $variables = [$v1, $v2]; $params = [ "sessionId" => $sessionId, @@ -1219,7 +1254,7 @@ function WSNewCaseImpersonate ($processId, $userId, $name1, $value1, $name2, $va * @return array | $fields | WS array | A WS Response associative array. * */ -function WSNewCase ($processId, $taskId, $name1, $value1, $name2, $value2) +function WSNewCase($processId, $taskId, $name1, $value1, $name2, $value2) { $client = WSOpen(); $sessionId = $_SESSION["WS_SESSION_ID"]; @@ -1232,14 +1267,17 @@ function WSNewCase ($processId, $taskId, $name1, $value1, $name2, $value2) $v2->name = $name2; $v2->value = $value2; - $variables = array ($v1,$v2 + $variables = array( + $v1, $v2 ); - $params = array ("sessionId" => $sessionId,"processId" => $processId,"taskId" => $taskId,"variables" => $variables + $params = array( + "sessionId" => $sessionId, "processId" => $processId, "taskId" => $taskId, "variables" => $variables ); - $result = $client->__soapCall( "NewCase", array ($params - ) ); + $result = $client->__soapCall("NewCase", array( + $params + )); $fields["status_code"] = $result->status_code; $fields["message"] = $result->message; @@ -1266,17 +1304,19 @@ function WSNewCase ($processId, $taskId, $name1, $value1, $name2, $value2) * @return array | $fields | WS array |A WS Response associative array. * */ -function WSAssignUserToGroup ($userId, $groupId) +function WSAssignUserToGroup($userId, $groupId) { $client = WSOpen(); $sessionId = $_SESSION["WS_SESSION_ID"]; - $params = array ("sessionId" => $sessionId,"userId" => $userId,"groupId" => $groupId + $params = array( + "sessionId" => $sessionId, "userId" => $userId, "groupId" => $groupId ); - $result = $client->__soapCall( "AssignUserToGroup", array ($params - ) ); + $result = $client->__soapCall("AssignUserToGroup", array( + $params + )); $fields["status_code"] = $result->status_code; $fields["message"] = $result->message; @@ -1306,18 +1346,19 @@ function WSAssignUserToGroup ($userId, $groupId) * @return array | $fields | WS array | A WS Response associative array. * */ -function WSCreateUser ($userId, $password, $firstname, $lastname, $email, $role, $dueDate = null, $status = null) +function WSCreateUser($userId, $password, $firstname, $lastname, $email, $role, $dueDate = null, $status = null) { $client = WSOpen(); $sessionId = $_SESSION["WS_SESSION_ID"]; - $params = array ("sessionId" => $sessionId,"userId" => $userId,"firstname" => $firstname,"lastname" => $lastname,"email" => $email,"role" => $role,"password" => $password,"dueDate" => $dueDate,"status" => $status + $params = array( + "sessionId" => $sessionId, "userId" => $userId, "firstname" => $firstname, "lastname" => $lastname, "email" => $email, "role" => $role, "password" => $password, "dueDate" => $dueDate, "status" => $status ); try { - $result = $client->__soapCall( "CreateUser", array ($params) ); - } catch(Exception $oError) { + $result = $client->__soapCall("CreateUser", array($params)); + } catch (Exception $oError) { return $oError->getMessage(); } @@ -1350,17 +1391,19 @@ function WSCreateUser ($userId, $password, $firstname, $lastname, $email, $role, * @return array | $fields | WS array | A WS Response associative array. * */ -function WSUpdateUser ($userUid, $userName, $firstName = null, $lastName = null, $email = null, $dueDate = null, $status = null, $role = null, $password = null) +function WSUpdateUser($userUid, $userName, $firstName = null, $lastName = null, $email = null, $dueDate = null, $status = null, $role = null, $password = null) { $client = WSOpen(); $sessionId = $_SESSION["WS_SESSION_ID"]; - $params = array ("sessionId" => $sessionId,"userUid" => $userUid,"userName" => $userName,"firstName" => $firstName,"lastName" => $lastName,"email" => $email,"dueDate" => $dueDate,"status" => $status,"role" => $role,"password" => $password + $params = array( + "sessionId" => $sessionId, "userUid" => $userUid, "userName" => $userName, "firstName" => $firstName, "lastName" => $lastName, "email" => $email, "dueDate" => $dueDate, "status" => $status, "role" => $role, "password" => $password ); - $result = $client->__soapCall( "updateUser", array ($params - ) ); + $result = $client->__soapCall("updateUser", array( + $params + )); $fields["status_code"] = $result->status_code; $fields["message"] = $result->message; @@ -1396,11 +1439,11 @@ function WSInformationUser($userUid) $result = $client->__soapCall("informationUser", array($params)); - $response = array(); + $response = []; $response["status_code"] = $result->status_code; $response["message"] = $result->message; $response["time_stamp"] = $result->timestamp; - $response["info"] = (isset($result->info))? $result->info : null; + $response["info"] = (isset($result->info)) ? $result->info : null; return $response; } @@ -1418,12 +1461,12 @@ function WSInformationUser($userUid) * @return string | $userId | Sesion ID | The unique ID for the current active session. * */ -function WSGetSession () +function WSGetSession() { - if (isset( $_SESSION["WS_SESSION_ID"] )) { + if (isset($_SESSION["WS_SESSION_ID"])) { return $_SESSION["WS_SESSION_ID"]; } else { - throw new Exception( "SW session is not open!" ); + throw new Exception("SW session is not open!"); } } @@ -1441,19 +1484,21 @@ function WSGetSession () * @return array | $response | WS array | A WS Response associative array. * */ -function WSDeleteCase ($caseUid) +function WSDeleteCase($caseUid) { $client = WSOpen(); $sessionId = $_SESSION["WS_SESSION_ID"]; - $params = array ("sessionId" => $sessionId,"caseUid" => $caseUid + $params = array( + "sessionId" => $sessionId, "caseUid" => $caseUid ); - $result = $client->__soapCall( "deleteCase", array ($params - ) ); + $result = $client->__soapCall("deleteCase", array( + $params + )); - $response = array (); + $response = []; $response["status_code"] = $result->status_code; $response["message"] = $result->message; $response["time_stamp"] = $result->timestamp; @@ -1477,19 +1522,21 @@ function WSDeleteCase ($caseUid) * @return array | $response | WS array | A WS Response associative array. * */ -function WSCancelCase ($caseUid, $delIndex, $userUid) +function WSCancelCase($caseUid, $delIndex, $userUid) { $client = WSOpen(); $sessionId = $_SESSION["WS_SESSION_ID"]; - $params = array ("sessionId" => $sessionId,"caseUid" => $caseUid,"delIndex" => $delIndex,"userUid" => $userUid + $params = array( + "sessionId" => $sessionId, "caseUid" => $caseUid, "delIndex" => $delIndex, "userUid" => $userUid ); - $result = $client->__soapCall( "cancelCase", array ($params - ) ); + $result = $client->__soapCall("cancelCase", array( + $params + )); - $response = array (); + $response = []; $response["status_code"] = $result->status_code; $response["message"] = $result->message; $response["time_stamp"] = $result->timestamp; @@ -1514,19 +1561,21 @@ function WSCancelCase ($caseUid, $delIndex, $userUid) * @return array | $response | WS array | A WS Response associative array. * */ -function WSPauseCase ($caseUid, $delIndex, $userUid, $unpauseDate = null) +function WSPauseCase($caseUid, $delIndex, $userUid, $unpauseDate = null) { $client = WSOpen(); $sessionId = $_SESSION["WS_SESSION_ID"]; - $params = array ("sessionId" => $sessionId,"caseUid" => $caseUid,"delIndex" => $delIndex,"userUid" => $userUid,"unpauseDate" => $unpauseDate + $params = array( + "sessionId" => $sessionId, "caseUid" => $caseUid, "delIndex" => $delIndex, "userUid" => $userUid, "unpauseDate" => $unpauseDate ); - $result = $client->__soapCall( "pauseCase", array ($params - ) ); + $result = $client->__soapCall("pauseCase", array( + $params + )); - $response = array (); + $response = []; $response["status_code"] = $result->status_code; $response["message"] = $result->message; $response["time_stamp"] = $result->timestamp; @@ -1550,19 +1599,21 @@ function WSPauseCase ($caseUid, $delIndex, $userUid, $unpauseDate = null) * @return array | $response | WS array | A WS Response associative array. * */ -function WSUnpauseCase ($caseUid, $delIndex, $userUid) +function WSUnpauseCase($caseUid, $delIndex, $userUid) { $client = WSOpen(); $sessionId = $_SESSION["WS_SESSION_ID"]; - $params = array ("sessionId" => $sessionId,"caseUid" => $caseUid,"delIndex" => $delIndex,"userUid" => $userUid + $params = array( + "sessionId" => $sessionId, "caseUid" => $caseUid, "delIndex" => $delIndex, "userUid" => $userUid ); - $result = $client->__soapCall( "unpauseCase", array ($params - ) ); + $result = $client->__soapCall("unpauseCase", array( + $params + )); - $response = array (); + $response = []; $response["status_code"] = $result->status_code; $response["message"] = $result->message; $response["time_stamp"] = $result->timestamp; @@ -1607,7 +1658,7 @@ function WSAddCaseNote($caseUid, $processUid, $taskUid, $userUid, $note, $sendMa $result = $client->__soapCall("addCaseNote", array($params)); - $response = array(); + $response = []; $response["status_code"] = $result->status_code; $response["message"] = $result->message; $response["time_stamp"] = $result->timestamp; @@ -1636,15 +1687,15 @@ function WSAddCaseNote($caseUid, $processUid, $taskUid, $userUid, $note, $sendMa * @return array | $rows | List of tasks | A list of tasks * */ -function PMFTaskCase ($caseId) //its test was successfull +function PMFTaskCase($caseId) //its test was successfull { $ws = new WsBase(); - $result = $ws->taskCase( $caseId ); - $rows = Array (); + $result = $ws->taskCase($caseId); + $rows = []; $i = 1; - if (isset( $result )) { + if (isset($result)) { foreach ($result as $item) { - $rows[$i ++] = $item; + $rows[$i++] = $item; } } return $rows; @@ -1664,15 +1715,15 @@ function PMFTaskCase ($caseId) //its test was successfull * @return array | $rows | List of tasks | An array of tasks * */ -function PMFTaskList ($userId) //its test was successfull +function PMFTaskList($userId) //its test was successfull { $ws = new WsBase(); - $result = $ws->taskList( $userId ); - $rows = Array (); + $result = $ws->taskList($userId); + $rows = []; $i = 1; - if (isset( $result )) { + if (isset($result)) { foreach ($result as $item) { - $rows[$i ++] = $item; + $rows[$i++] = $item; } } return $rows; @@ -1691,15 +1742,15 @@ function PMFTaskList ($userId) //its test was successfull * @return array | $rows | List of users | An array of users * */ -function PMFUserList () //its test was successfull +function PMFUserList() //its test was successfull { $ws = new WsBase(); $result = $ws->userList(); - $rows = Array (); + $rows = []; $i = 1; - if (isset( $result )) { + if (isset($result)) { foreach ($result as $item) { - $rows[$i ++] = $item; + $rows[$i++] = $item; } } return $rows; @@ -1791,7 +1842,7 @@ function PMFAddInputDocument( * @return none | $none | None | None * */ -function PMFGenerateOutputDocument ($outputID, $sApplication = null, $index = null, $sUserLogged = null) +function PMFGenerateOutputDocument($outputID, $sApplication = null, $index = null, $sUserLogged = null) { $g = new G(); @@ -1816,16 +1867,16 @@ function PMFGenerateOutputDocument ($outputID, $sApplication = null, $index = nu } $oCase = new Cases(); - $oCase->thisIsTheCurrentUser( $sApplication, $index, $sUserLogged, '', 'casesListExtJs' ); + $oCase->thisIsTheCurrentUser($sApplication, $index, $sUserLogged, '', 'casesListExtJs'); //require_once 'classes/model/OutputDocument.php'; $oOutputDocument = new OutputDocument(); - $aOD = $oOutputDocument->load( $outputID ); - $Fields = $oCase->loadCase( $sApplication ); + $aOD = $oOutputDocument->load($outputID); + $Fields = $oCase->loadCase($sApplication); //The $_GET['UID'] variable is used when a process executes. //$_GET['UID']=($aOD['OUT_DOC_VERSIONING'])?$_GET['UID']:$aOD['OUT_DOC_UID']; //$sUID = ($aOD['OUT_DOC_VERSIONING'])?$_GET['UID']:$aOD['OUT_DOC_UID']; - $sFilename = preg_replace( '[^A-Za-z0-9_]', '_', G::replaceDataField( $aOD['OUT_DOC_FILENAME'], $Fields['APP_DATA'], 'mysql', false ) ); + $sFilename = preg_replace('[^A-Za-z0-9_]', '_', G::replaceDataField($aOD['OUT_DOC_FILENAME'], $Fields['APP_DATA'], 'mysql', false)); require_once 'classes/model/AppFolder.php'; require_once 'classes/model/AppDocument.php'; @@ -1833,80 +1884,84 @@ function PMFGenerateOutputDocument ($outputID, $sApplication = null, $index = nu $oFolder = new AppFolder(); //$aOD['OUT_DOC_DESTINATION_PATH'] = ($aOD['OUT_DOC_DESTINATION_PATH']=='')?PATH_DOCUMENT // . $_SESSION['APPLICATION'] . PATH_SEP . 'outdocs'. PATH_SEP:$aOD['OUT_DOC_DESTINATION_PATH']; - $folderId = $oFolder->createFromPath( $aOD['OUT_DOC_DESTINATION_PATH'], $sApplication ); + $folderId = $oFolder->createFromPath($aOD['OUT_DOC_DESTINATION_PATH'], $sApplication); //Tags - $fileTags = $oFolder->parseTags( $aOD['OUT_DOC_TAGS'], $sApplication ); + $fileTags = $oFolder->parseTags($aOD['OUT_DOC_TAGS'], $sApplication); //Get last Document Version and apply versioning if is enabled $oAppDocument = new AppDocument(); - $lastDocVersion = $oAppDocument->getLastDocVersion( $outputID, $sApplication ); + $lastDocVersion = $oAppDocument->getLastDocVersion($outputID, $sApplication); - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( AppDocumentPeer::APP_UID, $sApplication ); + $oCriteria = new Criteria('workflow'); + $oCriteria->add(AppDocumentPeer::APP_UID, $sApplication); //$oCriteria->add(AppDocumentPeer::DEL_INDEX, $index); - $oCriteria->add( AppDocumentPeer::DOC_UID, $outputID ); - $oCriteria->add( AppDocumentPeer::DOC_VERSION, $lastDocVersion ); - $oCriteria->add( AppDocumentPeer::APP_DOC_TYPE, 'OUTPUT' ); - $oDataset = AppDocumentPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oCriteria->add(AppDocumentPeer::DOC_UID, $outputID); + $oCriteria->add(AppDocumentPeer::DOC_VERSION, $lastDocVersion); + $oCriteria->add(AppDocumentPeer::APP_DOC_TYPE, 'OUTPUT'); + $oDataset = AppDocumentPeer::doSelectRS($oCriteria); + $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); if (($aOD['OUT_DOC_VERSIONING']) && ($lastDocVersion != 0)) { //Create new Version of current output - $lastDocVersion ++; + $lastDocVersion++; if ($aRow = $oDataset->getRow()) { - $aFields = array ('APP_DOC_UID' => $aRow['APP_DOC_UID'],'APP_UID' => $sApplication,'DEL_INDEX' => $index,'DOC_UID' => $outputID,'DOC_VERSION' => $lastDocVersion + 1,'USR_UID' => $sUserLogged,'APP_DOC_TYPE' => 'OUTPUT','APP_DOC_CREATE_DATE' => date( 'Y-m-d H:i:s' ),'APP_DOC_FILENAME' => $sFilename,'FOLDER_UID' => $folderId,'APP_DOC_TAGS' => $fileTags + $aFields = array( + 'APP_DOC_UID' => $aRow['APP_DOC_UID'], 'APP_UID' => $sApplication, 'DEL_INDEX' => $index, 'DOC_UID' => $outputID, 'DOC_VERSION' => $lastDocVersion + 1, 'USR_UID' => $sUserLogged, 'APP_DOC_TYPE' => 'OUTPUT', 'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'), 'APP_DOC_FILENAME' => $sFilename, 'FOLDER_UID' => $folderId, 'APP_DOC_TAGS' => $fileTags ); $oAppDocument = new AppDocument(); - $oAppDocument->create( $aFields ); + $oAppDocument->create($aFields); $sDocUID = $aRow['APP_DOC_UID']; } } else { ////No versioning so Update a current Output or Create new if no exist if ($aRow = $oDataset->getRow()) { //Update - $aFields = array ('APP_DOC_UID' => $aRow['APP_DOC_UID'],'APP_UID' => $sApplication,'DEL_INDEX' => $index,'DOC_UID' => $outputID,'DOC_VERSION' => $lastDocVersion,'USR_UID' => $sUserLogged,'APP_DOC_TYPE' => 'OUTPUT','APP_DOC_CREATE_DATE' => date( 'Y-m-d H:i:s' ),'APP_DOC_FILENAME' => $sFilename,'FOLDER_UID' => $folderId,'APP_DOC_TAGS' => $fileTags + $aFields = array( + 'APP_DOC_UID' => $aRow['APP_DOC_UID'], 'APP_UID' => $sApplication, 'DEL_INDEX' => $index, 'DOC_UID' => $outputID, 'DOC_VERSION' => $lastDocVersion, 'USR_UID' => $sUserLogged, 'APP_DOC_TYPE' => 'OUTPUT', 'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'), 'APP_DOC_FILENAME' => $sFilename, 'FOLDER_UID' => $folderId, 'APP_DOC_TAGS' => $fileTags ); $oAppDocument = new AppDocument(); - $oAppDocument->update( $aFields ); + $oAppDocument->update($aFields); $sDocUID = $aRow['APP_DOC_UID']; } else { //we are creating the appdocument row //create if ($lastDocVersion == 0) { - $lastDocVersion ++; + $lastDocVersion++; } - $aFields = array ('APP_UID' => $sApplication,'DEL_INDEX' => $index,'DOC_UID' => $outputID,'DOC_VERSION' => $lastDocVersion,'USR_UID' => $sUserLogged,'APP_DOC_TYPE' => 'OUTPUT','APP_DOC_CREATE_DATE' => date( 'Y-m-d H:i:s' ),'APP_DOC_FILENAME' => $sFilename,'FOLDER_UID' => $folderId,'APP_DOC_TAGS' => $fileTags + $aFields = array( + 'APP_UID' => $sApplication, 'DEL_INDEX' => $index, 'DOC_UID' => $outputID, 'DOC_VERSION' => $lastDocVersion, 'USR_UID' => $sUserLogged, 'APP_DOC_TYPE' => 'OUTPUT', 'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'), 'APP_DOC_FILENAME' => $sFilename, 'FOLDER_UID' => $folderId, 'APP_DOC_TAGS' => $fileTags ); $oAppDocument = new AppDocument(); - $aFields['APP_DOC_UID'] = $sDocUID = $oAppDocument->create( $aFields ); + $aFields['APP_DOC_UID'] = $sDocUID = $oAppDocument->create($aFields); } } $sFilename = $aFields['APP_DOC_UID'] . "_" . $lastDocVersion; $pathOutput = PATH_DOCUMENT . G::getPathFromUID($sApplication) . PATH_SEP . 'outdocs' . PATH_SEP; //G::pr($sFilename);die; - G::mk_dir( $pathOutput ); + G::mk_dir($pathOutput); - $aProperties = array (); + $aProperties = []; - if (! isset( $aOD['OUT_DOC_MEDIA'] )) { + if (!isset($aOD['OUT_DOC_MEDIA'])) { $aOD['OUT_DOC_MEDIA'] = 'Letter'; } - if (! isset( $aOD['OUT_DOC_LEFT_MARGIN'] )) { + if (!isset($aOD['OUT_DOC_LEFT_MARGIN'])) { $aOD['OUT_DOC_LEFT_MARGIN'] = '15'; } - if (! isset( $aOD['OUT_DOC_RIGHT_MARGIN'] )) { + if (!isset($aOD['OUT_DOC_RIGHT_MARGIN'])) { $aOD['OUT_DOC_RIGHT_MARGIN'] = '15'; } - if (! isset( $aOD['OUT_DOC_TOP_MARGIN'] )) { + if (!isset($aOD['OUT_DOC_TOP_MARGIN'])) { $aOD['OUT_DOC_TOP_MARGIN'] = '15'; } - if (! isset( $aOD['OUT_DOC_BOTTOM_MARGIN'] )) { + if (!isset($aOD['OUT_DOC_BOTTOM_MARGIN'])) { $aOD['OUT_DOC_BOTTOM_MARGIN'] = '15'; } $aProperties['media'] = $aOD['OUT_DOC_MEDIA']; - $aProperties['margins'] = array ('left' => $aOD['OUT_DOC_LEFT_MARGIN'],'right' => $aOD['OUT_DOC_RIGHT_MARGIN'],'top' => $aOD['OUT_DOC_TOP_MARGIN'],'bottom' => $aOD['OUT_DOC_BOTTOM_MARGIN'] + $aProperties['margins'] = array( + 'left' => $aOD['OUT_DOC_LEFT_MARGIN'], 'right' => $aOD['OUT_DOC_RIGHT_MARGIN'], 'top' => $aOD['OUT_DOC_TOP_MARGIN'], 'bottom' => $aOD['OUT_DOC_BOTTOM_MARGIN'] ); if ($aOD['OUT_DOC_PDF_SECURITY_ENABLED'] == '1') { $aProperties['pdfSecurity'] = array('openPassword' => $aOD['OUT_DOC_PDF_SECURITY_OPEN_PASSWORD'], 'ownerPassword' => $aOD['OUT_DOC_PDF_SECURITY_OWNER_PASSWORD'], 'permissions' => $aOD['OUT_DOC_PDF_SECURITY_PERMISSIONS']); @@ -1914,18 +1969,18 @@ function PMFGenerateOutputDocument ($outputID, $sApplication = null, $index = nu if (isset($aOD['OUT_DOC_REPORT_GENERATOR'])) { $aProperties['report_generator'] = $aOD['OUT_DOC_REPORT_GENERATOR']; } - $oOutputDocument->generate( $outputID, $Fields['APP_DATA'], $pathOutput, $sFilename, $aOD['OUT_DOC_TEMPLATE'], (boolean) $aOD['OUT_DOC_LANDSCAPE'], $aOD['OUT_DOC_GENERATE'], $aProperties ); + $oOutputDocument->generate($outputID, $Fields['APP_DATA'], $pathOutput, $sFilename, $aOD['OUT_DOC_TEMPLATE'], (bool) $aOD['OUT_DOC_LANDSCAPE'], $aOD['OUT_DOC_GENERATE'], $aProperties); //Plugin Hook PM_UPLOAD_DOCUMENT for upload document $oPluginRegistry = PluginRegistry::loadSingleton(); - if ($oPluginRegistry->existsTrigger( PM_UPLOAD_DOCUMENT ) && class_exists( 'uploadDocumentData' )) { + if ($oPluginRegistry->existsTrigger(PM_UPLOAD_DOCUMENT) && class_exists('uploadDocumentData')) { /** @var \ProcessMaker\Plugins\Interfaces\TriggerDetail $triggerDetail */ - $triggerDetail = $oPluginRegistry->getTriggerInfo( PM_UPLOAD_DOCUMENT ); + $triggerDetail = $oPluginRegistry->getTriggerInfo(PM_UPLOAD_DOCUMENT); $aFields['APP_DOC_PLUGIN'] = $triggerDetail->getNamespace(); $oAppDocument1 = new AppDocument(); - $oAppDocument1->update( $aFields ); + $oAppDocument1->update($aFields); $sPathName = PATH_DOCUMENT . G::getPathFromUID($sApplication) . PATH_SEP; @@ -1933,47 +1988,47 @@ function PMFGenerateOutputDocument ($outputID, $sApplication = null, $index = nu $oData['ATTACHMENT_FOLDER'] = true; switch ($aOD['OUT_DOC_GENERATE']) { case "BOTH": - $documentData = new uploadDocumentData( $sApplication, $sUserLogged, $pathOutput . $sFilename . '.pdf', $sFilename . '.pdf', $sDocUID, $oAppDocument->getDocVersion() ); + $documentData = new uploadDocumentData($sApplication, $sUserLogged, $pathOutput . $sFilename . '.pdf', $sFilename . '.pdf', $sDocUID, $oAppDocument->getDocVersion()); $documentData->sFileType = "PDF"; $documentData->bUseOutputFolder = true; - $uploadReturn = $oPluginRegistry->executeTriggers( PM_UPLOAD_DOCUMENT, $documentData ); + $uploadReturn = $oPluginRegistry->executeTriggers(PM_UPLOAD_DOCUMENT, $documentData); if ($uploadReturn) { //Only delete if the file was saved correctly - unlink( $pathOutput . $sFilename . '.pdf' ); + unlink($pathOutput . $sFilename . '.pdf'); } - $documentData = new uploadDocumentData( $sApplication, $sUserLogged, $pathOutput . $sFilename . '.doc', $sFilename . '.doc', $sDocUID, $oAppDocument->getDocVersion() ); + $documentData = new uploadDocumentData($sApplication, $sUserLogged, $pathOutput . $sFilename . '.doc', $sFilename . '.doc', $sDocUID, $oAppDocument->getDocVersion()); $documentData->sFileType = "DOC"; $documentData->bUseOutputFolder = true; - $uploadReturn = $oPluginRegistry->executeTriggers( PM_UPLOAD_DOCUMENT, $documentData ); + $uploadReturn = $oPluginRegistry->executeTriggers(PM_UPLOAD_DOCUMENT, $documentData); if ($uploadReturn) { //Only delete if the file was saved correctly - unlink( $pathOutput . $sFilename . '.doc' ); + unlink($pathOutput . $sFilename . '.doc'); } break; case "PDF": - $documentData = new uploadDocumentData( $sApplication, $sUserLogged, $pathOutput . $sFilename . '.pdf', $sFilename . '.pdf', $sDocUID, $oAppDocument->getDocVersion() ); + $documentData = new uploadDocumentData($sApplication, $sUserLogged, $pathOutput . $sFilename . '.pdf', $sFilename . '.pdf', $sDocUID, $oAppDocument->getDocVersion()); $documentData->sFileType = "PDF"; $documentData->bUseOutputFolder = true; - $uploadReturn = $oPluginRegistry->executeTriggers( PM_UPLOAD_DOCUMENT, $documentData ); + $uploadReturn = $oPluginRegistry->executeTriggers(PM_UPLOAD_DOCUMENT, $documentData); if ($uploadReturn) { //Only delete if the file was saved correctly - unlink( $pathOutput . $sFilename . '.pdf' ); + unlink($pathOutput . $sFilename . '.pdf'); } break; case "DOC": - $documentData = new uploadDocumentData( $sApplication, $sUserLogged, $pathOutput . $sFilename . '.doc', $sFilename . '.doc', $sDocUID, $oAppDocument->getDocVersion() ); + $documentData = new uploadDocumentData($sApplication, $sUserLogged, $pathOutput . $sFilename . '.doc', $sFilename . '.doc', $sDocUID, $oAppDocument->getDocVersion()); $documentData->sFileType = "DOC"; $documentData->bUseOutputFolder = true; - $uploadReturn = $oPluginRegistry->executeTriggers( PM_UPLOAD_DOCUMENT, $documentData ); + $uploadReturn = $oPluginRegistry->executeTriggers(PM_UPLOAD_DOCUMENT, $documentData); if ($uploadReturn) { //Only delete if the file was saved correctly - unlink( $pathOutput . $sFilename . '.doc' ); + unlink($pathOutput . $sFilename . '.doc'); } break; } @@ -1998,11 +2053,11 @@ function PMFGenerateOutputDocument ($outputID, $sApplication = null, $index = nu * @return array | $rows | List of groups | An array of groups * */ -function PMFGroupList ($regex = null, $start = null, $limit = null) //its test was successfull +function PMFGroupList($regex = null, $start = null, $limit = null) //its test was successfull { $ws = new WsBase(); $result = $ws->groupList($regex, $start, $limit); - $rows = array(); + $rows = []; if ($result) { $rows = array_combine(range(1, count($result)), array_values($result)); } @@ -2022,15 +2077,15 @@ function PMFGroupList ($regex = null, $start = null, $limit = null) //its test w * @return array | $rows | List of roles | This function returns an array of roles * */ -function PMFRoleList () //its test was successfull +function PMFRoleList() //its test was successfull { $ws = new WsBase(); $result = $ws->roleList(); - $rows = Array (); + $rows = []; $i = 1; - if (isset( $result )) { + if (isset($result)) { foreach ($result as $item) { - $rows[$i ++] = $item; + $rows[$i++] = $item; } } return $rows; @@ -2050,15 +2105,15 @@ function PMFRoleList () //its test was successfull * @return array | $rows | List of cases | A list of cases * */ -function PMFCaseList ($userId) //its test was successfull +function PMFCaseList($userId) //its test was successfull { $ws = new WsBase(); - $result = $ws->caseList( $userId ); - $rows = Array (); + $result = $ws->caseList($userId); + $rows = []; $i = 1; - if (isset( $result )) { + if (isset($result)) { foreach ($result as $item) { - $rows[$i ++] = $item; + $rows[$i++] = $item; } } return $rows; @@ -2077,15 +2132,15 @@ function PMFCaseList ($userId) //its test was successfull * @return array | $rows | Lis ot Processes | An array of tasks in the indicated case which have open delegations * */ -function PMFProcessList () //its test was successfull +function PMFProcessList() //its test was successfull { $ws = new WsBase(); $result = $ws->processList(); - $rows = Array (); + $rows = []; $i = 1; - if (isset( $result )) { + if (isset($result)) { foreach ($result as $item) { - $rows[$i ++] = $item; + $rows[$i++] = $item; } } return $rows; @@ -2106,7 +2161,7 @@ function PMFProcessList () //its test was successfull * @return int | $result | Result of send variables | Returns 1 if the variables were sent successfully to the case; otherwise, returns 0 if an error occurred. * */ -function PMFSendVariables ($caseId, $variables) +function PMFSendVariables($caseId, $variables) { global $oPMScript; @@ -2115,8 +2170,11 @@ function PMFSendVariables ($caseId, $variables) } $ws = new WsBase(); - $result = $ws->sendVariables($caseId, $variables, - $oPMScript->executedOn() === PMScript::AFTER_ROUTING); + $result = $ws->sendVariables( + $caseId, + $variables, + $oPMScript->executedOn() === PMScript::AFTER_ROUTING + ); if ($result->status_code == 0) { if (isset($_SESSION['APPLICATION'])) { @@ -2151,14 +2209,14 @@ function PMFSendVariables ($caseId, $variables) * @return int | $result | Result of Derivate case | Returns 1 if new case was derivated (routed) successfully; otherwise, returns 0 if an error occurred. * */ -function PMFDerivateCase ($caseId, $delIndex, $bExecuteTriggersBeforeAssignment = false, $sUserLogged = null) +function PMFDerivateCase($caseId, $delIndex, $bExecuteTriggersBeforeAssignment = false, $sUserLogged = null) { - if (! $sUserLogged) { + if (!$sUserLogged) { $sUserLogged = $_SESSION['USER_LOGGED']; } $ws = new WsBase(); - $result = $ws->derivateCase( $sUserLogged, $caseId, $delIndex, $bExecuteTriggersBeforeAssignment ); + $result = $ws->derivateCase($sUserLogged, $caseId, $delIndex, $bExecuteTriggersBeforeAssignment); if (is_array($result)) { $result = (object)$result; } @@ -2187,10 +2245,10 @@ function PMFDerivateCase ($caseId, $delIndex, $bExecuteTriggersBeforeAssignment * @return int | $result | Result | Returns 1 if new case was created successfully; otherwise, returns 0 if an error occurred. * */ -function PMFNewCaseImpersonate ($processId, $userId, $variables, $taskId = '') +function PMFNewCaseImpersonate($processId, $userId, $variables, $taskId = '') { $ws = new WsBase(); - $result = $ws->newCaseImpersonate( $processId, $userId, $variables, $taskId); + $result = $ws->newCaseImpersonate($processId, $userId, $variables, $taskId); if ($result->status_code == 0) { return $result->caseId; @@ -2217,7 +2275,7 @@ function PMFNewCaseImpersonate ($processId, $userId, $variables, $taskId = '') * @return string | $idNewCase | Case ID | If an error occured, it returns the integer zero. Otherwise, it returns a string with the case UID of the new case. * */ -function PMFNewCase ($processId, $userId, $taskId, $variables, $status = null) +function PMFNewCase($processId, $userId, $taskId, $variables, $status = null) { $ws = new WsBase(); @@ -2247,10 +2305,10 @@ function PMFNewCase ($processId, $userId, $taskId, $variables, $status = null) * @return int | $result | Result of the assignment | Returns 1 if the user was successfully assigned to the group; otherwise, returns 0. * */ -function PMFAssignUserToGroup ($userId, $groupId) +function PMFAssignUserToGroup($userId, $groupId) { $ws = new WsBase(); - $result = $ws->assignUserToGroup( $userId, $groupId ); + $result = $ws->assignUserToGroup($userId, $groupId); if ($result->status_code == 0) { return 1; @@ -2280,10 +2338,10 @@ function PMFAssignUserToGroup ($userId, $groupId) * @return int | $result | Result of the creation | Returns 1 if the new user was created successfully; otherwise, returns 0 if an error occurred. * */ -function PMFCreateUser ($userId, $password, $firstname, $lastname, $email, $role, $dueDate = null, $status = null) +function PMFCreateUser($userId, $password, $firstname, $lastname, $email, $role, $dueDate = null, $status = null) { $ws = new WsBase(); - $result = $ws->createUser( $userId, $firstname, $lastname, $email, $role, $password, $dueDate, $status ); + $result = $ws->createUser($userId, $firstname, $lastname, $email, $role, $password, $dueDate, $status); //When the user is created the $result parameter is an array, in other case is a object exception if (!is_object($result)) { @@ -2319,10 +2377,10 @@ function PMFCreateUser ($userId, $password, $firstname, $lastname, $email, $role * @return int | $result | Result of the update | Returns 1 if the user is updated successfully; otherwise, returns 0 if an error occurred. * */ -function PMFUpdateUser ($userUid, $userName, $firstName = null, $lastName = null, $email = null, $dueDate = null, $status = null, $role = null, $password = null) +function PMFUpdateUser($userUid, $userName, $firstName = null, $lastName = null, $email = null, $dueDate = null, $status = null, $role = null, $password = null) { $ws = new WsBase(); - $result = $ws->updateUser( $userUid, $userName, $firstName, $lastName, $email, $dueDate, $status, $role, $password ); + $result = $ws->updateUser($userUid, $userName, $firstName, $lastName, $email, $dueDate, $status, $role, $password); //When the user is created the $result parameter is an array, in other case is a object exception if (!is_object($result)) { @@ -2354,7 +2412,7 @@ function PMFInformationUser($userUid) $ws = new WsBase(); $result = $ws->informationUser($userUid); - $info = array(); + $info = []; if ($result->status_code == 0 && isset($result->info)) { $info = $result->info; @@ -2379,9 +2437,9 @@ function PMFInformationUser($userUid) * @return string | $generateString | Generated string | The generated string of random characters. * */ -function generateCode ($iDigits = 4, $sType = 'NUMERIC') +function generateCode($iDigits = 4, $sType = 'NUMERIC') { - return G::generateCode( $iDigits, $sType ); + return G::generateCode($iDigits, $sType); } /** @@ -2400,17 +2458,17 @@ function generateCode ($iDigits = 4, $sType = 'NUMERIC') * @return int | $result | Result | If successful, returns one, otherwise zero or error number. * */ -function setCaseTrackerCode ($sApplicationUID, $sCode, $sPIN = '') +function setCaseTrackerCode($sApplicationUID, $sCode, $sPIN = '') { if ($sCode != '' || $sPIN != '') { $oCase = new Cases(); - $aFields = $oCase->loadCase( $sApplicationUID ); + $aFields = $oCase->loadCase($sApplicationUID); $aFields['APP_PROC_CODE'] = $sCode; if ($sPIN != '') { $aFields['APP_DATA']['PIN'] = $sPIN; - $aFields['APP_PIN'] = G::encryptOld( $sPIN ); + $aFields['APP_PIN'] = G::encryptOld($sPIN); } - $oCase->updateCase( $sApplicationUID, $aFields ); + $oCase->updateCase($sApplicationUID, $aFields); if (isset($_SESSION['APPLICATION'])) { if ($sApplicationUID == $_SESSION['APPLICATION']) { global $oPMScript; @@ -2440,18 +2498,18 @@ function setCaseTrackerCode ($sApplicationUID, $sCode, $sPIN = '') * @return none | $none | None | None * */ -function jumping ($caseId, $delIndex) +function jumping($caseId, $delIndex) { try { $response = PMFDerivateCase($caseId, $delIndex); if ($response) { - G::header( 'Location: casesListExtJsRedirector' ); + G::header('Location: casesListExtJsRedirector'); die(); // After routing and jumping the case, the thread execution will end } else { - G::SendTemporalMessage( 'ID_NOT_DERIVATED', 'error', 'labels' ); + G::SendTemporalMessage('ID_NOT_DERIVATED', 'error', 'labels'); } } catch (Exception $oException) { - G::SendTemporalMessage( 'ID_NOT_DERIVATED', 'error', 'labels' ); + G::SendTemporalMessage('ID_NOT_DERIVATED', 'error', 'labels'); } } @@ -2473,9 +2531,9 @@ function jumping ($caseId, $delIndex) * @return string | $label | Label of the specified option | A string holding the label of the specified option or NULL if the specified option does not exist. * */ -function PMFgetLabelOption ($PROCESS, $DYNAFORM_UID, $FIELD_NAME, $FIELD_SELECTED_ID) +function PMFgetLabelOption($PROCESS, $DYNAFORM_UID, $FIELD_NAME, $FIELD_SELECTED_ID) { - $data = array(); + $data = []; $data["CURRENT_DYNAFORM"] = $DYNAFORM_UID; $dynaform = new PmDynaform($data); if ($dynaform->isResponsive()) { @@ -2489,8 +2547,8 @@ function PMFgetLabelOption ($PROCESS, $DYNAFORM_UID, $FIELD_NAME, $FIELD_SELECTE return null; } - $G_FORM = new Form( "{$PROCESS}/{$DYNAFORM_UID}", PATH_DYNAFORM, SYS_LANG, false ); - if (isset( $G_FORM->fields[$FIELD_NAME]->option[$FIELD_SELECTED_ID] )) { + $G_FORM = new Form("{$PROCESS}/{$DYNAFORM_UID}", PATH_DYNAFORM, SYS_LANG, false); + if (isset($G_FORM->fields[$FIELD_NAME]->option[$FIELD_SELECTED_ID])) { return $G_FORM->fields[$FIELD_NAME]->option[$FIELD_SELECTED_ID]; } else { return null; @@ -2621,12 +2679,14 @@ function PMFGetNextAssignedUser($application, $task, $delIndex = null, $userUid if ($typeTask == 'BALANCED' && !is_null($_SESSION['INDEX']) && !is_null($_SESSION['USER_LOGGED'])) { $oDerivation = new Derivation(); - $aDeriv = $oDerivation->prepareInformation(array('USER_UID' => $_SESSION['USER_LOGGED'], 'APP_UID' => $application, 'DEL_INDEX' => $_SESSION['INDEX'] + $aDeriv = $oDerivation->prepareInformation(array( + 'USER_UID' => $_SESSION['USER_LOGGED'], 'APP_UID' => $application, 'DEL_INDEX' => $_SESSION['INDEX'] )); foreach ($aDeriv as $derivation) { - $aUser = array('USR_UID' => $derivation['NEXT_TASK']['USER_ASSIGNED']['USR_UID'], 'USR_USERNAME' => $derivation['NEXT_TASK']['USER_ASSIGNED']['USR_USERNAME'], 'USR_FIRSTNAME' => $derivation['NEXT_TASK']['USER_ASSIGNED']['USR_FIRSTNAME'], 'USR_LASTNAME' => $derivation['NEXT_TASK']['USER_ASSIGNED']['USR_LASTNAME'], 'USR_EMAIL' => $derivation['NEXT_TASK']['USER_ASSIGNED']['USR_EMAIL'] + $aUser = array( + 'USR_UID' => $derivation['NEXT_TASK']['USER_ASSIGNED']['USR_UID'], 'USR_USERNAME' => $derivation['NEXT_TASK']['USER_ASSIGNED']['USR_USERNAME'], 'USR_FIRSTNAME' => $derivation['NEXT_TASK']['USER_ASSIGNED']['USR_FIRSTNAME'], 'USR_LASTNAME' => $derivation['NEXT_TASK']['USER_ASSIGNED']['USR_LASTNAME'], 'USR_EMAIL' => $derivation['NEXT_TASK']['USER_ASSIGNED']['USR_EMAIL'] ); $aUsers[] = $aUser; } @@ -2638,7 +2698,6 @@ function PMFGetNextAssignedUser($application, $task, $delIndex = null, $userUid } else { return $aUsers; } - } else { $g->sessionVarRestore(); return false; @@ -2660,19 +2719,18 @@ function PMFGetNextAssignedUser($application, $task, $delIndex = null, $userUid * @return array | $aRecipient | Array of the Recipient | Return an Array of the Recipient. * */ -function PMFGetUserEmailAddress ($id, $APP_UID = null, $prefix = 'usr') +function PMFGetUserEmailAddress($id, $APP_UID = null, $prefix = 'usr') { - - if (is_string( $id ) && trim( $id ) == "") { + if (is_string($id) && trim($id) == "") { return false; } - if (is_array( $id ) && count( $id ) == 0) { + if (is_array($id) && count($id) == 0) { return false; } //recipient to store the email addresses - $aRecipient = Array (); - $aItems = Array (); + $aRecipient = []; + $aItems = []; /* * First at all the $id user input can be by example erik@colosa.com @@ -2683,27 +2741,27 @@ function PMFGetUserEmailAddress ($id, $APP_UID = null, $prefix = 'usr') /* * The second thing is that the return type will be configurated depend of the input type (using $retType) */ - if (is_array( $id )) { + if (is_array($id)) { $aItems = $id; $retType = 'array'; } else { $retType = 'string'; - if (strpos( $id, "," ) !== false) { - $aItems = explode( ',', $id ); + if (strpos($id, ",") !== false) { + $aItems = explode(',', $id); } else { - array_push( $aItems, $id ); + array_push($aItems, $id); } } foreach ($aItems as $sItem) { //cleaning for blank spaces into each array item - $sItem = trim( $sItem ); - if (strpos( $sItem, "|" ) !== false) { + $sItem = trim($sItem); + if (strpos($sItem, "|") !== false) { // explode the parameter because always will be compose with pipe separator to indicate // the type (user or group) and the target mai - list ($sType, $sID) = explode( '|', $sItem ); - $sType = trim( $sType ); - $sID = trim( $sID ); + list($sType, $sID) = explode('|', $sItem); + $sType = trim($sType); + $sID = trim($sID); } else { $sType = $prefix; $sID = $sItem; @@ -2711,34 +2769,34 @@ function PMFGetUserEmailAddress ($id, $APP_UID = null, $prefix = 'usr') switch ($sType) { case 'ext': - if (G::emailAddress( $sID )) { - array_push( $aRecipient, $sID ); + if (G::emailAddress($sID)) { + array_push($aRecipient, $sID); } break; case 'usr': if ($sID == '-1') { // -1: Curent user, load from user record - if (isset( $APP_UID )) { + if (isset($APP_UID)) { $oAppDelegation = new AppDelegation(); - $aAppDel = $oAppDelegation->getLastDeleration( $APP_UID ); - if (isset( $aAppDel )) { - $oUserRow = UsersPeer::retrieveByPK( $aAppDel['USR_UID'] ); - if (isset( $oUserRow )) { + $aAppDel = $oAppDelegation->getLastDeleration($APP_UID); + if (isset($aAppDel)) { + $oUserRow = UsersPeer::retrieveByPK($aAppDel['USR_UID']); + if (isset($oUserRow)) { $sID = $oUserRow->getUsrEmail(); } else { - throw new Exception( 'User with ID ' . $oAppDelegation->getUsrUid() . 'doesn\'t exist' ); + throw new Exception('User with ID ' . $oAppDelegation->getUsrUid() . 'doesn\'t exist'); } - if (G::emailAddress( $sID )) { - array_push( $aRecipient, $sID ); + if (G::emailAddress($sID)) { + array_push($aRecipient, $sID); } } } } else { - $oUserRow = UsersPeer::retrieveByPK( $sID ); + $oUserRow = UsersPeer::retrieveByPK($sID); if ($oUserRow != null) { $sID = $oUserRow->getUsrEmail(); - if (G::emailAddress( $sID )) { - array_push( $aRecipient, $sID ); + if (G::emailAddress($sID)) { + array_push($aRecipient, $sID); } } } @@ -2746,26 +2804,26 @@ function PMFGetUserEmailAddress ($id, $APP_UID = null, $prefix = 'usr') break; case 'grp': $oGroups = new Groups(); - $oCriteria = $oGroups->getUsersGroupCriteria( $sID ); - $oDataset = GroupwfPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oCriteria = $oGroups->getUsersGroupCriteria($sID); + $oDataset = GroupwfPeer::doSelectRS($oCriteria); + $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); while ($oDataset->next()) { $aGroup = $oDataset->getRow(); //to validate email address - if (G::emailAddress( $aGroup['USR_EMAIL'] )) { - array_push( $aRecipient, $aGroup['USR_EMAIL'] ); + if (G::emailAddress($aGroup['USR_EMAIL'])) { + array_push($aRecipient, $aGroup['USR_EMAIL']); } } break; case 'dyn': $oCase = new Cases(); - $aFields = $oCase->loadCase( $APP_UID ); - $aFields['APP_DATA'] = array_merge( $aFields['APP_DATA'], G::getSystemConstants() ); + $aFields = $oCase->loadCase($APP_UID); + $aFields['APP_DATA'] = array_merge($aFields['APP_DATA'], G::getSystemConstants()); //to validate email address - if (isset( $aFields['APP_DATA'][$sID] ) && G::emailAddress( $aFields['APP_DATA'][$sID] )) { - array_push( $aRecipient, $aFields['APP_DATA'][$sID] ); + if (isset($aFields['APP_DATA'][$sID]) && G::emailAddress($aFields['APP_DATA'][$sID])) { + array_push($aRecipient, $aFields['APP_DATA'][$sID]); } break; } @@ -2776,7 +2834,7 @@ function PMFGetUserEmailAddress ($id, $APP_UID = null, $prefix = 'usr') return $aRecipient; break; case 'string': - return implode( ',', $aRecipient ); + return implode(',', $aRecipient); break; default: return $aRecipient; @@ -2798,9 +2856,9 @@ function PMFGetUserEmailAddress ($id, $APP_UID = null, $prefix = 'usr') * @return array, object or string | $response | Array of the response | Return an Array or Object or String. * */ -function PMFGetCaseNotes ($applicationID, $type = 'array', $userUid = '') +function PMFGetCaseNotes($applicationID, $type = 'array', $userUid = '') { - $response = Cases::getCaseNotes( $applicationID, $type, $userUid ); + $response = Cases::getCaseNotes($applicationID, $type, $userUid); return $response; } @@ -2818,10 +2876,10 @@ function PMFGetCaseNotes ($applicationID, $type = 'array', $userUid = '') * @return int | $result | Result of the elimination | Returns 1 if the case is delete successfully; otherwise, returns 0 if an error occurred. * */ -function PMFDeleteCase ($caseUid) +function PMFDeleteCase($caseUid) { $ws = new WsBase(); - $result = $ws->deleteCase( $caseUid ); + $result = $ws->deleteCase($caseUid); if ($result->status_code == 0) { return 1; @@ -2859,13 +2917,11 @@ function PMFCancelCase($caseUid, $delIndex = null, $userUid = null) G::header('Location: ../cases/casesListExtJsRedirector'); die; } else { - die( - G::LoadTranslation( - 'ID_PM_FUNCTION_CHANGE_CASE', - SYS_LANG, - ['PMFCancelCase', G::LoadTranslation('ID_CANCELLED')] - ) - ); + die(G::LoadTranslation( + 'ID_PM_FUNCTION_CHANGE_CASE', + SYS_LANG, + ['PMFCancelCase', G::LoadTranslation('ID_CANCELLED')] + )); } } @@ -2892,7 +2948,7 @@ function PMFCancelCase($caseUid, $delIndex = null, $userUid = null) * @return int | $result | Result of the pause | Returns 1 if the case is paused successfully; otherwise, returns 0 if an error occurred. * */ -function PMFPauseCase ($caseUid, $delIndex, $userUid, $unpauseDate = null) +function PMFPauseCase($caseUid, $delIndex, $userUid, $unpauseDate = null) { $ws = new WsBase(); $result = $ws->pauseCase($caseUid, $delIndex, $userUid, $unpauseDate); @@ -2930,10 +2986,10 @@ function PMFPauseCase ($caseUid, $delIndex, $userUid, $unpauseDate = null) * @return int | $result | Result of the unpause | Returns 1 if the case is unpause successfully; otherwise, returns 0 if an error occurred. * */ -function PMFUnpauseCase ($caseUid, $delIndex, $userUid) +function PMFUnpauseCase($caseUid, $delIndex, $userUid) { $ws = new WsBase(); - $result = $ws->unpauseCase( $caseUid, $delIndex, $userUid ); + $result = $ws->unpauseCase($caseUid, $delIndex, $userUid); if ($result->status_code == 0) { return 1; @@ -3032,7 +3088,7 @@ function PMFAddAttachmentToArray($arrayData, $index, $value, $suffix = " Copy({i * */ -function PMFRemoveMask ($field, $separator = '.', $currency = '') +function PMFRemoveMask($field, $separator = '.', $currency = '') { $thousandSeparator = $separator; $decimalSeparator = ($thousandSeparator == ".") ? "," : "."; @@ -3040,7 +3096,7 @@ function PMFRemoveMask ($field, $separator = '.', $currency = '') $field = str_replace($thousandSeparator, "", $field); $field = str_replace($decimalSeparator, ".", $field); $field = str_replace($currency, "", $field); - if(strpos($decimalSeparator, $field) !== false){ + if (strpos($decimalSeparator, $field) !== false) { $field = (float)(trim($field)); } return $field; @@ -3058,7 +3114,7 @@ function PMFRemoveMask ($field, $separator = '.', $currency = '') * */ -function PMFSaveCurrentData () +function PMFSaveCurrentData() { global $oPMScript; @@ -3070,8 +3126,11 @@ function PMFSaveCurrentData () if (isset($_SESSION['APPLICATION']) && isset($oPMScript->aFields)) { $ws = new WsBase(); - $result = $ws->sendVariables($_SESSION['APPLICATION'], $oPMScript->aFields, - $oPMScript->executedOn() === PMScript::AFTER_ROUTING); + $result = $ws->sendVariables( + $_SESSION['APPLICATION'], + $oPMScript->aFields, + $oPMScript->executedOn() === PMScript::AFTER_ROUTING + ); $response = $result->status_code == 0 ? 1 : 0; } return $response; @@ -3088,7 +3147,7 @@ function PMFSaveCurrentData () */ function PMFTasksListByProcessId($processId, $lang = 'en') { - $result = array(); + $result = []; $criteria = new Criteria("workflow"); $criteria->addSelectColumn(TaskPeer::TAS_UID); $criteria->addSelectColumn(TaskPeer::TAS_TITLE); @@ -3122,7 +3181,7 @@ function PMFGetProcessUidByName($processName = '') if ($processName == '') { //Return - return (isset($_SESSION['PROCESS']))? $_SESSION['PROCESS'] : false; + return (isset($_SESSION['PROCESS'])) ? $_SESSION['PROCESS'] : false; } $criteria = new Criteria('workflow'); @@ -3230,7 +3289,7 @@ function PMFDynaFormFields($dynUid, $appUid = '', $delIndex = 0) $data["CURRENT_DYNAFORM"] = $dynUid; $dynaform = new PmDynaform(\ProcessMaker\Util\DateTime::convertUtcToTimeZone($data)); - $dynaform->onPropertyRead = function(&$json, $key, $value) { + $dynaform->onPropertyRead = function (&$json, $key, $value) { if (isset($json->data) && !isset($json->value)) { $json->value = $json->data->value; $json->value_label = $json->data->label; @@ -3271,7 +3330,8 @@ function PMFDynaFormFields($dynUid, $appUid = '', $delIndex = 0) * of the CONTENT table * @return string | $text | Translated text | the translated text of a string in Content */ -function PMFGetTaskName($taskUid, $lang = SYS_LANG) { +function PMFGetTaskName($taskUid, $lang = SYS_LANG) +{ if (empty($taskUid)) { return false; } @@ -3292,7 +3352,8 @@ function PMFGetTaskName($taskUid, $lang = SYS_LANG) { * @param string | $lang | Language | Is the language of the text, that must be the same to the column: "CON_LANG" of the CONTENT table * @return string | $text | Translated text | the translated text of a string in Content */ -function PMFGetGroupName($grpUid, $lang = SYS_LANG) { +function PMFGetGroupName($grpUid, $lang = SYS_LANG) +{ if (empty($grpUid)) { return false; } @@ -3375,7 +3436,7 @@ function PMFGetGroupUID($groupName) } //Return - return ($groupUid != '')? $groupUid : false; + return ($groupUid != '') ? $groupUid : false; } /** @@ -3405,8 +3466,11 @@ function PMFGetTaskUID($taskName, $processUid = null) $criteria->addSelectColumn(TaskPeer::TAS_UID); $criteria->add(TaskPeer::TAS_TITLE, $taskName, Criteria::EQUAL); - $criteria->add(TaskPeer::PRO_UID, (!empty($processUid)) ? $processUid : $_SESSION['PROCESS'], - Criteria::EQUAL); + $criteria->add( + TaskPeer::PRO_UID, + (!empty($processUid)) ? $processUid : $_SESSION['PROCESS'], + Criteria::EQUAL + ); $rsCriteria = TaskPeer::doSelectRS($criteria); $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC); @@ -3434,7 +3498,6 @@ function PMFGetGroupUsers($GroupUID) $groups = new Groups(); $usersGroup = $groups->getUsersOfGroup($GroupUID, 'ALL'); return $usersGroup; - } /** @@ -3511,7 +3574,8 @@ function PMFGetNextDerivationInfo($caseUid, $delIndex) $assignmentType = $arrayInfo['NEXT_TASK']['TAS_ASSIGN_TYPE']; - if ($arrayInfo['NEXT_TASK']['TAS_ASSIGN_TYPE'] == 'SELF_SERVICE' && + if ( + $arrayInfo['NEXT_TASK']['TAS_ASSIGN_TYPE'] == 'SELF_SERVICE' && trim($arrayInfo['NEXT_TASK']['TAS_GROUP_VARIABLE']) != '' ) { $assignmentType = 'SELF_SERVICE_VALUE'; @@ -3637,7 +3701,7 @@ function PMFAssociateUploadedFilesWithInputFile($inputDocumentUid, $gridVariable //Delete this file so it can't be uploaded again (Includes Mark Database Record) $appDocument->remove($file['APP_DOC_UID'], $file['DOC_VERSION']); - $fields = array ( + $fields = array( 'APP_UID' => $caseUid, 'DEL_INDEX' => $currentDelIndex, 'USR_UID' => $userUid, @@ -3656,8 +3720,8 @@ function PMFAssociateUploadedFilesWithInputFile($inputDocumentUid, $gridVariable $appUid = $appDocument->getAppUid(); $appDocUid = $appDocument->getAppDocUid(); $docVersion = $appDocument->getDocVersion(); - $info = pathinfo( $appDocument->getAppDocFilename() ); - $extAux = (isset( $info['extension'] )) ? $info['extension'] : ''; + $info = pathinfo($appDocument->getAppDocFilename()); + $extAux = (isset($info['extension'])) ? $info['extension'] : ''; //Save the file $pathName = PATH_DOCUMENT . G::getPathFromUID($appUid) . PATH_SEP; @@ -3872,7 +3936,8 @@ function PMFAddUserGroupToTask($taskUid, $userGroupUid) $userType = 'group'; } else { throw new Exception(G::LoadTranslation( - 'ID_USER_GROUP_NOT_CORRESPOND', [$userGroupUid, G::LoadTranslation('ID_USER') . '/' . G::LoadTranslation('ID_GROUP')] + 'ID_USER_GROUP_NOT_CORRESPOND', + [$userGroupUid, G::LoadTranslation('ID_USER') . '/' . G::LoadTranslation('ID_GROUP')] )); } } @@ -3921,7 +3986,8 @@ function PMFRemoveUserGroupFromTask($taskUid, $userGroupUid) $uid = $userGroupUid; } else { throw new Exception(G::LoadTranslation( - 'ID_USER_GROUP_NOT_CORRESPOND', [$userGroupUid, G::LoadTranslation('ID_USER') . '/' . G::LoadTranslation('ID_GROUP')] + 'ID_USER_GROUP_NOT_CORRESPOND', + [$userGroupUid, G::LoadTranslation('ID_USER') . '/' . G::LoadTranslation('ID_GROUP')] )); } } @@ -4002,14 +4068,25 @@ function PMFSendMessageToGroup( while ($rsCriteria->next()) { $record = $rsCriteria->getRow(); - $to .= (($to != '')? ', ' : '') . $record['USR_EMAIL']; + $to .= (($to != '') ? ', ' : '') . $record['USR_EMAIL']; $flagNextRecord = true; } if ($flagNextRecord) { $result = PMFSendMessage( - $caseId, $from, $to, null, null, $subject, $template, $arrayField, $arrayAttachment, $showMessage, $delIndex, $config + $caseId, + $from, + $to, + null, + null, + $subject, + $template, + $arrayField, + $arrayAttachment, + $showMessage, + $delIndex, + $config ); if ($result == 0) { @@ -4046,15 +4123,15 @@ function PMFSendMessageToGroup( */ function PMFNewUser( $username, - $password, - $firstname, - $lastname, + $password, + $firstname, + $lastname, $email, $role, $dueDate = null, $status = null, - $group = null) -{ + $group = null +) { if (empty($username)) { throw new Exception(G::LoadTranslation('ID_USERNAME_REQUIRED')); } @@ -4099,7 +4176,7 @@ function PMFNewUser( } $dueDate = mktime(0, 0, 0, 12, 31, date("Y") + $expirationDate); } - + if (!empty($status) && $status != null && $status != "" && $status) { if ($status != "ACTIVE" && $status != "INACTIVE" && $status != "VACATION") { throw new Exception(G::LoadTranslation('ID_INVALID_DATA')); @@ -4119,7 +4196,7 @@ function PMFNewUser( if (in_array('ID_PPP_MAXIMUM_LENGTH', $validation)) { throw new Exception(G::LoadTranslation('ID_PASSWORD_SURPRASES')); } - + if (in_array('ID_PPP_MINIMUM_LENGTH', $validation)) { throw new Exception(G::LoadTranslation('ID_PASSWORD_BELOW')); } @@ -4194,7 +4271,7 @@ function PMFNewUser( RbacUsers::createUser($data); $usrId = User::createUser($data); - + $data['USR_ID'] = $usrId; if (!is_null($group) && $group != '') { @@ -4216,7 +4293,7 @@ function PMFNewUser( 'status' => $data['USR_STATUS'], 'groupUid' => $group ]; - + return $response; } @@ -4273,7 +4350,7 @@ function PMFCaseInformation($caseUid, $delIndex = 0, $returnAppData = false) /** * Convert to string * - * @param variant $vValue + * @param string $vValue * @return string */ function pmToString($vValue) @@ -4284,7 +4361,7 @@ function pmToString($vValue) /** * Convert to integer * - * @param variant $vValue + * @param string $vValue * @return integer */ function pmToInteger($vValue) @@ -4295,7 +4372,7 @@ function pmToInteger($vValue) /** * Convert to float * - * @param variant $vValue + * @param string $vValue * @return float */ function pmToFloat($vValue) @@ -4306,7 +4383,7 @@ function pmToFloat($vValue) /** * Convert to Url * - * @param variant $vValue + * @param string $vValue * @return url */ function pmToUrl($vValue) @@ -4441,7 +4518,7 @@ function registerError($iType, $sError, $iLine, $sCode) /** * Obtain engine Data Base name * - * @param type $connection + * @param object $connection * @return type */ function getEngineDataBaseName($connection) @@ -4454,9 +4531,9 @@ function getEngineDataBaseName($connection) * Execute Queries for Oracle Database * * @param type $sql - * @param type $connection + * @param object $connection */ -function executeQueryOci($sql, $connection, $aParameter = array(), $dbsEncode = "") +function executeQueryOci($sql, $connection, $aParameter = [], $dbsEncode = "") { $aDNS = $connection->getDSN(); @@ -4496,7 +4573,7 @@ function executeQueryOci($sql, $connection, $aParameter = array(), $dbsEncode = } oci_execute($stid, OCI_DEFAULT); - $result = Array(); + $result = []; $i = 1; while ($row = oci_fetch_array($stid, OCI_ASSOC + OCI_RETURN_NULLS)) { $result[$i++] = $row; @@ -4532,7 +4609,7 @@ function executeQueryOci($sql, $connection, $aParameter = array(), $dbsEncode = default: // Stored procedures $stid = oci_parse($conn, $sql); - $aParameterRet = array(); + $aParameterRet = []; if (count($aParameter) > 0) { foreach ($aParameter as $key => $val) { $aParameterRet[$key] = $val;