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,6 +110,8 @@ if ($action == 'set')
}
$activeModules = $newActiveModules;
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
@@ -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'] : '').'>';

View File

@@ -80,8 +80,11 @@ class box_external_rss extends ModeleBoxes
// documents/externalrss is created by module activation
// documents/externalrss/tmp is created by rssparser
$keyforparamurl="EXTERNAL_RSS_URLRSS_".$site;
$keyforparamtitle="EXTERNAL_RSS_TITLE_".$site;
// Get RSS feed
$url=@constant("EXTERNAL_RSS_URLRSS_".$site);
$url=$conf->global->$keyforparamurl;
$rssparser=new RssParser($this->db);
$result = $rssparser->parser($url, $this->max, $cachedelay, $conf->externalrss->dir_temp);
@@ -90,7 +93,7 @@ class box_external_rss extends ModeleBoxes
$description=$rssparser->getDescription();
$link=$rssparser->getLink();
$title=$langs->trans("BoxTitleLastRssInfos",$max, @constant("EXTERNAL_RSS_TITLE_". $site));
$title=$langs->trans("BoxTitleLastRssInfos", $max, $conf->global->$keyforparamtitle);
if ($result < 0 || ! empty($rssparser->error))
{
// Show warning

View File

@@ -210,7 +210,7 @@ class Conf
$file=dol_sanitizeFileName($file);
include_once DOL_DOCUMENT_ROOT . "/".$file."/".$file."_consts.php";
foreach ($file2bddconsts as $key=>$value) {
$this->global->$key=constant($value);
$this->global->$key=$value;
}
}
}

View File

@@ -1495,10 +1495,10 @@ function dol_uncompress($inputfile,$outputdir)
{
global $conf, $langs;
if (defined('ODTPHP_PATHTOPCLZIP'))
if (! empty($conf->global->ODTPHP_PATHTOPCLZIP))
{
dol_syslog("Constant ODTPHP_PATHTOPCLZIP for pclzip library is set to ".constant('ODTPHP_PATHTOPCLZIP').", so we use Pclzip to unzip into ".$outputdir);
include_once ODTPHP_PATHTOPCLZIP.'/pclzip.lib.php';
dol_syslog("Constant ODTPHP_PATHTOPCLZIP for pclzip library is set to ".$conf->global->ODTPHP_PATHTOPCLZIP.", so we use Pclzip to unzip into ".$outputdir);
include_once $conf->global->ODTPHP_PATHTOPCLZIP.'/pclzip.lib.php';
$archive = new PclZip($inputfile);
$result=$archive->extract(PCLZIP_OPT_PATH, $outputdir);
//var_dump($result);

View File

@@ -3570,14 +3570,14 @@ function vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0)
$morelabel=' ('.$reg[1].')';
$rate=preg_replace('/\s*'.preg_quote($morelabel,'/').'/','',$rate);
}
if (preg_match('/\*/',$rate) || preg_match('/'.constant('MAIN_LABEL_MENTION_NPR').'/i',$rate))
if (preg_match('/\*/',$rate))
{
$rate=str_replace('*','',$rate);
$info_bits |= 1;
}
$ret=price($rate,0,'',0,0).($addpercent?'%':'');
if ($info_bits & 1) $ret.=' '.($usestarfornpr?'*':constant('MAIN_LABEL_MENTION_NPR'));
if ($info_bits & 1) $ret.=' *';
$ret.=$morelabel;
return $ret;
}

View File

@@ -150,9 +150,9 @@ function dol_loginfunction($langs,$conf,$mysoc)
// Title
$appli=constant('DOL_APPLICATION_TITLE');
$title=$appli.' '.DOL_VERSION;
$title=$appli.' '.constant('DOL_VERSION');
if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $title=$conf->global->MAIN_APPLICATION_TITLE;
$titletruedolibarrversion=DOL_VERSION; // $title used by login template after the @ to inform of true Dolibarr version
$titletruedolibarrversion=constant('DOL_VERSION'); // $title used by login template after the @ to inform of true Dolibarr version
// Note: $conf->css looks like '/theme/eldy/style.css.php'
$conf->css = "/theme/".(GETPOST('theme')?GETPOST('theme','alpha'):$conf->theme)."/style.css.php";

View File

@@ -48,7 +48,7 @@ class mod_syslog_chromephp extends LogHandler implements LogHandlerInterface
{
global $langs;
return $this->isActive()?'':$langs->trans('ClassNotFoundIntoPathWarning','ChromePhp.class.php');
return ($this->isActive() == 1)?'':$langs->trans('ClassNotFoundIntoPathWarning','ChromePhp.class.php');
}
/**
@@ -73,7 +73,7 @@ class mod_syslog_chromephp extends LogHandler implements LogHandlerInterface
if ($res)
{
return 1;
return empty($conf->global->SYSLOG_DISABLE_LOGHANDLER_CHROMEPHP)?1:0; // Set SYSLOG_DISABLE_LOGHANDLER_CHROMEPHP to 1 to disable this loghandler
}
else
{

View File

@@ -51,7 +51,8 @@ class mod_syslog_file extends LogHandler implements LogHandlerInterface
*/
public function isActive()
{
return 1;
global $conf;
return empty($conf->global->SYSLOG_DISABLE_LOGHANDLER_FILE)?1:0; // Set SYSLOG_DISABLE_LOGHANDLER_FILE to 1 to disable this loghandler
}
/**

View File

@@ -56,7 +56,7 @@ class mod_syslog_firephp extends LogHandler implements LogHandlerInterface
{
global $langs;
return $this->isActive()?'':$langs->trans('ClassNotFoundIntoPathWarning', self::$firephp_class_path);
return ($this->isActive() == 1)?'':$langs->trans('ClassNotFoundIntoPathWarning', self::$firephp_class_path);
}
/**
@@ -76,7 +76,7 @@ class mod_syslog_firephp extends LogHandler implements LogHandlerInterface
$res = @include_once self::$firephp_class_path;
restore_include_path();
if ($res) {
return 1;
return empty($conf->global->SYSLOG_DISABLE_LOGHANDLER_FIREPHP)?1:0; // Set SYSLOG_DISABLE_LOGHANDLER_FIREPHP to 1 to disable this loghandler
} else {
return 0;
}

View File

@@ -48,10 +48,12 @@ class mod_syslog_syslog extends LogHandler implements LogHandlerInterface
*/
public function isActive()
{
global $conf;
// This function does not exists on some ISP (Ex: Free in France)
if (!function_exists('openlog')) return 0;
return 1;
return empty($conf->global->SYSLOG_DISABLE_LOGHANDLER_SYSLOG)?1:0; // Set SYSLOG_DISABLE_LOGHANDLER_SYSLOG to 1 to disable this loghandler
}
/**
@@ -111,11 +113,11 @@ class mod_syslog_syslog extends LogHandler implements LogHandlerInterface
if (! empty($conf->global->MAIN_SYSLOG_DISABLE_SYSLOG)) return; // Global option to disable output of this handler
if (! empty($conf->global->SYSLOG_FACILITY))
if (! empty($conf->global->SYSLOG_FACILITY)) // Example LOG_USER
{
$facility = constant($conf->global->SYSLOG_FACILITY);
}
else $facility = LOG_USER;
else $facility = constant('LOG_USER');
// (int) is required to avoid error parameter 3 expected to be long
openlog('dolibarr', LOG_PID | LOG_PERROR, (int) $facility);

View File

@@ -247,40 +247,46 @@ else
print '<td></td>';
print "</tr>";
$keyforname="FTP_NAME_" . $idrss;
$keyforserver="FTP_SERVER_" . $idrss;
$keyforport="FTP_PORT_" . $idrss;
$keyforuser="FTP_USER_" . $idrss;
$keyforpassword="FTP_PASSWORD_" . $idrss;
$keyforpassive="FTP_PASSIVE_" . $idrss;
print '<tr class="oddeven">';
print "<td>".$langs->trans("Name")."</td>";
print "<td><input type=\"text\" class=\"flat\" name=\"FTP_NAME_" . $idrss . "\" value=\"" . @constant("FTP_NAME_" . $idrss) . "\" size=\"64\"></td>";
print "<td><input type=\"text\" class=\"flat\" name=\"FTP_NAME_" . $idrss . "\" value=\"" . $conf->global->$keyforname . "\" size=\"64\"></td>";
print "</tr>";
print '<tr class="oddeven">';
print "<td>".$langs->trans("Server")."</td>";
print "<td><input type=\"text\" class=\"flat\" name=\"FTP_SERVER_" . $idrss . "\" value=\"" . @constant("FTP_SERVER_" . $idrss) . "\" size=\"64\"></td>";
print "<td><input type=\"text\" class=\"flat\" name=\"FTP_SERVER_" . $idrss . "\" value=\"" . $conf->global->$keyforserver . "\" size=\"64\"></td>";
print "</tr>";
print '<tr class="oddeven">';
print "<td width=\"100\">".$langs->trans("Port")."</td>";
print "<td><input type=\"text\" class=\"flat\" name=\"FTP_PORT_" . $idrss . "\" value=\"" . @constant("FTP_PORT_" . $idrss) . "\" size=\"64\"></td>";
print "<td><input type=\"text\" class=\"flat\" name=\"FTP_PORT_" . $idrss . "\" value=\"" . $conf->global->$keyforport . "\" size=\"64\"></td>";
print "</tr>";
print '<tr class="oddeven">';
print "<td width=\"100\">".$langs->trans("User")."</td>";
print "<td><input type=\"text\" class=\"flat\" name=\"FTP_USER_" . $idrss . "\" value=\"" . @constant("FTP_USER_" . $idrss) . "\" size=\"24\"></td>";
print "<td><input type=\"text\" class=\"flat\" name=\"FTP_USER_" . $idrss . "\" value=\"" . $conf->global->$keyforuser . "\" size=\"24\"></td>";
print "</tr>";
print '<tr class="oddeven">';
print "<td width=\"100\">".$langs->trans("Password")."</td>";
print "<td><input type=\"password\" class=\"flat\" name=\"FTP_PASSWORD_" . $idrss . "\" value=\"" . @constant("FTP_PASSWORD_" . $idrss) . "\" size=\"24\"></td>";
print "<td><input type=\"password\" class=\"flat\" name=\"FTP_PASSWORD_" . $idrss . "\" value=\"" . $conf->global->$keyforpassword . "\" size=\"24\"></td>";
print "</tr>";
print '<tr class="oddeven">';
print "<td width=\"100\">".$langs->trans("FTPPassiveMode")."</td>";
print '<td>'.$form->selectyesno('FTP_PASSIVE_'.$idrss, @constant("FTP_PASSIVE_" . $idrss), 1).'</td>';
print '<td>'.$form->selectyesno('FTP_PASSIVE_'.$idrss, $conf->global->$keyforpassive, 1).'</td>';
print "</tr>";
print "<tr>";

View File

@@ -1865,7 +1865,7 @@ if (! function_exists("llxFooter"))
dol_htmloutput_events();
// Core error message
if (defined("MAIN_CORE_ERROR") && constant("MAIN_CORE_ERROR") == 1)
if (! empty($conf->global->MAIN_CORE_ERROR))
{
// Ajax version
if ($conf->use_javascript_ajax)