forked from Wavyzz/dolibarr
Works on capability to hook a thirdparty module.
This commit is contained in:
@@ -33,6 +33,9 @@
|
||||
|
||||
class CommonObject
|
||||
{
|
||||
// Instantiate classes of thirdparty module
|
||||
var $objModules=array();
|
||||
|
||||
/**
|
||||
* \brief Check if ref is used.
|
||||
* \return int <0 if KO, 0 if not found, >0 if found
|
||||
@@ -1142,14 +1145,31 @@ class CommonObject
|
||||
}
|
||||
|
||||
/**
|
||||
* Show add free products/services form
|
||||
* Instantiate hooks of thirdparty module
|
||||
* @param $type Type of hook
|
||||
*/
|
||||
function showAddFreeProductForm($dateSelector=0)
|
||||
function callHooks($type='objectcard')
|
||||
{
|
||||
global $conf,$langs;
|
||||
global $html,$bc,$var;
|
||||
|
||||
include(DOL_DOCUMENT_ROOT.'/core/tpl/addfreeproductform.tpl.php');
|
||||
global $conf;
|
||||
|
||||
foreach($conf->hooks_modules as $module => $hooks)
|
||||
{
|
||||
if ($conf->$module->enabled && in_array($type,$hooks))
|
||||
{
|
||||
// Include class and library of thirdparty module
|
||||
if (file_exists(DOL_DOCUMENT_ROOT.'/'.$module.'/class/'.$module.'.class.php'))
|
||||
{
|
||||
require_once(DOL_DOCUMENT_ROOT.'/'.$module.'/class/'.$module.'.class.php');
|
||||
}
|
||||
if (file_exists(DOL_DOCUMENT_ROOT.'/'.$module.'/lib/'.$module.'.lib.php'))
|
||||
{
|
||||
require_once(DOL_DOCUMENT_ROOT.'/'.$module.'/lib/'.$module.'.lib.php');
|
||||
}
|
||||
|
||||
$classname = ucfirst($module);
|
||||
$this->objModules[] = new $classname($this->db);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1162,6 +1182,17 @@ class CommonObject
|
||||
|
||||
include(DOL_DOCUMENT_ROOT.'/core/tpl/addpredefinedproductform.tpl.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show add free products/services form
|
||||
*/
|
||||
function showAddFreeProductForm($dateSelector=0)
|
||||
{
|
||||
global $conf,$langs;
|
||||
global $html,$bc,$var;
|
||||
|
||||
include(DOL_DOCUMENT_ROOT.'/core/tpl/addfreeproductform.tpl.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show linked object block
|
||||
|
||||
@@ -131,11 +131,21 @@ class Conf
|
||||
//print 'xxx'.$params[0].'-'.$value;
|
||||
}
|
||||
// If this is constant for triggers activated by a module
|
||||
elseif (preg_match('/^MAIN_MODULE_([A-Z_]+)_TRIGGERS$/i',$key,$regs))
|
||||
elseif (preg_match('/^MAIN_MODULE_([A-Z_]+)_TRIGGERS$/i',$key,$reg))
|
||||
{
|
||||
$modulename = strtolower($regs[1]);
|
||||
$modulename = strtolower($reg[1]);
|
||||
$this->triggers_modules[] = DOL_DOCUMENT_ROOT.'/'.$modulename.'/inc/triggers/';
|
||||
}
|
||||
// If this is constant for hook activated by a module
|
||||
elseif (preg_match('/^MAIN_MODULE_([A-Z_]+)_HOOKS$/i',$key,$reg))
|
||||
{
|
||||
$modulename = strtolower($reg[1]);
|
||||
$params=explode(':',$value);
|
||||
foreach($params as $value)
|
||||
{
|
||||
$this->hooks_modules[$modulename][]=$value;
|
||||
}
|
||||
}
|
||||
// If this is constant to force a module directories (used to manage some exceptions)
|
||||
// Should not be used by modules
|
||||
elseif (preg_match('/^MAIN_MODULE_([A-Z_]+)_DIR_/i',$key,$reg))
|
||||
|
||||
Reference in New Issue
Block a user