1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* Copyright (C) 2024 Rafael San José <[email protected]> |
4
|
|
|
* |
5
|
|
|
* This program is free software; you can redistribute it and/or modify |
6
|
|
|
* it under the terms of the GNU General Public License as published by |
7
|
|
|
* the Free Software Foundation; either version 3 of the License, or |
8
|
|
|
* (at your option) any later version. |
9
|
|
|
* |
10
|
|
|
* This program is distributed in the hope that it will be useful, |
11
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
12
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13
|
|
|
* GNU General Public License for more details. |
14
|
|
|
* |
15
|
|
|
* You should have received a copy of the GNU General Public License |
16
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
namespace Dolibarr\Core\Base; |
20
|
|
|
|
21
|
|
|
use Alxarafe\Base\Controller\GenericController; |
22
|
|
|
|
23
|
|
|
global $conf; |
24
|
|
|
global $db; |
25
|
|
|
global $user; |
26
|
|
|
global $hookmanager; |
27
|
|
|
global $menumanager; |
28
|
|
|
global $langs; |
29
|
|
|
global $mysoc; |
30
|
|
|
|
31
|
|
|
// Load Dolibarr environment |
32
|
|
|
require constant('DOL_DOCUMENT_ROOT') . '/main.inc.php'; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Class DolibarrGenericController. The generic controller contains what is necessary for any controller |
36
|
|
|
* |
37
|
|
|
* This class is only needed for compatibility with Dolibarr. |
38
|
|
|
* |
39
|
|
|
* @package DoliCore\Base |
40
|
|
|
*/ |
41
|
|
|
abstract class DolibarrGenericController extends GenericController |
42
|
|
|
{ |
43
|
|
|
public $conf; |
44
|
|
|
public $db; |
45
|
|
|
public $user; |
46
|
|
|
public $hookmanager; |
47
|
|
|
public $menumanager; |
48
|
|
|
public $langs; |
49
|
|
|
public $mysoc; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* GenericController constructor. |
53
|
|
|
*/ |
54
|
|
|
public function __construct() |
55
|
|
|
{ |
56
|
|
|
parent::__construct(); |
57
|
|
|
|
58
|
|
|
global $conf; |
59
|
|
|
global $db; |
60
|
|
|
global $hookmanager; |
61
|
|
|
global $user; |
62
|
|
|
global $menumanager; |
63
|
|
|
global $langs; |
64
|
|
|
global $mysoc; |
65
|
|
|
|
66
|
|
|
$this->conf = $conf; |
67
|
|
|
$this->db = $db; |
68
|
|
|
$this->hookmanager = $hookmanager; |
69
|
|
|
$this->user = $user; |
70
|
|
|
$this->menumanager = $menumanager; |
71
|
|
|
$this->langs = $langs; |
72
|
|
|
$this->mysoc = $mysoc; |
73
|
|
|
|
74
|
|
|
$method = filter_input(INPUT_GET, METHOD_VAR) ?? METHOD_DEFAULT_VALUE; |
75
|
|
|
if (method_exists($this, $method)) { |
76
|
|
|
return $this->{$method}(); |
77
|
|
|
} |
78
|
|
|
return true; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Returns the generic url of the controller; |
83
|
|
|
* |
84
|
|
|
* @param $full |
85
|
|
|
* |
86
|
|
|
* @return string |
87
|
|
|
*/ |
88
|
|
|
public static function url($full = false) |
89
|
|
|
{ |
90
|
|
|
$url = ''; |
91
|
|
|
|
92
|
|
|
if ($full) { |
93
|
|
|
$url .= BASE_URL . '/index.php'; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
$url .= |
97
|
|
|
'?' . MODULE_NAME_VAR . '=' . filter_input(INPUT_GET, MODULE_NAME_VAR) . |
98
|
|
|
'&' . CONTROLLER_VAR . '=' . filter_input(INPUT_GET, CONTROLLER_VAR); |
99
|
|
|
|
100
|
|
|
$method = filter_input(INPUT_GET, METHOD_VAR); |
101
|
|
|
if (isset($method)) { |
102
|
|
|
$url .= '&' . METHOD_VAR . '=' . $method; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
return $url; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
public function syslog($message, $level = LOG_DEBUG) |
109
|
|
|
{ |
110
|
|
|
if (!defined('LOG_DEBUG')) { |
111
|
|
|
define('LOG_DEBUG', 6); |
112
|
|
|
} |
113
|
|
|
dol_syslog($message, $level); |
114
|
|
|
} |
115
|
|
|
} |
116
|
|
|
|