diff --git a/INSTALL.txt b/INSTALL.txt index 5b4f588b7..18eae9d07 100644 --- a/INSTALL.txt +++ b/INSTALL.txt @@ -50,11 +50,10 @@ Internet Explorer 7 or later |* PHP Configuration *| ----------------------- In the PHP configuration file (php.ini), set the following settings: - memory_limit = 120M + memory_limit = 256M file_uploads = On short_open_tag = On -The memory_limit may be a minimum of 80MB, but it is recommended to set it to -120MB. If planning on uploading large Input Documents and attached files, then +If planning on uploading large Input Documents and attached files, then increase the max_post_size and upload_max_filesize to larger than the default 2MB: max_post_size = 2M diff --git a/database/factories/AbeConfigurationFactory.php b/database/factories/AbeConfigurationFactory.php index 8e9dd8b63..50f34ab21 100644 --- a/database/factories/AbeConfigurationFactory.php +++ b/database/factories/AbeConfigurationFactory.php @@ -27,7 +27,7 @@ $factory->define(\ProcessMaker\Model\AbeConfiguration::class, function (Faker $f 'ABE_UPDATE_DATE' => $faker->dateTime(), 'ABE_SUBJECT_FIELD' => '', 'ABE_MAILSERVER_OR_MAILCURRENT' => 0, - 'ABE_CUSTOM_GRID' => '', + 'ABE_CUSTOM_GRID' => serialize([]), 'ABE_EMAIL_SERVER_UID' => $emailServer->MESS_UID, 'ABE_ACTION_BODY_FIELD' => '', 'ABE_EMAIL_SERVER_RECEIVER_UID' => '' diff --git a/database/factories/AppNotesFactory.php b/database/factories/AppNotesFactory.php new file mode 100644 index 000000000..0f6cdd446 --- /dev/null +++ b/database/factories/AppNotesFactory.php @@ -0,0 +1,40 @@ +define(\ProcessMaker\Model\AppNotes::class, function (Faker $faker) { + return [ + 'APP_UID' => G::generateUniqueID(), + 'USR_UID' => G::generateUniqueID(), + 'NOTE_DATE' => $faker->dateTime(), + 'NOTE_CONTENT' => $faker->sentence(3), + 'NOTE_TYPE' => 'USER', + 'NOTE_AVAILABILITY' => 'PUBLIC', + 'NOTE_ORIGIN_OBJ' => '', + 'NOTE_AFFECTED_OBJ1' => '', + 'NOTE_AFFECTED_OBJ2' => '', + 'NOTE_RECIPIENTS' => '', + ]; +}); + +// Create a case notes with the foreign keys +$factory->state(\ProcessMaker\Model\AppNotes::class, 'foreign_keys', function (Faker $faker) { + // Create values in the foreign key relations + $application = factory(\ProcessMaker\Model\Application::class)->create(); + $user = factory(\ProcessMaker\Model\User::class)->create(); + + // Return with default values + return [ + 'APP_UID' => $application->APP_UID, + 'USR_UID' => $user->USR_UID, + 'NOTE_DATE' => $faker->dateTime(), + 'NOTE_CONTENT' => $faker->sentence(3), + 'NOTE_TYPE' => 'USER', + 'NOTE_AVAILABILITY' => 'PUBLIC', + 'NOTE_ORIGIN_OBJ' => '', + 'NOTE_AFFECTED_OBJ1' => '', + 'NOTE_AFFECTED_OBJ2' => '', + 'NOTE_RECIPIENTS' => '', + ]; +}); + diff --git a/database/factories/ProcessVariablesFactory.php b/database/factories/ProcessVariablesFactory.php index 6892de0b9..d7ee63666 100644 --- a/database/factories/ProcessVariablesFactory.php +++ b/database/factories/ProcessVariablesFactory.php @@ -15,7 +15,7 @@ $factory->define(ProcessVariables::class, function (Faker $faker) { 'VAR_SQL' => '', 'VAR_NULL' => 0, 'VAR_DEFAULT' => '', - 'VAR_ACCEPTED_VALUES' => '', + 'VAR_ACCEPTED_VALUES' => '[]', 'INP_DOC_UID' => '' ]; }); \ No newline at end of file diff --git a/framework/src/Maveriks/WebApplication.php b/framework/src/Maveriks/WebApplication.php index 82a9c5e97..46c788a23 100644 --- a/framework/src/Maveriks/WebApplication.php +++ b/framework/src/Maveriks/WebApplication.php @@ -536,7 +536,6 @@ class WebApplication ini_set('error_reporting', $arraySystemConfiguration['error_reporting']); ini_set('short_open_tag', 'On'); //?? ini_set('default_charset', 'UTF-8'); //?? - ini_set('memory_limit', $arraySystemConfiguration['memory_limit']); ini_set('soap.wsdl_cache_enabled', $arraySystemConfiguration['wsdl_cache']); ini_set('date.timezone', TIME_ZONE); //Set Time Zone diff --git a/gulliver/bin/tasks/templates/sysGeneric.php.tpl b/gulliver/bin/tasks/templates/sysGeneric.php.tpl index 79914245e..f89aba6fe 100644 --- a/gulliver/bin/tasks/templates/sysGeneric.php.tpl +++ b/gulliver/bin/tasks/templates/sysGeneric.php.tpl @@ -3,7 +3,6 @@ /*** enable display_error On to caught even fatal errors ***/ ini_set('display_errors','On'); ini_set('error_reporting', E_ALL ); -ini_set('memory_limit', '80M'); $path = Array(); $sf = $_SERVER['SCRIPT_FILENAME']; diff --git a/gulliver/system/class.dbMaintenance.php b/gulliver/system/class.dbMaintenance.php index cfa1ce711..bb3905a58 100644 --- a/gulliver/system/class.dbMaintenance.php +++ b/gulliver/system/class.dbMaintenance.php @@ -436,7 +436,6 @@ class DataBaseMaintenance */ public function restoreFromSql($sqlFile, $type = 'file') { - ini_set('memory_limit', '64M'); if ($type == 'file' && !is_file($sqlFile)) { throw new Exception("the $sqlFile doesn't exist!"); } diff --git a/gulliver/system/class.g.php b/gulliver/system/class.g.php index ee129521e..486670b0c 100644 --- a/gulliver/system/class.g.php +++ b/gulliver/system/class.g.php @@ -2750,11 +2750,6 @@ class G if (!array_key_exists("channels", $imageInfo)) { $imageInfo["channels"] = 3; } - $memoryNeeded = Round(($imageInfo[0] * $imageInfo[1] * $imageInfo['bits'] * $imageInfo['channels'] + Pow(2, 16)) * 1.95) / (1024 * 1024); - if ($memoryNeeded < 80) { - $memoryNeeded = 80; - } - ini_set('memory_limit', intval($memoryNeeded) . 'M'); $functions = array(IMAGETYPE_GIF => array('imagecreatefromgif', 'imagegif' ), IMAGETYPE_JPEG => array('imagecreatefromjpeg', 'imagejpeg'), IMAGETYPE_PNG => array('imagecreatefrompng', 'imagepng')); diff --git a/tests/Feature/DBQueryTest.php b/tests/Feature/DBQueryTest.php index a2ee1b029..00b15c367 100644 --- a/tests/Feature/DBQueryTest.php +++ b/tests/Feature/DBQueryTest.php @@ -23,6 +23,7 @@ class DBQueryTest extends TestCase /** * Verify the execution of a common SQL statement. + * Note, this test is now using Laravel DB backend work * @test */ public function testStandardExecuteQuery() diff --git a/tests/unit/workflow/engine/classes/ActionsByEmailCoreClassTest.php b/tests/unit/workflow/engine/classes/ActionsByEmailCoreClassTest.php new file mode 100644 index 000000000..f3ff0dd3a --- /dev/null +++ b/tests/unit/workflow/engine/classes/ActionsByEmailCoreClassTest.php @@ -0,0 +1,534 @@ +get() + ->first(); + $process = factory(Process::class)->create(); + $task = factory(Task::class)->create([ + 'PRO_UID' => $process->PRO_UID + ]); + $application = factory(Application::class)->create([ + 'PRO_UID' => $process->PRO_UID + ]); + $delegation = factory(Delegation::class)->create([ + 'APP_UID' => $application->APP_UID, + 'PRO_UID' => $process->PRO_UID, + 'TAS_UID' => $task->TAS_UID, + 'USR_UID' => $user->USR_UID + ]); + $data = [ + 'TAS_UID' => $task->TAS_UID, + 'APP_UID' => $application->APP_UID, + 'DEL_INDEX' => $delegation->DEL_INDEX, + 'USR_UID' => $user->USR_UID, + 'PREVIOUS_USR_UID' => $user->USR_UID + ]; + $data = (object) $data; + + //assertion Exception + $this->expectException(Exception::class); + + $this->actionsByEmailCoreClass = new ActionsByEmailCoreClass(); + $this->actionsByEmailCoreClass->sendActionsByEmail($data, []); + } + + /** + * This test checks if the sendActionsByEmail method handles an undefined configuration. + * @test + * @covers \ActionsByEmailCoreClass::sendActionsByEmail + */ + public function it_should_test_send_actions_by_email_if_abe_configuration_is_undefined() + { + $user = User::where('USR_UID', '=', '00000000000000000000000000000001') + ->get() + ->first(); + $process = factory(Process::class)->create(); + $task = factory(Task::class)->create([ + 'PRO_UID' => $process->PRO_UID + ]); + $abeConfiguration = [ + 'ABE_EMAIL_SERVER_UID' => '' + ]; + $application = factory(Application::class)->create([ + 'PRO_UID' => $process->PRO_UID + ]); + $delegation = factory(Delegation::class)->create([ + 'APP_UID' => $application->APP_UID, + 'PRO_UID' => $process->PRO_UID, + 'TAS_UID' => $task->TAS_UID, + 'USR_UID' => $user->USR_UID + ]); + $data = [ + 'TAS_UID' => $task->TAS_UID, + 'APP_UID' => $application->APP_UID, + 'DEL_INDEX' => $delegation->DEL_INDEX, + 'USR_UID' => $user->USR_UID, + 'PREVIOUS_USR_UID' => $user->USR_UID + ]; + $data = (object) $data; + + $this->actionsByEmailCoreClass = new ActionsByEmailCoreClass(); + $result = $this->actionsByEmailCoreClass->sendActionsByEmail($data, $abeConfiguration); + + $this->assertNull($result); + } + + /** + * This test checks if the sendActionsByEmail method throws an exception if + * the task properties do not exist. + * @test + * @covers \ActionsByEmailCoreClass::sendActionsByEmail + */ + public function it_should_test_send_actions_by_email_with_exception_if_task_property_is_undefined() + { + $user = User::where('USR_UID', '=', '00000000000000000000000000000001') + ->get() + ->first(); + $process = factory(Process::class)->create(); + $task = factory(Task::class)->create([ + 'PRO_UID' => $process->PRO_UID + ]); + $dynaform = factory(Dynaform::class)->create([ + 'PRO_UID' => $process->PRO_UID + ]); + $emailServer = factory(ProcessMaker\Model\EmailServerModel::class)->create(); + $abeConfiguration = factory(AbeConfiguration::class)->create([ + 'PRO_UID' => $process->PRO_UID, + 'TAS_UID' => '', + 'DYN_UID' => $dynaform->DYN_UID, + 'ABE_EMAIL_SERVER_UID' => $emailServer->MESS_UID, + 'ABE_TYPE' => 'CUSTOM', + 'ABE_CUSTOM_GRID' => serialize([]) + ]); + $abeConfiguration = $abeConfiguration->toArray(); + + $application = factory(Application::class)->create([ + 'PRO_UID' => $process->PRO_UID + ]); + $delegation = factory(Delegation::class)->create([ + 'APP_UID' => $application->APP_UID, + 'PRO_UID' => $process->PRO_UID, + 'TAS_UID' => $task->TAS_UID, + 'USR_UID' => $user->USR_UID + ]); + $data = [ + 'TAS_UID' => $task->TAS_UID, + 'APP_UID' => $application->APP_UID, + 'DEL_INDEX' => $delegation->DEL_INDEX, + 'USR_UID' => $user->USR_UID, + 'PREVIOUS_USR_UID' => $user->USR_UID + ]; + $data = (object) $data; + + $_SERVER["REQUEST_URI"] = ''; + + //assertion Exception + $this->expectException(Exception::class); + + $this->actionsByEmailCoreClass = new ActionsByEmailCoreClass(); + $this->actionsByEmailCoreClass->sendActionsByEmail($data, $abeConfiguration); + } + + /** + * This test checks if the sendActionsByEmail method throws an exception if the + * email address is empty. + * @test + * @covers \ActionsByEmailCoreClass::sendActionsByEmail + */ + public function it_should_test_send_actions_by_email_with_exception_if_email_to_is_empty() + { + $user = factory(User::class)->create([ + 'USR_EMAIL' => '' + ]); + + $process = factory(Process::class)->create(); + $task = factory(Task::class)->create([ + 'PRO_UID' => $process->PRO_UID + ]); + $dynaform = factory(Dynaform::class)->create([ + 'PRO_UID' => $process->PRO_UID + ]); + $emailServer = factory(ProcessMaker\Model\EmailServerModel::class)->create(); + $abeConfiguration = factory(AbeConfiguration::class)->create([ + 'PRO_UID' => $process->PRO_UID, + 'TAS_UID' => $task->TAS_UID, + 'DYN_UID' => $dynaform->DYN_UID, + 'ABE_EMAIL_SERVER_UID' => $emailServer->MESS_UID, + 'ABE_TYPE' => 'CUSTOM', + 'ABE_CUSTOM_GRID' => serialize([]), + 'ABE_EMAIL_FIELD' => '' + ]); + $abeConfiguration = $abeConfiguration->toArray(); + + $application = factory(Application::class)->create([ + 'PRO_UID' => $process->PRO_UID + ]); + $delegation = factory(Delegation::class)->create([ + 'APP_UID' => $application->APP_UID, + 'PRO_UID' => $process->PRO_UID, + 'TAS_UID' => $task->TAS_UID, + 'USR_UID' => $user->USR_UID + ]); + $data = [ + 'TAS_UID' => $task->TAS_UID, + 'APP_UID' => $application->APP_UID, + 'DEL_INDEX' => $delegation->DEL_INDEX, + 'USR_UID' => $user->USR_UID, + 'PREVIOUS_USR_UID' => $user->USR_UID + ]; + $data = (object) $data; + + $_SERVER["REQUEST_URI"] = ''; + + $this->actionsByEmailCoreClass = new ActionsByEmailCoreClass(); + $this->actionsByEmailCoreClass->setUser($user->USR_UID); + $this->actionsByEmailCoreClass->setIndex($delegation->DEL_INDEX); + $result = $this->actionsByEmailCoreClass->sendActionsByEmail($data, $abeConfiguration); + + $this->assertNull($result); + } + + /** + * This test checks if the sendActionsByEmail method throws an exception if + * the email type is empty. + * @test + * @covers \ActionsByEmailCoreClass::sendActionsByEmail + */ + public function it_should_test_send_actions_by_email_with_exception_if_email_type_is_empty() + { + $user = factory(User::class)->create(); + + $process = factory(Process::class)->create(); + $task = factory(Task::class)->create([ + 'PRO_UID' => $process->PRO_UID + ]); + $dynaform = factory(Dynaform::class)->create([ + 'PRO_UID' => $process->PRO_UID + ]); + $emailServer = factory(ProcessMaker\Model\EmailServerModel::class)->create(); + $abeConfiguration = factory(AbeConfiguration::class)->create([ + 'PRO_UID' => $process->PRO_UID, + 'TAS_UID' => $task->TAS_UID, + 'DYN_UID' => $dynaform->DYN_UID, + 'ABE_EMAIL_SERVER_UID' => $emailServer->MESS_UID, + 'ABE_TYPE' => '', + 'ABE_CUSTOM_GRID' => serialize([]), + 'ABE_EMAIL_FIELD' => '' + ]); + $abeConfiguration = $abeConfiguration->toArray(); + + $application = factory(Application::class)->create([ + 'PRO_UID' => $process->PRO_UID + ]); + $delegation = factory(Delegation::class)->create([ + 'APP_UID' => $application->APP_UID, + 'PRO_UID' => $process->PRO_UID, + 'TAS_UID' => $task->TAS_UID, + 'USR_UID' => $user->USR_UID + ]); + $data = [ + 'TAS_UID' => $task->TAS_UID, + 'APP_UID' => $application->APP_UID, + 'DEL_INDEX' => $delegation->DEL_INDEX, + 'USR_UID' => $user->USR_UID, + 'PREVIOUS_USR_UID' => $user->USR_UID + ]; + $data = (object) $data; + + $_SERVER["REQUEST_URI"] = ''; + + $this->actionsByEmailCoreClass = new ActionsByEmailCoreClass(); + $this->actionsByEmailCoreClass->setUser($user->USR_UID); + $this->actionsByEmailCoreClass->setIndex($delegation->DEL_INDEX); + $result = $this->actionsByEmailCoreClass->sendActionsByEmail($data, $abeConfiguration); + + $this->assertNull($result); + } + + /** + * This test verifies if the sendActionsByEmail method supports the 'CUSTOM' setting. + * @test + * @covers \ActionsByEmailCoreClass::sendActionsByEmail + */ + public function it_should_test_send_actions_by_email_custom() + { + $user = User::where('USR_UID', '=', '00000000000000000000000000000001') + ->get() + ->first(); + $process = factory(Process::class)->create(); + $task = factory(Task::class)->create([ + 'PRO_UID' => $process->PRO_UID + ]); + $dynaform = factory(Dynaform::class)->create([ + 'PRO_UID' => $process->PRO_UID + ]); + $emailServer = factory(ProcessMaker\Model\EmailServerModel::class)->create(); + $abeConfiguration = factory(AbeConfiguration::class)->create([ + 'PRO_UID' => $process->PRO_UID, + 'TAS_UID' => $task->TAS_UID, + 'DYN_UID' => $dynaform->DYN_UID, + 'ABE_EMAIL_SERVER_UID' => $emailServer->MESS_UID, + 'ABE_TYPE' => 'CUSTOM', + 'ABE_CUSTOM_GRID' => serialize([]) + ]); + $abeConfiguration = $abeConfiguration->toArray(); + + $application = factory(Application::class)->create([ + 'PRO_UID' => $process->PRO_UID + ]); + + $delegation = factory(Delegation::class)->create([ + 'APP_UID' => $application->APP_UID, + 'PRO_UID' => $process->PRO_UID, + 'TAS_UID' => $task->TAS_UID, + 'USR_UID' => $user->USR_UID + ]); + + $data = [ + 'TAS_UID' => $task->TAS_UID, + 'APP_UID' => $application->APP_UID, + 'DEL_INDEX' => $delegation->DEL_INDEX, + 'USR_UID' => $user->USR_UID, + 'PREVIOUS_USR_UID' => $user->USR_UID + ]; + $data = (object) $data; + + $_SERVER["REQUEST_URI"] = ''; + + $this->actionsByEmailCoreClass = new ActionsByEmailCoreClass(); + $this->actionsByEmailCoreClass->setUser($user->USR_UID); + $this->actionsByEmailCoreClass->setIndex($delegation->DEL_INDEX); + $this->actionsByEmailCoreClass->sendActionsByEmail($data, $abeConfiguration); + $result = $this->actionsByEmailCoreClass->getAbeRequest(); + + $this->assertArrayHasKey('ABE_REQ_UID', $result); + } + + /** + * This test verifies if the sendActionsByEmail method supports the 'RESPONSE' setting. + * @test + * @covers \ActionsByEmailCoreClass::sendActionsByEmail + */ + public function it_should_test_send_actions_by_email_response() + { + $user = User::where('USR_UID', '=', '00000000000000000000000000000001') + ->get() + ->first(); + $process = factory(Process::class)->create(); + $task = factory(Task::class)->create([ + 'PRO_UID' => $process->PRO_UID + ]); + $dynaform = factory(Dynaform::class)->create([ + 'PRO_UID' => $process->PRO_UID + ]); + $emailServer = factory(ProcessMaker\Model\EmailServerModel::class)->create(); + $abeConfiguration = factory(AbeConfiguration::class)->create([ + 'PRO_UID' => $process->PRO_UID, + 'TAS_UID' => $task->TAS_UID, + 'DYN_UID' => $dynaform->DYN_UID, + 'ABE_EMAIL_SERVER_UID' => $emailServer->MESS_UID, + 'ABE_TYPE' => 'RESPONSE', + 'ABE_CUSTOM_GRID' => serialize([]), + 'ABE_EMAIL_SERVER_RECEIVER_UID' => $emailServer->MESS_UID + ]); + $abeConfiguration = $abeConfiguration->toArray(); + + $application = factory(Application::class)->create([ + 'PRO_UID' => $process->PRO_UID + ]); + + $delegation = factory(Delegation::class)->create([ + 'APP_UID' => $application->APP_UID, + 'PRO_UID' => $process->PRO_UID, + 'TAS_UID' => $task->TAS_UID, + 'USR_UID' => $user->USR_UID + ]); + + $data = [ + 'TAS_UID' => $task->TAS_UID, + 'APP_UID' => $application->APP_UID, + 'DEL_INDEX' => $delegation->DEL_INDEX, + 'USR_UID' => $user->USR_UID, + 'PREVIOUS_USR_UID' => $user->USR_UID + ]; + $data = (object) $data; + + $_SERVER["REQUEST_URI"] = ''; + + $this->actionsByEmailCoreClass = new ActionsByEmailCoreClass(); + $this->actionsByEmailCoreClass->setUser($user->USR_UID); + $this->actionsByEmailCoreClass->setIndex($delegation->DEL_INDEX); + $this->actionsByEmailCoreClass->sendActionsByEmail($data, $abeConfiguration); + $result = $this->actionsByEmailCoreClass->getAbeRequest(); + + $this->assertArrayHasKey('ABE_REQ_UID', $result); + } + + /** + * This test verifies if the sendActionsByEmail method supports the 'FIELD' setting. + * @test + * @covers \ActionsByEmailCoreClass::sendActionsByEmail + */ + public function it_should_test_send_actions_by_email_link() + { + $user = User::where('USR_UID', '=', '00000000000000000000000000000001') + ->get() + ->first(); + $process = factory(Process::class)->create(); + $task = factory(Task::class)->create([ + 'PRO_UID' => $process->PRO_UID + ]); + $dynaform = factory(Dynaform::class)->create([ + 'PRO_UID' => $process->PRO_UID + ]); + $emailServer = factory(ProcessMaker\Model\EmailServerModel::class)->create(); + $abeConfiguration = factory(AbeConfiguration::class)->create([ + 'PRO_UID' => $process->PRO_UID, + 'TAS_UID' => $task->TAS_UID, + 'DYN_UID' => $dynaform->DYN_UID, + 'ABE_EMAIL_SERVER_UID' => $emailServer->MESS_UID, + 'ABE_TYPE' => 'LINK', + 'ABE_CUSTOM_GRID' => serialize([]), + 'ABE_EMAIL_SERVER_RECEIVER_UID' => $emailServer->MESS_UID + ]); + $abeConfiguration = $abeConfiguration->toArray(); + + $application = factory(Application::class)->create([ + 'PRO_UID' => $process->PRO_UID + ]); + + $delegation = factory(Delegation::class)->create([ + 'APP_UID' => $application->APP_UID, + 'PRO_UID' => $process->PRO_UID, + 'TAS_UID' => $task->TAS_UID, + 'USR_UID' => $user->USR_UID + ]); + + $data = [ + 'TAS_UID' => $task->TAS_UID, + 'APP_UID' => $application->APP_UID, + 'DEL_INDEX' => $delegation->DEL_INDEX, + 'USR_UID' => $user->USR_UID, + 'PREVIOUS_USR_UID' => $user->USR_UID + ]; + $data = (object) $data; + + $_SERVER["REQUEST_URI"] = ''; + + $this->actionsByEmailCoreClass = new ActionsByEmailCoreClass(); + $this->actionsByEmailCoreClass->setUser($user->USR_UID); + $this->actionsByEmailCoreClass->setIndex($delegation->DEL_INDEX); + $this->actionsByEmailCoreClass->sendActionsByEmail($data, $abeConfiguration); + $result = $this->actionsByEmailCoreClass->getAbeRequest(); + + $this->assertArrayHasKey('ABE_REQ_UID', $result); + } + + /** + * This test verifies if the sendActionsByEmail method supports the 'FIELD' setting. + * @test + * @covers \ActionsByEmailCoreClass::sendActionsByEmail + */ + public function it_should_test_send_actions_by_email_field() + { + $user = User::where('USR_UID', '=', '00000000000000000000000000000001') + ->get() + ->first(); + $process = factory(Process::class)->create(); + $task = factory(Task::class)->create([ + 'PRO_UID' => $process->PRO_UID + ]); + $dynaform = factory(Dynaform::class)->create([ + 'PRO_UID' => $process->PRO_UID + ]); + $emailServer = factory(ProcessMaker\Model\EmailServerModel::class)->create(); + $abeConfiguration = factory(AbeConfiguration::class)->create([ + 'PRO_UID' => $process->PRO_UID, + 'TAS_UID' => $task->TAS_UID, + 'DYN_UID' => $dynaform->DYN_UID, + 'ABE_EMAIL_SERVER_UID' => $emailServer->MESS_UID, + 'ABE_TYPE' => 'FIELD', + 'ABE_CUSTOM_GRID' => serialize([]), + 'ABE_EMAIL_SERVER_RECEIVER_UID' => $emailServer->MESS_UID + ]); + $abeConfiguration = $abeConfiguration->toArray(); + + $application = factory(Application::class)->create([ + 'PRO_UID' => $process->PRO_UID + ]); + + $delegation = factory(Delegation::class)->create([ + 'APP_UID' => $application->APP_UID, + 'PRO_UID' => $process->PRO_UID, + 'TAS_UID' => $task->TAS_UID, + 'USR_UID' => $user->USR_UID + ]); + + $data = [ + 'TAS_UID' => $task->TAS_UID, + 'APP_UID' => $application->APP_UID, + 'DEL_INDEX' => $delegation->DEL_INDEX, + 'USR_UID' => $user->USR_UID, + 'PREVIOUS_USR_UID' => $user->USR_UID + ]; + $data = (object) $data; + + $_SERVER["REQUEST_URI"] = ''; + + $this->actionsByEmailCoreClass = new ActionsByEmailCoreClass(); + $this->actionsByEmailCoreClass->setUser($user->USR_UID); + $this->actionsByEmailCoreClass->setIndex($delegation->DEL_INDEX); + $this->actionsByEmailCoreClass->sendActionsByEmail($data, $abeConfiguration); + $result = $this->actionsByEmailCoreClass->getAbeRequest(); + + $this->assertArrayHasKey('ABE_REQ_UID', $result); + } +} diff --git a/tests/unit/workflow/engine/classes/ProcessesTest.php b/tests/unit/workflow/engine/classes/ProcessesTest.php index 207ebe127..e8fa446cc 100644 --- a/tests/unit/workflow/engine/classes/ProcessesTest.php +++ b/tests/unit/workflow/engine/classes/ProcessesTest.php @@ -9,6 +9,7 @@ use ProcessMaker\Model\Dynaform; use ProcessMaker\Model\InputDocument; use ProcessMaker\Model\OutputDocument; use ProcessMaker\Model\Process; +use ProcessMaker\Model\ProcessVariables; use Tests\TestCase; class ProcessesTest extends TestCase @@ -479,4 +480,70 @@ class ProcessesTest extends TestCase $this->assertObjectHasAttribute($key, $result); } } + + /** + * Test it create a variable from old xml fields + * + * @covers \Processes::createProcessVariables() + * @test + */ + public function it_create_variables_from_import_old() + { + $process = factory(\ProcessMaker\Model\Process::class)->create(); + $attributes[] = [ + 'VAR_UID' => G::generateUniqueID(), + 'PRJ_UID' => $process->PRO_UID, + 'VAR_NAME' => 'varTest', + 'VAR_FIELD_TYPE' => 'integer', + 'VAR_FIELD_SIZE' => 10, + 'VAR_LABEL' => 'string', + 'VAR_DBCONNECTION' => '', + 'VAR_SQL' => '', + 'VAR_NULL' => 0, + 'VAR_DEFAULT' => '', + 'VAR_ACCEPTED_VALUES' => '[]', + 'INP_DOC_UID' => '' + ]; + $processes = new Processes(); + $processes->createProcessVariables($attributes); + $result = ProcessVariables::getVariables($process->PRO_ID); + $this->assertNotEmpty($result); + $result = head($result); + $this->assertArrayHasKey('PRO_ID', $result, "The result does not contains 'PRO_ID' as a key"); + $this->assertArrayHasKey('VAR_FIELD_TYPE_ID', $result, "The result does not contains 'VAR_FIELD_TYPE_ID' as a key"); + $this->assertEquals($result['VAR_FIELD_TYPE_ID'], 2); + } + + /** + * Test it create a variable from new xml fields + * + * @covers \Processes::createProcessVariables() + * @test + */ + public function it_create_variables_from_import_new() + { + $process = factory(\ProcessMaker\Model\Process::class)->create(); + $attributes[] = [ + 'VAR_UID' => G::generateUniqueID(), + 'PRJ_UID' => $process->PRO_UID, + 'VAR_NAME' => 'varTest', + 'VAR_FIELD_TYPE' => 'string', + 'VAR_FIELD_TYPE_ID' => 1, + 'VAR_FIELD_SIZE' => 10, + 'VAR_LABEL' => 'string', + 'VAR_DBCONNECTION' => '', + 'VAR_SQL' => '', + 'VAR_NULL' => 0, + 'VAR_DEFAULT' => '', + 'VAR_ACCEPTED_VALUES' => '[]', + 'INP_DOC_UID' => '' + ]; + $processes = new Processes(); + $processes->createProcessVariables($attributes); + $result = ProcessVariables::getVariables($process->PRO_ID); + $this->assertNotEmpty($result); + $result = head($result); + $this->assertArrayHasKey('PRO_ID', $result, "The result does not contains 'PRO_ID' as a key"); + $this->assertArrayHasKey('VAR_FIELD_TYPE_ID', $result, "The result does not contains 'VAR_FIELD_TYPE_ID' as a key"); + } } diff --git a/tests/unit/workflow/engine/classes/WsBaseTest.php b/tests/unit/workflow/engine/classes/WsBaseTest.php index 3c7a1ffb5..c88f56795 100755 --- a/tests/unit/workflow/engine/classes/WsBaseTest.php +++ b/tests/unit/workflow/engine/classes/WsBaseTest.php @@ -12,7 +12,6 @@ use ProcessMaker\Model\Process; use ProcessMaker\Model\Task; use ProcessMaker\Model\User; use ProcessMaker\Model\UserReporting; -use ProcessMaker\Util\WsMessageResponse; use Tests\TestCase; /** @@ -22,6 +21,7 @@ use Tests\TestCase; */ class WsBaseTest extends TestCase { + use DatabaseTransactions; /** @@ -65,21 +65,20 @@ class WsBaseTest extends TestCase */ private function createNewCase($applicationNumber = null) { + $userUid = G::generateUniqueID(); + $processUid = G::generateUniqueID(); + $applicationUid = G::generateUniqueID(); if (empty($applicationNumber)) { $faker = Factory::create(); $applicationNumber = $faker->unique()->numberBetween(1, 10000000); } - $userUid = G::generateUniqueID(); - $processUid = G::generateUniqueID(); - $taskUid = G::generateUniqueID(); - $applicationUid = G::generateUniqueID(); $appData = [ 'SYS_LANG' => 'en', 'SYS_SKIN' => 'neoclassic', 'SYS_SYS' => 'workflow', - 'APPLICATION' => G::generateUniqueID(), - 'PROCESS' => G::generateUniqueID(), + 'APPLICATION' => $applicationUid, + 'PROCESS' => $processUid, 'TASK' => '', 'INDEX' => 2, 'USER_LOGGED' => $userUid, @@ -108,16 +107,9 @@ class WsBaseTest extends TestCase ]); $result = new stdClass(); - $result->userUid = $userUid; - $result->processUid = $processUid; - $result->taskUid = $taskUid; - $result->applicationUid = $applicationUid; - $result->applicationNumber = $applicationNumber; - $result->appData = $appData; + $result->application = $application; $result->user = $user; $result->process = $process; - $result->task = $task; - $result->application = $application; return $result; } @@ -229,7 +221,7 @@ class WsBaseTest extends TestCase $template = $this->createTemplate($case->process->PRO_UID, $case->user->USR_UID); //parameters - $appUid = $case->applicationUid; + $appUid = $case->application->APP_UID; $from = $emailServer->MESS_ACCOUNT; $to = $emailServer->MESS_ACCOUNT; $cc = ""; @@ -269,7 +261,7 @@ class WsBaseTest extends TestCase $template = $this->createTemplate($case->process->PRO_UID, $case->user->USR_UID); //parameters - $appUid = $case->applicationUid; + $appUid = $case->application->APP_UID; $from = $emailServer->MESS_ACCOUNT; $to = ""; $cc = ""; @@ -308,7 +300,7 @@ class WsBaseTest extends TestCase $template = $this->createTemplate($case->process->PRO_UID, $case->user->USR_UID); //parameters - $appUid = $case->applicationUid; + $appUid = $case->application->APP_UID; $from = $emailServer->MESS_ACCOUNT; $to = $emailServer->MESS_ACCOUNT; $cc = ""; @@ -347,7 +339,7 @@ class WsBaseTest extends TestCase $template = $this->createTemplate($case->process->PRO_UID, $case->user->USR_UID); //parameters - $appUid = $case->applicationUid; + $appUid = $case->application->APP_UID; $from = $emailServer->MESS_ACCOUNT; $to = ""; $cc = ""; @@ -386,7 +378,7 @@ class WsBaseTest extends TestCase $template = $this->createTemplate($case->process->PRO_UID, $case->user->USR_UID); //parameters - $appUid = $case->applicationUid; + $appUid = $case->application->APP_UID; $from = $emailServer->MESS_ACCOUNT; $to = $emailServer->MESS_ACCOUNT; $cc = ""; @@ -425,7 +417,7 @@ class WsBaseTest extends TestCase $template = $this->createTemplate($case->process->PRO_UID, $case->user->USR_UID); //parameters - $appUid = $case->applicationUid; + $appUid = $case->application->APP_UID; $from = $emailServer->MESS_ACCOUNT; $to = ""; $cc = ""; @@ -464,7 +456,7 @@ class WsBaseTest extends TestCase $template = $this->createTemplate($case->process->PRO_UID, $case->user->USR_UID); //parameters - $appUid = $case->applicationUid; + $appUid = $case->application->APP_UID; $from = $emailServer->MESS_ACCOUNT; $to = ""; $cc = ""; @@ -644,7 +636,7 @@ class WsBaseTest extends TestCase $template = $this->createTemplate($case->process->PRO_UID, $case->user->USR_UID); //parameters - $appUid = $case->applicationUid; + $appUid = $case->application->APP_UID; $from = $faker->email; $to = ""; $cc = ""; @@ -659,7 +651,131 @@ class WsBaseTest extends TestCase $result = $wsBase->sendMessage($appUid, $from, $to, $cc, $bcc, $subject, $templateName, $appFields); //assertions - $this->assertInstanceOf(WsMessageResponse::class, $result); + $this->assertInstanceOf(WsResponse::class, $result); + } + + /** + * This test ensures the response when the default configuration does not exist. + * @test + * @covers WsBase::sendMessage + */ + public function it_should_test_an_send_message_without_default_configuration() + { + //data + $emailServer = $this->createEmailServer(); + $case = $this->createNewCase(); + $template = $this->createTemplate($case->process->PRO_UID, $case->user->USR_UID); + + //parameters + $appUid = $case->application->APP_UID; + $from = $emailServer->MESS_ACCOUNT; + $to = $emailServer->MESS_ACCOUNT; + $cc = ""; + $bcc = ""; + $subject = "test"; + $templateName = basename($template->PRF_PATH); + $appFields = []; + $attachment = []; + $showMessage = true; + $delIndex = 0; + $config = []; + $gmail = 0; + $appMsgType = ''; + + //for empty configuration + EmailServerModel::truncate(); + + $wsBase = new WsBase(); + $result = $wsBase->sendMessage($appUid, $from, $to, $cc, $bcc, $subject, $templateName, $appFields, $attachment, $showMessage, $delIndex, $config, $gmail, $appMsgType); + + //assertions + $this->assertObjectHasAttribute('status_code', $result); + $this->assertObjectHasAttribute('message', $result); + $this->assertObjectHasAttribute('timestamp', $result); + $this->assertObjectHasAttribute('extraParams', $result); + $this->assertEquals(29, $result->status_code); + } + + /** + * This test ensures the response when the template is not found. + * @test + * @covers WsBase::sendMessage + */ + public function it_should_test_an_send_message_missing_template() + { + //data + $emailServer = $this->createEmailServer(); + $case = $this->createNewCase(); + $template = $this->createTemplate($case->process->PRO_UID, $case->user->USR_UID); + + //parameters + $appUid = $case->application->APP_UID; + $from = $emailServer->MESS_ACCOUNT; + $to = $emailServer->MESS_ACCOUNT; + $cc = ""; + $bcc = ""; + $subject = "test"; + $templateName = basename($template->PRF_PATH); + $appFields = []; + $attachment = []; + $showMessage = true; + $delIndex = 0; + $config = $emailServer->toArray(); + $gmail = 0; + $appMsgType = ''; + + //for a missing template + $templateName = 'MissingFile'; + G::rm_dir(PATH_DATA_SITE . 'mailTemplates'); + + $wsBase = new WsBase(); + $result = $wsBase->sendMessage($appUid, $from, $to, $cc, $bcc, $subject, $templateName, $appFields, $attachment, $showMessage, $delIndex, $config, $gmail, $appMsgType); + + //assertions + $this->assertObjectHasAttribute('status_code', $result); + $this->assertObjectHasAttribute('message', $result); + $this->assertObjectHasAttribute('timestamp', $result); + $this->assertObjectHasAttribute('extraParams', $result); + $this->assertEquals(28, $result->status_code); + } + + /** + * This test ensures the response when there is an exception. + * @test + * @covers WsBase::sendMessage + */ + public function it_should_test_an_send_message_when_appears_an_exception() + { + //data + $emailServer = $this->createEmailServer(); + $case = $this->createNewCase(); + $template = $this->createTemplate($case->process->PRO_UID, $case->user->USR_UID); + + //parameters + $appUid = null; + $from = $emailServer->MESS_ACCOUNT; + $to = $emailServer->MESS_ACCOUNT; + $cc = ""; + $bcc = ""; + $subject = "test"; + $templateName = basename($template->PRF_PATH); + $appFields = []; + $attachment = []; + $showMessage = true; + $delIndex = 0; + $config = $emailServer->toArray(); + $gmail = 0; + $appMsgType = ''; + + $wsBase = new WsBase(); + $result = $wsBase->sendMessage($appUid, $from, $to, $cc, $bcc, $subject, $templateName, $appFields, $attachment, $showMessage, $delIndex, $config, $gmail, $appMsgType); + + //assertions + $this->assertObjectHasAttribute('status_code', $result); + $this->assertObjectHasAttribute('message', $result); + $this->assertObjectHasAttribute('timestamp', $result); + $this->assertObjectHasAttribute('extraParams', $result); + $this->assertEquals(100, $result->status_code); } /** @@ -680,7 +796,7 @@ class WsBaseTest extends TestCase ]); $_SESSION["APPLICATION"] = $delegation->APP_UID; $ws = new WsBase(); - $response = (object)$ws->cancelCase($delegation->APP_UID, $delegation->DEL_INDEX, $delegation->APP_UID); + $response = (object) $ws->cancelCase($delegation->APP_UID, $delegation->DEL_INDEX, $delegation->APP_UID); $this->assertEquals($ws->getFlagSameCase(), true); $this->assertNotEmpty($response); } @@ -695,7 +811,7 @@ class WsBaseTest extends TestCase { $delegation = factory(Delegation::class)->states('foreign_keys')->create(); $ws = new WsBase(); - $response = (object)$ws->cancelCase('', $delegation->DE_INDEX, $delegation->URS_UID); + $response = (object) $ws->cancelCase('', $delegation->DE_INDEX, $delegation->URS_UID); $this->assertEquals($response->status_code, 100); $this->assertEquals($response->message, G::LoadTranslation("ID_REQUIRED_FIELD") . ' caseUid'); } @@ -718,7 +834,7 @@ class WsBaseTest extends TestCase 'APP_UID' => $application->APP_UID, ]); $ws = new WsBase(); - $response = (object)$ws->cancelCase($delegation->APP_UID, $delegation->DE_INDEX, $delegation->URS_UID); + $response = (object) $ws->cancelCase($delegation->APP_UID, $delegation->DE_INDEX, $delegation->URS_UID); $this->assertEquals($response->status_code, 100); $this->assertEquals($response->message, G::LoadTranslation("ID_CASE_IN_STATUS") . ' DRAFT'); @@ -732,7 +848,7 @@ class WsBaseTest extends TestCase 'APP_UID' => $application->APP_UID, ]); $ws = new WsBase(); - $response = (object)$ws->cancelCase($delegation->APP_UID, $delegation->DE_INDEX, $delegation->URS_UID); + $response = (object) $ws->cancelCase($delegation->APP_UID, $delegation->DE_INDEX, $delegation->URS_UID); $this->assertEquals($response->status_code, 100); $this->assertEquals($response->message, G::LoadTranslation("ID_CASE_IN_STATUS") . ' COMPLETED'); @@ -746,7 +862,7 @@ class WsBaseTest extends TestCase 'APP_UID' => $application->APP_UID, ]); $ws = new WsBase(); - $response = (object)$ws->cancelCase($delegation->APP_UID, $delegation->DE_INDEX, $delegation->URS_UID); + $response = (object) $ws->cancelCase($delegation->APP_UID, $delegation->DE_INDEX, $delegation->URS_UID); $this->assertEquals($response->status_code, 100); $this->assertEquals($response->message, G::LoadTranslation("ID_CASE_IN_STATUS") . ' CANCELLED'); } @@ -768,7 +884,7 @@ class WsBaseTest extends TestCase 'APP_UID' => $application->APP_UID, ]); $ws = new WsBase(); - $response = (object)$ws->cancelCase($delegation->APP_UID, '', $delegation->USR_UID); + $response = (object) $ws->cancelCase($delegation->APP_UID, '', $delegation->USR_UID); $this->assertEquals($response->status_code, 100); $this->assertEquals($response->message, G::LoadTranslation("ID_REQUIRED_FIELD") . ' delIndex'); } @@ -791,7 +907,7 @@ class WsBaseTest extends TestCase 'DEL_THREAD_STATUS' => 'CLOSED' ]); $ws = new WsBase(); - $response = (object)$ws->cancelCase($delegation->APP_UID, $delegation->DEL_INDEX, ''); + $response = (object) $ws->cancelCase($delegation->APP_UID, $delegation->DEL_INDEX, ''); $this->assertEquals($response->status_code, 100); $this->assertEquals($response->message, G::LoadTranslation("ID_CASE_DELEGATION_ALREADY_CLOSED")); } @@ -813,7 +929,7 @@ class WsBaseTest extends TestCase 'APP_UID' => $application->APP_UID, ]); $ws = new WsBase(); - $response = (object)$ws->cancelCase($delegation->APP_UID, $delegation->DEL_INDEX, ''); + $response = (object) $ws->cancelCase($delegation->APP_UID, $delegation->DEL_INDEX, ''); $this->assertEquals($response->status_code, 100); $this->assertEquals($response->message, G::LoadTranslation("ID_REQUIRED_FIELD") . ' userUid'); } @@ -857,7 +973,7 @@ class WsBaseTest extends TestCase ]); $ws = new WsBase(); - $response = (object)$ws->cancelCase($delegation->APP_UID, $delegation->DEL_INDEX, $delegation->USR_UID); + $response = (object) $ws->cancelCase($delegation->APP_UID, $delegation->DEL_INDEX, $delegation->USR_UID); $this->assertEquals($response->status_code, 100); $this->assertEquals($response->message, G::LoadTranslation("ID_CASE_CANCELLED_PARALLEL")); } @@ -904,7 +1020,7 @@ class WsBaseTest extends TestCase ]); $ws = new WsBase(); - $response = (object)$ws->cancelCase($delegation->APP_UID, $delegation->DEL_INDEX, $delegation->USR_UID); + $response = (object) $ws->cancelCase($delegation->APP_UID, $delegation->DEL_INDEX, $delegation->USR_UID); $this->assertNotEmpty($response); $this->assertObjectHasAttribute('status_code', $response); $this->assertEquals($response->message, G::LoadTranslation("ID_COMMAND_EXECUTED_SUCCESSFULLY")); @@ -969,7 +1085,7 @@ class WsBaseTest extends TestCase ]); $ws = new WsBase(); - $response = (object)$ws->cancelCase($delegation->APP_UID, null, null); + $response = (object) $ws->cancelCase($delegation->APP_UID, null, null); $this->assertNotEmpty($response); $this->assertObjectHasAttribute('status_code', $response); $this->assertEquals($response->message, G::LoadTranslation("ID_COMMAND_EXECUTED_SUCCESSFULLY")); @@ -1002,7 +1118,7 @@ class WsBaseTest extends TestCase 'DEL_INDEX' => 2, ]); $ws = new WsBase(); - $response = (object)$ws->cancelCase($fakeApp, $delegation->DEL_INDEX, $delegation->USR_UID); + $response = (object) $ws->cancelCase($fakeApp, $delegation->DEL_INDEX, $delegation->USR_UID); $this->assertEquals($response->status_code, 100); $this->assertEquals($response->message, "The Application row '$fakeApp' doesn't exist!"); } diff --git a/tests/unit/workflow/engine/classes/WsResponseTest.php b/tests/unit/workflow/engine/classes/WsResponseTest.php new file mode 100644 index 000000000..33f5fa2d6 --- /dev/null +++ b/tests/unit/workflow/engine/classes/WsResponseTest.php @@ -0,0 +1,86 @@ +wsResponse = new WsResponse(0, ''); + + //assert + $actual = $this->wsResponse->getExtraParam(''); + $this->assertEmpty($actual); + + //assert + $actual = $this->wsResponse->getExtraParam('test'); + $this->assertEmpty($actual); + + //assert + $expected = 'test'; + $this->wsResponse->addExtraParam('test', $expected); + $actual = $this->wsResponse->getExtraParam('test'); + $this->assertEquals($expected, $actual); + } + + /** + * This test the add extra param. + * @test + * @covers \WsResponse::addExtraParam + */ + public function it_should_test_add_extra_param() + { + $this->wsResponse = new WsResponse(0, ''); + + //assert + $expected = 'test'; + $this->wsResponse->addExtraParam('test', $expected); + $actual = $this->wsResponse->getExtraParam('test'); + $this->assertEquals($expected, $actual); + } + + /** + * This test a get payload string. + * @test + * @covers \WsResponse::getPayloadString + */ + public function it_should_test_get_payload_string() + { + $this->wsResponse = new WsResponse(0, ''); + + //assert + $actual = $this->wsResponse->getPayloadString('test'); + $this->assertContains('test', $actual); + } + + /** + * @test + * @covers \WsResponse::getPayloadArray + */ + public function it_should_test_payload_array() + { + $this->wsResponse = new WsResponse(0, ''); + + //assert + $actual = $this->wsResponse->getPayloadArray(); + $this->assertArrayHasKey('status_code', $actual); + $this->assertArrayHasKey('message', $actual); + $this->assertArrayHasKey('timestamp', $actual); + } +} diff --git a/tests/unit/workflow/engine/classes/model/AppNotesTest.php b/tests/unit/workflow/engine/classes/model/AppNotesTest.php new file mode 100644 index 000000000..e6529b4f4 --- /dev/null +++ b/tests/unit/workflow/engine/classes/model/AppNotesTest.php @@ -0,0 +1,104 @@ +create(); + $user = factory(User::class)->create(); + $reason = "The case was canceled due to:"; + $appNotes = new ModelAppNotes(); + $noteContent = addslashes($reason); + $appNotes->postNewNote( + $application->APP_UID, $user->USR_UID, $noteContent, false + ); + + // Query to get the cases notes + $query = AppNotes::query(); + $query->select()->where('APP_UID', $application->APP_UID)->where('USR_UID', $user->USR_UID); + $result = $query->get()->values()->toArray(); + $this->assertNotEmpty($result); + } + + /** + * It test the cases notes creation and send a email to specific user + * + * @test + */ + public function it_test_case_notes_creation_and_send_email_to_user() + { + $application = factory(Application::class)->create(); + $user = factory(User::class)->create(); + $reason = "The case was canceled due to:"; + $appNotes = new ModelAppNotes(); + $noteContent = addslashes($reason); + $appNotes->postNewNote( + $application->APP_UID, $user->USR_UID, $noteContent, true, 'PUBLIC', $user->USR_UID + ); + + // Query to get the cases notes + $query = AppNotes::query(); + $query->select()->where('APP_UID', $application->APP_UID)->where('USR_UID', $user->USR_UID); + $result = $query->get()->values()->toArray(); + $this->assertNotEmpty($result); + + // Query to get the emails + $query = AppMessage::query(); + $query->select()->where('APP_UID', $application->APP_UID)->where('APP_MSG_TYPE', 'CASE_NOTE'); + $result = $query->get()->values()->toArray(); + $this->assertNotEmpty($result); + } + + /** + * It test the cases notes creation and send a email to user with participaion in the case + * + * @test + */ + public function it_test_case_notes_creation_and_send_email() + { + $application = factory(Application::class)->create(); + $user = factory(User::class)->create(); + factory(Delegation::class)->create([ + 'APP_UID' => $application->APP_UID, + 'USR_UID' => $user->USR_UID + ]); + $reason = "The case was canceled due to:"; + $appNotes = new ModelAppNotes(); + $noteContent = addslashes($reason); + $appNotes->postNewNote( + $application->APP_UID, $user->USR_UID, $noteContent, true, 'PUBLIC' + ); + + // Query to get the cases notes + $query = AppNotes::query(); + $query->select()->where('APP_UID', $application->APP_UID)->where('USR_UID', $user->USR_UID); + $result = $query->get()->values()->toArray(); + $this->assertNotEmpty($result); + + // Query to get the emails + $query = AppMessage::query(); + $query->select()->where('APP_UID', $application->APP_UID)->where('APP_MSG_TYPE', 'CASE_NOTE'); + $result = $query->get()->values()->toArray(); + $this->assertNotEmpty($result); + } +} \ No newline at end of file diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/VariableTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/VariableTest.php new file mode 100644 index 000000000..794dd14f2 --- /dev/null +++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/VariableTest.php @@ -0,0 +1,191 @@ +create(); + + factory(ProcessVariables::class)->create([ + 'PRJ_UID' => $process->PRO_UID, + 'PRO_ID' => $process->PRO_ID, + ] + ); + $properties = [ + 'VAR_UID' => G::generateUniqueID(), + 'VAR_NAME' => 'var_test', + 'VAR_FIELD_TYPE' => 'string', + 'VAR_FIELD_SIZE' => 10, + 'VAR_LABEL' => 'string', + 'VAR_DBCONNECTION' => '', + 'VAR_SQL' => '', + 'VAR_NULL' => 0, + 'VAR_DEFAULT' => '', + 'VAR_ACCEPTED_VALUES' => '[]', + 'INP_DOC_UID' => '' + ]; + + $variable = new Variable(); + $res = $variable->create($process->PRO_UID, $properties); + $this->assertNotEmpty($res); + $this->assertArrayHasKey('var_uid', $res, "The result does not contains 'var_uid' as key"); + $this->assertArrayHasKey('prj_uid', $res, "The result does not contains 'prj_uid' as key"); + $this->assertArrayHasKey('var_name', $res, "The result does not contains 'var_name' as key"); + $this->assertArrayHasKey('var_field_type', $res, "The result does not contains 'var_field_type' as key"); + $this->assertArrayHasKey('var_field_size', $res, "The result does not contains 'var_field_size' as key"); + $this->assertArrayHasKey('var_label', $res, "The result does not contains 'var_label' as key"); + $this->assertArrayHasKey('var_dbconnection', $res, "The result does not contains 'var_dbconnection' as key"); + $this->assertArrayHasKey('var_dbconnection_label', $res, "The result does not contains 'var_dbconnection_label' as key"); + $this->assertArrayHasKey('var_sql', $res, "The result does not contains 'var_sql' as key"); + $this->assertArrayHasKey('var_null', $res, "The result does not contains 'var_null' as key"); + $this->assertArrayHasKey('var_default', $res, "The result does not contains 'var_default' as key"); + $this->assertArrayHasKey('var_accepted_values', $res, "The result does not contains 'var_accepted_values' as key"); + $this->assertArrayHasKey('inp_doc_uid', $res, "The result does not contains 'inp_doc_uid' as key"); + } + + /** + * Tests the exception + * + * @covers \ProcessMaker\BusinessModel\Variable::create() + * @test + */ + public function it_return_an_exception_when_var_name_is_empty() + { + $process = factory(Process::class)->create(); + factory(ProcessVariables::class)->create([ + 'PRJ_UID' => $process->PRO_UID, + 'PRO_ID' => $process->PRO_ID, + ] + ); + $properties = [ + 'VAR_UID' => G::generateUniqueID(), + 'VAR_NAME' => '', + 'VAR_FIELD_TYPE' => 'string', + 'VAR_FIELD_SIZE' => 10, + 'VAR_LABEL' => 'string', + 'VAR_DBCONNECTION' => '', + 'VAR_SQL' => '', + 'VAR_NULL' => 0, + 'VAR_DEFAULT' => '', + 'VAR_ACCEPTED_VALUES' => '[]', + 'INP_DOC_UID' => '' + ]; + $variable = new Variable(); + $this->expectExceptionMessage("**ID_CAN_NOT_BE_NULL**"); + $res = $variable->create($process->PRO_UID, $properties); + } + + /** + * Tests the exception + * + * @covers \ProcessMaker\BusinessModel\Variable::create() + * @test + */ + public function it_return_an_exception_when_var_field_type_is_empty() + { + $process = factory(Process::class)->create(); + factory(ProcessVariables::class)->create([ + 'PRJ_UID' => $process->PRO_UID, + 'PRO_ID' => $process->PRO_ID, + ] + ); + $properties = [ + 'VAR_UID' => G::generateUniqueID(), + 'VAR_NAME' => 'var_test', + 'VAR_FIELD_TYPE' => '', + 'VAR_FIELD_SIZE' => 10, + 'VAR_LABEL' => 'string', + 'VAR_DBCONNECTION' => '', + 'VAR_SQL' => '', + 'VAR_NULL' => 0, + 'VAR_DEFAULT' => '', + 'VAR_ACCEPTED_VALUES' => '[]', + 'INP_DOC_UID' => '' + ]; + $variable = new Variable(); + $this->expectExceptionMessage("**ID_CAN_NOT_BE_NULL**"); + $res = $variable->create($process->PRO_UID, $properties); + } + + /** + * Tests the exception + * + * @covers \ProcessMaker\BusinessModel\Variable::create() + * @test + */ + public function it_return_an_exception_when_var_label_is_empty() + { + $process = factory(Process::class)->create(); + factory(ProcessVariables::class)->create([ + 'PRJ_UID' => $process->PRO_UID, + 'PRO_ID' => $process->PRO_ID, + ] + ); + $properties = [ + 'VAR_UID' => G::generateUniqueID(), + 'VAR_NAME' => 'var_test', + 'VAR_FIELD_TYPE' => 'string', + 'VAR_FIELD_SIZE' => 10, + 'VAR_LABEL' => '', + 'VAR_DBCONNECTION' => '', + 'VAR_SQL' => '', + 'VAR_NULL' => 0, + 'VAR_DEFAULT' => '', + 'VAR_ACCEPTED_VALUES' => '[]', + 'INP_DOC_UID' => '' + ]; + $variable = new Variable(); + $this->expectExceptionMessage("**ID_CAN_NOT_BE_NULL**"); + $res = $variable->create($process->PRO_UID, $properties); + } + + /** + * Test it return the variables related to the PRO_UID + * + * @covers \ProcessMaker\BusinessModel\Variable::getVariables() + * @test + */ + public function it_list_variables_by_process() + { + $process = factory(Process::class)->create(); + + factory(ProcessVariables::class)->create([ + 'PRJ_UID' => $process->PRO_UID, + 'PRO_ID' => $process->PRO_ID, + ] + ); + $variable = new Variable(); + $res = $variable->getVariables($process->PRO_UID); + $this->assertNotEmpty($res); + $res = head($res); + $this->assertArrayHasKey('var_uid', $res, "The result does not contains 'var_uid' as key"); + $this->assertArrayHasKey('prj_uid', $res, "The result does not contains 'prj_uid' as key"); + $this->assertArrayHasKey('var_name', $res, "The result does not contains 'var_name' as key"); + $this->assertArrayHasKey('var_field_type', $res, "The result does not contains 'var_field_type' as key"); + $this->assertArrayHasKey('var_field_size', $res, "The result does not contains 'var_field_size' as key"); + $this->assertArrayHasKey('var_label', $res, "The result does not contains 'var_label' as key"); + $this->assertArrayHasKey('var_dbconnection', $res, "The result does not contains 'var_dbconnection' as key"); + $this->assertArrayHasKey('var_dbconnection_label', $res, "The result does not contains 'var_dbconnection_label' as key"); + $this->assertArrayHasKey('var_sql', $res, "The result does not contains 'var_sql' as key"); + $this->assertArrayHasKey('var_null', $res, "The result does not contains 'var_null' as key"); + $this->assertArrayHasKey('var_default', $res, "The result does not contains 'var_default' as key"); + $this->assertArrayHasKey('var_accepted_values', $res, "The result does not contains 'var_accepted_values' as key"); + $this->assertArrayHasKey('inp_doc_uid', $res, "The result does not contains 'inp_doc_uid' as key"); + } +} diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Core/SystemTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Core/SystemTest.php index 5065344e9..56d03ba37 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Core/SystemTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Core/SystemTest.php @@ -237,4 +237,54 @@ class SystemTest extends TestCase // Restore content of th env.ini file file_put_contents($path, $oldContent); } + + /** + * This represents a set of connection strings that make up the dsn string. + * https://processmaker.atlassian.net/browse/PMCORE-574 + * @return array + */ + public function dsnConections() + { + return [ + ["oci8", "user1", "das#4dba", "localhost", "1521", "testDatabase?encoding=utf8"], + ["mssql", "user1", "Sample12345!@#", "localhost", "1433", "testDatabase?encoding=utf8"], + ["mysqli", "user1", "123*/.abc-+", "localhost", "3306", "testDatabase?encoding=utf8"], + ["mysqli", "user1", "123*/.abc-+", "localhost", "", "testDatabase?encoding=utf8"], + ["sqlite", "user1", "das#4dba", "localhost", "", "testDatabase?encoding=utf8"], + ["sybase", "user1", "123!das#4dba", "localhost", "1433", "testDatabase?encoding=utf8"], + ["sybase", "user1", "123!das@#4dba", "localhost", "1433", "testDatabase?encoding=utf8"], + ["sybase", "user1", "123!das@#4db@a", "localhost", "1433", "testDatabase?encoding=utf8"], + ]; + } + + /** + * This tests the parsing of the dsn string. + * @test + * @dataProvider dsnConections + * @covers \Creole::parseDSN() + * @covers \ProcessMaker\Core\System::parseUrlWithNotEncodedPassword() + */ + public function it_should_return_parse_url_for_dsn_string_with_special_characters($scheme, $user, $password, $host, $port, $database) + { + $hostname = $host; + if (!empty($port)) { + $hostname = $host . ":" . $port; + } + $dsn = $scheme . "://" . $user . ":" . $password . "@" . $hostname . "/" . $database; + $result = System::parseUrlWithNotEncodedPassword($dsn); + $this->assertEquals($scheme, $result["scheme"]); + $this->assertEquals($user, $result["user"]); + $this->assertEquals($password, $result["pass"]); + $this->assertEquals($host, $result["host"]); + if (!empty($port)) { + $this->assertEquals($port, $result["port"]); + } + + $dsn = $scheme; + $result = System::parseUrlWithNotEncodedPassword($dsn); + $this->assertEmpty($result["scheme"]); + $this->assertEmpty($result["user"]); + $this->assertEmpty($result["pass"]); + $this->assertEmpty($result["host"]); + } } diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Importer/XmlImporterTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Importer/XmlImporterTest.php index 1cf6ae13a..dda3d3677 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Importer/XmlImporterTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Importer/XmlImporterTest.php @@ -233,7 +233,7 @@ class XmlImporterTest extends TestCase * Test the import new option and the import new group option with repeated title. * @test * @covers \ProcessMaker\Importer\XmlImporter::import() - * @covers \ProcessMaker\Importer\XmlImporter::updateTheProcessOwner() + * @covers \ProcessMaker\Importer\XmlImporter::updateProcessInformation() */ public function it_should_matter_with_import_option_create_new_and_group_import_option_create_new_try_rename_title() { diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Model/ProcessVariablesTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Model/ProcessVariablesTest.php index b5da806a9..ee2b26edc 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Model/ProcessVariablesTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Model/ProcessVariablesTest.php @@ -6,6 +6,9 @@ use ProcessMaker\Model\Process; use ProcessMaker\Model\ProcessVariables; use Tests\TestCase; +/** + * @coversDefaultClass ProcessMaker\Model\ProcessVariables + */ class ProcessVariablesTest extends TestCase { /** @@ -48,4 +51,23 @@ class ProcessVariablesTest extends TestCase $this->assertEquals($process[0]['PRO_UID'], $result[0]['PRJ_UID']); $this->assertEquals($process[0]['PRO_UID'], $result[1]['PRJ_UID']); } + + /** + * Test it return the variables related to the PRO_ID + * + * @covers \ProcessMaker\Model\ProcessVariables::getVariables() + * @test + */ + public function it_list_variables_by_process() + { + $process = factory(Process::class)->create(); + + factory(ProcessVariables::class)->create([ + 'PRJ_UID' => $process->PRO_UID, + 'PRO_ID' => $process->PRO_ID, + ] + ); + $result = ProcessVariables::getVariables($process->PRO_ID); + $this->assertNotEmpty($result); + } } \ No newline at end of file diff --git a/thirdparty/creole/Creole.php b/thirdparty/creole/Creole.php index 72b5e1683..c3ffd7ea2 100644 --- a/thirdparty/creole/Creole.php +++ b/thirdparty/creole/Creole.php @@ -28,6 +28,8 @@ include_once 'creole/Connection.php'; @ini_set('track_errors', true); + use ProcessMaker\Core\System; + /** * This is the class that manages the database drivers. * @@ -309,6 +311,10 @@ class Creole { ); $info = parse_url($dsn); + if ($info === false) { + $info = System::parseUrlWithNotEncodedPassword($dsn); + } + $info['pass'] = urldecode($info['pass']); if (count($info) === 1) { // if there's only one element in result, then it must be the phptype $parsed['phptype'] = array_pop($info); diff --git a/thirdparty/phing/Phing.php b/thirdparty/phing/Phing.php index ca9ca7fd6..a44c4cfd8 100644 --- a/thirdparty/phing/Phing.php +++ b/thirdparty/phing/Phing.php @@ -1111,12 +1111,6 @@ class Phing { ini_set('default_charset', 'iso-8859-1'); ini_set('register_globals', 'off'); ini_set('allow_call_time_pass_reference', 'on'); - - // should return memory limit in MB - $mem_limit = (int) ini_get('memory_limit'); - if ($mem_limit < 32) { - ini_set('memory_limit', '32M'); // nore: this may need to be higher for many projects - } } /** diff --git a/workflow/engine/PmBootstrap.php b/workflow/engine/PmBootstrap.php index 4745282c4..4f38b2eec 100644 --- a/workflow/engine/PmBootstrap.php +++ b/workflow/engine/PmBootstrap.php @@ -36,7 +36,6 @@ class PmBootstrap extends Bootstrap ini_set('error_reporting', $e_all); ini_set('short_open_tag', 'On'); ini_set('default_charset', "UTF-8"); - ini_set('memory_limit', $this->pmConfig['memory_limit']); ini_set('soap.wsdl_cache_enabled', $this->pmConfig['wsdl_cache']); ini_set('date.timezone', (isset($_SESSION['__SYSTEM_UTC_TIME_ZONE__']) && $_SESSION['__SYSTEM_UTC_TIME_ZONE__'])? 'UTC' : $this->pmConfig['time_zone']); //Set Time Zone diff --git a/workflow/engine/bin/cron.php b/workflow/engine/bin/cron.php index 5aa50b485..7b552d923 100644 --- a/workflow/engine/bin/cron.php +++ b/workflow/engine/bin/cron.php @@ -101,7 +101,6 @@ try { ini_set('error_reporting', $e_all); ini_set('short_open_tag', 'On'); ini_set('default_charset', 'UTF-8'); - ini_set('memory_limit', $arraySystemConfiguration['memory_limit']); ini_set('soap.wsdl_cache_enabled', $arraySystemConfiguration['wsdl_cache']); ini_set('date.timezone', $systemUtcTimeZone ? 'UTC' : $arraySystemConfiguration['time_zone']); diff --git a/workflow/engine/bin/cron_single.php b/workflow/engine/bin/cron_single.php index 2306f622a..83c5fa260 100644 --- a/workflow/engine/bin/cron_single.php +++ b/workflow/engine/bin/cron_single.php @@ -95,7 +95,6 @@ try { restore_error_handler(); // Do not change any of these settings directly, use env.ini instead - ini_set('memory_limit', $arraySystemConfiguration['memory_limit']); ini_set('display_errors', $arraySystemConfiguration['debug']); ini_set('error_reporting', $e_all); ini_set('short_open_tag', 'On'); diff --git a/workflow/engine/bin/reindex_solr.php b/workflow/engine/bin/reindex_solr.php index 67fe269d2..74f255211 100644 --- a/workflow/engine/bin/reindex_solr.php +++ b/workflow/engine/bin/reindex_solr.php @@ -87,8 +87,6 @@ if(count ($argv) > 3) { $debug = 1; ini_set ('display_errors', 1); -//error_reporting (E_ALL); -ini_set ('memory_limit', '256M'); // set enough memory for the script $e_all = defined( 'E_DEPRECATED' ) ? E_ALL & ~ E_DEPRECATED : E_ALL; $e_all = defined( 'E_STRICT' ) ? $e_all & ~ E_STRICT : $e_all; diff --git a/workflow/engine/bin/verify_solr.php b/workflow/engine/bin/verify_solr.php index 043a8a3e8..6223b15d8 100644 --- a/workflow/engine/bin/verify_solr.php +++ b/workflow/engine/bin/verify_solr.php @@ -52,8 +52,6 @@ $debug = 1;//enable o disable notice, this mechanism is inherited from '/process ini_set ('display_errors', 1); -ini_set ('memory_limit', '256M'); // set enough memory for the script - $e_all = defined( 'E_DEPRECATED' ) ? E_ALL & ~ E_DEPRECATED : E_ALL; $e_all = defined( 'E_STRICT' ) ? $e_all & ~ E_STRICT : $e_all; $e_all = $debug ? $e_all : $e_all & ~ E_NOTICE; diff --git a/workflow/engine/classes/ActionsByEmailCoreClass.php b/workflow/engine/classes/ActionsByEmailCoreClass.php index e3e579735..6c17e0266 100644 --- a/workflow/engine/classes/ActionsByEmailCoreClass.php +++ b/workflow/engine/classes/ActionsByEmailCoreClass.php @@ -437,18 +437,6 @@ class ActionsByEmailCoreClass extends PMPlugin return $emailSetup; } - /** - * Define the properties in the task related the action by email configuration - * - * @return void - */ - private function defineTaskAbeProperties() - { - $actionEmailTable = new AbeConfiguration(); - $properties = $actionEmailTable->getTaskConfiguration($this->getCasePropertiesKey('PRO_UID'), $this->getTask()); - $this->setTaskAbeProperties($properties); - } - /** * Define the email from * @@ -623,79 +611,94 @@ class ActionsByEmailCoreClass extends PMPlugin self::validateAndSetValues($data); $emailServerSetup = $this->getEmailServer($dataAbe['ABE_EMAIL_SERVER_UID']); - if (!empty($emailServerSetup)) { - $cases = new Cases(); - $caseFields = $cases->loadCase($this->getAppUid(), $this->getIndex()); - $this->setCaseProperties($caseFields); - $this->defineTaskAbeProperties(); - $caseFields['APP_DATA']['PRO_ID'] = $this->getItemAbeProperties('PRO_ID'); - $caseFields['APP_DATA']['TAS_ID'] = $this->getItemAbeProperties('TAS_ID'); - if (!empty($this->getTaskAbeProperties())) { - $this->defineEmailTo($this->getItemAbeProperties('ABE_EMAIL_FIELD'), $caseFields['APP_DATA']); - - if (!empty($this->getEmailTo())) { - $this->defineSubject($this->getItemAbeProperties('ABE_SUBJECT_FIELD'), $caseFields['APP_DATA']); - - $request = [ - 'ABE_REQ_UID' => '', - 'ABE_UID' => $this->getItemAbeProperties('ABE_UID'), - 'APP_UID' => $this->getAppUid(), - 'DEL_INDEX' => $this->getIndex(), - 'ABE_REQ_SENT_TO' => $this->getEmailTo(), - 'ABE_REQ_SUBJECT' => $this->getSubject(), - 'ABE_REQ_BODY' => '', - 'ABE_REQ_ANSWERED' => 0, - 'ABE_REQ_STATUS' => 'PENDING' - ]; - $this->setAbeRequest($request); - $this->registerRequest(); - - if (!empty($this->getItemAbeProperties('ABE_TYPE'))) { - // Email - $_SESSION['CURRENT_DYN_UID'] = $this->getItemAbeProperties('DYN_UID'); - $__ABE__ = ''; - - switch ($this->getItemAbeProperties('ABE_TYPE')) { - case 'CUSTOM': - $__ABE__ .= $this->getCustomTemplate(); - break; - case 'RESPONSE': - $this->defineReplyTo($dataAbe['ABE_EMAIL_SERVER_RECEIVER_UID']); - $__ABE__ .= $this->getResponseTemplate(); - break; - case 'LINK': - $__ABE__ .= $this->getServicePathTemplate(); - break; - case 'FIELD': - $__ABE__ .= $this->getFieldTemplate(); - break; - } - $__ABE__ = preg_replace('/\/', '', $__ABE__); - $__ABE__ = preg_replace('/\]*\/>/', '', $__ABE__); - $__ABE__ = preg_replace('/]*>(.*?)<\/select>/is', "", $__ABE__); - $__ABE__ = preg_replace('/align=\"center\"/', '', $__ABE__); - $__ABE__ = preg_replace('/class="tableGrid_view" /', 'class="tableGrid_view" width="100%" ', - $__ABE__); - $caseFields['APP_DATA']['__ABE__'] = $__ABE__; - - $this->defineEmailFrom($emailServerSetup); - $result = $this->abeSendMessage( - $this->getItemAbeProperties('ABE_TEMPLATE'), - $caseFields['APP_DATA'], - $emailServerSetup - ); - $request = []; - $request['ABE_REQ_STATUS'] = ($result->status_code == 0 ? 'SENT' : 'ERROR'); - - $request['ABE_REQ_BODY'] = empty($result->getAppMessUid()) ? '' : AppMessage::getAppMsgBodyByKey($result->getAppMessUid()); - $this->addItemAbeRequest($request); - $this->registerRequest(); - } - } - } else { - throw new Exception('Task does not have an action by email configuration.'); - } + if (empty($emailServerSetup)) { + return; } + + $cases = new Cases(); + $caseFields = $cases->loadCase($this->getAppUid(), $this->getIndex()); + $this->setCaseProperties($caseFields); + + $actionEmailTable = new AbeConfiguration(); + $properties = $actionEmailTable->getTaskConfiguration($this->getCasePropertiesKey('PRO_UID'), $this->getTask()); + if (empty($properties)) { + throw new Exception('Task does not have an action by email configuration.'); + } + $this->setTaskAbeProperties($properties); + + $caseFields['APP_DATA']['PRO_ID'] = $this->getItemAbeProperties('PRO_ID'); + $caseFields['APP_DATA']['TAS_ID'] = $this->getItemAbeProperties('TAS_ID'); + + $this->defineEmailTo($this->getItemAbeProperties('ABE_EMAIL_FIELD'), $caseFields['APP_DATA']); + if (empty($this->getEmailTo())) { + return; + } + + $this->defineSubject($this->getItemAbeProperties('ABE_SUBJECT_FIELD'), $caseFields['APP_DATA']); + + $request = [ + 'ABE_REQ_UID' => '', + 'ABE_UID' => $this->getItemAbeProperties('ABE_UID'), + 'APP_UID' => $this->getAppUid(), + 'DEL_INDEX' => $this->getIndex(), + 'ABE_REQ_SENT_TO' => $this->getEmailTo(), + 'ABE_REQ_SUBJECT' => $this->getSubject(), + 'ABE_REQ_BODY' => '', + 'ABE_REQ_ANSWERED' => 0, + 'ABE_REQ_STATUS' => 'PENDING' + ]; + $this->setAbeRequest($request); + $this->registerRequest(); + + if (empty($this->getItemAbeProperties('ABE_TYPE'))) { + return; + } + // Email + $_SESSION['CURRENT_DYN_UID'] = $this->getItemAbeProperties('DYN_UID'); + + $__ABE__ = ''; + switch ($this->getItemAbeProperties('ABE_TYPE')) { + case 'CUSTOM': + $__ABE__ .= $this->getCustomTemplate(); + break; + case 'RESPONSE': + $this->defineReplyTo($dataAbe['ABE_EMAIL_SERVER_RECEIVER_UID']); + $__ABE__ .= $this->getResponseTemplate(); + break; + case 'LINK': + $__ABE__ .= $this->getServicePathTemplate(); + break; + case 'FIELD': + $__ABE__ .= $this->getFieldTemplate(); + break; + } + $__ABE__ = preg_replace('/\/', '', $__ABE__); + $__ABE__ = preg_replace('/\]*\/>/', '', $__ABE__); + $__ABE__ = preg_replace('/]*>(.*?)<\/select>/is', "", $__ABE__); + $__ABE__ = preg_replace('/align=\"center\"/', '', $__ABE__); + $__ABE__ = preg_replace('/class="tableGrid_view" /', 'class="tableGrid_view" width="100%" ', $__ABE__); + + $caseFields['APP_DATA']['__ABE__'] = $__ABE__; + + $this->defineEmailFrom($emailServerSetup); + + $params = [ + $this->getItemAbeProperties('ABE_TEMPLATE'), + $caseFields['APP_DATA'], + $emailServerSetup + ]; + $result = $this->abeSendMessage(...$params); + + $request = [ + 'ABE_REQ_STATUS' => $result->status_code == 0 ? 'SENT' : 'ERROR', + 'ABE_REQ_BODY' => '', + ]; + if (!empty($result->getExtraParam('AppMessUid'))) { + $request['ABE_REQ_BODY'] = AppMessage::getAppMsgBodyByKey($result->getExtraParam('AppMessUid')); + } + + $this->addItemAbeRequest($request); + $this->registerRequest(); } catch (Exception $error) { throw $error; } diff --git a/workflow/engine/classes/DbConnections.php b/workflow/engine/classes/DbConnections.php index 784d97230..002b1deb2 100644 --- a/workflow/engine/classes/DbConnections.php +++ b/workflow/engine/classes/DbConnections.php @@ -206,6 +206,7 @@ class DbConnections }); foreach ($externalDbs as $externalDb) { $conf['datasources'][$externalDb->DBS_UID] = []; + $laravelConfig = []; $flagTns = ($externalDb->DBS_TYPE == "oracle" && $externalDb->DBS_CONNECTION_TYPE == "TNS")? 1 : 0; // Build the appropriate items to add to our Propel configuration // Let's grab the decrypted password @@ -235,12 +236,26 @@ class DbConnections . $externalDb->DBS_USERNAME . ':' . $passw . '@' . $externalDb->DBS_SERVER . $dbsPort . '/' . $externalDb->DBS_DATABASE_NAME . $encoding; } + $laravelConfig = [ + 'driver' => $externalDb->DBS_TYPE === 'mssql' ? 'sqlsrv' : $externalDb->DBS_TYPE, // MSSQL driver is not supported anymore, only SQLSRV + 'host' => $externalDb->DBS_SERVER, + 'port' => $externalDb->DBS_PORT == '' ? null : $externalDb->DBS_PORT, + 'database' => $externalDb->DBS_DATABASE_NAME, + 'username' => $externalDb->DBS_USERNAME, + 'password' => $passw, + 'charset' => trim($externalDb->DBS_ENCODE) == '' ? null : trim($externalDb->DBS_ENCODE), + 'options' => [PDO::ATTR_STRINGIFY_FETCHES => true] // For keep the old behaviour, all values are transformed to strings + ]; } else { // Is oracle and TNS, let's provide a TNS based DSN $conf["datasources"][$externalDb->DBS_UID]["connection"] = $externalDb->DBS_TYPE . "://" . $externalDb->DBS_USERNAME . ":" . $passw . "@" . $externalDb->DBS_TNS; } $conf['datasources'][$externalDb->DBS_UID]['adapter'] = $externalDb->DBS_TYPE; + // Load the config for the external database into laravel + config([ + 'database.connections.' . $externalDb->DBS_UID => $laravelConfig + ]); } Propel::initConfiguration($conf); $lastProcessId = $_SESSION['PROCESS']; diff --git a/workflow/engine/classes/PmDynaform.php b/workflow/engine/classes/PmDynaform.php index 48e4354f9..ab1c263fb 100644 --- a/workflow/engine/classes/PmDynaform.php +++ b/workflow/engine/classes/PmDynaform.php @@ -1741,8 +1741,7 @@ class PmDynaform return false; } foreach ($result as $row) { - $dynaform = new PmDynaform(["CURRENT_DYNAFORM" => $row->DYN_UID]); - $json = G::json_decode($dynaform->record["DYN_CONTENT"]); + $json = G::json_decode($row->DYN_CONTENT); if ($this->jsoni($json, $variable)) { return $row->DYN_UID; } diff --git a/workflow/engine/classes/Processes.php b/workflow/engine/classes/Processes.php index 1c928ed61..9807cc72e 100644 --- a/workflow/engine/classes/Processes.php +++ b/workflow/engine/classes/Processes.php @@ -1,6 +1,7 @@ add(ProcessVariablesPeer::VAR_UID, $row['VAR_UID']); $criteria->add(ProcessVariablesPeer::PRJ_UID, $row['PRJ_UID']); + // Load the PRO_ID + $process = new Process(); + if ($process->processExists($row['PRJ_UID'])) { + $processRow = $process->load($row['PRJ_UID']); + $row['PRO_ID'] = $processRow['PRO_ID']; + if (!empty($row['PRO_ID'])) { + $criteria->add(ProcessVariablesPeer::PRO_ID, $row['PRO_ID']); + } + } $criteria->add(ProcessVariablesPeer::VAR_NAME, $row['VAR_NAME']); $criteria->add(ProcessVariablesPeer::VAR_FIELD_TYPE, $row['VAR_FIELD_TYPE']); + if (empty($row['VAR_FIELD_TYPE_ID'])) { + $row['VAR_FIELD_TYPE_ID'] = BmVariable::$varTypesValues[$row["VAR_FIELD_TYPE"]]; + } + $criteria->add(ProcessVariablesPeer::VAR_FIELD_TYPE_ID, $row['VAR_FIELD_TYPE_ID']); $criteria->add(ProcessVariablesPeer::VAR_FIELD_SIZE, $row['VAR_FIELD_SIZE']); $criteria->add(ProcessVariablesPeer::VAR_LABEL, $row['VAR_LABEL']); $criteria->add(ProcessVariablesPeer::VAR_DBCONNECTION, $row['VAR_DBCONNECTION']); @@ -3609,6 +3623,8 @@ class Processes $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { + unset($aRow['VAR_ID']); + unset($aRow['PRO_ID']); $aVars[] = $aRow; $oDataset->next(); } diff --git a/workflow/engine/classes/WorkspaceTools.php b/workflow/engine/classes/WorkspaceTools.php index 24112d1dd..4b0c9049f 100644 --- a/workflow/engine/classes/WorkspaceTools.php +++ b/workflow/engine/classes/WorkspaceTools.php @@ -4260,6 +4260,57 @@ class WorkspaceTools $con->commit(); CLI::logging("-> Populating APP_ASSIGN_SELF_SERVICE_VALUE.TAS_ID Done \n"); + // Populating PROCESS_VARIABLES.PRO_ID + CLI::logging("-> Populating PROCESS_VARIABLES.PRO_ID \n"); + $con->begin(); + $stmt = $con->createStatement(); + $rs = $stmt->executeQuery("UPDATE PROCESS_VARIABLES AS PV + INNER JOIN ( + SELECT PROCESS.PRO_UID, PROCESS.PRO_ID + FROM PROCESS + ) AS PRO + ON (PV.PRJ_UID = PRO.PRO_UID) + SET PV.PRO_ID = PRO.PRO_ID + WHERE PV.PRO_ID = 0"); + $con->commit(); + CLI::logging("-> Populating PROCESS_VARIABLES.PRO_ID Done \n"); + + // Populating PROCESS_VARIABLES.VAR_FIELD_TYPE_ID + CLI::logging("-> Populating PROCESS_VARIABLES.VAR_FIELD_TYPE_ID \n"); + $con->begin(); + $stmt = $con->createStatement(); + $rs = $stmt->executeQuery("UPDATE PROCESS_VARIABLES + SET VAR_FIELD_TYPE_ID = (case + when VAR_FIELD_TYPE = 'string' then 1 + when VAR_FIELD_TYPE = 'integer' then 2 + when VAR_FIELD_TYPE = 'float' then 3 + when VAR_FIELD_TYPE = 'boolean' then 4 + when VAR_FIELD_TYPE = 'datetime' then 5 + when VAR_FIELD_TYPE = 'grid' then 6 + when VAR_FIELD_TYPE = 'array' then 7 + when VAR_FIELD_TYPE = 'file' then 8 + when VAR_FIELD_TYPE = 'multiplefile' then 9 + when VAR_FIELD_TYPE = 'object' then 10 + end) + WHERE VAR_FIELD_TYPE_ID = 0"); + $con->commit(); + CLI::logging("-> Populating PROCESS_VARIABLES.VAR_FIELD_TYPE_ID Done \n"); + + // Populating DB_SOURCE.PRO_ID + CLI::logging("-> Populating DB_SOURCE.PRO_ID \n"); + $con->begin(); + $stmt = $con->createStatement(); + $rs = $stmt->executeQuery("UPDATE DB_SOURCE AS DS + INNER JOIN ( + SELECT PROCESS.PRO_UID, PROCESS.PRO_ID + FROM PROCESS + ) AS PRO + ON (DS.PRO_UID = PRO.PRO_UID) + SET DS.PRO_ID = PRO.PRO_ID + WHERE DS.PRO_ID = 0"); + $con->commit(); + CLI::logging("-> Populating DB_SOURCE.PRO_ID Done \n"); + //Complete all migrations CLI::logging("-> Migrating And Populating Indexing for avoiding the use of table APP_CACHE_VIEW Done \n"); } diff --git a/workflow/engine/classes/WsBase.php b/workflow/engine/classes/WsBase.php index ef1bb9352..7e3653b33 100644 --- a/workflow/engine/classes/WsBase.php +++ b/workflow/engine/classes/WsBase.php @@ -9,7 +9,6 @@ use ProcessMaker\ChangeLog\ChangeLog; use ProcessMaker\Core\JobsManager; use ProcessMaker\Core\System; use ProcessMaker\Model\Delegation; -use ProcessMaker\Util\WsMessageResponse; class WsBase { @@ -911,6 +910,7 @@ class WsBase ) { try { + $setup = []; /*----------------------------------********---------------------------------*/ if (!empty($config)) { @@ -973,9 +973,7 @@ class WsBase if (!file_exists($fileTemplate)) { $data['FILE_TEMPLATE'] = $fileTemplate; - $result = new WsResponse(28, G::LoadTranslation('ID_TEMPLATE_FILE_NOT_EXIST', SYS_LANG, $data)); - - return $result; + return new WsResponse(28, G::LoadTranslation('ID_TEMPLATE_FILE_NOT_EXIST', SYS_LANG, $data)); } if ($appFields == null) { @@ -1003,45 +1001,46 @@ class WsBase (preg_match("/^.+\.html?$/i", $fileTemplate)) ? true : false, isset($fieldsCase['APP_NUMBER']) ? $fieldsCase['APP_NUMBER'] : 0, isset($fieldsCase['PRO_ID']) ? $fieldsCase['PRO_ID'] : 0, - $this->getTaskId() ?$this->getTaskId():(isset($oldFields['TAS_ID'])? $oldFields['TAS_ID'] : 0) + $this->getTaskId() ? $this->getTaskId() : (isset($oldFields['TAS_ID']) ? $oldFields['TAS_ID'] : 0) ); - $result = ""; - if ($gmail != 1) { - // Create always the record in APP_MESSAGE table + if ($gmail === 1) { + return new WsResponse(0, G::loadTranslation('ID_PMGMAIL')); + } + + // Create always the record in APP_MESSAGE table + $spool = new SpoolRun(); + $spool->setConfig($setup); + $spool->create($messageArray); + + // Get the data of the record created + $fileData = $spool->getFileData(); + $fileData['spoolId'] = $spool->getSpoolId(); + + // Create the closure and send the required data + $closure = function() use ($setup, $fileData, $gmail, $to) { $spool = new SpoolRun(); $spool->setConfig($setup); - $spool->create($messageArray); - - // Get the data of the record created - $fileData = $spool->getFileData(); - $fileData['spoolId'] = $spool->getSpoolId(); - - // Create the closure and send the required data - $closure = function() use ($setup, $fileData, $gmail, $to) { - $spool = new SpoolRun(); - $spool->setConfig($setup); - $spool->setSpoolId($fileData['spoolId']); - $spool->setFileData($fileData); - $spool->sendMail(); - return $spool; - }; - $result = new WsMessageResponse(0, G::loadTranslation('ID_MESSAGE_SENT') . ": " . $to); - switch ($appMsgType) { - case WsBase::MESSAGE_TYPE_EMAIL_EVENT: - case WsBase::MESSAGE_TYPE_PM_FUNCTION: - JobsManager::getSingleton()->dispatch(EmailEvent::class, $closure); - break; - default : - $spool = $closure(); - if ($spool->status == 'sent') { - $result = new WsMessageResponse(0, G::loadTranslation('ID_MESSAGE_SENT') . ": " . $to); - $result->setAppMessUid($spool->getSpoolId()); - } else { - $result = new WsResponse(29, $spool->status . ' ' . $spool->error . PHP_EOL . print_r($setup, 1)); - } - break; - } + $spool->setSpoolId($fileData['spoolId']); + $spool->setFileData($fileData); + $spool->sendMail(); + return $spool; + }; + switch ($appMsgType) { + case WsBase::MESSAGE_TYPE_EMAIL_EVENT: + case WsBase::MESSAGE_TYPE_PM_FUNCTION: + JobsManager::getSingleton()->dispatch(EmailEvent::class, $closure); + $result = new WsResponse(0, G::loadTranslation('ID_MESSAGE_SENT') . ": " . $to); + break; + default : + $spool = $closure(); + if ($spool->status == 'sent') { + $result = new WsResponse(0, G::loadTranslation('ID_MESSAGE_SENT') . ": " . $to); + $result->addExtraParam('AppMessUid', $spool->getSpoolId()); + } else { + $result = new WsResponse(29, $spool->status . ' ' . $spool->error . PHP_EOL . print_r($setup, 1)); + } + break; } return $result; } catch (Exception $e) { diff --git a/workflow/engine/classes/WsResponse.php b/workflow/engine/classes/WsResponse.php index 70add2778..67d9aba30 100644 --- a/workflow/engine/classes/WsResponse.php +++ b/workflow/engine/classes/WsResponse.php @@ -43,10 +43,11 @@ class WsResponse * 36 ID_CASE_COULD_NOT_REASSIGNED * * 100 Exception - */ + */ public $status_code = 0; public $message = ''; public $timestamp = ''; + private $extraParams = []; /** * Function __construct @@ -56,11 +57,31 @@ class WsResponse * @param string $message * @return void */ - function __construct ($status, $message) + public function __construct($status, $message) { $this->status_code = $status; $this->message = $message; - $this->timestamp = date( 'Y-m-d H:i:s' ); + $this->timestamp = date('Y-m-d H:i:s'); + } + + /** + * Get extra parameters for message response. + * @return mixed + */ + public function getExtraParam(string $name) + { + return isset($this->extraParams[$name]) ? $this->extraParams[$name] : ''; + } + + /** + * Add extra parameters for message response. + * @param string $name + * @param mixed $value + * @return void + */ + public function addExtraParam(string $name, $value): void + { + $this->extraParams[$name] = $value; } /** @@ -69,13 +90,12 @@ class WsResponse * @param string $operation * @return string */ - function getPayloadString ($operation) + public function getPayloadString($operation) { $res = "<$operation>\n"; $res .= "" . $this->status_code . ""; $res .= "" . $this->message . ""; $res .= "" . $this->timestamp . ""; - // $res .= "" . $this->timestamp . ""; $res .= "<$operation>"; return $res; } @@ -85,9 +105,8 @@ class WsResponse * * @return array */ - function getPayloadArray () + public function getPayloadArray() { - return array ("status_code" => $this->status_code,'message' => $this->message,'timestamp' => $this->timestamp - ); + return ["status_code" => $this->status_code, 'message' => $this->message, 'timestamp' => $this->timestamp]; } } diff --git a/workflow/engine/classes/class.pmFunctions.php b/workflow/engine/classes/class.pmFunctions.php index e99854804..857e0246b 100644 --- a/workflow/engine/classes/class.pmFunctions.php +++ b/workflow/engine/classes/class.pmFunctions.php @@ -32,6 +32,7 @@ use ProcessMaker\BusinessModel\Cases as BusinessModelCases; use ProcessMaker\Core\System; use ProcessMaker\Plugins\PluginRegistry; use ProcessMaker\Util\ElementTranslation; +use Illuminate\Support\Facades\DB; /** * ProcessMaker has made a number of its PHP functions available be used in triggers and conditions. @@ -243,8 +244,22 @@ function executeQuery ($SqlStatement, $DBConnectionUID = 'workflow', $aParameter { $sysSys = (!empty(config("system.workspace")))? config("system.workspace") : "Undefined"; $aContext = \Bootstrap::getDefaultContextLog(); - $con = Propel::getConnection( $DBConnectionUID ); - $con->begin(); + + // This means the DBConnectionUID is not loaded yet, so we'll force DbConnections::loadAdditionalConnections + if (is_null(config('database.connections.' . $DBConnectionUID . '.driver'))) { + // Force to load the external connections + DbConnections::loadAdditionalConnections(); + if (config('database.connections.' . $DBConnectionUID . '.driver') !== 'oracle') { + // If the connections drivers are "mysql", "pgsql" or "sqlsrv" we're using Laravel + $con = DB::connection($DBConnectionUID); + $con->beginTransaction(); + } else { + // If the connection driver is "oracle" we're using the native oci8 functions + $con = Propel::getConnection($DBConnectionUID); + $con->begin(); + } + } + $blackList = System::getQueryBlackList(); $listQueries = explode('|', isset($blackList['queries']) ? $blackList['queries'] : ''); $aListAllTables = explode( @@ -299,36 +314,34 @@ function executeQuery ($SqlStatement, $DBConnectionUID = 'workflow', $aParameter $statement = str_replace( '(', '', $statement ); $result = false; - if (getEngineDataBaseName( $con ) != 'oracle') { + + // Check to see if we're not running oracle, which is usually a safe default + if (config('database.connections.' . $DBConnectionUID . '.driver') != 'oracle') { switch (true) { case preg_match( "/^(SELECT|EXECUTE|EXEC|SHOW|DESCRIBE|EXPLAIN|BEGIN)\s/i", $statement ): - $rs = $con->executeQuery( $SqlStatement ); - $result = Array (); - $i = 1; - while ($rs->next()) { - $result[$i ++] = $rs->getRow(); - } - $rs->close(); + $result = $con->select( $SqlStatement ); + + // Convert to 1 index key array of array results + $result = collect($result)->map(function($x) { return (array)$x; })->toArray(); + array_unshift($result, []); + unset($result[0]); + $con->commit(); break; case preg_match( "/^INSERT\s/i", $statement ): - $rs = $con->executeUpdate( $SqlStatement ); - $result = $con->getUpdateCount(); + $result = $con->insert( $SqlStatement ); $con->commit(); break; case preg_match( "/^REPLACE\s/i", $statement ): - $rs = $con->executeUpdate( $SqlStatement ); - $result = $con->getUpdateCount(); + $result = $con->update( $SqlStatement ); $con->commit(); break; case preg_match( "/^UPDATE\s/i", $statement ): - $rs = $con->executeUpdate( $SqlStatement ); - $result = $con->getUpdateCount(); + $result = $con->update( $SqlStatement ); $con->commit(); break; case preg_match( "/^DELETE\s/i", $statement ): - $rs = $con->executeUpdate( $SqlStatement ); - $result = $con->getUpdateCount(); + $result = $con->delete( $SqlStatement ); $con->commit(); break; } @@ -947,9 +960,8 @@ function PMFSendMessage( $delIndex = 0, $config = [] ) { - ini_set ( "pcre.backtrack_limit", 1000000 ); - ini_set ( 'memory_limit', '-1' ); - @set_time_limit ( 100000 ); + ini_set("pcre.backtrack_limit", 1000000); + @set_time_limit(100000); global $oPMScript; diff --git a/workflow/engine/classes/model/map/DbSourceMapBuilder.php b/workflow/engine/classes/model/map/DbSourceMapBuilder.php index 9c739136f..900bef8c4 100644 --- a/workflow/engine/classes/model/map/DbSourceMapBuilder.php +++ b/workflow/engine/classes/model/map/DbSourceMapBuilder.php @@ -63,12 +63,16 @@ class DbSourceMapBuilder $tMap = $this->dbMap->addTable('DB_SOURCE'); $tMap->setPhpName('DbSource'); - $tMap->setUseIdGenerator(false); + $tMap->setUseIdGenerator(true); + + $tMap->addColumn('DBS_ID', 'DbsId', 'int', CreoleTypes::INTEGER, true, null); $tMap->addPrimaryKey('DBS_UID', 'DbsUid', 'string', CreoleTypes::VARCHAR, true, 32); $tMap->addPrimaryKey('PRO_UID', 'ProUid', 'string', CreoleTypes::VARCHAR, true, 32); + $tMap->addColumn('PRO_ID', 'ProId', 'int', CreoleTypes::INTEGER, false, null); + $tMap->addColumn('DBS_TYPE', 'DbsType', 'string', CreoleTypes::VARCHAR, true, 8); $tMap->addColumn('DBS_SERVER', 'DbsServer', 'string', CreoleTypes::VARCHAR, true, 100); diff --git a/workflow/engine/classes/model/map/ProcessVariablesMapBuilder.php b/workflow/engine/classes/model/map/ProcessVariablesMapBuilder.php index 403c0c2dd..a911b5a99 100644 --- a/workflow/engine/classes/model/map/ProcessVariablesMapBuilder.php +++ b/workflow/engine/classes/model/map/ProcessVariablesMapBuilder.php @@ -63,16 +63,22 @@ class ProcessVariablesMapBuilder $tMap = $this->dbMap->addTable('PROCESS_VARIABLES'); $tMap->setPhpName('ProcessVariables'); - $tMap->setUseIdGenerator(false); + $tMap->setUseIdGenerator(true); + + $tMap->addColumn('VAR_ID', 'VarId', 'int', CreoleTypes::INTEGER, true, null); $tMap->addPrimaryKey('VAR_UID', 'VarUid', 'string', CreoleTypes::VARCHAR, true, 32); $tMap->addColumn('PRJ_UID', 'PrjUid', 'string', CreoleTypes::VARCHAR, true, 32); + $tMap->addColumn('PRO_ID', 'ProId', 'int', CreoleTypes::INTEGER, false, null); + $tMap->addColumn('VAR_NAME', 'VarName', 'string', CreoleTypes::VARCHAR, false, 255); $tMap->addColumn('VAR_FIELD_TYPE', 'VarFieldType', 'string', CreoleTypes::VARCHAR, false, 32); + $tMap->addColumn('VAR_FIELD_TYPE_ID', 'VarFieldTypeId', 'int', CreoleTypes::INTEGER, false, null); + $tMap->addColumn('VAR_FIELD_SIZE', 'VarFieldSize', 'int', CreoleTypes::INTEGER, false, null); $tMap->addColumn('VAR_LABEL', 'VarLabel', 'string', CreoleTypes::VARCHAR, false, 255); diff --git a/workflow/engine/classes/model/om/BaseDbSource.php b/workflow/engine/classes/model/om/BaseDbSource.php index b21a8a1f6..199c9b45e 100644 --- a/workflow/engine/classes/model/om/BaseDbSource.php +++ b/workflow/engine/classes/model/om/BaseDbSource.php @@ -27,6 +27,12 @@ abstract class BaseDbSource extends BaseObject implements Persistent */ protected static $peer; + /** + * The value for the dbs_id field. + * @var int + */ + protected $dbs_id; + /** * The value for the dbs_uid field. * @var string @@ -39,6 +45,12 @@ abstract class BaseDbSource extends BaseObject implements Persistent */ protected $pro_uid = '0'; + /** + * The value for the pro_id field. + * @var int + */ + protected $pro_id = 0; + /** * The value for the dbs_type field. * @var string @@ -107,6 +119,17 @@ abstract class BaseDbSource extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Get the [dbs_id] column value. + * + * @return int + */ + public function getDbsId() + { + + return $this->dbs_id; + } + /** * Get the [dbs_uid] column value. * @@ -129,6 +152,17 @@ abstract class BaseDbSource extends BaseObject implements Persistent return $this->pro_uid; } + /** + * Get the [pro_id] column value. + * + * @return int + */ + public function getProId() + { + + return $this->pro_id; + } + /** * Get the [dbs_type] column value. * @@ -228,6 +262,28 @@ abstract class BaseDbSource extends BaseObject implements Persistent return $this->dbs_tns; } + /** + * Set the value of [dbs_id] column. + * + * @param int $v new value + * @return void + */ + public function setDbsId($v) + { + + // Since the native PHP type for this column is integer, + // we will cast the input value to an int (if it is not). + if ($v !== null && !is_int($v) && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->dbs_id !== $v) { + $this->dbs_id = $v; + $this->modifiedColumns[] = DbSourcePeer::DBS_ID; + } + + } // setDbsId() + /** * Set the value of [dbs_uid] column. * @@ -272,6 +328,28 @@ abstract class BaseDbSource extends BaseObject implements Persistent } // setProUid() + /** + * Set the value of [pro_id] column. + * + * @param int $v new value + * @return void + */ + public function setProId($v) + { + + // Since the native PHP type for this column is integer, + // we will cast the input value to an int (if it is not). + if ($v !== null && !is_int($v) && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->pro_id !== $v || $v === 0) { + $this->pro_id = $v; + $this->modifiedColumns[] = DbSourcePeer::PRO_ID; + } + + } // setProId() + /** * Set the value of [dbs_type] column. * @@ -487,34 +565,38 @@ abstract class BaseDbSource extends BaseObject implements Persistent { try { - $this->dbs_uid = $rs->getString($startcol + 0); + $this->dbs_id = $rs->getInt($startcol + 0); - $this->pro_uid = $rs->getString($startcol + 1); + $this->dbs_uid = $rs->getString($startcol + 1); - $this->dbs_type = $rs->getString($startcol + 2); + $this->pro_uid = $rs->getString($startcol + 2); - $this->dbs_server = $rs->getString($startcol + 3); + $this->pro_id = $rs->getInt($startcol + 3); - $this->dbs_database_name = $rs->getString($startcol + 4); + $this->dbs_type = $rs->getString($startcol + 4); - $this->dbs_username = $rs->getString($startcol + 5); + $this->dbs_server = $rs->getString($startcol + 5); - $this->dbs_password = $rs->getString($startcol + 6); + $this->dbs_database_name = $rs->getString($startcol + 6); - $this->dbs_port = $rs->getInt($startcol + 7); + $this->dbs_username = $rs->getString($startcol + 7); - $this->dbs_encode = $rs->getString($startcol + 8); + $this->dbs_password = $rs->getString($startcol + 8); - $this->dbs_connection_type = $rs->getString($startcol + 9); + $this->dbs_port = $rs->getInt($startcol + 9); - $this->dbs_tns = $rs->getString($startcol + 10); + $this->dbs_encode = $rs->getString($startcol + 10); + + $this->dbs_connection_type = $rs->getString($startcol + 11); + + $this->dbs_tns = $rs->getString($startcol + 12); $this->resetModified(); $this->setNew(false); // FIXME - using NUM_COLUMNS may be clearer. - return $startcol + 11; // 11 = DbSourcePeer::NUM_COLUMNS - DbSourcePeer::NUM_LAZY_LOAD_COLUMNS). + return $startcol + 13; // 13 = DbSourcePeer::NUM_COLUMNS - DbSourcePeer::NUM_LAZY_LOAD_COLUMNS). } catch (Exception $e) { throw new PropelException("Error populating DbSource object", $e); @@ -719,36 +801,42 @@ abstract class BaseDbSource extends BaseObject implements Persistent { switch($pos) { case 0: - return $this->getDbsUid(); + return $this->getDbsId(); break; case 1: - return $this->getProUid(); + return $this->getDbsUid(); break; case 2: - return $this->getDbsType(); + return $this->getProUid(); break; case 3: - return $this->getDbsServer(); + return $this->getProId(); break; case 4: - return $this->getDbsDatabaseName(); + return $this->getDbsType(); break; case 5: - return $this->getDbsUsername(); + return $this->getDbsServer(); break; case 6: - return $this->getDbsPassword(); + return $this->getDbsDatabaseName(); break; case 7: - return $this->getDbsPort(); + return $this->getDbsUsername(); break; case 8: - return $this->getDbsEncode(); + return $this->getDbsPassword(); break; case 9: - return $this->getDbsConnectionType(); + return $this->getDbsPort(); break; case 10: + return $this->getDbsEncode(); + break; + case 11: + return $this->getDbsConnectionType(); + break; + case 12: return $this->getDbsTns(); break; default: @@ -771,17 +859,19 @@ abstract class BaseDbSource extends BaseObject implements Persistent { $keys = DbSourcePeer::getFieldNames($keyType); $result = array( - $keys[0] => $this->getDbsUid(), - $keys[1] => $this->getProUid(), - $keys[2] => $this->getDbsType(), - $keys[3] => $this->getDbsServer(), - $keys[4] => $this->getDbsDatabaseName(), - $keys[5] => $this->getDbsUsername(), - $keys[6] => $this->getDbsPassword(), - $keys[7] => $this->getDbsPort(), - $keys[8] => $this->getDbsEncode(), - $keys[9] => $this->getDbsConnectionType(), - $keys[10] => $this->getDbsTns(), + $keys[0] => $this->getDbsId(), + $keys[1] => $this->getDbsUid(), + $keys[2] => $this->getProUid(), + $keys[3] => $this->getProId(), + $keys[4] => $this->getDbsType(), + $keys[5] => $this->getDbsServer(), + $keys[6] => $this->getDbsDatabaseName(), + $keys[7] => $this->getDbsUsername(), + $keys[8] => $this->getDbsPassword(), + $keys[9] => $this->getDbsPort(), + $keys[10] => $this->getDbsEncode(), + $keys[11] => $this->getDbsConnectionType(), + $keys[12] => $this->getDbsTns(), ); return $result; } @@ -814,36 +904,42 @@ abstract class BaseDbSource extends BaseObject implements Persistent { switch($pos) { case 0: - $this->setDbsUid($value); + $this->setDbsId($value); break; case 1: - $this->setProUid($value); + $this->setDbsUid($value); break; case 2: - $this->setDbsType($value); + $this->setProUid($value); break; case 3: - $this->setDbsServer($value); + $this->setProId($value); break; case 4: - $this->setDbsDatabaseName($value); + $this->setDbsType($value); break; case 5: - $this->setDbsUsername($value); + $this->setDbsServer($value); break; case 6: - $this->setDbsPassword($value); + $this->setDbsDatabaseName($value); break; case 7: - $this->setDbsPort($value); + $this->setDbsUsername($value); break; case 8: - $this->setDbsEncode($value); + $this->setDbsPassword($value); break; case 9: - $this->setDbsConnectionType($value); + $this->setDbsPort($value); break; case 10: + $this->setDbsEncode($value); + break; + case 11: + $this->setDbsConnectionType($value); + break; + case 12: $this->setDbsTns($value); break; } // switch() @@ -870,47 +966,55 @@ abstract class BaseDbSource extends BaseObject implements Persistent $keys = DbSourcePeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { - $this->setDbsUid($arr[$keys[0]]); + $this->setDbsId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { - $this->setProUid($arr[$keys[1]]); + $this->setDbsUid($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { - $this->setDbsType($arr[$keys[2]]); + $this->setProUid($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { - $this->setDbsServer($arr[$keys[3]]); + $this->setProId($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { - $this->setDbsDatabaseName($arr[$keys[4]]); + $this->setDbsType($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { - $this->setDbsUsername($arr[$keys[5]]); + $this->setDbsServer($arr[$keys[5]]); } if (array_key_exists($keys[6], $arr)) { - $this->setDbsPassword($arr[$keys[6]]); + $this->setDbsDatabaseName($arr[$keys[6]]); } if (array_key_exists($keys[7], $arr)) { - $this->setDbsPort($arr[$keys[7]]); + $this->setDbsUsername($arr[$keys[7]]); } if (array_key_exists($keys[8], $arr)) { - $this->setDbsEncode($arr[$keys[8]]); + $this->setDbsPassword($arr[$keys[8]]); } if (array_key_exists($keys[9], $arr)) { - $this->setDbsConnectionType($arr[$keys[9]]); + $this->setDbsPort($arr[$keys[9]]); } if (array_key_exists($keys[10], $arr)) { - $this->setDbsTns($arr[$keys[10]]); + $this->setDbsEncode($arr[$keys[10]]); + } + + if (array_key_exists($keys[11], $arr)) { + $this->setDbsConnectionType($arr[$keys[11]]); + } + + if (array_key_exists($keys[12], $arr)) { + $this->setDbsTns($arr[$keys[12]]); } } @@ -924,6 +1028,10 @@ abstract class BaseDbSource extends BaseObject implements Persistent { $criteria = new Criteria(DbSourcePeer::DATABASE_NAME); + if ($this->isColumnModified(DbSourcePeer::DBS_ID)) { + $criteria->add(DbSourcePeer::DBS_ID, $this->dbs_id); + } + if ($this->isColumnModified(DbSourcePeer::DBS_UID)) { $criteria->add(DbSourcePeer::DBS_UID, $this->dbs_uid); } @@ -932,6 +1040,10 @@ abstract class BaseDbSource extends BaseObject implements Persistent $criteria->add(DbSourcePeer::PRO_UID, $this->pro_uid); } + if ($this->isColumnModified(DbSourcePeer::PRO_ID)) { + $criteria->add(DbSourcePeer::PRO_ID, $this->pro_id); + } + if ($this->isColumnModified(DbSourcePeer::DBS_TYPE)) { $criteria->add(DbSourcePeer::DBS_TYPE, $this->dbs_type); } @@ -1034,6 +1146,10 @@ abstract class BaseDbSource extends BaseObject implements Persistent public function copyInto($copyObj, $deepCopy = false) { + $copyObj->setDbsId($this->dbs_id); + + $copyObj->setProId($this->pro_id); + $copyObj->setDbsType($this->dbs_type); $copyObj->setDbsServer($this->dbs_server); diff --git a/workflow/engine/classes/model/om/BaseDbSourcePeer.php b/workflow/engine/classes/model/om/BaseDbSourcePeer.php index fd02370c9..accb8c270 100644 --- a/workflow/engine/classes/model/om/BaseDbSourcePeer.php +++ b/workflow/engine/classes/model/om/BaseDbSourcePeer.php @@ -25,18 +25,24 @@ abstract class BaseDbSourcePeer const CLASS_DEFAULT = 'classes.model.DbSource'; /** The total number of columns. */ - const NUM_COLUMNS = 11; + const NUM_COLUMNS = 13; /** The number of lazy-loaded columns. */ const NUM_LAZY_LOAD_COLUMNS = 0; + /** the column name for the DBS_ID field */ + const DBS_ID = 'DB_SOURCE.DBS_ID'; + /** the column name for the DBS_UID field */ const DBS_UID = 'DB_SOURCE.DBS_UID'; /** the column name for the PRO_UID field */ const PRO_UID = 'DB_SOURCE.PRO_UID'; + /** the column name for the PRO_ID field */ + const PRO_ID = 'DB_SOURCE.PRO_ID'; + /** the column name for the DBS_TYPE field */ const DBS_TYPE = 'DB_SOURCE.DBS_TYPE'; @@ -75,10 +81,10 @@ abstract class BaseDbSourcePeer * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ private static $fieldNames = array ( - BasePeer::TYPE_PHPNAME => array ('DbsUid', 'ProUid', 'DbsType', 'DbsServer', 'DbsDatabaseName', 'DbsUsername', 'DbsPassword', 'DbsPort', 'DbsEncode', 'DbsConnectionType', 'DbsTns', ), - BasePeer::TYPE_COLNAME => array (DbSourcePeer::DBS_UID, DbSourcePeer::PRO_UID, DbSourcePeer::DBS_TYPE, DbSourcePeer::DBS_SERVER, DbSourcePeer::DBS_DATABASE_NAME, DbSourcePeer::DBS_USERNAME, DbSourcePeer::DBS_PASSWORD, DbSourcePeer::DBS_PORT, DbSourcePeer::DBS_ENCODE, DbSourcePeer::DBS_CONNECTION_TYPE, DbSourcePeer::DBS_TNS, ), - BasePeer::TYPE_FIELDNAME => array ('DBS_UID', 'PRO_UID', 'DBS_TYPE', 'DBS_SERVER', 'DBS_DATABASE_NAME', 'DBS_USERNAME', 'DBS_PASSWORD', 'DBS_PORT', 'DBS_ENCODE', 'DBS_CONNECTION_TYPE', 'DBS_TNS', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ) + BasePeer::TYPE_PHPNAME => array ('DbsId', 'DbsUid', 'ProUid', 'ProId', 'DbsType', 'DbsServer', 'DbsDatabaseName', 'DbsUsername', 'DbsPassword', 'DbsPort', 'DbsEncode', 'DbsConnectionType', 'DbsTns', ), + BasePeer::TYPE_COLNAME => array (DbSourcePeer::DBS_ID, DbSourcePeer::DBS_UID, DbSourcePeer::PRO_UID, DbSourcePeer::PRO_ID, DbSourcePeer::DBS_TYPE, DbSourcePeer::DBS_SERVER, DbSourcePeer::DBS_DATABASE_NAME, DbSourcePeer::DBS_USERNAME, DbSourcePeer::DBS_PASSWORD, DbSourcePeer::DBS_PORT, DbSourcePeer::DBS_ENCODE, DbSourcePeer::DBS_CONNECTION_TYPE, DbSourcePeer::DBS_TNS, ), + BasePeer::TYPE_FIELDNAME => array ('DBS_ID', 'DBS_UID', 'PRO_UID', 'PRO_ID', 'DBS_TYPE', 'DBS_SERVER', 'DBS_DATABASE_NAME', 'DBS_USERNAME', 'DBS_PASSWORD', 'DBS_PORT', 'DBS_ENCODE', 'DBS_CONNECTION_TYPE', 'DBS_TNS', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, ) ); /** @@ -88,10 +94,10 @@ abstract class BaseDbSourcePeer * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 */ private static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('DbsUid' => 0, 'ProUid' => 1, 'DbsType' => 2, 'DbsServer' => 3, 'DbsDatabaseName' => 4, 'DbsUsername' => 5, 'DbsPassword' => 6, 'DbsPort' => 7, 'DbsEncode' => 8, 'DbsConnectionType' => 9, 'DbsTns' => 10, ), - BasePeer::TYPE_COLNAME => array (DbSourcePeer::DBS_UID => 0, DbSourcePeer::PRO_UID => 1, DbSourcePeer::DBS_TYPE => 2, DbSourcePeer::DBS_SERVER => 3, DbSourcePeer::DBS_DATABASE_NAME => 4, DbSourcePeer::DBS_USERNAME => 5, DbSourcePeer::DBS_PASSWORD => 6, DbSourcePeer::DBS_PORT => 7, DbSourcePeer::DBS_ENCODE => 8, DbSourcePeer::DBS_CONNECTION_TYPE => 9, DbSourcePeer::DBS_TNS => 10, ), - BasePeer::TYPE_FIELDNAME => array ('DBS_UID' => 0, 'PRO_UID' => 1, 'DBS_TYPE' => 2, 'DBS_SERVER' => 3, 'DBS_DATABASE_NAME' => 4, 'DBS_USERNAME' => 5, 'DBS_PASSWORD' => 6, 'DBS_PORT' => 7, 'DBS_ENCODE' => 8, 'DBS_CONNECTION_TYPE' => 9, 'DBS_TNS' => 10, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ) + BasePeer::TYPE_PHPNAME => array ('DbsId' => 0, 'DbsUid' => 1, 'ProUid' => 2, 'ProId' => 3, 'DbsType' => 4, 'DbsServer' => 5, 'DbsDatabaseName' => 6, 'DbsUsername' => 7, 'DbsPassword' => 8, 'DbsPort' => 9, 'DbsEncode' => 10, 'DbsConnectionType' => 11, 'DbsTns' => 12, ), + BasePeer::TYPE_COLNAME => array (DbSourcePeer::DBS_ID => 0, DbSourcePeer::DBS_UID => 1, DbSourcePeer::PRO_UID => 2, DbSourcePeer::PRO_ID => 3, DbSourcePeer::DBS_TYPE => 4, DbSourcePeer::DBS_SERVER => 5, DbSourcePeer::DBS_DATABASE_NAME => 6, DbSourcePeer::DBS_USERNAME => 7, DbSourcePeer::DBS_PASSWORD => 8, DbSourcePeer::DBS_PORT => 9, DbSourcePeer::DBS_ENCODE => 10, DbSourcePeer::DBS_CONNECTION_TYPE => 11, DbSourcePeer::DBS_TNS => 12, ), + BasePeer::TYPE_FIELDNAME => array ('DBS_ID' => 0, 'DBS_UID' => 1, 'PRO_UID' => 2, 'PRO_ID' => 3, 'DBS_TYPE' => 4, 'DBS_SERVER' => 5, 'DBS_DATABASE_NAME' => 6, 'DBS_USERNAME' => 7, 'DBS_PASSWORD' => 8, 'DBS_PORT' => 9, 'DBS_ENCODE' => 10, 'DBS_CONNECTION_TYPE' => 11, 'DBS_TNS' => 12, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, ) ); /** @@ -192,10 +198,14 @@ abstract class BaseDbSourcePeer public static function addSelectColumns(Criteria $criteria) { + $criteria->addSelectColumn(DbSourcePeer::DBS_ID); + $criteria->addSelectColumn(DbSourcePeer::DBS_UID); $criteria->addSelectColumn(DbSourcePeer::PRO_UID); + $criteria->addSelectColumn(DbSourcePeer::PRO_ID); + $criteria->addSelectColumn(DbSourcePeer::DBS_TYPE); $criteria->addSelectColumn(DbSourcePeer::DBS_SERVER); diff --git a/workflow/engine/classes/model/om/BaseProcessVariables.php b/workflow/engine/classes/model/om/BaseProcessVariables.php index bc9526da9..f8e44973b 100644 --- a/workflow/engine/classes/model/om/BaseProcessVariables.php +++ b/workflow/engine/classes/model/om/BaseProcessVariables.php @@ -27,6 +27,12 @@ abstract class BaseProcessVariables extends BaseObject implements Persistent */ protected static $peer; + /** + * The value for the var_id field. + * @var int + */ + protected $var_id; + /** * The value for the var_uid field. * @var string @@ -39,6 +45,12 @@ abstract class BaseProcessVariables extends BaseObject implements Persistent */ protected $prj_uid; + /** + * The value for the pro_id field. + * @var int + */ + protected $pro_id = 0; + /** * The value for the var_name field. * @var string @@ -51,6 +63,12 @@ abstract class BaseProcessVariables extends BaseObject implements Persistent */ protected $var_field_type = ''; + /** + * The value for the var_field_type_id field. + * @var int + */ + protected $var_field_type_id = 0; + /** * The value for the var_field_size field. * @var int @@ -113,6 +131,17 @@ abstract class BaseProcessVariables extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Get the [var_id] column value. + * + * @return int + */ + public function getVarId() + { + + return $this->var_id; + } + /** * Get the [var_uid] column value. * @@ -135,6 +164,17 @@ abstract class BaseProcessVariables extends BaseObject implements Persistent return $this->prj_uid; } + /** + * Get the [pro_id] column value. + * + * @return int + */ + public function getProId() + { + + return $this->pro_id; + } + /** * Get the [var_name] column value. * @@ -157,6 +197,17 @@ abstract class BaseProcessVariables extends BaseObject implements Persistent return $this->var_field_type; } + /** + * Get the [var_field_type_id] column value. + * + * @return int + */ + public function getVarFieldTypeId() + { + + return $this->var_field_type_id; + } + /** * Get the [var_field_size] column value. * @@ -245,6 +296,28 @@ abstract class BaseProcessVariables extends BaseObject implements Persistent return $this->inp_doc_uid; } + /** + * Set the value of [var_id] column. + * + * @param int $v new value + * @return void + */ + public function setVarId($v) + { + + // Since the native PHP type for this column is integer, + // we will cast the input value to an int (if it is not). + if ($v !== null && !is_int($v) && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->var_id !== $v) { + $this->var_id = $v; + $this->modifiedColumns[] = ProcessVariablesPeer::VAR_ID; + } + + } // setVarId() + /** * Set the value of [var_uid] column. * @@ -289,6 +362,28 @@ abstract class BaseProcessVariables extends BaseObject implements Persistent } // setPrjUid() + /** + * Set the value of [pro_id] column. + * + * @param int $v new value + * @return void + */ + public function setProId($v) + { + + // Since the native PHP type for this column is integer, + // we will cast the input value to an int (if it is not). + if ($v !== null && !is_int($v) && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->pro_id !== $v || $v === 0) { + $this->pro_id = $v; + $this->modifiedColumns[] = ProcessVariablesPeer::PRO_ID; + } + + } // setProId() + /** * Set the value of [var_name] column. * @@ -333,6 +428,28 @@ abstract class BaseProcessVariables extends BaseObject implements Persistent } // setVarFieldType() + /** + * Set the value of [var_field_type_id] column. + * + * @param int $v new value + * @return void + */ + public function setVarFieldTypeId($v) + { + + // Since the native PHP type for this column is integer, + // we will cast the input value to an int (if it is not). + if ($v !== null && !is_int($v) && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->var_field_type_id !== $v || $v === 0) { + $this->var_field_type_id = $v; + $this->modifiedColumns[] = ProcessVariablesPeer::VAR_FIELD_TYPE_ID; + } + + } // setVarFieldTypeId() + /** * Set the value of [var_field_size] column. * @@ -526,36 +643,42 @@ abstract class BaseProcessVariables extends BaseObject implements Persistent { try { - $this->var_uid = $rs->getString($startcol + 0); + $this->var_id = $rs->getInt($startcol + 0); - $this->prj_uid = $rs->getString($startcol + 1); + $this->var_uid = $rs->getString($startcol + 1); - $this->var_name = $rs->getString($startcol + 2); + $this->prj_uid = $rs->getString($startcol + 2); - $this->var_field_type = $rs->getString($startcol + 3); + $this->pro_id = $rs->getInt($startcol + 3); - $this->var_field_size = $rs->getInt($startcol + 4); + $this->var_name = $rs->getString($startcol + 4); - $this->var_label = $rs->getString($startcol + 5); + $this->var_field_type = $rs->getString($startcol + 5); - $this->var_dbconnection = $rs->getString($startcol + 6); + $this->var_field_type_id = $rs->getInt($startcol + 6); - $this->var_sql = $rs->getString($startcol + 7); + $this->var_field_size = $rs->getInt($startcol + 7); - $this->var_null = $rs->getInt($startcol + 8); + $this->var_label = $rs->getString($startcol + 8); - $this->var_default = $rs->getString($startcol + 9); + $this->var_dbconnection = $rs->getString($startcol + 9); - $this->var_accepted_values = $rs->getString($startcol + 10); + $this->var_sql = $rs->getString($startcol + 10); - $this->inp_doc_uid = $rs->getString($startcol + 11); + $this->var_null = $rs->getInt($startcol + 11); + + $this->var_default = $rs->getString($startcol + 12); + + $this->var_accepted_values = $rs->getString($startcol + 13); + + $this->inp_doc_uid = $rs->getString($startcol + 14); $this->resetModified(); $this->setNew(false); // FIXME - using NUM_COLUMNS may be clearer. - return $startcol + 12; // 12 = ProcessVariablesPeer::NUM_COLUMNS - ProcessVariablesPeer::NUM_LAZY_LOAD_COLUMNS). + return $startcol + 15; // 15 = ProcessVariablesPeer::NUM_COLUMNS - ProcessVariablesPeer::NUM_LAZY_LOAD_COLUMNS). } catch (Exception $e) { throw new PropelException("Error populating ProcessVariables object", $e); @@ -760,39 +883,48 @@ abstract class BaseProcessVariables extends BaseObject implements Persistent { switch($pos) { case 0: - return $this->getVarUid(); + return $this->getVarId(); break; case 1: - return $this->getPrjUid(); + return $this->getVarUid(); break; case 2: - return $this->getVarName(); + return $this->getPrjUid(); break; case 3: - return $this->getVarFieldType(); + return $this->getProId(); break; case 4: - return $this->getVarFieldSize(); + return $this->getVarName(); break; case 5: - return $this->getVarLabel(); + return $this->getVarFieldType(); break; case 6: - return $this->getVarDbconnection(); + return $this->getVarFieldTypeId(); break; case 7: - return $this->getVarSql(); + return $this->getVarFieldSize(); break; case 8: - return $this->getVarNull(); + return $this->getVarLabel(); break; case 9: - return $this->getVarDefault(); + return $this->getVarDbconnection(); break; case 10: - return $this->getVarAcceptedValues(); + return $this->getVarSql(); break; case 11: + return $this->getVarNull(); + break; + case 12: + return $this->getVarDefault(); + break; + case 13: + return $this->getVarAcceptedValues(); + break; + case 14: return $this->getInpDocUid(); break; default: @@ -815,18 +947,21 @@ abstract class BaseProcessVariables extends BaseObject implements Persistent { $keys = ProcessVariablesPeer::getFieldNames($keyType); $result = array( - $keys[0] => $this->getVarUid(), - $keys[1] => $this->getPrjUid(), - $keys[2] => $this->getVarName(), - $keys[3] => $this->getVarFieldType(), - $keys[4] => $this->getVarFieldSize(), - $keys[5] => $this->getVarLabel(), - $keys[6] => $this->getVarDbconnection(), - $keys[7] => $this->getVarSql(), - $keys[8] => $this->getVarNull(), - $keys[9] => $this->getVarDefault(), - $keys[10] => $this->getVarAcceptedValues(), - $keys[11] => $this->getInpDocUid(), + $keys[0] => $this->getVarId(), + $keys[1] => $this->getVarUid(), + $keys[2] => $this->getPrjUid(), + $keys[3] => $this->getProId(), + $keys[4] => $this->getVarName(), + $keys[5] => $this->getVarFieldType(), + $keys[6] => $this->getVarFieldTypeId(), + $keys[7] => $this->getVarFieldSize(), + $keys[8] => $this->getVarLabel(), + $keys[9] => $this->getVarDbconnection(), + $keys[10] => $this->getVarSql(), + $keys[11] => $this->getVarNull(), + $keys[12] => $this->getVarDefault(), + $keys[13] => $this->getVarAcceptedValues(), + $keys[14] => $this->getInpDocUid(), ); return $result; } @@ -859,39 +994,48 @@ abstract class BaseProcessVariables extends BaseObject implements Persistent { switch($pos) { case 0: - $this->setVarUid($value); + $this->setVarId($value); break; case 1: - $this->setPrjUid($value); + $this->setVarUid($value); break; case 2: - $this->setVarName($value); + $this->setPrjUid($value); break; case 3: - $this->setVarFieldType($value); + $this->setProId($value); break; case 4: - $this->setVarFieldSize($value); + $this->setVarName($value); break; case 5: - $this->setVarLabel($value); + $this->setVarFieldType($value); break; case 6: - $this->setVarDbconnection($value); + $this->setVarFieldTypeId($value); break; case 7: - $this->setVarSql($value); + $this->setVarFieldSize($value); break; case 8: - $this->setVarNull($value); + $this->setVarLabel($value); break; case 9: - $this->setVarDefault($value); + $this->setVarDbconnection($value); break; case 10: - $this->setVarAcceptedValues($value); + $this->setVarSql($value); break; case 11: + $this->setVarNull($value); + break; + case 12: + $this->setVarDefault($value); + break; + case 13: + $this->setVarAcceptedValues($value); + break; + case 14: $this->setInpDocUid($value); break; } // switch() @@ -918,51 +1062,63 @@ abstract class BaseProcessVariables extends BaseObject implements Persistent $keys = ProcessVariablesPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { - $this->setVarUid($arr[$keys[0]]); + $this->setVarId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { - $this->setPrjUid($arr[$keys[1]]); + $this->setVarUid($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { - $this->setVarName($arr[$keys[2]]); + $this->setPrjUid($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { - $this->setVarFieldType($arr[$keys[3]]); + $this->setProId($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { - $this->setVarFieldSize($arr[$keys[4]]); + $this->setVarName($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { - $this->setVarLabel($arr[$keys[5]]); + $this->setVarFieldType($arr[$keys[5]]); } if (array_key_exists($keys[6], $arr)) { - $this->setVarDbconnection($arr[$keys[6]]); + $this->setVarFieldTypeId($arr[$keys[6]]); } if (array_key_exists($keys[7], $arr)) { - $this->setVarSql($arr[$keys[7]]); + $this->setVarFieldSize($arr[$keys[7]]); } if (array_key_exists($keys[8], $arr)) { - $this->setVarNull($arr[$keys[8]]); + $this->setVarLabel($arr[$keys[8]]); } if (array_key_exists($keys[9], $arr)) { - $this->setVarDefault($arr[$keys[9]]); + $this->setVarDbconnection($arr[$keys[9]]); } if (array_key_exists($keys[10], $arr)) { - $this->setVarAcceptedValues($arr[$keys[10]]); + $this->setVarSql($arr[$keys[10]]); } if (array_key_exists($keys[11], $arr)) { - $this->setInpDocUid($arr[$keys[11]]); + $this->setVarNull($arr[$keys[11]]); + } + + if (array_key_exists($keys[12], $arr)) { + $this->setVarDefault($arr[$keys[12]]); + } + + if (array_key_exists($keys[13], $arr)) { + $this->setVarAcceptedValues($arr[$keys[13]]); + } + + if (array_key_exists($keys[14], $arr)) { + $this->setInpDocUid($arr[$keys[14]]); } } @@ -976,6 +1132,10 @@ abstract class BaseProcessVariables extends BaseObject implements Persistent { $criteria = new Criteria(ProcessVariablesPeer::DATABASE_NAME); + if ($this->isColumnModified(ProcessVariablesPeer::VAR_ID)) { + $criteria->add(ProcessVariablesPeer::VAR_ID, $this->var_id); + } + if ($this->isColumnModified(ProcessVariablesPeer::VAR_UID)) { $criteria->add(ProcessVariablesPeer::VAR_UID, $this->var_uid); } @@ -984,6 +1144,10 @@ abstract class BaseProcessVariables extends BaseObject implements Persistent $criteria->add(ProcessVariablesPeer::PRJ_UID, $this->prj_uid); } + if ($this->isColumnModified(ProcessVariablesPeer::PRO_ID)) { + $criteria->add(ProcessVariablesPeer::PRO_ID, $this->pro_id); + } + if ($this->isColumnModified(ProcessVariablesPeer::VAR_NAME)) { $criteria->add(ProcessVariablesPeer::VAR_NAME, $this->var_name); } @@ -992,6 +1156,10 @@ abstract class BaseProcessVariables extends BaseObject implements Persistent $criteria->add(ProcessVariablesPeer::VAR_FIELD_TYPE, $this->var_field_type); } + if ($this->isColumnModified(ProcessVariablesPeer::VAR_FIELD_TYPE_ID)) { + $criteria->add(ProcessVariablesPeer::VAR_FIELD_TYPE_ID, $this->var_field_type_id); + } + if ($this->isColumnModified(ProcessVariablesPeer::VAR_FIELD_SIZE)) { $criteria->add(ProcessVariablesPeer::VAR_FIELD_SIZE, $this->var_field_size); } @@ -1078,12 +1246,18 @@ abstract class BaseProcessVariables extends BaseObject implements Persistent public function copyInto($copyObj, $deepCopy = false) { + $copyObj->setVarId($this->var_id); + $copyObj->setPrjUid($this->prj_uid); + $copyObj->setProId($this->pro_id); + $copyObj->setVarName($this->var_name); $copyObj->setVarFieldType($this->var_field_type); + $copyObj->setVarFieldTypeId($this->var_field_type_id); + $copyObj->setVarFieldSize($this->var_field_size); $copyObj->setVarLabel($this->var_label); diff --git a/workflow/engine/classes/model/om/BaseProcessVariablesPeer.php b/workflow/engine/classes/model/om/BaseProcessVariablesPeer.php index 2ba345ffe..a6d472c47 100644 --- a/workflow/engine/classes/model/om/BaseProcessVariablesPeer.php +++ b/workflow/engine/classes/model/om/BaseProcessVariablesPeer.php @@ -25,24 +25,33 @@ abstract class BaseProcessVariablesPeer const CLASS_DEFAULT = 'classes.model.ProcessVariables'; /** The total number of columns. */ - const NUM_COLUMNS = 12; + const NUM_COLUMNS = 15; /** The number of lazy-loaded columns. */ const NUM_LAZY_LOAD_COLUMNS = 0; + /** the column name for the VAR_ID field */ + const VAR_ID = 'PROCESS_VARIABLES.VAR_ID'; + /** the column name for the VAR_UID field */ const VAR_UID = 'PROCESS_VARIABLES.VAR_UID'; /** the column name for the PRJ_UID field */ const PRJ_UID = 'PROCESS_VARIABLES.PRJ_UID'; + /** the column name for the PRO_ID field */ + const PRO_ID = 'PROCESS_VARIABLES.PRO_ID'; + /** the column name for the VAR_NAME field */ const VAR_NAME = 'PROCESS_VARIABLES.VAR_NAME'; /** the column name for the VAR_FIELD_TYPE field */ const VAR_FIELD_TYPE = 'PROCESS_VARIABLES.VAR_FIELD_TYPE'; + /** the column name for the VAR_FIELD_TYPE_ID field */ + const VAR_FIELD_TYPE_ID = 'PROCESS_VARIABLES.VAR_FIELD_TYPE_ID'; + /** the column name for the VAR_FIELD_SIZE field */ const VAR_FIELD_SIZE = 'PROCESS_VARIABLES.VAR_FIELD_SIZE'; @@ -78,10 +87,10 @@ abstract class BaseProcessVariablesPeer * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ private static $fieldNames = array ( - BasePeer::TYPE_PHPNAME => array ('VarUid', 'PrjUid', 'VarName', 'VarFieldType', 'VarFieldSize', 'VarLabel', 'VarDbconnection', 'VarSql', 'VarNull', 'VarDefault', 'VarAcceptedValues', 'InpDocUid', ), - BasePeer::TYPE_COLNAME => array (ProcessVariablesPeer::VAR_UID, ProcessVariablesPeer::PRJ_UID, ProcessVariablesPeer::VAR_NAME, ProcessVariablesPeer::VAR_FIELD_TYPE, ProcessVariablesPeer::VAR_FIELD_SIZE, ProcessVariablesPeer::VAR_LABEL, ProcessVariablesPeer::VAR_DBCONNECTION, ProcessVariablesPeer::VAR_SQL, ProcessVariablesPeer::VAR_NULL, ProcessVariablesPeer::VAR_DEFAULT, ProcessVariablesPeer::VAR_ACCEPTED_VALUES, ProcessVariablesPeer::INP_DOC_UID, ), - BasePeer::TYPE_FIELDNAME => array ('VAR_UID', 'PRJ_UID', 'VAR_NAME', 'VAR_FIELD_TYPE', 'VAR_FIELD_SIZE', 'VAR_LABEL', 'VAR_DBCONNECTION', 'VAR_SQL', 'VAR_NULL', 'VAR_DEFAULT', 'VAR_ACCEPTED_VALUES', 'INP_DOC_UID', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ) + BasePeer::TYPE_PHPNAME => array ('VarId', 'VarUid', 'PrjUid', 'ProId', 'VarName', 'VarFieldType', 'VarFieldTypeId', 'VarFieldSize', 'VarLabel', 'VarDbconnection', 'VarSql', 'VarNull', 'VarDefault', 'VarAcceptedValues', 'InpDocUid', ), + BasePeer::TYPE_COLNAME => array (ProcessVariablesPeer::VAR_ID, ProcessVariablesPeer::VAR_UID, ProcessVariablesPeer::PRJ_UID, ProcessVariablesPeer::PRO_ID, ProcessVariablesPeer::VAR_NAME, ProcessVariablesPeer::VAR_FIELD_TYPE, ProcessVariablesPeer::VAR_FIELD_TYPE_ID, ProcessVariablesPeer::VAR_FIELD_SIZE, ProcessVariablesPeer::VAR_LABEL, ProcessVariablesPeer::VAR_DBCONNECTION, ProcessVariablesPeer::VAR_SQL, ProcessVariablesPeer::VAR_NULL, ProcessVariablesPeer::VAR_DEFAULT, ProcessVariablesPeer::VAR_ACCEPTED_VALUES, ProcessVariablesPeer::INP_DOC_UID, ), + BasePeer::TYPE_FIELDNAME => array ('VAR_ID', 'VAR_UID', 'PRJ_UID', 'PRO_ID', 'VAR_NAME', 'VAR_FIELD_TYPE', 'VAR_FIELD_TYPE_ID', 'VAR_FIELD_SIZE', 'VAR_LABEL', 'VAR_DBCONNECTION', 'VAR_SQL', 'VAR_NULL', 'VAR_DEFAULT', 'VAR_ACCEPTED_VALUES', 'INP_DOC_UID', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, ) ); /** @@ -91,10 +100,10 @@ abstract class BaseProcessVariablesPeer * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 */ private static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('VarUid' => 0, 'PrjUid' => 1, 'VarName' => 2, 'VarFieldType' => 3, 'VarFieldSize' => 4, 'VarLabel' => 5, 'VarDbconnection' => 6, 'VarSql' => 7, 'VarNull' => 8, 'VarDefault' => 9, 'VarAcceptedValues' => 10, 'InpDocUid' => 11, ), - BasePeer::TYPE_COLNAME => array (ProcessVariablesPeer::VAR_UID => 0, ProcessVariablesPeer::PRJ_UID => 1, ProcessVariablesPeer::VAR_NAME => 2, ProcessVariablesPeer::VAR_FIELD_TYPE => 3, ProcessVariablesPeer::VAR_FIELD_SIZE => 4, ProcessVariablesPeer::VAR_LABEL => 5, ProcessVariablesPeer::VAR_DBCONNECTION => 6, ProcessVariablesPeer::VAR_SQL => 7, ProcessVariablesPeer::VAR_NULL => 8, ProcessVariablesPeer::VAR_DEFAULT => 9, ProcessVariablesPeer::VAR_ACCEPTED_VALUES => 10, ProcessVariablesPeer::INP_DOC_UID => 11, ), - BasePeer::TYPE_FIELDNAME => array ('VAR_UID' => 0, 'PRJ_UID' => 1, 'VAR_NAME' => 2, 'VAR_FIELD_TYPE' => 3, 'VAR_FIELD_SIZE' => 4, 'VAR_LABEL' => 5, 'VAR_DBCONNECTION' => 6, 'VAR_SQL' => 7, 'VAR_NULL' => 8, 'VAR_DEFAULT' => 9, 'VAR_ACCEPTED_VALUES' => 10, 'INP_DOC_UID' => 11, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ) + BasePeer::TYPE_PHPNAME => array ('VarId' => 0, 'VarUid' => 1, 'PrjUid' => 2, 'ProId' => 3, 'VarName' => 4, 'VarFieldType' => 5, 'VarFieldTypeId' => 6, 'VarFieldSize' => 7, 'VarLabel' => 8, 'VarDbconnection' => 9, 'VarSql' => 10, 'VarNull' => 11, 'VarDefault' => 12, 'VarAcceptedValues' => 13, 'InpDocUid' => 14, ), + BasePeer::TYPE_COLNAME => array (ProcessVariablesPeer::VAR_ID => 0, ProcessVariablesPeer::VAR_UID => 1, ProcessVariablesPeer::PRJ_UID => 2, ProcessVariablesPeer::PRO_ID => 3, ProcessVariablesPeer::VAR_NAME => 4, ProcessVariablesPeer::VAR_FIELD_TYPE => 5, ProcessVariablesPeer::VAR_FIELD_TYPE_ID => 6, ProcessVariablesPeer::VAR_FIELD_SIZE => 7, ProcessVariablesPeer::VAR_LABEL => 8, ProcessVariablesPeer::VAR_DBCONNECTION => 9, ProcessVariablesPeer::VAR_SQL => 10, ProcessVariablesPeer::VAR_NULL => 11, ProcessVariablesPeer::VAR_DEFAULT => 12, ProcessVariablesPeer::VAR_ACCEPTED_VALUES => 13, ProcessVariablesPeer::INP_DOC_UID => 14, ), + BasePeer::TYPE_FIELDNAME => array ('VAR_ID' => 0, 'VAR_UID' => 1, 'PRJ_UID' => 2, 'PRO_ID' => 3, 'VAR_NAME' => 4, 'VAR_FIELD_TYPE' => 5, 'VAR_FIELD_TYPE_ID' => 6, 'VAR_FIELD_SIZE' => 7, 'VAR_LABEL' => 8, 'VAR_DBCONNECTION' => 9, 'VAR_SQL' => 10, 'VAR_NULL' => 11, 'VAR_DEFAULT' => 12, 'VAR_ACCEPTED_VALUES' => 13, 'INP_DOC_UID' => 14, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, ) ); /** @@ -195,14 +204,20 @@ abstract class BaseProcessVariablesPeer public static function addSelectColumns(Criteria $criteria) { + $criteria->addSelectColumn(ProcessVariablesPeer::VAR_ID); + $criteria->addSelectColumn(ProcessVariablesPeer::VAR_UID); $criteria->addSelectColumn(ProcessVariablesPeer::PRJ_UID); + $criteria->addSelectColumn(ProcessVariablesPeer::PRO_ID); + $criteria->addSelectColumn(ProcessVariablesPeer::VAR_NAME); $criteria->addSelectColumn(ProcessVariablesPeer::VAR_FIELD_TYPE); + $criteria->addSelectColumn(ProcessVariablesPeer::VAR_FIELD_TYPE_ID); + $criteria->addSelectColumn(ProcessVariablesPeer::VAR_FIELD_SIZE); $criteria->addSelectColumn(ProcessVariablesPeer::VAR_LABEL); diff --git a/workflow/engine/config/schema.xml b/workflow/engine/config/schema.xml index 725884961..24e4d7490 100644 --- a/workflow/engine/config/schema.xml +++ b/workflow/engine/config/schema.xml @@ -360,7 +360,7 @@ - + @@ -1974,7 +1974,7 @@ - +
@@ -1995,8 +1995,10 @@ + + @@ -2006,6 +2008,9 @@ + + + @@ -2023,6 +2028,9 @@ + + +
@@ -4250,11 +4258,14 @@
- +
+ + + @@ -4263,6 +4274,9 @@ + + + @@ -4273,6 +4287,9 @@ + + +
diff --git a/workflow/engine/controllers/InstallerModule.php b/workflow/engine/controllers/InstallerModule.php index 0ab4eacbf..49606d9f4 100644 --- a/workflow/engine/controllers/InstallerModule.php +++ b/workflow/engine/controllers/InstallerModule.php @@ -1181,7 +1181,6 @@ class InstallerModule extends Controller { $filter = new InputFilter(); ini_set('max_execution_time', '0'); - ini_set('memory_limit', '256M'); $serv = 'http://'; if (isset($_SERVER['HTTPS']) && !empty(trim($_SERVER['HTTPS']))) { diff --git a/workflow/engine/controllers/adminProxy.php b/workflow/engine/controllers/adminProxy.php index 8ecb2e07f..5516af836 100644 --- a/workflow/engine/controllers/adminProxy.php +++ b/workflow/engine/controllers/adminProxy.php @@ -65,11 +65,6 @@ class adminProxy extends HttpProxyController $updatedConf['expiration_year'] = $httpData->expiration_year; } - $httpData->memory_limit .= 'M'; - if ($sysConf['memory_limit'] != $httpData->memory_limit) { - $updatedConf['memory_limit'] = $httpData->memory_limit; - } - if ($sysConf['proxy_host'] != $httpData->proxy_host) { $updatedConf['proxy_host'] = $httpData->proxy_host; } @@ -126,7 +121,7 @@ class adminProxy extends HttpProxyController $msg = ", Host -> " . $httpData->proxy_host . ", Port -> " . $httpData->proxy_port . ", User -> " . $httpData->proxy_user; } - G::auditLog("UploadSystemSettings", "Time Zone -> " . $httpData->time_zone . ", Memory Limit -> " . $httpData->memory_limit . ", Cookie lifetime -> " . $httpData->max_life_time . ", Default Skin -> " . $httpData->default_skin . ", Default Language -> " . $httpData->default_lang . $msg); + G::auditLog("UploadSystemSettings", "Time Zone -> " . $httpData->time_zone . ", Cookie lifetime -> " . $httpData->max_life_time . ", Default Skin -> " . $httpData->default_skin . ", Default Language -> " . $httpData->default_lang . $msg); } public function uxUserUpdate($httpData) @@ -1584,12 +1579,6 @@ class adminProxy extends HttpProxyController */ public static function validateDataSystemConf($httpData, $envFile) { - if (!((is_numeric($httpData->memory_limit)) && ((int)$httpData->memory_limit == $httpData->memory_limit) && - ((int)$httpData->memory_limit >= -1)) - ) { - throw new Exception(G::LoadTranslation('ID_MEMORY_LIMIT_VALIDATE')); - } - if (!((is_numeric($httpData->max_life_time)) && ((int)$httpData->max_life_time == $httpData->max_life_time) && ((int)$httpData->max_life_time > 0)) ) { diff --git a/workflow/engine/data/mysql/schema.sql b/workflow/engine/data/mysql/schema.sql index 97732ea0f..4946fb777 100644 --- a/workflow/engine/data/mysql/schema.sql +++ b/workflow/engine/data/mysql/schema.sql @@ -154,7 +154,7 @@ CREATE TABLE `APP_MESSAGE` `DEL_INDEX` INTEGER default 0 NOT NULL, `APP_MSG_TYPE` VARCHAR(100) default '' NOT NULL, `APP_MSG_TYPE_ID` TINYINT default 0, - `APP_MSG_SUBJECT` VARCHAR(150) default '' NOT NULL, + `APP_MSG_SUBJECT` VARCHAR(998) default '' NOT NULL, `APP_MSG_FROM` VARCHAR(100) default '' NOT NULL, `APP_MSG_TO` MEDIUMTEXT NOT NULL, `APP_MSG_BODY` MEDIUMTEXT NOT NULL, @@ -935,8 +935,10 @@ DROP TABLE IF EXISTS `DB_SOURCE`; CREATE TABLE `DB_SOURCE` ( + `DBS_ID` INTEGER NOT NULL AUTO_INCREMENT, `DBS_UID` VARCHAR(32) default '' NOT NULL, `PRO_UID` VARCHAR(32) default '0' NOT NULL, + `PRO_ID` INTEGER default 0, `DBS_TYPE` VARCHAR(8) default '0' NOT NULL, `DBS_SERVER` VARCHAR(100) default '0' NOT NULL, `DBS_DATABASE_NAME` VARCHAR(100) default '0' NOT NULL, @@ -947,7 +949,9 @@ CREATE TABLE `DB_SOURCE` `DBS_CONNECTION_TYPE` VARCHAR(32) default 'NORMAL', `DBS_TNS` VARCHAR(256) default '', PRIMARY KEY (`DBS_UID`,`PRO_UID`), - KEY `indexDBSource`(`PRO_UID`) + UNIQUE KEY `DBS_ID` (`DBS_ID`), + KEY `indexDBSource`(`PRO_UID`), + KEY `INDEX_PRO_ID`(`PRO_ID`) )ENGINE=InnoDB DEFAULT CHARSET='utf8' COMMENT='DB_SOURCE'; #----------------------------------------------------------------------------- #-- STEP_SUPERVISOR @@ -2274,10 +2278,13 @@ DROP TABLE IF EXISTS `PROCESS_VARIABLES`; CREATE TABLE `PROCESS_VARIABLES` ( + `VAR_ID` INTEGER NOT NULL AUTO_INCREMENT, `VAR_UID` VARCHAR(32) NOT NULL, `PRJ_UID` VARCHAR(32) NOT NULL, + `PRO_ID` INTEGER default 0, `VAR_NAME` VARCHAR(255) default '', `VAR_FIELD_TYPE` VARCHAR(32) default '', + `VAR_FIELD_TYPE_ID` INTEGER default 0, `VAR_FIELD_SIZE` INTEGER, `VAR_LABEL` VARCHAR(255) default '', `VAR_DBCONNECTION` VARCHAR(32), @@ -2287,7 +2294,9 @@ CREATE TABLE `PROCESS_VARIABLES` `VAR_ACCEPTED_VALUES` MEDIUMTEXT, `INP_DOC_UID` VARCHAR(32) default '', PRIMARY KEY (`VAR_UID`), - KEY `indexPrjUidVarName`(`PRJ_UID`, `VAR_NAME`) + UNIQUE KEY `VAR_ID` (`VAR_ID`), + KEY `indexPrjUidVarName`(`PRJ_UID`, `VAR_NAME`), + KEY `INDEX_PRO_ID`(`PRO_ID`) )ENGINE=InnoDB ; #----------------------------------------------------------------------------- #-- APP_TIMEOUT_ACTION_EXECUTED diff --git a/workflow/engine/methods/cases/ajaxListener.php b/workflow/engine/methods/cases/ajaxListener.php index 4dd2cee01..a966c5c1e 100644 --- a/workflow/engine/methods/cases/ajaxListener.php +++ b/workflow/engine/methods/cases/ajaxListener.php @@ -571,6 +571,14 @@ class Ajax // Review if the case was cancelled, true if the case was cancelled $result->status = ($response->status_code == 0) ? true : false; $result->msg = $response->message; + // Register in cases notes + if (!empty($_POST['NOTE_REASON'])) { + $appNotes = new AppNotes(); + $noteContent = addslashes($_POST['NOTE_REASON']); + $appNotes->postNewNote( + $appUid, $usrUid, $noteContent, $_POST['NOTIFY_CANCEL'] + ); + } } else { $result->status = false; $result->msg = G::LoadTranslation("ID_CASE_USER_INVALID_CANCEL_CASE", [$usrUid]); diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Validator.php b/workflow/engine/src/ProcessMaker/BusinessModel/Validator.php index 54fde9163..db86a326e 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Validator.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Validator.php @@ -138,26 +138,28 @@ class Validator /** * Validate pro_uid * - * @param string $pro_uid , Uid for process + * @param string $proUid , Uid for process * @param string $nameField . Name of field for message * * @access public - * @author Brayan Pereyra (Cochalo) - * @copyright Colosa - Bolivia * - * @return string + * @return int */ - static public function proUid($pro_uid, $nameField = 'pro_uid') + static public function proUid($proUid, $nameField = 'pro_uid') { - $pro_uid = trim($pro_uid); - if ($pro_uid == '') { + $proUid = trim($proUid); + if (empty($proUid)) { throw (new Exception(G::LoadTranslation("ID_PROCESS_NOT_EXIST", array($nameField, '')))); } - $oProcess = new \Process(); - if (!($oProcess->exists($pro_uid))) { - throw (new Exception(G::LoadTranslation("ID_PROCESS_NOT_EXIST", array($nameField, $pro_uid)))); + $process = new \Process(); + $proId = 0; + if (!($process->exists($proUid))) { + throw (new Exception(G::LoadTranslation("ID_PROCESS_NOT_EXIST", array($nameField, $proUid)))); + } else { + $proId = $process->load($proUid)['PRO_ID']; } - return $pro_uid; + + return $proId; } /** diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Variable.php b/workflow/engine/src/ProcessMaker/BusinessModel/Variable.php index 086451bf3..bcd1768b5 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Variable.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Variable.php @@ -7,106 +7,92 @@ use Cases as ClassesCases; use Exception; use G; use PmDynaform; - +use ProcessMaker\Model\ProcessVariables; +use ProcessMaker\Util\Common; class Variable { private $variableTypes = ['string', 'integer', 'float', 'boolean', 'datetime', 'grid', 'array', 'file', 'multiplefile', 'object']; + public static $varTypesValues = [ + 'string' => 1, + 'integer' => 2, + 'float' => 3, + 'boolean' => 4, + 'datetime' => 5, + 'grid' => 6, + 'array' => 7, + 'file' => 8, + 'multiplefile' => 9, + 'object' => 10 + ]; /** * Create Variable for a Process * - * @param string $processUid Unique id of Process + * @param string $proUid Unique id of Process * @param array $arrayData Data * * @return array, return data of the new Variable created * @throws Exception */ - public function create($processUid, array $arrayData) + public function create($proUid, array $arrayData) { try { - //Verify data - Validator::proUid($processUid, '$prj_uid'); + $attributes = []; + // Verify the process + $proId = Validator::proUid($proUid, '$prj_uid'); + $attributes["PRJ_UID"] = $proUid; + $attributes["PRO_ID"] = $proId; + // Get the unique varUid + $varUid = Common::generateUID(); + $attributes["VAR_UID"] = $varUid; + // Get the attributes $arrayData = array_change_key_case($arrayData, CASE_UPPER); - $this->existsName($processUid, $arrayData["VAR_NAME"], ""); - $this->throwExceptionFieldDefinition($arrayData); - - //Create - $cnn = \Propel::getConnection("workflow"); - try { - $variable = new \ProcessVariables(); - $sPkProcessVariables = \ProcessMaker\Util\Common::generateUID(); - - $variable->setVarUid($sPkProcessVariables); - $variable->setPrjUid($processUid); - - if ($variable->validate()) { - $cnn->begin(); - - if (isset($arrayData["VAR_NAME"])) { - $variable->setVarName($arrayData["VAR_NAME"]); - } else { - throw new Exception(G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('$var_name'))); - } - if (isset($arrayData["VAR_FIELD_TYPE"])) { - $arrayData["VAR_FIELD_TYPE"] = $this->validateVarFieldType($arrayData["VAR_FIELD_TYPE"]); - $variable->setVarFieldType($arrayData["VAR_FIELD_TYPE"]); - } else { - throw new Exception(G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('$var_field_type'))); - } - if (isset($arrayData["VAR_FIELD_SIZE"])) { - $variable->setVarFieldSize($arrayData["VAR_FIELD_SIZE"]); - } - if (isset($arrayData["VAR_LABEL"])) { - $variable->setVarLabel($arrayData["VAR_LABEL"]); - } else { - throw new Exception(G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('$var_label'))); - } - if (isset($arrayData["VAR_DBCONNECTION"])) { - $variable->setVarDbconnection($arrayData["VAR_DBCONNECTION"]); - } else { - $variable->setVarDbconnection(""); - } - if (isset($arrayData["VAR_SQL"])) { - $variable->setVarSql($arrayData["VAR_SQL"]); - } else { - $variable->setVarSql(""); - } - if (isset($arrayData["VAR_NULL"])) { - $variable->setVarNull($arrayData["VAR_NULL"]); - } else { - $variable->setVarNull(0); - } - if (isset($arrayData["VAR_DEFAULT"])) { - $variable->setVarDefault($arrayData["VAR_DEFAULT"]); - } - if (isset($arrayData["VAR_ACCEPTED_VALUES"])) { - $encodeAcceptedValues = G::json_encode($arrayData["VAR_ACCEPTED_VALUES"]); - $variable->setVarAcceptedValues($encodeAcceptedValues); - } - if (isset($arrayData["INP_DOC_UID"])) { - $variable->setInpDocUid($arrayData["INP_DOC_UID"]); - } - $variable->save(); - $cnn->commit(); - } else { - $msg = ""; - - foreach ($variable->getValidationFailures() as $validationFailure) { - $msg = $msg . (($msg != "") ? "\n" : "") . $validationFailure->getMessage(); - } - - throw new Exception(G::LoadTranslation("ID_RECORD_CANNOT_BE_CREATED") . "\n" . $msg); - } - } catch (Exception $e) { - $cnn->rollback(); - - throw $e; + // Validate properties that cannot be empty + if (!empty($arrayData["VAR_NAME"])) { + $attributes["VAR_NAME"] = $arrayData["VAR_NAME"]; + } else { + throw new Exception(G::LoadTranslation("ID_CAN_NOT_BE_NULL", ['$var_name'])); } - - //Return - $variable = $this->getVariable($processUid, $sPkProcessVariables); - + if (!empty($arrayData["VAR_FIELD_TYPE"])) { + $attributes["VAR_FIELD_TYPE"] = $this->validateVarFieldType($arrayData["VAR_FIELD_TYPE"]); + $attributes["VAR_FIELD_TYPE_ID"] = self::$varTypesValues[$arrayData["VAR_FIELD_TYPE"]]; + } else { + throw new Exception(G::LoadTranslation("ID_CAN_NOT_BE_NULL", ['$var_field_type'])); + } + if (!empty($arrayData["VAR_LABEL"])) { + $attributes["VAR_LABEL"] = $arrayData["VAR_LABEL"]; + } else { + throw new Exception(G::LoadTranslation("ID_CAN_NOT_BE_NULL", ['$var_label'])); + } + if (!empty($arrayData["VAR_FIELD_SIZE"])) { + $attributes["VAR_FIELD_SIZE"] = $arrayData["VAR_FIELD_SIZE"]; + } + if (!empty($arrayData["VAR_DBCONNECTION"])) { + $attributes["VAR_DBCONNECTION"] = $arrayData["VAR_DBCONNECTION"]; + } + if (!empty($arrayData["VAR_SQL"])) { + $attributes["VAR_SQL"] = $arrayData["VAR_SQL"]; + } + if (!empty($arrayData["VAR_NULL"])) { + $attributes["VAR_NULL"] = $arrayData["VAR_NULL"]; + } + if (!empty($arrayData["VAR_DEFAULT"])) { + $attributes["VAR_DEFAULT"] = $arrayData["VAR_DEFAULT"]; + } + if (!empty($arrayData["VAR_ACCEPTED_VALUES"])) { + $attributes["VAR_ACCEPTED_VALUES"] = G::json_encode($arrayData["VAR_ACCEPTED_VALUES"]); + } + if (!empty($arrayData["INP_DOC_UID"])) { + $attributes["INP_DOC_UID"] = $arrayData["INP_DOC_UID"]; + } + // Additional validations over the data + $this->existsName($proUid, $arrayData["VAR_NAME"], ""); + $this->throwExceptionFieldDefinition($arrayData); + // Register the new variable + $processVariables = ProcessVariables::create($attributes); + // Return theriable created + $variable = $this->getVariable($proUid, $varUid); return $variable; } catch (Exception $e) { throw $e; @@ -292,7 +278,7 @@ class Variable $arrayVariables = array(); while ($aRow = $rsCriteria->getRow()) { $VAR_ACCEPTED_VALUES = G::json_decode($aRow['VAR_ACCEPTED_VALUES'], true); - if (count($VAR_ACCEPTED_VALUES)) { + if (!empty($VAR_ACCEPTED_VALUES)) { $encodeAcceptedValues = preg_replace_callback("/\\\\u([a-f0-9]{4})/", function ($m) { return iconv('UCS-4LE', 'UTF-8', pack('V', hexdec('U' . $m[1]))); }, G::json_encode($VAR_ACCEPTED_VALUES)); @@ -333,64 +319,40 @@ class Variable */ public function getVariables($processUid) { - try { - //Verify data - Validator::proUid($processUid, '$prj_uid'); - - //Get data - $criteria = new \Criteria("workflow"); - $criteria->addSelectColumn(\ProcessVariablesPeer::VAR_UID); - $criteria->addSelectColumn(\ProcessVariablesPeer::PRJ_UID); - $criteria->addSelectColumn(\ProcessVariablesPeer::VAR_NAME); - $criteria->addSelectColumn(\ProcessVariablesPeer::VAR_FIELD_TYPE); - $criteria->addSelectColumn(\ProcessVariablesPeer::VAR_FIELD_SIZE); - $criteria->addSelectColumn(\ProcessVariablesPeer::VAR_LABEL); - $criteria->addSelectColumn(\ProcessVariablesPeer::VAR_DBCONNECTION); - $criteria->addSelectColumn(\ProcessVariablesPeer::VAR_SQL); - $criteria->addSelectColumn(\ProcessVariablesPeer::VAR_NULL); - $criteria->addSelectColumn(\ProcessVariablesPeer::VAR_DEFAULT); - $criteria->addSelectColumn(\ProcessVariablesPeer::VAR_ACCEPTED_VALUES); - $criteria->addSelectColumn(\ProcessVariablesPeer::INP_DOC_UID); - $criteria->addSelectColumn(\DbSourcePeer::DBS_SERVER); - $criteria->addSelectColumn(\DbSourcePeer::DBS_PORT); - $criteria->addSelectColumn(\DbSourcePeer::DBS_DATABASE_NAME); - $criteria->addSelectColumn(\DbSourcePeer::DBS_TYPE); - $criteria->add(\ProcessVariablesPeer::PRJ_UID, $processUid, \Criteria::EQUAL); - $criteria->addJoin(\ProcessVariablesPeer::VAR_DBCONNECTION, \DbSourcePeer::DBS_UID . " AND " . \DbSourcePeer::PRO_UID . " = '" . $processUid . "'", \Criteria::LEFT_JOIN); - $rsCriteria = \ProcessVariablesPeer::doSelectRS($criteria); - $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); - $rsCriteria->next(); - $arrayVariables = array(); - while ($aRow = $rsCriteria->getRow()) { - $VAR_ACCEPTED_VALUES = G::json_decode($aRow['VAR_ACCEPTED_VALUES'], true); - if (count($VAR_ACCEPTED_VALUES)) { - $encodeAcceptedValues = preg_replace_callback("/\\\\u([a-f0-9]{4})/", function ($m) { - return iconv('UCS-4LE', 'UTF-8', pack('V', hexdec($m[1]))); - }, G::json_encode($VAR_ACCEPTED_VALUES)); - } else { - $encodeAcceptedValues = $aRow['VAR_ACCEPTED_VALUES']; - } - - $arrayVariables[] = array('var_uid' => $aRow['VAR_UID'], - 'prj_uid' => $aRow['PRJ_UID'], - 'var_name' => $aRow['VAR_NAME'], - 'var_field_type' => $aRow['VAR_FIELD_TYPE'], - 'var_field_size' => (int)$aRow['VAR_FIELD_SIZE'], - 'var_label' => $aRow['VAR_LABEL'], - 'var_dbconnection' => $aRow['VAR_DBCONNECTION'] === 'none' ? 'workflow' : $aRow['VAR_DBCONNECTION'], - 'var_dbconnection_label' => $aRow['DBS_SERVER'] !== null ? '[' . $aRow['DBS_SERVER'] . ':' . $aRow['DBS_PORT'] . '] ' . $aRow['DBS_TYPE'] . ': ' . $aRow['DBS_DATABASE_NAME'] : 'PM Database', - 'var_sql' => $aRow['VAR_SQL'], - 'var_null' => (int)$aRow['VAR_NULL'], - 'var_default' => $aRow['VAR_DEFAULT'], - 'var_accepted_values' => $encodeAcceptedValues, - 'inp_doc_uid' => $aRow['INP_DOC_UID']); - $rsCriteria->next(); + //Verify data + $proId = Validator::proUid($processUid, '$prj_uid'); + $variables = ProcessVariables::getVariables($proId); + $arrayVariables = []; + foreach ($variables as $var) { + $varAcceptedValues = G::json_decode($var['VAR_ACCEPTED_VALUES'], true); + if (count($varAcceptedValues)) { + $encodeAcceptedValues = preg_replace_callback("/\\\\u([a-f0-9]{4})/", function ($m) { + return iconv('UCS-4LE', 'UTF-8', pack('V', hexdec($m[1]))); + }, G::json_encode($varAcceptedValues)); + } else { + $encodeAcceptedValues = $var['VAR_ACCEPTED_VALUES']; } - //Return - return $arrayVariables; - } catch (Exception $e) { - throw $e; + $dbconnectionLabel = !is_null($var['DBS_SERVER']) ? + '[' . $var['DBS_SERVER'] . ':' . $var['DBS_PORT'] . '] ' . $var['DBS_TYPE'] . ': ' . $var['DBS_DATABASE_NAME'] : 'PM Database'; + $arrayVariables[] = [ + 'var_uid' => $var['VAR_UID'], + 'prj_uid' => $var['PRJ_UID'], + 'var_name' => $var['VAR_NAME'], + 'var_field_type' => $var['VAR_FIELD_TYPE'], + 'var_field_size' => (int)$var['VAR_FIELD_SIZE'], + 'var_label' => $var['VAR_LABEL'], + 'var_dbconnection' => $var['VAR_DBCONNECTION'] === 'none' ? 'workflow' : $var['VAR_DBCONNECTION'], + 'var_dbconnection_label' => !is_null($var['DBS_SERVER']) ? + '[' . $var['DBS_SERVER'] . ':' . $var['DBS_PORT'] . '] ' . $var['DBS_TYPE'] . ': ' . $var['DBS_DATABASE_NAME'] : 'PM Database', + 'var_sql' => $var['VAR_SQL'], + 'var_null' => (int)$var['VAR_NULL'], + 'var_default' => $var['VAR_DEFAULT'], + 'var_accepted_values' => $encodeAcceptedValues, + 'inp_doc_uid' => $var['INP_DOC_UID'] + ]; } + + return $arrayVariables; } /** diff --git a/workflow/engine/src/ProcessMaker/Core/Installer.php b/workflow/engine/src/ProcessMaker/Core/Installer.php index 1706e684a..e93baa821 100644 --- a/workflow/engine/src/ProcessMaker/Core/Installer.php +++ b/workflow/engine/src/ProcessMaker/Core/Installer.php @@ -376,9 +376,7 @@ class Installer } //ACTIVE ENTERPRISE - ini_set('max_execution_time', '0'); - ini_set('memory_limit', '256M'); $serv = 'http://'; if (isset($_SERVER['HTTPS']) && trim($_SERVER['HTTPS']) != '') { diff --git a/workflow/engine/src/ProcessMaker/Core/System.php b/workflow/engine/src/ProcessMaker/Core/System.php index ee6d1b95b..3fb29ea34 100644 --- a/workflow/engine/src/ProcessMaker/Core/System.php +++ b/workflow/engine/src/ProcessMaker/Core/System.php @@ -36,7 +36,6 @@ class System 'debug_time' => 0, 'debug_calendar' => 0, 'wsdl_cache' => 1, - 'memory_limit' => "256M", 'time_zone' => 'America/New_York', 'expiration_year' => '1', 'memcached' => 0, @@ -77,7 +76,8 @@ class System 'mobile_offline_tables_download_interval' => 24, 'highlight_home_folder_enable' => 0, 'highlight_home_folder_refresh_time' => 10, - 'highlight_home_folder_scope' => 'unassigned' // For now only this list is supported + 'highlight_home_folder_scope' => 'unassigned', // For now only this list is supported + 'disable_advanced_search_case_title_fulltext' => 0 ]; /** @@ -1713,4 +1713,50 @@ class System } return (object) $result; } + + /** + * Parse an url with not encoded password that break the native “parse_url” function. + * @param string $dsn + * @return array + */ + public static function parseUrlWithNotEncodedPassword(string $dsn): array + { + $default = [ + 'scheme' => '', + 'host' => '', + 'port' => '', + 'user' => '', + 'pass' => '', + 'path' => '', + 'query' => '', + ]; + $separator = "://"; + $colon = ":"; + $at = "@"; + + $result = explode($separator, $dsn, 2); + if (empty($result[0]) || empty($result[1])) { + return $default; + } + $scheme = $result[0]; + $urlWithoutScheme = $result[1]; + + $colonPosition = strpos($urlWithoutScheme, $colon); + $user = substr($urlWithoutScheme, 0, $colonPosition); + + $withoutUser = substr($urlWithoutScheme, $colonPosition + 1); + $atPosition = strrpos($withoutUser, $at); + $pass = substr($urlWithoutScheme, $colonPosition + 1, $atPosition); + + $withoutPass = substr($withoutUser, $atPosition + 1); + + $fixedDsn = $scheme . $separator . $user . $colon . urlencode($pass) . $at . $withoutPass; + + $parseDsn = parse_url($fixedDsn); + if ($parseDsn === false) { + return $default; + } + $parseDsn["pass"] = urldecode($parseDsn["pass"]); + return $parseDsn; + } } diff --git a/workflow/engine/src/ProcessMaker/Importer/Importer.php b/workflow/engine/src/ProcessMaker/Importer/Importer.php index 8e34a01fb..263c08fc6 100644 --- a/workflow/engine/src/ProcessMaker/Importer/Importer.php +++ b/workflow/engine/src/ProcessMaker/Importer/Importer.php @@ -1,10 +1,12 @@ verifyIfTheProcessHasStartedCases(); @@ -333,7 +335,7 @@ abstract class Importer $diagram = $project->getStruct($projectUid); $res = $project->updateFromStruct($projectUid, $diagram); } - $this->updateTheProcessOwner($projectUid); + $this->updateProcessInformation($projectUid); return $projectUid; } } catch (\Exception $e) { @@ -342,17 +344,20 @@ abstract class Importer /*----------------------------------********---------------------------------*/ $result = $this->doImport($generateUid); - $this->updateTheProcessOwner($result); + $this->updateProcessInformation($result); return $result; } /** - * This updates the process owner. + * This updates information related to the process + * * @param string $proUid + * * @return void */ - private function updateTheProcessOwner(string $proUid): void + private function updateProcessInformation(string $proUid): void { + // Update the process owner $processOwner = $this->data["usr_uid"]; $currentProcess = $this->getCurrentProcess(); @@ -363,6 +368,17 @@ abstract class Importer $process->update([ 'PRO_CREATE_USER' => $processOwner ]); + + // Update the process Variables with the PRO_ID related + $process = new ModelProcess(); + if ($process->processExists($proUid)) { + $processRow = $process->load($proUid); + $proId = $processRow['PRO_ID']; + $processVar = ProcessVariables::where('PRJ_UID', '=', $proUid); + $processVar->update([ + 'PRO_ID' => $proId + ]); + } } /** @@ -887,7 +903,7 @@ abstract class Importer $this->importData["tables"]["workflow"]["process"] = $this->importData["tables"]["workflow"]["process"][0]; $result = $this->doImport(true, false); - $this->updateTheProcessOwner($result); + $this->updateProcessInformation($result); return ['prj_uid' => $result]; } catch (\Exception $e) { return $e->getMessage(); diff --git a/workflow/engine/src/ProcessMaker/Model/AppNotes.php b/workflow/engine/src/ProcessMaker/Model/AppNotes.php new file mode 100644 index 000000000..2db007ad5 --- /dev/null +++ b/workflow/engine/src/ProcessMaker/Model/AppNotes.php @@ -0,0 +1,11 @@ +join('APPLICATION', function ($join) use ($filterBy, $search, $status, $query) { $join->on('APP_DELEGATION.APP_NUMBER', '=', 'APPLICATION.APP_NUMBER'); if ($filterBy == 'APP_TITLE' && $search) { - // Cleaning "fulltext" operators in order to avoid unexpected results - $search = str_replace(['-', '+', '<', '>', '(', ')', '~', '*', '"'], ['', '', '', '', '', '', '', '', ''], $search); + $config = System::getSystemConfiguration(); + if ((int)$config['disable_advanced_search_case_title_fulltext'] === 0) { + // Cleaning "fulltext" operators in order to avoid unexpected results + $search = str_replace(['-', '+', '<', '>', '(', ')', '~', '*', '"'], + ['', '', '', '', '', '', '', '', ''], $search); - // Build the "fulltext" expression - $search = '+"' . preg_replace('/\s+/', '" +"', addslashes($search)) . '"'; + // Build the "fulltext" expression + $search = '+"' . preg_replace('/\s+/', '" +"', addslashes($search)) . '"'; - // Searching using "fulltext" index - $join->whereRaw("MATCH(APPLICATION.APP_TITLE) AGAINST('{$search}' IN BOOLEAN MODE)"); + // Searching using "fulltext" index + $join->whereRaw("MATCH(APPLICATION.APP_TITLE) AGAINST('{$search}' IN BOOLEAN MODE)"); + } else { + // Searching using "like" operator + $join->where('APPLICATION.APP_TITLE', 'LIKE', "%${search}%"); + } } // Based on the below, we can further limit the join so that we have a smaller data set based on join criteria switch ($status) { diff --git a/workflow/engine/src/ProcessMaker/Model/ProcessVariables.php b/workflow/engine/src/ProcessMaker/Model/ProcessVariables.php index 37fdc9347..19693cab9 100644 --- a/workflow/engine/src/ProcessMaker/Model/ProcessVariables.php +++ b/workflow/engine/src/ProcessMaker/Model/ProcessVariables.php @@ -3,6 +3,7 @@ namespace ProcessMaker\Model; use Illuminate\Database\Eloquent\Model; +use Illuminate\Support\Facades\DB; class ProcessVariables extends Model { @@ -10,19 +11,89 @@ class ProcessVariables extends Model protected $table = 'PROCESS_VARIABLES'; // No timestamps public $timestamps = false; - //primary key + // Primary key protected $primaryKey = 'VAR_UID'; + // The IDs are auto-incrementing public $incrementing = false; + /** + * The model's default values for attributes. + * + * @var array + */ + protected $attributes = [ + 'VAR_FIELD_SIZE' => 0, + 'VAR_DBCONNECTION' => '', + 'VAR_SQL' => '', + 'VAR_NULL' => 0, + 'VAR_DEFAULT' => '', + 'VAR_ACCEPTED_VALUES' => '[]', + 'INP_DOC_UID' => '', + ]; + /** + * The attributes that are mass assignable. + * + * @var array + */ + protected $fillable = [ + 'VAR_UID', + 'PRJ_UID', + 'PRO_ID', + 'VAR_NAME', + 'VAR_FIELD_TYPE', + 'VAR_FIELD_TYPE_ID', + 'VAR_FIELD_SIZE', + 'VAR_LABEL', + 'VAR_DBCONNECTION', + 'VAR_SQL', + 'VAR_NULL', + 'VAR_DEFAULT', + 'VAR_ACCEPTED_VALUES', + 'INP_DOC_UID' + ]; /** * Scope a query to filter an specific process * * @param \Illuminate\Database\Eloquent\Builder $query - * @param string $columns + * @param string $proUid * @return \Illuminate\Database\Eloquent\Builder */ - public function scopeProcess($query, string $proUID) + public function scopeProcess($query, string $proUid) { - return $query->where('PRJ_UID', $proUID); + return $query->where('PRJ_UID', $proUid); + } + + /** + * Scope a query to filter an specific process + * + * @param \Illuminate\Database\Eloquent\Builder $query + * @param int $proId + * @return \Illuminate\Database\Eloquent\Builder + */ + public function scopeProcessId($query, int $proId) + { + return $query->where('PRO_ID', $proId); + } + /** + * Return the variables list + * + * @param int $proId + * + * @return array + */ + public static function getVariables(int $proId) + { + $query = ProcessVariables::query()->select(); + $query->leftJoin('DB_SOURCE', function ($join) { + $join->on('DB_SOURCE.PRO_ID', '=', 'PROCESS_VARIABLES.PRO_ID'); + }); + $query->where('PROCESS_VARIABLES.PRO_ID', $proId); + $results = $query->get(); + $variablesList = []; + $results->each(function ($item, $key) use (&$variablesList) { + $variablesList[] = $item->toArray(); + }); + + return $variablesList; } } \ No newline at end of file diff --git a/workflow/engine/src/ProcessMaker/Util/WsMessageResponse.php b/workflow/engine/src/ProcessMaker/Util/WsMessageResponse.php deleted file mode 100644 index ec6a1f92c..000000000 --- a/workflow/engine/src/ProcessMaker/Util/WsMessageResponse.php +++ /dev/null @@ -1,32 +0,0 @@ -appMessUid; - } - - /** - * Set the appMessUid - * - * @param string $v - * @return void - */ - public function setAppMessUid($v) - { - $this->appMessUid = $v; - } -} - diff --git a/workflow/engine/templates/admin/system.js b/workflow/engine/templates/admin/system.js index 7dc38aa8e..e8d14efad 100644 --- a/workflow/engine/templates/admin/system.js +++ b/workflow/engine/templates/admin/system.js @@ -96,21 +96,6 @@ Ext.onReady(function(){ items: [ cmbTimeZone, { - xtype: 'numberfield', - id: 'memory_limit', - name: 'memory_limit', - fieldLabel: _('ID_MEMORY_LIMIT'), - allowBlank: false, - allowDecimals: false, - minValue: -1, - autoCreate: {tag: "input", type: "text", autocomplete: "off", maxlength: 15}, - value: sysConf.memory_limit, - listeners: { - change: function () { - changeSettings(); - } - } - }, { xtype: 'numberfield', id: 'max_life_time', name: 'max_life_time', diff --git a/workflow/engine/templates/cases/open.js b/workflow/engine/templates/cases/open.js index 47bf3716d..42d32d9ca 100644 --- a/workflow/engine/templates/cases/open.js +++ b/workflow/engine/templates/cases/open.js @@ -1073,7 +1073,7 @@ Ext.onReady(function(){ params: { action: 'cancelCase', NOTE_REASON: noteReasonTxt, - NOTIFY_PAUSE: notifyReasonVal + NOTIFY_CANCEL: notifyReasonVal }, success: function (result, request) { try { diff --git a/workflow/public_html/bootstrap.php b/workflow/public_html/bootstrap.php index dd9348d49..cf58c3128 100644 --- a/workflow/public_html/bootstrap.php +++ b/workflow/public_html/bootstrap.php @@ -52,7 +52,6 @@ $config = PmSystem::getSystemConfiguration(); $filter = new InputFilter(); $config['display_errors'] = $filter->validateInput($config['display_errors']); $config['error_reporting'] = $filter->validateInput($config['error_reporting']); -$config['memory_limit'] = $filter->validateInput($config['memory_limit']); $config['wsdl_cache'] = $filter->validateInput($config['wsdl_cache'], 'int'); $config['time_zone'] = $filter->validateInput($config['time_zone']); // Do not change any of these settings directly, use env.ini instead @@ -60,7 +59,6 @@ ini_set('display_errors', $filter->validateInput($config['display_errors'])); ini_set('error_reporting', $filter->validateInput($config['error_reporting'])); ini_set('short_open_tag', 'On'); ini_set('default_charset', "UTF-8"); -ini_set('memory_limit', $filter->validateInput($config['memory_limit'])); ini_set('soap.wsdl_cache_enabled', $config['wsdl_cache']); ini_set('date.timezone', (isset($_SESSION['__SYSTEM_UTC_TIME_ZONE__']) && $_SESSION['__SYSTEM_UTC_TIME_ZONE__']) ? 'UTC' : $config['time_zone']); //Set Time Zone diff --git a/workflow/public_html/sysGeneric.php b/workflow/public_html/sysGeneric.php index bb5c9eb63..a18f7ded0 100644 --- a/workflow/public_html/sysGeneric.php +++ b/workflow/public_html/sysGeneric.php @@ -315,7 +315,6 @@ ini_set('display_errors', $config['display_errors']); ini_set('error_reporting', $config['error_reporting']); ini_set('short_open_tag', 'On'); ini_set('default_charset', "UTF-8"); -ini_set('memory_limit', $config['memory_limit']); ini_set('soap.wsdl_cache_enabled', $config['wsdl_cache']); ini_set('date.timezone', (isset($_SESSION['__SYSTEM_UTC_TIME_ZONE__']) && $_SESSION['__SYSTEM_UTC_TIME_ZONE__']) ? 'UTC' : $config['time_zone']); //Set Time Zone @@ -572,7 +571,6 @@ ini_set('display_errors', $config['display_errors']); ini_set('error_reporting', $config['error_reporting']); ini_set('short_open_tag', 'On'); ini_set('default_charset', "UTF-8"); -ini_set('memory_limit', $config['memory_limit']); ini_set('soap.wsdl_cache_enabled', $config['wsdl_cache']); ini_set('date.timezone', TIME_ZONE); //Set Time Zone