Merged in bugfix/HOR-1697 (pull request #5650)

HOR-1697

Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
dheeyi william
2017-05-05 16:22:05 +00:00
committed by Julio Cesar Laura Avendaño
4 changed files with 118 additions and 74 deletions

View File

@@ -2113,6 +2113,24 @@ msgstr "This case does not exist"
msgid "Application ID or Delegation Index is missing!. The System can not open the case."
msgstr "Application ID or Delegation Index is missing!. The System can not open the case."
# TRANSLATION
# LABEL/ID_MEMORY_LIMIT_VALIDATE
#: LABEL/ID_MEMORY_LIMIT_VALIDATE
msgid "Memory Limit value has to be either a positive integer or -1."
msgstr "Memory Limit value has to be either a positive integer or -1."
# TRANSLATION
# LABEL/ID_LIFETIME_VALIDATE
#: LABEL/ID_LIFETIME_VALIDATE
msgid "Max Lifetime value has to be a positive integer."
msgstr "Max Lifetime value has to be a positive integer."
# TRANSLATION
# LABEL/ID_DEFAULT_EXPIRATION_YEAR_VALIDATE
#: LABEL/ID_DEFAULT_EXPIRATION_YEAR_VALIDATE
msgid "Default Expiration Year value has to be a positive integer."
msgstr "Default Expiration Year value has to be a positive integer."
# TRANSLATION
# LABEL/ID_PLEASE_SELECT_UPGRADE_FILE
#: LABEL/ID_PLEASE_SELECT_UPGRADE_FILE

View File

@@ -27,28 +27,18 @@ class adminProxy extends HttpProxyController
{
const hashunlink = 'unlink';
/**
* Save configurations of systemConf
* @param $httpData
* @throws Exception
*/
public function saveSystemConf($httpData)
{
G::loadClass('system');
$envFile = PATH_CONFIG . 'env.ini';
$updateRedirector = false;
$restart = false;
if (!file_exists($envFile) ) {
if (!is_writable(PATH_CONFIG)) {
throw new Exception('The enviroment config directory is not writable. <br/>Please give write permission to directory: /workflow/engine/config');
}
$content = ";\r\n";
$content .= "; ProcessMaker System Bootstrap Configuration\r\n";
$content .= ";\r\n";
file_put_contents($envFile, $content);
//@chmod($envFile, 0777);
} else {
if (!is_writable($envFile)) {
throw new Exception('The enviroment ini file file is not writable. <br/>Please give write permission to file: /workflow/engine/config/env.ini');
}
}
self::validateDataSystemConf($httpData, $envFile);
$sysConf = System::getSystemConfiguration($envFile);
$updatedConf = array();
@@ -1536,5 +1526,46 @@ class adminProxy extends HttpProxyController
G::streamFile($support, true);
G::rm_dir($support);
}
}
/**
* Validate data before saving
* @param $httpData
* @param $envFile
* @throws Exception
*/
public static function validateDataSystemConf($httpData, $envFile)
{
if (!((is_numeric($httpData->memory_limit)) && ((int)$httpData->memory_limit == $httpData->memory_limit) &&
((int)$httpData->memory_limit >= -1))
) {
throw new Exception(G::LoadTranslation('ID_MEMORY_LIMIT_VALIDATE'));
}
if (!((is_numeric($httpData->max_life_time)) && ((int)$httpData->max_life_time == $httpData->max_life_time) &&
((int)$httpData->max_life_time > 0))
) {
throw new Exception(G::LoadTranslation('ID_LIFETIME_VALIDATE'));
}
if (!((is_numeric($httpData->expiration_year)) && ((int)$httpData->expiration_year == $httpData->expiration_year) &&
((int)$httpData->expiration_year > 0))
) {
throw new Exception(G::LoadTranslation('ID_DEFAULT_EXPIRATION_YEAR_VALIDATE'));
}
if (!file_exists($envFile)) {
if (!is_writable(PATH_CONFIG)) {
throw new Exception('The enviroment config directory is not writable. <br/>Please give write permission to directory: /workflow/engine/config');
}
$content = ";\r\n";
$content .= "; ProcessMaker System Bootstrap Configuration\r\n";
$content .= ";\r\n";
file_put_contents($envFile, $content);
//@chmod($envFile, 0777);
} else {
if (!is_writable($envFile)) {
throw new Exception('The enviroment ini file is not writable. <br/>Please give write permission to file: /workflow/engine/config/env.ini');
}
}
}
}

View File

@@ -1793,6 +1793,9 @@ INSERT INTO TRANSLATION (TRN_CATEGORY,TRN_ID,TRN_LANG,TRN_VALUE,TRN_UPDATE_DATE
( 'LABEL','ID_IN','en','in','2014-01-15') ,
( 'LABEL','ID_CASE_DOES_NOT_EXISTS','en','This case does not exist','2014-01-15') ,
( 'LABEL','ID_APPLICATION_OR_INDEX_MISSING','en','Application ID or Delegation Index is missing!. The System can not open the case.','2017-03-30') ,
( 'LABEL','ID_MEMORY_LIMIT_VALIDATE','en','Memory Limit value has to be either a positive integer or -1','2017-04-05') ,
( 'LABEL','ID_LIFETIME_VALIDATE','en','Max Lifetime value has to be a positive integer','2017-04-05') ,
( 'LABEL','ID_DEFAULT_EXPIRATION_YEAR_VALIDATE','en','Default Expiration Year value has to be a positive integer','2017-04-05') ,
( 'LABEL','ID_PLEASE_SELECT_UPGRADE_FILE','en','Please select the upgrade file','2014-01-15') ,
( 'LABEL','ID_PLEASE_SELECT_MAX_X_FIELDS','en','Please select 80 fields at most','2014-01-15') ,
( 'LABEL','ID_UPGRADE_READY','en','System upgraded from revision','2014-01-15') ,

View File

@@ -85,32 +85,6 @@ Ext.onReady(function(){
cmbTimeZone.setValue(sysConf.time_zone);
txtExpirationYear = new Ext.form.TextField({
xtype: 'numberfield',
id : 'expiration_year',
name : 'expiration_year',
fieldLabel: _('ID_DEFAULT_EXPIRATION_YEAR'),
allowBlank: false,
allowNegative: false,
value: 1,
maxlength: 15,
minValue: 1,
validator: function(value){
if(value > 0) {
return true;
} else {
PMExt.error( _('ID_ERROR'), _('ID_INVALID_VALUE_EXPECTING_POSITIVE_INTEGER', _('ID_DEFAULT_EXPIRATION_YEAR')));
return false;
}
},
listeners:{
change: function(){
changeSettings();
}
}
});
txtExpirationYear.setValue(sysConf.expiration_year);
saveButton = new Ext.Action({
text : _('ID_SAVE_SETTINGS'),
disabled : true,
@@ -118,38 +92,56 @@ Ext.onReady(function(){
});
xfieldsUp = new Ext.form.FieldSet({
title: _('ID_SYSTEM_SETTINGS'),
items : [
cmbTimeZone,
{
xtype: 'numberfield',
id : 'memory_limit',
name : 'memory_limit',
fieldLabel: _('ID_MEMORY_LIMIT'),
allowBlank: false,
autoCreate: {tag: "input", type: "text", autocomplete: "off", maxlength: 15 },
value: sysConf.memory_limit,
listeners:{
change: function(){
changeSettings();
title: _('ID_SYSTEM_SETTINGS'),
items: [
cmbTimeZone,
{
xtype: 'numberfield',
id: 'memory_limit',
name: 'memory_limit',
fieldLabel: _('ID_MEMORY_LIMIT'),
allowBlank: false,
allowDecimals: false,
minValue: -1,
autoCreate: {tag: "input", type: "text", autocomplete: "off", maxlength: 15},
value: sysConf.memory_limit,
listeners: {
change: function () {
changeSettings();
}
}
}, {
xtype: 'numberfield',
id: 'max_life_time',
name: 'max_life_time',
fieldLabel: _('ID_MAX_LIFETIME'),
allowNegative: false,
allowDecimals: false,
autoCreate: {tag: "input", type: "text", autocomplete: "off", maxlength: 15},
value: sysConf.session_gc_maxlifetime,
listeners: {
change: function () {
changeSettings();
}
}
}, {
xtype: 'numberfield',
id: 'expiration_year',
name: 'expiration_year',
fieldLabel: _('ID_DEFAULT_EXPIRATION_YEAR'),
allowBlank: false,
allowNegative: false,
allowDecimals: false,
value: sysConf.expiration_year,
maxlength: 15,
minValue: 1,
listeners: {
change: function () {
changeSettings();
}
}
}
}
}, {
xtype: 'numberfield',
id : 'max_life_time',
name : 'max_life_time',
fieldLabel: _('ID_MAX_LIFETIME'),
// allowBlank: false,
autoCreate: {tag: "input", type: "text", autocomplete: "off", maxlength: 15 },
value: sysConf.session_gc_maxlifetime,
listeners:{
change: function(){
changeSettings();
}
}
}
,txtExpirationYear
]
]
});
xfieldsBelow = new Ext.form.FieldSet({