Merged in release/3.2.2 (pull request #6059)

Updating branch release/3.2.3 with the last changes made on branch release/3.2.2

Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
Julio Cesar Laura Avendaño
2017-09-14 19:48:06 +00:00
8 changed files with 1191 additions and 1098 deletions

View File

@@ -748,6 +748,7 @@ class headPublisher
*/
public function getExtJsViewState()
{
$json = new stdClass();
$views = array();
$keyState = "extJsViewState";
$prefixExtJs = "ys-";
@@ -772,7 +773,9 @@ class headPublisher
$views[$key] = $value[1];
}
}
$oServerConf->setProperty($keyState, G::json_encode($views));
if ((array)$json != $views) {
$oServerConf->setProperty($keyState, G::json_encode($views));
}
return $views;
}

View File

@@ -389,6 +389,8 @@ class RBAC
"PER_NAME" => "Edit User profile Default Cases Menu Options"
), array("PER_UID" => "00000000000000000000000000000064", "PER_CODE" => "PM_REASSIGNCASE_SUPERVISOR",
"PER_NAME" => "Reassign case supervisor"
), array("PER_UID" => "00000000000000000000000000000065", "PER_CODE" => "PM_SETUP_CUSTOM_CASES_LIST",
"PER_NAME" => "Setup Custom Cases List"
)
);
return $permissionsAdmin;

View File

@@ -1,6 +1,7 @@
<?php
use ProcessMaker\Core\System;
use ProcessMaker\BusinessModel\DynaForm\SuggestTrait;
/**
* Implementing pmDynaform library in the running case.
@@ -9,6 +10,7 @@ use ProcessMaker\Core\System;
*/
class PmDynaform
{
use SuggestTrait;
public static $instance = null;
public $fields = null;
@@ -256,66 +258,7 @@ class PmDynaform
}
$sql = G::replaceDataField($json->sql, $dtFields);
if ($value === "suggest") {
$sql = $this->sqlParse($sql, function($parsed, &$select, &$from, &$where, &$groupBy, &$having, &$orderBy, &$limit) use ($json) {
$dt = $parsed["SELECT"];
$isWhere = empty($where);
if ($isWhere === false) {
$where = substr_replace($where, " (", 5, 0) . ")";
}
if (!isset($json->queryField) && isset($dt[0]["base_expr"])) {
$col = $dt[0]["base_expr"];
$dv = str_replace("'", "''", $json->defaultValue);
if ($dv !== "") {
$where = $isWhere ? "WHERE " . $col . "='" . $dv . "'" : $where . " AND " . $col . "='" . $dv . "'";
}
}
if (isset($json->queryField) && isset($dt[0]["base_expr"])) {
$col = isset($dt[1]["base_expr"]) ? $dt[1]["base_expr"] : $dt[0]["base_expr"];
$qf = str_replace("'", "''", $json->queryFilter);
$where = $isWhere ? "WHERE " . $col . " LIKE '%" . $qf . "%'" : $where . " AND " . $col . " LIKE '%" . $qf . "%'";
}
$provider = $this->getDatabaseProvider($json->dbConnection);
$start = 0;
$end = 10;
if (isset($json->queryStart)) {
$start = $json->queryStart;
}
if (isset($json->queryLimit)) {
$end = $json->queryLimit;
}
if (empty($limit) && $provider === "mysql") {
$limit = "LIMIT " . $start . "," . $end . "";
}
if (empty($limit) && $provider === "pgsql") {
$limit = "OFFSET " . $start . " LIMIT " . $end . "";
}
if ($provider === "mssql") {
$limit = "";
if (strpos(strtoupper($select), "TOP") === false) {
$isDistinct = strpos(strtoupper($select), "DISTINCT");
$isAll = strpos(strtoupper($select), "ALL");
if ($isDistinct === false && $isAll === false) {
$select = preg_replace("/SELECT/", "SELECT TOP(" . $end . ")", strtoupper($select), 1);
}
if ($isDistinct !== false) {
$select = preg_replace("/DISTINCT/", "DISTINCT TOP(" . $end . ")", strtoupper($select), 1);
}
if ($isAll !== false) {
$select = preg_replace("/DISTINCT/", "DISTINCT TOP(" . $end . ")", strtoupper($select), 1);
}
}
}
if ($provider === "oracle") {
$limit = "";
$rowNumber = "";
if (strpos(strtoupper($where), "ROWNUM") === false) {
$rowNumber = " AND " . $start . " <= ROWNUM AND ROWNUM <= " . $end;
}
$where = empty($where) ? "WHERE " . $start . " <= ROWNUM AND ROWNUM <= " . $end : $where . $rowNumber;
}
});
$sql = $this->prepareSuggestSql($sql, $json);
}
$dt = $this->getCacheQueryData($json->dbConnection, $sql, $json->type);
foreach ($dt as $row) {

File diff suppressed because it is too large Load Diff

View File

@@ -293,10 +293,6 @@ try {
unset($_SESSION['FAILED_LOGINS']);
// increment logins in heartbeat
$oServerConf =& ServerConf::getSingleton();
$oServerConf->sucessfulLogin();
// Assign the uid of user to userloggedobj
$RBAC->loadUserRolePermission($RBAC->sSystem, $uid);
$res = $RBAC->userCanAccess('PM_LOGIN');
@@ -324,15 +320,6 @@ try {
$weblog->create($aLog);
/**end log**/
//************** background processes, here we are putting some back office routines **********
$heartBeatNWIDate = $oServerConf->getHeartbeatProperty('HB_NEXT_GWI_DATE','HEART_BEAT_CONF');
if (is_null($heartBeatNWIDate)) {
$heartBeatNWIDate = time();
}
if (time() >= $heartBeatNWIDate) {
$oServerConf->setHeartbeatProperty('HB_NEXT_GWI_DATE', strtotime('+1 day'), 'HEART_BEAT_CONF');
}
//**** defining and saving server info, this file has the values of the global array $_SERVER ****
//this file is useful for command line environment (no Browser), I mean for triggers, crons and other executed over command line

View File

@@ -1,128 +1,101 @@
<?php
/**
* language_Ajax.php
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*/
try {
$filter = new InputFilter();
$_POST = $filter->xssFilterHard($_POST);
if (isset( $_POST['form'] )) {
if (isset($_POST['form'])) {
$_POST = $_POST['form'];
}
$_POST['function'] = get_ajax_value( 'function' );
$_POST['function'] = get_ajax_value('function');
$_POST['function'] = $filter->xssFilterHard($_POST['function']);
switch ($_POST['function']) {
case 'savePredetermined':
$tranlationsList = Translation::getTranslationEnvironments();
g::pr( $tranlationsList );
die();
if (isset( $meta['LAN_ID'] ) && $meta['LAN_ID'] == $_POST['lang']) {
G::pr($tranlationsList);
if (isset($meta['LAN_ID']) && $meta['LAN_ID'] == $_POST['lang']) {
echo 'The Setting was saved successfully!';
} else {
echo 'Some error occured while the setting was being save, try later please.';
}
break;
case 'languagesList':
$isoCountry = new IsoCountry();
$translationRow = new Translation();
$response = new stdClass();
$translationsEnvList = $translationRow->getTranslationEnvironments();
//print_r($translationsEnvList); die;
$i = 0;
foreach ($translationsEnvList as $locale => $translationRow) {
$COUNTRY_ID = $translationRow['IC_UID'];
if ($COUNTRY_ID != '') {
$isoCountryRecord = $isoCountry->findById( strtoupper( $COUNTRY_ID ) );
$flag = strtolower( $isoCountryRecord['IC_UID'] );
$countryId = $translationRow['IC_UID'];
if ($countryId != '') {
$isoCountryRecord = $isoCountry->findById(strtoupper($countryId));
$flag = strtolower($isoCountryRecord['IC_UID']);
$countryName = $translationRow['HEADERS']['X-Poedit-Country'];
} else {
$flag = 'international';
$countryName = G::LoadTranslation( 'ID_INTERNATIONAL' );
$countryName = G::LoadTranslation('ID_INTERNATIONAL');
}
$conf = new Configurations();
$confCasesList = $conf->getConfiguration( 'casesList', 'todo' );
//echo date($confCasesList['dateformat'], '2010-01-01');
$confCasesList = $conf->getConfiguration('casesList', 'todo');
if (isset( $confCasesList['dateformat'] )) {
$datetime = explode( ' ', $translationRow['DATE'] );
$date = explode( '-', $datetime[0] );
if (count( $datetime ) == 2)
$time = explode( ':', $datetime[1] );
if (count( $date ) == 3) {
if (count( $time ) >= 2) {
$DATE = date( $confCasesList['dateformat'], mktime( $time[0], $time[1], 0, $date[1], $date[2], $date[0] ) );
} else {
$DATE = date( $confCasesList['dateformat'], mktime( 0, 0, 0, $date[1], $date[2], $date[0] ) );
}
} else {
$DATE = $translationRow['DATE'];
if (isset($confCasesList['dateformat'])) {
$datetime = explode(' ', $translationRow['DATE']);
$date = explode('-', $datetime[0]);
if (count($datetime) == 2) {
$time = explode(':', $datetime[1]);
}
$datetime = explode( ' ', $translationRow['HEADERS']['PO-Revision-Date'] );
$date = explode( '-', $datetime[0] );
if (count( $datetime ) == 2)
$time = explode( ':', $datetime[1] );
if (count( $date ) == 3) {
if (count( $time ) >= 2) {
$REV_DATE = date( $confCasesList['dateformat'], mktime( $time[0], substr( $time[1], 0, 2 ), 0, $date[1], $date[2], $date[0] ) );
if (count($date) == 3) {
if (count($time) >= 2) {
$dateFormat = date($confCasesList['dateformat'],
mktime($time[0], $time[1], 0, $date[1], $date[2], $date[0]));
} else {
$REV_DATE = date( $confCasesList['dateformat'], mktime( 0, 0, 0, $date[1], $date[2], $date[0] ) );
$dateFormat = date($confCasesList['dateformat'], mktime(0, 0, 0, $date[1], $date[2], $date[0]));
}
} else {
$REV_DATE = $translationRow['HEADERS']['PO-Revision-Date'];
$dateFormat = $translationRow['DATE'];
}
$datetime = explode(' ', $translationRow['HEADERS']['PO-Revision-Date']);
$date = explode('-', $datetime[0]);
if (count($datetime) == 2) {
$time = explode(':', $datetime[1]);
}
if (count($date) == 3) {
if (count($time) >= 2) {
$revDate = date($confCasesList['dateformat'],
mktime($time[0], substr($time[1], 0, 2), 0, $date[1], $date[2], $date[0]));
} else {
$revDate = date($confCasesList['dateformat'],
mktime(0, 0, 0, $date[1], $date[2], $date[0]));
}
} else {
$revDate = $translationRow['HEADERS']['PO-Revision-Date'];
}
} else {
$DATE = $translationRow['DATE'];
$REV_DATE = $translationRow['HEADERS']['PO-Revision-Date'];
$dateFormat = $translationRow['DATE'];
$revDate = $translationRow['HEADERS']['PO-Revision-Date'];
}
$languagesList[$i]['LAN_ID'] = $translationRow['LAN_ID'];
$languagesList[$i]['LOCALE'] = $translationRow['LOCALE'];
$languagesList[$i]['LAN_FLAG'] = $flag;
$languagesList[$i]['NUM_RECORDS'] = $translationRow['NUM_RECORDS'];
$languagesList[$i]['DATE'] = $DATE;
$languagesList[$i]['DATE'] = $dateFormat;
$languagesList[$i]['LAN_NAME'] = $translationRow['HEADERS']['X-Poedit-Language'];
$languagesList[$i]['COUNTRY_NAME'] = $countryName;
$languagesList[$i]['TRANSLATOR'] = htmlentities( $translationRow['HEADERS']['Last-Translator'] );
$languagesList[$i]['REV_DATE'] = $REV_DATE;
$languagesList[$i]['TRANSLATOR'] = htmlentities($translationRow['HEADERS']['Last-Translator']);
$languagesList[$i]['REV_DATE'] = $revDate;
$languagesList[$i]['VERSION'] = $translationRow['HEADERS']['Project-Id-Version'];
$i ++;
$i++;
}
$translationRow = new Translation();
$response->data = $languagesList;
print (G::json_encode( $response )) ;
print (G::json_encode($response));
break;
case 'delete':
include_once 'classes/model/Translation.php';
@@ -130,48 +103,34 @@ try {
$locale = $_POST['LOCALE'];
$trn = new Translation();
if (strpos( $locale, Translation::$localeSeparator ))
list ($LAN_ID, $IC_UID) = explode( Translation::$localeSeparator, $locale );
else {
$LAN_ID = $locale;
$LAN_ID = '';
if (strpos($locale, Translation::$localeSeparator)) {
list ($LAN_ID, $IC_UID) = explode(Translation::$localeSeparator, $locale);
}
$oCriteria = new Criteria( 'workflow' );
//$oCriteria->addSelectColumn('COUNT('.ContentPeer::CON_CATEGORY.')');
$oCriteria->addSelectColumn(ApplicationPeer::APP_TITLE);
$oDataset = ApplicationPeer::doSelectRS( $oCriteria );
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$oDataset->next();
$aRow = $oDataset->getRow();
if ($locale != "en") { //Default Language 'en'
if ($locale != SYS_LANG) { //Current Language
//THERE IS NO ANY CASE STARTED FROM THIS LANGUAGE
if (empty($aRow)) { //so we can delete this language
try {
Content::removeLanguageContent($locale);
$trn->removeTranslationEnvironment($locale);
echo G::LoadTranslation('ID_LANGUAGE_DELETED_SUCCESSFULLY');
} catch (Exception $e) {
$token = strtotime("now");
PMException::registerErrorLog($e, $token);
G::outRes(G::LoadTranslation("ID_EXCEPTION_LOG_INTERFAZ", array($token)));
}
} else {
echo str_replace('{0}', $aRow['APP_TITLE'], G::LoadTranslation('ID_LANGUAGE_CANT_DELETE'));
//Verify if is the default language 'en'
if ($locale != "en") {
//Verify if is the current language
if ($locale != SYS_LANG) {
try {
Content::removeLanguageContent($locale);
$trn->removeTranslationEnvironment($locale);
echo G::LoadTranslation('ID_LANGUAGE_DELETED_SUCCESSFULLY');
} catch (Exception $e) {
$token = strtotime("now");
PMException::registerErrorLog($e, $token);
G::outRes(G::LoadTranslation("ID_EXCEPTION_LOG_INTERFAZ", array($token)));
}
} else {
echo str_replace('{0}', $aRow['APP_TITLE'], G::LoadTranslation('ID_LANGUAGE_CANT_DELETE_CURRENTLY'));
echo G::LoadTranslation('ID_LANGUAGE_CANT_DELETE_CURRENTLY');
}
} else {
echo str_replace('{0}', $aRow['APP_TITLE'], G::LoadTranslation('ID_LANGUAGE_CANT_DELETE_DEFAULT'));
echo G::LoadTranslation('ID_LANGUAGE_CANT_DELETE_DEFAULT');
}
break;
}
} catch (Exception $oException) {
$token = strtotime("now");
PMException::registerErrorLog($oException, $token);
G::outRes( G::LoadTranslation("ID_EXCEPTION_LOG_INTERFAZ", array($token)) );
G::outRes(G::LoadTranslation("ID_EXCEPTION_LOG_INTERFAZ", array($token)));
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,173 @@
<?php
namespace ProcessMaker\BusinessModel\DynaForm;
/**
* SuggestTrait
* Methods required to prepare the query for the suggest fields.
*/
trait SuggestTrait
{
/**
* Get field current value.
*
* @param type $json
* @return type
*/
private function getSuggestValue($json)
{
$value = "";
if ($json->defaultValue !== "") {
$value = $json->defaultValue;
}
if (isset($this->fields["APP_DATA"][$json->name])) {
$value = $this->fields["APP_DATA"][$json->name];
}
return $value;
}
/**
* Prepare the query for the suggest field.
*
* @param type $sql
* @param type $json
* @return type
*/
private function prepareSuggestSql($sql, $json)
{
//If 0 find an specific row by the first column.
$optionsLimit = empty($json->queryLimit) ? 0 : $json->queryLimit;
return $this->sqlParse(
$sql,
function ($parsed, &$select, &$from, &$where, &$groupBy, &$having, &$orderBy, &$limit) use ($json, $optionsLimit)
{
$dt = $parsed["SELECT"];
$isWhere = empty($where);
if ($isWhere === false) {
$where = substr_replace($where, " (", 5, 0) . ")";
}
if (!isset($json->queryField) && isset($dt[0]["base_expr"])) {
$col = $dt[0]["base_expr"];
$dv = str_replace("'", "''", $json->defaultValue);
if ($dv !== "") {
$where = $isWhere ? "WHERE " . $col . "='" . $dv . "'" : $where . " AND " . $col . "='" . $dv . "'";
}
}
if (isset($json->queryField) && isset($dt[0]["base_expr"])) {
$col = isset($dt[1]["base_expr"]) ? $dt[1]["base_expr"] : $dt[0]["base_expr"];
$qf = str_replace("'", "''", $json->queryFilter);
$where = $isWhere ? "WHERE " . $col . " LIKE '%" . $qf . "%'" : $where . " AND " . $col . " LIKE '%" . $qf . "%'";
}
if ($optionsLimit > 0) {
$this->addSuggestLimit($json, $select, $limit, $where);
} else {
$this->addSuggestWhere($json, $parsed, $select, $where, $having);
}
}
);
}
/**
* Add the limit sentence to the suggest query.
*
* @param type $json
* @param type $select
* @param type $limit
* @param type $where
*/
private function addSuggestLimit($json, &$select, &$limit, &$where)
{
$start = 0;
$end = 10;
$provider = $this->getDatabaseProvider($json->dbConnection);
if (isset($json->queryStart)) {
$start = $json->queryStart;
}
if (isset($json->queryLimit)) {
$end = $json->queryLimit;
}
if (empty($limit) && $provider === "mysql") {
$limit = "LIMIT " . $start . "," . $end . "";
}
if (empty($limit) && $provider === "pgsql") {
$limit = "OFFSET " . $start . " LIMIT " . $end . "";
}
if ($provider === "mssql") {
$limit = "";
if (strpos(strtoupper($select), "TOP") === false) {
$isDistinct = strpos(strtoupper($select), "DISTINCT");
$isAll = strpos(strtoupper($select), "ALL");
if ($isDistinct === false && $isAll === false) {
$select = preg_replace("/SELECT/",
"SELECT TOP(" . $end . ")",
strtoupper($select), 1);
}
if ($isDistinct !== false) {
$select = preg_replace("/DISTINCT/",
"DISTINCT TOP(" . $end . ")",
strtoupper($select), 1);
}
if ($isAll !== false) {
$select = preg_replace("/DISTINCT/",
"DISTINCT TOP(" . $end . ")",
strtoupper($select), 1);
}
}
}
if ($provider === "oracle") {
$limit = "";
$rowNumber = "";
if (strpos(strtoupper($where), "ROWNUM") === false) {
$rowNumber = " AND " . $start . " <= ROWNUM AND ROWNUM <= " . $end;
}
$where = empty($where)
? "WHERE " . $start . " <= ROWNUM AND ROWNUM <= " . $end
: $where . $rowNumber;
}
}
/**
* If possible, add a where to get the current label.
*
* @param type $json
* @param type $parsed
* @param type $select
* @param type $where
* @param type $having
* @return boolean
*/
private function addSuggestWhere($json, $parsed, &$select, &$where, &$having)
{
$value = $this->escapeQuote($this->getSuggestValue($json));
switch ($parsed['SELECT'][0]['expr_type']) {
case 'colref':
case 'expression':
if (
is_array($parsed['SELECT'][0]['sub_tree'])
&& $parsed['SELECT'][0]['sub_tree'][0]['expr_type']==='aggregate_function'
) {
return false;
} else {
$where = empty($where)
? "WHERE (" . $parsed['SELECT'][0]['base_expr'] . "='$value')"
: "$where and (" . $parsed['SELECT'][0]['base_expr'] . "='$value')";
}
return true;
}
return false;
}
/**
* Escape a sql string.
*
* @param type $text
* @return type
*/
private function escapeQuote($text)
{
return str_replace("'", "''", $text);
}
}