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
|
|
|
* 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 DoliCore\Base\Controller; |
20
|
|
|
|
21
|
|
|
use DoliLib\DolibarrAuth; |
22
|
|
|
|
23
|
|
|
class DolibarrController extends DolibarrPublicController |
24
|
|
|
{ |
25
|
|
|
public $object; |
26
|
|
|
public $username; |
27
|
|
|
|
28
|
|
|
public function __construct() |
29
|
|
|
{ |
30
|
|
|
parent::__construct(); |
31
|
|
|
if (!DolibarrAuth::isLogged()) { |
32
|
|
|
header('Location: ' . BASE_URL . '/index.php?module=Auth&controller=Login'); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
$this->username = DolibarrAuth::$user->login; |
36
|
|
|
|
37
|
|
|
return $this->index(); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
function filterPostInt($field) |
41
|
|
|
{ |
42
|
|
|
return (int)$this->filterPost($field, 'int'); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
function filterPost($field, $filter) |
46
|
|
|
{ |
47
|
|
|
if (!isset($_REQUEST[$field])) { |
48
|
|
|
return $this->object->$field ?? false; |
49
|
|
|
} |
50
|
|
|
return GETPOST($field, $filter); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function index(bool $executeActions = true): bool |
54
|
|
|
{ |
55
|
|
|
if (method_exists($this, 'loadRecord') && !$this->loadRecord()) { |
56
|
|
|
return false; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
if (method_exists($this, 'loadPost') && !$this->loadPost()) { |
60
|
|
|
return false; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
if (!parent::index($executeActions)) { |
64
|
|
|
return $this->action === null; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
return true; |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|