Fix: Overwritting code is not role of a template but of a module.
Code is now working as a module change. Also it is faster (no need to make a failed include when module is not installed) and support alternative directory.
This commit is contained in:
parent
a862b5d5c3
commit
ff06360071
@ -73,12 +73,13 @@ class modMyModule extends DolibarrModules
|
|||||||
// for specific path of parts (eg: /mymodule/core/modules/barcode)
|
// for specific path of parts (eg: /mymodule/core/modules/barcode)
|
||||||
// for specific css file (eg: /mymodule/css/mymodule.css.php)
|
// for specific css file (eg: /mymodule/css/mymodule.css.php)
|
||||||
//$this->module_parts = array(
|
//$this->module_parts = array(
|
||||||
// 'triggers' => 0, // Set this to 1 if module has its own trigger 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
|
// '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
|
// '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
|
// 'menus' => 0, // Set this to 1 if module has its own menus handler directory (core/menus)
|
||||||
// 'barcode' => 0, // Set this to 1 if module has its own barcode directory
|
// 'tpl' => 0, // Set this to 1 if module overwrite template dir (core/tpl)
|
||||||
// 'models' => 0, // Set this to 1 if module has its own models directory
|
// '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
|
// '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
|
// '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
|
// 'workflow' => array('order' => array('WORKFLOW_ORDER_AUTOCREATE_INVOICE')) // Set here all workflow context managed by module
|
||||||
|
|||||||
@ -107,8 +107,8 @@ $barcodelist=array();
|
|||||||
clearstatcache();
|
clearstatcache();
|
||||||
|
|
||||||
|
|
||||||
// Check if there is external substitution to do asked by plugins
|
// Scan list of all barcode included provided by external modules
|
||||||
$dirbarcode=array_merge(array("/core/modules/barcode/"),$conf->barcode_modules);
|
$dirbarcode=array_merge(array("/core/modules/barcode/"),$conf->modules_parts['barcode']);
|
||||||
|
|
||||||
foreach($dirbarcode as $reldir)
|
foreach($dirbarcode as $reldir)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -204,14 +204,12 @@ if ($id > 0 || ! empty($ref))
|
|||||||
|
|
||||||
print '<br>';
|
print '<br>';
|
||||||
|
|
||||||
// Contacts lines
|
// Contacts lines (modules that overwrite templates must declare this into descriptor)
|
||||||
if (file_exists(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/contacts.tpl.php"))
|
$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');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -221,6 +219,7 @@ if ($id > 0 || ! empty($ref))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$db->close();
|
|
||||||
llxFooter();
|
llxFooter();
|
||||||
|
|
||||||
|
$db->close();
|
||||||
?>
|
?>
|
||||||
@ -204,16 +204,13 @@ if ($id > 0 || ! empty($ref))
|
|||||||
|
|
||||||
print '<br>';
|
print '<br>';
|
||||||
|
|
||||||
// Select template for Contacts lines
|
// Contacts lines (modules that overwrite templates must declare this into descriptor)
|
||||||
if (file_exists(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/contacts.tpl.php"))
|
$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
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@ -34,7 +34,7 @@ require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
|
|||||||
$langs->load("bills");
|
$langs->load("bills");
|
||||||
$langs->load("companies");
|
$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');
|
$ref = GETPOST('ref','alpha');
|
||||||
$lineid = GETPOST('lineid','int');
|
$lineid = GETPOST('lineid','int');
|
||||||
$socid = GETPOST('socid','int');
|
$socid = GETPOST('socid','int');
|
||||||
@ -57,7 +57,7 @@ if ($action == 'addcontact' && $user->rights->facture->creer)
|
|||||||
|
|
||||||
if ($result > 0 && $id > 0)
|
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"]);
|
$result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,14 +170,12 @@ if ($id > 0 || ! empty($ref))
|
|||||||
|
|
||||||
print '<br>';
|
print '<br>';
|
||||||
|
|
||||||
// Contacts lines
|
// Contacts lines (modules that overwrite templates must declare this into descriptor)
|
||||||
if (file_exists(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/contacts.tpl.php"))
|
$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');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -52,18 +52,18 @@ class Conf
|
|||||||
public $smart_menu;
|
public $smart_menu;
|
||||||
|
|
||||||
public $modules = array(); // List of activated modules
|
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
|
// 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 $sms_engine_modules = array();
|
||||||
public $css_modules = array();
|
public $css_modules = array();
|
||||||
public $tabs_modules = array();
|
public $tabs_modules = array();
|
||||||
public $triggers_modules = array();
|
|
||||||
public $menus_modules = array();
|
|
||||||
public $hooks_modules = array();
|
public $hooks_modules = array();
|
||||||
public $login_modules = array();
|
|
||||||
public $barcode_modules = array();
|
|
||||||
public $substitutions_modules = array();
|
|
||||||
public $societe_modules = array();
|
public $societe_modules = array();
|
||||||
|
|
||||||
var $logbuffer = 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(); }
|
if (! isset($this->modules_parts[$partname]) || ! is_array($this->modules_parts[$partname])) { $this->modules_parts[$partname] = array(); }
|
||||||
$arrValue = json_decode($value,true);
|
$arrValue = json_decode($value,true);
|
||||||
if (is_array($arrValue) && ! empty($arrValue)) $value = $arrValue;
|
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 (in_array($partname,array('models'))) $value = '/'.$modulename.'/';
|
||||||
else if ($value == 1) $value = '/'.$modulename.'/core/modules/'.$partname.'/';
|
else if ($value == 1) $value = '/'.$modulename.'/core/modules/'.$partname.'/';
|
||||||
$this->$varname = array_merge($this->$varname, array($modulename => $value)); // TODO deprecated
|
$this->$varname = array_merge($this->$varname, array($modulename => $value)); // TODO deprecated
|
||||||
|
|||||||
@ -74,7 +74,7 @@ class Interfaces
|
|||||||
$orders = array();
|
$orders = array();
|
||||||
$i=0;
|
$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)
|
foreach($dirtriggers as $reldir)
|
||||||
{
|
{
|
||||||
$dir=dol_buildpath($reldir,0);
|
$dir=dol_buildpath($reldir,0);
|
||||||
@ -203,7 +203,7 @@ class Interfaces
|
|||||||
$orders = array();
|
$orders = array();
|
||||||
$i = 0;
|
$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)
|
foreach($dirtriggers as $reldir)
|
||||||
{
|
{
|
||||||
$dir=dol_buildpath($reldir,0);
|
$dir=dol_buildpath($reldir,0);
|
||||||
|
|||||||
@ -591,7 +591,7 @@ class Translate
|
|||||||
|
|
||||||
$newnumber=$number;
|
$newnumber=$number;
|
||||||
|
|
||||||
$dirsubstitutions=array_merge(array(),$conf->substitutions_modules);
|
$dirsubstitutions=array_merge(array(),$conf->modules_parts['substitutions']);
|
||||||
foreach($dirsubstitutions as $reldir)
|
foreach($dirsubstitutions as $reldir)
|
||||||
{
|
{
|
||||||
$dir=dol_buildpath($reldir,0);
|
$dir=dol_buildpath($reldir,0);
|
||||||
|
|||||||
@ -3361,7 +3361,7 @@ function complete_substitutions_array(&$substitutionarray,$outputlangs,$object='
|
|||||||
require_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php');
|
require_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php');
|
||||||
|
|
||||||
// Check if there is external substitution to do asked by plugins
|
// 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)
|
foreach($dirsubstitutions as $reldir)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1181,7 +1181,7 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a
|
|||||||
if (! class_exists('MenuTop'))
|
if (! class_exists('MenuTop'))
|
||||||
{
|
{
|
||||||
$menufound=0;
|
$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)
|
foreach($dirmenus as $dirmenu)
|
||||||
{
|
{
|
||||||
$menufound=dol_include_once($dirmenu."standard/".$top_menu);
|
$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'))
|
if (! class_exists('MenuLeft'))
|
||||||
{
|
{
|
||||||
$menufound=0;
|
$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)
|
foreach($dirmenus as $dirmenu)
|
||||||
{
|
{
|
||||||
$menufound=dol_include_once($dirmenu."standard/".$left_menu);
|
$menufound=dol_include_once($dirmenu."standard/".$left_menu);
|
||||||
|
|||||||
@ -336,7 +336,7 @@ if ($modulepart == 'barcode')
|
|||||||
$encoding=$_GET["encoding"];
|
$encoding=$_GET["encoding"];
|
||||||
$readable=$_GET["readable"]?$_GET["readable"]:"Y";
|
$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;
|
$result=0;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user