This commit is contained in:
Roly Rudy Gutierrez Pinto
2019-03-08 09:56:08 -04:00
parent 099d056cd0
commit 2e79581a30
6 changed files with 89 additions and 75 deletions

View File

@@ -28,11 +28,11 @@
//
// License: LGPL, see LICENSE
////////////////////////////////////////////////////
use ProcessMaker\BusinessModel\Cases as BusinessModelCases;
use ProcessMaker\Core\System;
use ProcessMaker\Plugins\PluginRegistry;
use ProcessMaker\Util\ElementTranslation;
/**
* ProcessMaker has made a number of its PHP functions available be used in triggers and conditions.
* Most of these functions are wrappers for internal functions used in Gulliver, which is the development framework
@@ -3470,38 +3470,26 @@ function PMFGetNextDerivationInfo($caseUid, $delIndex)
* @param string | $skin = null | Skin | The skin
*
* @return string | $url | Direct case link | Returns the direct case link, FALSE otherwise
* @link https://wiki.processmaker.com/3.2/Direct_Case_Link
*/
function PMFCaseLink($caseUid, $workspace = null, $language = null, $skin = null)
{
try {
$case = new \ProcessMaker\BusinessModel\Cases();
$case = new BusinessModelCases();
$arrayApplicationData = $case->getApplicationRecordByPk($caseUid, [], false);
if ($arrayApplicationData === false) {
return false;
}
$conf = new Configurations();
$envSkin = defined("SYS_SKIN") ? SYS_SKIN : $conf->getConfiguration('SKIN_CRON', '');
$workspace = (!empty($workspace)) ? $workspace : config("system.workspace");
$language = (!empty($language)) ? $language : SYS_LANG;
$skin = (!empty($skin)) ? $skin : $envSkin;
$workspace = !empty($workspace) ? $workspace : config("system.workspace");
$language = !empty($language) ? $language : SYS_LANG;
if (empty($skin)) {
$config = System::getSystemConfiguration();
$skin = defined("SYS_SKIN") ? SYS_SKIN : $config['default_skin'];
}
$uri = '/sys' . $workspace . '/' . $language . '/' . $skin . '/cases/opencase/' . $caseUid;
$envHost = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : SERVER_NAME;
$envProtocol = defined("REQUEST_SCHEME") && REQUEST_SCHEME === "https";
if (isset($_SERVER['SERVER_PORT'])) {
$envPort = ($_SERVER['SERVER_PORT'] != "80") ? ":" . $_SERVER['SERVER_PORT'] : "";
} else if (defined('SERVER_PORT')) {
$envPort = (SERVER_PORT . "" != "80") ? ":" . SERVER_PORT : "";
} else {
$envPort = "";
}
if (!empty($envPort) && strpos($envHost, $envPort) === false) {
$envHost = $envHost . $envPort;
}
$link = (G::is_https() || $envProtocol ? 'https://' : 'http://') . $envHost . $uri;
$link = System::getServerProtocolHost() . $uri;
return $link;
} catch (Exception $e) {
throw $e;