dolibarr 24.0.0-beta
arrayfield_object_position_fields.tpl.php
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
17// This tpl file is included into the init part of pages, so before action.
18// So no output must be done.
19// Used to modify fields positions according to user parameters
20
29'
30@phan-var-force string|array<string|int, mixed> $contextpage
31@phan-var-force array<string,array{label:string,checked?:string,position?:int,help?:string,enabled?:string}> $arrayfields
32';
33
34// Protection to avoid direct call of template
35if (empty($user) || !is_object($user)) {
36 print "Error, template page can't be called as URL";
37 exit(1);
38}
39
40$tmpvar = "MAIN_POSITIONFIELDS_" . $contextpage; // To get list of saved position fields to show
41if (!empty($user->conf->$tmpvar)) { // A list of fields was already customized for user
42 $tmparray = dolExplodeIntoArray($user->conf->$tmpvar, ',', ':');
43 foreach ($arrayfields as $key => $val) {
44 if (isset($tmparray[$key])) {
45 $arrayfields[$key]['position'] = $tmparray[$key];
46 $object->fields[explode('.', $key)[1]]['position'] = $tmparray[$key];
47 }
48 }
49}
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
dolExplodeIntoArray($string, $delimiter=';', $kv='=')
Split a string with 2 keys into key array.