Skip to content
Snippets Groups Projects
Commit 01bd2014 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Fix: Some fixes and enhancement into modularizing log functions

parent b160b97c
Branches
Tags
No related merge requests found
......@@ -182,15 +182,21 @@ foreach ($syslogModules as $moduleName)
{
$module = new $moduleName;
$moduleactive=$module->isActive();
if ($moduleactive == -1 && empty($conf->global->MAIN_FEATURES_LEVEL)) continue; // Some modules are hidden if not activable and not into debug mode (end user must not see them)
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td width="140"><input '.$bc[$var].' type="checkbox" name="SYSLOG_HANDLERS[]" value="'.$moduleName.'" '.(in_array($moduleName, $activeModules) ? 'checked="checked"' : '').(!$module->isActive() ? 'disabled="disabled"' : '').'> ';
print $module->getName().'</td>';
print '<td width="140">';
print '<input '.$bc[$var].' type="checkbox" name="SYSLOG_HANDLERS[]" value="'.$moduleName.'" '.(in_array($moduleName, $activeModules) ? 'checked="checked"' : '').(!$moduleactive ? 'disabled="disabled"' : '').'> ';
print $module->getName();
print '</td>';
print '<td nowrap="nowrap">';
if ($module->configure())
$setuparray=$module->configure();
if ($setuparray)
{
foreach ($module->configure() as $option)
foreach ($setuparray as $option)
{
if (defined($option['constant'])) $value = constant($option['constant']);
else $value = (isset($option['default']) ? $option['default'] : '');
......
......@@ -2,6 +2,9 @@
require_once DOL_DOCUMENT_ROOT.'/core/modules/syslog/logHandlerInterface.php';
/**
* Parent class for log handlers
*/
class LogHandler
{
const STABLE = 'stable';
......@@ -10,6 +13,7 @@ class LogHandler
/**
* Content of the info tooltip.
*
* @return false|string
*/
public function getInfo()
......@@ -19,6 +23,7 @@ class LogHandler
/**
* Version of the module
*
* @return string
*/
public function getVersion()
......@@ -28,6 +33,7 @@ class LogHandler
/**
* ¿Is the module active?
*
* @return boolean
*/
public function isActive()
......@@ -37,6 +43,7 @@ class LogHandler
/**
* Configuration variables of the module
*
* @return array
*/
public function configure()
......@@ -48,6 +55,7 @@ class LogHandler
* Function that checks if the configuration is valid.
* It will be called after setting the configuration.
* The function returns an array with error messages
*
* @return array
*/
public function checkConfiguration()
......
......@@ -27,7 +27,7 @@ class mod_syslog_chromephp extends LogHandler implements LogHandlerInterface
{
global $langs;
return $langs->trans('ChromePHPIncludePathWarning');
return $this->isActive()?'':$langs->trans('ClassNotFoundIntoPathWarning','ChromePhp.class.php');
}
/**
......@@ -35,22 +35,24 @@ class mod_syslog_chromephp extends LogHandler implements LogHandlerInterface
*/
public function isActive()
{
global $conf;
try
{
set_include_path(SYSLOG_CHROMEPHP_INCLUDEPATH);
if (empty($conf->global->SYSLOG_CHROMEPHP_INCLUDEPATH)) $conf->global->SYSLOG_CHROMEPHP_INCLUDEPATH='/usr/share/php';
set_include_path($conf->global->SYSLOG_CHROMEPHP_INCLUDEPATH);
$res = @include_once 'ChromePhp.class.php';
restore_include_path();
if ($res)
{
return true;
return 1;
}
}
catch(Exception $e)
{
print '<!-- FirePHP no available into PHP -->'."\n";
print '<!-- ChromePHP not available into PHP -->'."\n";
}
return false;
return -1;
}
/**
......@@ -82,9 +84,9 @@ class mod_syslog_chromephp extends LogHandler implements LogHandlerInterface
$oldinclude = get_include_path();
set_include_path(SYSLOG_CHROMEPHP_INCLUDEPATH);
if (!file_exists('ChromePhp.php'))
if (!file_exists('ChromePhp.class.php'))
{
$errors[] = $langs->trans("ErrorFailedToOpenFile", 'ChromePhp.php');
$errors[] = $langs->trans("ErrorFailedToOpenFile", 'ChromePhp.class.php');
}
set_include_path($oldinclude);
......@@ -106,7 +108,7 @@ class mod_syslog_chromephp extends LogHandler implements LogHandlerInterface
// database or config file because we must be able to log data before database or config file read.
$oldinclude=get_include_path();
set_include_path(SYSLOG_CHROMEPHP_INCLUDEPATH);
include_once 'ChromePhp.php';
include_once 'ChromePhp.class.php';
set_include_path($oldinclude);
ob_start(); // To be sure headers are not flushed until all page is completely processed
if ($level == LOG_ERR) ChromePhp::error($message);
......
......@@ -37,7 +37,7 @@ class mod_syslog_file extends LogHandler implements LogHandlerInterface
*/
public function isActive()
{
return true;
return 1;
}
/**
......
......@@ -27,7 +27,7 @@ class mod_syslog_firephp extends LogHandler implements LogHandlerInterface
{
global $langs;
return $langs->trans('FirePHPIncludePathWarning');
return $langs->trans('ClassNotFoundIntoPathWarning','FirePHPCore/FirePHP.class.php');
}
/**
......@@ -42,7 +42,7 @@ class mod_syslog_firephp extends LogHandler implements LogHandlerInterface
restore_include_path();
if ($res)
{
return true;
return 1;
}
}
catch(Exception $e)
......@@ -50,7 +50,7 @@ class mod_syslog_firephp extends LogHandler implements LogHandlerInterface
print '<!-- FirePHP no available into PHP -->'."\n";
}
return false;
return -1;
}
// /**
......
......@@ -38,10 +38,10 @@ class mod_syslog_syslog extends LogHandler implements LogHandlerInterface
// This function does not exists on some ISP (Ex: Free in France)
if (!function_exists('openlog'))
{
return false;
return 0;
}
return true;
return 1;
}
/**
......
......@@ -911,6 +911,7 @@ TranslationSetup=Configuration de la traduction
TranslationDesc=Choice of language visible on screen can be modified:<br>* Globally from menu <strong>Home - Setup - Display</strong><br>* For user only from tab <strong>User display</strong> of user card (click on login on top of screen).
TotalNumberOfActivatedModules=Total number of activated feature modules: <b>%s</b>
YouMustEnableOneModule=You must at least enable 1 module
ClassNotFoundIntoPathWarning=Class %s not found into PHP path
##### Module password generation
PasswordGenerationStandard=Return a password generated according to internal Dolibarr algorithm: 8 characters containing shared numbers and characters in lowercase.
......
......@@ -918,6 +918,8 @@ PathDirectory= Répertoire
SendmailOptionMayHurtBuggedMTA=La fonction d'envoi de mails par la méthode "PHP mail directe" génère une requete mail qui peut être mal interprété par certains serveurs buggués de réception de mail. Cela se traduit par des mails non lisibles chez les personnes hebergés par ces plateformes bugguées. C'est le cas des clients de certains fournisseurs d'accès internet (Ex: Orange). Ce n'est pas un problème ni dans Dolibarr ni dans PHP mais sur le serveur de réception. Vous pouvez toutefois ajouter l'option MAIN_FIX_FOR_BUGGED_MTA à 1 dans configuration - divers pour modifier Dolibarr afin de compenser le bug. Toutefois ce sont les serveurs respectueux du standard d'envoi de mail qui pourront avoir des problèmes. L'autre solution (recommandée) est d'utiliser la méthode d'envoi SMTP socket library qui n'a aucun de ces inconvénients.
TranslationSetup=Translation setup
TranslationDesc=Le choix de la langue affichée à l'écran se modifie:<br>* Soit de manière globale depuis le menu <strong>Accueil - Configuration - Affichage</strong><br>* Soit de manière spécifique à l'utilisateur depuis l'onglet <strong>Interface utilisateur</strong> de sa fiche utilisateur (cliquer sur le login en haut de l'écran).
ClassNotFoundIntoPathWarning=La class %s n'a pas été trouvée dans le path PHP
##### Module password generation= undefined
PasswordGenerationStandard= Renvoie un mot de passe généré selon algorithme interne Dolibarr: 8 caractères, chiffres et caractères en minuscules mélangés.
PasswordGenerationNone= Ne propose pas de mots de passe générés. Le mot de passe est à saisir manuellement.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment