Fix conflicts with develop branch
This commit is contained in:
@@ -40,6 +40,7 @@ use ProcessMaker\BusinessModel\Task as BmTask;
|
||||
use ProcessMaker\BusinessModel\User as BmUser;
|
||||
use ProcessMaker\Core\System;
|
||||
use ProcessMaker\Exception\UploadException;
|
||||
use ProcessMaker\Model\Application as ModelApplication;
|
||||
use ProcessMaker\Model\Delegation;
|
||||
use ProcessMaker\Plugins\PluginRegistry;
|
||||
use ProcessMaker\Services\OAuth2\Server;
|
||||
@@ -1114,35 +1115,37 @@ class Cases
|
||||
* Delete case
|
||||
*
|
||||
* @access public
|
||||
* @param string $app_uid, Uid for case
|
||||
* @param string $usr_uid, Uid user
|
||||
* @param string $appUid, Uid for case
|
||||
* @param string $usrUid, Uid user
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function deleteCase($app_uid, $usr_uid)
|
||||
public function deleteCase($appUid, $usrUid)
|
||||
{
|
||||
Validator::isString($app_uid, '$app_uid');
|
||||
Validator::appUid($app_uid, '$app_uid');
|
||||
Validator::isString($appUid, '$app_uid');
|
||||
Validator::appUid($appUid, '$app_uid');
|
||||
|
||||
$criteria = new Criteria();
|
||||
$criteria->addSelectColumn(ApplicationPeer::APP_STATUS);
|
||||
$criteria->addSelectColumn(ApplicationPeer::APP_INIT_USER);
|
||||
$criteria->add(ApplicationPeer::APP_UID, $app_uid, Criteria::EQUAL);
|
||||
$dataset = ApplicationPeer::doSelectRS($criteria);
|
||||
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$dataset->next();
|
||||
$aRow = $dataset->getRow();
|
||||
if ($aRow['APP_STATUS'] != 'DRAFT') {
|
||||
throw (new Exception(G::LoadTranslation("ID_DELETE_CASE_NO_STATUS")));
|
||||
// Review the permission for delete case
|
||||
global $RBAC;
|
||||
if ($RBAC->userCanAccess('PM_DELETECASE') != 1) {
|
||||
throw new Exception(G::LoadTranslation('ID_NOT_ABLE_DELETE_CASES'));
|
||||
}
|
||||
|
||||
if ($aRow['APP_INIT_USER'] != $usr_uid) {
|
||||
throw (new Exception(G::LoadTranslation("ID_DELETE_CASE_NO_OWNER")));
|
||||
// Review the status and user
|
||||
$caseInfo = ModelApplication::getCase($appUid);
|
||||
if (!empty($caseInfo)){
|
||||
// Review the status
|
||||
if ($caseInfo['APP_STATUS'] != 'DRAFT') {
|
||||
throw new Exception(G::LoadTranslation("ID_DELETE_CASE_NO_STATUS"));
|
||||
}
|
||||
// Review the user requester
|
||||
if ($caseInfo['APP_INIT_USER'] != $usrUid) {
|
||||
throw new Exception(G::LoadTranslation("ID_DELETE_CASE_NO_OWNER"));
|
||||
}
|
||||
}
|
||||
|
||||
$case = new ClassesCases();
|
||||
$case->removeCase($app_uid);
|
||||
$case->removeCase($appUid);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1733,7 +1736,7 @@ class Cases
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
private function __getFieldsAndValuesByDynaFormAndAppData(array $form, array $appData, array $caseVariable)
|
||||
private function getFieldsAndValuesByDynaFormAndAppData(array $form, array $appData, array $caseVariable)
|
||||
{
|
||||
try {
|
||||
foreach ($form['items'] as $value) {
|
||||
@@ -1754,7 +1757,7 @@ class Cases
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$caseVariableAux = $this->__getFieldsAndValuesByDynaFormAndAppData($field, $appData,
|
||||
$caseVariableAux = $this->getFieldsAndValuesByDynaFormAndAppData($field, $appData,
|
||||
$caseVariable);
|
||||
$caseVariable = array_merge($caseVariable, $caseVariableAux);
|
||||
}
|
||||
@@ -1827,7 +1830,7 @@ class Cases
|
||||
|
||||
$arrayAppData = $fields['APP_DATA'];
|
||||
|
||||
$arrayCaseVariable = $this->__getFieldsAndValuesByDynaFormAndAppData(
|
||||
$arrayCaseVariable = $this->getFieldsAndValuesByDynaFormAndAppData(
|
||||
$arrayDynContent['items'][0], $arrayAppData, $arrayCaseVariable
|
||||
);
|
||||
} else {
|
||||
@@ -2406,7 +2409,7 @@ class Cases
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
private function __getStatusInfoDataByRsCriteria($rsCriteria)
|
||||
private function getStatusInfoDataByRsCriteria($rsCriteria)
|
||||
{
|
||||
try {
|
||||
$arrayData = [];
|
||||
@@ -2489,7 +2492,7 @@ class Cases
|
||||
$rsCriteria = AppDelayPeer::doSelectRS($criteria);
|
||||
$rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
$arrayData = $this->__getStatusInfoDataByRsCriteria($rsCriteria);
|
||||
$arrayData = $this->getStatusInfoDataByRsCriteria($rsCriteria);
|
||||
|
||||
if (!empty($arrayData)) {
|
||||
return $arrayData;
|
||||
@@ -2522,7 +2525,7 @@ class Cases
|
||||
$rsCriteria = AppCacheViewPeer::doSelectRS($criteria);
|
||||
$rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
$arrayData = $this->__getStatusInfoDataByRsCriteria($rsCriteria);
|
||||
$arrayData = $this->getStatusInfoDataByRsCriteria($rsCriteria);
|
||||
|
||||
if (!empty($arrayData)) {
|
||||
return $arrayData;
|
||||
@@ -2565,7 +2568,7 @@ class Cases
|
||||
$rsCriteria = ApplicationPeer::doSelectRS($criteria);
|
||||
$rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
$arrayData = $this->__getStatusInfoDataByRsCriteria($rsCriteria);
|
||||
$arrayData = $this->getStatusInfoDataByRsCriteria($rsCriteria);
|
||||
|
||||
if (!empty($arrayData)) {
|
||||
return $arrayData;
|
||||
@@ -2605,7 +2608,7 @@ class Cases
|
||||
$rsCriteria2 = ApplicationPeer::doSelectRS($criteria2);
|
||||
$rsCriteria2->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
$arrayData = $this->__getStatusInfoDataByRsCriteria($rsCriteria2);
|
||||
$arrayData = $this->getStatusInfoDataByRsCriteria($rsCriteria2);
|
||||
|
||||
if (!empty($arrayData)) {
|
||||
return $arrayData;
|
||||
@@ -3152,7 +3155,7 @@ class Cases
|
||||
*
|
||||
* @return array Returns array with Case data updated
|
||||
*/
|
||||
private function __applicationDataDeleteMultipleFile(
|
||||
private function applicationDataDeleteMultipleFile(
|
||||
array $arrayApplicationData,
|
||||
$variable1,
|
||||
$variable2,
|
||||
@@ -3198,7 +3201,7 @@ class Cases
|
||||
case 'GRID':
|
||||
foreach ($arrayApplicationData[$variable1] as $key => $value) {
|
||||
if (array_key_exists($variable2, $value)) {
|
||||
$arrayApplicationData[$variable1][$key] = $this->__applicationDataDeleteMultipleFile(
|
||||
$arrayApplicationData[$variable1][$key] = $this->applicationDataDeleteMultipleFile(
|
||||
$value, $variable2, null, 'NORMAL', $arrayDocumentToDelete
|
||||
);
|
||||
}
|
||||
@@ -3254,7 +3257,7 @@ class Cases
|
||||
foreach ($arrayDocumentDelete as $value2) {
|
||||
$appDocument->remove($value2['appDocUid'], (int)($value2['version']));
|
||||
|
||||
$arrayApplicationData['APP_DATA'] = $this->__applicationDataDeleteMultipleFile(
|
||||
$arrayApplicationData['APP_DATA'] = $this->applicationDataDeleteMultipleFile(
|
||||
$arrayApplicationData['APP_DATA'], $variable, null, $type, $value2
|
||||
);
|
||||
|
||||
@@ -3272,7 +3275,7 @@ class Cases
|
||||
foreach ($arrayDocumentDelete as $value4) {
|
||||
$appDocument->remove($value4['appDocUid'], (int)($value4['version']));
|
||||
|
||||
$arrayApplicationData['APP_DATA'] = $this->__applicationDataDeleteMultipleFile(
|
||||
$arrayApplicationData['APP_DATA'] = $this->applicationDataDeleteMultipleFile(
|
||||
$arrayApplicationData['APP_DATA'], $grid, $variable, $type, $value4
|
||||
);
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ class Variable extends Attribute
|
||||
* @return mixed Returns array with Application, AppDelegation and Variable record,
|
||||
* ThrowTheException/FALSE otherwise
|
||||
*/
|
||||
private function __getApplicationAppDelegationAndVariableRecordByData(
|
||||
private function getApplicationAppDelegationAndVariableRecordByData(
|
||||
$applicationUid,
|
||||
$delIndex,
|
||||
$variableName,
|
||||
@@ -144,7 +144,7 @@ class Variable extends Attribute
|
||||
*
|
||||
* @return array Returns an array with Fields of a Grid
|
||||
*/
|
||||
private function __getGridFieldDefinitions($projectUid, $gridName)
|
||||
private function getGridFieldDefinitions($projectUid, $gridName)
|
||||
{
|
||||
try {
|
||||
$arrayGridField = [];
|
||||
@@ -202,7 +202,7 @@ class Variable extends Attribute
|
||||
*
|
||||
* @return bool Returns TRUE when array data is valid, ThrowTheException/FALSE otherwise
|
||||
*/
|
||||
private function __validateData(array $arrayData, array $arrayVariableData, $throwException = true)
|
||||
private function validateData(array $arrayData, array $arrayVariableData, $throwException = true)
|
||||
{
|
||||
try {
|
||||
if (empty($arrayData)) {
|
||||
@@ -303,7 +303,7 @@ class Variable extends Attribute
|
||||
{
|
||||
try {
|
||||
//Verify data and Set variables
|
||||
$result = $this->__getApplicationAppDelegationAndVariableRecordByData(
|
||||
$result = $this->getApplicationAppDelegationAndVariableRecordByData(
|
||||
$applicationUid, $delIndex, $variableName, $throwException
|
||||
);
|
||||
|
||||
@@ -329,12 +329,12 @@ class Variable extends Attribute
|
||||
}
|
||||
|
||||
if ($arrayVariableData['VAR_FIELD_TYPE'] == 'grid') {
|
||||
$arrayVariableData['arrayGridField'] = $this->__getGridFieldDefinitions(
|
||||
$arrayVariableData['arrayGridField'] = $this->getGridFieldDefinitions(
|
||||
$arrayVariableData['PRJ_UID'], $arrayVariableData['VAR_NAME']
|
||||
);
|
||||
}
|
||||
|
||||
$result = $this->__validateData($arrayData, $arrayVariableData, $throwException);
|
||||
$result = $this->validateData($arrayData, $arrayVariableData, $throwException);
|
||||
|
||||
if ($result === false) {
|
||||
return false;
|
||||
@@ -396,7 +396,7 @@ class Variable extends Attribute
|
||||
{
|
||||
try {
|
||||
//Verify data and Set variables
|
||||
$result = $this->__getApplicationAppDelegationAndVariableRecordByData(
|
||||
$result = $this->getApplicationAppDelegationAndVariableRecordByData(
|
||||
$applicationUid, $delIndex, $variableName, $throwException
|
||||
);
|
||||
|
||||
@@ -420,12 +420,12 @@ class Variable extends Attribute
|
||||
}
|
||||
|
||||
if ($arrayVariableData['VAR_FIELD_TYPE'] == 'grid') {
|
||||
$arrayVariableData['arrayGridField'] = $this->__getGridFieldDefinitions(
|
||||
$arrayVariableData['arrayGridField'] = $this->getGridFieldDefinitions(
|
||||
$arrayVariableData['PRJ_UID'], $arrayVariableData['VAR_NAME']
|
||||
);
|
||||
}
|
||||
|
||||
$result = $this->__validateData($arrayData, $arrayVariableData, $throwException);
|
||||
$result = $this->validateData($arrayData, $arrayVariableData, $throwException);
|
||||
|
||||
if ($result === false) {
|
||||
return false;
|
||||
@@ -490,7 +490,7 @@ class Variable extends Attribute
|
||||
{
|
||||
try {
|
||||
//Verify data and Set variables
|
||||
$result = $this->__getApplicationAppDelegationAndVariableRecordByData(
|
||||
$result = $this->getApplicationAppDelegationAndVariableRecordByData(
|
||||
$applicationUid, $delIndex, $variableName, $throwException
|
||||
);
|
||||
|
||||
@@ -605,7 +605,7 @@ class Variable extends Attribute
|
||||
$arrayVariable = [];
|
||||
|
||||
//Verify data and Set variables
|
||||
$result = $this->__getApplicationAppDelegationAndVariableRecordByData(
|
||||
$result = $this->getApplicationAppDelegationAndVariableRecordByData(
|
||||
$applicationUid, $delIndex, $variableName, $throwException
|
||||
);
|
||||
|
||||
@@ -696,7 +696,7 @@ class Variable extends Attribute
|
||||
}
|
||||
}
|
||||
|
||||
$result = $this->__getApplicationAppDelegationAndVariableRecordByData(
|
||||
$result = $this->getApplicationAppDelegationAndVariableRecordByData(
|
||||
$applicationUid, $delIndex, $variableName, $throwException
|
||||
);
|
||||
|
||||
|
||||
@@ -226,7 +226,7 @@ class Department
|
||||
* @param array $record Record
|
||||
* @return array Return an array with custom record
|
||||
*/
|
||||
private function __getUserCustomRecordFromRecord(array $record)
|
||||
private function getUserCustomRecordFromRecord(array $record)
|
||||
{
|
||||
try {
|
||||
$recordc = [
|
||||
@@ -414,7 +414,7 @@ class Department
|
||||
break;
|
||||
}
|
||||
|
||||
$arrayUser[] = ($flagRecord)? $record : $this->__getUserCustomRecordFromRecord($record);
|
||||
$arrayUser[] = ($flagRecord)? $record : $this->getUserCustomRecordFromRecord($record);
|
||||
}
|
||||
|
||||
//Return
|
||||
|
||||
@@ -696,9 +696,8 @@ class Light
|
||||
$sAppDocUid = $oAppDocument->getAppDocUid();
|
||||
$iDocVersion = $oAppDocument->getDocVersion();
|
||||
$info = pathinfo($oAppDocument->getAppDocFilename());
|
||||
$ext = (isset($info['extension']) ? $info['extension'] : '');//BUG fix: must handle files without any extension
|
||||
$ext = (isset($info['extension']) ? $info['extension'] : ''); //BUG fix: must handle files without any extension
|
||||
|
||||
//$app_uid = G::getPathFromUID($oAppDocument->Fields['APP_UID']);
|
||||
$file = G::getPathFromFileUID($oAppDocument->Fields['APP_UID'], $sAppDocUid);
|
||||
|
||||
$realPath = PATH_DOCUMENT . G::getPathFromUID($app_uid) . '/' . $file[0] . $file[1] . '_' . $iDocVersion . '.' . $ext;
|
||||
@@ -1358,12 +1357,14 @@ class Light
|
||||
*/
|
||||
public function getConfiguration($params)
|
||||
{
|
||||
$response = [];
|
||||
|
||||
$sysConf = Bootstrap::getSystemConfiguration('', '', config("system.workspace"));
|
||||
$multiTimeZone = false;
|
||||
//Set Time Zone
|
||||
/*----------------------------------********---------------------------------*/
|
||||
if (\PMLicensedFeatures::getSingleton()->verifyfeature('oq3S29xemxEZXJpZEIzN01qenJUaStSekY4cTdJVm5vbWtVM0d4S2lJSS9qUT0=')) {
|
||||
$multiTimeZone = (int)($sysConf['system_utc_time_zone']) == 1;
|
||||
$multiTimeZone = (int) ($sysConf['system_utc_time_zone']) == 1;
|
||||
}
|
||||
/*----------------------------------********---------------------------------*/
|
||||
$tz = isset($_SESSION['USR_TIME_ZONE']) ? $_SESSION['USR_TIME_ZONE'] : $sysConf['time_zone'];
|
||||
@@ -1423,6 +1424,8 @@ class Light
|
||||
$response['tz'] = isset($_SESSION['USR_TIME_ZONE']) ? $_SESSION['USR_TIME_ZONE'] : $sysConf['time_zone'];
|
||||
}
|
||||
|
||||
$response['mobile_offline_tables_download_interval'] = $sysConf['mobile_offline_tables_download_interval'];
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
@@ -1431,13 +1434,13 @@ class Light
|
||||
switch (substr($size_str, -1)) {
|
||||
case 'M':
|
||||
case 'm':
|
||||
return (int)$size_str * 1048576;
|
||||
return (int) $size_str * 1048576;
|
||||
case 'K':
|
||||
case 'k':
|
||||
return (int)$size_str * 1024;
|
||||
return (int) $size_str * 1024;
|
||||
case 'G':
|
||||
case 'g':
|
||||
return (int)$size_str * 1073741824;
|
||||
return (int) $size_str * 1073741824;
|
||||
default:
|
||||
return $size_str;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ class ReportTable
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
private function __getDefaultColumns($type = 'NORMAL')
|
||||
private function getDefaultColumns($type = 'NORMAL')
|
||||
{
|
||||
$defaultColumns = [];
|
||||
$application = new \stdClass(); //APPLICATION KEY
|
||||
@@ -97,7 +97,7 @@ class ReportTable
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function __populateData(array $arrayTableData, array $tableNameMap)
|
||||
private function populateData(array $arrayTableData, array $tableNameMap)
|
||||
{
|
||||
try {
|
||||
$errors = '';
|
||||
@@ -408,7 +408,7 @@ class ReportTable
|
||||
//New report table
|
||||
if ($flagIsReportTable && $flagAlterTable) {
|
||||
//Setting default columns
|
||||
$defaultColumns = $this->__getDefaultColumns($arrayData['REP_TAB_TYPE']);
|
||||
$defaultColumns = $this->getDefaultColumns($arrayData['REP_TAB_TYPE']);
|
||||
$columns = array_merge($defaultColumns, $columns);
|
||||
}
|
||||
|
||||
@@ -486,7 +486,9 @@ class ReportTable
|
||||
'DBS_UID' => ($arrayData['REP_TAB_CONNECTION']) ? $arrayData['REP_TAB_CONNECTION'] : 'workflow',
|
||||
'PRO_UID' => $arrayData['PRO_UID'],
|
||||
'ADD_TAB_TYPE' => $arrayData['REP_TAB_TYPE'],
|
||||
'ADD_TAB_GRID' => $arrayData['REP_TAB_GRID']
|
||||
'ADD_TAB_GRID' => $arrayData['REP_TAB_GRID'],
|
||||
'ADD_TAB_OFFLINE' => !empty($arrayData['REP_TAB_OFFLINE']) ?? 0,
|
||||
'ADD_TAB_UPDATE_DATE' => date('Y-m-d H:i:s'),
|
||||
];
|
||||
|
||||
if ($arrayData['REP_TAB_UID'] == '' || (isset($arrayData['forceUid']) && $arrayData['forceUid'])) {
|
||||
@@ -806,6 +808,8 @@ class ReportTable
|
||||
$tableData->REP_TAB_CONNECTION = $contentSchema['DBS_UID'];
|
||||
$tableData->REP_TAB_TYPE = (isset($contentSchema['ADD_TAB_TYPE'])) ? $contentSchema['ADD_TAB_TYPE'] : '';
|
||||
$tableData->REP_TAB_GRID = (isset($contentSchema['ADD_TAB_GRID'])) ? $contentSchema['ADD_TAB_GRID'] : '';
|
||||
$tableData->REP_TAB_OFFLINE = (isset($contentSchema['ADD_TAB_OFFLINE'])) ? $contentSchema['ADD_TAB_OFFLINE'] : '0';
|
||||
$tableData->REP_TAB_UPDATE_DATE = date('Y-m-d H:i:s');
|
||||
$tableData->columns = G::json_encode($columns);
|
||||
$tableData->forceUid = true;
|
||||
|
||||
@@ -835,7 +839,7 @@ class ReportTable
|
||||
}
|
||||
|
||||
if (!empty($tableNameMap)) {
|
||||
$errors = $this->__populateData($arrayTableData, $tableNameMap);
|
||||
$errors = $this->populateData($arrayTableData, $tableNameMap);
|
||||
}
|
||||
|
||||
//Return
|
||||
|
||||
@@ -20,7 +20,7 @@ class Table
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getTables($pro_uid = '', $reportFlag = false)
|
||||
public function getTables($pro_uid = '', $reportFlag = false, $offline = false)
|
||||
{
|
||||
//VALIDATION
|
||||
if ($reportFlag) {
|
||||
@@ -87,6 +87,7 @@ class Table
|
||||
$tabData['PMT_UID'] = $tab_uid;
|
||||
$tabData['PMT_TAB_NAME'] = $table['ADD_TAB_NAME'];
|
||||
$tabData['PMT_TAB_DESCRIPTION'] = $table['ADD_TAB_DESCRIPTION'];
|
||||
$tabData['PMT_TAB_OFFLINE'] = $table['ADD_TAB_OFFLINE'];
|
||||
$tabData['PMT_TAB_CLASS_NAME'] = $table['ADD_TAB_CLASS_NAME'];
|
||||
$tabData['PMT_NUM_ROWS'] = $tableData['count'];
|
||||
}
|
||||
@@ -384,6 +385,8 @@ class Table
|
||||
'ADD_TAB_NAME' => $dataValidate['REP_TAB_NAME'],
|
||||
'ADD_TAB_CLASS_NAME' => $repTabClassName,
|
||||
'ADD_TAB_DESCRIPTION' => $dataValidate['REP_TAB_DSC'],
|
||||
'ADD_TAB_OFFLINE' => 0,
|
||||
'ADD_TAB_UPDATE_DATE' => date('Y-m-d H:i:s'),
|
||||
'ADD_TAB_PLG_UID' => '',
|
||||
'DBS_UID' => ($dataValidate['REP_TAB_CONNECTION'] ? $dataValidate['REP_TAB_CONNECTION'] : 'workflow'),
|
||||
'PRO_UID' => $dataValidate['PRO_UID'],
|
||||
@@ -396,6 +399,8 @@ class Table
|
||||
'ADD_TAB_NAME' => $dataValidate['PMT_TAB_NAME'],
|
||||
'ADD_TAB_CLASS_NAME' => $repTabClassName,
|
||||
'ADD_TAB_DESCRIPTION' => $dataValidate['PMT_TAB_DSC'],
|
||||
'ADD_TAB_OFFLINE' => !empty($dataValidate['PMT_TAB_OFFLINE']) ?? 0,
|
||||
'ADD_TAB_UPDATE_DATE' => date('Y-m-d H:i:s'),
|
||||
'ADD_TAB_PLG_UID' => '',
|
||||
'DBS_UID' => ($dataValidate['PMT_TAB_CONNECTION'] ? $dataValidate['PMT_TAB_CONNECTION'] : 'workflow'),
|
||||
'PRO_UID' => '',
|
||||
@@ -549,6 +554,11 @@ class Table
|
||||
$dataValidate['rep_tab_dsc'] = $tableData['pmt_tab_dsc'];
|
||||
$tableDsc = true;
|
||||
}
|
||||
if (!empty($tableData['pmt_tab_offline'])) {
|
||||
$dataValidate['rep_tab_offline'] = $tableData['pmt_tab_offline'];
|
||||
$tableDsc = true;
|
||||
}
|
||||
$dataValidate['rep_tab_update_date'] = date('Y-m-d H:i:s');
|
||||
}
|
||||
if (!empty($tableData['fields'])) {
|
||||
$dataValidate['fields'] = $tableData['fields'];
|
||||
|
||||
@@ -640,7 +640,7 @@ class User
|
||||
* @return array Return an array with custom record
|
||||
* @throws Exception
|
||||
*/
|
||||
private function __getUserCustomRecordFromRecord(array $record)
|
||||
private function getUserCustomRecordFromRecord(array $record)
|
||||
{
|
||||
try {
|
||||
//Get Calendar
|
||||
@@ -1084,7 +1084,7 @@ class User
|
||||
$row = $rsCriteria->getRow();
|
||||
|
||||
//Return
|
||||
return (!$flagGetRecord) ? $this->__getUserCustomRecordFromRecord($row) : $row;
|
||||
return (!$flagGetRecord) ? $this->getUserCustomRecordFromRecord($row) : $row;
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
@@ -1494,7 +1494,7 @@ class User
|
||||
while ($rsCriteria->next()) {
|
||||
$record = $rsCriteria->getRow();
|
||||
|
||||
$arrayUser[] = ($flagRecord) ? $record : $this->__getUserCustomRecordFromRecord($record);
|
||||
$arrayUser[] = ($flagRecord) ? $record : $this->getUserCustomRecordFromRecord($record);
|
||||
}
|
||||
|
||||
//Return
|
||||
|
||||
@@ -73,7 +73,8 @@ class System
|
||||
'files_white_list' => '',
|
||||
'delay' => '0',
|
||||
'tries' => '10',
|
||||
'retry_after' => '90'
|
||||
'retry_after' => '90',
|
||||
'mobile_offline_tables_download_interval' => 24
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -1206,6 +1207,15 @@ class System
|
||||
$config['proxy_pass'] = G::decrypt($config['proxy_pass'], 'proxy_pass');
|
||||
}
|
||||
|
||||
/**
|
||||
* Here if you validate if the type of data obtained from the configuration
|
||||
* files are valid, otherwise the default value is used.
|
||||
*/
|
||||
$value = (string) $config['mobile_offline_tables_download_interval'];
|
||||
if (!is_numeric($value)) {
|
||||
$config['mobile_offline_tables_download_interval'] = self::$defaultConfig['mobile_offline_tables_download_interval'];
|
||||
}
|
||||
|
||||
return $config;
|
||||
}
|
||||
|
||||
|
||||
105
workflow/engine/src/ProcessMaker/Model/AdditionalTables.php
Normal file
105
workflow/engine/src/ProcessMaker/Model/AdditionalTables.php
Normal file
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Model;
|
||||
|
||||
use AdditionalTables as ModelAdditionalTables;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class AdditionalTables extends Model
|
||||
{
|
||||
protected $table = 'ADDITIONAL_TABLES';
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* Get the fields related to the table belongs to
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function columns()
|
||||
{
|
||||
return $this->belongsTo(Fields::class, 'ADD_TAB_UID', 'ADD_TAB_UID');
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to get the offline tables
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeOffline($query)
|
||||
{
|
||||
return $query->where('ADD_TAB_OFFLINE', '=', 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the structure of offline tables
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getTablesOfflineStructure()
|
||||
{
|
||||
$query = AdditionalTables::query()->select([
|
||||
'ADD_TAB_UID',
|
||||
'ADD_TAB_NAME',
|
||||
'ADD_TAB_DESCRIPTION',
|
||||
'ADD_TAB_CLASS_NAME'
|
||||
]);
|
||||
$query->offline();
|
||||
|
||||
$results = $query->get();
|
||||
$data = [];
|
||||
$results->each(function ($item, $key) use (&$data) {
|
||||
$data[$key] = array_change_key_case($item->toArray(), CASE_LOWER);
|
||||
$data[$key]['fields'] = Fields::getFields($item->ADD_TAB_UID);
|
||||
});
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data of offline tables
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getTablesOfflineData()
|
||||
{
|
||||
$query = AdditionalTables::query()->select([
|
||||
'ADD_TAB_UID',
|
||||
'ADD_TAB_NAME',
|
||||
'ADD_TAB_DESCRIPTION',
|
||||
'ADD_TAB_CLASS_NAME'
|
||||
]);
|
||||
$query->offline();
|
||||
|
||||
$results = $query->get();
|
||||
$data = [];
|
||||
$results->each(function ($item, $key) use (&$data) {
|
||||
$data[$key] = array_change_key_case($item->toArray(), CASE_LOWER);
|
||||
|
||||
$additionalTables = new ModelAdditionalTables();
|
||||
$result = $additionalTables->getAllData($item->ADD_TAB_UID);
|
||||
if (empty($result['rows'])) {
|
||||
$data[$key]['rows'] = [];
|
||||
} else {
|
||||
foreach ($result['rows'] as $i => $row) {
|
||||
$data[$key]['rows'][$i] = $row;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the offline property.
|
||||
* @param array $tablesUid
|
||||
* @param int $value
|
||||
* @return void
|
||||
*/
|
||||
public static function updatePropertyOffline(array $tablesUid, $value): void
|
||||
{
|
||||
$query = AdditionalTables::whereIn('ADD_TAB_UID', $tablesUid)
|
||||
->update(['ADD_TAB_OFFLINE' => $value]);
|
||||
}
|
||||
}
|
||||
@@ -27,24 +27,23 @@ class Application extends Model
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Applications by PRO_UID, ordered by APP_NUMBER.
|
||||
* @param string $proUid
|
||||
* @return object
|
||||
* @see ReportTables->populateTable()
|
||||
* Scope for query to get the application by APP_UID.
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param string $appUid
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public static function getByProUid($proUid)
|
||||
public function scopeAppUid($query, $appUid)
|
||||
{
|
||||
$query = Application::query()
|
||||
->select()
|
||||
->proUid($proUid)
|
||||
->orderBy('APP_NUMBER', 'ASC');
|
||||
return $query->get();
|
||||
$result = $query->where('APP_UID', '=', $appUid);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope for query to get the applications by PRO_UID.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param string $proUid
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeProUid($query, $proUid)
|
||||
@@ -52,4 +51,38 @@ class Application extends Model
|
||||
$result = $query->where('PRO_UID', '=', $proUid);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Applications by PRO_UID, ordered by APP_NUMBER.
|
||||
*
|
||||
* @param string $proUid
|
||||
*
|
||||
* @return object
|
||||
* @see ReportTables->populateTable()
|
||||
*/
|
||||
public static function getByProUid($proUid)
|
||||
{
|
||||
$query = Application::query()
|
||||
->select()
|
||||
->proUid($proUid)
|
||||
->orderBy('APP_NUMBER', 'ASC');
|
||||
return $query->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get information related to the created case
|
||||
*
|
||||
* @param string $appUid
|
||||
*
|
||||
* @return array|bool
|
||||
*/
|
||||
public static function getCase($appUid)
|
||||
{
|
||||
$query = Application::query()->select(['APP_STATUS', 'APP_INIT_USER']);
|
||||
$query->appUid($appUid);
|
||||
$result = $query->get()->toArray();
|
||||
$firstElement = head($result);
|
||||
|
||||
return $firstElement;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,10 @@ class Delegation extends Model
|
||||
// We don't have our standard timestamp columns
|
||||
public $timestamps = false;
|
||||
|
||||
// Static properties to preserve values
|
||||
public static $usrUid = '';
|
||||
public static $groups = [];
|
||||
|
||||
/**
|
||||
* Returns the application this delegation belongs to
|
||||
*/
|
||||
@@ -478,39 +482,81 @@ class Delegation extends Model
|
||||
*/
|
||||
public static function countSelfService($usrUid)
|
||||
{
|
||||
//Get the task self services related to the user
|
||||
$taskSelfService = TaskUser::getSelfServicePerUser($usrUid);
|
||||
//Get the task self services value based related to the user
|
||||
$selfServiceValueBased = AppAssignSelfServiceValue::getSelfServiceCasesByEvaluatePerUser($usrUid);
|
||||
// Set the 'usrUid' property to preserve
|
||||
Delegation::$usrUid = $usrUid;
|
||||
|
||||
//Start the query for get the cases related to the user
|
||||
$query = Delegation::query()->select('APP_NUMBER');
|
||||
//Add Join with task filtering only the type self-service
|
||||
$query->join('TASK', function ($join) {
|
||||
$join->on('APP_DELEGATION.TAS_ID', '=', 'TASK.TAS_ID')
|
||||
->where('TASK.TAS_ASSIGN_TYPE', '=', 'SELF_SERVICE');
|
||||
// Get and build the groups parameter related to the user
|
||||
$groups = GroupUser::getGroups($usrUid);
|
||||
$groups = array_map(function ($value) {
|
||||
return "'" . $value['GRP_ID'] . "'";
|
||||
}, $groups);
|
||||
|
||||
// Add dummy value to avoid syntax error in complex join
|
||||
$groups[] = "'-1'";
|
||||
|
||||
// Set the 'groups' property to preserve
|
||||
Delegation::$groups = $groups;
|
||||
|
||||
// Start the first query
|
||||
$query1 = Delegation::query()->select('APP_NUMBER');
|
||||
|
||||
// Add the join clause
|
||||
$query1->join('TASK', function ($join) {
|
||||
// Build partial plain query for a complex Join, because Eloquent doesn't support this type of Join
|
||||
$complexJoin = "
|
||||
((`APP_DELEGATION`.`APP_NUMBER`, `APP_DELEGATION`.`DEL_INDEX`, `APP_DELEGATION`.`TAS_ID`) IN (
|
||||
SELECT
|
||||
`APP_ASSIGN_SELF_SERVICE_VALUE`.`APP_NUMBER`,
|
||||
`APP_ASSIGN_SELF_SERVICE_VALUE`.`DEL_INDEX`,
|
||||
`APP_ASSIGN_SELF_SERVICE_VALUE`.`TAS_ID`
|
||||
FROM
|
||||
`APP_ASSIGN_SELF_SERVICE_VALUE`
|
||||
INNER JOIN `APP_ASSIGN_SELF_SERVICE_VALUE_GROUP` ON
|
||||
`APP_ASSIGN_SELF_SERVICE_VALUE`.`ID` = `APP_ASSIGN_SELF_SERVICE_VALUE_GROUP`.`ID`
|
||||
WHERE (
|
||||
`APP_ASSIGN_SELF_SERVICE_VALUE_GROUP`.`GRP_UID` = '%s' OR (
|
||||
`APP_ASSIGN_SELF_SERVICE_VALUE_GROUP`.`ASSIGNEE_ID` IN (%s) AND
|
||||
`APP_ASSIGN_SELF_SERVICE_VALUE_GROUP`.`ASSIGNEE_TYPE` = '2')
|
||||
)
|
||||
))";
|
||||
$groups = implode(',', Delegation::$groups);
|
||||
$complexJoin = sprintf($complexJoin, Delegation::$usrUid, $groups);
|
||||
|
||||
// Add joins
|
||||
$join->on('APP_DELEGATION.TAS_ID', '=', 'TASK.TAS_ID');
|
||||
$join->on('TASK.TAS_ASSIGN_TYPE', '=', DB::raw("'SELF_SERVICE'"));
|
||||
$join->on('APP_DELEGATION.DEL_THREAD_STATUS', '=', DB::raw("'OPEN'"));
|
||||
$join->on('APP_DELEGATION.USR_ID', '=', DB::raw("'0'"))->
|
||||
whereRaw($complexJoin);
|
||||
});
|
||||
//Filtering the open threads and without users
|
||||
$query->isThreadOpen()->noUserInThread();
|
||||
|
||||
//Get the cases unassigned
|
||||
if (!empty($selfServiceValueBased)) {
|
||||
$query->where(function ($query) use ($selfServiceValueBased, $taskSelfService) {
|
||||
//Get the cases related to the task self service
|
||||
$query->tasksIn($taskSelfService);
|
||||
foreach ($selfServiceValueBased as $case) {
|
||||
//Get the cases related to the task self service value based
|
||||
$query->orWhere(function ($query) use ($case) {
|
||||
$query->case($case['APP_NUMBER'])->index($case['DEL_INDEX'])->task($case['TAS_ID']);
|
||||
});
|
||||
}
|
||||
});
|
||||
// Get self services tasks related to the user
|
||||
$selfServiceTasks = TaskUser::getSelfServicePerUser($usrUid);
|
||||
|
||||
if (!empty($selfServiceTasks)) {
|
||||
// Start the first query
|
||||
$query2 = Delegation::query()->select('APP_NUMBER');
|
||||
$query2->tasksIn($selfServiceTasks);
|
||||
$query2->noUserInThread();
|
||||
|
||||
// Build the complex query that uses "UNION DISTINCT" clause
|
||||
$unionQuery = sprintf('select count(*) as aggregate from ((%s) union distinct (%s)) self_service_cases',
|
||||
toSqlWithBindings($query1), toSqlWithBindings($query2));
|
||||
|
||||
// Execute the query
|
||||
$result = DB::selectOne($unionQuery);
|
||||
$count = $result->aggregate;
|
||||
} else {
|
||||
//Get the cases related to the task self service
|
||||
$query->tasksIn($taskSelfService);
|
||||
// Execute the query
|
||||
$count = $query1->count();
|
||||
}
|
||||
|
||||
return $query->count();
|
||||
// Clean static properties
|
||||
Delegation::$usrUid = '';
|
||||
Delegation::$groups = [];
|
||||
|
||||
// Return value
|
||||
return $count;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
55
workflow/engine/src/ProcessMaker/Model/Fields.php
Normal file
55
workflow/engine/src/ProcessMaker/Model/Fields.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Model;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Fields extends Model
|
||||
{
|
||||
protected $table = 'FIELDS';
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* Get the fields related to the table belongs to
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function table()
|
||||
{
|
||||
return $this->belongsTo(AdditionalTables::class, 'ADD_TAB_UID', 'ADD_TAB_UID');
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to get the offline tables
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param string $tabUid
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeTable($query, $tabUid)
|
||||
{
|
||||
return $query->where('ADD_TAB_UID', '=', $tabUid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the offline tables
|
||||
*
|
||||
* @param string $tabUid
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getFields($tabUid)
|
||||
{
|
||||
$query = Fields::query();
|
||||
$query->table($tabUid);
|
||||
|
||||
$results = $query->get();
|
||||
$data = [];
|
||||
$results->each(function ($item, $key) use (&$data) {
|
||||
$data[$key] = array_change_key_case($item->toArray(), CASE_LOWER);
|
||||
});
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -1502,6 +1502,7 @@ class PluginRegistry
|
||||
return $oMenuFromPlugin[$strMenuName];
|
||||
}
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -87,9 +87,9 @@ class WorkflowBpmn extends Project\Workflow
|
||||
return parent::getList($start, $limit, $filter, $changeCaseTo);
|
||||
}
|
||||
|
||||
public function remove()
|
||||
public function remove($flagRemoveCases = true, $onlyDiagram = false)
|
||||
{
|
||||
parent::remove();
|
||||
parent::remove($flagRemoveCases, $onlyDiagram);
|
||||
$this->bp->remove();
|
||||
}
|
||||
|
||||
|
||||
@@ -1169,12 +1169,13 @@ class Workflow extends Handler
|
||||
|
||||
//Getting DynaForms
|
||||
foreach ($workflowData["dynaforms"] as $dynaform) {
|
||||
$dynFile = PATH_DYNAFORM . $dynaform["DYN_FILENAME"] . ".xml";
|
||||
$dynFile = PATH_DYNAFORM . $dynaform["PRO_UID"] . "/" . $dynaform["DYN_UID"] . ".xml";
|
||||
$content = file_exists($dynFile) ? file_get_contents($dynFile) : '';
|
||||
|
||||
$workflowFile["DYNAFORMS"][] = array(
|
||||
"filename" => $dynaform["DYN_TITLE"],
|
||||
"filepath" => $dynaform["DYN_FILENAME"] . ".xml",
|
||||
"file_content" => file_get_contents($dynFile)
|
||||
"file_content" => $content
|
||||
);
|
||||
|
||||
$htmlFile = PATH_DYNAFORM . $dynaform["DYN_FILENAME"] . ".html";
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Services\Api;
|
||||
|
||||
use Exception;
|
||||
use Luracast\Restler\RestException;
|
||||
use ProcessMaker\BusinessModel\Table as BusinessModelTable;
|
||||
use ProcessMaker\Model\AdditionalTables;
|
||||
use ProcessMaker\Services\Api;
|
||||
|
||||
/**
|
||||
@@ -14,85 +16,137 @@ use ProcessMaker\Services\Api;
|
||||
class Pmtable extends Api
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
* Get a list of the PM tables in the workspace. It does not include any Report Table
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
* @url GET
|
||||
* @status 200
|
||||
*
|
||||
* @param boolean $offline {@from path}
|
||||
*
|
||||
* @return array
|
||||
* @throws RestException
|
||||
*
|
||||
* @access protected
|
||||
* @class AccessControl {@permission PM_SETUP_PM_TABLES}
|
||||
* @url GET
|
||||
* @class AccessControl {@permission PM_LOGIN}
|
||||
* @link https://wiki.processmaker.com/3.1/REST_API_Administration/PM_Tables#PM_Tables_List:_GET_.2Fpmtable
|
||||
*/
|
||||
public function doGetPmTables()
|
||||
public function doGetPmTables($offline = false)
|
||||
{
|
||||
try {
|
||||
$oPmTable = new \ProcessMaker\BusinessModel\Table();
|
||||
$response = $oPmTable->getTables();
|
||||
if ($offline) {
|
||||
$response = AdditionalTables::getTablesOfflineStructure();
|
||||
} else {
|
||||
$pmTable = new BusinessModelTable();
|
||||
$response = $pmTable->getTables();
|
||||
}
|
||||
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $pmt_uid {@min 1} {@max 32}
|
||||
* Get the data of the offline PM tables
|
||||
*
|
||||
* @url GET /offline/data
|
||||
* @status 200
|
||||
*
|
||||
* @param boolean $compress {@from path}
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
* @throws RestException
|
||||
*
|
||||
* @access protected
|
||||
* @class AccessControl {@permission PM_SETUP_PM_TABLES}
|
||||
* @class AccessControl {@permission PM_LOGIN}
|
||||
* @link https://wiki.processmaker.com/3.1/REST_API_Administration/PM_Tables#PM_Tables_List:_GET_.2Fpmtable
|
||||
*/
|
||||
public function doGetPmTablesDataOffline($compress = true)
|
||||
{
|
||||
try {
|
||||
$data = AdditionalTables::getTablesOfflineData();
|
||||
if ($compress) {
|
||||
$json = json_encode($data);
|
||||
$compressed = gzcompress($json, 5);
|
||||
echo $compressed;
|
||||
} else {
|
||||
return $data;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the structure from a specific PM Table, including a list of its fields and their properties.
|
||||
*
|
||||
* @url GET /:pmt_uid
|
||||
* @status 200
|
||||
*
|
||||
* @param string $pmt_uid {@min 1} {@max 32}
|
||||
*
|
||||
* @return array
|
||||
* @throws RestException
|
||||
*
|
||||
* @access protected
|
||||
* @class AccessControl {@permission PM_SETUP_PM_TABLES}
|
||||
* @link https://wiki.processmaker.com/3.1/REST_API_Administration/PM_Tables#Get_PM_Table_Structure:_GET_.2Fpmtable.2F.7Bpmt_uid.7D
|
||||
*/
|
||||
public function doGetPmTable($pmt_uid)
|
||||
{
|
||||
try {
|
||||
$oPmTable = new \ProcessMaker\BusinessModel\Table();
|
||||
$oPmTable = new BusinessModelTable();
|
||||
$response = $oPmTable->getTable($pmt_uid);
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data from a PM table
|
||||
*
|
||||
* @url GET /:pmt_uid/data
|
||||
* @status 200
|
||||
*
|
||||
* @param string $pmt_uid {@min 1} {@max 32}
|
||||
* @param string $filter
|
||||
* @param string $q
|
||||
* @return array
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
* @return array
|
||||
* @throws RestException
|
||||
*
|
||||
* @access protected
|
||||
* @class AccessControl {@permission PM_SETUP_PM_TABLES}
|
||||
* @url GET /:pmt_uid/data
|
||||
*
|
||||
*/
|
||||
public function doGetPmTableData($pmt_uid, $filter = null, $q = "")
|
||||
{
|
||||
try {
|
||||
$oPmTable = new \ProcessMaker\BusinessModel\Table();
|
||||
$oPmTable = new BusinessModelTable();
|
||||
$response = $oPmTable->getTableData($pmt_uid, null, $filter, false, $q);
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new PM Table
|
||||
*
|
||||
* @url POST
|
||||
* @status 201
|
||||
*
|
||||
* @param array $request_data
|
||||
* @param string $pmt_tab_name {@from body}
|
||||
* @param string $pmt_tab_dsc {@from body}
|
||||
* @return array
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
* @return array
|
||||
* @throws RestException
|
||||
*
|
||||
* @access protected
|
||||
* @class AccessControl {@permission PM_SETUP_PM_TABLES}
|
||||
* @url POST
|
||||
* @status 201
|
||||
*/
|
||||
public function doPostPmTable(
|
||||
$request_data,
|
||||
@@ -100,58 +154,58 @@ class Pmtable extends Api
|
||||
$pmt_tab_dsc = ''
|
||||
) {
|
||||
try {
|
||||
$oReportTable = new \ProcessMaker\BusinessModel\Table();
|
||||
$oReportTable = new BusinessModelTable();
|
||||
$response = $oReportTable->saveTable($request_data);
|
||||
if (isset($response['pro_uid'])) {
|
||||
unset($response['pro_uid']);
|
||||
}
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $pmt_uid {@min 1} {@max 32}
|
||||
* Add a new record to a PM Table
|
||||
*
|
||||
* @param array $request_data
|
||||
* @return array
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @access protected
|
||||
* @class AccessControl {@permission PM_SETUP_PM_TABLES}
|
||||
* @url POST /:pmt_uid/data
|
||||
* @status 201
|
||||
*
|
||||
* @param string $pmt_uid {@min 1} {@max 32}
|
||||
* @param array $request_data
|
||||
*
|
||||
* @return array
|
||||
* @throws RestException
|
||||
* @access protected
|
||||
* @class AccessControl {@permission PM_SETUP_PM_TABLES}
|
||||
*/
|
||||
public function doPostPmTableData(
|
||||
$pmt_uid,
|
||||
$request_data
|
||||
) {
|
||||
try {
|
||||
$oReportTable = new \ProcessMaker\BusinessModel\Table();
|
||||
$oReportTable = new BusinessModelTable();
|
||||
$response = $oReportTable->saveTableData($pmt_uid, $request_data);
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update pm-table.
|
||||
* Update the structure of a PM table.
|
||||
*
|
||||
* @url PUT /:pmt_uid
|
||||
* @status 200
|
||||
*
|
||||
* @param string $pmt_uid {@min 1} {@max 32}
|
||||
* @param array $request_data
|
||||
*
|
||||
* @return void
|
||||
* @throw RestException
|
||||
* @throws RestException
|
||||
*
|
||||
* @access protected
|
||||
* @class AccessControl {@permission PM_SETUP_PM_TABLES}
|
||||
* @throws RestException
|
||||
*/
|
||||
public function doPutPmTable(
|
||||
$pmt_uid,
|
||||
@@ -167,9 +221,10 @@ class Pmtable extends Api
|
||||
}
|
||||
|
||||
/**
|
||||
* Update pm-table data.
|
||||
* Update the data of an existing record in a PM table.
|
||||
*
|
||||
* @url PUT /:pmt_uid/data
|
||||
* @status 200
|
||||
*
|
||||
* @param string $pmt_uid {@min 1} {@max 32}
|
||||
* @param array $request_data
|
||||
@@ -185,37 +240,47 @@ class Pmtable extends Api
|
||||
$request_data
|
||||
) {
|
||||
try {
|
||||
$oReportTable = new \ProcessMaker\BusinessModel\Table();
|
||||
$oReportTable = new BusinessModelTable();
|
||||
$response = $oReportTable->updateTableData($pmt_uid, $request_data);
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a specified PM table and all its data.
|
||||
*
|
||||
* @url DELETE /:pmt_uid
|
||||
* @status 200
|
||||
*
|
||||
* @param string $pmt_uid {@min 1} {@max 32}
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
* @throws RestException
|
||||
*
|
||||
* @access protected
|
||||
* @class AccessControl {@permission PM_SETUP_PM_TABLES}
|
||||
* @url DELETE /:pmt_uid
|
||||
*/
|
||||
public function doDeletePmTable($pmt_uid)
|
||||
{
|
||||
try {
|
||||
$oReportTable = new \ProcessMaker\BusinessModel\Table();
|
||||
$oReportTable = new BusinessModelTable();
|
||||
$response = $oReportTable->deleteTable($pmt_uid);
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a record from a PM table, by specifying its primary key(s). The PM Table can have up to 3 primary key
|
||||
* fields.
|
||||
*
|
||||
* @url DELETE /:pmt_uid/data/:key1/:value1
|
||||
* @url DELETE /:pmt_uid/data/:key1/:value1/:key2/:value2
|
||||
* @url DELETE /:pmt_uid/data/:key1/:value1/:key2/:value2/:key3/:value3
|
||||
* @status 200
|
||||
*
|
||||
* @param string $pmt_uid {@min 1} {@max 32}
|
||||
* @param string $key1 {@min 1}
|
||||
* @param string $value1 {@min 1}
|
||||
@@ -225,15 +290,10 @@ class Pmtable extends Api
|
||||
* @param string $value3
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
* @throws RestException
|
||||
*
|
||||
* @access protected
|
||||
* @class AccessControl {@permission PM_SETUP_PM_TABLES}
|
||||
* @url DELETE /:pmt_uid/data/:key1/:value1
|
||||
* @url DELETE /:pmt_uid/data/:key1/:value1/:key2/:value2
|
||||
* @url DELETE /:pmt_uid/data/:key1/:value1/:key2/:value2/:key3/:value3
|
||||
*/
|
||||
public function doDeletePmTableData($pmt_uid, $key1, $value1, $key2 = '', $value2 = '', $key3 = '', $value3 = '')
|
||||
{
|
||||
@@ -245,10 +305,10 @@ class Pmtable extends Api
|
||||
if ($key3 != '') {
|
||||
$rows[$key3] = $value3;
|
||||
}
|
||||
$oReportTable = new \ProcessMaker\BusinessModel\Table();
|
||||
$oReportTable = new BusinessModelTable();
|
||||
$response = $oReportTable->deleteTableData($pmt_uid, $rows);
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Services\OAuth2;
|
||||
|
||||
use OAuth2\Server;
|
||||
|
||||
/**
|
||||
* Extended class where the properties are correctly initialized, compatibility with PHP 7.3.x
|
||||
*/
|
||||
class OAuth2Server extends Server
|
||||
{
|
||||
protected $responseTypes = [];
|
||||
}
|
||||
@@ -3,6 +3,7 @@ namespace ProcessMaker\Services\OAuth2;
|
||||
|
||||
use Luracast\Restler\iAuthenticate;
|
||||
use Luracast\Restler\RestException;
|
||||
use OAuth2\Request;
|
||||
/*----------------------------------********---------------------------------*/
|
||||
use ProcessMaker\ChangeLog\ChangeLog;
|
||||
/*----------------------------------********---------------------------------*/
|
||||
@@ -53,7 +54,7 @@ class Server implements iAuthenticate
|
||||
}
|
||||
|
||||
// Pass a storage object or array of storage objects to the OAuth2 server class
|
||||
$this->server = new \OAuth2\Server($this->storage, array('allow_implicit' => true, 'access_lifetime' => 86400));
|
||||
$this->server = new OAuth2Server($this->storage, array('allow_implicit' => true, 'access_lifetime' => 86400));
|
||||
|
||||
$this->server->setConfig('enforce_state', false);
|
||||
|
||||
@@ -411,6 +412,19 @@ class Server implements iAuthenticate
|
||||
|
||||
public static function getUserId()
|
||||
{
|
||||
// If is empty, get the User Uid using the current request
|
||||
if (empty(self::$userId) && !empty(self::$dsn)) {
|
||||
// Get current request object
|
||||
$request = Request::createFromGlobals();
|
||||
|
||||
// Get token data
|
||||
$serverInstance = new Server();
|
||||
$server = $serverInstance->getServer();
|
||||
$tokenData = $server->getAccessTokenData($request);
|
||||
|
||||
// Set the User Uid
|
||||
self::$userId = $tokenData['user_id'];
|
||||
}
|
||||
return self::$userId;
|
||||
}
|
||||
|
||||
|
||||
@@ -545,3 +545,34 @@ function updateUserLastLogin($userLog, $keyLastLogin = 'LOG_INIT_DATE')
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return raw query with the bindings replaced
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $queryObject
|
||||
* @return string
|
||||
*/
|
||||
function toSqlWithBindings(Illuminate\Database\Eloquent\Builder $queryObject) {
|
||||
// Get some values from the object
|
||||
$bindings = $queryObject->getBindings();
|
||||
$originalQuery = $queryObject->toSql();
|
||||
|
||||
// If not exist bindings, return the original query
|
||||
if (empty($bindings)) {
|
||||
return $originalQuery;
|
||||
}
|
||||
|
||||
// Initializing another variables
|
||||
$queryParts = explode('?', $originalQuery);
|
||||
$pdo = $queryObject->getConnection()->getPdo();
|
||||
$query = '';
|
||||
|
||||
// Walking the parts of the query replacing the bindings
|
||||
foreach ($queryParts as $index => $part) {
|
||||
if ($index < count($queryParts) - 1) {
|
||||
$query .= $part . $pdo->quote($bindings[$index]);
|
||||
}
|
||||
}
|
||||
|
||||
// Return query
|
||||
return $query;
|
||||
}
|
||||
|
||||
@@ -70,18 +70,18 @@ class ValidationUploadedFiles
|
||||
->validate($file, function($file) {
|
||||
$systemConfiguration = System::getSystemConfiguration('', '', config("system.workspace"));
|
||||
$filesWhiteList = explode(',', $systemConfiguration['upload_attempts_limit_per_user']);
|
||||
$userId = Server::getUserId();
|
||||
$userId = !empty($_SESSION['USER_LOGGED']) ? $_SESSION['USER_LOGGED'] : Server::getUserId();
|
||||
$key = config("system.workspace") . '/' . $userId;
|
||||
$attemps = (int) trim($filesWhiteList[0]);
|
||||
$attempts = (int) trim($filesWhiteList[0]);
|
||||
$minutes = (int) trim($filesWhiteList[1]);
|
||||
$pastAttemps = Cache::remember($key, $minutes, function() {
|
||||
return 1;
|
||||
});
|
||||
$pastAttempts = Cache::remember($key, $minutes, function() {
|
||||
return 1;
|
||||
});
|
||||
//We only increase when the file path exists, useful when pre-validation is done.
|
||||
if (isset($file->path)) {
|
||||
Cache::increment($key, 1);
|
||||
}
|
||||
if ($pastAttemps <= $attemps) {
|
||||
if ($pastAttempts <= $attempts) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user