From ccd20d979f6b3ab6cf25c97f33c2eb4d6fc785d1 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@destailleur.fr>
Date: Fri, 14 Jul 2017 03:09:58 +0200
Subject: [PATCH] Fix template

---
 htdocs/modulebuilder/template/scripts/myobject.php | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/htdocs/modulebuilder/template/scripts/myobject.php b/htdocs/modulebuilder/template/scripts/myobject.php
index f83a808a0b9..1b22500f2c6 100644
--- a/htdocs/modulebuilder/template/scripts/myobject.php
+++ b/htdocs/modulebuilder/template/scripts/myobject.php
@@ -43,7 +43,11 @@ $error=0;
 define('EVEN_IF_ONLY_LOGIN_ALLOWED',1);		// Set this define to 0 if you want to lock your script when dolibarr setup is "locked to admin user only".
 
 // Include and load Dolibarr environment variables
-require_once($path."../../htdocs/master.inc.php");
+if (! $res && file_exists($path."master.inc.php")) $res=@include($path."master.inc.php");
+if (! $res && file_exists($path."../master.inc.php")) $res=@include($path."../master.inc.php");
+if (! $res && file_exists($path."../../master.inc.php")) $res=@include($path."../../master.inc.php");
+if (! $res && file_exists($path."../../../master.inc.php")) $res=@include($path."../../../master.inc.php");
+if (! $res) die("Include of master fails");
 // After this $db, $mysoc, $langs, $conf and $hookmanager are defined (Opened $db handler to database will be closed at end of file).
 // $user is created but empty.
 
-- 
GitLab