|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* Copyright (C) 2017 ATM Consulting <[email protected]> |
|
4
|
|
|
* Copyright (C) 2017-2018 Laurent Destailleur <[email protected]> |
|
5
|
|
|
* Copyright (C) 2024 Rafael San José <[email protected]> |
|
6
|
|
|
* |
|
7
|
|
|
* This program is free software; you can redistribute it and/or modify |
|
8
|
|
|
* it under the terms of the GNU General Public License as published by |
|
9
|
|
|
* the Free Software Foundation; either version 3 of the License, or |
|
10
|
|
|
* (at your option) any later version. |
|
11
|
|
|
* |
|
12
|
|
|
* This program is distributed in the hope that it will be useful, |
|
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15
|
|
|
* GNU General Public License for more details. |
|
16
|
|
|
* |
|
17
|
|
|
* You should have received a copy of the GNU General Public License |
|
18
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
namespace DoliModules\BlockedLog\Controller; |
|
22
|
|
|
|
|
23
|
|
|
global $conf; |
|
24
|
|
|
global $db; |
|
25
|
|
|
global $user; |
|
26
|
|
|
global $hookmanager; |
|
27
|
|
|
global $user; |
|
28
|
|
|
global $menumanager; |
|
29
|
|
|
global $langs; |
|
30
|
|
|
global $mysoc; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* \file htdocs/blockedlog/admin/blockedlog.php |
|
34
|
|
|
* \ingroup blockedlog |
|
35
|
|
|
* \brief Page setup for blockedlog module |
|
36
|
|
|
*/ |
|
37
|
|
|
|
|
38
|
|
|
use DoliCore\Base\DolibarrController; |
|
39
|
|
|
|
|
40
|
|
|
// Load Dolibarr environment |
|
41
|
|
|
require BASE_PATH . '/main.inc.php'; |
|
42
|
|
|
require_once BASE_PATH . '/../Dolibarr/Modules/BlockedLog/Lib/BlockedLog.php'; |
|
43
|
|
|
require_once BASE_PATH . '/../Dolibarr/Lib/Admin.php'; |
|
44
|
|
|
|
|
45
|
|
|
|
|
46
|
|
|
class BlockedLogAdminController extends DolibarrController |
|
47
|
|
|
{ |
|
48
|
|
|
public function blockedlog(bool $executeActions = true): bool |
|
49
|
|
|
{ |
|
50
|
|
|
global $conf; |
|
51
|
|
|
global $db; |
|
52
|
|
|
global $user; |
|
53
|
|
|
global $hookmanager; |
|
54
|
|
|
global $user; |
|
55
|
|
|
global $menumanager; |
|
56
|
|
|
global $langs; |
|
57
|
|
|
global $mysoc; |
|
58
|
|
|
|
|
59
|
|
|
// Load translation files required by the page |
|
60
|
|
|
$langs->loadLangs(['admin', 'blockedlog', 'other']); |
|
61
|
|
|
|
|
62
|
|
|
// Access Control |
|
63
|
|
|
if (!$user->admin || empty($conf->blockedlog->enabled)) { |
|
64
|
|
|
accessforbidden(); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
// Get Parameters |
|
68
|
|
|
$action = GETPOST('action', 'aZ09'); |
|
69
|
|
|
$backtopage = GETPOST('backtopage', 'alpha'); |
|
70
|
|
|
$withtab = GETPOSTINT('withtab'); |
|
71
|
|
|
|
|
72
|
|
|
|
|
73
|
|
|
/* |
|
74
|
|
|
* Actions |
|
75
|
|
|
*/ |
|
76
|
|
|
|
|
77
|
|
|
$reg = []; |
|
78
|
|
|
if (preg_match('/set_(.*)/', $action, $reg)) { |
|
79
|
|
|
$code = $reg[1]; |
|
80
|
|
|
$values = GETPOST($code); |
|
81
|
|
|
if (is_array($values)) { |
|
82
|
|
|
$values = implode(',', $values); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
if (dolibarr_set_const($db, $code, $values, 'chaine', 0, '', $conf->entity) > 0) { |
|
86
|
|
|
header("Location: " . $_SERVER['PHP_SELF'] . ($withtab ? '?withtab=' . $withtab : '')); |
|
87
|
|
|
exit; |
|
|
|
|
|
|
88
|
|
|
} else { |
|
89
|
|
|
dol_print_error($db); |
|
90
|
|
|
} |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
if (preg_match('/del_(.*)/', $action, $reg)) { |
|
94
|
|
|
$code = $reg[1]; |
|
95
|
|
|
if (dolibarr_del_const($db, $code, 0) > 0) { |
|
96
|
|
|
header("Location: " . $_SERVER['PHP_SELF'] . ($withtab ? '?withtab=' . $withtab : '')); |
|
97
|
|
|
exit; |
|
|
|
|
|
|
98
|
|
|
} else { |
|
99
|
|
|
dol_print_error($db); |
|
100
|
|
|
} |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
|
|
104
|
|
|
/* |
|
105
|
|
|
* View |
|
106
|
|
|
*/ |
|
107
|
|
|
require_once realpath(BASE_PATH . '/../Dolibarr/Modules/BlockedLog/Views/admin_blocked_log.php'); |
|
108
|
|
|
|
|
109
|
|
|
$db->close(); |
|
110
|
|
|
|
|
111
|
|
|
return true; |
|
112
|
|
|
} |
|
113
|
|
|
} |
|
114
|
|
|
|
For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example: