From 08b9cf2a40f5c5205f14dcd80c596e00c2962e1e Mon Sep 17 00:00:00 2001 From: Vincent Maury Date: Thu, 1 Feb 2024 17:43:33 +0100 Subject: [PATCH] Fix :external user (client for example) can see PMP and accountancy infos (#27952) --- htdocs/product/class/product.class.php | 48 ++++++++++++++------------ 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 1858ed5f985..a6252829e28 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -5228,7 +5228,7 @@ class Product extends CommonObject */ public function getTooltipContentArray($params) { - global $conf, $langs; + global $conf, $langs, $user; $langs->loadLangs(array('products', 'other')); @@ -5313,29 +5313,31 @@ class Product extends CommonObject } $datas['duration'] .= (!empty($this->duration_unit) && isset($dur[$this->duration_unit]) ? " ".$langs->trans($dur[$this->duration_unit]) : ''); } - if (!empty($this->pmp) && $this->pmp) { - $datas['pmp'] = "
".$langs->trans("PMPValue").': '.price($this->pmp, 0, '', 1, -1, -1, $conf->currency); - } - - if (isModEnabled('accounting')) { - if ($this->status && isset($this->accountancy_code_sell)) { - include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; - $selllabel = '
'; - $selllabel .= '
'.$langs->trans('ProductAccountancySellCode').': '.length_accountg($this->accountancy_code_sell); - $selllabel .= '
'.$langs->trans('ProductAccountancySellIntraCode').': '.length_accountg($this->accountancy_code_sell_intra); - $selllabel .= '
'.$langs->trans('ProductAccountancySellExportCode').': '.length_accountg($this->accountancy_code_sell_export); - $datas['accountancysell'] = $selllabel; + if (empty($user->socid)) { + if (!empty($this->pmp) && $this->pmp) { + $datas['pmp'] = "
".$langs->trans("PMPValue").': '.price($this->pmp, 0, '', 1, -1, -1, $conf->currency); } - if ($this->status_buy && isset($this->accountancy_code_buy)) { - include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; - $buylabel = ''; - if (empty($this->status)) { - $buylabel .= '
'; + + if (isModEnabled('accounting')) { + if ($this->status && isset($this->accountancy_code_sell)) { + include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; + $selllabel = '
'; + $selllabel .= '
'.$langs->trans('ProductAccountancySellCode').': '.length_accountg($this->accountancy_code_sell); + $selllabel .= '
'.$langs->trans('ProductAccountancySellIntraCode').': '.length_accountg($this->accountancy_code_sell_intra); + $selllabel .= '
'.$langs->trans('ProductAccountancySellExportCode').': '.length_accountg($this->accountancy_code_sell_export); + $datas['accountancysell'] = $selllabel; + } + if ($this->status_buy && isset($this->accountancy_code_buy)) { + include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; + $buylabel = ''; + if (empty($this->status)) { + $buylabel .= '
'; + } + $buylabel .= '
'.$langs->trans('ProductAccountancyBuyCode').': '.length_accountg($this->accountancy_code_buy); + $buylabel .= '
'.$langs->trans('ProductAccountancyBuyIntraCode').': '.length_accountg($this->accountancy_code_buy_intra); + $buylabel .= '
'.$langs->trans('ProductAccountancyBuyExportCode').': '.length_accountg($this->accountancy_code_buy_export); + $datas['accountancybuy'] = $buylabel; } - $buylabel .= '
'.$langs->trans('ProductAccountancyBuyCode').': '.length_accountg($this->accountancy_code_buy); - $buylabel .= '
'.$langs->trans('ProductAccountancyBuyIntraCode').': '.length_accountg($this->accountancy_code_buy_intra); - $buylabel .= '
'.$langs->trans('ProductAccountancyBuyExportCode').': '.length_accountg($this->accountancy_code_buy_export); - $datas['accountancybuy'] = $buylabel; } } // show categories for this record only in ajax to not overload lists @@ -5363,7 +5365,7 @@ class Product extends CommonObject */ public function getNomUrl($withpicto = 0, $option = '', $maxlength = 0, $save_lastsearch_value = -1, $notooltip = 0, $morecss = '', $add_label = 0, $sep = ' - ') { - global $conf, $langs, $hookmanager; + global $conf, $langs, $hookmanager, $user; include_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; $result = '';