dolibarr 21.0.0-alpha
extrafields_list_array_fields.tpl.php
1<?php
2
3// This tpl file is included into the init part of pages, so before action.
4// So no output must be done.
5
6// TODO: Note, supposing $arrayfields is already set
7'
8 @phan-var-force array $arrayfields;
9';
10
11// Protection to avoid direct call of template
12if (empty($conf) || !is_object($conf)) {
13 print "Error, template page can't be called as URL";
14 exit(1);
15}
16
17if (empty($extrafieldsobjectkey) && is_object($object)) {
18 $extrafieldsobjectkey = $object->table_element;
19}
20
21// Loop to show all columns of extrafields from $obj, $extrafields and $db
22if (!empty($extrafieldsobjectkey)) { // $extrafieldsobject is the $object->table_element like 'societe', 'socpeople', ...
23 if (isset($extrafields->attributes[$extrafieldsobjectkey]['label']) && is_array($extrafields->attributes[$extrafieldsobjectkey]['label']) && count($extrafields->attributes[$extrafieldsobjectkey]['label']) > 0) {
24 if (empty($extrafieldsobjectprefix)) {
25 $extrafieldsobjectprefix = 'ef.';
26 }
27 foreach ($extrafields->attributes[$extrafieldsobjectkey]['label'] as $key => $val) {
28 $enabled = true;
29 if (!empty($extrafields->attributes[$extrafieldsobjectkey]['enabled'][$key])) {
30 // An enablement condition exist, it is evaluated.
31 $enabled = dol_eval($extrafields->attributes[$extrafieldsobjectkey]['enabled'][$key], 1);
32 }
33 if (!empty($extrafields->attributes[$extrafieldsobjectkey]['list'][$key]) && $enabled ) {
34 $arrayfields[$extrafieldsobjectprefix.$key] = array(
35 'label' => $extrafields->attributes[$extrafieldsobjectkey]['label'][$key],
36 'type' => $extrafields->attributes[$extrafieldsobjectkey]['type'][$key],
37 'checked' => (((int) dol_eval($extrafields->attributes[$extrafieldsobjectkey]['list'][$key], 1, 1, '1') <= 0) ? 0 : 1),
38 'position' => $extrafields->attributes[$extrafieldsobjectkey]['pos'][$key],
39 'enabled' => (abs((int) dol_eval($extrafields->attributes[$extrafieldsobjectkey]['list'][$key], 1)) != 3 && (int) dol_eval($extrafields->attributes[$extrafieldsobjectkey]['perms'][$key], 1, 1, '1')),
40 'langfile' => $extrafields->attributes[$extrafieldsobjectkey]['langfile'][$key],
41 'help' => $extrafields->attributes[$extrafieldsobjectkey]['help'][$key],
42 );
43 }
44 }
45 }
46}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.