2
0
forked from Wavyzz/dolibarr

Fix compatibility with the removal of "constant".

This commit is contained in:
Laurent Destailleur
2017-04-29 18:30:36 +02:00
parent ff0f40ab37
commit a8c775dcbd
12 changed files with 51 additions and 32 deletions

View File

@@ -40,7 +40,7 @@ $action = GETPOST("action");
$syslogModules = array();
$activeModules = array();
if (defined('SYSLOG_HANDLERS')) $activeModules = json_decode(constant('SYSLOG_HANDLERS'));
if (! empty($conf->global->SYSLOG_HANDLERS)) $activeModules = json_decode($conf->global->SYSLOG_HANDLERS);
$dirsyslogs = array_merge(array('/core/modules/syslog/'), $conf->modules_parts['syslog']);
foreach ($dirsyslogs as $reldir) {
@@ -88,7 +88,8 @@ if ($action == 'set')
$newActiveModules = array();
$selectedModules = (isset($_POST['SYSLOG_HANDLERS']) ? $_POST['SYSLOG_HANDLERS'] : array());
//var_dump($selectedModules);
// Save options of handler
foreach ($syslogModules as $syslogHandler)
{
if (in_array($syslogHandler, $syslogModules))
@@ -101,7 +102,7 @@ if ($action == 'set')
if (isset($_POST[$option['constant']]))
{
$_POST[$option['constant']] = trim($_POST[$option['constant']]);
dolibarr_del_const($db, $option['constant'], 0);
dolibarr_del_const($db, $option['constant'], -1);
dolibarr_set_const($db, $option['constant'], $_POST[$option['constant']], 'chaine',0, '', 0);
}
}
@@ -109,7 +110,9 @@ if ($action == 'set')
}
$activeModules = $newActiveModules;
dolibarr_set_const($db, 'SYSLOG_HANDLERS', json_encode($activeModules), 'chaine',0,'',0);
dolibarr_del_const($db, 'SYSLOG_HANDLERS', -1); // To be sure ther is not a setup into another entity
dolibarr_set_const($db, 'SYSLOG_HANDLERS', json_encode($activeModules), 'chaine',0,'',0);
// Check configuration
foreach ($activeModules as $modulename) {
@@ -217,8 +220,12 @@ foreach ($syslogModules as $moduleName)
{
foreach ($setuparray as $option)
{
if (isset($_POST[$option['constant']])) $value=$_POST[$option['constant']];
else if (defined($option['constant'])) $value = constant($option['constant']);
$tmpoption=$option['constant'];
if (! empty($tmpoption))
{
if (isset($_POST[$tmpoption])) $value=$_POST[$tmpoption];
else if (! empty($conf->global->$tmpoption)) $value = $conf->global->$tmpoption;
}
else $value = (isset($option['default']) ? $option['default'] : '');
print $option['name'].': <input type="text" class="flat" name="'.$option['constant'].'" value="'.$value.'"'.(isset($option['attr']) ? ' '.$option['attr'] : '').'>';