2
0
forked from Wavyzz/dolibarr

FIX #4597 PHP 7 Uniform Variable Syntax

PHP7 compatibility with the new Uniform Variable Syntax.
This change is compatible with both PHP 5 and PHP 7.
See: https://wiki.php.net/rfc/uniform_variable_syntax#backward_incompatible_changes
This commit is contained in:
Raphaël Doursenaud
2016-02-11 20:01:51 +01:00
parent 51cc252d4a
commit d038ca1875
8 changed files with 107 additions and 100 deletions

View File

@@ -3,6 +3,7 @@
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Simon Tosser <simon@kornog-computing.com> * Copyright (C) 2005 Simon Tosser <simon@kornog-computing.com>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -158,7 +159,7 @@ if ($action == 'edit')
foreach($delays as $delay) foreach($delays as $delay)
{ {
$var=!$var; $var=!$var;
$value=(! empty($conf->global->$delay['code'])?$conf->global->$delay['code']:0); $value=(! empty($conf->global->{$delay['code']})?$conf->global->{$delay['code']}:0);
print '<tr '.$bc[$var].'>'; print '<tr '.$bc[$var].'>';
print '<td width="20px">'.img_object('',$delay['img']).'</td>'; print '<td width="20px">'.img_object('',$delay['img']).'</td>';
print '<td>'.$langs->trans('Delays_'.$delay['code']).'</td><td>'; print '<td>'.$langs->trans('Delays_'.$delay['code']).'</td><td>';
@@ -205,7 +206,7 @@ else
foreach($delays as $delay) foreach($delays as $delay)
{ {
$var=!$var; $var=!$var;
$value=(! empty($conf->global->$delay['code'])?$conf->global->$delay['code']:0); $value=(! empty($conf->global->{$delay['code']})?$conf->global->{$delay['code']}:0);
print '<tr '.$bc[$var].'>'; print '<tr '.$bc[$var].'>';
print '<td width="20px">'.img_object('',$delay['img']).'</td>'; print '<td width="20px">'.img_object('',$delay['img']).'</td>';
print '<td>'.$langs->trans('Delays_'.$delay['code']).'</td>'; print '<td>'.$langs->trans('Delays_'.$delay['code']).'</td>';

View File

@@ -10,6 +10,7 @@
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@ltairis.fr> * Copyright (C) 2012 Christophe Battarel <christophe.battarel@ltairis.fr>
* Copyright (C) 2011-2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2011-2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2015 Ferran Marcet <fmarcet@2byte.es> * Copyright (C) 2015 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -1146,7 +1147,7 @@ if ($id)
{ {
$showfield=1; $showfield=1;
$align="left"; $align="left";
$valuetoshow=$obj->$fieldlist[$field]; $valuetoshow=$obj->{$fieldlist[$field]};
if ($value == 'type_template') if ($value == 'type_template')
{ {
$valuetoshow = isset($elementList[$valuetoshow])?$elementList[$valuetoshow]:$valuetoshow; $valuetoshow = isset($elementList[$valuetoshow])?$elementList[$valuetoshow]:$valuetoshow;
@@ -1183,77 +1184,77 @@ if ($id)
else if ($fieldlist[$field]=='libelle_facture') { else if ($fieldlist[$field]=='libelle_facture') {
$langs->load("bills"); $langs->load("bills");
$key=$langs->trans("PaymentCondition".strtoupper($obj->code)); $key=$langs->trans("PaymentCondition".strtoupper($obj->code));
$valuetoshow=($obj->code && $key != "PaymentCondition".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); $valuetoshow=($obj->code && $key != "PaymentCondition".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]});
$valuetoshow=nl2br($valuetoshow); $valuetoshow=nl2br($valuetoshow);
} }
else if ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_country') { else if ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_country') {
$key=$langs->trans("Country".strtoupper($obj->code)); $key=$langs->trans("Country".strtoupper($obj->code));
$valuetoshow=($obj->code && $key != "Country".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); $valuetoshow=($obj->code && $key != "Country".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]});
} }
else if ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_availability') { else if ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_availability') {
$langs->load("propal"); $langs->load("propal");
$key=$langs->trans("AvailabilityType".strtoupper($obj->code)); $key=$langs->trans("AvailabilityType".strtoupper($obj->code));
$valuetoshow=($obj->code && $key != "AvailabilityType".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); $valuetoshow=($obj->code && $key != "AvailabilityType".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]});
} }
else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_actioncomm') { else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_actioncomm') {
$key=$langs->trans("Action".strtoupper($obj->code)); $key=$langs->trans("Action".strtoupper($obj->code));
$valuetoshow=($obj->code && $key != "Action".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); $valuetoshow=($obj->code && $key != "Action".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]});
} }
else if (! empty($obj->code_iso) && $fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_currencies') { else if (! empty($obj->code_iso) && $fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_currencies') {
$key=$langs->trans("Currency".strtoupper($obj->code_iso)); $key=$langs->trans("Currency".strtoupper($obj->code_iso));
$valuetoshow=($obj->code_iso && $key != "Currency".strtoupper($obj->code_iso)?$key:$obj->$fieldlist[$field]); $valuetoshow=($obj->code_iso && $key != "Currency".strtoupper($obj->code_iso)?$key:$obj->{$fieldlist[$field]});
} }
else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_typent') { else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_typent') {
$key=$langs->trans(strtoupper($obj->code)); $key=$langs->trans(strtoupper($obj->code));
$valuetoshow=($key != strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); $valuetoshow=($key != strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]});
} }
else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_prospectlevel') { else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_prospectlevel') {
$key=$langs->trans(strtoupper($obj->code)); $key=$langs->trans(strtoupper($obj->code));
$valuetoshow=($key != strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); $valuetoshow=($key != strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]});
} }
else if ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_civility') { else if ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_civility') {
$key=$langs->trans("Civility".strtoupper($obj->code)); $key=$langs->trans("Civility".strtoupper($obj->code));
$valuetoshow=($obj->code && $key != "Civility".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); $valuetoshow=($obj->code && $key != "Civility".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]});
} }
else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_type_contact') { else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_type_contact') {
$langs->load('agenda'); $langs->load('agenda');
$key=$langs->trans("TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code)); $key=$langs->trans("TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code));
$valuetoshow=($obj->code && $key != "TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); $valuetoshow=($obj->code && $key != "TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]});
} }
else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_payment_term') { else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_payment_term') {
$langs->load("bills"); $langs->load("bills");
$key=$langs->trans("PaymentConditionShort".strtoupper($obj->code)); $key=$langs->trans("PaymentConditionShort".strtoupper($obj->code));
$valuetoshow=($obj->code && $key != "PaymentConditionShort".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); $valuetoshow=($obj->code && $key != "PaymentConditionShort".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]});
} }
else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_paiement') { else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_paiement') {
$langs->load("bills"); $langs->load("bills");
$key=$langs->trans("PaymentType".strtoupper($obj->code)); $key=$langs->trans("PaymentType".strtoupper($obj->code));
$valuetoshow=($obj->code && $key != "PaymentType".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); $valuetoshow=($obj->code && $key != "PaymentType".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]});
} }
else if ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_input_reason') { else if ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_input_reason') {
$key=$langs->trans("DemandReasonType".strtoupper($obj->code)); $key=$langs->trans("DemandReasonType".strtoupper($obj->code));
$valuetoshow=($obj->code && $key != "DemandReasonType".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); $valuetoshow=($obj->code && $key != "DemandReasonType".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]});
} }
else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_input_method') { else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_input_method') {
$langs->load("orders"); $langs->load("orders");
$key=$langs->trans($obj->code); $key=$langs->trans($obj->code);
$valuetoshow=($obj->code && $key != $obj->code)?$key:$obj->$fieldlist[$field]; $valuetoshow=($obj->code && $key != $obj->code)?$key:$obj->{$fieldlist[$field]};
} }
else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_shipment_mode') { else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_shipment_mode') {
$langs->load("sendings"); $langs->load("sendings");
$key=$langs->trans("SendingMethod".strtoupper($obj->code)); $key=$langs->trans("SendingMethod".strtoupper($obj->code));
$valuetoshow=($obj->code && $key != "SendingMethod".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); $valuetoshow=($obj->code && $key != "SendingMethod".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]});
} }
else if ($fieldlist[$field] == 'libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_paper_format') else if ($fieldlist[$field] == 'libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_paper_format')
{ {
$key = $langs->trans('PaperFormat'.strtoupper($obj->code)); $key = $langs->trans('PaperFormat'.strtoupper($obj->code));
$valuetoshow = ($obj->code && $key != 'PaperFormat'.strtoupper($obj->code) ? $key : $obj->$fieldlist[$field]); $valuetoshow = ($obj->code && $key != 'PaperFormat'.strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]});
} }
else if ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_type_fees') else if ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_type_fees')
{ {
$langs->load('trips'); $langs->load('trips');
$key = $langs->trans(strtoupper($obj->code)); $key = $langs->trans(strtoupper($obj->code));
$valuetoshow = ($obj->code && $key != strtoupper($obj->code) ? $key : $obj->$fieldlist[$field]); $valuetoshow = ($obj->code && $key != strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]});
} }
else if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') { else if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') {
$showfield=0; $showfield=0;
@@ -1263,16 +1264,16 @@ if ($id)
} }
else if ($fieldlist[$field]=='label' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_units') { else if ($fieldlist[$field]=='label' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_units') {
$langs->load("products"); $langs->load("products");
$valuetoshow=$langs->trans($obj->$fieldlist[$field]); $valuetoshow=$langs->trans($obj->{$fieldlist[$field]});
} }
else if ($fieldlist[$field]=='short_label' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_units') { else if ($fieldlist[$field]=='short_label' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_units') {
$langs->load("products"); $langs->load("products");
$valuetoshow = $langs->trans($obj->$fieldlist[$field]); $valuetoshow = $langs->trans($obj->{$fieldlist[$field]});
} }
else if (($fieldlist[$field] == 'unit') && ($tabname[$id] == MAIN_DB_PREFIX.'c_paper_format')) else if (($fieldlist[$field] == 'unit') && ($tabname[$id] == MAIN_DB_PREFIX.'c_paper_format'))
{ {
$key = $langs->trans('SizeUnit'.strtolower($obj->unit)); $key = $langs->trans('SizeUnit'.strtolower($obj->unit));
$valuetoshow = ($obj->code && $key != 'SizeUnit'.strtolower($obj->unit) ? $key : $obj->$fieldlist[$field]); $valuetoshow = ($obj->code && $key != 'SizeUnit'.strtolower($obj->unit) ? $key : $obj->{$fieldlist[$field]});
} }
else if ($fieldlist[$field]=='localtax1_type') { else if ($fieldlist[$field]=='localtax1_type') {
@@ -1484,7 +1485,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='')
{ {
if (! in_array('country',$fieldlist)) // If there is already a field country, we don't show country_id (avoid duplicate) if (! in_array('country',$fieldlist)) // If there is already a field country, we don't show country_id (avoid duplicate)
{ {
$country_id = (! empty($obj->$fieldlist[$field]) ? $obj->$fieldlist[$field] : 0); $country_id = (! empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} : 0);
print '<td>'; print '<td>';
print '<input type="hidden" name="'.$fieldlist[$field].'" value="'.$country_id.'">'; print '<input type="hidden" name="'.$fieldlist[$field].'" value="'.$country_id.'">';
print '</td>'; print '</td>';
@@ -1498,7 +1499,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='')
} }
elseif ($fieldlist[$field] == 'region_id') elseif ($fieldlist[$field] == 'region_id')
{ {
$region_id = (! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:0); $region_id = (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:0);
print '<td>'; print '<td>';
print '<input type="hidden" name="'.$fieldlist[$field].'" value="'.$region_id.'">'; print '<input type="hidden" name="'.$fieldlist[$field].'" value="'.$region_id.'">';
print '</td>'; print '</td>';
@@ -1513,21 +1514,21 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='')
elseif ($fieldlist[$field] == 'type_template') elseif ($fieldlist[$field] == 'type_template')
{ {
print '<td>'; print '<td>';
print $form->selectarray('type_template', $elementList,(! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:'')); print $form->selectarray('type_template', $elementList,(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''));
print '</td>'; print '</td>';
} }
// Le type de l'element (pour les type de contact) // Le type de l'element (pour les type de contact)
elseif ($fieldlist[$field] == 'element') elseif ($fieldlist[$field] == 'element')
{ {
print '<td>'; print '<td>';
print $form->selectarray('element', $elementList,(! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:'')); print $form->selectarray('element', $elementList,(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''));
print '</td>'; print '</td>';
} }
// La source de l'element (pour les type de contact) // La source de l'element (pour les type de contact)
elseif ($fieldlist[$field] == 'source') elseif ($fieldlist[$field] == 'source')
{ {
print '<td>'; print '<td>';
print $form->selectarray('source', $sourceList,(! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:'')); print $form->selectarray('source', $sourceList,(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''));
print '</td>'; print '</td>';
} }
elseif ($fieldlist[$field] == 'type' && $tabname == MAIN_DB_PREFIX."c_actioncomm") elseif ($fieldlist[$field] == 'type' && $tabname == MAIN_DB_PREFIX."c_actioncomm")
@@ -1538,18 +1539,18 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='')
} }
elseif ($fieldlist[$field] == 'recuperableonly' || $fieldlist[$field] == 'fdm' || $fieldlist[$field] == 'deductible') { elseif ($fieldlist[$field] == 'recuperableonly' || $fieldlist[$field] == 'fdm' || $fieldlist[$field] == 'deductible') {
print '<td>'; print '<td>';
print $form->selectyesno($fieldlist[$field],(! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:''),1); print $form->selectyesno($fieldlist[$field],(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''),1);
print '</td>'; print '</td>';
} }
elseif (in_array($fieldlist[$field],array('nbjour','decalage','taux','localtax1','localtax2'))) { elseif (in_array($fieldlist[$field],array('nbjour','decalage','taux','localtax1','localtax2'))) {
$align="left"; $align="left";
if (in_array($fieldlist[$field],array('taux','localtax1','localtax2'))) $align="right"; // Fields aligned on right if (in_array($fieldlist[$field],array('taux','localtax1','localtax2'))) $align="right"; // Fields aligned on right
print '<td align="'.$align.'">'; print '<td align="'.$align.'">';
print '<input type="text" class="flat" value="'.(isset($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:'').'" size="3" name="'.$fieldlist[$field].'">'; print '<input type="text" class="flat" value="'.(isset($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'').'" size="3" name="'.$fieldlist[$field].'">';
print '</td>'; print '</td>';
} }
elseif (in_array($fieldlist[$field], array('libelle_facture'))) { elseif (in_array($fieldlist[$field], array('libelle_facture'))) {
print '<td><textarea cols="30" rows="'.ROWS_2.'" class="flat" name="'.$fieldlist[$field].'">'.(! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:'').'</textarea></td>'; print '<td><textarea cols="30" rows="'.ROWS_2.'" class="flat" name="'.$fieldlist[$field].'">'.(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'').'</textarea></td>';
} }
elseif (in_array($fieldlist[$field], array('content'))) elseif (in_array($fieldlist[$field], array('content')))
{ {
@@ -1560,18 +1561,18 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='')
else print '<td>'; else print '<td>';
if ($context != 'hide') if ($context != 'hide')
{ {
//print '<textarea cols="3" rows="'.ROWS_2.'" class="flat" name="'.$fieldlist[$field].'">'.(! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:'').'</textarea>'; //print '<textarea cols="3" rows="'.ROWS_2.'" class="flat" name="'.$fieldlist[$field].'">'.(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'').'</textarea>';
$doleditor = new DolEditor($fieldlist[$field], (! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:''), '', 140, 'dolibarr_mailings', 'In', 0, false, true, ROWS_5, '90%'); $doleditor = new DolEditor($fieldlist[$field], (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''), '', 140, 'dolibarr_mailings', 'In', 0, false, true, ROWS_5, '90%');
print $doleditor->Create(1); print $doleditor->Create(1);
} }
else print '&nbsp;'; else print '&nbsp;';
print '</td>'; print '</td>';
} }
elseif ($fieldlist[$field] == 'price' || preg_match('/^amount/i',$fieldlist[$field])) { elseif ($fieldlist[$field] == 'price' || preg_match('/^amount/i',$fieldlist[$field])) {
print '<td><input type="text" class="flat" value="'.price((! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:'')).'" size="8" name="'.$fieldlist[$field].'"></td>'; print '<td><input type="text" class="flat" value="'.price((! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'')).'" size="8" name="'.$fieldlist[$field].'"></td>';
} }
elseif ($fieldlist[$field] == 'code' && isset($obj->$fieldlist[$field])) { elseif ($fieldlist[$field] == 'code' && isset($obj->{$fieldlist[$field]})) {
print '<td><input type="text" class="flat" value="'.(! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:'').'" size="10" name="'.$fieldlist[$field].'"></td>'; print '<td><input type="text" class="flat" value="'.(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'').'" size="10" name="'.$fieldlist[$field].'"></td>';
} }
elseif ($fieldlist[$field]=='unit') { elseif ($fieldlist[$field]=='unit') {
print '<td>'; print '<td>';
@@ -1581,14 +1582,14 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='')
'point' => $langs->trans('SizeUnitpoint'), 'point' => $langs->trans('SizeUnitpoint'),
'inch' => $langs->trans('SizeUnitinch') 'inch' => $langs->trans('SizeUnitinch')
); );
print $form->selectarray('unit', $units, (! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:''), 0, 0, 0); print $form->selectarray('unit', $units, (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''), 0, 0, 0);
print '</td>'; print '</td>';
} }
// Le type de taxe locale // Le type de taxe locale
elseif ($fieldlist[$field] == 'localtax1_type' || $fieldlist[$field] == 'localtax2_type') elseif ($fieldlist[$field] == 'localtax1_type' || $fieldlist[$field] == 'localtax2_type')
{ {
print '<td align="center">'; print '<td align="center">';
print $form->selectarray($fieldlist[$field], $localtax_typeList, (! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:'')); print $form->selectarray($fieldlist[$field], $localtax_typeList, (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''));
print '</td>'; print '</td>';
} }
else else
@@ -1603,7 +1604,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='')
if ($fieldlist[$field]=='accountancy_code_sell') $size='size="10" '; if ($fieldlist[$field]=='accountancy_code_sell') $size='size="10" ';
if ($fieldlist[$field]=='accountancy_code_buy') $size='size="10" '; if ($fieldlist[$field]=='accountancy_code_buy') $size='size="10" ';
if ($fieldlist[$field]=='sortorder') $size='size="2" '; if ($fieldlist[$field]=='sortorder') $size='size="2" ';
print '<input type="text" '.$size.' class="flat" value="'.(isset($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:'').'" name="'.$fieldlist[$field].'">'; print '<input type="text" '.$size.' class="flat" value="'.(isset($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'').'" name="'.$fieldlist[$field].'">';
print '</td>'; print '</td>';
} }
} }

View File

@@ -1,5 +1,6 @@
<?php <?php
/* Copyright (C) 2015 Frederic France <frederic.france@free.fr> /* Copyright (C) 2015 Frederic France <frederic.france@free.fr>
* Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -346,14 +347,14 @@ foreach ($list as $key)
$var = !$var; $var = !$var;
print '<tr '.$bc[$var].' class="value">'; print '<tr '.$bc[$var].' class="value">';
print '<td><label for="'.$key[1].'">'.$langs->trans($key[1]).'</label></td>'; print '<td><label for="'.$key[1].'">'.$langs->trans($key[1]).'</label></td>';
print '<td><input type="text" size="100" id="'.$key[1].'" name="'.$key[1].'" value="'.$conf->global->$key[1].'">'; print '<td><input type="text" size="100" id="'.$key[1].'" name="'.$key[1].'" value="'.$conf->global->{$key[1]}.'">';
print '</td></tr>'; print '</td></tr>';
// Api Secret // Api Secret
$var = !$var; $var = !$var;
print '<tr '.$bc[$var].' class="value">'; print '<tr '.$bc[$var].' class="value">';
print '<td><label for="'.$key[2].'">'.$langs->trans($key[2]).'</label></td>'; print '<td><label for="'.$key[2].'">'.$langs->trans($key[2]).'</label></td>';
print '<td><input type="password" size="100" id="'.$key[2].'" name="'.$key[2].'" value="'.$conf->global->$key[2].'">'; print '<td><input type="password" size="100" id="'.$key[2].'" name="'.$key[2].'" value="'.$conf->global->{$key[2]}.'">';
print '</td></tr>'; print '</td></tr>';
} }

View File

@@ -7,6 +7,7 @@
* Copyright (C) 2009-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2009-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Florian Henry <forian.henry@open-concept.pro> * Copyright (C) 2013 Florian Henry <forian.henry@open-concept.pro>
* Copyright (C) 2015 Charles-Fr BENKE <charles.fr@benke.fr> * Copyright (C) 2015 Charles-Fr BENKE <charles.fr@benke.fr>
* Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -867,7 +868,7 @@ class ExtraFields
} }
else else
{ {
$labeltoshow=$obj->$InfoFieldList[1]; $labeltoshow=$obj->{$InfoFieldList[1]};
} }
$labeltoshow=dol_trunc($labeltoshow,45); $labeltoshow=dol_trunc($labeltoshow,45);
@@ -888,12 +889,12 @@ class ExtraFields
{ {
if(!$notrans) if(!$notrans)
{ {
$translabel=$langs->trans($obj->$InfoFieldList[1]); $translabel=$langs->trans($obj->{$InfoFieldList[1]});
if ($translabel!=$obj->$InfoFieldList[1]) { if ($translabel!=$obj->{$InfoFieldList[1]}) {
$labeltoshow=dol_trunc($translabel,18); $labeltoshow=dol_trunc($translabel,18);
} }
else { else {
$labeltoshow=dol_trunc($obj->$InfoFieldList[1],18); $labeltoshow=dol_trunc($obj->{$InfoFieldList[1]},18);
} }
} }
if (empty($labeltoshow)) $labeltoshow='(not defined)'; if (empty($labeltoshow)) $labeltoshow='(not defined)';
@@ -1044,7 +1045,7 @@ class ExtraFields
$labeltoshow .= $obj->$field_toshow . ' '; $labeltoshow .= $obj->$field_toshow . ' ';
} }
} else { } else {
$labeltoshow = $obj->$InfoFieldList[1]; $labeltoshow = $obj->{$InfoFieldList[1]};
} }
$labeltoshow = dol_trunc($labeltoshow, 45); $labeltoshow = dol_trunc($labeltoshow, 45);
@@ -1065,11 +1066,11 @@ class ExtraFields
$out .= '/>' . $labeltoshow . '<br>'; $out .= '/>' . $labeltoshow . '<br>';
} else { } else {
if (! $notrans) { if (! $notrans) {
$translabel = $langs->trans($obj->$InfoFieldList[1]); $translabel = $langs->trans($obj->{$InfoFieldList[1]});
if ($translabel != $obj->$InfoFieldList[1]) { if ($translabel != $obj->{$InfoFieldList[1]}) {
$labeltoshow = dol_trunc($translabel, 18); $labeltoshow = dol_trunc($translabel, 18);
} else { } else {
$labeltoshow = dol_trunc($obj->$InfoFieldList[1], 18); $labeltoshow = dol_trunc($obj->{$InfoFieldList[1]}, 18);
} }
} }
if (empty($labeltoshow)) if (empty($labeltoshow))
@@ -1263,13 +1264,13 @@ class ExtraFields
else else
{ {
$translabel=''; $translabel='';
if (!empty($obj->$InfoFieldList[1])) { if (!empty($obj->{$InfoFieldList[1]})) {
$translabel=$langs->trans($obj->$InfoFieldList[1]); $translabel=$langs->trans($obj->{$InfoFieldList[1]});
} }
if ($translabel!=$obj->$InfoFieldList[1]) { if ($translabel!=$obj->{$InfoFieldList[1]}) {
$value=dol_trunc($translabel,18); $value=dol_trunc($translabel,18);
}else { }else {
$value=$obj->$InfoFieldList[1]; $value=$obj->{$InfoFieldList[1]};
} }
} }
} }
@@ -1343,13 +1344,13 @@ class ExtraFields
} }
} else { } else {
$translabel = ''; $translabel = '';
if (! empty($obj->$InfoFieldList[1])) { if (! empty($obj->{$InfoFieldList[1]})) {
$translabel = $langs->trans($obj->$InfoFieldList[1]); $translabel = $langs->trans($obj->{$InfoFieldList[1]});
} }
if ($translabel != $obj->$InfoFieldList[1]) { if ($translabel != $obj->{$InfoFieldList[1]}) {
$value .= dol_trunc($translabel, 18) . '<BR>'; $value .= dol_trunc($translabel, 18) . '<BR>';
} else { } else {
$value .= $obj->$InfoFieldList[1] . '<BR>'; $value .= $obj->{$InfoFieldList[1]} . '<BR>';
} }
} }
} }

View File

@@ -3,6 +3,7 @@
* Copyright (C) 2012-2015 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2012-2015 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -2256,18 +2257,18 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu
// Define $accessallowed // Define $accessallowed
if (preg_match('/^([a-z]+)_user_temp$/i',$modulepart,$reg)) if (preg_match('/^([a-z]+)_user_temp$/i',$modulepart,$reg))
{ {
if ($fuser->rights->$reg[1]->lire || $fuser->rights->$reg[1]->read || ($fuser->rights->$reg[1]->download)) $accessallowed=1; if ($fuser->rights->{$reg[1]}->lire || $fuser->rights->{$reg[1]}->read || ($fuser->rights->{$reg[1]}->download)) $accessallowed=1;
$original_file=$conf->$reg[1]->dir_temp.'/'.$fuser->id.'/'.$original_file; $original_file=$conf->{$reg[1]}->dir_temp.'/'.$fuser->id.'/'.$original_file;
} }
else if (preg_match('/^([a-z]+)_temp$/i',$modulepart,$reg)) else if (preg_match('/^([a-z]+)_temp$/i',$modulepart,$reg))
{ {
if ($fuser->rights->$reg[1]->lire || $fuser->rights->$reg[1]->read || ($fuser->rights->$reg[1]->download)) $accessallowed=1; if ($fuser->rights->{$reg[1]}->lire || $fuser->rights->{$reg[1]}->read || ($fuser->rights->{$reg[1]}->download)) $accessallowed=1;
$original_file=$conf->$reg[1]->dir_temp.'/'.$original_file; $original_file=$conf->{$reg[1]}->dir_temp.'/'.$original_file;
} }
else if (preg_match('/^([a-z]+)_user$/i',$modulepart,$reg)) else if (preg_match('/^([a-z]+)_user$/i',$modulepart,$reg))
{ {
if ($fuser->rights->$reg[1]->lire || $fuser->rights->$reg[1]->read || ($fuser->rights->$reg[1]->download)) $accessallowed=1; if ($fuser->rights->{$reg[1]}->lire || $fuser->rights->{$reg[1]}->read || ($fuser->rights->{$reg[1]}->download)) $accessallowed=1;
$original_file=$conf->$reg[1]->dir_output.'/'.$fuser->id.'/'.$original_file; $original_file=$conf->{$reg[1]}->dir_output.'/'.$fuser->id.'/'.$original_file;
} }
else else
{ {

View File

@@ -4,7 +4,7 @@
* Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr> * Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2015 Ferran Marcet <fmarcet@2byte.es> * Copyright (C) 2015 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr> * Copyright (C) 2015-2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -1910,7 +1910,7 @@ function fetchObjectByElement($element_id, $element_type)
global $db,$conf; global $db,$conf;
$element_prop = getElementProperties($element_type); $element_prop = getElementProperties($element_type);
if (is_array($element_prop) && $conf->$element_prop['module']->enabled) if (is_array($element_prop) && $conf->{$element_prop['module']}->enabled)
{ {
dol_include_once('/'.$element_prop['classpath'].'/'.$element_prop['classfile'].'.class.php'); dol_include_once('/'.$element_prop['classpath'].'/'.$element_prop['classfile'].'.class.php');

View File

@@ -2,6 +2,7 @@
/* Copyright (C) 2005-2011 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2005-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2012 Charles-Fr BENKE <charles.fr@benke.fr> * Copyright (C) 2012 Charles-Fr BENKE <charles.fr@benke.fr>
* Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -131,11 +132,11 @@ class Export
//print_r("$perm[0]-$perm[1]-$perm[2]<br>"); //print_r("$perm[0]-$perm[1]-$perm[2]<br>");
if (! empty($perm[2])) if (! empty($perm[2]))
{ {
$bool=$user->rights->$perm[0]->$perm[1]->$perm[2]; $bool=$user->rights->{$perm[0]}->{$perm[1]}->{$perm[2]};
} }
else else
{ {
$bool=$user->rights->$perm[0]->$perm[1]; $bool=$user->rights->{$perm[0]}->{$perm[1]};
} }
if ($perm[0]=='user' && $user->admin) $bool=true; if ($perm[0]=='user' && $user->admin) $bool=true;
if (! $bool) break; if (! $bool) break;

View File

@@ -1,5 +1,6 @@
<?php <?php
/* Copyright (C) 2011 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -106,11 +107,11 @@ class Import
//print_r("$perm[0]-$perm[1]-$perm[2]<br>"); //print_r("$perm[0]-$perm[1]-$perm[2]<br>");
if ($perm[2]) if ($perm[2])
{ {
$bool=$user->rights->$perm[0]->$perm[1]->$perm[2]; $bool=$user->rights->{$perm[0]}->{$perm[1]}->{$perm[2]};
} }
else else
{ {
$bool=$user->rights->$perm[0]->$perm[1]; $bool=$user->rights->{$perm[0]}->{$perm[1]};
} }
if ($perm[0]=='user' && $user->admin) $bool=true; if ($perm[0]=='user' && $user->admin) $bool=true;
//print $bool." $perm[0]"."<br>"; //print $bool." $perm[0]"."<br>";