diff --git a/database/factories/DepartmentFactory.php b/database/factories/DepartmentFactory.php new file mode 100644 index 000000000..1a4cc3ae5 --- /dev/null +++ b/database/factories/DepartmentFactory.php @@ -0,0 +1,16 @@ +define(\ProcessMaker\Model\Department::class, function (Faker $faker) { + return [ + 'DEP_UID' => G::generateUniqueID(), + 'DEP_TITLE' => $faker->sentence(2), + 'DEP_PARENT' => '', + 'DEP_MANAGER' => '', + 'DEP_LOCATION' => 0, + 'DEP_STATUS' => 'ACTIVE', + 'DEP_REF_CODE' => '', + 'DEP_LDAP_DN' => '', + ]; +}); diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/ValidatorTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/ValidatorTest.php new file mode 100644 index 000000000..dbbc875d6 --- /dev/null +++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/ValidatorTest.php @@ -0,0 +1,504 @@ +expectException(Exception::class); + $result = Validator::depUid(''); + } + + /** + * Test the exception + * + * @covers \ProcessMaker\BusinessModel\Validator::depUid() + * @test + */ + public function it_test_exception_dep_uid_doesnot_exist() + { + $this->expectException(Exception::class); + $fakeUid = G::generateUniqueID(); + $result = Validator::depUid($fakeUid); + } + + /** + * Test the exception + * + * @covers \ProcessMaker\BusinessModel\Validator::depUid() + * @test + */ + public function it_test_exception_dep_uid_exist() + { + $table = factory(Department::class)->create(); + DB::commit(); + $result = Validator::depUid($table->DEP_UID); + } + + /** + * Test the exception + * + * @covers \ProcessMaker\BusinessModel\Validator::depStatus() + * @test + */ + public function it_test_exception_dep_status() + { + $result = Validator::depStatus('ACTIVE'); + $this->assertNotEmpty($result); + $this->expectException(Exception::class); + $result = Validator::depStatus('OTHER'); + } + + /** + * Test the exception + * + * @covers \ProcessMaker\BusinessModel\Validator::usrUid() + * @test + */ + public function it_test_exception_usr_uid() + { + $this->expectException(Exception::class); + $result = Validator::usrUid(''); + } + + /** + * Test the exception + * + * @covers \ProcessMaker\BusinessModel\Validator::usrUid() + * @test + */ + public function it_test_exception_usr_uid_doesnot_exist() + { + $this->expectException(Exception::class); + $fakeUid = G::generateUniqueID(); + $result = Validator::usrUid($fakeUid); + } + + /** + * Test the exception + * + * @covers \ProcessMaker\BusinessModel\Validator::usrUid() + * @test + */ + public function it_test_exception_usr_uid_exist() + { + $table = factory(User::class)->create(); + DB::commit(); + $result = Validator::usrUid($table->USR_UID); + $this->assertNotEmpty($result); + } + + /** + * Test the exception + * + * @covers \ProcessMaker\BusinessModel\Validator::appUid() + * @test + */ + public function it_test_exception_app_uid() + { + $this->expectException(Exception::class); + $result = Validator::appUid(''); + } + + /** + * Test the exception + * + * @covers \ProcessMaker\BusinessModel\Validator::appUid() + * @test + */ + public function it_test_exception_app_uid_not_32() + { + $this->expectException(Exception::class); + $result = Validator::appUid('null'); + } + + /** + * Test the exception + * + * @covers \ProcessMaker\BusinessModel\Validator::appUid() + * @test + */ + public function it_test_exception_app_uid_doesnot_exist() + { + $this->expectException(Exception::class); + $fakeUid = G::generateUniqueID(); + $result = Validator::appUid($fakeUid); + } + + /** + * Test the exception + * + * @covers \ProcessMaker\BusinessModel\Validator::appUid() + * @test + */ + public function it_test_exception_app_uid_exist() + { + $table = factory(Application::class)->create(); + DB::commit(); + $result = Validator::appUid($table->APP_UID); + $this->assertNotEmpty($result); + } + + /** + * Test the exception + * + * @covers \ProcessMaker\BusinessModel\Validator::triUid() + * @test + */ + public function it_test_exception_tri_uid() + { + $this->expectException(Exception::class); + $result = Validator::triUid(''); + } + + /** + * Test the exception + * + * @covers \ProcessMaker\BusinessModel\Validator::triUid() + * @test + */ + public function it_test_exception_tri_uid_doesnot_exist() + { + $this->expectException(Exception::class); + $fakeUid = G::generateUniqueID(); + $result = Validator::triUid($fakeUid); + } + + /** + * Test the exception + * + * @covers \ProcessMaker\BusinessModel\Validator::triUid() + * @test + */ + public function it_test_exception_tri_uid_exist() + { + $table = factory(Triggers::class)->create(); + DB::commit(); + $result = Validator::triUid($table->TRI_UID); + $this->assertNotEmpty($result); + } + + /** + * Test the exception + * + * @covers \ProcessMaker\BusinessModel\Validator::proUid() + * @test + */ + public function it_test_exception_pro_uid() + { + $this->expectException(Exception::class); + $result = Validator::proUid(''); + } + + /** + * Test the exception + * + * @covers \ProcessMaker\BusinessModel\Validator::proUid() + * @test + */ + public function it_test_exception_pro_uid_doesnot_exist() + { + $this->expectException(Exception::class); + $fakeUid = G::generateUniqueID(); + $result = Validator::proUid($fakeUid); + } + + /** + * Test the exception + * + * @covers \ProcessMaker\BusinessModel\Validator::proUid() + * @test + */ + public function it_test_exception_pro_uid_exist() + { + $table = factory(Process::class)->create(); + DB::commit(); + $result = Validator::proUid($table->PRO_UID); + $this->assertNotEmpty($result); + } + + /** + * Test the exception + * + * @covers \ProcessMaker\BusinessModel\Validator::catUid() + * @test + */ + public function it_test_exception_cat_uid() + { + $this->expectException(Exception::class); + $result = Validator::catUid(''); + } + + /** + * Test the exception + * + * @covers \ProcessMaker\BusinessModel\Validator::catUid() + * @test + */ + public function it_test_exception_cat_uid_doesnot_exist() + { + $this->expectException(Exception::class); + $fakeUid = G::generateUniqueID(); + $result = Validator::catUid($fakeUid); + } + + /** + * Test the exception + * + * @covers \ProcessMaker\BusinessModel\Validator::catUid() + * @test + */ + public function it_test_exception_cat_uid_exist() + { + $table = factory(ProcessCategory::class)->create(); + DB::commit(); + $result = Validator::catUid($table->CATEGORY_UID); + $this->assertNotEmpty($result); + } + + /** + * Test the exception + * + * @covers \ProcessMaker\BusinessModel\Validator::isDate() + * @test + */ + public function it_test_exception_is_date() + { + $this->expectException(Exception::class); + $result = Validator::isDate(''); + } + + /** + * Test the exception + * + * @covers \ProcessMaker\BusinessModel\Validator::isDate() + * @test + */ + public function it_test_exception_is_date_invalid_format() + { + $this->expectException(Exception::class); + $result = Validator::isDate('15-Feb-2009', 'j-M'); + } + + /** + * Test the exception + * + * @covers \ProcessMaker\BusinessModel\Validator::isDate() + * @test + */ + public function it_test_exception_is_date_exist() + { + $result = Validator::isDate('15-Feb-2009', 'j-M-Y'); + $this->assertNotEmpty($result); + } + + /** + * Test the exception + * + * @covers \ProcessMaker\BusinessModel\Validator::isArray() + * @test + */ + public function it_test_exception_is_array() + { + $this->expectException(Exception::class); + $result = Validator::isArray('', 'nameField'); + } + + /** + * Test the exception + * + * @covers \ProcessMaker\BusinessModel\Validator::isArray() + * @test + */ + public function it_test_is_array() + { + $result = Validator::isArray(['hello'], 'nameField'); + $this->assertTrue($result == null); + } + + /** + * Test the exception + * + * @covers \ProcessMaker\BusinessModel\Validator::isString() + * @test + */ + public function it_test_exception_is_string() + { + $this->expectException(Exception::class); + $result = Validator::isString(1, 'nameField'); + } + + /** + * Test the exception + * + * @covers \ProcessMaker\BusinessModel\Validator::isString() + * @test + */ + public function it_test_is_string() + { + $result = Validator::isString('hello', 'nameField'); + $this->assertTrue($result == null); + } + + /** + * Test the exception + * + * @covers \ProcessMaker\BusinessModel\Validator::isInteger() + * @test + */ + public function it_test_exception_is_integer() + { + $this->expectException(Exception::class); + $result = Validator::isInteger('', 'nameField'); + } + + /** + * Test the exception + * + * @covers \ProcessMaker\BusinessModel\Validator::isInteger() + * @test + */ + public function it_test_is_integer() + { + $result = Validator::isInteger(1, 'nameField'); + $this->assertTrue($result == null); + } + + /** + * Test the exception + * + * @covers \ProcessMaker\BusinessModel\Validator::isBoolean() + * @test + */ + public function it_test_exception_is_bool() + { + $this->expectException(Exception::class); + $result = Validator::isBoolean('', 'nameField'); + } + + /** + * Test the exception + * + * @covers \ProcessMaker\BusinessModel\Validator::isBoolean() + * @test + */ + public function it_test_is_bool() + { + $result = Validator::isBoolean(true, 'nameField'); + $this->assertTrue($result == null); + } + + /** + * Test the exception + * + * @covers \ProcessMaker\BusinessModel\Validator::isNotEmpty() + * @test + */ + public function it_test_exception_is_not_empty() + { + $this->expectException(Exception::class); + $result = Validator::isNotEmpty('', 'nameField'); + } + + /** + * Test the exception + * + * @covers \ProcessMaker\BusinessModel\Validator::isNotEmpty() + * @test + */ + public function it_test_is_not_empty() + { + $result = Validator::isNotEmpty('fieldValue', 'nameField'); + $this->assertTrue($result == null); + } + + /** + * Test the exception + * + * @covers \ProcessMaker\BusinessModel\Validator::isValidVariableName() + * @test + */ + public function it_test_exception_is_valid_variable() + { + $this->expectException(Exception::class); + $result = Validator::isValidVariableName('1field-t'); + } + + /** + * Test the exception + * + * @covers \ProcessMaker\BusinessModel\Validator::isValidVariableName() + * @test + */ + public function it_test_is_valid_variable() + { + $result = Validator::isValidVariableName('varName'); + $this->assertTrue($result == null); + } + + /** + * Test the exception + * + * @covers \ProcessMaker\BusinessModel\Validator::throwExceptionIfDataIsNotArray() + * @test + */ + public function it_test_exception_throw_exception_if_data_is_not_array() + { + $this->expectException(Exception::class); + $result = Validator::throwExceptionIfDataIsNotArray('', 'nameField'); + } + + /** + * Test the exception + * + * @covers \ProcessMaker\BusinessModel\Validator::throwExceptionIfDataNotMetIso8601Format() + * @test + */ + public function it_test_exception_throw_exception_if_data_not_meet_date_format_string() + { + $this->expectException(Exception::class); + $_SESSION['__SYSTEM_UTC_TIME_ZONE__'] = 1; + $result = Validator::throwExceptionIfDataNotMetIso8601Format('value', 'dateFrom'); + } + + /** + * Test the exception + * + * @covers \ProcessMaker\BusinessModel\Validator::throwExceptionIfDataNotMetIso8601Format() + * @test + */ + public function it_test_exception_throw_exception_if_data_not_meet_date_format_array() + { + $_SESSION['__SYSTEM_UTC_TIME_ZONE__'] = 1; + $data = []; + $data['dateFrom'] = date('Y-m-d'); + $data['dateTo'] = date('Y-m-d'); + $result = Validator::throwExceptionIfDataNotMetIso8601Format($data, 'dateFrom'); + $this->assertTrue($result == null); + } +} \ No newline at end of file diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php index 49953f5fb..91f771ef7 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php @@ -3793,6 +3793,9 @@ class Cases public function uploadFiles($userUid, $appUid, $varName, $inpDocUid = -1, $appDocUid = null, $delegationIndex = null) { $response = []; + // Review the appUid + Validator::appUid($appUid, '$appUid'); + if (isset($_FILES["form"]["name"]) && count($_FILES["form"]["name"]) > 0) { // Get the delIndex related to the case $cases = new ClassesCases(); diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Validator.php b/workflow/engine/src/ProcessMaker/BusinessModel/Validator.php index db86a326e..bf89eb235 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Validator.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Validator.php @@ -2,60 +2,64 @@ namespace ProcessMaker\BusinessModel; + +use Application; +use DateTime; +use Department; use Exception; use G; +use Process; +use ProcessMaker\Util\DateTime as UtilDateTime; +use ProcessCategory; +use Triggers; +use Users; /** * Validator fields * - * @author Brayan Pereyra (Cochalo) - * @copyright Colosa - Bolivia - * * @protected */ class Validator { /** * Validate dep_uid - * @var string $dep_uid . Uid for Departament - * @var string $nameField . Name of field for message + * + * @param string $dep_uid . Uid for Departament + * @param string $nameField . Name of field for message * * @access public - * @author Brayan Pereyra (Cochalo) - * @copyright Colosa - Bolivia * * @return string */ static public function depUid($dep_uid, $nameField = 'dep_uid') { $dep_uid = trim($dep_uid); - if ($dep_uid == '') { - throw (new Exception(G::LoadTranslation("ID_DEPARTMENT_NOT_EXIST", array($nameField, '')))); + if (empty($dep_uid)) { + throw new Exception(G::LoadTranslation("ID_DEPARTMENT_NOT_EXIST", [$nameField, ''])); } - $oDepartment = new \Department(); - if (!($oDepartment->existsDepartment($dep_uid))) { - throw (new Exception(G::LoadTranslation("ID_DEPARTMENT_NOT_EXIST", array($nameField, $dep_uid)))); + $department = new Department(); + if (!($department->existsDepartment($dep_uid))) { + throw new Exception(G::LoadTranslation("ID_DEPARTMENT_NOT_EXIST", [$nameField, $dep_uid])); } return $dep_uid; } /** * Validate dep_status - * @var string $dep_uid . Uid for Departament - * @var string $nameField . Name of field for message + * + * @param string $dep_uid . Uid for Departament + * @param string $nameField . Name of field for message * * @access public - * @author Brayan Pereyra (Cochalo) - * @copyright Colosa - Bolivia * * @return string */ static public function depStatus($dep_status) { $dep_status = trim($dep_status); - $values = array('ACTIVE', 'INACTIVE'); + $values = ['ACTIVE', 'INACTIVE']; if (!in_array($dep_status, $values)) { - throw (new Exception(G::LoadTranslation("ID_DEPARTMENT_NOT_EXIST", array('dep_status', $dep_status)))); + throw new Exception(G::LoadTranslation("ID_DEPARTMENT_NOT_EXIST", ['dep_status', $dep_status])); } return $dep_status; } @@ -67,20 +71,18 @@ class Validator * @param string $nameField . Name of field for message * * @access public - * @author Brayan Pereyra (Cochalo) - * @copyright Colosa - Bolivia * * @return string */ static public function usrUid($usr_uid, $nameField = 'usr_uid') { $usr_uid = trim($usr_uid); - if ($usr_uid == '') { - throw (new Exception(G::LoadTranslation("ID_USER_NOT_EXIST", array($nameField, '')))); + if (empty($usr_uid)) { + throw new Exception(G::LoadTranslation("ID_USER_NOT_EXIST", [$nameField, ''])); } - $oUsers = new \Users(); - if (!($oUsers->userExists($usr_uid))) { - throw (new Exception(G::LoadTranslation("ID_USER_NOT_EXIST", array($nameField, $usr_uid)))); + $users = new Users(); + if (!($users->userExists($usr_uid))) { + throw new Exception(G::LoadTranslation("ID_USER_NOT_EXIST", [$nameField, $usr_uid])); } return $usr_uid; } @@ -89,23 +91,24 @@ class Validator * Validate app_uid * * @param string $app_uid , Uid for application - * @param string $nameField . Name of field for message + * @param string $nameField , Name of field for message * * @access public - * @author Brayan Pereyra (Cochalo) - * @copyright Colosa - Bolivia * * @return string */ static public function appUid($app_uid, $nameField = 'app_uid') { $app_uid = trim($app_uid); - if ($app_uid == '') { - throw (new Exception(G::LoadTranslation("ID_APPLICATION_NOT_EXIST", array($nameField, '')))); + if (empty($app_uid)) { + throw new Exception(G::LoadTranslation("ID_APPLICATION_NOT_EXIST", [$nameField, ''])); } - $oApplication = new \Application(); - if (!($oApplication->exists($app_uid))) { - throw (new Exception(G::LoadTranslation("ID_APPLICATION_NOT_EXIST", array($nameField, $app_uid)))); + if (strlen($app_uid) !== 32) { + throw new Exception(G::LoadTranslation("ID_CASE_NOT_EXISTS")); + } + $application = new Application(); + if (!($application->exists($app_uid))) { + throw new Exception(G::LoadTranslation("ID_APPLICATION_NOT_EXIST", [$nameField, $app_uid])); } return $app_uid; } @@ -117,20 +120,18 @@ class Validator * @param string $nameField . Name of field for message * * @access public - * @author Brayan Pereyra (Cochalo) - * @copyright Colosa - Bolivia * * @return string */ static public function triUid($tri_uid, $nameField = 'tri_uid') { $tri_uid = trim($tri_uid); - if ($tri_uid == '') { - throw (new Exception(G::LoadTranslation("ID_TRIGGER_NOT_EXIST", array($nameField, '')))); + if (empty($tri_uid)) { + throw new Exception(G::LoadTranslation("ID_TRIGGER_NOT_EXIST", [$nameField, ''])); } - $oTriggers = new \Triggers(); - if (!($oTriggers->TriggerExists($tri_uid))) { - throw (new Exception(G::LoadTranslation("ID_TRIGGER_NOT_EXIST", array($nameField, $tri_uid)))); + $triggers = new Triggers(); + if (!($triggers->TriggerExists($tri_uid))) { + throw new Exception(G::LoadTranslation("ID_TRIGGER_NOT_EXIST", [$nameField, $tri_uid])); } return $tri_uid; } @@ -149,12 +150,12 @@ class Validator { $proUid = trim($proUid); if (empty($proUid)) { - throw (new Exception(G::LoadTranslation("ID_PROCESS_NOT_EXIST", array($nameField, '')))); + throw new Exception(G::LoadTranslation("ID_PROCESS_NOT_EXIST", [$nameField, ''])); } - $process = new \Process(); + $process = new Process(); $proId = 0; if (!($process->exists($proUid))) { - throw (new Exception(G::LoadTranslation("ID_PROCESS_NOT_EXIST", array($nameField, $proUid)))); + throw new Exception(G::LoadTranslation("ID_PROCESS_NOT_EXIST", [$nameField, $proUid])); } else { $proId = $process->load($proUid)['PRO_ID']; } @@ -169,20 +170,18 @@ class Validator * @param string $nameField . Name of field for message * * @access public - * @author Brayan Pereyra (Cochalo) - * @copyright Colosa - Bolivia * * @return string */ static public function catUid($cat_uid, $nameField = 'cat_uid') { $cat_uid = trim($cat_uid); - if ($cat_uid == '') { - throw (new Exception(G::LoadTranslation("ID_CATEGORY_NOT_EXIST", array($nameField, '')))); + if (empty($cat_uid)) { + throw new Exception(G::LoadTranslation("ID_CATEGORY_NOT_EXIST", [$nameField, ''])); } - $oCategory = new \ProcessCategory(); - if (!($oCategory->exists($cat_uid))) { - throw (new Exception(G::LoadTranslation("ID_CATEGORY_NOT_EXIST", array($nameField, $cat_uid)))); + $category = new ProcessCategory(); + if (!($category->exists($cat_uid))) { + throw new Exception(G::LoadTranslation("ID_CATEGORY_NOT_EXIST", [$nameField, $cat_uid])); } return $cat_uid; } @@ -191,123 +190,123 @@ class Validator * Validate date * * @param string $date , Date for validate + * @param string $format * @param string $nameField . Name of field for message * * @access public - * @author Brayan Pereyra (Cochalo) - * @copyright Colosa - Bolivia * * @return string */ static public function isDate($date, $format = 'Y-m-d H:i:s', $nameField = 'app_uid') { $date = trim($date); - if ($date == '') { - throw (new Exception(G::LoadTranslation("ID_DATE_NOT_VALID", array('', $format)))); + if (empty($date)) { + throw new Exception(G::LoadTranslation("ID_DATE_NOT_VALID", ['', $format])); } - $d = \DateTime::createFromFormat($format, $date); + $d = DateTime::createFromFormat($format, $date); if (!($d && $d->format($format) == $date)) { - throw (new Exception(G::LoadTranslation("ID_DATE_NOT_VALID", array($date, $format)))); + throw new Exception(G::LoadTranslation("ID_DATE_NOT_VALID", [$date, $format])); } return $date; } /** * Validate is array - * @var array $field . Field type array + * + * @param string $field + * @param string $nameField * * @access public - * @author Brayan Pereyra (Cochalo) - * @copyright Colosa - Bolivia * * @return void */ static public function isArray($field, $nameField) { if (!is_array($field)) { - throw (new Exception(G::LoadTranslation("ID_INVALID_VALUE_ARRAY", array($nameField)))); + throw new Exception(G::LoadTranslation("ID_INVALID_VALUE_ARRAY", [$nameField])); } } /** * Validate is string - * @var array $field . Field type string + * + * @param string $field + * @param string $nameField * * @access public - * @author Brayan Pereyra (Cochalo) - * @copyright Colosa - Bolivia * * @return void */ static public function isString($field, $nameField) { if (!is_string($field)) { - throw (new Exception(G::LoadTranslation("ID_INVALID_VALUE_STRING", array($nameField)))); + throw new Exception(G::LoadTranslation("ID_INVALID_VALUE_STRING", [$nameField])); } } /** * Validate is integer - * @var array $field . Field type integer + * + * @param string $field + * @param string $nameField * * @access public - * @author Brayan Pereyra (Cochalo) - * @copyright Colosa - Bolivia * * @return void */ static public function isInteger($field, $nameField) { if (!is_integer($field)) { - throw (new Exception(G::LoadTranslation("ID_INVALID_VALUE_INTEGER", array($nameField)))); + throw new Exception(G::LoadTranslation("ID_INVALID_VALUE_INTEGER", [$nameField])); } } /** * Validate is boolean - * @var boolean $field . Field type boolean + * + * @param string $field + * @param string $nameField * * @access public - * @author Brayan Pereyra (Cochalo) - * @copyright Colosa - Bolivia * * @return void */ static public function isBoolean($field, $nameField) { if (!is_bool($field)) { - throw (new Exception(G::LoadTranslation("ID_INVALID_VALUE_BOOLEAN", array($nameField)))); + throw new Exception(G::LoadTranslation("ID_INVALID_VALUE_BOOLEAN", [$nameField])); } } /** - * Validate is boolean - * @var boolean $field . Field type boolean + * Validate is empty + * + * @param string $field + * @param string $nameField * * @access public - * @author Brayan Pereyra (Cochalo) - * @copyright Colosa - Bolivia * * @return void */ static public function isNotEmpty($field, $nameField) { if (empty($field)) { - throw (new Exception(G::LoadTranslation("ID_INVALID_VALUE_IS_EMPTY", array($nameField)))); + throw new Exception(G::LoadTranslation("ID_INVALID_VALUE_IS_EMPTY", [$nameField])); } } /** * Validate a variable name + * * @param $nameField - * @throws \Exception + * * @return void */ static public function isValidVariableName($nameField) { $resp = preg_match(config('constants.validation.pmVariable.regEx'), $nameField, $matches); if (isset($resp) && $resp === 0) { - throw (new Exception(G::LoadTranslation("ID_INVALID_NAME", array($nameField)))); + throw new Exception(G::LoadTranslation("ID_INVALID_NAME", [$nameField])); } } @@ -319,11 +318,11 @@ class Validator * * return void Throw exception if data is not array */ - public function throwExceptionIfDataIsNotArray($data, $dataNameForException) + static public function throwExceptionIfDataIsNotArray($data, $dataNameForException) { try { if (!is_array($data)) { - throw new Exception(G::LoadTranslation("ID_INVALID_VALUE_THIS_MUST_BE_ARRAY", array($dataNameForException))); + throw new Exception(G::LoadTranslation("ID_INVALID_VALUE_THIS_MUST_BE_ARRAY", [$dataNameForException])); } } catch (Exception $e) { throw $e; @@ -338,11 +337,11 @@ class Validator * * return void Throw exception if data is empty */ - public function throwExceptionIfDataIsEmpty($data, $dataNameForException) + static public function throwExceptionIfDataIsEmpty($data, $dataNameForException) { try { if (empty($data)) { - throw new Exception(G::LoadTranslation("ID_INVALID_VALUE_CAN_NOT_BE_EMPTY", array($dataNameForException))); + throw new Exception(G::LoadTranslation("ID_INVALID_VALUE_CAN_NOT_BE_EMPTY", [$dataNameForException])); } } catch (Exception $e) { throw $e; @@ -364,8 +363,8 @@ class Validator return; } - $regexpDate = \ProcessMaker\Util\DateTime::REGEXPDATE; - $regexpTime = \ProcessMaker\Util\DateTime::REGEXPTIME; + $regexpDate = UtilDateTime::REGEXPDATE; + $regexpTime = UtilDateTime::REGEXPTIME; $regexpIso8601 = $regexpDate . 'T' . $regexpTime . '[\+\-]\d{2}:\d{2}'; @@ -417,7 +416,7 @@ class Validator (int)($value) < 0 ) ) { - return \G::LoadTranslation('ID_INVALID_VALUE_EXPECTING_POSITIVE_INTEGER', [$nameForException]); + return G::LoadTranslation('ID_INVALID_VALUE_EXPECTING_POSITIVE_INTEGER', [$nameForException]); } } diff --git a/workflow/engine/src/ProcessMaker/Model/Department.php b/workflow/engine/src/ProcessMaker/Model/Department.php new file mode 100644 index 000000000..3894a6d6a --- /dev/null +++ b/workflow/engine/src/ProcessMaker/Model/Department.php @@ -0,0 +1,17 @@ +