Passed
Push — main ( 875825...95c1dc )
by Rafael
48:39
created

BookMarksAdminBookmarkController   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 26
c 1
b 0
f 0
dl 0
loc 48
rs 10
wmc 5

1 Method

Rating   Name   Duplication   Size   Complexity  
A index() 0 45 5
1
<?php
2
3
/* Copyright (C) 2004       Rodolphe Quiedeville    <[email protected]>
4
 * Copyright (C) 2005-2009  Laurent Destailleur     <[email protected]>
5
 * Copyright (C) 2011-2012  Juanjo Menent           <[email protected]>
6
 * Copyright (C) 2024       Rafael San José         <[email protected]>
7
 *
8
 * This program is free software; you can redistribute it and/or modify
9
 * it under the terms of the GNU General Public License as published by
10
 * the Free Software Foundation; either version 3 of the License, or
11
 * (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20
 */
21
22
namespace DoliModules\BookMarks\Controller;
23
24
global $conf;
25
global $db;
26
global $user;
27
global $hookmanager;
28
global $user;
29
global $menumanager;
30
global $langs;
31
global $mysoc;
32
33
use DoliCore\Base\DolibarrController;
34
35
36
/**     \file       htdocs/bookmarks/admin/bookmark.php
37
 *      \ingroup    bookmark
38
 *      \brief      Page to setup bookmark module
39
 */
40
41
// Load Dolibarr environment
42
require BASE_PATH . '/main.inc.php';
43
require_once BASE_PATH . '/../Dolibarr/Lib/Admin.php';
44
45
class BookMarksAdminBookmarkController extends DolibarrController
46
{
47
48
    public function index(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
58
// Load translation files required by the page
59
        $langs->load("admin");
60
61
        if (!$user->admin) {
62
            accessforbidden();
63
        }
64
65
        $action = GETPOST('action', 'aZ09');
66
67
        if ($action == 'setvalue') {
68
            $showmenu = GETPOST('BOOKMARKS_SHOW_IN_MENU', 'alpha');
69
            $res = dolibarr_set_const($db, "BOOKMARKS_SHOW_IN_MENU", $showmenu, 'chaine', 0, '', $conf->entity);
70
71
            if (!($res > 0)) {
72
                $error++;
73
            }
74
75
            if (!$error) {
76
                $db->commit();
77
                setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
78
            } else {
79
                $db->rollback();
80
                setEventMessages($langs->trans("Error"), null, 'errors');
81
            }
82
        }
83
84
85
        /*
86
         * View
87
         */
88
        require_once realpath(BASE_PATH . '/../Dolibarr/Modules/BookMarks/Views/admin_bookmark.php');
89
90
        $db->close();
91
92
        return true;
93
    }
94
}
95