Merge remote-tracking branch 'origin/release/3.6.0' into bugfix/PMCORE-2609

This commit is contained in:
fabio
2020-12-23 12:31:45 -04:00
18 changed files with 545 additions and 467 deletions

View File

@@ -35,10 +35,10 @@
"laravel/framework": "5.7.*",
"luracast/restler": "3.0",
"bshaffer/oauth2-server-php": "v1.0",
"colosa/pmui": "release/3.5.0-dev",
"colosa/michelangelofe": "release/3.5.0-dev",
"colosa/pmdynaform": "release/3.5.0-dev",
"colosa/taskscheduler": "release/1.0.0-dev",
"colosa/pmui": "release/3.6.0-dev",
"colosa/michelangelofe": "release/3.6.0-dev",
"colosa/pmdynaform": "release/3.6.0-dev",
"colosa/taskscheduler": "release/1.0.2-dev",
"google/apiclient": "1.1.6",
"dapphp/securimage": "^3.6",
"psr/log": "1.0.0",

735
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -67,6 +67,15 @@ $factory->state(\ProcessMaker\Model\Application::class, 'foreign_keys', function
];
});
$factory->state(\ProcessMaker\Model\Application::class, 'web_entry', function (Faker $faker) {
$appNumber = $faker->unique()->numberBetween(5000);
return [
'APP_NUMBER' => $appNumber * -1,
'APP_STATUS_ID' => 2,
'APP_STATUS' => 'TO_DO'
];
});
$factory->state(\ProcessMaker\Model\Application::class, 'todo', function (Faker $faker) {
return [
'APP_NUMBER' => $faker->unique()->numberBetween(1000),

View File

@@ -86,6 +86,51 @@ $factory->state(\ProcessMaker\Model\Delegation::class, 'foreign_keys', function
];
});
// Create a delegation with the foreign keys
$factory->state(\ProcessMaker\Model\Delegation::class, 'web_entry', function (Faker $faker) {
// Create values in the foreign key relations
$user = factory(\ProcessMaker\Model\User::class)->create();
$category = factory(\ProcessMaker\Model\ProcessCategory::class)->create();
$process = factory(\ProcessMaker\Model\Process::class)->create([
'PRO_CATEGORY' => $category->CATEGORY_UID,
'CATEGORY_ID' => $category->CATEGORY_ID
]);
$task = factory(\ProcessMaker\Model\Task::class)->create([
'PRO_UID' => $process->PRO_UID,
'PRO_ID' => $process->PRO_ID
]);
$application = factory(\ProcessMaker\Model\Application::class)->states('web_entry')->create([
'PRO_UID' => $process->PRO_UID,
'APP_INIT_USER' => $user->USR_UID,
'APP_CUR_USER' => $user->USR_UID
]);
// Return with default values
return [
'DELEGATION_ID' => $faker->unique()->numberBetween(5000),
'APP_UID' => $application->APP_UID,
'DEL_INDEX' => 1,
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_PREVIOUS' => 0,
'PRO_UID' => $process->PRO_UID,
'TAS_UID' => $task->TAS_UID,
'USR_UID' => $user->USR_UID,
'DEL_TYPE' => 'NORMAL',
'DEL_THREAD' => 1,
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_PRIORITY' => 3,
'DEL_DELEGATE_DATE' => $faker->dateTime(),
'DEL_INIT_DATE' => $faker->dateTime(),
'DEL_TASK_DUE_DATE' => $faker->dateTime(),
'DEL_RISK_DATE' => $faker->dateTime(),
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process->PRO_ID,
'TAS_ID' => $task->TAS_ID,
'DEL_DATA' => '',
'DEL_TITLE' => $faker->word()
];
});
// Create a open delegation
$factory->state(\ProcessMaker\Model\Delegation::class, 'open', function (Faker $faker) {
// Create dates with sense

View File

@@ -393,3 +393,7 @@
-webkit-transform: translateY(-50%) rotate(90deg);
transform: translateY(-50%) rotate(270deg) !important;
}
.vsm--mobile-item {
max-width: 200px !important;
}

View File

@@ -238,6 +238,27 @@ class SearchTest extends TestCase
$this->assertNotEmpty($result);
}
/**
* It tests web entry with negative appNumbers
*
* @covers \ProcessMaker\BusinessModel\Cases\Search::getData()
* @test
*/
public function it_get_web_entry_not_submitted()
{
// Create factories related to the delegation cases
$cases = $this->createSearch();
$casesNotSubmitted = factory(Delegation::class, 5)->states('web_entry')->create();
// Create new Search object
$search = new Search();
// Set order by column value
$search->setOrderByColumn('APP_NUMBER');
$result = $search->getData();
// Review if the cases not submitted are not considered
$this->assertNotEmpty($result);
$this->assertEquals(count($result) , count($cases));
}
/**
* It tests the getCounter method
*

View File

@@ -5,6 +5,11 @@ namespace ProcessMaker\BusinessModel;
use Exception;
use Tests\TestCase;
/**
* Class GroupTest
*
* @coversDefaultClass \ProcessMaker\BusinessModel\Group
*/
class GroupTest extends TestCase
{
/**

View File

@@ -10,7 +10,7 @@ use ProcessMaker\Model\User;
use Tests\TestCase;
/**
* Class DelegationTest
* Class ApplicationTest
*
* @coversDefaultClass \ProcessMaker\Model\Application
*/

View File

@@ -2,10 +2,16 @@
namespace Tests\unit\workflow\engine\src\ProcessMaker\Model;
use G;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use ProcessMaker\Model\User;
use Tests\TestCase;
/**
* Class UserTest
*
* @coversDefaultClass \ProcessMaker\Model\User
*/
class UserTest extends TestCase
{
use DatabaseTransactions;
@@ -85,6 +91,8 @@ class UserTest extends TestCase
* It test get users for the new home view
*
* @covers \ProcessMaker\Model\User::getUsersForHome()
* @covers \ProcessMaker\Model\User::scopeActive()
* @covers \ProcessMaker\Model\User::scopeWithoutGuest()
* @test
*/
public function it_should_test_get_users_for_home()
@@ -128,4 +136,22 @@ class UserTest extends TestCase
// Only will considerate by default the actives and limit
$this->assertCount(1, User::getUsersForHome(null, 2, 1));
}
/**
* It test get the user Id
*
* @covers \ProcessMaker\Model\User::getId()
* @covers \ProcessMaker\Model\User::scopeUser()
* @test
*/
public function it_get_usr_id()
{
$user = factory(User::class)->create();
// When the user exist
$results = User::getId($user->USR_UID);
$this->assertGreaterThan(0, $results);
// When the user does not exist
$results = User::getId(G::generateUniqueID());
$this->assertEquals(0, $results);
}
}

View File

@@ -798,7 +798,7 @@ class Cases
}
// Update case title
if (!empty($appUid) && !empty($appFields['APP_NUMBER']) && !empty($appFields['DEL_INDEX'])) {
if (!empty($appUid) && !empty($appFields['APP_NUMBER']) && $appFields['APP_NUMBER'] > 0 && !empty($appFields['DEL_INDEX'])) {
$this->updateThreadTitle($appUid, $appFields['APP_NUMBER'], $appFields['DEL_INDEX'], $appFields['APP_DATA']);
}
@@ -903,7 +903,7 @@ class Cases
$this->appSolr->updateApplicationSearchIndex($appUid);
}
if ($Fields["APP_STATUS"] == "COMPLETED") {
if (isset($Fields["APP_STATUS"]) && $Fields["APP_STATUS"] == "COMPLETED") {
//Delete records of the table APP_ASSIGN_SELF_SERVICE_VALUE
$appAssignSelfServiceValue = new AppAssignSelfServiceValue();
$appAssignSelfServiceValue->remove($appUid);
@@ -1650,7 +1650,11 @@ class Cases
$user = UsersPeer::retrieveByPK($usrUid);
// Create new delegation
$delegation = new AppDelegation();
if ($appNumber > 0) {
$delegation->setDelTitle($threadTitle);
} else {
$delegation->setDelTitle("");
}
$result = $delegation->createAppDelegation(
$proUid,
$appUid,

View File

@@ -27677,6 +27677,12 @@ msgstr "The row '{USR_UID}' in table USER doesn't exist!"
msgid "Users with role"
msgstr "Users with role"
# TRANSLATION
# LABEL/ID_USE_ALPHANUMERIC_CHARACTERS_INCLUDING
#: LABEL/ID_USE_ALPHANUMERIC_CHARACTERS_INCLUDING
msgid "Please just use alphanumeric characters including: {0}"
msgstr "Please just use alphanumeric characters including: {0}"
# TRANSLATION
# LABEL/ID_USE_LANGUAGE_URL
#: LABEL/ID_USE_LANGUAGE_URL

View File

@@ -61575,6 +61575,7 @@ INSERT INTO TRANSLATION (TRN_CATEGORY,TRN_ID,TRN_LANG,TRN_VALUE,TRN_UPDATE_DATE
( 'LABEL','ID_USER_TO_REASSIGN','en','Reassign to:','2014-01-15') ,
( 'LABEL','ID_USER_UID_DOESNT_EXIST','en','The row ''{USR_UID}'' in table USER doesn''t exist!','2014-01-15') ,
( 'LABEL','ID_USER_WITH_ROLE','en','Users with role','2014-01-15') ,
( 'LABEL','ID_USE_ALPHANUMERIC_CHARACTERS_INCLUDING','en','Please just use alphanumeric characters including: {0}','2020-12-22') ,
( 'LABEL','ID_USE_LANGUAGE_URL','en','Use the language of URL','2014-08-08') ,
( 'LABEL','ID_UXS_NORMAL','en','Normal','2014-01-15') ,
( 'LABEL','ID_UXS_SIMPLIFIED','en','Mobile','2014-01-15') ,

View File

@@ -249,7 +249,7 @@
},
importUsers(row) {
//the return action is in: processmaker/workflow/engine/templates/ldapAdvanced/ldapAdvancedSearch.js
location.href = this.$root.baseUrl() + 'authSources_SearchUsers?sUID=' + row.AUTH_SOURCE_UID;
location.href = this.$root.baseUrl() + "authSources/authSources_SearchUsers?sUID=" + row.AUTH_SOURCE_UID;
},
syncGroups(row) {
//the return action is in: processmaker/workflow/engine/templates/authSources/authSourcesSynchronize.js

View File

@@ -200,40 +200,35 @@
this.statusAttributeId = null;
},
onsubmit() {
this.statusName = true;
if (this.form.name.trim() === "") {
this.statusName = false;
this.statusNameMessage = this.$root.translation("ID_IS_REQUIRED");
return;
}
this.statusAttributeId = true;
if (this.form.attributeId.trim() === "") {
this.statusAttributeId = false;
this.statusAttributeIdMessage = this.$root.translation("ID_IS_REQUIRED");
return;
}
if (this.form.attributeId.length >= 50) {
this.statusAttributeId = false;
this.statusAttributeIdMessage = this.$root.translation("ID_INVALID_MAX_PERMITTED", [this.$root.translation('ID_ATTRIBUTE_ID'), '50']);
return;
}
if (/^[a-zA-Z][_0-9a-zA-Z]+$/.test(this.form.attributeId) === false) {
this.statusAttributeId = false;
this.statusAttributeIdMessage = this.$root.translation("ID_INVALID_DATA");
return;
}
let promise = this.validateName();
promise.then(response => {
response;
let promise2 = this.validateAttributeId();
promise2.then(response2 => {
response2;
if (this.statusName === true && this.statusAttributeId === true) {
this.saveForm();
}
});
});
},
validateName() {
this.statusValidation = false;
this.statusName = true;
if (this.form.name.trim() === "") {
this.statusName = false;
this.statusNameMessage = this.$root.translation("ID_IS_REQUIRED");
return;
}
if (this.form.name.length >= 50) {
this.statusName = false;
this.statusNameMessage = this.$root.translation("ID_INVALID_MAX_PERMITTED", [this.$root.translation('ID_ATTRIBUTE_NAME'), '50']);
return;
}
if (/^[a-zA-Z][-_0-9a-zA-Z]+$/.test(this.form.name) === false) {
this.statusName = false;
this.statusNameMessage = this.$root.translation("ID_USE_ALPHANUMERIC_CHARACTERS_INCLUDING", ["- _"]);
return;
}
let formData = new FormData();
formData.append("id", this.form.id);
formData.append("name", this.form.name);
@@ -245,7 +240,6 @@
this.statusNameMessage = response.data.message;
} else {
this.statusName = true;
this.statusValidation = true;
}
})
.catch(error => {
@@ -255,10 +249,20 @@
});
},
validateAttributeId() {
this.statusValidation = false;
if (/^[a-zA-Z][_0-9a-zA-Z]+$/.test(this.form.attributeId) === false) {
this.statusAttributeId = true;
if (this.form.attributeId.trim() === "") {
this.statusAttributeId = false;
this.statusAttributeIdMessage = this.$root.translation("ID_INVALID_DATA");
this.statusAttributeIdMessage = this.$root.translation("ID_IS_REQUIRED");
return;
}
if (this.form.attributeId.length >= 250) {
this.statusAttributeId = false;
this.statusAttributeIdMessage = this.$root.translation("ID_INVALID_MAX_PERMITTED", [this.$root.translation('ID_ATTRIBUTE_ID'), '250']);
return;
}
if (/^[a-zA-Z][-_.0-9a-zA-Z]+$/.test(this.form.attributeId) === false) {
this.statusAttributeId = false;
this.statusAttributeIdMessage = this.$root.translation("ID_USE_ALPHANUMERIC_CHARACTERS_INCLUDING", [". - _"]);
return;
}
let formData = new FormData();
@@ -272,7 +276,6 @@
this.statusAttributeIdMessage = response.data.message;
} else {
this.statusAttributeId = true;
this.statusValidation = true;
}
})
.catch(error => {

View File

@@ -162,6 +162,8 @@ class Search extends AbstractCases
$query->groupBy('APP_NUMBER');
/** Apply filters */
$this->filters($query);
/** Exclude the web entries does not submitted */
$query->positiveCases($query);
/** Apply order and pagination */
// The order by clause
$query->orderBy($this->getOrderByColumn(), $this->getOrderDirection());

View File

@@ -455,6 +455,18 @@ class Delegation extends Model
return $query->where('APP_DELEGATION.APP_NUMBER', '<=', $to);
}
/**
* Scope for query to get the positive cases for avoid the web entry
*
* @param \Illuminate\Database\Eloquent\Builder $query
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopePositiveCases($query)
{
return $query->where('APP_DELEGATION.APP_NUMBER', '>', 0);
}
/**
* Scope more than one range of cases
*
@@ -1594,7 +1606,7 @@ class Delegation extends Model
}
$items = $query->get();
$items->each(function ($item) use (&$data) {
$data[] = get_object_vars($item);
$data[] = $item->toArray();
});
} else {
// Set offset and limit if were sent
@@ -1829,7 +1841,11 @@ class Delegation extends Model
// If is empty get the previous title
if ($delIndexPrevious > 0) {
$thread = self::getThreadInfo($appNumber, $delIndexPrevious);
if(empty($thread['DEL_TITLE'])) {
$threadTitle = '# '. $appNumber;
} else {
$threadTitle = $thread['DEL_TITLE'];
}
} else {
$threadTitle = '# '. $appNumber;
}

View File

@@ -31,6 +31,20 @@ class User extends Model
return $this->belongsTo(GroupUser::class, 'USR_UID', 'USR_UID');
}
/**
* Scope for query to get the user by USR_UID
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param string $usrUid
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeUser($query, string $usrUid)
{
$result = $query->where('USR_UID', '=', $usrUid);
return $result;
}
/**
* Return the groups from a user
*
@@ -157,4 +171,24 @@ class User extends Model
throw new Exception("Error getting the users: {$e->getMessage()}.");
}
}
/**
* Get the user id
*
* @param string $usrUid
*
* @return int
*/
public static function getId($usrUid)
{
$query = User::query()->select(['USR_ID'])
->user($usrUid)
->limit(1);
$results = $query->get();
$id = 0;
$results->each(function ($item) use (&$id) {
$id = $item->USR_ID;
});
return $id;
}
}

View File

@@ -76,7 +76,7 @@ class Home extends Api
$properties['task'] = $task;
// Get the user that access to the API
$usrUid = $this->getUserId();
$properties['user'] = User::find($usrUid)->first()->USR_ID;
$properties['user'] = !empty($usrUid) ? User::getId($usrUid) : 0;
// Set the pagination parameters
$paged = explode(',', $paged);
$sort = explode(',', $sort);
@@ -131,7 +131,7 @@ class Home extends Api
$properties['task'] = $task;
// Get the user that access to the API
$usrUid = $this->getUserId();
$properties['user'] = User::find($usrUid)->first()->USR_ID;
$properties['user'] = !empty($usrUid) ? User::getId($usrUid) : 0;
// Set the pagination parameters
$paged = explode(',', $paged);
$sort = explode(',', $sort);
@@ -186,7 +186,7 @@ class Home extends Api
$properties['task'] = $task;
// Get the user that access to the API
$usrUid = $this->getUserId();
$properties['user'] = User::find($usrUid)->first()->USR_ID;
$properties['user'] = !empty($usrUid) ? User::getId($usrUid) : 0;
// Set the pagination parameters
$paged = explode(',', $paged);
$sort = explode(',', $sort);
@@ -243,7 +243,7 @@ class Home extends Api
$properties['task'] = $task;
// Get the user that access to the API
$usrUid = $this->getUserId();
$properties['user'] = User::find($usrUid)->first()->USR_ID;
$properties['user'] = !empty($usrUid) ? User::getId($usrUid) : 0;
// Set the pagination parameters
$paged = explode(',', $paged);
$sort = explode(',', $sort);
@@ -308,7 +308,7 @@ class Home extends Api
$properties['task'] = $task;
// Get the user that access to the API
$usrUid = $this->getUserId();
$properties['user'] = User::find($usrUid)->first()->USR_ID;
$properties['user'] = !empty($usrUid) ? User::getId($usrUid) : 0;
$properties['filter'] = $filter;
$properties['caseStatus'] = $caseStatus;
$properties['startCaseFrom'] = $startCaseFrom;
@@ -370,7 +370,8 @@ class Home extends Api
$participatedStatuses = ['STARTED', 'IN_PROGRESS', 'COMPLETED', 'SUPERVISING'];
$participatedLabels = array_combine($participatedStatuses, ['ID_OPT_STARTED', 'ID_IN_PROGRESS', 'ID_COMPLETED', 'ID_SUPERVISING']);
$counters = [];
// Get the user that access to the API
$usrUid = $this->getUserId();
// Get counters
foreach ($participatedStatuses as $participatedStatus) {
// Initializing counter object
@@ -385,12 +386,14 @@ class Home extends Api
case 'COMPLETED':
$participated = new Participated();
$participated->setParticipatedStatus($participatedStatus);
$participated->setUserId($this->getUserId());
$usrId = !empty($usrUid) ? User::getId($usrUid) : 0;
$participated->setUserId($usrId);
$counter->counter = $participated->getCounter();
break;
case 'SUPERVISING':
$supervising = new Supervising();
$supervising->setUserUid($this->getUserId());
$usrId = !empty($usrUid) ? User::getId($usrUid) : 0;
$supervising->setUserUid($usrId);
$counter->counter = $supervising->getCounter();
break;
default:
@@ -636,7 +639,7 @@ class Home extends Api
{
$result = [];
$usrUid = $this->getUserId();
$usrId = User::find($usrUid)->first()->USR_ID;
$usrId = !empty($usrUid) ? User::getId($usrUid) : 0;
// For inbox
$inbox = new Inbox();
$inbox->setUserUid($usrUid);