dolibarr 24.0.0-beta
changepositionfields.php
Go to the documentation of this file.
1<?php
2/*
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <https://www.gnu.org/licenses/>.
15 */
16
22if (!defined('NOTOKENRENEWAL')) {
23 define('NOTOKENRENEWAL', '1'); // Disables token renewal
24}
25if (!defined('NOREQUIREMENU')) {
26 define('NOREQUIREMENU', '1');
27}
28if (!defined('NOREQUIREHTML')) {
29 define('NOREQUIREHTML', '1');
30}
31if (!defined('NOREQUIREAJAX')) {
32 define('NOREQUIREAJAX', '1');
33}
34if (!defined('NOREQUIRESOC')) {
35 define('NOREQUIRESOC', '1');
36}
37if (!defined('NOREQUIRETRAN')) {
38 define('NOREQUIRETRAN', '1');
39}
40if (!defined('CSRFCHECK_WITH_TOKEN')) {
41 define('CSRFCHECK_WITH_TOKEN', '1'); // Token is required even in GET mode
42}
43
44// Load Dolibarr environment
45require '../../main.inc.php';
46
55$action = GETPOST('action', 'aZ09'); // set or del
56$contextpage = GETPOST('contextpage');
57$postitionfields = GETPOST("positionfields", "array");
58$userid = GETPOSTINT('userid');
59
60// Security check
61if ($userid != $user->id) {
62 httponly_accessforbidden('Bad userid parameter. Must match logged user.');
63}
64
65
66/*
67 * Actions
68 */
69
70// Registering the new value of constant
71if (!empty($action) && !empty($contextpage)) {
72 if ($action == "listafterchangingpositionfields") { // Test on permission not required here. Done in security check
73 dol_syslog("Ajax changepositionfields contextpage=".$contextpage." postitionfields=".$postitionfields." userid=".$userid, LOG_DEBUG);
74 $tabparam = array();
75 if (!empty($postitionfields)) {
76 $position = "";
77 foreach ($postitionfields as $pos => $field) {
78 $position .= ($pos != 0 ? "," : "").$field.":".$pos;
79 }
80 $tabparam["MAIN_POSITIONFIELDS_".$contextpage] = $position;
81 } else {
82 $tabparam["MAIN_POSITIONFIELDS_".$contextpage] = '';
83 }
84 include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
85
86 $result = dol_set_user_param($db, $conf, $user, $tabparam);
87 }
88} else {
89 httponly_accessforbidden('Param action and contextpage are required', 403);
90}
91
92
93/*
94 * View
95 */
96
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
dol_set_user_param($db, $conf, &$user, $tab, $entity=-1)
Save personal parameter.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
httponly_accessforbidden($message='1', $http_response_code=403, $stringalreadysanitized=0)
Show a message to say access is forbidden and stop program.