Merged in bugfix/PMCORE-935 (pull request #8442)
PMCORE-935 Approved-by: Julio Cesar Laura Avendaño
This commit is contained in:
16
database/factories/DepartmentFactory.php
Normal file
16
database/factories/DepartmentFactory.php
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Faker\Generator as Faker;
|
||||||
|
|
||||||
|
$factory->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' => '',
|
||||||
|
];
|
||||||
|
});
|
||||||
@@ -0,0 +1,504 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace ProcessMaker\BusinessModel;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use G;
|
||||||
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use ProcessMaker\BusinessModel\Validator;
|
||||||
|
use ProcessMaker\Model\Application;
|
||||||
|
use ProcessMaker\Model\Department;
|
||||||
|
use ProcessMaker\Model\Process;
|
||||||
|
use ProcessMaker\Model\ProcessCategory;
|
||||||
|
use ProcessMaker\Model\Triggers;
|
||||||
|
use ProcessMaker\Model\User;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @coversDefaultClass ProcessMaker\BusinessModel\Validator
|
||||||
|
*/
|
||||||
|
class ValidatorTest extends TestCase
|
||||||
|
{
|
||||||
|
use DatabaseTransactions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the exception
|
||||||
|
*
|
||||||
|
* @covers \ProcessMaker\BusinessModel\Validator::depUid()
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_test_exception_dep_uid()
|
||||||
|
{
|
||||||
|
$this->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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3793,6 +3793,9 @@ class Cases
|
|||||||
public function uploadFiles($userUid, $appUid, $varName, $inpDocUid = -1, $appDocUid = null, $delegationIndex = null)
|
public function uploadFiles($userUid, $appUid, $varName, $inpDocUid = -1, $appDocUid = null, $delegationIndex = null)
|
||||||
{
|
{
|
||||||
$response = [];
|
$response = [];
|
||||||
|
// Review the appUid
|
||||||
|
Validator::appUid($appUid, '$appUid');
|
||||||
|
|
||||||
if (isset($_FILES["form"]["name"]) && count($_FILES["form"]["name"]) > 0) {
|
if (isset($_FILES["form"]["name"]) && count($_FILES["form"]["name"]) > 0) {
|
||||||
// Get the delIndex related to the case
|
// Get the delIndex related to the case
|
||||||
$cases = new ClassesCases();
|
$cases = new ClassesCases();
|
||||||
|
|||||||
@@ -2,60 +2,64 @@
|
|||||||
|
|
||||||
namespace ProcessMaker\BusinessModel;
|
namespace ProcessMaker\BusinessModel;
|
||||||
|
|
||||||
|
|
||||||
|
use Application;
|
||||||
|
use DateTime;
|
||||||
|
use Department;
|
||||||
use Exception;
|
use Exception;
|
||||||
use G;
|
use G;
|
||||||
|
use Process;
|
||||||
|
use ProcessMaker\Util\DateTime as UtilDateTime;
|
||||||
|
use ProcessCategory;
|
||||||
|
use Triggers;
|
||||||
|
use Users;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validator fields
|
* Validator fields
|
||||||
*
|
*
|
||||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
||||||
* @copyright Colosa - Bolivia
|
|
||||||
*
|
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
class Validator
|
class Validator
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Validate dep_uid
|
* 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
|
* @access public
|
||||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
||||||
* @copyright Colosa - Bolivia
|
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
static public function depUid($dep_uid, $nameField = 'dep_uid')
|
static public function depUid($dep_uid, $nameField = 'dep_uid')
|
||||||
{
|
{
|
||||||
$dep_uid = trim($dep_uid);
|
$dep_uid = trim($dep_uid);
|
||||||
if ($dep_uid == '') {
|
if (empty($dep_uid)) {
|
||||||
throw (new Exception(G::LoadTranslation("ID_DEPARTMENT_NOT_EXIST", array($nameField, ''))));
|
throw new Exception(G::LoadTranslation("ID_DEPARTMENT_NOT_EXIST", [$nameField, '']));
|
||||||
}
|
}
|
||||||
$oDepartment = new \Department();
|
$department = new Department();
|
||||||
if (!($oDepartment->existsDepartment($dep_uid))) {
|
if (!($department->existsDepartment($dep_uid))) {
|
||||||
throw (new Exception(G::LoadTranslation("ID_DEPARTMENT_NOT_EXIST", array($nameField, $dep_uid))));
|
throw new Exception(G::LoadTranslation("ID_DEPARTMENT_NOT_EXIST", [$nameField, $dep_uid]));
|
||||||
}
|
}
|
||||||
return $dep_uid;
|
return $dep_uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate dep_status
|
* 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
|
* @access public
|
||||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
||||||
* @copyright Colosa - Bolivia
|
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
static public function depStatus($dep_status)
|
static public function depStatus($dep_status)
|
||||||
{
|
{
|
||||||
$dep_status = trim($dep_status);
|
$dep_status = trim($dep_status);
|
||||||
$values = array('ACTIVE', 'INACTIVE');
|
$values = ['ACTIVE', 'INACTIVE'];
|
||||||
if (!in_array($dep_status, $values)) {
|
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;
|
return $dep_status;
|
||||||
}
|
}
|
||||||
@@ -67,20 +71,18 @@ class Validator
|
|||||||
* @param string $nameField . Name of field for message
|
* @param string $nameField . Name of field for message
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
||||||
* @copyright Colosa - Bolivia
|
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
static public function usrUid($usr_uid, $nameField = 'usr_uid')
|
static public function usrUid($usr_uid, $nameField = 'usr_uid')
|
||||||
{
|
{
|
||||||
$usr_uid = trim($usr_uid);
|
$usr_uid = trim($usr_uid);
|
||||||
if ($usr_uid == '') {
|
if (empty($usr_uid)) {
|
||||||
throw (new Exception(G::LoadTranslation("ID_USER_NOT_EXIST", array($nameField, ''))));
|
throw new Exception(G::LoadTranslation("ID_USER_NOT_EXIST", [$nameField, '']));
|
||||||
}
|
}
|
||||||
$oUsers = new \Users();
|
$users = new Users();
|
||||||
if (!($oUsers->userExists($usr_uid))) {
|
if (!($users->userExists($usr_uid))) {
|
||||||
throw (new Exception(G::LoadTranslation("ID_USER_NOT_EXIST", array($nameField, $usr_uid))));
|
throw new Exception(G::LoadTranslation("ID_USER_NOT_EXIST", [$nameField, $usr_uid]));
|
||||||
}
|
}
|
||||||
return $usr_uid;
|
return $usr_uid;
|
||||||
}
|
}
|
||||||
@@ -89,23 +91,24 @@ class Validator
|
|||||||
* Validate app_uid
|
* Validate app_uid
|
||||||
*
|
*
|
||||||
* @param string $app_uid , Uid for application
|
* @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
|
* @access public
|
||||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
||||||
* @copyright Colosa - Bolivia
|
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
static public function appUid($app_uid, $nameField = 'app_uid')
|
static public function appUid($app_uid, $nameField = 'app_uid')
|
||||||
{
|
{
|
||||||
$app_uid = trim($app_uid);
|
$app_uid = trim($app_uid);
|
||||||
if ($app_uid == '') {
|
if (empty($app_uid)) {
|
||||||
throw (new Exception(G::LoadTranslation("ID_APPLICATION_NOT_EXIST", array($nameField, ''))));
|
throw new Exception(G::LoadTranslation("ID_APPLICATION_NOT_EXIST", [$nameField, '']));
|
||||||
}
|
}
|
||||||
$oApplication = new \Application();
|
if (strlen($app_uid) !== 32) {
|
||||||
if (!($oApplication->exists($app_uid))) {
|
throw new Exception(G::LoadTranslation("ID_CASE_NOT_EXISTS"));
|
||||||
throw (new Exception(G::LoadTranslation("ID_APPLICATION_NOT_EXIST", array($nameField, $app_uid))));
|
}
|
||||||
|
$application = new Application();
|
||||||
|
if (!($application->exists($app_uid))) {
|
||||||
|
throw new Exception(G::LoadTranslation("ID_APPLICATION_NOT_EXIST", [$nameField, $app_uid]));
|
||||||
}
|
}
|
||||||
return $app_uid;
|
return $app_uid;
|
||||||
}
|
}
|
||||||
@@ -117,20 +120,18 @@ class Validator
|
|||||||
* @param string $nameField . Name of field for message
|
* @param string $nameField . Name of field for message
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
||||||
* @copyright Colosa - Bolivia
|
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
static public function triUid($tri_uid, $nameField = 'tri_uid')
|
static public function triUid($tri_uid, $nameField = 'tri_uid')
|
||||||
{
|
{
|
||||||
$tri_uid = trim($tri_uid);
|
$tri_uid = trim($tri_uid);
|
||||||
if ($tri_uid == '') {
|
if (empty($tri_uid)) {
|
||||||
throw (new Exception(G::LoadTranslation("ID_TRIGGER_NOT_EXIST", array($nameField, ''))));
|
throw new Exception(G::LoadTranslation("ID_TRIGGER_NOT_EXIST", [$nameField, '']));
|
||||||
}
|
}
|
||||||
$oTriggers = new \Triggers();
|
$triggers = new Triggers();
|
||||||
if (!($oTriggers->TriggerExists($tri_uid))) {
|
if (!($triggers->TriggerExists($tri_uid))) {
|
||||||
throw (new Exception(G::LoadTranslation("ID_TRIGGER_NOT_EXIST", array($nameField, $tri_uid))));
|
throw new Exception(G::LoadTranslation("ID_TRIGGER_NOT_EXIST", [$nameField, $tri_uid]));
|
||||||
}
|
}
|
||||||
return $tri_uid;
|
return $tri_uid;
|
||||||
}
|
}
|
||||||
@@ -149,12 +150,12 @@ class Validator
|
|||||||
{
|
{
|
||||||
$proUid = trim($proUid);
|
$proUid = trim($proUid);
|
||||||
if (empty($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;
|
$proId = 0;
|
||||||
if (!($process->exists($proUid))) {
|
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 {
|
} else {
|
||||||
$proId = $process->load($proUid)['PRO_ID'];
|
$proId = $process->load($proUid)['PRO_ID'];
|
||||||
}
|
}
|
||||||
@@ -169,20 +170,18 @@ class Validator
|
|||||||
* @param string $nameField . Name of field for message
|
* @param string $nameField . Name of field for message
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
||||||
* @copyright Colosa - Bolivia
|
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
static public function catUid($cat_uid, $nameField = 'cat_uid')
|
static public function catUid($cat_uid, $nameField = 'cat_uid')
|
||||||
{
|
{
|
||||||
$cat_uid = trim($cat_uid);
|
$cat_uid = trim($cat_uid);
|
||||||
if ($cat_uid == '') {
|
if (empty($cat_uid)) {
|
||||||
throw (new Exception(G::LoadTranslation("ID_CATEGORY_NOT_EXIST", array($nameField, ''))));
|
throw new Exception(G::LoadTranslation("ID_CATEGORY_NOT_EXIST", [$nameField, '']));
|
||||||
}
|
}
|
||||||
$oCategory = new \ProcessCategory();
|
$category = new ProcessCategory();
|
||||||
if (!($oCategory->exists($cat_uid))) {
|
if (!($category->exists($cat_uid))) {
|
||||||
throw (new Exception(G::LoadTranslation("ID_CATEGORY_NOT_EXIST", array($nameField, $cat_uid))));
|
throw new Exception(G::LoadTranslation("ID_CATEGORY_NOT_EXIST", [$nameField, $cat_uid]));
|
||||||
}
|
}
|
||||||
return $cat_uid;
|
return $cat_uid;
|
||||||
}
|
}
|
||||||
@@ -191,123 +190,123 @@ class Validator
|
|||||||
* Validate date
|
* Validate date
|
||||||
*
|
*
|
||||||
* @param string $date , Date for validate
|
* @param string $date , Date for validate
|
||||||
|
* @param string $format
|
||||||
* @param string $nameField . Name of field for message
|
* @param string $nameField . Name of field for message
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
||||||
* @copyright Colosa - Bolivia
|
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
static public function isDate($date, $format = 'Y-m-d H:i:s', $nameField = 'app_uid')
|
static public function isDate($date, $format = 'Y-m-d H:i:s', $nameField = 'app_uid')
|
||||||
{
|
{
|
||||||
$date = trim($date);
|
$date = trim($date);
|
||||||
if ($date == '') {
|
if (empty($date)) {
|
||||||
throw (new Exception(G::LoadTranslation("ID_DATE_NOT_VALID", array('', $format))));
|
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)) {
|
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;
|
return $date;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate is array
|
* Validate is array
|
||||||
* @var array $field . Field type array
|
*
|
||||||
|
* @param string $field
|
||||||
|
* @param string $nameField
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
||||||
* @copyright Colosa - Bolivia
|
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
static public function isArray($field, $nameField)
|
static public function isArray($field, $nameField)
|
||||||
{
|
{
|
||||||
if (!is_array($field)) {
|
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
|
* Validate is string
|
||||||
* @var array $field . Field type string
|
*
|
||||||
|
* @param string $field
|
||||||
|
* @param string $nameField
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
||||||
* @copyright Colosa - Bolivia
|
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
static public function isString($field, $nameField)
|
static public function isString($field, $nameField)
|
||||||
{
|
{
|
||||||
if (!is_string($field)) {
|
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
|
* Validate is integer
|
||||||
* @var array $field . Field type integer
|
*
|
||||||
|
* @param string $field
|
||||||
|
* @param string $nameField
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
||||||
* @copyright Colosa - Bolivia
|
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
static public function isInteger($field, $nameField)
|
static public function isInteger($field, $nameField)
|
||||||
{
|
{
|
||||||
if (!is_integer($field)) {
|
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
|
* Validate is boolean
|
||||||
* @var boolean $field . Field type boolean
|
*
|
||||||
|
* @param string $field
|
||||||
|
* @param string $nameField
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
||||||
* @copyright Colosa - Bolivia
|
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
static public function isBoolean($field, $nameField)
|
static public function isBoolean($field, $nameField)
|
||||||
{
|
{
|
||||||
if (!is_bool($field)) {
|
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
|
* Validate is empty
|
||||||
* @var boolean $field . Field type boolean
|
*
|
||||||
|
* @param string $field
|
||||||
|
* @param string $nameField
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
||||||
* @copyright Colosa - Bolivia
|
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
static public function isNotEmpty($field, $nameField)
|
static public function isNotEmpty($field, $nameField)
|
||||||
{
|
{
|
||||||
if (empty($field)) {
|
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
|
* Validate a variable name
|
||||||
|
*
|
||||||
* @param $nameField
|
* @param $nameField
|
||||||
* @throws \Exception
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
static public function isValidVariableName($nameField)
|
static public function isValidVariableName($nameField)
|
||||||
{
|
{
|
||||||
$resp = preg_match(config('constants.validation.pmVariable.regEx'), $nameField, $matches);
|
$resp = preg_match(config('constants.validation.pmVariable.regEx'), $nameField, $matches);
|
||||||
if (isset($resp) && $resp === 0) {
|
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
|
* return void Throw exception if data is not array
|
||||||
*/
|
*/
|
||||||
public function throwExceptionIfDataIsNotArray($data, $dataNameForException)
|
static public function throwExceptionIfDataIsNotArray($data, $dataNameForException)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if (!is_array($data)) {
|
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) {
|
} catch (Exception $e) {
|
||||||
throw $e;
|
throw $e;
|
||||||
@@ -338,11 +337,11 @@ class Validator
|
|||||||
*
|
*
|
||||||
* return void Throw exception if data is empty
|
* return void Throw exception if data is empty
|
||||||
*/
|
*/
|
||||||
public function throwExceptionIfDataIsEmpty($data, $dataNameForException)
|
static public function throwExceptionIfDataIsEmpty($data, $dataNameForException)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if (empty($data)) {
|
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) {
|
} catch (Exception $e) {
|
||||||
throw $e;
|
throw $e;
|
||||||
@@ -364,8 +363,8 @@ class Validator
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$regexpDate = \ProcessMaker\Util\DateTime::REGEXPDATE;
|
$regexpDate = UtilDateTime::REGEXPDATE;
|
||||||
$regexpTime = \ProcessMaker\Util\DateTime::REGEXPTIME;
|
$regexpTime = UtilDateTime::REGEXPTIME;
|
||||||
|
|
||||||
$regexpIso8601 = $regexpDate . 'T' . $regexpTime . '[\+\-]\d{2}:\d{2}';
|
$regexpIso8601 = $regexpDate . 'T' . $regexpTime . '[\+\-]\d{2}:\d{2}';
|
||||||
|
|
||||||
@@ -417,7 +416,7 @@ class Validator
|
|||||||
(int)($value) < 0
|
(int)($value) < 0
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
return \G::LoadTranslation('ID_INVALID_VALUE_EXPECTING_POSITIVE_INTEGER', [$nameForException]);
|
return G::LoadTranslation('ID_INVALID_VALUE_EXPECTING_POSITIVE_INTEGER', [$nameForException]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
17
workflow/engine/src/ProcessMaker/Model/Department.php
Normal file
17
workflow/engine/src/ProcessMaker/Model/Department.php
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace ProcessMaker\Model;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Department
|
||||||
|
* @package ProcessMaker\Model
|
||||||
|
*/
|
||||||
|
class Department extends Model
|
||||||
|
{
|
||||||
|
// Set our table name
|
||||||
|
protected $table = 'DEPARTMENT';
|
||||||
|
// We do not store timestamps
|
||||||
|
public $timestamps = false;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user