diff --git a/dev/skeletons/modMyModule.class.php b/dev/skeletons/modMyModule.class.php index 9cf6604ce9b..f81b72b5776 100644 --- a/dev/skeletons/modMyModule.class.php +++ b/dev/skeletons/modMyModule.class.php @@ -73,12 +73,13 @@ class modMyModule extends DolibarrModules // for specific path of parts (eg: /mymodule/core/modules/barcode) // for specific css file (eg: /mymodule/css/mymodule.css.php) //$this->module_parts = array( - // 'triggers' => 0, // Set this to 1 if module has its own trigger directory - // 'login' => 0, // Set this to 1 if module has its own login method directory - // 'substitutions' => 0, // Set this to 1 if module has its own substitution function file - // 'menus' => 0, // Set this to 1 if module has its own menus handler directory - // 'barcode' => 0, // Set this to 1 if module has its own barcode directory - // 'models' => 0, // Set this to 1 if module has its own models directory + // 'triggers' => 0, // Set this to 1 if module has its own trigger directory (core/triggers) + // 'login' => 0, // Set this to 1 if module has its own login method directory (core/login) + // 'substitutions' => 0, // Set this to 1 if module has its own substitution function file (core/substitutions) + // 'menus' => 0, // Set this to 1 if module has its own menus handler directory (core/menus) + // 'tpl' => 0, // Set this to 1 if module overwrite template dir (core/tpl) + // 'barcode' => 0, // Set this to 1 if module has its own barcode directory (core/modules/barcode) + // 'models' => 0, // Set this to 1 if module has its own models directory (core/modules/xxx) // 'css' => '/mymodule/css/mymodule.css.php', // Set this to relative path of css if module has its own css file // 'hooks' => array('hookcontext1','hookcontext2') // Set here all hooks context managed by module // 'workflow' => array('order' => array('WORKFLOW_ORDER_AUTOCREATE_INVOICE')) // Set here all workflow context managed by module diff --git a/htdocs/admin/barcode.php b/htdocs/admin/barcode.php index f87df7b6ea9..39e059d3c97 100644 --- a/htdocs/admin/barcode.php +++ b/htdocs/admin/barcode.php @@ -107,8 +107,8 @@ $barcodelist=array(); clearstatcache(); -// Check if there is external substitution to do asked by plugins -$dirbarcode=array_merge(array("/core/modules/barcode/"),$conf->barcode_modules); +// Scan list of all barcode included provided by external modules +$dirbarcode=array_merge(array("/core/modules/barcode/"),$conf->modules_parts['barcode']); foreach($dirbarcode as $reldir) { diff --git a/htdocs/comm/propal/contact.php b/htdocs/comm/propal/contact.php index b9406d6012b..d129c1b40ae 100644 --- a/htdocs/comm/propal/contact.php +++ b/htdocs/comm/propal/contact.php @@ -174,7 +174,7 @@ if ($id > 0 || ! empty($ref)) if (is_null($object->client)) $object->fetch_thirdparty(); print "".$langs->trans("Company").""; print ''.$object->client->getNomUrl(1).''; - + // Delivery address if ($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) { @@ -182,11 +182,11 @@ if ($id > 0 || ! empty($ref)) print ''; - + if ($action != 'editdelivery_address' && $object->brouillon) print ''; print '
'; print $langs->trans('DeliveryAddress'); print 'socid.'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetDeliveryAddress'),1).'
'; print ''; - + if ($action == 'editdelivery_address') { $formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->socid,'fk_address','propal',$object->id); @@ -201,19 +201,17 @@ if ($id > 0 || ! empty($ref)) print ""; print ''; - + print '
'; - - // Contacts lines - if (file_exists(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/contacts.tpl.php")) + + // Contacts lines (modules that overwrite templates must declare this into descriptor) + $dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl')); + foreach($dirtpls as $reldir) { - include(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/contacts.tpl.php"); + $res=@include(dol_buildpath($reldir.'/contacts.tpl.php')); + if ($res) break; } - else - { - include(DOL_DOCUMENT_ROOT.'/core/tpl/contacts.tpl.php'); - } - + } else { @@ -221,6 +219,7 @@ if ($id > 0 || ! empty($ref)) } } -$db->close(); llxFooter(); + +$db->close(); ?> \ No newline at end of file diff --git a/htdocs/commande/contact.php b/htdocs/commande/contact.php index 4356abd37b3..f1e977fe9e6 100644 --- a/htdocs/commande/contact.php +++ b/htdocs/commande/contact.php @@ -137,7 +137,7 @@ dol_htmloutput_mesg($mesg); if ($id > 0 || ! empty($ref)) { $langs->trans("OrderCard"); - + if ($object->fetch($id, $ref) > 0) { $soc = new Societe($db); @@ -174,7 +174,7 @@ if ($id > 0 || ! empty($ref)) print "".$langs->trans("Company").""; print ''.$object->client->getNomUrl(1).''; - + // Delivery address if ($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) { @@ -182,11 +182,11 @@ if ($id > 0 || ! empty($ref)) print ''; - + if ($action != 'editdelivery_address' && $object->brouillon) print ''; print '
'; print $langs->trans('DeliveryAddress'); print 'socid.'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetDeliveryAddress'),1).'
'; print ''; - + if ($action == 'editdelivery_address') { $formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,GETPOST('socid','int'),'fk_address','commande',$object->id); @@ -197,23 +197,20 @@ if ($id > 0 || ! empty($ref)) } print ''; } - + print ""; print ''; print '
'; - - // Select template for Contacts lines - if (file_exists(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/contacts.tpl.php")) - { - include(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/contacts.tpl.php"); - } - else - { - include(DOL_DOCUMENT_ROOT.'/core/tpl/contacts.tpl.php'); - } + // Contacts lines (modules that overwrite templates must declare this into descriptor) + $dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl')); + foreach($dirtpls as $reldir) + { + $res=@include(dol_buildpath($reldir.'/contacts.tpl.php')); + if ($res) break; + } } else { diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php index a2a9ad4192e..affa7414dfa 100644 --- a/htdocs/compta/facture/contact.php +++ b/htdocs/compta/facture/contact.php @@ -34,7 +34,7 @@ require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); $langs->load("bills"); $langs->load("companies"); -$id = (GETPOST('id','int')?GETPOST('id','int'):GETPOST('facid','int')); // For backward compatibility +$id = (GETPOST('id')?GETPOST('id','int'):GETPOST('facid','int')); // For backward compatibility $ref = GETPOST('ref','alpha'); $lineid = GETPOST('lineid','int'); $socid = GETPOST('socid','int'); @@ -57,7 +57,7 @@ if ($action == 'addcontact' && $user->rights->facture->creer) if ($result > 0 && $id > 0) { - $contactid = (GETPOST('userid','int') ? GETPOST('userid','int') : GETPOST('contactid','int')); + $contactid = (GETPOST('userid') ? GETPOST('userid','int') : GETPOST('contactid','int')); $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); } @@ -169,15 +169,13 @@ if ($id > 0 || ! empty($ref)) print ''; print '
'; - - // Contacts lines - if (file_exists(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/contacts.tpl.php")) + + // Contacts lines (modules that overwrite templates must declare this into descriptor) + $dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl')); + foreach($dirtpls as $reldir) { - include(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/contacts.tpl.php"); - } - else - { - include(DOL_DOCUMENT_ROOT.'/core/tpl/contacts.tpl.php'); + $res=@include(dol_buildpath($reldir.'/contacts.tpl.php')); + if ($res) break; } } diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index a2c19812434..930387e52b6 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -52,18 +52,18 @@ class Conf public $smart_menu; public $modules = array(); // List of activated modules - public $modules_parts = array(); // List of modules parts + public $modules_parts = array('triggers'=>array(),'login'=>array(),'substitutions'=>array(),'menus'=>array(),'tpl'=>array(),'barcode'=>array(),'models'=>array()); // List of modules parts // TODO Remove all thoose tabs with one generic + public $triggers_modules = array(); + public $login_modules = array(); + public $substitutions_modules = array(); + public $menus_modules = array(); + public $barcode_modules = array(); public $sms_engine_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 $barcode_modules = array(); - public $substitutions_modules = array(); public $societe_modules = array(); var $logbuffer = array(); @@ -188,7 +188,7 @@ class Conf if (! isset($this->modules_parts[$partname]) || ! is_array($this->modules_parts[$partname])) { $this->modules_parts[$partname] = array(); } $arrValue = json_decode($value,true); if (is_array($arrValue) && ! empty($arrValue)) $value = $arrValue; - else if (in_array($partname,array('login','menus','substitutions','triggers'))) $value = '/'.$modulename.'/core/'.$partname.'/'; + else if (in_array($partname,array('login','menus','substitutions','triggers','tpl'))) $value = '/'.$modulename.'/core/'.$partname.'/'; else if (in_array($partname,array('models'))) $value = '/'.$modulename.'/'; else if ($value == 1) $value = '/'.$modulename.'/core/modules/'.$partname.'/'; $this->$varname = array_merge($this->$varname, array($modulename => $value)); // TODO deprecated diff --git a/htdocs/core/class/interfaces.class.php b/htdocs/core/class/interfaces.class.php index b64dcb58881..8a20803a9e8 100644 --- a/htdocs/core/class/interfaces.class.php +++ b/htdocs/core/class/interfaces.class.php @@ -74,7 +74,7 @@ class Interfaces $orders = array(); $i=0; - $dirtriggers=array_merge(array('/core/triggers'),$conf->triggers_modules); + $dirtriggers=array_merge(array('/core/triggers'),$conf->modules_parts['triggers']); foreach($dirtriggers as $reldir) { $dir=dol_buildpath($reldir,0); @@ -203,7 +203,7 @@ class Interfaces $orders = array(); $i = 0; - $dirtriggers=array_merge(array('/core/triggers/'),$conf->triggers_modules); + $dirtriggers=array_merge(array('/core/triggers/'),$conf->modules_parts['triggers']); foreach($dirtriggers as $reldir) { $dir=dol_buildpath($reldir,0); diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 8f14de84b39..6372e2a78ca 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -591,7 +591,7 @@ class Translate $newnumber=$number; - $dirsubstitutions=array_merge(array(),$conf->substitutions_modules); + $dirsubstitutions=array_merge(array(),$conf->modules_parts['substitutions']); foreach($dirsubstitutions as $reldir) { $dir=dol_buildpath($reldir,0); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index c76924f5822..0cbd3224ffc 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3361,7 +3361,7 @@ 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 - $dirsubstitutions=array_merge(array(),$conf->substitutions_modules); + $dirsubstitutions=array_merge(array(),$conf->modules_parts['substitutions']); foreach($dirsubstitutions as $reldir) { diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 73759787103..79e6b268555 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -669,7 +669,7 @@ if (! defined('NOREQUIRETRAN')) if ($conf->global->MAIN_USE_TEMPLATE_ENGINE && ! defined('NOTEMPLATEENGINE')) { require_once(DOL_DOCUMENT_ROOT.'/includes/savant/Savant3.php'); - + $tpl = new Savant3(); } @@ -1181,7 +1181,7 @@ 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->modules_parts['menus']); foreach($dirmenus as $dirmenu) { $menufound=dol_include_once($dirmenu."standard/".$top_menu); @@ -1387,7 +1387,7 @@ 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->modules_parts['menus']); foreach($dirmenus as $dirmenu) { $menufound=dol_include_once($dirmenu."standard/".$left_menu); diff --git a/htdocs/viewimage.php b/htdocs/viewimage.php index 148202b4f98..6fac7405ebb 100644 --- a/htdocs/viewimage.php +++ b/htdocs/viewimage.php @@ -336,7 +336,7 @@ if ($modulepart == 'barcode') $encoding=$_GET["encoding"]; $readable=$_GET["readable"]?$_GET["readable"]:"Y"; - $dirbarcode=array_merge(array("/core/modules/barcode/"),$conf->barcode_modules); + $dirbarcode=array_merge(array("/core/modules/barcode/"),$conf->modules_parts['barcode']); $result=0;