Merged in bugfix/PMC-973 (pull request #6978)

PMC-973

Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
Paula Quispe
2019-07-23 17:48:06 +00:00
committed by Julio Cesar Laura Avendaño
9 changed files with 461 additions and 190 deletions

11
gulliver/system/class.rbac.php Normal file → Executable file
View File

@@ -201,6 +201,17 @@ class RBAC
'unassigned' => ['PM_CASES'],
'to_reassign' => ['PM_REASSIGNCASE,PM_REASSIGNCASE_SUPERVISOR'],
'to_revise' => ['PM_SUPERVISOR']
],
'casesList_Ajax.php' => [
'userValues' => ['PM_CASES'],
'processListExtJs' => ['PM_CASES'],
'verifySession' => [],
'getUsersToReassign' => ['PM_CASES'],
'reassignCase' => ['PM_CASES'],
'showHistoryMessage' => ['PM_CASES'],
'showDynaformListHistory' => ['PM_CASES'],
'dynaformChangeLogViewHistory' => ['PM_CASES'],
'historyDynaformGridPreview' => ['PM_CASES'],
]
];
$this->aliasPermissions['PM_CASES'] = [self::PM_GUEST_CASE];

View File

@@ -0,0 +1,93 @@
<?php
namespace Tests\unit\workflow\engine\classes;
use Configurations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use ProcessMaker\Model\User;
use Tests\TestCase;
class ConfigurationsTest extends TestCase
{
use DatabaseTransactions;
private $filters = [];
/**
* Define values of some parameters of the test
*/
protected function setUp()
{
//Define filters
$filters = [];
$filters['category'] = ''; //Dropdown: Category id
$filters['columnSearch'] = 'APP_TITLE'; //Dropdown: filter by value
$filters['dateFrom'] = '2019-07-01'; //Date picker
$filters['dateTo'] = '2020-07-01'; //Date picker
$filters['dir'] = 'DESC';
$filters['limit'] = 15;
$filters['filterStatus'] = 3; //Dropdown: Status id
$filters['process'] = ''; //Suggest: Process id
$filters['process_label'] = ''; //Suggest: Process label
$filters['search'] = ''; //Text search
$filters['sort'] = 'APP_NUMBER';
$filters['start'] = 0;
$filters['user'] = ''; //Suggest: User id
$filters['user_label'] = ''; //Suggest: User label
$this->filters['advanced'] = $filters;
}
/**
* Review the user preferences when the user does not save filters
* @covers Configurations::getUserPreferences
* @test
*/
public function it_should_return_default_filters()
{
$user = factory(User::class)->create();
$configuration = new Configurations();
//Get the user preferences
$response = $configuration->getUserPreferences('FILTERS', $user->USR_UID);
//Compare filters
$this->assertEquals($response, ['advanced' => []]);
}
/**
* Review the user preferences when the user save filters
* @covers Configurations::getUserPreferences
* @test
*/
public function it_should_return_filters_saved()
{
//Define a user
$user = factory(User::class)->create();
//Save the configuration defined
$configuration = new Configurations();
$configuration->aConfig['FILTERS'] = $this->filters;
$configuration->saveConfig('USER_PREFERENCES', '', '', $user->USR_UID);
//Get the user preferences
$response = $configuration->getUserPreferences('FILTERS', $user->USR_UID);
//Compare filters
$this->assertEquals($response, $this->filters);
//Review if some keys exist
$this->assertArrayHasKey('category', $response['advanced']);
$this->assertArrayHasKey('columnSearch', $response['advanced']);
$this->assertArrayHasKey('dateFrom', $response['advanced']);
$this->assertArrayHasKey('dateTo', $response['advanced']);
$this->assertArrayHasKey('dir', $response['advanced']);
$this->assertArrayHasKey('limit', $response['advanced']);
$this->assertArrayHasKey('filterStatus', $response['advanced']);
$this->assertArrayHasKey('process', $response['advanced']);
$this->assertArrayHasKey('process_label', $response['advanced']);
$this->assertArrayHasKey('search', $response['advanced']);
$this->assertArrayHasKey('sort', $response['advanced']);
$this->assertArrayHasKey('start', $response['advanced']);
$this->assertArrayHasKey('user', $response['advanced']);
$this->assertArrayHasKey('user_label', $response['advanced']);
}
}

30
workflow/engine/classes/Configurations.php Normal file → Executable file
View File

@@ -612,6 +612,36 @@ class Configurations // extends Configuration
}
}
/**
* Get the values stored in the USER_PREFERENCES
*
* @param string $key
* @param string $userUid
* @param string $listName
*
* @return array
*/
public function getUserPreferences($key = null, $userUid = null, $listName = 'advanced')
{
$this->loadConfig($obj, 'USER_PREFERENCES', '', '', $userUid, '');
if (isset($key)) {
if (isset($this->aConfig[$key])) {
if (isset($data) && is_array($data)) {
foreach ($data as $k => $v) {
$this->aConfig[$key] = str_replace('@' . $k, $v, $this->aConfig[$key]);
}
}
return $this->aConfig[$key];
} else {
return [$listName => []];
}
} else {
return $this->aConfig;
}
}
/**
* Gets the default fields and configuration for the cases list
*

View File

@@ -22787,6 +22787,12 @@ msgstr "Result"
msgid "[LABEL/ID_RESUME] Resume"
msgstr "Resume"
# TRANSLATION
# LABEL/ID_RETURN_ADVANCED_SEARCH
#: LABEL/ID_RETURN_ADVANCED_SEARCH
msgid "Return"
msgstr "Return"
# TRANSLATION
# LABEL/ID_RIGHT
#: LABEL/ID_RIGHT

1
workflow/engine/data/mysql/insert.sql Normal file → Executable file
View File

@@ -60681,6 +60681,7 @@ INSERT INTO TRANSLATION (TRN_CATEGORY,TRN_ID,TRN_LANG,TRN_VALUE,TRN_UPDATE_DATE
( 'LABEL','ID_RESTORING_CASE','en','Restoring case','2015-09-15') ,
( 'LABEL','ID_RESULT','en','Result','2014-01-15') ,
( 'LABEL','ID_RESUME','en','Resume','2014-01-15') ,
( 'LABEL','ID_RETURN_ADVANCED_SEARCH','en','Return','2019-07-17') ,
( 'LABEL','ID_RIGHT','en','right','2014-09-18') ,
( 'LABEL','ID_RIGHT_MARGIN','en','Right Margin','2014-01-15') ,
( 'LABEL','ID_ROLE','en','Role','2014-01-15') ,

8
workflow/engine/menus/caseOptions.php Normal file → Executable file
View File

@@ -14,9 +14,9 @@ global $RBAC;
$viewSteps = true;
$statusSendAndUnassigned = false;
$listName = $_SESSION['actionCaseOptions'];
//caseOptions
switch ($_SESSION['actionCaseOptions']) {
switch ($listName) {
case 'todo':
case 'draft':
if (isset($_SESSION['bNoShowSteps'])) {
@@ -73,3 +73,7 @@ if ((($sStatus === 'DRAFT') || ($sStatus === 'TO_DO')) && !$statusSendAndUnassig
}
//Menu: Cases Notes
$G_TMP_MENU->AddIdOption('NOTES', G::LoadTranslation('ID_NOTES'), 'javascript:showNotes();', 'absolute');
//Menu: Return to advanced search button
if ($listName === 'search'){
$G_TMP_MENU->AddIdOption('RETURN_ADVANCED_SEARCH', G::LoadTranslation('ID_RETURN_ADVANCED_SEARCH'), 'javascript:showReturnAdvancedSearch();', 'absolute');
}

376
workflow/engine/methods/cases/casesListExtJs.php Normal file → Executable file

File diff suppressed because it is too large Load Diff

5
workflow/engine/methods/cases/casesList_Ajax.php Normal file → Executable file
View File

@@ -8,7 +8,10 @@ if (!isset($_SESSION['USER_LOGGED'])) {
die();
}
$actionAjax = isset($_REQUEST['actionAjax']) ? $_REQUEST['actionAjax'] : null;
$actionAjax = isset($_REQUEST['actionAjax']) ? $_REQUEST['actionAjax'] : 'verifySession';
global $RBAC;
$RBAC->allows(basename(__FILE__), $actionAjax);
function filterUserListArray($users = array(), $filter = '')
{

121
workflow/engine/methods/cases/proxyCasesList.php Normal file → Executable file
View File

@@ -1,4 +1,5 @@
<?php
use ProcessMaker\Model\Delegation;
/**
@@ -20,38 +21,41 @@ if (!isset($_SESSION['USER_LOGGED'])) {
$filter = new InputFilter();
$_GET = $filter->xssFilterHard($_GET);
$_REQUEST = $filter->xssFilterHard($_REQUEST);
$_SESSION['USER_LOGGED'] = $filter->xssFilterHard($_SESSION['USER_LOGGED']);
$userLogged = $filter->xssFilterHard($_SESSION['USER_LOGGED']);
$filters = [];
// Callback in the UI to utilize
$callback = isset($_REQUEST["callback"]) ? $_REQUEST["callback"] : "stcCallback1001";
// Sort column
$sort = isset($_REQUEST["sort"]) ? $_REQUEST["sort"] : "APP_NUMBER";
$filters['sort'] = $sort = isset($_REQUEST["sort"]) ? $_REQUEST["sort"] : "APP_NUMBER";
// Sort direction
$dir = isset($_REQUEST["dir"]) ? $_REQUEST["dir"] : "DESC";
$filters['dir'] = $dir = isset($_REQUEST["dir"]) ? $_REQUEST["dir"] : "DESC";
// Pagination control
$start = !empty($_REQUEST["start"]) ? $_REQUEST["start"] : 0;
$limit = !empty($_REQUEST["limit"]) ? $_REQUEST["limit"] : 25;
$filters['start'] = $start = !empty($_REQUEST["start"]) ? $_REQUEST["start"] : 0;
$filters['limit'] = $limit = !empty($_REQUEST["limit"]) ? $_REQUEST["limit"] : 25;
// Our search filter
$filter = isset($_REQUEST["filter"]) ? $_REQUEST["filter"] : "";
// What process
$process = isset($_REQUEST["process"]) ? $_REQUEST["process"] : "";
$filters['process'] = $process = isset($_REQUEST["process"]) ? $_REQUEST["process"] : "";
$filters['process_label'] = $processLabel = isset($_REQUEST["process_label"]) ? $_REQUEST["process_label"] : "";
// What category
$category = isset($_REQUEST["category"]) ? $_REQUEST["category"] : "";
$filters['category'] = $category = isset($_REQUEST["category"]) ? $_REQUEST["category"] : "";
// What status
$status = isset($_REQUEST["status"]) ? strtoupper($_REQUEST["status"]) : "";
$filterStatus = isset($_REQUEST["filterStatus"]) ? strtoupper($_REQUEST["filterStatus"]) : "";
$filters['filterStatus'] = $filterStatus = isset($_REQUEST["filterStatus"]) ? strtoupper($_REQUEST["filterStatus"]) : "";
// What user
$user = isset($_REQUEST["user"]) ? $_REQUEST["user"] : "";
$filters['user'] = $user = isset($_REQUEST["user"]) ? $_REQUEST["user"] : "";
$filters['user_label'] = $userLabel = isset($_REQUEST["user_label"]) ? $_REQUEST["user_label"] : "";
// What keywords to search
$search = isset($_REQUEST["search"]) ? $_REQUEST["search"] : "";
$filters['search'] = $search = isset($_REQUEST["search"]) ? $_REQUEST["search"] : "";
// What kind of action
$action = isset($_GET["action"]) ? $_GET["action"] : (isset($_REQUEST["action"]) ? $_REQUEST["action"] : "todo");
@@ -60,17 +64,20 @@ $action = isset($_GET["action"]) ? $_GET["action"] : (isset($_REQUEST["action"])
$type = isset($_GET["type"]) ? $_GET["type"] : (isset($_REQUEST["type"]) ? $_REQUEST["type"] : "extjs");
// Date ranges
$dateFrom = isset($_REQUEST["dateFrom"]) ? substr($_REQUEST["dateFrom"], 0, 10) : "";
$dateTo = isset($_REQUEST["dateTo"]) ? substr($_REQUEST["dateTo"], 0, 10) : "";
$filters['dateFrom'] = $dateFrom = isset($_REQUEST["dateFrom"]) ? substr($_REQUEST["dateFrom"], 0, 10) : "";
$filters['dateTo'] = $dateTo = isset($_REQUEST["dateTo"]) ? substr($_REQUEST["dateTo"], 0, 10) : "";
// First? No idea
$first = isset($_REQUEST["first"]) ? true : false;
// First define if we need to return empty data the first time
$first = isset($_REQUEST["first"]);
// Do search define if the action was defined from the button search
$doSearch = isset($_REQUEST["doSearch"]);
// Open case from case link
$openApplicationUid = (isset($_REQUEST['openApplicationUid']) && $_REQUEST['openApplicationUid'] != '') ?
$_REQUEST['openApplicationUid'] : null;
$search = (!is_null($openApplicationUid)) ? $openApplicationUid : $search;
$columnSearch = isset($_REQUEST["columnSearch"]) ? strtoupper($_REQUEST["columnSearch"]) : "";
$filters['columnSearch'] = $columnSearch = isset($_REQUEST["columnSearch"]) ? strtoupper($_REQUEST["columnSearch"]) : "";
if ($sort == 'CASE_SUMMARY' || $sort == 'CASE_NOTES_COUNT') {
$sort = 'APP_NUMBER';//DEFAULT VALUE
@@ -79,43 +86,61 @@ if ($sort == 'APP_STATUS_LABEL') {
$sort = 'APP_STATUS';
}
try {
$userUid = (isset($_SESSION["USER_LOGGED"]) && $_SESSION["USER_LOGGED"] != "") ? $_SESSION["USER_LOGGED"] : null;
$result = [];
//Load Configurations
$conf = new Configurations();
//Load the user preferences
$conf->getUserPreferences('FILTERS', $userLogged);
//Save the filters used
if ($doSearch && (empty($conf->aConfig['FILTERS']['advanced']) || $conf->aConfig['FILTERS']['advanced'] != $filters)) {
//The user does not have filters or we need to update the user preferences
$conf->aConfig['FILTERS']['advanced'] = $filters;
$conf->saveConfig('USER_PREFERENCES', '', '', $userLogged);
}
switch ($action) {
case "search":
case "to_reassign":
if ($first) {
$result['totalCount'] = 0;
$result['data'] = array();
$result = G::json_encode($result);
echo $result;
return;
}
$user = ($user == "CURRENT_USER") ? $userUid : $user;
$userUid = $user;
break;
default:
break;
}
try {
$result = [];
//Define the user logged into the system
$userUid = (isset($userLogged) && $userLogged != "") ? $userLogged : null;
if ($action == 'search') {
$data = Delegation::search(
$userUid,
$start,
$limit,
$search,
$process,
$filterStatus,
$dir,
$sort,
$category,
$dateFrom,
$dateTo,
$columnSearch
);
//Return empty if does not have filters
if (empty($conf->aConfig['FILTERS']['advanced'])) {
$result['totalCount'] = 0;
$result['data'] = [];
$result = G::json_encode($result);
echo $result;
return;
} else {
//Define the user
$user = ($user == "CURRENT_USER") ? $userUid : $user;
$userUid = $user;
//Get the data from the specific search
$data = Delegation::search(
$userUid,
$start,
$limit,
$search,
$process,
$filterStatus,
$dir,
$sort,
$category,
$dateFrom,
$dateTo,
$columnSearch
);
}
} else {
//We check if we need to return empty
if ($action == "to_reassign" && $first) {
$result['totalCount'] = 0;
$result['data'] = [];
$result = G::json_encode($result);
echo $result;
return;
}
//This section is used by the community version
$apps = new Applications();
$data = $apps->getAll(