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