diff --git a/workflow/engine/bin/cron_single.php b/workflow/engine/bin/cron_single.php index be7faf0a6..83c25f284 100644 --- a/workflow/engine/bin/cron_single.php +++ b/workflow/engine/bin/cron_single.php @@ -91,6 +91,8 @@ try { require_once('propel/Propel.php'); require_once('creole/Creole.php'); + //TODO: get rid of the global variable improving the timezone activation when this feature is enabled + global $arraySystemConfiguration; $arraySystemConfiguration = System::getSystemConfiguration('', '', $workspace); $e_all = (defined('E_DEPRECATED'))? E_ALL & ~E_DEPRECATED : E_ALL; @@ -639,15 +641,7 @@ function executeScheduledCases($sNow=null) setExecutionMessage("Executing the scheduled starting cases"); setExecutionResultMessage('PROCESSING'); - if (isset($sNow)) { - //as the $sNow param that comes from the command line doesn't specicy a time zone - //we assume that the user set this time using the server time zone so we use the gmdate - //function to convert it - $runDate = gmdate('Y-m-d H:i:s', strtotime($sNow)); - } - else { - $runDate = gmdate('Y-m-d H:i:s'); - } + $runDate = runDateForScheduledCases($sNow); $oCaseScheduler = new CaseScheduler(); $oCaseScheduler->caseSchedulerCron($runDate, $log, 1); @@ -667,6 +661,35 @@ function executeScheduledCases($sNow=null) } } +function runDateForScheduledCases($sNow) { + global $arraySystemConfiguration; + + $runDate = isset($sNow)? $sNow : date('Y-m-d H:i:s'); + + $systemUtcTimeZone = false; + /*----------------------------------********---------------------------------*/ + if (PMLicensedFeatures::getSingleton()->verifyfeature('oq3S29xemxEZXJpZEIzN01qenJUaStSekY4cTdJVm5vbWtVM0d4S2lJSS9qUT0=')) { + $systemUtcTimeZone = (int)($arraySystemConfiguration['system_utc_time_zone']) == 1; + } + /*----------------------------------********---------------------------------*/ + + if ($systemUtcTimeZone) { + if (isset($sNow)) { + //as the $sNow param that comes from the command line doesn't specicy a time zone + //we assume that the user set this time using the server time zone so we use the gmdate + //function to convert it + $currentTimeZone = date_default_timezone_get(); + date_default_timezone_set($arraySystemConfiguration['time_zone']); + $runDate = gmdate('Y-m-d H:i:s', strtotime($sNow)); + date_default_timezone_set($currentTimeZone); + } + else { + $runDate = gmdate('Y-m-d H:i:s'); + } + } + return $runDate; +} + function executeUpdateAppTitle() { try {