Fix: Some fixes and enhancement into modularizing log functions

This commit is contained in:
Laurent Destailleur 2012-10-17 14:46:20 +02:00
parent b160b97cbe
commit 01bd20147e
8 changed files with 49 additions and 30 deletions

View File

@ -182,15 +182,21 @@ foreach ($syslogModules as $moduleName)
{ {
$module = new $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; $var=!$var;
print '<tr '.$bc[$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 '<td width="140">';
print $module->getName().'</td>'; 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">'; 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']); if (defined($option['constant'])) $value = constant($option['constant']);
else $value = (isset($option['default']) ? $option['default'] : ''); else $value = (isset($option['default']) ? $option['default'] : '');

View File

@ -2,6 +2,9 @@
require_once DOL_DOCUMENT_ROOT.'/core/modules/syslog/logHandlerInterface.php'; require_once DOL_DOCUMENT_ROOT.'/core/modules/syslog/logHandlerInterface.php';
/**
* Parent class for log handlers
*/
class LogHandler class LogHandler
{ {
const STABLE = 'stable'; const STABLE = 'stable';
@ -10,6 +13,7 @@ class LogHandler
/** /**
* Content of the info tooltip. * Content of the info tooltip.
*
* @return false|string * @return false|string
*/ */
public function getInfo() public function getInfo()
@ -19,6 +23,7 @@ class LogHandler
/** /**
* Version of the module * Version of the module
*
* @return string * @return string
*/ */
public function getVersion() public function getVersion()
@ -28,6 +33,7 @@ class LogHandler
/** /**
* ¿Is the module active? * ¿Is the module active?
*
* @return boolean * @return boolean
*/ */
public function isActive() public function isActive()
@ -37,6 +43,7 @@ class LogHandler
/** /**
* Configuration variables of the module * Configuration variables of the module
*
* @return array * @return array
*/ */
public function configure() public function configure()
@ -48,6 +55,7 @@ class LogHandler
* Function that checks if the configuration is valid. * Function that checks if the configuration is valid.
* It will be called after setting the configuration. * It will be called after setting the configuration.
* The function returns an array with error messages * The function returns an array with error messages
*
* @return array * @return array
*/ */
public function checkConfiguration() public function checkConfiguration()

View File

@ -27,7 +27,7 @@ class mod_syslog_chromephp extends LogHandler implements LogHandlerInterface
{ {
global $langs; 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() public function isActive()
{ {
global $conf;
try 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'; $res = @include_once 'ChromePhp.class.php';
restore_include_path(); restore_include_path();
if ($res) if ($res)
{ {
return true; return 1;
} }
} }
catch(Exception $e) 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(); $oldinclude = get_include_path();
set_include_path(SYSLOG_CHROMEPHP_INCLUDEPATH); 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); 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. // database or config file because we must be able to log data before database or config file read.
$oldinclude=get_include_path(); $oldinclude=get_include_path();
set_include_path(SYSLOG_CHROMEPHP_INCLUDEPATH); set_include_path(SYSLOG_CHROMEPHP_INCLUDEPATH);
include_once 'ChromePhp.php'; include_once 'ChromePhp.class.php';
set_include_path($oldinclude); set_include_path($oldinclude);
ob_start(); // To be sure headers are not flushed until all page is completely processed ob_start(); // To be sure headers are not flushed until all page is completely processed
if ($level == LOG_ERR) ChromePhp::error($message); if ($level == LOG_ERR) ChromePhp::error($message);

View File

@ -37,7 +37,7 @@ class mod_syslog_file extends LogHandler implements LogHandlerInterface
*/ */
public function isActive() public function isActive()
{ {
return true; return 1;
} }
/** /**

View File

@ -27,7 +27,7 @@ class mod_syslog_firephp extends LogHandler implements LogHandlerInterface
{ {
global $langs; 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(); restore_include_path();
if ($res) if ($res)
{ {
return true; return 1;
} }
} }
catch(Exception $e) catch(Exception $e)
@ -50,7 +50,7 @@ class mod_syslog_firephp extends LogHandler implements LogHandlerInterface
print '<!-- FirePHP no available into PHP -->'."\n"; print '<!-- FirePHP no available into PHP -->'."\n";
} }
return false; return -1;
} }
// /** // /**

View File

@ -38,10 +38,10 @@ class mod_syslog_syslog extends LogHandler implements LogHandlerInterface
// This function does not exists on some ISP (Ex: Free in France) // This function does not exists on some ISP (Ex: Free in France)
if (!function_exists('openlog')) if (!function_exists('openlog'))
{ {
return false; return 0;
} }
return true; return 1;
} }
/** /**

View File

@ -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). 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> TotalNumberOfActivatedModules=Total number of activated feature modules: <b>%s</b>
YouMustEnableOneModule=You must at least enable 1 module YouMustEnableOneModule=You must at least enable 1 module
ClassNotFoundIntoPathWarning=Class %s not found into PHP path
##### Module password generation ##### Module password generation
PasswordGenerationStandard=Return a password generated according to internal Dolibarr algorithm: 8 characters containing shared numbers and characters in lowercase. PasswordGenerationStandard=Return a password generated according to internal Dolibarr algorithm: 8 characters containing shared numbers and characters in lowercase.

View File

@ -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. 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 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). 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 ##### 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. 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. PasswordGenerationNone= Ne propose pas de mots de passe générés. Le mot de passe est à saisir manuellement.