dolibarr 19.0.3
mymodule.js.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) ---Put here your own copyright and developer email---
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 *
17 * Library javascript to enable Browser notifications
18 */
19
20if (!defined('NOREQUIREUSER')) {
21 define('NOREQUIREUSER', '1');
22}
23if (!defined('NOREQUIREDB')) {
24 define('NOREQUIREDB', '1');
25}
26if (!defined('NOREQUIRESOC')) {
27 define('NOREQUIRESOC', '1');
28}
29if (!defined('NOREQUIRETRAN')) {
30 define('NOREQUIRETRAN', '1');
31}
32if (!defined('NOCSRFCHECK')) {
33 define('NOCSRFCHECK', 1);
34}
35if (!defined('NOTOKENRENEWAL')) {
36 define('NOTOKENRENEWAL', 1);
37}
38if (!defined('NOLOGIN')) {
39 define('NOLOGIN', 1);
40}
41if (!defined('NOREQUIREMENU')) {
42 define('NOREQUIREMENU', 1);
43}
44if (!defined('NOREQUIREHTML')) {
45 define('NOREQUIREHTML', 1);
46}
47if (!defined('NOREQUIREAJAX')) {
48 define('NOREQUIREAJAX', '1');
49}
50
51
58// Load Dolibarr environment
59$res = 0;
60// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
61if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) {
62 $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
63}
64// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
65$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
66while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
67 $i--;
68 $j--;
69}
70if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) {
71 $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
72}
73if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/../main.inc.php")) {
74 $res = @include substr($tmp, 0, ($i + 1))."/../main.inc.php";
75}
76// Try main.inc.php using relative path
77if (!$res && file_exists("../../main.inc.php")) {
78 $res = @include "../../main.inc.php";
79}
80if (!$res && file_exists("../../../main.inc.php")) {
81 $res = @include "../../../main.inc.php";
82}
83if (!$res) {
84 die("Include of main fails");
85}
86
87// Define js type
88header('Content-Type: application/javascript');
89// Important: Following code is to cache this file to avoid page request by browser at each Dolibarr page access.
90// You can use CTRL+F5 to refresh your browser cache.
91if (empty($dolibarr_nocache)) {
92 header('Cache-Control: max-age=3600, public, must-revalidate');
93} else {
94 header('Cache-Control: no-cache');
95}
96?>
97
98/* Javascript library of module MyModule */
99
100