diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php
index cc922cb724b..d5ec0d6d2df 100644
--- a/htdocs/product/fournisseurs.php
+++ b/htdocs/product/fournisseurs.php
@@ -102,6 +102,9 @@ if (! $sortorder) $sortorder="ASC";
if ($cancel) $action='';
+$usercanread = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->lire) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->lire));
+$usercancreate = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->creer));
+
$parameters=array('socid'=>$socid, 'id_prod'=>$id);
$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
@@ -385,9 +388,9 @@ if ($id > 0 || $ref)
$textdesc =$langs->trans("CostPriceDescription");
$textdesc.="
".$langs->trans("CostPriceUsage");
$text=$form->textwithpicto($langs->trans("CostPrice"), $textdesc, 1, 'help', '');
- print $form->editfieldkey($text, 'cost_price', $object->cost_price, $object, $user->rights->produit->creer||$user->rights->service->creer, 'amount:6');
+ print $form->editfieldkey($text, 'cost_price', $object->cost_price, $object, $usercancreate, 'amount:6');
print '
';
- print $form->editfieldval($text, 'cost_price', $object->cost_price, $object, $user->rights->produit->creer||$user->rights->service->creer, 'amount:6');
+ print $form->editfieldval($text, 'cost_price', $object->cost_price, $object, $usercancreate, 'amount:6');
print ' | ';
print '';
@@ -399,7 +402,7 @@ if ($id > 0 || $ref)
// Form to add or update a price
- if (($action == 'add_price' || $action == 'updateprice' ) && ($user->rights->produit->creer || $user->rights->service->creer))
+ if (($action == 'add_price' || $action == 'updateprice' ) && $usercancreate)
{
$langs->load("suppliers");
@@ -747,7 +750,7 @@ SCRIPT;
$reshook=$hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if (empty($reshook))
{
- if ($user->rights->produit->creer || $user->rights->service->creer)
+ if ($usercancreate)
{
print '';
print $langs->trans("AddSupplierPrice").'';
@@ -758,7 +761,7 @@ SCRIPT;
print "\n\n";
print '
';
- if ($user->rights->fournisseur->lire)
+ if ($user->rights->fournisseur->lire) // Duplicate ? this check is already in the head of this file
{
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
@@ -822,7 +825,7 @@ SCRIPT;
print ''.$productfourn->getSocNomUrl(1, 'supplier').' | ';
// Supplier ref
- if ($user->rights->produit->creer || $user->rights->service->creer) // change required right here
+ if ($usercancreate) // change required right here
{
print ''.$productfourn->getNomUrl().' | ';
}
@@ -924,7 +927,7 @@ SCRIPT;
// Modify-Remove
print '';
- if ($user->rights->produit->creer || $user->rights->service->creer)
+ if ($usercancreate)
{
print ''.img_edit()."";
print ' ';
diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php
index f6a8eb9f8d9..3409a9599d0 100644
--- a/htdocs/user/class/user.class.php
+++ b/htdocs/user/class/user.class.php
@@ -2512,7 +2512,7 @@ class User extends CommonObject
}
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/**
* Retourne chaine DN complete dans l'annuaire LDAP pour l'objet
*
@@ -2522,7 +2522,7 @@ class User extends CommonObject
* 2=Return key only (RDN) (uid=qqq)
* @return string DN
*/
- private function _load_ldap_dn($info, $mode = 0)
+ public function _load_ldap_dn($info, $mode = 0)
{
// phpcs:enable
global $conf;
@@ -2533,13 +2533,13 @@ class User extends CommonObject
return $dn;
}
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/**
* Initialize the info array (array of LDAP values) that will be used to call LDAP functions
*
* @return array Tableau info des attributs
*/
- private function _load_ldap_info()
+ public function _load_ldap_info()
{
// phpcs:enable
global $conf,$langs;
diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php
index eada58c3e3b..721ef661cc2 100644
--- a/htdocs/user/class/usergroup.class.php
+++ b/htdocs/user/class/usergroup.class.php
@@ -924,7 +924,7 @@ class UserGroup extends CommonObject
return $result;
}
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/**
* Retourne chaine DN complete dans l'annuaire LDAP pour l'objet
*
@@ -934,7 +934,7 @@ class UserGroup extends CommonObject
* 2=Return key only (uid=qqq)
* @return string DN
*/
- private function _load_ldap_dn($info, $mode = 0)
+ public function _load_ldap_dn($info, $mode = 0)
{
// phpcs:enable
global $conf;
@@ -946,13 +946,13 @@ class UserGroup extends CommonObject
}
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/**
* Initialize the info array (array of LDAP values) that will be used to call LDAP functions
*
* @return array Tableau info des attributs
*/
- private function _load_ldap_info()
+ public function _load_ldap_info()
{
// phpcs:enable
global $conf,$langs;
|