New: Now all features can be provided by a module with all files inside
the directory of module.
This commit is contained in:
parent
e4cf111ac2
commit
2647cb72ac
@ -106,25 +106,32 @@ $barcodelist=array();
|
||||
clearstatcache();
|
||||
|
||||
|
||||
foreach ($conf->file->dol_document_root as $dirroot)
|
||||
{
|
||||
$dir = $dirroot . "/core/modules/barcode/";
|
||||
// Check if there is external substitution to do asked by plugins
|
||||
$dirbarcode=array_merge(array("/core/modules/barcode/"),$conf->barcode_modules);
|
||||
|
||||
$handle=@opendir($dir);
|
||||
foreach($dirbarcode as $reldir)
|
||||
{
|
||||
$dir=dol_buildpath($reldir,0);
|
||||
$newdir=dol_osencode($dir);
|
||||
|
||||
// Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php)
|
||||
if (! is_dir($newdir)) continue;
|
||||
|
||||
$handle=@opendir($newdir);
|
||||
if (is_resource($handle))
|
||||
{
|
||||
while (($file = readdir($handle))!==false)
|
||||
{
|
||||
if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
|
||||
{
|
||||
if (is_readable($dir.$file))
|
||||
if (is_readable($newdir.$file))
|
||||
{
|
||||
if (preg_match('/(.*)\.modules\.php$/i',$file,$reg))
|
||||
{
|
||||
$filebis=$reg[1];
|
||||
|
||||
// Chargement de la classe de codage
|
||||
require_once($dir.$file);
|
||||
require_once($newdir.$file);
|
||||
$classname = "mod".ucfirst($filebis);
|
||||
$module = new $classname($db);
|
||||
|
||||
@ -190,12 +197,16 @@ if ($resql)
|
||||
if ($obj->coder && $obj->coder != -1)
|
||||
{
|
||||
$result=0;
|
||||
// Chargement de la classe de codage
|
||||
foreach ($conf->file->dol_document_root as $dirroot)
|
||||
|
||||
foreach($dirbarcode as $reldir)
|
||||
{
|
||||
$dir=$dirroot . "/core/modules/barcode/";
|
||||
$result=@include_once($dir.$obj->coder.".modules.php");
|
||||
//print $dir.$obj->coder.".modules.php - ".$result;
|
||||
$dir=dol_buildpath($reldir,0);
|
||||
$newdir=dol_osencode($dir);
|
||||
|
||||
// Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php)
|
||||
if (! is_dir($newdir)) continue;
|
||||
|
||||
$result=@include_once($newdir.$obj->coder.".modules.php");
|
||||
if ($result) break;
|
||||
}
|
||||
if ($result)
|
||||
|
||||
@ -43,8 +43,8 @@ $dirstandard = array("/core/menus/standard");
|
||||
$dirsmartphone = array("/core/menus/smartphone");
|
||||
foreach($conf->menus_modules as $dir)
|
||||
{
|
||||
$dirstandard[]=$dir.'/standard';
|
||||
$dirsmartphone[]=$dir.'/standard';
|
||||
$dirstandard[]=$dir.'standard';
|
||||
$dirsmartphone[]=$dir.'standard';
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -36,8 +36,8 @@ $dirstandard = array("/core/menus/standard");
|
||||
$dirsmartphone = array("/core/menus/smartphone");
|
||||
foreach($conf->menus_modules as $dir)
|
||||
{
|
||||
$dirstandard[]=$dir.'/standard';
|
||||
$dirsmartphone[]=$dir.'/standard';
|
||||
$dirstandard[]=$dir.'standard';
|
||||
$dirsmartphone[]=$dir.'standard';
|
||||
}
|
||||
|
||||
$mesg=$_GET["mesg"];
|
||||
|
||||
@ -51,14 +51,17 @@ class Conf
|
||||
public $top_menu;
|
||||
public $smart_menu;
|
||||
|
||||
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 $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();
|
||||
|
||||
var $logbuffer = array();
|
||||
|
||||
@ -142,33 +145,16 @@ class Conf
|
||||
// If this is constant for a css file activated by a module
|
||||
if (preg_match('/^MAIN_MODULE_([A-Z_]+)_CSS$/i',$key))
|
||||
{
|
||||
$this->css_modules[]=$value;
|
||||
$modulename = strtolower($reg[1]);
|
||||
$this->css_modules[$modulename]=$value;
|
||||
}
|
||||
// If this is constant for a new tab page activated by a module
|
||||
// If this is constant for a new tab page activated by a module.
|
||||
elseif (preg_match('/^MAIN_MODULE_([A-Z_]+)_TABS_/i',$key))
|
||||
{
|
||||
$params=explode(':',$value,2);
|
||||
$this->tabs_modules[$params[0]][]=$value;
|
||||
}
|
||||
// If this is constant for a new tab page activated by a module
|
||||
elseif (preg_match('/^MAIN_MODULE_([A-Z_]+)_MENUS/i',$key,$reg))
|
||||
{
|
||||
$modulename = strtolower($reg[1]);
|
||||
$this->menus_modules[] = '/'.$modulename.'/core/menus';
|
||||
}
|
||||
// If this is constant for triggers activated by a module
|
||||
elseif (preg_match('/^MAIN_MODULE_([A-Z_]+)_TRIGGERS$/i',$key,$reg))
|
||||
{
|
||||
$modulename = strtolower($reg[1]);
|
||||
$this->triggers_modules[] = '/'.$modulename.'/core/triggers/';
|
||||
}
|
||||
// If this is constant for login method activated by a module
|
||||
elseif (preg_match('/^MAIN_MODULE_([A-Z_]+)_LOGIN_METHOD$/i',$key,$reg))
|
||||
{
|
||||
$modulename = strtolower($reg[1]);
|
||||
$this->login_method_modules[] = dol_buildpath('/'.$modulename.'/core/login/');
|
||||
}
|
||||
// If this is constant for hook activated by a module. Value is list of hooked tabs separated with :
|
||||
// If this is constant for hook activated by a module. Value is list of hooked tabs separated with ':'
|
||||
elseif (preg_match('/^MAIN_MODULE_([A-Z_]+)_HOOKS$/i',$key,$reg))
|
||||
{
|
||||
$modulename = strtolower($reg[1]);
|
||||
@ -178,13 +164,47 @@ class Conf
|
||||
$this->hooks_modules[$modulename][]=$value;
|
||||
}
|
||||
}
|
||||
// If this is constant for a sms engine
|
||||
elseif (preg_match('/^MAIN_MODULE_([A-Z_]+)_SMS$/i',$key,$reg))
|
||||
{
|
||||
$module=strtolower($reg[1]);
|
||||
$this->sms_engine_modules[$module]=$module; // Add this module in list of modules that provide SMS
|
||||
}
|
||||
// If this is a module constant
|
||||
// If this is constant for a sms engine
|
||||
elseif (preg_match('/^MAIN_MODULE_([A-Z_]+)_SMS$/i',$key,$reg))
|
||||
{
|
||||
$module=strtolower($reg[1]);
|
||||
$this->sms_engine_modules[$module]=$module; // Add this module in list of modules that provide SMS
|
||||
}
|
||||
// If this is constant for triggers activated by a module
|
||||
elseif (preg_match('/^MAIN_MODULE_([A-Z_]+)_BARCODE$/i',$key,$reg))
|
||||
{
|
||||
$modulename = strtolower($reg[1]);
|
||||
$this->barcode_modules[$modulename] = '/'.$modulename.'/core/modules/barcode/';
|
||||
}
|
||||
|
||||
// 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/';
|
||||
}
|
||||
// If this is constant for a new tab page activated by a module
|
||||
elseif (preg_match('/^MAIN_MODULE_([A-Z_]+)_MENUS$/i',$key,$reg))
|
||||
{
|
||||
$modulename = strtolower($reg[1]);
|
||||
$this->menus_modules[$modulename] = '/'.$modulename.'/core/menus/';
|
||||
}
|
||||
// If this is constant for triggers activated by a module
|
||||
elseif (preg_match('/^MAIN_MODULE_([A-Z_]+)_TRIGGERS$/i',$key,$reg))
|
||||
{
|
||||
$modulename = strtolower($reg[1]);
|
||||
$this->triggers_modules[$modulename] = '/'.$modulename.'/core/triggers/';
|
||||
}
|
||||
// If this is constant for triggers activated by a module
|
||||
elseif (preg_match('/^MAIN_MODULE_([A-Z_]+)_SUBSTITUTIONS$/i',$key,$reg))
|
||||
{
|
||||
$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))
|
||||
{
|
||||
$module=strtolower($reg[1]);
|
||||
|
||||
@ -78,18 +78,18 @@ class Interfaces
|
||||
foreach($dirtriggers as $reldir)
|
||||
{
|
||||
$dir=dol_buildpath($reldir,0);
|
||||
$dir=dol_osencode($dir);
|
||||
$newdir=dol_osencode($dir);
|
||||
//print "xx".$dir;exit;
|
||||
|
||||
// Check if directory exists
|
||||
if (! dol_is_dir($dir)) continue;
|
||||
// Check if directory exists (we do not use dol_is_dir to avoir loading files.lib.php at each call)
|
||||
if (! is_dir($newdir)) continue;
|
||||
|
||||
$handle=opendir($dir);
|
||||
$handle=opendir($newdir);
|
||||
if (is_resource($handle))
|
||||
{
|
||||
while (($file = readdir($handle))!==false)
|
||||
{
|
||||
if (is_readable($dir."/".$file) && preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php$/i',$file,$reg))
|
||||
if (is_readable($newdir."/".$file) && preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php$/i',$file,$reg))
|
||||
{
|
||||
$part1=$reg[1];
|
||||
$part2=$reg[2];
|
||||
@ -107,7 +107,7 @@ class Interfaces
|
||||
}
|
||||
else
|
||||
{
|
||||
include_once($dir.'/'.$file);
|
||||
include_once($newdir.'/'.$file);
|
||||
}
|
||||
|
||||
// Check if trigger file is disabled by name
|
||||
@ -207,17 +207,18 @@ class Interfaces
|
||||
foreach($dirtriggers as $reldir)
|
||||
{
|
||||
$dir=dol_buildpath($reldir,0);
|
||||
$newdir=dol_osencode($dir);
|
||||
//print "xx".$dir;exit;
|
||||
|
||||
// Check if directory exists
|
||||
if (!is_dir($dir)) continue;
|
||||
// Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php at each call)
|
||||
if (! is_dir($newdir)) continue;
|
||||
|
||||
$handle=opendir($dir);
|
||||
$handle=opendir($newdir);
|
||||
if (is_resource($handle))
|
||||
{
|
||||
while (($file = readdir($handle))!==false)
|
||||
{
|
||||
if (is_readable($dir.'/'.$file) && preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php/',$file,$reg))
|
||||
if (is_readable($newdir.'/'.$file) && preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php/',$file,$reg))
|
||||
{
|
||||
$part1=$reg[1];
|
||||
$part2=$reg[2];
|
||||
@ -232,7 +233,7 @@ class Interfaces
|
||||
}
|
||||
else
|
||||
{
|
||||
include_once($dir.'/'.$file);
|
||||
include_once($newdir.'/'.$file);
|
||||
}
|
||||
|
||||
$files[$i] = $file;
|
||||
|
||||
@ -593,21 +593,21 @@ class Translate
|
||||
{
|
||||
global $conf;
|
||||
|
||||
/*
|
||||
$outlang=$this->defaultlang; // Output language we want
|
||||
$outlangarray=explode('_',$outlang,2);
|
||||
// If lang is xx_XX, then we use xx
|
||||
if (strtolower($outlangarray[0]) == strtolower($outlangarray[1])) $outlang=$outlangarray[0];
|
||||
*/
|
||||
|
||||
$newnumber=$number;
|
||||
foreach ($conf->file->dol_document_root as $dirroot)
|
||||
|
||||
$dirsubstitutions=array_merge(array(),$conf->substitutions_modules);
|
||||
foreach($dirsubstitutions as $reldir)
|
||||
{
|
||||
$dir=$dirroot."/core/modules/substitutions";
|
||||
$dir=dol_buildpath($reldir,0);
|
||||
$newdir=dol_osencode($dir);
|
||||
|
||||
// Check if directory exists
|
||||
if (! dol_is_dir($dir)) continue;
|
||||
|
||||
$fonc='numberwords';
|
||||
if (file_exists($dir.'/functions_'.$fonc.'.lib.php'))
|
||||
if (file_exists($newdir.'/functions_'.$fonc.'.lib.php'))
|
||||
{
|
||||
include_once($dir.'/functions_'.$fonc.'.lib.php');
|
||||
include_once($newdir.'/functions_'.$fonc.'.lib.php');
|
||||
$newnumber=numberwords_getLabelFromNumber($this,$number,$isamount);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -3397,14 +3397,15 @@ function dol_textishtml($msg,$option=0)
|
||||
}
|
||||
|
||||
/**
|
||||
* Make substition into a string
|
||||
* There is two type of substitions:
|
||||
* - From $substitutionarray (oldval=>newval)
|
||||
* - From special constants (__XXX__=>f(objet->xxx)) by substitutions modules
|
||||
* Make substition into a string
|
||||
* There is two type of substitions:
|
||||
* - From $substitutionarray (oldval=>newval)
|
||||
* - From special constants (__XXX__=>f(objet->xxx)) by substitutions modules
|
||||
*
|
||||
* @param string $chaine Source string in which we must do substitution
|
||||
* @param array $substitutionarray Array with key->val to substitute
|
||||
* @return string Output string after subsitutions
|
||||
* @param string $chaine Source string in which we must do substitution
|
||||
* @param array $substitutionarray Array with key->val to substitute
|
||||
* @return string Output string after subsitutions
|
||||
* @see make_substitutions
|
||||
*/
|
||||
function make_substitutions($chaine,$substitutionarray)
|
||||
{
|
||||
@ -3421,10 +3422,11 @@ function make_substitutions($chaine,$substitutionarray)
|
||||
/**
|
||||
* Complete the $substitutionarray with more entries
|
||||
*
|
||||
* @param array &$substitutionarray Array substitution old value => new value value
|
||||
* @param Translate $outputlangs If we want substitution from special constants, we provide a language
|
||||
* @param Object $object If we want substitution from special constants, we provide data in a source object
|
||||
* @param array &$substitutionarray Array substitution old value => new value value
|
||||
* @param Translate $outputlangs If we want substitution from special constants, we provide a language
|
||||
* @param Object $object If we want substitution from special constants, we provide data in a source object
|
||||
* @return void
|
||||
* @see make_substitutions
|
||||
*/
|
||||
function complete_substitutions_array(&$substitutionarray,$outputlangs,$object='')
|
||||
{
|
||||
@ -3433,23 +3435,26 @@ function complete_substitutions_array(&$substitutionarray,$outputlangs,$object='
|
||||
require_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php');
|
||||
|
||||
// Check if there is external substitution to do asked by plugins
|
||||
// We look files into the core/modules/substitutions directory
|
||||
// By default, there is no such external plugins.
|
||||
foreach ($conf->file->dol_document_root as $dirroot)
|
||||
$dirsubstitutions=array_merge(array(),$conf->substitutions_modules);
|
||||
|
||||
foreach($dirsubstitutions as $reldir)
|
||||
{
|
||||
$substitfiles=dol_dir_list($dirroot.'/core/modules/substitutions','files',0,'functions_');
|
||||
$dir=dol_buildpath($reldir,0);
|
||||
|
||||
// Check if directory exists
|
||||
if (! dol_is_dir($dir)) continue;
|
||||
|
||||
$substitfiles=dol_dir_list($dir,'files',0,'functions_');
|
||||
foreach($substitfiles as $substitfile)
|
||||
{
|
||||
if (preg_match('/functions_(.*)\.lib\.php/i',$substitfile['name'],$reg))
|
||||
{
|
||||
$module=$reg[1];
|
||||
if (! empty($conf->$module->enabled)) // If module enabled
|
||||
{
|
||||
dol_syslog("Library functions_".$module.".lib.php found into ".$dirroot);
|
||||
require_once($dirroot."/core/modules/substitutions/functions_".$module.".lib.php");
|
||||
$function_name=$module."_completesubstitutionarray";
|
||||
$function_name($substitutionarray,$outputlangs,$object);
|
||||
}
|
||||
|
||||
dol_syslog("Library functions_".$substitfile['name']." found into ".$dir);
|
||||
require_once($dir.$substitfile['name']);
|
||||
$function_name=$module."_completesubstitutionarray";
|
||||
$function_name($substitutionarray,$outputlangs,$object);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -63,8 +63,10 @@ function checkLoginPassEntity($usertotest,$passwordtotest,$entitytotest,$authmod
|
||||
// Validation of login/pass/entity with a third party login module method
|
||||
if (! empty($conf->login_method_modules) && is_array($conf->login_method_modules))
|
||||
{
|
||||
foreach($conf->login_method_modules as $dir)
|
||||
foreach($conf->login_method_modules as $reldir)
|
||||
{
|
||||
$dir=dol_buildpath($reldir,0);
|
||||
|
||||
$newdir=dol_osencode($dir);
|
||||
|
||||
// Check if directory exists
|
||||
|
||||
@ -177,7 +177,7 @@ abstract class DolibarrModules
|
||||
// Remove activation of module's triggers (MAIN_MODULE_MYMODULE_TRIGGERS in llx_const)
|
||||
if (! $err) $err+=$this->delete_triggers();
|
||||
|
||||
// Remove activation of module's authentification method (MAIN_MODULE_MYMODULE_LOGIN_METHOD in llx_const)
|
||||
// Remove activation of module's authentification method (MAIN_MODULE_MYMODULE_LOGIN in llx_const)
|
||||
if (! $err) $err+=$this->delete_login_method();
|
||||
|
||||
// Remove constants defined by modules
|
||||
@ -1424,7 +1424,7 @@ abstract class DolibarrModules
|
||||
$sql.= ", entity";
|
||||
$sql.= ")";
|
||||
$sql.= " VALUES (";
|
||||
$sql.= $this->db->encrypt($this->const_name."_LOGIN_METHOD",1);
|
||||
$sql.= $this->db->encrypt($this->const_name."_LOGIN",1);
|
||||
$sql.= ", 'chaine'";
|
||||
$sql.= ", ".$this->db->encrypt($this->login_method,1);
|
||||
$sql.= ", null";
|
||||
@ -1455,7 +1455,7 @@ abstract class DolibarrModules
|
||||
$err=0;
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."const";
|
||||
$sql.= " WHERE ".$this->db->decrypt('name')." LIKE '".$this->const_name."_LOGIN_METHOD'";
|
||||
$sql.= " WHERE ".$this->db->decrypt('name')." LIKE '".$this->const_name."_LOGIN'";
|
||||
$sql.= " AND entity = ".$conf->entity;
|
||||
|
||||
dol_syslog(get_class($this)."::delete_login_method sql=".$sql);
|
||||
|
||||
@ -1173,10 +1173,10 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a
|
||||
if (! class_exists('MenuTop'))
|
||||
{
|
||||
$menufound=0;
|
||||
$dirmenus=array_merge(array("/core/menus"),$conf->menus_modules);
|
||||
$dirmenus=array_merge(array("/core/menus/"),$conf->menus_modules);
|
||||
foreach($dirmenus as $dirmenu)
|
||||
{
|
||||
$menufound=dol_include_once($dirmenu."/standard/".$top_menu);
|
||||
$menufound=dol_include_once($dirmenu."standard/".$top_menu);
|
||||
if ($menufound) break;
|
||||
}
|
||||
if (! $menufound) // If failed to include, we try with standard
|
||||
@ -1382,10 +1382,10 @@ function left_menu($menu_array_before, $helppagename='', $moresearchform='', $me
|
||||
if (! class_exists('MenuLeft'))
|
||||
{
|
||||
$menufound=0;
|
||||
$dirmenus=array_merge(array("/core/menus"),$conf->menus_modules);
|
||||
$dirmenus=array_merge(array("/core/menus/"),$conf->menus_modules);
|
||||
foreach($dirmenus as $dirmenu)
|
||||
{
|
||||
$menufound=dol_include_once($dirmenu."/standard/".$left_menu);
|
||||
$menufound=dol_include_once($dirmenu."standard/".$left_menu);
|
||||
if ($menufound) break;
|
||||
}
|
||||
if (! $menufound) // If failed to include, we try with standard
|
||||
|
||||
@ -335,15 +335,23 @@ if ($modulepart == 'barcode')
|
||||
$encoding=$_GET["encoding"];
|
||||
$readable=$_GET["readable"]?$_GET["readable"]:"Y";
|
||||
|
||||
// Output files with barcode generators
|
||||
foreach ($conf->file->dol_document_root as $dirroot)
|
||||
$dirbarcode=array_merge(array("/core/modules/barcode/"),$conf->barcode_modules);
|
||||
|
||||
$result=0;
|
||||
|
||||
foreach($dirbarcode as $reldir)
|
||||
{
|
||||
$dir=$dirroot . "/core/modules/barcode/";
|
||||
$result=@include_once($dir.$generator.".modules.php");
|
||||
$dir=dol_buildpath($reldir,0);
|
||||
$newdir=dol_osencode($dir);
|
||||
|
||||
// Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php)
|
||||
if (! is_dir($newdir)) continue;
|
||||
|
||||
$result=@include_once($newdir.$generator.".modules.php");
|
||||
if ($result) break;
|
||||
}
|
||||
|
||||
// Chargement de la classe de codage
|
||||
// Load barcode class
|
||||
$classname = "mod".ucfirst($generator);
|
||||
$module = new $classname($db);
|
||||
if ($module->encodingIsSupported($encoding))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user