diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 5767b9976e9..62de18a4235 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -37,11 +37,6 @@ require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php"); require_once(DOL_DOCUMENT_ROOT."/lib/propal.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php"); if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'); -if ($conf->milestone->enabled) -{ - require_once(DOL_DOCUMENT_ROOT.'/milestone/lib/milestone.lib.php'); - require_once(DOL_DOCUMENT_ROOT.'/milestone/class/milestone.class.php'); -} $langs->load('companies'); $langs->load('propal'); @@ -77,6 +72,13 @@ $result = restrictedArea($user, $module, $objectid, $dbtable); // Nombre de ligne pour choix de produit/service predefinis $NBLINES=4; +// Instantiate hooks of thirdparty module +if (is_array($conf->hooks_modules) && !empty($conf->hooks_modules)) +{ + $hooks = new Propal($db); + $hooks->callHooks('objectcard'); +} + /******************************************************************************/ /* Actions */ diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index db873d2b015..cd0caa1e33a 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -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 diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 13fd656ffc6..b2d882377c9 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -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))