Merge remote branch 'upstream/master'
This commit is contained in:
@@ -225,6 +225,12 @@ class headPublisher
|
||||
}
|
||||
|
||||
$head = $head . "
|
||||
<noscript>
|
||||
<div>
|
||||
". G::LoadTranslation( 'ID_ERROR_JS_NOT_AVAILABLE' )."
|
||||
</div>
|
||||
</noscript>
|
||||
|
||||
<script type=\"text/javascript\">
|
||||
var BROWSER_CACHE_FILES_UID = \"" . G::browserCacheFilesGetUid() . "\";
|
||||
</script>
|
||||
|
||||
@@ -54,8 +54,10 @@ $bCronIsRunning = false;
|
||||
$sLastExecution = null;
|
||||
$processcTimeProcess = 0;
|
||||
$processcTimeStart = 0;
|
||||
if (file_exists(PATH_DATA . "cron")) {
|
||||
|
||||
$force = false;
|
||||
$osIsLinux = strtoupper(substr(PHP_OS, 0, 3)) != "WIN";
|
||||
|
||||
for ($i = 1; $i <= count($argv) - 1; $i++) {
|
||||
if (strpos($argv[$i], "+force") !== false) {
|
||||
$force = true;
|
||||
@@ -63,24 +65,36 @@ if (file_exists(PATH_DATA . "cron")) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!$force) {
|
||||
$arrayCron = unserialize(trim(@file_get_contents(PATH_DATA . "cron")));
|
||||
|
||||
if (!$force && file_exists(PATH_DATA . "cron")) {
|
||||
//Windows flag
|
||||
//Get data of cron file
|
||||
$arrayCron = unserialize(trim(file_get_contents(PATH_DATA . "cron")));
|
||||
|
||||
$bCronIsRunning = (boolean)($arrayCron["bCronIsRunning"]);
|
||||
$sLastExecution = $arrayCron["sLastExecution"];
|
||||
$processcTimeProcess = (isset($arrayCron["processcTimeProcess"]))? intval($arrayCron["processcTimeProcess"]) : 10; //Minutes
|
||||
$processcTimeProcess = (isset($arrayCron["processcTimeProcess"]))? (int)($arrayCron["processcTimeProcess"]) : 10; //Minutes
|
||||
$processcTimeStart = (isset($arrayCron["processcTimeStart"]))? $arrayCron["processcTimeStart"] : 0;
|
||||
} else {
|
||||
G::rm_dir(PATH_DATA . "cron");
|
||||
}
|
||||
}
|
||||
if ($bCronIsRunning && $processcTimeStart != 0) {
|
||||
if ((time() - $processcTimeStart) > ($processcTimeProcess * 60)) {
|
||||
//Cron finished his execution for some reason
|
||||
$bCronIsRunning = false;
|
||||
|
||||
if (!$force && $osIsLinux) {
|
||||
//Linux flag
|
||||
//Check if cron it's running
|
||||
exec("ps -fea | grep cron.php | grep -v grep", $arrayOutput);
|
||||
|
||||
if (count($arrayOutput) > 1) {
|
||||
$bCronIsRunning = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$bCronIsRunning) {
|
||||
//if (!$force && $bCronIsRunning && $processcTimeStart != 0) {
|
||||
// if ((time() - $processcTimeStart) > ($processcTimeProcess * 60)) {
|
||||
// //Cron finished his execution for some reason
|
||||
// $bCronIsRunning = false;
|
||||
// }
|
||||
//}
|
||||
|
||||
if ($force || !$bCronIsRunning) {
|
||||
//Start cron
|
||||
$arrayCron = array("bCronIsRunning" => "1", "sLastExecution" => date("Y-m-d H:i:s"));
|
||||
@file_put_contents(PATH_DATA . "cron", serialize($arrayCron));
|
||||
|
||||
@@ -176,20 +176,6 @@ if (! defined ('PATH_HOME')) {
|
||||
|
||||
// G::loadClass('pmScript');
|
||||
|
||||
// //default values
|
||||
// $bCronIsRunning = false;
|
||||
// $sLastExecution = '';
|
||||
// if ( file_exists(PATH_DATA . 'cron') ) {
|
||||
// $aAux = unserialize( trim( @file_get_contents(PATH_DATA . 'cron')) );
|
||||
// $bCronIsRunning = (boolean)$aAux['bCronIsRunning'];
|
||||
// $sLastExecution = $aAux['sLastExecution'];
|
||||
// }
|
||||
// else {
|
||||
// //if not exists the file, just create a new one with current date
|
||||
// @file_put_contents(PATH_DATA . 'cron', serialize(array('bCronIsRunning' =>
|
||||
// '1', 'sLastExecution' => date('Y-m-d H:i:s'))));
|
||||
// }
|
||||
|
||||
print "PATH_HOME: " . PATH_HOME . "\n";
|
||||
print "PATH_DB: " . PATH_DB . "\n";
|
||||
print "PATH_CORE: " . PATH_CORE . "\n";
|
||||
@@ -312,10 +298,6 @@ else {
|
||||
processWorkspace ();
|
||||
}
|
||||
|
||||
// finally update the file
|
||||
// @file_put_contents(PATH_DATA . 'cron', serialize(array('bCronIsRunning' =>
|
||||
// '0', 'sLastExecution' => date('Y-m-d H:i:s'))));
|
||||
|
||||
function processWorkspace()
|
||||
{
|
||||
global $sLastExecution;
|
||||
|
||||
@@ -107,20 +107,6 @@ require_once 'classes/model/AppEvent.php';
|
||||
require_once 'classes/model/CaseScheduler.php';
|
||||
// G::loadClass('pmScript');
|
||||
|
||||
// //default values
|
||||
// $bCronIsRunning = false;
|
||||
// $sLastExecution = '';
|
||||
// if ( file_exists(PATH_DATA . 'cron') ) {
|
||||
// $aAux = unserialize( trim( @file_get_contents(PATH_DATA . 'cron')) );
|
||||
// $bCronIsRunning = (boolean)$aAux['bCronIsRunning'];
|
||||
// $sLastExecution = $aAux['sLastExecution'];
|
||||
// }
|
||||
// else {
|
||||
// //if not exists the file, just create a new one with current date
|
||||
// @file_put_contents(PATH_DATA . 'cron', serialize(array('bCronIsRunning' =>
|
||||
// '1', 'sLastExecution' => date('Y-m-d H:i:s'))));
|
||||
// }
|
||||
|
||||
print "PATH_HOME: " . PATH_HOME . "\n";
|
||||
print "PATH_DB: " . PATH_DB . "\n";
|
||||
print "PATH_CORE: " . PATH_CORE . "\n";
|
||||
@@ -244,10 +230,6 @@ else {
|
||||
processWorkspace ();
|
||||
}
|
||||
|
||||
// finally update the file
|
||||
// @file_put_contents(PATH_DATA . 'cron', serialize(array('bCronIsRunning' =>
|
||||
// '0', 'sLastExecution' => date('Y-m-d H:i:s'))));
|
||||
|
||||
function processWorkspace()
|
||||
{
|
||||
global $sLastExecution;
|
||||
|
||||
@@ -19,7 +19,6 @@ class pmDynaform
|
||||
{
|
||||
$this->dyn_uid = $dyn_uid;
|
||||
$this->app_data = $app_data;
|
||||
|
||||
$this->getDynaform();
|
||||
}
|
||||
|
||||
@@ -87,6 +86,18 @@ class pmDynaform
|
||||
public function printEdit($pm_run_outside_main_app, $application, $headData)
|
||||
{
|
||||
ob_clean();
|
||||
|
||||
$a = $this->clientToken();
|
||||
$clientToken = array(
|
||||
"accessToken" => $a["access_token"],
|
||||
"expiresIn" => $a["expires_in"],
|
||||
"tokenType" => $a["token_type"],
|
||||
"scope" => $a["scope"],
|
||||
"refreshToken" => $a["refresh_token"],
|
||||
"clientId" => $a["client_id"],
|
||||
"clientSecret" => $a["client_secret"]
|
||||
);
|
||||
|
||||
$file = file_get_contents(PATH_HOME . 'public_html/lib/pmdynaform/build/cases_Step_Pmdynaform.html');
|
||||
$file = str_replace("{JSON_DATA}", $this->record["DYN_CONTENT"], $file);
|
||||
$file = str_replace("{CASE}", $headData["CASE"], $file);
|
||||
@@ -97,9 +108,78 @@ class pmDynaform
|
||||
$file = str_replace("{DYN_UID}", $this->dyn_uid, $file);
|
||||
$file = str_replace("{DYNAFORMNAME}", $this->record["PRO_UID"] . "_" . $this->record["DYN_UID"], $file);
|
||||
$file = str_replace("{APP_UID}", $application, $file);
|
||||
$file = str_replace("{PRJ_UID}", $this->app_data["PROCESS"], $file);
|
||||
$file = str_replace("{WORKSPACE}", $this->app_data["SYS_SYS"], $file);
|
||||
$file = str_replace("{credentials}", json_encode($clientToken), $file);
|
||||
echo $file;
|
||||
exit();
|
||||
}
|
||||
|
||||
private function clientToken()
|
||||
{
|
||||
$client = $this->getClientCredentials();
|
||||
$authCode = $this->getAuthorizationCode($client);
|
||||
|
||||
|
||||
$request = array(
|
||||
'grant_type' => 'authorization_code',
|
||||
'code' => $authCode
|
||||
);
|
||||
$server = array(
|
||||
'REQUEST_METHOD' => 'POST'
|
||||
);
|
||||
$headers = array(
|
||||
"PHP_AUTH_USER" => $client['CLIENT_ID'],
|
||||
"PHP_AUTH_PW" => $client['CLIENT_SECRET'],
|
||||
"Content-Type" => "multipart/form-data;",
|
||||
"Authorization" => "Basic " . base64_encode($client['CLIENT_ID'] . ":" . $client['CLIENT_SECRET'])
|
||||
);
|
||||
|
||||
$request = new \OAuth2\Request(array(), $request, array(), array(), array(), $server, null, $headers);
|
||||
$oauthServer = new \ProcessMaker\Services\OAuth2\Server();
|
||||
$response = $oauthServer->getServer()->handleTokenRequest($request);
|
||||
$clientToken = $response->getParameters();
|
||||
$clientToken["client_id"] = $client['CLIENT_ID'];
|
||||
$clientToken["client_secret"] = $client['CLIENT_SECRET'];
|
||||
|
||||
return $clientToken;
|
||||
}
|
||||
|
||||
protected $clientId = 'x-pm-local-client';
|
||||
|
||||
protected function getClientCredentials()
|
||||
{
|
||||
$oauthQuery = new ProcessMaker\Services\OAuth2\PmPdo($this->getDsn());
|
||||
return $oauthQuery->getClientDetails($this->clientId);
|
||||
}
|
||||
|
||||
protected function getAuthorizationCode($client)
|
||||
{
|
||||
\ProcessMaker\Services\OAuth2\Server::setDatabaseSource($this->getDsn());
|
||||
\ProcessMaker\Services\OAuth2\Server::setPmClientId($client['CLIENT_ID']);
|
||||
|
||||
$oauthServer = new \ProcessMaker\Services\OAuth2\Server();
|
||||
$userId = $_SESSION['USER_LOGGED'];
|
||||
$authorize = true;
|
||||
$_GET = array_merge($_GET, array(
|
||||
'response_type' => 'code',
|
||||
'client_id' => $client['CLIENT_ID'],
|
||||
'scope' => implode(' ', $oauthServer->getScope())
|
||||
));
|
||||
|
||||
$response = $oauthServer->postAuthorize($authorize, $userId, true);
|
||||
$code = substr($response->getHttpHeader('Location'), strpos($response->getHttpHeader('Location'), 'code=') + 5, 40);
|
||||
|
||||
return $code;
|
||||
}
|
||||
|
||||
private function getDsn()
|
||||
{
|
||||
list($host, $port) = strpos(DB_HOST, ':') !== false ? explode(':', DB_HOST) : array(DB_HOST, '');
|
||||
$port = empty($port) ? '' : ";port=$port";
|
||||
$dsn = DB_ADAPTER . ':host=' . $host . ';dbname=' . DB_NAME . $port;
|
||||
|
||||
return array('dsn' => $dsn, 'username' => DB_USER, 'password' => DB_PASS);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -219,16 +219,16 @@ class PMScript
|
||||
{
|
||||
$sScript = "";
|
||||
$iAux = 0;
|
||||
$bEqual = false;
|
||||
$iOcurrences = preg_match_all( '/\@(?:([\@\%\#\?\$\=])([a-zA-Z\_]\w*)|([a-zA-Z\_][\w\-\>\:]*)\(((?:[^\\\\\)]' . '*(?:[\\\\][\w\W])?)*)\))((?:\s*\[[\'"]?\w+[\'"]?\])+)?/', $this->sScript, $aMatch, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE );
|
||||
if ($iOcurrences) {
|
||||
for ($i = 0; $i < $iOcurrences; $i ++) {
|
||||
$bEqual = false;
|
||||
$sAux = substr( $this->sScript, $iAux, $aMatch[0][$i][1] - $iAux );
|
||||
if (! $bEqual) {
|
||||
if (strpos( $sAux, '==' ) !== false) {
|
||||
if (strpos($sAux, "==") !== false || strpos($sAux, "!=") !== false || strpos($sAux, ">") !== false || strpos($sAux, "<") !== false || strpos($sAux, ">=") !== false || strpos($sAux, "<=") !== false || strpos($sAux, "<>") !== false || strpos($sAux, "===") !== false || strpos($sAux, "!==") !== false) {
|
||||
$bEqual = false;
|
||||
} else {
|
||||
if (strpos( $sAux, '=' ) !== false) {
|
||||
if (strpos($sAux, "=") !== false || strpos($sAux, "+=") !== false || strpos($sAux, "-=") !== false || strpos($sAux, "*=") !== false || strpos($sAux, "/=") !== false || strpos($sAux, "%=") !== false || strpos($sAux, ".=") !== false) {
|
||||
$bEqual = true;
|
||||
}
|
||||
}
|
||||
@@ -246,22 +246,6 @@ class PMScript
|
||||
}
|
||||
}
|
||||
$sScript .= $sAux;
|
||||
/** patch1: support for the expression: @@a = @@b = @@c = @@d; */
|
||||
$bEqual = true;
|
||||
if ($i < $iOcurrences - 1) {
|
||||
$ii = $aMatch[0][$i][1] + strlen($aMatch[0][$i][0]);
|
||||
$ss = trim(substr($this->sScript, $ii, $aMatch[0][$i + 1][1] - $ii));
|
||||
} else {
|
||||
$ii = $aMatch[0][$i][1] + strlen($aMatch[0][$i][0]);
|
||||
$ss = trim(substr($this->sScript, $ii));
|
||||
}
|
||||
$sw0 = strpos($ss, '=') === 0 || strpos($ss, '+=') === 0 || strpos($ss, '-=') === 0;
|
||||
$sw1 = strpos($ss, '==') === 0 || strpos($ss, '===') === 0 || strpos($ss, '!=') === 0 || strpos($ss, '!==') === 0 || strpos($ss, '<=') === 0 || strpos($ss, '>=') === 0;
|
||||
$sw3 = substr(trim($sAux), strlen(trim($sAux)) - 6, strlen(trim($sAux))) === "empty(";
|
||||
if (($sw0 && !$sw1) || $sw3) {
|
||||
$bEqual = false;
|
||||
}
|
||||
/** patch1 end */
|
||||
$iAux = $aMatch[0][$i][1] + strlen( $aMatch[0][$i][0] );
|
||||
switch ($aMatch[1][$i][0]) {
|
||||
case '@':
|
||||
|
||||
@@ -108,7 +108,7 @@ class Home extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
$switchLink = $userProperty->getUserLocation( $_SESSION['USER_LOGGED'] );
|
||||
$switchLink = $userProperty->getUserLocation( $_SESSION['USER_LOGGED'], SYS_LANG );
|
||||
|
||||
if (!isset($_COOKIE['workspaceSkin'])) {
|
||||
if (substr( $sysConf['default_skin'], 0, 2 ) == 'ux') {
|
||||
|
||||
@@ -25,6 +25,12 @@ $(window).load(function () {
|
||||
var data = JSON.parse(jsondata);
|
||||
window.dynaform = new PMDynaform.core.Project({
|
||||
data: data,
|
||||
keys: {
|
||||
server: location.host,
|
||||
projectId: prj_uid,
|
||||
workspace: workspace
|
||||
},
|
||||
token: credentials,
|
||||
submitRest: false
|
||||
});
|
||||
|
||||
|
||||
@@ -16,21 +16,36 @@ $sLastExecution = null;
|
||||
$processcTimeProcess = 0;
|
||||
$processcTimeStart = 0;
|
||||
|
||||
$osIsLinux = strtoupper(substr(PHP_OS, 0, 3)) != "WIN";
|
||||
|
||||
if (file_exists(PATH_DATA . "cron")) {
|
||||
$arrayCron = unserialize( trim( @file_get_contents( PATH_DATA . "cron" ) ) );
|
||||
//Windows flag
|
||||
//Get data of cron file
|
||||
$arrayCron = unserialize(trim(file_get_contents(PATH_DATA . "cron")));
|
||||
|
||||
$bCronIsRunning = (boolean)($arrayCron["bCronIsRunning"]);
|
||||
$sLastExecution = $arrayCron["sLastExecution"];
|
||||
$processcTimeProcess = (isset( $arrayCron["processcTimeProcess"] )) ? intval( $arrayCron["processcTimeProcess"] ) : 10;
|
||||
$processcTimeProcess = (isset($arrayCron["processcTimeProcess"]))? (int)($arrayCron["processcTimeProcess"]) : 10; //Minutes
|
||||
$processcTimeStart = (isset($arrayCron["processcTimeStart"]))? $arrayCron["processcTimeStart"] : 0;
|
||||
}
|
||||
|
||||
if ($bCronIsRunning && $processcTimeStart != 0) {
|
||||
if ((time() - $processcTimeStart) > ($processcTimeProcess * 60)) {
|
||||
//Cron finished his execution for some reason
|
||||
$bCronIsRunning = false;
|
||||
if ($osIsLinux) {
|
||||
//Linux flag
|
||||
//Check if cron it's running
|
||||
exec("ps -fea | grep cron.php | grep -v grep", $arrayOutput);
|
||||
|
||||
if (count($arrayOutput) > 0) {
|
||||
$bCronIsRunning = true;
|
||||
}
|
||||
}
|
||||
|
||||
//if ($bCronIsRunning && $processcTimeStart != 0) {
|
||||
// if ((time() - $processcTimeStart) > ($processcTimeProcess * 60)) {
|
||||
// //Cron finished his execution for some reason
|
||||
// $bCronIsRunning = false;
|
||||
// }
|
||||
//}
|
||||
|
||||
//Data
|
||||
$c = new Configurations();
|
||||
$configPage = $c->getConfiguration( "cronList", "pageSize", null, $_SESSION["USER_LOGGED"] );
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
var dyn_uid = '{DYN_UID}';
|
||||
var __DynaformName__ = '{DYNAFORMNAME}';
|
||||
var app_uid = '{APP_UID}';
|
||||
var prj_uid = '{PRJ_UID}';
|
||||
var workspace = '{WORKSPACE}';
|
||||
var credentials = {credentials};
|
||||
</script>
|
||||
<script type="text/javascript" src="/jscore/cases/core/cases_Step.js"></script>
|
||||
<script type="text/javascript" src="/jscore/cases/core/cases_Step_Pmdynaform.js"></script>
|
||||
|
||||
@@ -72,8 +72,14 @@
|
||||
$previouspage = $_POST['previous_step']['PAGE'];
|
||||
|
||||
$html .= '</td></tr><tr><td align="center">';
|
||||
if($netxpage == ""){
|
||||
$html .= '<a href='.$previouspage.'>';
|
||||
$html .= '<input type="button" value="Back" class="module_app_button___gray" />';
|
||||
$html .= '</a>';
|
||||
} else{
|
||||
$html .= '<input type="button" value="Back" class="module_app_button___gray" onclick="javascript:history.back()">';
|
||||
$html .= '<input type="button" value="Continue" class="module_app_button___gray" onclick="javascript:location.href=\''.$netxpage.'\'">';
|
||||
}
|
||||
|
||||
|
||||
echo '<div class="grid" style="width:'.$width_content.'">
|
||||
|
||||
@@ -137,6 +137,30 @@ try {
|
||||
* you can change it or redirect to another page
|
||||
* i.e. G::header("Location: http://www.processmaker.com");
|
||||
*/
|
||||
|
||||
$_POST['__notValidateThisFields__'] = (isset( $_POST['__notValidateThisFields__'] ) && $_POST['__notValidateThisFields__'] != '') ? $_POST['__notValidateThisFields__'] : $_POST['DynaformRequiredFields'];
|
||||
if ($missing_req_values = $oForm->validateRequiredFields( $_POST['form'], Bootstrap::json_decode( stripslashes( $_POST['__notValidateThisFields__'] ) ) )) {
|
||||
$fieldsRequired = Bootstrap::json_decode(str_replace(array("%27", "%39"), array("\"", "'"), $_POST["DynaformRequiredFields"]));
|
||||
|
||||
foreach ($fieldsRequired as $key1 => $value1) {
|
||||
foreach ($missing_req_values as $key2 => $value2) {
|
||||
if ($value1->name == $value2) {
|
||||
$missing_req_values[$key2] = $value1->label;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$_POST['next_step']['PAGE'] = "";
|
||||
$_POST['previous_step']['PAGE'] = $_SERVER['HTTP_REFERER'];
|
||||
$_POST['req_val'] = $missing_req_values;
|
||||
|
||||
global $G_PUBLISH;
|
||||
$G_PUBLISH = new Publisher();
|
||||
$G_PUBLISH->AddContent( 'view', 'cases/missRequiredFields' );
|
||||
G::RenderPage( 'publish', 'blank' );
|
||||
exit( 0 );
|
||||
}
|
||||
|
||||
$G_PUBLISH = new Publisher();
|
||||
$G_PUBLISH->AddContent("xmlform", "xmlform", "login/showInfo", "", $aMessage);
|
||||
G::RenderPage("publish", "blank");
|
||||
|
||||
Reference in New Issue
Block a user