From 33b7672e57977ce9e089dcee3ae1c6f02a54d6fe Mon Sep 17 00:00:00 2001 From: Paula Quispe Date: Thu, 24 May 2018 09:10:04 -0400 Subject: [PATCH] HOR-4589 --- .../src/ProcessMaker/BusinessModel/Light.php | 33 ++++++++++--------- .../src/ProcessMaker/Services/Api/Light.php | 6 ++-- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Light.php b/workflow/engine/src/ProcessMaker/BusinessModel/Light.php index 8b1c4ef9a..999fa8bfd 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Light.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Light.php @@ -6,6 +6,7 @@ use ProcessMaker\BusinessModel\Lists; use G; use Criteria; use UsersPeer; +use AppDelegation; use AppDelegationPeer; use AppDelayPeer; use ProcessMaker\Core\System; @@ -1076,28 +1077,30 @@ class Light } /** - * claim case + * Claim case * - * @param $userUid - * @param $Fields - * @param $type + * @param string $userUid + * @param string $appUid + * @param integer $delIndex + * + * @return array * @throws Exception */ - public function claimCaseUser($userUid, $sAppUid) + public function claimCaseUser($userUid, $appUid, $delIndex = null) { - $response = array("status" => "fail"); - $oCase = new Cases(); - $iDelIndex = $oCase->getCurrentDelegation($sAppUid, '', true); + $response = ['status' => 'fail']; + $case = new Cases(); + $appDelegation = new AppDelegation(); + if (empty($delIndex)) { + $delIndex = $case->getCurrentDelegation($appUid, '', true); + } - $oAppDelegation = new \AppDelegation(); - $aDelegation = $oAppDelegation->load($sAppUid, $iDelIndex); + $delegation = $appDelegation->Load($appUid, $delIndex); //if there are no user in the delegation row, this case is still in selfservice - if ($aDelegation['USR_UID'] == "") { - $oCase->setCatchUser($sAppUid, $iDelIndex, $userUid); - $response = array("status" => "ok"); - } else { - //G::SendMessageText( G::LoadTranslation( 'ID_CASE_ALREADY_DERIVATED' ), 'error' ); + if (empty($delegation['USR_UID'])) { + $case->setCatchUser($appUid, $delIndex, $userUid); + $response['status'] = 'ok'; } return $response; diff --git a/workflow/engine/src/ProcessMaker/Services/Api/Light.php b/workflow/engine/src/ProcessMaker/Services/Api/Light.php index 1d5360d38..f958feeae 100644 --- a/workflow/engine/src/ProcessMaker/Services/Api/Light.php +++ b/workflow/engine/src/ProcessMaker/Services/Api/Light.php @@ -1490,12 +1490,12 @@ class Light extends Api * @access protected * @class AccessControl {@permission PM_CASES} */ - public function claimCaseUser($app_uid) + public function claimCaseUser($app_uid, $del_index = null) { try { $userUid = $this->getUserId(); - $oMobile = new BusinessModelLight(); - $response = $oMobile->claimCaseUser($userUid, $app_uid); + $mobile = new BusinessModelLight(); + $response = $mobile->claimCaseUser($userUid, $app_uid, $del_index); } catch (Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); }