forked from ATM-Consulting/dolibarr_module_ship2bill
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.php
executable file
·57 lines (46 loc) · 1.49 KB
/
config.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
$res = 0;
// Try main.inc.php using relative path
if (!$res && file_exists("../main.inc.php")) {
$res = @include __DIR__ . "/../main.inc.php";
}
if (!$res && file_exists("../../main.inc.php")) {
$res = @include __DIR__ . "/../../main.inc.php";
}
if (!$res && file_exists("../../../main.inc.php")) {
$res = @include __DIR__ . "/../../../main.inc.php";
}
if (!$res) {
die("Include of main fails");
}
if(!defined('INC_FROM_CRON_SCRIPT') && !defined('INC_FROM_DOLIBARR')) {
if(!class_exists('modShip2bill')) dol_include_once('/ship2bill/core/modules/modShip2bill.class.php');
checkVersion($db, 'modShip2bill');
}
//Fonction reprise d'abricot, car module fonctionnant sans abricot
/**
* @param DoliDB $DoliDb
* @param string $moduleName
*/
function checkVersion(&$DoliDb, $moduleName) {
global $conf;
if(class_exists($moduleName)) {
$conf_name = 'ATM_MODULE_VERSION_'.strtoupper($moduleName);
$mod = new $moduleName($DoliDb);
if(!empty($mod->version)) {
$version = $mod->version;
if(versionXY($conf->global->$conf_name) != versionXY($version)) {
$message = "Your module wasn't updated (v".$conf->global->$conf_name." != ".$version."). Please reload it or launch the update of database script";
accessforbidden($message);
}
}
}
}
/**
* @param string $version A version number in the form X.Y.Z (ex: 1.21.9)
*
* @return string The same version number with only X.Y (ex: 1.21)
*/
function versionXY($version) {
return preg_replace('/^(\d+\.\d+)(\.\d+)?$/', '$1', $version);
}