From a34cb606b7894edaa3fc3a0297a8dbc1785d7dd2 Mon Sep 17 00:00:00 2001 From: Paula Quispe Date: Wed, 23 Aug 2017 17:26:00 -0400 Subject: [PATCH] HOR-3778 --- workflow/engine/classes/model/ListInbox.php | 6 + .../engine/classes/model/ListUnassigned.php | 6 + .../src/ProcessMaker/BusinessModel/Light.php | 57 ++ .../src/ProcessMaker/BusinessModel/Lists.php | 35 +- .../src/ProcessMaker/Services/Api/Light.php | 872 ++++++++++-------- 5 files changed, 594 insertions(+), 382 deletions(-) diff --git a/workflow/engine/classes/model/ListInbox.php b/workflow/engine/classes/model/ListInbox.php index 619bebe1b..77fbfb4ab 100644 --- a/workflow/engine/classes/model/ListInbox.php +++ b/workflow/engine/classes/model/ListInbox.php @@ -406,6 +406,7 @@ class ListInbox extends BaseListInbox $filterStatus = isset($filters['filterStatus']) ? $filters['filterStatus'] : ''; $newestthan = isset($filters['newestthan']) ? $filters['newestthan'] : ''; $oldestthan = isset($filters['oldestthan']) ? $filters['oldestthan'] : ''; + $appUidCheck = isset($filters['appUidCheck']) ? $filters['appUidCheck'] : array(); //Check the inbox to call switch ($action) { @@ -503,6 +504,11 @@ class ListInbox extends BaseListInbox if ($oldestthan != '') { $criteria->add( $criteria->getNewCriterion( ListInboxPeer::DEL_DELEGATE_DATE, $oldestthan, Criteria::LESS_THAN )); } + + //Review in the specific lot of cases + if (!empty($appUidCheck)) { + $criteria->add(ListInboxPeer::APP_UID, $appUidCheck, Criteria::IN); + } } /** diff --git a/workflow/engine/classes/model/ListUnassigned.php b/workflow/engine/classes/model/ListUnassigned.php index 2f6a714ff..abfe3284b 100644 --- a/workflow/engine/classes/model/ListUnassigned.php +++ b/workflow/engine/classes/model/ListUnassigned.php @@ -182,6 +182,7 @@ class ListUnassigned extends BaseListUnassigned $category = isset($filters['category']) ? $filters['category'] : ''; $dateFrom = isset($filters['dateFrom']) ? $filters['dateFrom'] : ''; $dateTo = isset($filters['dateTo']) ? $filters['dateTo'] : ''; + $appUidCheck = isset($filters['appUidCheck']) ? $filters['appUidCheck'] : array(); //Filter Search if ($search != '') { @@ -208,6 +209,11 @@ class ListUnassigned extends BaseListUnassigned $aConditions[] = array(ProcessPeer::PRO_CATEGORY, "'" . $category . "'"); $criteria->addJoinMC($aConditions, Criteria::INNER_JOIN); } + + //Review in the specific lot of cases + if (!empty($appUidCheck)) { + $criteria->add(ListUnassignedPeer::APP_UID, $appUidCheck, Criteria::IN); + } } /** diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Light.php b/workflow/engine/src/ProcessMaker/BusinessModel/Light.php index 92a578e4c..2e3942477 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Light.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Light.php @@ -2,6 +2,8 @@ namespace ProcessMaker\BusinessModel; +use ProcessMaker\BusinessModel\Lists; +use ProcessMaker\BusinessModel\Cases; use G; use Criteria; use UsersPeer; @@ -1348,4 +1350,59 @@ class Light return $children; } + /** + * This function check if the $data are in the corresponding cases list + * @param string $userUid + * @param array $data + * @param string $listName + * @param string $action + * @return array $response + */ + public function getListCheck($userUid, $data, $listName = 'inbox', $action = 'todo') + { + $casesToCheck = []; + foreach ($data as $key => $val) { + array_push($casesToCheck, $val['caseId']); + } + $dataList = []; + $dataList['appUidCheck'] = $casesToCheck; + $dataList['userId'] = $userUid; + $dataList['action'] = $action; + /*----------------------------------********---------------------------------*/ + if (true) { + //In enterprise version this block of code should always be executed + //In community version this block of code is deleted and is executed the other + $list = new Lists(); + $response = $list->getList($listName, $dataList); + } else { + /*----------------------------------********---------------------------------*/ + $case = new Cases(); + $response = $case->getList($dataList); + + /*----------------------------------********---------------------------------*/ + } + /*----------------------------------********---------------------------------*/ + $result = []; + foreach ($data as $key => $val) { + $flagRemoved = true; + foreach ($response['data'] as $row) { + $row = array_change_key_case($row,CASE_UPPER); + if (isset($row['APP_UID']) && isset($row['DEL_INDEX'])) { + if ($val['caseId'] === $row['APP_UID'] && $val['delIndex'] === $row['DEL_INDEX'] ) { + $flagRemoved = false; + continue; + } + } + + } + if ($flagRemoved) { + $result[] = [ + 'caseId' => $val['caseId'], + 'delIndex' => $val['delIndex'] + ]; + } + } + + return $result; + } } diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Lists.php b/workflow/engine/src/ProcessMaker/BusinessModel/Lists.php index 7fc5eadf2..23f2be320 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Lists.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Lists.php @@ -98,25 +98,22 @@ class Lists { } $userUid = $dataList["userId"]; - $filters["paged"] = isset( $dataList["paged"] ) ? $dataList["paged"] : true; - $filters['count'] = isset( $dataList['count'] ) ? $dataList['count'] : true; - $filters["category"] = isset( $dataList["category"] ) ? $dataList["category"] : ""; - $filters["process"] = isset( $dataList["process"] ) ? $dataList["process"] : ""; - $filters["search"] = isset( $dataList["search"] ) ? $dataList["search"] : ""; - $filters["filter"] = isset( $dataList["filter"] ) ? $dataList["filter"] : ""; - $filters["dateFrom"] = (!empty( $dataList["dateFrom"] )) ? substr( $dataList["dateFrom"], 0, 10 ) : ""; - $filters["dateTo"] = (!empty( $dataList["dateTo"] )) ? substr( $dataList["dateTo"], 0, 10 ) : ""; - - $filters["start"] = isset( $dataList["start"] ) ? $dataList["start"] : "0"; - $filters["limit"] = isset( $dataList["limit"] ) ? $dataList["limit"] : "25"; - $filters["sort"] = isset( $dataList["sort"] ) ? $dataList["sort"] : ""; - $filters["dir"] = isset( $dataList["dir"] ) ? $dataList["dir"] : "ASC"; - - $filters["action"] = isset( $dataList["action"] ) ? $dataList["action"] : ""; - - $filters['newestthan'] = isset( $dataList['newerThan'] ) ? $dataList['newerThan'] : ''; - - $filters['oldestthan'] = isset( $dataList['oldestthan'] ) ? $dataList['oldestthan'] : ''; + $filters["paged"] = isset($dataList["paged"]) ? $dataList["paged"] : true; + $filters['count'] = isset($dataList['count']) ? $dataList['count'] : true; + $filters["category"] = isset($dataList["category"]) ? $dataList["category"] : ""; + $filters["process"] = isset($dataList["process"]) ? $dataList["process"] : ""; + $filters["search"] = isset($dataList["search"]) ? $dataList["search"] : ""; + $filters["filter"] = isset($dataList["filter"]) ? $dataList["filter"] : ""; + $filters["dateFrom"] = (!empty($dataList["dateFrom"])) ? substr($dataList["dateFrom"], 0, 10) : ""; + $filters["dateTo"] = (!empty($dataList["dateTo"])) ? substr($dataList["dateTo"], 0, 10) : ""; + $filters["start"] = isset($dataList["start"]) ? $dataList["start"] : "0"; + $filters["limit"] = isset($dataList["limit"]) ? $dataList["limit"] : "25"; + $filters["sort"] = isset($dataList["sort"]) ? $dataList["sort"] : ""; + $filters["dir"] = isset($dataList["dir"]) ? $dataList["dir"] : "ASC"; + $filters["action"] = isset($dataList["action"]) ? $dataList["action"] : ""; + $filters['newestthan'] = isset($dataList['newerThan']) ? $dataList['newerThan'] : ''; + $filters['oldestthan'] = isset($dataList['oldestthan']) ? $dataList['oldestthan'] : ''; + $filters['appUidCheck'] = isset($dataList['appUidCheck']) ? $dataList['appUidCheck'] : array(); // Select list switch ($listName) { diff --git a/workflow/engine/src/ProcessMaker/Services/Api/Light.php b/workflow/engine/src/ProcessMaker/Services/Api/Light.php index afb607a32..7b34f0d8c 100644 --- a/workflow/engine/src/ProcessMaker/Services/Api/Light.php +++ b/workflow/engine/src/ProcessMaker/Services/Api/Light.php @@ -9,7 +9,20 @@ use Luracast\Restler\RestException; use ProcessMaker\BusinessModel\Validator; use ProcessMaker\Util\DateTime; use PmDynaform; - +use Exception; +use ProcessMaker\BusinessModel\Light as BusinessModelLight; +use RBAC; +use ProcessMaker\BusinessModel\Cases as BusinessModelCases; +use Cases; +use AppDelegation; +use ProcessMaker\BusinessModel\Lists; +use ProcessMaker\BusinessModel\Task; +use ProcessMaker\BusinessModel\ProcessMap; +use ProcessMaker\BusinessModel\Process; +use Criteria; +use StepPeer; +use stdclass; +use ProcessMaker\BusinessModel\DynaForm as BusinessModelDynaForm; /** * * Process Api Controller @@ -35,23 +48,25 @@ class Light extends Api { try { $methodName = $this->restler->apiMethodInfo->methodName; - $arrayArgs = $this->restler->apiMethodInfo->arguments; + $arrayArgs = $this->restler->apiMethodInfo->arguments; switch ($methodName) { case 'doIfAlreadyRoute': $applicationUid = $this->parameters[$arrayArgs['app_uid']]; $delIndex = $this->parameters[$arrayArgs['cas_index']]; $userUid = $this->getUserId(); //Check if the user has the case - $appDelegation = new \AppDelegation(); + $appDelegation = new AppDelegation(); $aCurUser = $appDelegation->getCurrentUsers($applicationUid, $delIndex); if (!empty($aCurUser) && in_array($userUid, $aCurUser)) { return true; } + return false; break; } + return false; - } catch (\Exception $e) { + } catch (Exception $e) { throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } } @@ -65,23 +80,23 @@ class Light extends Api { try { /** - * The variable $RBAC can be defined as follows: - * - * $RBAC = new \stdClass(); + * The variable $RBAC can be defined as follows: + * + * $RBAC = new stdclass(); * $RBAC->aUserInfo['USER_INFO'] = ["USR_UID" => $this->getUserId()]; - * - * Please consider removing the use of this variable in model class, + * + * Please consider removing the use of this variable in model class, * or perform a corresponding improvement. */ global $RBAC; if (!isset($RBAC)) { - $RBAC = \RBAC::getSingleton(PATH_DATA, session_id()); + $RBAC = RBAC::getSingleton(PATH_DATA, session_id()); $RBAC->sSystem = 'PROCESSMAKER'; $RBAC->initRBAC(); $RBAC->loadUserRolePermission($RBAC->sSystem, $this->getUserId()); } - } catch (\Exception $e) { + } catch (Exception $e) { throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } } @@ -94,36 +109,37 @@ class Light extends Api * * @url GET /counters */ - public function countersCases () + public function countersCases() { try { - $userId = $this->getUserId(); + $userId = $this->getUserId(); /*----------------------------------********---------------------------------*/ if (true) { //In enterprise version this block of code should always be executed //In community version this block of code is deleted and is executed the other - $list = new \ProcessMaker\BusinessModel\Lists(); + $list = new Lists(); $arrayListCounter = $list->getCounters($userId); } else { - /*----------------------------------********---------------------------------*/ - $case = new \ProcessMaker\BusinessModel\Cases(); + /*----------------------------------********---------------------------------*/ + $case = new BusinessModelCases(); $arrayListCounter = $case->getListCounters( $userId, ['to_do', 'draft', 'sent', 'selfservice', 'paused', 'completed', 'cancelled'] ); - /*----------------------------------********---------------------------------*/ + /*----------------------------------********---------------------------------*/ } /*----------------------------------********---------------------------------*/ $result = $this->parserCountersCases($arrayListCounter); - } catch (\Exception $e) { + } catch (Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } + return $result; } - public function parserCountersCases ($data) + public function parserCountersCases($data) { $structure = array( "CASES_INBOX" => "toDo", @@ -143,7 +159,7 @@ class Light extends Api ); $response = array(); foreach ($data as $key => $counterList) { - if(isset($structure[$counterList['item']])){ + if (isset($structure[$counterList['item']])) { $name = $structure[$counterList['item']]; $response[$name] = $counterList['count']; } else { @@ -152,8 +168,10 @@ class Light extends Api } } } + return $response; } + /** * Get list process start * @return array @@ -162,15 +180,16 @@ class Light extends Api * * @url GET /start-case */ - public function getProcessListStartCase () + public function getProcessListStartCase() { try { - $oMobile = new \ProcessMaker\BusinessModel\Light(); + $oMobile = new BusinessModelLight(); $processListStartCase = $oMobile->getProcessListStartCase($this->getUserId()); $startCase = $processListStartCase; - } catch (\Exception $e) { + } catch (Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } + return $startCase; } @@ -193,7 +212,7 @@ class Light extends Api $date_from = '', $date_to = '', $newerThan = '', - $oldestthan ='' + $oldestthan = '' ) { try { if (preg_match($this->regexNull, $newerThan)) { @@ -202,17 +221,17 @@ class Light extends Api $dataList['userId'] = $this->getUserId(); $dataList['action'] = 'todo'; - $dataList['paged'] = true; + $dataList['paged'] = true; $dataList['start'] = $start; $dataList['limit'] = $limit; - $dataList['sort'] = $sort; - $dataList['dir'] = $dir; + $dataList['sort'] = $sort; + $dataList['dir'] = $dir; $dataList['category'] = $cat_uid; - $dataList['process'] = $pro_uid; - $dataList['search'] = $search; - $dataList['filter'] = $filter; + $dataList['process'] = $pro_uid; + $dataList['search'] = $search; + $dataList['filter'] = $filter; $dataList['dateFrom'] = $date_from; - $dataList['dateTo'] = $date_to; + $dataList['dateTo'] = $date_to; $dataList['newerThan'] = $newerThan; $dataList['oldestthan'] = $oldestthan; @@ -223,69 +242,74 @@ class Light extends Api if (true) { //In enterprise version this block of code should always be executed //In community version this block of code is deleted and is executed the other - $list = new \ProcessMaker\BusinessModel\Lists(); + $list = new Lists(); $response = $list->getList('inbox', $dataList); } else { - /*----------------------------------********---------------------------------*/ - $case = new \ProcessMaker\BusinessModel\Cases(); + /*----------------------------------********---------------------------------*/ + $case = new BusinessModelCases(); $response = $case->getList($dataList); - /*----------------------------------********---------------------------------*/ + /*----------------------------------********---------------------------------*/ } /*----------------------------------********---------------------------------*/ //Complete the list information with some task properties $response['data'] = $this->addTaskProperties($response['data']); - $result = $this->parserDataTodo($response['data']); + $result = $this->parserDataTodo($response['data']); + return DateTime::convertUtcToIso8601($result, $this->arrayFieldIso8601); - } catch (\Exception $e) { + } catch (Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } } - public function addTaskProperties($data){ - $task = new \ProcessMaker\BusinessModel\Task(); + public function addTaskProperties($data) + { + $task = new Task(); foreach ($data as $key => $value) { $valueUpper = array_change_key_case($value, CASE_UPPER); - list($data[$key]['TAS_OFFLINE'], $data[$key]['TAS_AUTO_ROOT']) = $task->getColumnValues($valueUpper['PRO_UID'], $valueUpper['TAS_UID'], array('TAS_OFFLINE', 'TAS_AUTO_ROOT')); + list($data[$key]['TAS_OFFLINE'], $data[$key]['TAS_AUTO_ROOT']) = $task->getColumnValues($valueUpper['PRO_UID'], + $valueUpper['TAS_UID'], array('TAS_OFFLINE', 'TAS_AUTO_ROOT')); } + return $data; } - public function parserDataTodo ($data) + public function parserDataTodo($data) { $structure = array( - 'APP_UID' => 'caseId', - 'APP_TITLE' => 'caseTitle', - 'APP_NUMBER' => 'caseNumber', - 'APP_UPDATE_DATE' => 'date', + 'APP_UID' => 'caseId', + 'APP_TITLE' => 'caseTitle', + 'APP_NUMBER' => 'caseNumber', + 'APP_UPDATE_DATE' => 'date', 'DEL_TASK_DUE_DATE' => 'dueDate', - 'DEL_INDEX' => 'delIndex', + 'DEL_INDEX' => 'delIndex', 'DEL_DELEGATE_DATE' => 'delegateDate', 'DEL_RISK_DATE' => 'delRiskDate', 'user' => array( - 'USR_UID' => 'userId' + 'USR_UID' => 'userId' ), 'prevUser' => array( - 'PREVIOUS_USR_UID' => 'userId', + 'PREVIOUS_USR_UID' => 'userId', 'PREVIOUS_USR_FIRSTNAME' => 'firstName', - 'PREVIOUS_USR_LASTNAME' => 'lastName', - 'PREVIOUS_USR_USERNAME' => 'userName', + 'PREVIOUS_USR_LASTNAME' => 'lastName', + 'PREVIOUS_USR_USERNAME' => 'userName', ), 'process' => array( - 'PRO_UID' => 'processId', + 'PRO_UID' => 'processId', 'APP_PRO_TITLE' => 'name' ), 'task' => array( - 'TAS_UID' => 'taskId', + 'TAS_UID' => 'taskId', 'APP_TAS_TITLE' => 'name', - 'TAS_OFFLINE' => 'offlineEnabled', + 'TAS_OFFLINE' => 'offlineEnabled', 'TAS_AUTO_ROOT' => 'autoRoot' ) ); $response = $this->replaceFields($data, $structure); + return $response; } @@ -299,13 +323,13 @@ class Light extends Api public function doGetCasesListDraft( $start = 0, $limit = 10, - $sort = 'DEL_DELEGATE_DATE', - $dir = 'DESC', + $sort = 'DEL_DELEGATE_DATE', + $dir = 'DESC', $cat_uid = '', $pro_uid = '', $search = '', $newerThan = '', - $oldestthan ='' + $oldestthan = '' ) { try { if (preg_match($this->regexNull, $newerThan)) { @@ -314,7 +338,7 @@ class Light extends Api $dataList['userId'] = $this->getUserId(); $dataList['action'] = 'draft'; - $dataList['paged'] = true; + $dataList['paged'] = true; $dataList['start'] = $start; $dataList['limit'] = $limit; @@ -333,58 +357,60 @@ class Light extends Api if (true) { //In enterprise version this block of code should always be executed //In community version this block of code is deleted and is executed the other - $list = new \ProcessMaker\BusinessModel\Lists(); + $list = new Lists(); $response = $list->getList('inbox', $dataList); } else { - /*----------------------------------********---------------------------------*/ - $case = new \ProcessMaker\BusinessModel\Cases(); + /*----------------------------------********---------------------------------*/ + $case = new BusinessModelCases(); $response = $case->getList($dataList); - /*----------------------------------********---------------------------------*/ + /*----------------------------------********---------------------------------*/ } /*----------------------------------********---------------------------------*/ //Complete the list information with some task properties $response['data'] = $this->addTaskProperties($response['data']); - $result = $this->parserDataDraft($response['data']); + $result = $this->parserDataDraft($response['data']); + return DateTime::convertUtcToIso8601($result, $this->arrayFieldIso8601); - } catch (\Exception $e) { + } catch (Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } } - public function parserDataDraft ($data) + public function parserDataDraft($data) { $structure = array( - 'APP_UID' => 'caseId', - 'APP_TITLE' => 'caseTitle', - 'APP_NUMBER' => 'caseNumber', - 'APP_UPDATE_DATE' => 'date', + 'APP_UID' => 'caseId', + 'APP_TITLE' => 'caseTitle', + 'APP_NUMBER' => 'caseNumber', + 'APP_UPDATE_DATE' => 'date', 'DEL_TASK_DUE_DATE' => 'dueDate', - 'DEL_INDEX' => 'delIndex', + 'DEL_INDEX' => 'delIndex', 'DEL_DELEGATE_DATE' => 'delegateDate', 'user' => array( - 'USR_UID' => 'userId' + 'USR_UID' => 'userId' ), 'currentUser' => array( - 'USR_UID' => 'userId', + 'USR_UID' => 'userId', 'USR_FIRSTNAME' => 'firstName', - 'USR_LASTNAME' => 'lastName', - 'USR_USERNAME' => 'userName', + 'USR_LASTNAME' => 'lastName', + 'USR_USERNAME' => 'userName', ), 'process' => array( - 'PRO_UID' => 'processId', + 'PRO_UID' => 'processId', 'APP_PRO_TITLE' => 'name' ), 'task' => array( - 'TAS_UID' => 'taskId', + 'TAS_UID' => 'taskId', 'APP_TAS_TITLE' => 'name', - 'TAS_OFFLINE' => 'offlineEnabled', + 'TAS_OFFLINE' => 'offlineEnabled', 'TAS_AUTO_ROOT' => 'autoRoot' ) ); $response = $this->replaceFields($data, $structure); + return $response; } @@ -400,8 +426,8 @@ class Light extends Api $paged = true, $start = 0, $limit = 10, - $sort = 'DEL_DELEGATE_DATE', - $dir = 'DESC', + $sort = 'DEL_DELEGATE_DATE', + $dir = 'DESC', $category = '', $process = '', $search = '', @@ -409,7 +435,7 @@ class Light extends Api $date_from = '', $date_to = '', $newerThan = '', - $oldestthan ='' + $oldestthan = '' ) { try { if (preg_match($this->regexNull, $newerThan)) { @@ -418,22 +444,22 @@ class Light extends Api $dataList['userId'] = $this->getUserId(); $dataList['action'] = 'sent'; - $dataList['paged'] = $paged; - $dataList['count'] = $count; + $dataList['paged'] = $paged; + $dataList['count'] = $count; $dataList['start'] = $start; $dataList['limit'] = $limit; - $dataList['sort'] = $sort; - $dataList['dir'] = $dir; + $dataList['sort'] = $sort; + $dataList['dir'] = $dir; $dataList['category'] = $category; - $dataList['process'] = $process; - $dataList['search'] = $search; - $dataList['filter'] = $filter; + $dataList['process'] = $process; + $dataList['search'] = $search; + $dataList['filter'] = $filter; $dataList['dateFrom'] = $date_from; - $dataList['dateTo'] = $date_to; + $dataList['dateTo'] = $date_to; $dataList['newerThan'] = $newerThan; - $dataList['oldestthan'] = $oldestthan; + $dataList['oldestthan'] = $oldestthan; Validator::throwExceptionIfDataNotMetIso8601Format($dataList, $this->arrayFieldIso8601); $dataList = DateTime::convertDataToUtc($dataList, $this->arrayFieldIso8601); @@ -442,56 +468,58 @@ class Light extends Api if (true) { //In enterprise version this block of code should always be executed //In community version this block of code is deleted and is executed the other - $list = new \ProcessMaker\BusinessModel\Lists(); + $list = new Lists(); $response = $list->getList('participated_last', $dataList); } else { - /*----------------------------------********---------------------------------*/ - $case = new \ProcessMaker\BusinessModel\Cases(); + /*----------------------------------********---------------------------------*/ + $case = new BusinessModelCases(); $response = $case->getList($dataList); - /*----------------------------------********---------------------------------*/ + /*----------------------------------********---------------------------------*/ } /*----------------------------------********---------------------------------*/ $result = $this->parserDataParticipated($response['data']); + return DateTime::convertUtcToIso8601($result, $this->arrayFieldIso8601); - } catch (\Exception $e) { + } catch (Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } } - public function parserDataParticipated ($data) + public function parserDataParticipated($data) { $structure = array( - 'APP_UID' => 'caseId', - 'APP_TITLE' => 'caseTitle', - 'APP_NUMBER' => 'caseNumber', - 'APP_UPDATE_DATE' => 'date', + 'APP_UID' => 'caseId', + 'APP_TITLE' => 'caseTitle', + 'APP_NUMBER' => 'caseNumber', + 'APP_UPDATE_DATE' => 'date', 'DEL_TASK_DUE_DATE' => 'dueDate', - 'DEL_INDEX' => 'delIndex', + 'DEL_INDEX' => 'delIndex', 'DEL_DELEGATE_DATE' => 'delegateDate', 'currentUser' => array( - 'USR_UID' => 'userId', + 'USR_UID' => 'userId', 'USR_FIRSTNAME' => 'firstName', - 'USR_LASTNAME' => 'lastName', - 'USR_USERNAME' => 'userName', + 'USR_LASTNAME' => 'lastName', + 'USR_USERNAME' => 'userName', ), 'prevUser' => array( - 'PREVIOUS_USR_UID' => 'userId', + 'PREVIOUS_USR_UID' => 'userId', 'PREVIOUS_USR_FIRSTNAME' => 'firstName', - 'PREVIOUS_USR_LASTNAME' => 'lastName', - 'PREVIOUS_USR_USERNAME' => 'userName', + 'PREVIOUS_USR_LASTNAME' => 'lastName', + 'PREVIOUS_USR_USERNAME' => 'userName', ), 'process' => array( - 'PRO_UID' => 'processId', + 'PRO_UID' => 'processId', 'APP_PRO_TITLE' => 'name' ), 'task' => array( - 'TAS_UID' => 'taskId', + 'TAS_UID' => 'taskId', 'APP_TAS_TITLE' => 'name' ) ); $response = $this->replaceFields($data, $structure); + return $response; } @@ -523,75 +551,77 @@ class Light extends Api $dataList['userId'] = $this->getUserId(); $dataList['action'] = 'paused'; - $dataList['paged'] = true; + $dataList['paged'] = true; - $dataList['start'] = $start; - $dataList['limit'] = $limit; - $dataList['sort'] = $sort; - $dataList['dir'] = $dir; + $dataList['start'] = $start; + $dataList['limit'] = $limit; + $dataList['sort'] = $sort; + $dataList['dir'] = $dir; $dataList['category'] = $cat_uid; - $dataList['process'] = $pro_uid; - $dataList['search'] = $search; - $dataList['filter'] = $filter; + $dataList['process'] = $pro_uid; + $dataList['search'] = $search; + $dataList['filter'] = $filter; $dataList['dateFrom'] = $date_from; - $dataList['dateTo'] = $date_to; - $dataList['newerThan'] = $newerThan; + $dataList['dateTo'] = $date_to; + $dataList['newerThan'] = $newerThan; $dataList['oldestthan'] = $oldestthan; /*----------------------------------********---------------------------------*/ if (true) { //In enterprise version this block of code should always be executed //In community version this block of code is deleted and is executed the other - $list = new \ProcessMaker\BusinessModel\Lists(); + $list = new Lists(); $response = $list->getList('paused', $dataList); } else { - /*----------------------------------********---------------------------------*/ - $case = new \ProcessMaker\BusinessModel\Cases(); + /*----------------------------------********---------------------------------*/ + $case = new BusinessModelCases(); $response = $case->getList($dataList); - /*----------------------------------********---------------------------------*/ + /*----------------------------------********---------------------------------*/ } /*----------------------------------********---------------------------------*/ $result = $this->parserDataParticipated($response['data']); + return DateTime::convertUtcToIso8601($result, $this->arrayFieldIso8601); - } catch (\Exception $e) { + } catch (Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } } - public function parserDataPaused ($data) + public function parserDataPaused($data) { $structure = array( - 'APP_UID' => 'caseId', - 'APP_TITLE' => 'caseTitle', - 'APP_NUMBER' => 'caseNumber', - 'APP_UPDATE_DATE' => 'date', + 'APP_UID' => 'caseId', + 'APP_TITLE' => 'caseTitle', + 'APP_NUMBER' => 'caseNumber', + 'APP_UPDATE_DATE' => 'date', 'DEL_TASK_DUE_DATE' => 'dueDate', - 'DEL_INDEX' => 'delIndex', + 'DEL_INDEX' => 'delIndex', 'DEL_DELEGATE_DATE' => 'delegateDate', 'currentUser' => array( - 'USR_UID' => 'userId', + 'USR_UID' => 'userId', 'DEL_CURRENT_USR_FIRSTNAME' => 'firstName', - 'DEL_CURRENT_USR_LASTNAME' => 'lastName', - 'DEL_CURRENT_USR_USERNAME' => 'userName', + 'DEL_CURRENT_USR_LASTNAME' => 'lastName', + 'DEL_CURRENT_USR_USERNAME' => 'userName', ), 'prevUser' => array( - 'DEL_PREVIOUS_USR_UID' => 'userId', + 'DEL_PREVIOUS_USR_UID' => 'userId', 'DEL_PREVIOUS_USR_FIRSTNAME' => 'firstName', - 'DEL_PREVIOUS_USR_LASTNAME' => 'lastName', - 'DEL_PREVIOUS_USR_USERNAME' => 'userName', + 'DEL_PREVIOUS_USR_LASTNAME' => 'lastName', + 'DEL_PREVIOUS_USR_USERNAME' => 'userName', ), 'process' => array( - 'PRO_UID' => 'processId', + 'PRO_UID' => 'processId', 'APP_PRO_TITLE' => 'name' ), 'task' => array( - 'TAS_UID' => 'taskId', + 'TAS_UID' => 'taskId', 'APP_TAS_TITLE' => 'name' ) ); $response = $this->replaceFields($data, $structure); + return $response; } @@ -611,7 +641,7 @@ class Light extends Api $pro_uid = '', $search = '', $newerThan = '', - $oldestthan ='' + $oldestthan = '' ) { try { if (preg_match($this->regexNull, $newerThan)) { @@ -620,17 +650,17 @@ class Light extends Api $dataList['userId'] = $this->getUserId(); $dataList['action'] = 'unassigned'; - $dataList['paged'] = false; + $dataList['paged'] = false; - $dataList['start'] = $start; - $dataList['limit'] = $limit; - $dataList['sort'] = $sort; - $dataList['dir'] = $dir; + $dataList['start'] = $start; + $dataList['limit'] = $limit; + $dataList['sort'] = $sort; + $dataList['dir'] = $dir; $dataList['category'] = $cat_uid; - $dataList['process'] = $pro_uid; - $dataList['search'] = $search; + $dataList['process'] = $pro_uid; + $dataList['search'] = $search; $dataList['newerThan'] = $newerThan; - $dataList['oldestthan'] = $oldestthan; + $dataList['oldestthan'] = $oldestthan; Validator::throwExceptionIfDataNotMetIso8601Format($dataList, $this->arrayFieldIso8601); $dataList = DateTime::convertDataToUtc($dataList, $this->arrayFieldIso8601); @@ -638,59 +668,61 @@ class Light extends Api if (true) { //In enterprise version this block of code should always be executed //In community version this block of code is deleted and is executed the other - $oCases = new \ProcessMaker\BusinessModel\Lists(); + $oCases = new Lists(); $response = $oCases->getList('unassigned', $dataList); } else { - /*----------------------------------********---------------------------------*/ - $oCases = new \ProcessMaker\BusinessModel\Cases(); + /*----------------------------------********---------------------------------*/ + $oCases = new BusinessModelCases(); $response = $oCases->getList($dataList); - /*----------------------------------********---------------------------------*/ + /*----------------------------------********---------------------------------*/ } /*----------------------------------********---------------------------------*/ - $result = $this->parserDataUnassigned($response); + $result = $this->parserDataUnassigned($response); + return DateTime::convertUtcToIso8601($result, $this->arrayFieldIso8601); - } catch (\Exception $e) { + } catch (Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } } - public function parserDataUnassigned ($data) + public function parserDataUnassigned($data) { $structure = array( - 'app_uid' => 'caseId', - 'app_title' => 'caseTitle', - 'app_number' => 'caseNumber', - 'app_update_date' => 'date', + 'app_uid' => 'caseId', + 'app_title' => 'caseTitle', + 'app_number' => 'caseNumber', + 'app_update_date' => 'date', 'del_task_due_date' => 'dueDate', - 'del_index' => 'delIndex', + 'del_index' => 'delIndex', 'del_delegate_date' => 'delegateDate', 'currentUser' => array( - 'usrcr_usr_uid' => 'userId', + 'usrcr_usr_uid' => 'userId', 'usrcr_usr_firstname' => 'firstName', - 'usrcr_usr_lastname' => 'lastName', - 'usrcr_usr_username' => 'userName', + 'usrcr_usr_lastname' => 'lastName', + 'usrcr_usr_username' => 'userName', ), 'prevUser' => array( - 'previous_usr_uid' => 'userId', + 'previous_usr_uid' => 'userId', 'previous_usr_firstname' => 'firstName', - 'previous_usr_lastname' => 'lastName', - 'previous_usr_username' => 'userName', + 'previous_usr_lastname' => 'lastName', + 'previous_usr_username' => 'userName', ), 'process' => array( - 'pro_uid' => 'processId', + 'pro_uid' => 'processId', 'app_pro_title' => 'name' ), 'task' => array( - 'tas_uid' => 'taskId', + 'tas_uid' => 'taskId', 'app_tas_title' => 'name' ) ); $response = $this->replaceFields($data, $structure); + return $response; } - public function replaceFields ($data, $structure) + public function replaceFields($data, $structure) { $response = array(); foreach ($data as $field => $d) { @@ -708,7 +740,7 @@ class Light extends Api !is_array($structure[$arrayMatch[1]]) ) { $newName = $structure[$arrayMatch[1]]; - $newData[$newName] = is_null($value) ? "":$value; + $newData[$newName] = is_null($value) ? "" : $value; } else { foreach ($structure as $name => $str) { if (is_array($str) && @@ -720,13 +752,14 @@ class Light extends Api !is_array($str[$arrayMatch[1]]) ) { $newName = $str[$arrayMatch[1]]; - $newData[$name][$newName] = is_null($value) ? "":$value; + $newData[$name][$newName] = is_null($value) ? "" : $value; } } } } - if (count($newData) > 0) + if (count($newData) > 0) { $response[] = $newData; + } } else { if ( preg_match( @@ -737,25 +770,26 @@ class Light extends Api !is_array($structure[$arrayMatch[1]]) ) { $newName = $structure[$arrayMatch[1]]; - $response[$newName] = is_null($d) ? "":$d; + $response[$newName] = is_null($d) ? "" : $d; } else { foreach ($structure as $name => $str) { if (is_array($str) && preg_match( '/\|(' . $field . ')\|/i', - '|' . implode('|', array_keys($str)) .'|', + '|' . implode('|', array_keys($str)) . '|', $arrayMatch ) && !is_array($str[$arrayMatch[1]]) ) { $newName = $str[$arrayMatch[1]]; - $response[$name][$newName] = is_null($d) ? "":$d; + $response[$name][$newName] = is_null($d) ? "" : $d; } } } } } + return $response; } @@ -771,14 +805,15 @@ class Light extends Api public function doDeleteCases($app_uid) { try { - $oCase = new \Cases(); - $oCase->removeCase( $app_uid ); - $result = array ( - "message" => \G::LoadTranslation( "ID_COMMAND_EXECUTED_SUCCESSFULLY" ) + $oCase = new Cases(); + $oCase->removeCase($app_uid); + $result = array( + "message" => G::LoadTranslation("ID_COMMAND_EXECUTED_SUCCESSFULLY") ); - } catch (\Exception $e) { + } catch (Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } + return $result; } @@ -795,20 +830,21 @@ class Light extends Api { try { $arrayFieldIso8601 = array('DEL_DELEGATE_DATE', 'DEL_INIT_DATE', 'DEL_FINISH_DATE'); - $oMobile = new \ProcessMaker\BusinessModel\Light(); - $response = $oMobile->getCasesListHistory($app_uid); - $response8601 = DateTime::convertUtcToIso8601($response['flow'], $arrayFieldIso8601); + $oMobile = new BusinessModelLight(); + $response = $oMobile->getCasesListHistory($app_uid); + $response8601 = DateTime::convertUtcToIso8601($response['flow'], $arrayFieldIso8601); $response['flow'] = $this->parserDataHistory($response8601); - $r = new \stdclass(); - $r->data = $response; + $r = new stdclass(); + $r->data = $response; $r->totalCount = count($response['flow']); + return $r; - } catch (\Exception $e) { + } catch (Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } } - public function parserDataHistory ($data) + public function parserDataHistory($data) { $structure = array( //'' => 'caseId', @@ -816,15 +852,16 @@ class Light extends Api //'' => 'processName', //'' => 'ownerFullName', //'flow' => array( - 'TAS_TITLE' => 'taskName', - //'' => 'userId', - 'USR_NAME' => 'userFullName', - 'APP_TYPE' => 'flowStatus', // is null default Router in FE - 'DEL_DELEGATE_DATE' => 'dueDate', + 'TAS_TITLE' => 'taskName', + //'' => 'userId', + 'USR_NAME' => 'userFullName', + 'APP_TYPE' => 'flowStatus', // is null default Router in FE + 'DEL_DELEGATE_DATE' => 'dueDate', //) ); $response = $this->replaceFields($data, $structure); + return $response; } @@ -833,7 +870,7 @@ class Light extends Api * * @access protected * @class AccessControl {@className \ProcessMaker\Services\Api\Light} - * @param string $app_uid {@min 1}{@max 32} + * @param string $app_uid {@min 1}{@max 32} * @param int $cas_index * * @status 204 @@ -842,12 +879,13 @@ class Light extends Api public function doIfAlreadyRoute($app_uid, $cas_index) { try { - $oAppDelegate = new \AppDelegation(); + $oAppDelegate = new AppDelegation(); $alreadyRouted = $oAppDelegate->alreadyRouted($app_uid, $cas_index); if ($alreadyRouted) { - throw (new RestException(Api::STAT_APP_EXCEPTION, G::LoadTranslation('ID_CASE_DELEGATION_ALREADY_CLOSED'))); + throw (new RestException(Api::STAT_APP_EXCEPTION, + G::LoadTranslation('ID_CASE_DELEGATION_ALREADY_CLOSED'))); } - } catch (\Exception $e) { + } catch (Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } } @@ -861,22 +899,23 @@ class Light extends Api public function doGetDynaForms($prj_uid) { try { - $process = new \ProcessMaker\BusinessModel\Process(); + $process = new Process(); $process->setFormatFieldNameInUppercase(false); $process->setArrayFieldNameForException(array("processUid" => "prj_uid")); $_SESSION['PROCESS'] = $prj_uid; $response = $process->getDynaForms($prj_uid); - $result = $this->parserDataDynaForm($response); + $result = $this->parserDataDynaForm($response); $pmDynaForm = new PmDynaform(); foreach ($result as $k => $form) { - $result[$k]['formContent'] = (isset($form['formContent']) && $form['formContent'] != null)?json_decode($form['formContent']):""; + $result[$k]['formContent'] = (isset($form['formContent']) && $form['formContent'] != null) ? json_decode($form['formContent']) : ""; $pmDynaForm->jsonr($result[$k]['formContent']); - $result[$k]['index'] = $k; + $result[$k]['index'] = $k; } - } catch (\Exception $e) { + } catch (Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } + return $result; } @@ -889,48 +928,50 @@ class Light extends Api public function doGetActivitySteps($act_uid, $prj_uid) { try { - $task = new \ProcessMaker\BusinessModel\Task(); + $task = new Task(); $task->setFormatFieldNameInUppercase(false); $task->setArrayParamException(array("taskUid" => "act_uid", "stepUid" => "step_uid")); $activitySteps = $task->getSteps($act_uid); $_SESSION['PROCESS'] = $prj_uid; - $dynaForm = new \ProcessMaker\BusinessModel\DynaForm(); + $dynaForm = new BusinessModelDynaForm(); $dynaForm->setFormatFieldNameInUppercase(false); - $oMobile = new \ProcessMaker\BusinessModel\Light(); + $oMobile = new BusinessModelLight(); $step = new \ProcessMaker\Services\Api\Project\Activity\Step(); $response = array(); for ($i = 0; $i < count($activitySteps); $i++) { if ($activitySteps[$i]['step_type_obj'] == "DYNAFORM") { $dataForm = $dynaForm->getDynaForm($activitySteps[$i]['step_uid_obj']); - $result = $this->parserDataDynaForm($dataForm); - $result["formUpdateDate"] = \ProcessMaker\Util\DateTime::convertUtcToIso8601($result["formUpdateDate"]); - $result['index'] = $i; - $result['stepId'] = $activitySteps[$i]["step_uid"]; - $result['stepUidObj'] = $activitySteps[$i]["step_uid_obj"]; - $result['stepMode'] = $activitySteps[$i]['step_mode']; + $result = $this->parserDataDynaForm($dataForm); + $result["formUpdateDate"] = DateTime::convertUtcToIso8601($result["formUpdateDate"]); + $result['index'] = $i; + $result['stepId'] = $activitySteps[$i]["step_uid"]; + $result['stepUidObj'] = $activitySteps[$i]["step_uid_obj"]; + $result['stepMode'] = $activitySteps[$i]['step_mode']; $result['stepCondition'] = $activitySteps[$i]['step_condition']; $result['stepPosition'] = $activitySteps[$i]['step_position']; - $trigger = $oMobile->statusTriggers($step->doGetActivityStepTriggers($activitySteps[$i]["step_uid"], $act_uid, $prj_uid)); - $result["triggers"] = $trigger; + $trigger = $oMobile->statusTriggers($step->doGetActivityStepTriggers($activitySteps[$i]["step_uid"], + $act_uid, $prj_uid)); + $result["triggers"] = $trigger; unset($result["formContent"]); $response[] = $result; } } - } catch (\Exception $e) { + } catch (Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } + return $response; } /** * Execute Trigger case * - * @param string $prj_uid {@min 1}{@max 32} - * @param string $act_uid {@min 1}{@max 32} - * @param string $cas_uid {@min 1}{@max 32} + * @param string $prj_uid {@min 1}{@max 32} + * @param string $act_uid {@min 1}{@max 32} + * @param string $cas_uid {@min 1}{@max 32} * @param string $step_uid {@min 32}{@max 32} - * @param string $type {@choice before,after} + * @param string $type {@choice before,after} * * @copyright Colosa - Bolivia * @@ -940,19 +981,20 @@ class Light extends Api { try { $userUid = $this->getUserId(); - $oMobile = new \ProcessMaker\BusinessModel\Light(); + $oMobile = new BusinessModelLight(); $response = $oMobile->doExecuteTriggerCase($userUid, $prj_uid, $act_uid, $cas_uid, $step_uid, $type); - } catch (\Exception $e) { + } catch (Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } + return $response; } /** * Get next step * - * @param string $pro_uid {@min 1}{@max 32} - * @param string $app_uid {@min 1}{@max 32} + * @param string $pro_uid {@min 1}{@max 32} + * @param string $app_uid {@min 1}{@max 32} * @param int $cas_index * @param int $step_pos * @@ -961,25 +1003,27 @@ class Light extends Api public function doGetNextStep($pro_uid, $app_uid, $cas_index, $step_pos) { try { - $oCase = new \Cases(); + $oCase = new Cases(); - $oAppDelegate = new \AppDelegation(); + $oAppDelegate = new AppDelegation(); $alreadyRouted = $oAppDelegate->alreadyRouted($app_uid, $cas_index); if ($alreadyRouted) { - throw (new RestException(Api::STAT_APP_EXCEPTION, G::LoadTranslation('ID_CASE_DELEGATION_ALREADY_CLOSED'))); + throw (new RestException(Api::STAT_APP_EXCEPTION, + G::LoadTranslation('ID_CASE_DELEGATION_ALREADY_CLOSED'))); } $userUid = $this->getUserId(); - $_SESSION["APPLICATION"] = $app_uid; - $_SESSION["PROCESS"] = $pro_uid; + $_SESSION["APPLICATION"] = $app_uid; + $_SESSION["PROCESS"] = $pro_uid; //$_SESSION["TASK"] = ""; - $_SESSION["INDEX"] = $cas_index; - $_SESSION["USER_LOGGED"] = $userUid; + $_SESSION["INDEX"] = $cas_index; + $_SESSION["USER_LOGGED"] = $userUid; //$_SESSION["USR_USERNAME"] = ""; - $response = $oCase->getNextStep($pro_uid, $app_uid, $cas_index, $step_pos ); - } catch (\Exception $e) { + $response = $oCase->getNextStep($pro_uid, $app_uid, $cas_index, $step_pos); + } catch (Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } + return $response; } @@ -992,28 +1036,29 @@ class Light extends Api public function doGetDynaformProcessed($prj_uid, $dyn_uid, $app_uid = null, $del_index = 0) { try { - $dynaForm = new \ProcessMaker\BusinessModel\DynaForm(); + $dynaForm = new BusinessModelDynaForm(); $dynaForm->setFormatFieldNameInUppercase(false); $_SESSION['PROCESS'] = $prj_uid; $response = $dynaForm->getDynaForm($dyn_uid); $result = $this->parserDataDynaForm($response); $result['formContent'] = (isset($result['formContent']) && $result['formContent'] != null) ? - \G::json_decode($result['formContent']) : ""; + G::json_decode($result['formContent']) : ""; $caseVariables = array(); if (!is_null($app_uid)) { - $case = new \Cases(); + $case = new Cases(); $fields = $case->loadCase($app_uid, $del_index); $caseVariables = array_merge($fields['APP_DATA'], - \ProcessMaker\BusinessModel\Cases::getGlobalVariables($fields['APP_DATA'])); - + BusinessModelCases::getGlobalVariables($fields['APP_DATA'])); + $caseVariables = DateTime::convertUtcToTimeZone($caseVariables); } $pmDynaform = new PmDynaform(array("APP_DATA" => $caseVariables, "CURRENT_DYNAFORM" => $dyn_uid)); $pmDynaform->jsonr($result['formContent']); + return $result; - } catch (\Exception $e) { + } catch (Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } } @@ -1027,17 +1072,18 @@ class Light extends Api public function doGetDynaForm($prj_uid, $dyn_uid) { try { - $dynaForm = new \ProcessMaker\BusinessModel\DynaForm(); + $dynaForm = new BusinessModelDynaForm(); $dynaForm->setFormatFieldNameInUppercase(false); $_SESSION['PROCESS'] = $prj_uid; $response = $dynaForm->getDynaForm($dyn_uid); $result = $this->parserDataDynaForm($response); - $result['formContent'] = (isset($result['formContent']) && $result['formContent'] != null) ? \G::json_decode($result['formContent']) : ""; + $result['formContent'] = (isset($result['formContent']) && $result['formContent'] != null) ? G::json_decode($result['formContent']) : ""; $pmDynaForm = new PmDynaform(["CURRENT_DYNAFORM" => $dyn_uid]); $pmDynaForm->jsonr($result['formContent']); + return $result; - } catch (\Exception $e) { + } catch (Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } } @@ -1051,7 +1097,7 @@ class Light extends Api public function doGetDynaFormsId($prj_uid, $request_data) { try { - $dynaForm = new \ProcessMaker\BusinessModel\DynaForm(); + $dynaForm = new BusinessModelDynaForm(); $dynaForm->setFormatFieldNameInUppercase(false); $_SESSION['PROCESS'] = $prj_uid; @@ -1059,28 +1105,30 @@ class Light extends Api foreach ($request_data['formId'] as $dyn_uid) { $response = $dynaForm->getDynaForm($dyn_uid); $pmDynaForm = new PmDynaform(array("CURRENT_DYNAFORM" => $dyn_uid)); - $result = $this->parserDataDynaForm($response); - $result['formContent'] = (isset($result['formContent']) && $result['formContent'] != null)?json_decode($result['formContent']):""; + $result = $this->parserDataDynaForm($response); + $result['formContent'] = (isset($result['formContent']) && $result['formContent'] != null) ? json_decode($result['formContent']) : ""; $pmDynaForm->jsonr($result['formContent']); $return[] = $result; } - } catch (\Exception $e) { + } catch (Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } + return $return; } - public function parserDataDynaForm ($data) + public function parserDataDynaForm($data) { $structure = array( - 'dyn_uid' => 'formId', - 'dyn_title' => 'formTitle', + 'dyn_uid' => 'formId', + 'dyn_title' => 'formTitle', 'dyn_description' => 'formDescription', - 'dyn_content' => 'formContent', - 'dyn_update_date' => 'formUpdateDate' + 'dyn_content' => 'formContent', + 'dyn_update_date' => 'formUpdateDate' ); $response = $this->replaceFields($data, $structure); + return $response; } @@ -1093,11 +1141,12 @@ class Light extends Api public function postStartCase($pro_uid, $task_uid) { try { - $oMobile = new \ProcessMaker\BusinessModel\Light(); - $result = $oMobile->startCase($this->getUserId(), $pro_uid, $task_uid); - } catch (\Exception $e) { + $oMobile = new BusinessModelLight(); + $result = $oMobile->startCase($this->getUserId(), $pro_uid, $task_uid); + } catch (Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } + return $result; } @@ -1115,11 +1164,12 @@ class Light extends Api { try { $usr_uid = $this->getUserId(); - $oMobile = new \ProcessMaker\BusinessModel\Light(); + $oMobile = new BusinessModelLight(); $response = $oMobile->getPrepareInformation($usr_uid, $tas_uid, $app_uid, $del_index); - } catch (\Exception $e) { + } catch (Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } + return $response; } @@ -1134,11 +1184,12 @@ class Light extends Api public function doPutRouteCase($app_uid, $del_index = null, $tasks = array()) { try { - $oMobile = new \ProcessMaker\BusinessModel\Light(); + $oMobile = new BusinessModelLight(); $response = $oMobile->updateRouteCase($app_uid, $this->getUserId(), $del_index, $tasks); - } catch (\Exception $e) { + } catch (Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } + return $response; } @@ -1148,12 +1199,13 @@ class Light extends Api public function doGetUserData() { try { - $userUid = $this->getUserId(); - $oMobile = new \ProcessMaker\BusinessModel\Light(); + $userUid = $this->getUserId(); + $oMobile = new BusinessModelLight(); $response = $oMobile->getUserData($userUid); - } catch (\Exception $e) { + } catch (Exception $e) { throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } + return $response; } @@ -1164,32 +1216,33 @@ class Light extends Api { try { $response = array(); - $oMobile = new \ProcessMaker\BusinessModel\Light(); + $oMobile = new BusinessModelLight(); foreach ($request_data['user']['ids'] as $userUid) { $response[] = $oMobile->getUserData($userUid); } - } catch (\Exception $e) { + } catch (Exception $e) { throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } + return $response; } /** * @url POST /case/:app_uid/upload/location * - * @param string $app_uid { @min 32}{@max 32} - * @param float $latitude {@min -90}{@max 90} - * @param float $longitude {@min -180}{@max 180} + * @param string $app_uid { @min 32}{@max 32} + * @param float $latitude {@min -90}{@max 90} + * @param float $longitude {@min -180}{@max 180} */ public function postInputDocumentLocation($app_uid, $latitude, $longitude) { try { - $userUid = $this->getUserId(); - $oMobile = new \ProcessMaker\BusinessModel\Light(); + $userUid = $this->getUserId(); + $oMobile = new BusinessModelLight(); - $url = "http://maps.googleapis.com/maps/api/staticmap?center=".$latitude.','.$longitude."&format=jpg&size=600x600&zoom=15&markers=color:blue%7Clabel:S%7C".$latitude.','.$longitude; + $url = "http://maps.googleapis.com/maps/api/staticmap?center=" . $latitude . ',' . $longitude . "&format=jpg&size=600x600&zoom=15&markers=color:blue%7Clabel:S%7C" . $latitude . ',' . $longitude; $imageLocation = imagecreatefromjpeg($url); - $tmpfname = tempnam("php://temp","pmm"); + $tmpfname = tempnam("php://temp", "pmm"); imagejpeg($imageLocation, $tmpfname); $_FILES["form"]["type"] = "image/jpeg"; @@ -1204,30 +1257,32 @@ class Light extends Api $strPathName = PATH_DOCUMENT . G::getPathFromUID($app_uid) . PATH_SEP; $strFileName = $file[0]['appDocUid'] . "_" . $file[0]['docVersion'] . ".jpg"; - if (! is_dir( $strPathName )) { - G::verifyPath( $strPathName, true ); + if (!is_dir($strPathName)) { + G::verifyPath($strPathName, true); } copy($tmpfname, $strPathName . $strFileName); unlink($tmpfname); - } catch (\Exception $e) { + } catch (Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } + return $file; } /** * @url POST /case/:app_uid/download64 * - * @param string $app_uid {@min 32}{@max 32} + * @param string $app_uid {@min 32}{@max 32} */ public function postDownloadFile($app_uid, $request_data) { try { - $oMobile = new \ProcessMaker\BusinessModel\Light(); + $oMobile = new BusinessModelLight(); $files = $oMobile->downloadFile($app_uid, $request_data); - } catch (\Exception $e) { + } catch (Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } + return $files; } @@ -1241,11 +1296,12 @@ class Light extends Api public function postLogout($access, $refresh) { try { - $oMobile = new \ProcessMaker\BusinessModel\Light(); + $oMobile = new BusinessModelLight(); $files = $oMobile->logout($access, $refresh); - } catch (\Exception $e) { + } catch (Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } + return $files; } @@ -1259,47 +1315,55 @@ class Light extends Api public function getInformation($type, $app_uid) { try { - $arrayFieldIso8601 = array('caseCreateDate', 'caseUpdateData', 'delDelegateDate', 'delInitDate', - 'delDueDate', 'delFinishDate'); - $userUid = $this->getUserId(); - $oMobile = new \ProcessMaker\BusinessModel\Light(); + $arrayFieldIso8601 = array( + 'caseCreateDate', + 'caseUpdateData', + 'delDelegateDate', + 'delInitDate', + 'delDueDate', + 'delFinishDate' + ); + $userUid = $this->getUserId(); + $oMobile = new BusinessModelLight(); $response = $oMobile->getInformation($userUid, $type, $app_uid); $response = $this->parserGetInformation($response); $response = DateTime::convertUtcToIso8601($response, $arrayFieldIso8601); - } catch (\Exception $e) { + } catch (Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } + return $response; } - public function parserGetInformation ($data) + public function parserGetInformation($data) { $structure = array( 'case' => array( - 'PRO_TITLE' => 'processTitle', - 'APP_TITLE' => 'caseTitle', - 'APP_NUMBER' => 'caseNumber', - 'APP_STATUS' => 'caseStatus', - 'APP_UID' => 'caseId', - 'CREATOR' => 'caseCreator', + 'PRO_TITLE' => 'processTitle', + 'APP_TITLE' => 'caseTitle', + 'APP_NUMBER' => 'caseNumber', + 'APP_STATUS' => 'caseStatus', + 'APP_UID' => 'caseId', + 'CREATOR' => 'caseCreator', 'CREATE_DATE' => 'caseCreateDate', 'UPDATE_DATE' => 'caseUpdateData', 'DESCRIPTION' => 'caseDescription', - 'PRO_UID' => 'processId', - 'DEL_INDEX' => 'delIndex' + 'PRO_UID' => 'processId', + 'DEL_INDEX' => 'delIndex' ), 'task' => array( - 'TAS_TITLE' => 'taskTitle', - 'CURRENT_USER' => 'currentUser', + 'TAS_TITLE' => 'taskTitle', + 'CURRENT_USER' => 'currentUser', 'DEL_DELEGATE_DATE' => 'delDelegateDate', - 'DEL_INIT_DATE' => 'delInitDate', + 'DEL_INIT_DATE' => 'delInitDate', 'DEL_TASK_DUE_DATE' => 'delDueDate', - 'DEL_FINISH_DATE' => 'delFinishDate', - 'TAS_UID' => 'taskId' + 'DEL_FINISH_DATE' => 'delFinishDate', + 'TAS_UID' => 'taskId' ) ); $response = $this->replaceFields($data, $structure); + return $response; } @@ -1314,11 +1378,12 @@ class Light extends Api { try { $userUid = $this->getUserId(); - $oMobile = new \ProcessMaker\BusinessModel\Light(); + $oMobile = new BusinessModelLight(); $filesUids = $oMobile->postUidUploadFiles($userUid, $app_uid, $request_data); - } catch (\Exception $e) { + } catch (Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } + return $filesUids; } @@ -1333,11 +1398,12 @@ class Light extends Api { try { $userUid = $this->getUserId(); - $oMobile = new \ProcessMaker\BusinessModel\Light(); + $oMobile = new BusinessModelLight(); $response = $oMobile->documentUploadFiles($userUid, $app_uid, $app_doc_uid, $request_data); - } catch (\Exception $e) { + } catch (Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } + return $response; } @@ -1351,11 +1417,12 @@ class Light extends Api { try { $userUid = $this->getUserId(); - $oMobile = new \ProcessMaker\BusinessModel\Light(); + $oMobile = new BusinessModelLight(); $response = $oMobile->claimCaseUser($userUid, $app_uid); - } catch (\Exception $e) { + } catch (Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } + return $response; } @@ -1399,33 +1466,34 @@ class Light extends Api $dataList['search'] = $search; $appNotes = new \AppNotes(); - $response = $appNotes->getNotesList( $app_uid, '', $start, $limit ); - $response = $this->parserDataNotes($response['array']['notes']); + $response = $appNotes->getNotesList($app_uid, '', $start, $limit); + $response = $this->parserDataNotes($response['array']['notes']); return DateTime::convertUtcToIso8601($response, array('date')); - } catch (\Exception $e) { + } catch (Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } } - public function parserDataNotes ($data) + public function parserDataNotes($data) { $structure = array( - 'APP_UID' => 'caseId', + 'APP_UID' => 'caseId', 'notes' => array( - 'NOTE_DATE' => 'date', + 'NOTE_DATE' => 'date', 'NOTE_CONTENT' => 'content' ), 'user' => array( - 'USR_UID' => 'userId', - 'USR_USERNAME' => 'name', + 'USR_UID' => 'userId', + 'USR_USERNAME' => 'name', 'USR_FIRSTNAME' => 'firstName', - 'USR_LASTNAME' => 'lastName', - 'USR_EMAIL' => 'email' + 'USR_LASTNAME' => 'lastName', + 'USR_EMAIL' => 'email' ) ); $response = $this->replaceFields($data, $structure); + return $response; } @@ -1444,13 +1512,14 @@ class Light extends Api { try { $usr_uid = $this->getUserId(); - $cases = new \ProcessMaker\BusinessModel\Cases(); + $cases = new BusinessModelCases(); $sendMail = ($sendMail == 0) ? false : true; $cases->saveCaseNote($app_uid, $usr_uid, $noteContent, $sendMail); $result = array("status" => 'ok'); - } catch (\Exception $e) { + } catch (Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } + return $result; } @@ -1465,11 +1534,12 @@ class Light extends Api public function getCategoryList() { try { - $oLight = new \ProcessMaker\BusinessModel\Light(); + $oLight = new BusinessModelLight(); $category = $oLight->getCategoryList(); - } catch (\Exception $e) { + } catch (Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } + return $category; } @@ -1484,15 +1554,16 @@ class Light extends Api * * @url GET /process/:action */ - public function getProcessList ($action, $cat_uid = null) + public function getProcessList($action, $cat_uid = null) { try { $usr_uid = $this->getUserId(); - $oLight = new \ProcessMaker\BusinessModel\Light(); + $oLight = new BusinessModelLight(); $process = $oLight->getProcessList($action, $cat_uid, $usr_uid); - } catch (\Exception $e) { + } catch (Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } + return $process; } @@ -1506,20 +1577,21 @@ class Light extends Api * * @url GET /userstoreassign/:task_uid */ - public function getUsersToReassign ($task_uid) + public function getUsersToReassign($task_uid) { try { $usr_uid = $this->getUserId(); - $oLight = new \ProcessMaker\BusinessModel\Light(); + $oLight = new BusinessModelLight(); $process = $oLight->getUsersToReassign($usr_uid, $task_uid); - } catch (\Exception $e) { + } catch (Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } + return $process; } /** - * @return \stdclass + * @return stdclass * @throws RestException * * @param string $app_uid {@min 1}{@max 32} @@ -1527,62 +1599,65 @@ class Light extends Api * * @url POST /reassign/:app_uid/user/:to_usr_uid */ - public function reassignCase ($app_uid, $to_usr_uid) + public function reassignCase($app_uid, $to_usr_uid) { try { $usr_uid = $this->getUserId(); - $oLight = new \ProcessMaker\BusinessModel\Light(); + $oLight = new BusinessModelLight(); $process = $oLight->reassignCase($usr_uid, $app_uid, $to_usr_uid); - } catch (\Exception $e) { + } catch (Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } + return $process; } /** * Paused Case * - * @return \stdclass + * @return stdclass * @throws RestException * * @param string $app_uid {@min 1}{@max 32} * * @url POST /cases/:app_uid/pause */ - public function pauseCase ($app_uid, $request_data) + public function pauseCase($app_uid, $request_data) { try { Validator::throwExceptionIfDataNotMetIso8601Format($request_data, array('unpauseDate')); $usr_uid = $this->getUserId(); - $oLight = new \ProcessMaker\BusinessModel\Light(); + $oLight = new BusinessModelLight(); $process = $oLight->pauseCase($usr_uid, $app_uid, $request_data); - } catch (\Exception $e) { + } catch (Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } + return $process; } /** * Unpaused Case * - * @return \stdclass + * @return stdclass * @throws RestException * * @param string $app_uid {@min 1}{@max 32} * * @url POST /cases/:app_uid/unpause */ - public function unpauseCase ($app_uid) + public function unpauseCase($app_uid) { $result = array(); try { $usr_uid = $this->getUserId(); - $cases = new \ProcessMaker\BusinessModel\Cases(); + $cases = new BusinessModelCases(); $cases->putUnpauseCase($app_uid, $usr_uid); $result["status"] = "ok"; - } catch (\Exception $e) { + } catch (Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } + return $result; } @@ -1600,12 +1675,13 @@ class Light extends Api $response = array("status" => "false"); try { $userUid = $this->getUserId(); - $cases = new \ProcessMaker\BusinessModel\Cases(); + $cases = new BusinessModelCases(); $cases->putCancelCase($app_uid, $userUid); $response["status"] = "ok"; - } catch (\Exception $e) { + } catch (Exception $e) { throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } + return $response; } @@ -1613,7 +1689,7 @@ class Light extends Api * Get Case Variables * * @access protected - * @class AccessControl {@className \ProcessMaker\Services\Api\Cases} + * @class AccessControl {@className \ProcessMaker\Services\ApiCases} * @url GET /:app_uid/variables * * @param string $app_uid {@min 1}{@max 32} @@ -1628,10 +1704,11 @@ class Light extends Api { try { $usr_uid = $this->getUserId(); - $cases = new \ProcessMaker\BusinessModel\Cases(); + $cases = new BusinessModelCases(); $response = $cases->getCaseVariables($app_uid, $usr_uid, $dyn_uid, $pro_uid, $act_uid, $app_index); + return DateTime::convertUtcToTimeZone($response); - } catch (\Exception $e) { + } catch (Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } } @@ -1651,24 +1728,26 @@ class Light extends Api try { //Check if the user is a supervisor or have permissions $usr_uid = $this->getUserId(); - $cases = new \ProcessMaker\BusinessModel\Cases(); + $cases = new BusinessModelCases(); $hasAccess = $cases->checkUserHasPermissionsOrSupervisor($usr_uid, $app_uid, $dyn_uid); //When the user is a supervisor del_index is 0 if ($del_index <= 0 && !$hasAccess) { - throw (new \Exception(G::LoadTranslation('ID_INVALID_VALUE_EXPECTING_POSITIVE_INTEGER', array('del_index')), Api::STAT_APP_EXCEPTION)); + throw (new Exception(G::LoadTranslation('ID_INVALID_VALUE_EXPECTING_POSITIVE_INTEGER', + array('del_index')), Api::STAT_APP_EXCEPTION)); } if ($del_index === null) { - throw (new \Exception(G::LoadTranslation('ID_CAN_NOT_BE_NULL', array('del_index')), Api::STAT_APP_EXCEPTION)); + throw (new Exception(G::LoadTranslation('ID_CAN_NOT_BE_NULL', array('del_index')), + Api::STAT_APP_EXCEPTION)); } if ($del_index > 0) { if ($cases->caseAlreadyRouted($app_uid, $del_index, $usr_uid)) { - throw (new \Exception(G::LoadTranslation('ID_CASE_ALREADY_DERIVATED'), Api::STAT_APP_EXCEPTION)); + throw (new Exception(G::LoadTranslation('ID_CASE_ALREADY_DERIVATED'), Api::STAT_APP_EXCEPTION)); } } - $request_data = \ProcessMaker\Util\DateTime::convertDataToUtc($request_data); + $request_data = DateTime::convertDataToUtc($request_data); $cases->setCaseVariables($app_uid, $request_data, $dyn_uid, $usr_uid, $del_index); - } catch (\Exception $e) { + } catch (Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } } @@ -1685,12 +1764,12 @@ class Light extends Api { $return = array(); try { - $oPMap = new \ProcessMaker\BusinessModel\ProcessMap(); + $oPMap = new ProcessMap(); $schema = Adapter\BpmnWorkflow::getStruct($pro_uid); $schemaStatus = array(); if (!is_null($app_uid)) { - $case = new \ProcessMaker\BusinessModel\Cases(); + $case = new BusinessModelCases(); $case->setFormatFieldNameInUppercase(false); $schemaStatus = $case->getTasks($app_uid); } @@ -1698,12 +1777,13 @@ class Light extends Api $file = $oPMap->get_image($schema, $schemaStatus); ob_start(); imagepng($file); - $image = ob_get_clean(); + $image = ob_get_clean(); $return["map"] = base64_encode($image); - } catch (\Exception $e) { + } catch (Exception $e) { throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } + return $return; } @@ -1721,11 +1801,12 @@ class Light extends Api { try { $params = array('fileLimit' => $fileLimit); - $oMobile = new \ProcessMaker\BusinessModel\Light(); + $oMobile = new BusinessModelLight(); $response = $oMobile->getConfiguration($params); - } catch (\Exception $e) { + } catch (Exception $e) { throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } + return $response; } @@ -1743,17 +1824,18 @@ class Light extends Api { try { $params = array('fileLimit' => $fileLimit, 'tz' => $tz); - $oMobile = new \ProcessMaker\BusinessModel\Light(); + $oMobile = new BusinessModelLight(); $response = $oMobile->getConfiguration($params); - } catch (\Exception $e) { + } catch (Exception $e) { throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } + return $response; } - + /** * Get next step - * + * * @url POST /get-next-step/:app_uid * @return array */ @@ -1770,8 +1852,8 @@ class Light extends Api $response = array(); //conditionalSteps - $oCase = new \Cases(); - $oAppDelegate = new \AppDelegation(); + $oCase = new Cases(); + $oAppDelegate = new AppDelegation(); $alreadyRouted = $oAppDelegate->alreadyRouted($app_uid, $app_index); if ($alreadyRouted) { throw (new RestException(Api::STAT_APP_EXCEPTION, G::LoadTranslation('ID_CASE_DELEGATION_ALREADY_CLOSED'))); @@ -1795,21 +1877,22 @@ class Light extends Api $response["conditionalSteps"] = $conditionalSteps; //trigger before - if($conditionalSteps) { - $c = new \Criteria(); + if ($conditionalSteps) { + $c = new Criteria(); $c->clearSelectColumns(); - $c->addSelectColumn(\StepPeer::STEP_UID); - $c->addSelectColumn(\StepPeer::STEP_UID_OBJ); - $c->add(\StepPeer::TAS_UID, $act_uid); - $c->add(\StepPeer::STEP_TYPE_OBJ, 'DYNAFORM'); - $c->add(\StepPeer::STEP_UID_OBJ, $conditionalSteps['UID']); - $rs = \StepPeer::doSelectRS($c); + $c->addSelectColumn(StepPeer::STEP_UID); + $c->addSelectColumn(StepPeer::STEP_UID_OBJ); + $c->add(StepPeer::TAS_UID, $act_uid); + $c->add(StepPeer::STEP_TYPE_OBJ, 'DYNAFORM'); + $c->add(StepPeer::STEP_UID_OBJ, $conditionalSteps['UID']); + $rs = StepPeer::doSelectRS($c); $rs->setFetchmode(\ResultSet::FETCHMODE_ASSOC); $rs->next(); $row = $rs->getRow(); if ($row) { - $oMobile = new \ProcessMaker\BusinessModel\Light(); - $triggers = $oMobile->doExecuteTriggerCase($usr_uid, $pro_uid, $act_uid, $app_uid, $row['STEP_UID'], "before", $app_index); + $oMobile = new BusinessModelLight(); + $triggers = $oMobile->doExecuteTriggerCase($usr_uid, $pro_uid, $act_uid, $app_uid, $row['STEP_UID'], + "before", $app_index); if ($triggers["status"] === "ok") { $triggers["status"] = "200"; } @@ -1818,11 +1901,74 @@ class Light extends Api } //variables - $cases = new \ProcessMaker\BusinessModel\Cases(); + $cases = new BusinessModelCases(); $variables = $cases->getCaseVariables($app_uid, $usr_uid, $dyn_uid, $pro_uid, $act_uid, $app_index); $variables = DateTime::convertUtcToTimeZone($variables); $response["variables"] = $variables; return $response; } + + /** + * This function checks if the application uids sent are in the to do list for the specified user + * @url POST /todo/check + * @param array $requestData + * @return array $response + * @throws Exception + */ + public function doGetTodoCheck($requestData) + { + try { + $response = []; + $userUid = $this->getUserId(); + $mobile = new BusinessModelLight(); + $response = $mobile->getListCheck($userUid, $requestData, 'inbox', 'todo'); + } catch (Exception $e) { + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); + } + + return $response; + } + + /** + * This function checks if the application uids sent are in the draft list for the specified user + * @url POST /draft/check + * @param array $requestData + * @return array $response + * @throws Exception + */ + public function doGetDraftCheck($requestData) + { + try { + $response = []; + $userUid = $this->getUserId(); + $mobile = new BusinessModelLight(); + $response = $mobile->getListCheck($userUid, $requestData, 'inbox', 'draft'); + } catch (Exception $e) { + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); + } + + return $response; + } + + /** + * This function checks if the application uids sent are in the unassigned list for the specified user + * @url POST /unassigned/check + * @param array $requestData + * @return array $response + * @throws Exception + */ + public function doGetUnassignedCheck($requestData) + { + try { + $response = []; + $userUid = $this->getUserId(); + $mobile = new BusinessModelLight(); + $response = $mobile->getListCheck($userUid, $requestData, 'unassigned'); + } catch (Exception $e) { + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); + } + + return $response; + } }