Merged in bugfix/PMCORE-1464 (pull request #8413)
PMCORE-1464 Approved-by: Julio Cesar Laura Avendaño
This commit is contained in:
@@ -808,7 +808,7 @@ class AppDelegation extends BaseAppDelegation
|
|||||||
return $rs->getRow();
|
return $rs->getRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCurrentIndex($appUid)
|
public static function getCurrentIndex($appUid)
|
||||||
{
|
{
|
||||||
$oCriteria = new Criteria();
|
$oCriteria = new Criteria();
|
||||||
$oCriteria->addSelectColumn(AppDelegationPeer::DEL_INDEX);
|
$oCriteria->addSelectColumn(AppDelegationPeer::DEL_INDEX);
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ use G;
|
|||||||
use ObjectPermissionPeer;
|
use ObjectPermissionPeer;
|
||||||
use ProcessMaker\BusinessModel\Cases AS BusinessModelCases;
|
use ProcessMaker\BusinessModel\Cases AS BusinessModelCases;
|
||||||
use ProcessMaker\BusinessModel\ProcessSupervisor;
|
use ProcessMaker\BusinessModel\ProcessSupervisor;
|
||||||
|
use ProcessMaker\Model\Application;
|
||||||
|
use ProcessMaker\Model\Delegation;
|
||||||
use ProcessMaker\Plugins\PluginRegistry;
|
use ProcessMaker\Plugins\PluginRegistry;
|
||||||
use ProcessMaker\Validation\ValidationUploadedFiles;
|
use ProcessMaker\Validation\ValidationUploadedFiles;
|
||||||
use ProcessUserPeer;
|
use ProcessUserPeer;
|
||||||
@@ -769,7 +771,7 @@ class InputDocument
|
|||||||
/**
|
/**
|
||||||
* Get data of Cases InputDocument
|
* Get data of Cases InputDocument
|
||||||
*
|
*
|
||||||
* @param string $applicationUid
|
* @param string $appUid
|
||||||
* @param string $taskUid
|
* @param string $taskUid
|
||||||
* @param string $appDocComment
|
* @param string $appDocComment
|
||||||
* @param string $inputDocumentUid
|
* @param string $inputDocumentUid
|
||||||
@@ -778,7 +780,7 @@ class InputDocument
|
|||||||
* @return array Return an array with data of an InputDocument
|
* @return array Return an array with data of an InputDocument
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function addCasesInputDocument($applicationUid, $taskUid, $appDocComment, $inputDocumentUid, $userUid, $runningWorkflow = true)
|
public function addCasesInputDocument($appUid, $taskUid, $appDocComment, $inputDocumentUid, $userUid, $runningWorkflow = true)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if ((isset( $_FILES['form'] )) && ($_FILES['form']['error'] != 0)) {
|
if ((isset( $_FILES['form'] )) && ($_FILES['form']['error'] != 0)) {
|
||||||
@@ -818,64 +820,49 @@ class InputDocument
|
|||||||
$appDocUid = G::generateUniqueID();
|
$appDocUid = G::generateUniqueID();
|
||||||
$docVersion = '';
|
$docVersion = '';
|
||||||
$appDocType = 'INPUT';
|
$appDocType = 'INPUT';
|
||||||
|
$delIndex = AppDelegation::getCurrentIndex($appUid);
|
||||||
$case = new Cases();
|
$case = new Cases();
|
||||||
$delIndex = AppDelegation::getCurrentIndex($applicationUid);
|
|
||||||
|
|
||||||
if ($runningWorkflow) {
|
if ($runningWorkflow) {
|
||||||
$case->thisIsTheCurrentUser($applicationUid, $delIndex, $userUid, 'REDIRECT', 'casesListExtJs');
|
$case->thisIsTheCurrentUser($appUid, $delIndex, $userUid, 'REDIRECT', 'casesListExtJs');
|
||||||
} else {
|
} else {
|
||||||
$criteria = new Criteria('workflow');
|
$appInfo = Application::getCase($appUid);
|
||||||
|
$proUid = $appInfo['PRO_UID'];
|
||||||
$criteria->add(AppDelegationPeer::APP_UID, $applicationUid);
|
$appNumber = $appInfo['APP_NUMBER'];
|
||||||
$criteria->add(AppDelegationPeer::DEL_INDEX, $delIndex);
|
$msg = '';
|
||||||
$criteria->add(AppDelegationPeer::USR_UID, $userUid);
|
// Check the current user
|
||||||
|
$currentUser = Delegation::getCurrentUser($appNumber, $delIndex);
|
||||||
$rsCriteria = ProcessUserPeer::doSelectRS($criteria);
|
if ($currentUser !== $userUid) {
|
||||||
|
// Review if is a supervisor
|
||||||
if (!$rsCriteria->next()) {
|
|
||||||
$case2 = new BusinessModelCases();
|
|
||||||
|
|
||||||
$arrayApplicationData = $case2->getApplicationRecordByPk($applicationUid, [], false);
|
|
||||||
|
|
||||||
$msg = '';
|
|
||||||
|
|
||||||
$supervisor = new ProcessSupervisor();
|
$supervisor = new ProcessSupervisor();
|
||||||
$flagps = $supervisor->isUserProcessSupervisor($arrayApplicationData['PRO_UID'], $userUid);
|
$isSupervisor = $supervisor->isUserProcessSupervisor($proUid, $userUid);
|
||||||
|
if ($isSupervisor) {
|
||||||
if ($flagps == false) {
|
|
||||||
$msg = G::LoadTranslation('ID_USER_NOT_IT_BELONGS_CASE_OR_NOT_SUPERVISOR');
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($msg == '') {
|
|
||||||
$criteria = new Criteria('workflow');
|
$criteria = new Criteria('workflow');
|
||||||
|
$criteria->add(StepSupervisorPeer::PRO_UID, $proUid, Criteria::EQUAL);
|
||||||
$criteria->add(StepSupervisorPeer::PRO_UID, $arrayApplicationData['PRO_UID'], Criteria::EQUAL);
|
|
||||||
$criteria->add(StepSupervisorPeer::STEP_TYPE_OBJ, 'INPUT_DOCUMENT', Criteria::EQUAL);
|
$criteria->add(StepSupervisorPeer::STEP_TYPE_OBJ, 'INPUT_DOCUMENT', Criteria::EQUAL);
|
||||||
$criteria->add(StepSupervisorPeer::STEP_UID_OBJ, $inputDocumentUid, Criteria::EQUAL);
|
$criteria->add(StepSupervisorPeer::STEP_UID_OBJ, $inputDocumentUid, Criteria::EQUAL);
|
||||||
|
|
||||||
$rsCriteria = StepSupervisorPeer::doSelectRS($criteria);
|
$rsCriteria = StepSupervisorPeer::doSelectRS($criteria);
|
||||||
|
|
||||||
if (!$rsCriteria->next()) {
|
if (!$rsCriteria->next()) {
|
||||||
$msg = G::LoadTranslation('ID_USER_IS_SUPERVISOR_DOES_NOT_ASSOCIATED_INPUT_DOCUMENT');
|
$msg = G::LoadTranslation('ID_USER_IS_SUPERVISOR_DOES_NOT_ASSOCIATED_INPUT_DOCUMENT');
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$msg = G::LoadTranslation('ID_USER_NOT_IT_BELONGS_CASE_OR_NOT_SUPERVISOR');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (!empty($msg)) {
|
||||||
|
if ($runningWorkflow) {
|
||||||
|
G::SendMessageText($msg, 'ERROR');
|
||||||
|
$backUrlObj = explode('sys' . config("system.workspace"), $_SERVER['HTTP_REFERER']);
|
||||||
|
|
||||||
if ($msg != '') {
|
G::header('location: ' . '/sys' . config("system.workspace") . $backUrlObj[1]);
|
||||||
if ($runningWorkflow) {
|
exit(0);
|
||||||
G::SendMessageText($msg, 'ERROR');
|
} else {
|
||||||
$backUrlObj = explode('sys' . config("system.workspace"), $_SERVER['HTTP_REFERER']);
|
throw new Exception($msg);
|
||||||
|
|
||||||
G::header('location: ' . '/sys' . config("system.workspace") . $backUrlObj[1]);
|
|
||||||
exit(0);
|
|
||||||
} else {
|
|
||||||
throw new Exception($msg);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Load the fields
|
//Load the fields
|
||||||
$arrayField = $case->loadCase($applicationUid);
|
$arrayField = $case->loadCase($appUid);
|
||||||
$arrayField["APP_DATA"] = array_merge($arrayField["APP_DATA"], G::getSystemConstants());
|
$arrayField["APP_DATA"] = array_merge($arrayField["APP_DATA"], G::getSystemConstants());
|
||||||
//Validate Process Uid and Input Document Process Uid
|
//Validate Process Uid and Input Document Process Uid
|
||||||
$inputDocumentInstance = new \InputDocument();
|
$inputDocumentInstance = new \InputDocument();
|
||||||
@@ -900,7 +887,7 @@ class InputDocument
|
|||||||
$appDocType,
|
$appDocType,
|
||||||
$appDocComment,
|
$appDocComment,
|
||||||
'',
|
'',
|
||||||
$applicationUid,
|
$appUid,
|
||||||
$delIndex,
|
$delIndex,
|
||||||
$taskUid,
|
$taskUid,
|
||||||
$userUid,
|
$userUid,
|
||||||
@@ -910,7 +897,7 @@ class InputDocument
|
|||||||
$_FILES["form"]["tmp_name"]);
|
$_FILES["form"]["tmp_name"]);
|
||||||
}
|
}
|
||||||
//Trigger - Execute after - Start
|
//Trigger - Execute after - Start
|
||||||
$arrayField["APP_DATA"] = $case->executeTriggers ($taskUid,
|
$arrayField["APP_DATA"] = $case->executeTriggers($taskUid,
|
||||||
"INPUT_DOCUMENT",
|
"INPUT_DOCUMENT",
|
||||||
$inputDocumentUid,
|
$inputDocumentUid,
|
||||||
"AFTER",
|
"AFTER",
|
||||||
@@ -923,8 +910,8 @@ class InputDocument
|
|||||||
$arrayData["APP_DATA"] = $arrayField["APP_DATA"];
|
$arrayData["APP_DATA"] = $arrayField["APP_DATA"];
|
||||||
$arrayData["DEL_INDEX"] = $delIndex;
|
$arrayData["DEL_INDEX"] = $delIndex;
|
||||||
$arrayData["TAS_UID"] = $taskUid;
|
$arrayData["TAS_UID"] = $taskUid;
|
||||||
$case->updateCase($applicationUid, $arrayData);
|
$case->updateCase($appUid, $arrayData);
|
||||||
return($this->getCasesInputDocument($applicationUid, $userUid, $appDocUid));
|
return($this->getCasesInputDocument($appUid, $userUid, $appDocUid));
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user