dolibarr 18.0.6
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--; $j--;
68}
69if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) {
70 $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
71}
72if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/../main.inc.php")) {
73 $res = @include substr($tmp, 0, ($i + 1))."/../main.inc.php";
74}
75// Try main.inc.php using relative path
76if (!$res && file_exists("../../main.inc.php")) {
77 $res = @include "../../main.inc.php";
78}
79if (!$res && file_exists("../../../main.inc.php")) {
80 $res = @include "../../../main.inc.php";
81}
82if (!$res) {
83 die("Include of main fails");
84}
85
86// Define js type
87header('Content-Type: application/javascript');
88// Important: Following code is to cache this file to avoid page request by browser at each Dolibarr page access.
89// You can use CTRL+F5 to refresh your browser cache.
90if (empty($dolibarr_nocache)) {
91 header('Cache-Control: max-age=3600, public, must-revalidate');
92} else {
93 header('Cache-Control: no-cache');
94}
95?>
96
97/* Javascript library of module MyModule */
98
99