From a444fc955d0b4a86524c163f2fe1eb237c61ed65 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 23 Feb 2012 14:28:50 +0100 Subject: [PATCH] New: add generic function for module parts --- htdocs/cashdesk/class/Auth.class.php | 2 +- htdocs/core/class/conf.class.php | 39 +++++++++++++++++----------- htdocs/core/lib/security2.lib.php | 4 +-- htdocs/main.inc.php | 2 +- 4 files changed, 28 insertions(+), 19 deletions(-) diff --git a/htdocs/cashdesk/class/Auth.class.php b/htdocs/cashdesk/class/Auth.class.php index e6273273cb6..a6868aa1814 100644 --- a/htdocs/cashdesk/class/Auth.class.php +++ b/htdocs/cashdesk/class/Auth.class.php @@ -102,7 +102,7 @@ class Auth $authmode=explode(',',$dolibarr_main_authentication); // No authentication mode - if (! count($authmode) && empty($conf->login_method_modules)) + if (! count($authmode) && empty($conf->login_modules)) { $langs->load('main'); dol_print_error('',$langs->trans("ErrorConfigParameterNotDefined",'dolibarr_main_authentication')); diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 9f21c61b296..9168aafe590 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -51,26 +51,26 @@ class Conf public $top_menu; public $smart_menu; - public $modules = array(); // List of activated modules + public $modules = array(); // List of activated modules - public $css_modules = array(); - public $tabs_modules = array(); - public $triggers_modules = array(); - public $menus_modules = array(); - public $hooks_modules = array(); - public $login_method_modules = array(); - public $sms_engine_modules = array(); - public $barcode_modules = array(); - public $substitutions_modules = array(); + public $css_modules = array(); + public $tabs_modules = array(); + public $triggers_modules = array(); + public $menus_modules = array(); + public $hooks_modules = array(); + public $login_modules = array(); + public $sms_engine_modules = array(); + public $barcode_modules = array(); + public $substitutions_modules = array(); - var $logbuffer = array(); + var $logbuffer = array(); //! To store properties of multi-company public $multicompany; //! Used to store running instance for multi-company (default 1) - public $entity=1; + public $entity = 1; //! Used to store list of entities to use for each element - public $entities = array(); + public $entities = array(); @@ -176,14 +176,22 @@ class Conf $modulename = strtolower($reg[1]); $this->barcode_modules[$modulename] = '/'.$modulename.'/core/modules/barcode/'; } + // If this is constant for all generic part activated by a module + elseif (preg_match('/^MAIN_MODULE_([A-Z_]+)_([A-Z]+)$/i',$key,$reg)) + { + $modulename = strtolower($reg[1]); + $partname = strtolower($reg[2]); + $varname = $partname.'_modules'; + $this->$varname[$modulename] = '/'.$modulename.'/core/'.$partname.'/'; + } // TODO All of this part could be mutualized into one generic part - + /* // If this is constant for login method activated by a module elseif (preg_match('/^MAIN_MODULE_([A-Z_]+)_LOGIN$/i',$key,$reg)) { $modulename = strtolower($reg[1]); - $this->login_method_modules[$modulename] = '/'.$modulename.'/core/login/'; + $this->login_modules[$modulename] = '/'.$modulename.'/core/login/'; } // If this is constant for a new tab page activated by a module elseif (preg_match('/^MAIN_MODULE_([A-Z_]+)_MENUS$/i',$key,$reg)) @@ -203,6 +211,7 @@ class Conf $modulename = strtolower($reg[1]); $this->substitutions_modules[$modulename] = '/'.$modulename.'/core/substitutions/'; } + */ // If this is a module constant (must be at end) elseif (preg_match('/^MAIN_MODULE_([A-Z_]+)$/i',$key,$reg)) diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index 1fefcae0f05..338efbb5e80 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -61,9 +61,9 @@ function checkLoginPassEntity($usertotest,$passwordtotest,$entitytotest,$authmod $login = ''; // Validation of login/pass/entity with a third party login module method - if (! empty($conf->login_method_modules) && is_array($conf->login_method_modules)) + if (! empty($conf->login_modules) && is_array($conf->login_modules)) { - foreach($conf->login_method_modules as $reldir) + foreach($conf->login_modules as $reldir) { $dir=dol_buildpath($reldir,0); diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index cb6159afc0e..9f8216bf98e 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -320,7 +320,7 @@ if (! defined('NOLOGIN')) $authmode=explode(',',$dolibarr_main_authentication); // No authentication mode - if (! count($authmode) && empty($conf->login_method_modules)) + if (! count($authmode) && empty($conf->login_modules)) { $langs->load('main'); dol_print_error('',$langs->trans("ErrorConfigParameterNotDefined",'dolibarr_main_authentication'));