Skip to content
Permalink
Browse files

Prepare for Dolibarr 11

  • Loading branch information
fappels committed Nov 12, 2019
1 parent 6f263a9 commit b76425247d1ea211318cd9baa965512825f3b777
@@ -23,10 +23,18 @@
*/
// Load Dolibarr environment
if (false === (@include '../../main.inc.php')) { // From htdocs directory
require '../../../main.inc.php'; // From "custom" directory
$custom = true;
}
$res=0;
// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include($_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php");
// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1;
while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; }
if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/main.inc.php");
if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php");
// Try main.inc.php using relative path
if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php");
if (! $res && file_exists("../../../main.inc.php")) $res=@include("../../../main.inc.php");
if (! $res) die("Include of main fails");
require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
dol_include_once("/extdirect/class/extdirect.class.php");
@@ -152,7 +160,7 @@
$title = $langs->trans('DirectConnectSetup');
$tabsTitle = $langs->trans('DirectConnect');
$tabs = array('tab1' => $authentication,'tab2' => $activities);
$head = extdirect_admin_prepare_head($tabs, $custom);
$head = extdirect_admin_prepare_head($tabs, $langs);
llxHeader('', $title);
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
@@ -337,22 +345,20 @@
* @param Array $tabs tab names
* @return array head array with tabs
*/
function extdirect_admin_prepare_head($tabs, $custom)
function extdirect_admin_prepare_head($tabs, $langs)
{
global $conf;
$h = 0;
$head = array();
foreach ($tabs as $key => $value) {
if ($custom) {
$head[$h][0] = DOL_URL_ROOT."/custom/extdirect/admin/extdirect.php?mode=".$value->mode;
} else {
$head[$h][0] = DOL_URL_ROOT."/extdirect/admin/extdirect.php?mode=".$value->mode;
}
$head[$h][0] = dol_buildpath("/extdirect/admin/extdirect.php?mode=".$value->mode, 1);
$head[$h][1] = $value->title;
$head[$h][2] = $key;
$h++;
}
complete_head_from_modules($conf, $langs, $object, $head, $h, 'extdirect');
return $head;
}
@@ -47,7 +47,7 @@ function __construct($login)
global $langs,$db,$user;
if (!empty($login)) {
if ($user->fetch('', $login, '', 1) > 0) {
if (get_class($db) == get_class($login) || $user->id > 0 || $user->fetch('', $login, '', 1) > 0) {
$user->getrights();
$this->_user = $user;
if (isset($this->_user->conf->MAIN_LANG_DEFAULT) && ($this->_user->conf->MAIN_LANG_DEFAULT != 'auto')) {
@@ -353,7 +353,11 @@ function createAction($params)
// prepare fields
$this->prepareFields($param);
// create
if (($result = $this->add($this->_user, $notrigger)) < 0) return ExtDirect::getDolError($result, $this->errors, $this->error);
if (ExtDirect::checkDolVersion(0, '','10.0')) {
if (($result = $this->add($this->_user, $notrigger)) < 0) return ExtDirect::getDolError($result, $this->errors, $this->error);
} else {
if (($result = $this->create($this->_user, $notrigger)) < 0) return ExtDirect::getDolError($result, $this->errors, $this->error);
}
$param->id=$this->id;
$this->_societe->id=$this->socid;
@@ -51,7 +51,7 @@ public function __construct($login)
global $langs,$db,$user;
if (!empty($login)) {
if ($user->fetch('', $login, '', 1)>0) {
if (get_class($db) == get_class($login) || $user->id > 0 || $user->fetch('', $login, '', 1) > 0) {
$user->getrights();
$this->_user = $user; //product.class uses global user
if (isset($this->_user->conf->MAIN_LANG_DEFAULT) && ($this->_user->conf->MAIN_LANG_DEFAULT != 'auto')) {
@@ -50,16 +50,16 @@ public function __construct($login)
global $langs,$db,$user;
if (!empty($login)) {
if (empty($user->id) && $user->fetch('', $login, '', 1)>0) {
if (get_class($db) == get_class($login) || $user->id > 0 || $user->fetch('', $login, '', 1) > 0) {
$user->getrights();
$this->_user = $user; //commande.class uses global user
if (isset($this->_user->conf->MAIN_LANG_DEFAULT) && ($this->_user->conf->MAIN_LANG_DEFAULT != 'auto')) {
$langs->setDefaultLang($this->_user->conf->MAIN_LANG_DEFAULT);
}
$langs->load("orders");
$langs->load("sendings"); // for shipment methods
parent::__construct($db);
}
$this->_user = $user; //commande.class uses global user
if (isset($this->_user->conf->MAIN_LANG_DEFAULT) && ($this->_user->conf->MAIN_LANG_DEFAULT != 'auto')) {
$langs->setDefaultLang($this->_user->conf->MAIN_LANG_DEFAULT);
}
$langs->load("orders");
$langs->load("sendings"); // for shipment methods
parent::__construct($db);
}
}
@@ -64,7 +64,7 @@ public function __construct($login)
global $langs,$db,$user;
if (!empty($login)) {
if ($user->fetch('', $login, '', 1)>0) {
if (get_class($db) == get_class($login) || $user->id > 0 || $user->fetch('', $login, '', 1) > 0) {
$user->getrights();
$this->_user = $user; //commande.class uses global user
if (isset($this->_user->conf->MAIN_LANG_DEFAULT) && ($this->_user->conf->MAIN_LANG_DEFAULT != 'auto')) {
@@ -45,7 +45,7 @@ function __construct($login)
global $user,$db,$langs;
if (!empty($login)) {
if ($user->fetch('', $login, '', 1)>0) {
if (get_class($db) == get_class($login) || $user->id > 0 || $user->fetch('', $login, '', 1) > 0) {
$user->getrights();
$this->_user = $user; //commande.class uses global user
if (isset($this->_user->conf->MAIN_LANG_DEFAULT) && ($this->_user->conf->MAIN_LANG_DEFAULT != 'auto')) {
@@ -51,18 +51,18 @@ public function __construct($login)
global $langs,$user,$db;
if (!empty($login)) {
if (empty($user->id) && $user->fetch('', $login, '', 1)>0) {
if (get_class($db) == get_class($login) || $user->id > 0 || $user->fetch('', $login, '', 1) > 0) {
$user->getrights();
$this->_user = $user; //commande.class uses global user
if (isset($this->_user->conf->MAIN_LANG_DEFAULT) && ($this->_user->conf->MAIN_LANG_DEFAULT != 'auto')) {
$langs->setDefaultLang($this->_user->conf->MAIN_LANG_DEFAULT);
}
$langs->load("sendings");
$langs->load("products");
$langs->load("stocks");
$langs->load("productbatch");
parent::__construct($db);
}
$this->_user = $user; //commande.class uses global user
if (isset($this->_user->conf->MAIN_LANG_DEFAULT) && ($this->_user->conf->MAIN_LANG_DEFAULT != 'auto')) {
$langs->setDefaultLang($this->_user->conf->MAIN_LANG_DEFAULT);
}
$langs->load("sendings");
$langs->load("products");
$langs->load("stocks");
$langs->load("productbatch");
parent::__construct($db);
}
}
@@ -54,7 +54,7 @@ public function __construct($login)
global $langs,$db,$user;
if (!empty($login)) {
if ($user->fetch('', $login, '', 1)>0) {
if (get_class($db) == get_class($login) || $user->id > 0 || $user->fetch('', $login, '', 1) > 0) {
$user->getrights();
$this->_user = $user; //commande.class uses global user
if (isset($this->_user->conf->MAIN_LANG_DEFAULT) && ($this->_user->conf->MAIN_LANG_DEFAULT != 'auto')) {
@@ -47,7 +47,7 @@ public function __construct($login)
global $langs,$user,$db;
if (!empty($login)) {
if ($user->fetch('', $login, '', 1)>0) {
if (get_class($db) == get_class($login) || $user->id > 0 || $user->fetch('', $login, '', 1) > 0) {
$user->getrights();
$this->_user = $user; //commande.class uses global user
if (isset($this->_user->conf->MAIN_LANG_DEFAULT) && ($this->_user->conf->MAIN_LANG_DEFAULT != 'auto')) {
@@ -54,18 +54,18 @@ public function __construct($login)
global $langs,$db,$user,$conf;
if (!empty($login)) {
if (empty($user->id) && $user->fetch('', $login, '', 1) > 0) {
if (get_class($db) == get_class($login) || $user->id > 0 || $user->fetch('', $login, '', 1) > 0) {
$user->getrights();
$this->_user = $user; //product.class uses global user
if (isset($this->_user->conf->MAIN_LANG_DEFAULT) && ($this->_user->conf->MAIN_LANG_DEFAULT != 'auto')) {
$langs->setDefaultLang($this->_user->conf->MAIN_LANG_DEFAULT);
}
$langs->load("products");
$langs->load("stocks");
$langs->load("productbatch");
if (! empty($conf->productbatch->enabled)) $langs->load("productbatch");
parent::__construct($db);
}
$this->_user = $user; //product.class uses global user
if (isset($this->_user->conf->MAIN_LANG_DEFAULT) && ($this->_user->conf->MAIN_LANG_DEFAULT != 'auto')) {
$langs->setDefaultLang($this->_user->conf->MAIN_LANG_DEFAULT);
}
$langs->load("products");
$langs->load("stocks");
$langs->load("productbatch");
if (! empty($conf->productbatch->enabled)) $langs->load("productbatch");
parent::__construct($db);
}
}
@@ -46,17 +46,17 @@ function __construct($login)
global $langs,$user,$db;
if (!empty($login)) {
if (empty($user->id) && $user->fetch('', $login, '', 1) > 0) {
if (get_class($db) == get_class($login) || $user->id > 0 || $user->fetch('', $login, '', 1) > 0) {
$user->getrights();
$this->_user = $user;
if (isset($user->conf->MAIN_LANG_DEFAULT) && ($user->conf->MAIN_LANG_DEFAULT != 'auto')) {
$langs->setDefaultLang($user->conf->MAIN_LANG_DEFAULT);
}
$langs->load("companies");
$langs->load("bills");
$langs->load("dict");
parent::__construct($db);
}
$this->_user = $user;
if (isset($user->conf->MAIN_LANG_DEFAULT) && ($user->conf->MAIN_LANG_DEFAULT != 'auto')) {
$langs->setDefaultLang($user->conf->MAIN_LANG_DEFAULT);
}
$langs->load("companies");
$langs->load("bills");
$langs->load("dict");
parent::__construct($db);
}
}
@@ -496,7 +496,7 @@ public static function checkDolVersion($validate = 0, $minVersion = '', $maxVers
return $dolMajorMinorVersion;
} else {
if (empty($minVersion)) $minVersion = '3.3';
if (empty($maxVersion)) $maxVersion = '10.0'; // debugging version
if (empty($maxVersion)) $maxVersion = '11.0'; // debugging version
if (version_compare($minVersion, $dolMajorMinorVersion, '<=') && version_compare($maxVersion, $dolMajorMinorVersion, '>='))
{
return 1;
@@ -61,7 +61,7 @@ function __construct($db)
// not found (where XXX is value of numeric property 'numero' of module)
$this->description = "Connect to external applications which use Sencha Ext.direct";
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
$this->version = '1.0.52';
$this->version = '1.0.53';
// Key used in llx_const table to save module status enabled/disabled
// (where MYMODULE is value of property name of module in uppercase)
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
@@ -15,6 +15,7 @@
$res=0;
if (! $res && file_exists("../main.inc.php")) $res=@include("../main.inc.php");
if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php");
if (! $res && file_exists("../../../main.inc.php")) $res=@include("../../../main.inc.php");
if (! $res) die("Include of main fails");
require('class/extdirect.class.php');
require('config.php');

0 comments on commit b764252

Please sign in to comment.
You can’t perform that action at this time.