From aaaad713470a2dbada31b0a2c68052d3bfe59bad Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Fri, 24 May 2019 12:10:58 +0200 Subject: [PATCH 1/4] FIX : do not include disabled modules tpl --- htdocs/core/class/commonobject.class.php | 68 ++++++++++++++++++------ 1 file changed, 52 insertions(+), 16 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index f0fe7bf437c..22c96f0f589 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3715,16 +3715,25 @@ abstract class CommonObject // Output template part (modules that overwrite templates must declare this into descriptor) // Use global variables + $dateSelector + $seller and $buyer - $dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl')); - foreach($dirtpls as $reldir) + $dirtpls=array_merge($conf->modules_parts['tpl'], array('/core/tpl')); + foreach($dirtpls as $module => $reldir) { - $tpl = dol_buildpath($reldir.'/objectline_create.tpl.php'); + if (!empty($module) && empty($conf->$module->enabled)) continue; + + if (!empty($module)) + { + $tpl = dol_buildpath($reldir.'/objectline_create.tpl.php'); + } + else + { + $tpl = DOL_DOCUMENT_ROOT.$reldir.'/objectline_create.tpl.php'; + } if (empty($conf->file->strict_mode)) { $res=@include $tpl; } else { $res=include $tpl; // for debug } - if ($res) break; + if ($res > 0) break; } } @@ -3967,16 +3976,25 @@ abstract class CommonObject // Output template part (modules that overwrite templates must declare this into descriptor) // Use global variables + $dateSelector + $seller and $buyer - $dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl')); - foreach($dirtpls as $reldir) + $dirtpls=array_merge($conf->modules_parts['tpl'], array('/core/tpl')); + foreach($dirtpls as $module => $reldir) { - $tpl = dol_buildpath($reldir.'/objectline_view.tpl.php'); + if (!empty($module) && empty($conf->$module->enabled)) continue; + + if (!empty($module)) + { + $tpl = dol_buildpath($reldir.'/objectline_view.tpl.php'); + } + else + { + $tpl = DOL_DOCUMENT_ROOT.$reldir.'/objectline_view.tpl.php'; + } if (empty($conf->file->strict_mode)) { $res=@include $tpl; } else { $res=include $tpl; // for debug } - if ($res) break; + if ($res > 0) break; } } @@ -3990,16 +4008,25 @@ abstract class CommonObject // Output template part (modules that overwrite templates must declare this into descriptor) // Use global variables + $dateSelector + $seller and $buyer - $dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl')); - foreach($dirtpls as $reldir) + $dirtpls=array_merge($conf->modules_parts['tpl'], array('/core/tpl')); + foreach($dirtpls as $module => $reldir) { - $tpl = dol_buildpath($reldir.'/objectline_edit.tpl.php'); + if (!empty($module) && empty($conf->$module->enabled)) continue; + + if (!empty($module)) + { + $tpl = dol_buildpath($reldir.'/objectline_edit.tpl.php'); + } + else + { + $tpl = DOL_DOCUMENT_ROOT.$reldir.'/objectline_edit.tpl.php'; + } if (empty($conf->file->strict_mode)) { $res=@include $tpl; } else { $res=include $tpl; // for debug } - if ($res) break; + if ($res > 0) break; } } } @@ -4186,16 +4213,25 @@ abstract class CommonObject // Output template part (modules that overwrite templates must declare this into descriptor) // Use global variables + $dateSelector + $seller and $buyer - $dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl')); - foreach($dirtpls as $reldir) + $dirtpls=array_merge($conf->modules_parts['tpl'], array('/core/tpl')); + foreach($dirtpls as $module => $reldir) { - $tpl = dol_buildpath($reldir.'/originproductline.tpl.php'); + if (!empty($module) && empty($conf->$module->enabled)) continue; + + if (!empty($module)) + { + $tpl = dol_buildpath($reldir.'/originproductline.tpl.php'); + } + else + { + $tpl = DOL_DOCUMENT_ROOT.$reldir.'/originproductline.tpl.php'; + } if (empty($conf->file->strict_mode)) { $res=@include $tpl; } else { $res=include $tpl; // for debug } - if ($res) break; + if ($res > 0) break; } } From abc7c2f0f8deead444bc41727cc36099d517a014 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Fri, 24 May 2019 12:33:40 +0200 Subject: [PATCH 2/4] test include return on TRUE --- htdocs/core/class/commonobject.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 22c96f0f589..5034e4c4899 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3733,7 +3733,7 @@ abstract class CommonObject } else { $res=include $tpl; // for debug } - if ($res > 0) break; + if ($res === TRUE) break; } } @@ -3994,7 +3994,7 @@ abstract class CommonObject } else { $res=include $tpl; // for debug } - if ($res > 0) break; + if ($res === TRUE) break; } } @@ -4026,7 +4026,7 @@ abstract class CommonObject } else { $res=include $tpl; // for debug } - if ($res > 0) break; + if ($res === TRUE) break; } } } @@ -4231,7 +4231,7 @@ abstract class CommonObject } else { $res=include $tpl; // for debug } - if ($res > 0) break; + if ($res === TRUE) break; } } From 545cdd07623163eda45df13a92f7ef4a5a16cf9d Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Fri, 24 May 2019 12:54:24 +0200 Subject: [PATCH 3/4] test include return on FALSE --- htdocs/core/class/commonobject.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 5034e4c4899..eae3f566d2f 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3733,7 +3733,7 @@ abstract class CommonObject } else { $res=include $tpl; // for debug } - if ($res === TRUE) break; + if ($res !== FALSE) break; } } @@ -3994,7 +3994,7 @@ abstract class CommonObject } else { $res=include $tpl; // for debug } - if ($res === TRUE) break; + if ($res !== FALSE) break; } } @@ -4026,7 +4026,7 @@ abstract class CommonObject } else { $res=include $tpl; // for debug } - if ($res === TRUE) break; + if ($res !== FALSE) break; } } } @@ -4231,7 +4231,7 @@ abstract class CommonObject } else { $res=include $tpl; // for debug } - if ($res === TRUE) break; + if ($res !== FALSE) break; } } From 83d883c36a9d36c4a687939e04d7686d1bada205 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Fri, 24 May 2019 15:14:34 +0200 Subject: [PATCH 4/4] finally eldy is always right --- htdocs/core/class/commonobject.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index eae3f566d2f..b64ae066cb1 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3733,7 +3733,7 @@ abstract class CommonObject } else { $res=include $tpl; // for debug } - if ($res !== FALSE) break; + if ($res) break; } } @@ -3994,7 +3994,7 @@ abstract class CommonObject } else { $res=include $tpl; // for debug } - if ($res !== FALSE) break; + if ($res) break; } } @@ -4026,7 +4026,7 @@ abstract class CommonObject } else { $res=include $tpl; // for debug } - if ($res !== FALSE) break; + if ($res) break; } } } @@ -4231,7 +4231,7 @@ abstract class CommonObject } else { $res=include $tpl; // for debug } - if ($res !== FALSE) break; + if ($res) break; } }