From ebd25c5c75f49e5b01426ab4e7d162c9d0a35658 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 15 Dec 2010 17:50:42 +0000 Subject: [PATCH] New: add directory for external module and other customization --- htdocs/core/class/commonobject.class.php | 25 ++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 6ef95e5b1f3..62de50c032b 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1279,15 +1279,28 @@ class CommonObject { if ($conf->$module->enabled && in_array($type,$hooks)) { + $path = '/'.$module.'/class/'; + $actionfile = 'actions_'.$module.'.class.php'; + $daofile = 'dao_'.$module.'.class.php'; + $pathroot = ''; + // Include class and library of thirdparty module - if (file_exists(DOL_DOCUMENT_ROOT.'/'.$module.'/class/actions_'.$module.'.class.php') && - file_exists(DOL_DOCUMENT_ROOT.'/'.$module.'/class/dao_'.$module.'.class.php')) + if (file_exists(DOL_DOCUMENT_ROOT.$path.$actionfile) && file_exists(DOL_DOCUMENT_ROOT.$path.$daofile)) + { + $pathroot = DOL_DOCUMENT_ROOT; + } + else if (file_exists(DOL_DOCUMENT_EXTMODULE.$path.$actionfile) && file_exists(DOL_DOCUMENT_EXTMODULE.$path.$daofile)) + { + $pathroot = DOL_DOCUMENT_EXTMODULE; + } + + if ($pathroot) { // Include actions class (controller) - require_once(DOL_DOCUMENT_ROOT.'/'.$module.'/class/actions_'.$module.'.class.php'); + require_once($pathroot.$path.$actionfile); // Include dataservice class (model) - require_once(DOL_DOCUMENT_ROOT.'/'.$module.'/class/dao_'.$module.'.class.php'); + require_once($pathroot.$path.$daofile); // Instantiate actions class (controller) $controlclassname = 'Actions'.ucfirst($module); @@ -1299,9 +1312,9 @@ class CommonObject $this->hooks[$objModule->module_number]->object = new $modelclassname($this->db); } - if (file_exists(DOL_DOCUMENT_ROOT.'/'.$module.'/lib/'.$module.'.lib.php')) + if (file_exists($pathroot.'/'.$module.'/lib/'.$module.'.lib.php')) { - require_once(DOL_DOCUMENT_ROOT.'/'.$module.'/lib/'.$module.'.lib.php'); + require_once($pathroot.'/'.$module.'/lib/'.$module.'.lib.php'); } } }