Passed
Push — main ( 9a81fe...875825 )
by Rafael
41:55
created

BookCalAdminCalendarExtrafieldsController   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 24
dl 0
loc 48
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A index() 0 45 3
1
<?php
2
3
/* Copyright (C) 2001-2002  Rodolphe Quiedeville    <[email protected]>
4
 * Copyright (C) 2003		Jean-Louis Bergamo		<[email protected]>
5
 * Copyright (C) 2004-2011	Laurent Destailleur		<[email protected]>
6
 * Copyright (C) 2012		Regis Houssin			<[email protected]>
7
 * Copyright (C) 2014		Florian Henry			<[email protected]>
8
 * Copyright (C) 2015		Jean-François Ferry		<[email protected]>
9
 * Copyright (C) 2024       Frédéric France         <[email protected]>
10
 * Copyright (C) 2024       Rafael San José         <[email protected]>
11
 *
12
 * This program is free software; you can redistribute it and/or modify
13
 * it under the terms of the GNU General Public License as published by
14
 * the Free Software Foundation; either version 3 of the License, or
15
 * (at your option) any later version.
16
 *
17
 * This program is distributed in the hope that it will be useful,
18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
 * GNU General Public License for more details.
21
 *
22
 * You should have received a copy of the GNU General Public License
23
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
24
 */
25
26
namespace DoliModules\BookCal\Controller;
27
28
global $conf;
29
global $db;
30
global $user;
31
global $hookmanager;
32
global $user;
33
global $menumanager;
34
global $langs;
35
global $mysoc;
36
37
use DoliCore\Base\DolibarrController;
38
use DoliCore\Form\Form;
39
use DoliCore\Lib\ExtraFields;
40
41
/**
42
 *   \file       htdocs/bookcal/admin/calendar_extrafields.php
43
 *   \ingroup    bookcal
44
 *   \brief      Page to setup extra fields of calendar
45
 */
46
47
// Load Dolibarr environment
48
49
require BASE_PATH . '/main.inc.php';
50
require_once BASE_PATH . '/../Dolibarr/Modules/BookCal/Lib/BookCal.php';
51
52
class BookCalAdminCalendarExtrafieldsController extends DolibarrController
53
{
54
55
    public function index(bool $executeActions = true): bool
56
    {
57
        global $conf;
58
        global $db;
59
        global $user;
60
        global $hookmanager;
61
        global $user;
62
        global $menumanager;
63
        global $langs;
64
65
66
// Load translation files required by the page
67
        $langs->loadLangs(['agenda', 'admin']);
68
69
        $extrafields = new ExtraFields($db);
70
        $form = new Form($db);
71
72
// List of supported format
73
        $tmptype2label = ExtraFields::$type2label;
74
        $type2label = [''];
75
        foreach ($tmptype2label as $key => $val) {
76
            $type2label[$key] = $langs->transnoentitiesnoconv($val);
77
        }
78
79
        $action = GETPOST('action', 'aZ09');
80
        $attrname = GETPOST('attrname', 'alpha');
81
        $elementtype = 'bookcal_calendar'; //Must be the $table_element of the class that manage extrafield
82
83
        if (!$user->admin) {
84
            accessforbidden();
85
        }
86
87
        /*
88
         * Actions
89
         */
90
        require DOL_DOCUMENT_ROOT . '/core/actions_extrafields.inc.php';
91
92
        /*
93
         * View
94
         */
95
        require_once realpath(BASE_PATH . '/../Dolibarr/Modules/BookCal/Views/admin_calendar_extrafields.php');
96
97
        $db->close();
98
99
        return true;
100
    }
101
}
102