From e1da377db149e78053c139edba88c9dacf02a5a7 Mon Sep 17 00:00:00 2001 From: dheeyi william Date: Wed, 18 Jan 2017 16:38:39 -0400 Subject: [PATCH] HOR-2501 Cases Link is not executing the redirect when the connections comes from a Mobile Device. --- gulliver/system/class.g.php | 33 ---------- workflow/engine/classes/class.pmFunctions.php | 19 ------ workflow/engine/methods/cases/opencase.php | 63 +++++++++---------- workflow/public_html/sysGeneric.php | 1 + 4 files changed, 31 insertions(+), 85 deletions(-) diff --git a/gulliver/system/class.g.php b/gulliver/system/class.g.php index 6b593fb25..d205e663e 100644 --- a/gulliver/system/class.g.php +++ b/gulliver/system/class.g.php @@ -5792,39 +5792,6 @@ class G { return $e->getMessage(); } - - /** - * Direct case link mobile - * @access public - * - * @param string - * @param int - * - * @return string - */ - public static function caseLinkMobile($applicationUid, $delIndex = 0) - { - $application = ApplicationPeer::retrieveByPK($applicationUid); - - if (is_null($application) || !is_numeric($delIndex) || $delIndex < 0) { - return false; - } - - if ($delIndex != 0) { - $appDelegation = AppDelegationPeer::retrieveByPK($applicationUid, $delIndex); - - if (is_null($appDelegation)) { - return false; - } - - $uri = 'processmakerMobile://' . $applicationUid . '/' . $delIndex; - } else { - $uri = 'processmakerMobile://' . $applicationUid; - } - - //Return - return $uri; - } } /** diff --git a/workflow/engine/classes/class.pmFunctions.php b/workflow/engine/classes/class.pmFunctions.php index 8b31758aa..e76f3ce0c 100644 --- a/workflow/engine/classes/class.pmFunctions.php +++ b/workflow/engine/classes/class.pmFunctions.php @@ -3946,22 +3946,3 @@ function PMFSendMessageToGroup( //Return return 1; } - -/** - * @method - * - * Direct case link mobile - * - * @name PMFCaseLinkMobile - * @label PMF Direct case link mobile - * @link http://wiki.processmaker.com/index.php/ProcessMaker_Functions#PMFCaseLinkMobile.28.29 - * - * @param string(32) | $applicationUid | ID of the case | The unique ID of the case - * @param int | $delIndex = 0 | Delegation index of the case | Optional parameter. The delegation index of a case - * @return string | $url | Direct case link to Mobile | Returns the direct case link to Mobile, FALSE otherwise - */ -function PMFCaseLinkMobile($applicationUid, $delIndex = 0) -{ - //Return - return G::caseLinkMobile($applicationUid, $delIndex); -} diff --git a/workflow/engine/methods/cases/opencase.php b/workflow/engine/methods/cases/opencase.php index 26331921f..82381f525 100644 --- a/workflow/engine/methods/cases/opencase.php +++ b/workflow/engine/methods/cases/opencase.php @@ -1,36 +1,29 @@ requirePermissions('PM_CASES'); +$isBrowserMobile = G::check_is_mobile(strtolower($_SERVER['HTTP_USER_AGENT'])); +if (!((defined('REDIRECT_TO_MOBILE') && REDIRECT_TO_MOBILE == 1 && $isBrowserMobile))) { + $isBrowserMobile = false; + if ($RBAC->userCanAccess('PM_CASES') != 1) { + header('location: ' . SYS_URI . 'login/login' . '?u=' . urlencode($_SERVER['REQUEST_URI'])); + die(); + } +} $G_MAIN_MENU = 'processmaker'; $G_ID_MENU_SELECTED = 'CASES'; $_POST['qs'] = ''; - $arrayAux = explode('?', $_SERVER['REQUEST_URI']); - preg_match('/^.*\/cases\/opencase\/([\w\-]{32})$/', $arrayAux[0], $arrayMatch); $applicationUid = $arrayMatch[1]; - $case = new \ProcessMaker\BusinessModel\Cases(); - $arrayApplicationData = $case->getApplicationRecordByPk($applicationUid, [], false); $G_PUBLISH = new Publisher(); -if ($arrayApplicationData !== false) { - $isBrowserMobile = G::check_is_mobile(strtolower($_SERVER['HTTP_USER_AGENT'])); - - if (!(defined('REDIRECT_TO_MOBILE') && REDIRECT_TO_MOBILE == 1 && $isBrowserMobile)) { - $_SESSION['__CD__'] = '../'; - $_SESSION['__OPEN_APPLICATION_UID__'] = $applicationUid; - - $G_PUBLISH->AddContent('view', 'cases/cases_Load'); - - $headPublisher = &headPublisher::getSingleton(); - $headPublisher->addScriptFile('/jscore/src/PM.js'); - $headPublisher->addScriptFile('/jscore/src/Sessions.js'); - } else { +if ($isBrowserMobile) { + $delIndex = 0; + if ($arrayApplicationData !== false) { $case = new \ProcessMaker\BusinessModel\Cases(); $arrayResult = $case->getStatusInfo($applicationUid, 0, $_SESSION['USER_LOGGED']); @@ -42,26 +35,30 @@ if ($arrayApplicationData !== false) { $arrayResult = $case->getStatusInfo($applicationUid); $arrayDelIndex = $arrayResult['DEL_INDEX']; } - - $delIndex = 0; - if (count($arrayDelIndex) == 1) { $delIndex = $arrayDelIndex[0]; } - - $urlMobile = G::caseLinkMobile($applicationUid, $delIndex); - - G::header('Location: ' . $urlMobile); - exit(0); } + $urlMobile = 'processmakerMobile://' . $applicationUid . '/' . $delIndex; + G::header('Location: ' . $urlMobile); + exit(0); } else { - $G_PUBLISH->AddContent( - 'xmlform', - 'xmlform', - 'login/showMessage', - '', - ['MESSAGE' => \G::LoadTranslation('ID_CASE_DOES_NOT_EXIST2', ['app_uid', $applicationUid])] - ); + if ($arrayApplicationData !== false) { + $_SESSION['__CD__'] = '../'; + $_SESSION['__OPEN_APPLICATION_UID__'] = $applicationUid; + $G_PUBLISH->AddContent('view', 'cases/cases_Load'); + $headPublisher = &headPublisher::getSingleton(); + $headPublisher->addScriptFile('/jscore/src/PM.js'); + $headPublisher->addScriptFile('/jscore/src/Sessions.js'); + } else { + $G_PUBLISH->AddContent( + 'xmlform', + 'xmlform', + 'login/showMessage', + '', + ['MESSAGE' => \G::LoadTranslation('ID_CASE_DOES_NOT_EXIST2', ['app_uid', $applicationUid])] + ); + } } G::RenderPage('publish'); diff --git a/workflow/public_html/sysGeneric.php b/workflow/public_html/sysGeneric.php index 0b32f04eb..b7b4fb4d3 100644 --- a/workflow/public_html/sysGeneric.php +++ b/workflow/public_html/sysGeneric.php @@ -960,6 +960,7 @@ if (! defined( 'EXECUTE_BY_CRON' )) { $noLoginFiles[] = 'propelTableAjax'; $noLoginFiles[] = 'licenseUpdate'; $noLoginFiles[] = 'casesStreamingFile'; + $noLoginFiles[] = 'opencase'; $noLoginFolders[] = 'services'; $noLoginFolders[] = 'tracker';