dolibarr 25.0.0-alpha
actions_addbox.inc.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2026 Frédéric France <frederic.france@free.fr>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 * or see https://www.gnu.org/
17 */
18
32if (GETPOST('addbox')) {
33 require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php';
34
35 $zone = GETPOSTINT('areacode');
36 $boxcombo = GETPOSTINT('boxcombo');
37
38 // Current order of boxes, format is 'A:12,34,-B:56,' (see FormOther::getBoxesArea())
39 $boxorder = GETPOST('boxorder', 'alphanohtml');
40 if (!preg_match('/^[A-Z]:[0-9,]*(-[A-Z]:[0-9,]*)*$/', $boxorder)) {
41 $boxorder = 'A:';
42 }
43
44 if ($boxcombo > 0) {
45 // Append the new box at the end of the last column
46 if (!preg_match('/[:,]$/', $boxorder)) {
47 $boxorder .= ',';
48 }
49 $boxorder .= $boxcombo;
50
51 // The layout saved is always the one of the logged user, whatever the posted userid
52 $result = InfoBox::saveboxorder($db, $zone, $boxorder, $user->id);
53 if ($result > 0) {
54 setEventMessages($langs->trans("BoxAdded"), null);
55 }
56 }
57}
static saveboxorder($dbs, $zone, $boxorder, $userid=0)
Save order of boxes for area and user.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.