From 686c60e0bc5d236bbceffd069ba1a54f1815e3da Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 31 Aug 2024 19:13:26 +0200 Subject: [PATCH 1/2] Fix permission to update stock --- htdocs/product/stock/movement_card.php | 4 ++-- htdocs/product/stock/product.php | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/product/stock/movement_card.php b/htdocs/product/stock/movement_card.php index b5642d3870f..2b5210ab2f4 100644 --- a/htdocs/product/stock/movement_card.php +++ b/htdocs/product/stock/movement_card.php @@ -169,7 +169,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' } // Correct stock -if ($action == "correct_stock") { +if ($action == "correct_stock" && !$cancel && $usercancreate) { $product = new Product($db); if (!empty($product_id)) { $result = $product->fetch($product_id); @@ -249,7 +249,7 @@ if ($action == "correct_stock") { } // Transfer stock from a warehouse to another warehouse -if ($action == "transfert_stock" && !$cancel) { +if ($action == "transfert_stock" && !$cancel && $usercancreate) { $error = 0; $product = new Product($db); if (!empty($product_id)) { diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 8d269608ac3..44b179aa259 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -118,6 +118,7 @@ $error = 0; $usercanread = (($object->type == Product::TYPE_PRODUCT && $user->hasRight('produit', 'lire')) || ($object->type == Product::TYPE_SERVICE && $user->hasRight('service', 'lire'))); $usercancreate = (($object->type == Product::TYPE_PRODUCT && $user->hasRight('produit', 'creer')) || ($object->type == Product::TYPE_SERVICE && $user->hasRight('service', 'creer'))); $usercancreadprice = getDolGlobalString('MAIN_USE_ADVANCED_PERMS') ? $user->hasRight('product', 'product_advance', 'read_prices') : $user->hasRight('product', 'lire'); +$usercanupdatestock = $user->hasRight('stock', 'mouvement', 'creer'); if ($object->isService()) { $label = $langs->trans('Service'); @@ -244,7 +245,7 @@ if ($action == 'setdesiredstock' && $usercancreate) { // Correct stock -if ($action == "correct_stock" && !$cancel && $usercancreate) { +if ($action == "correct_stock" && !$cancel && $usercanupdatestock) { if (!(GETPOSTINT("id_entrepot") > 0)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); $error++; @@ -337,7 +338,7 @@ if ($action == "correct_stock" && !$cancel && $usercancreate) { } // Transfer stock from a warehouse to another warehouse -if ($action == "transfert_stock" && !$cancel && $usercancreate) { +if ($action == "transfert_stock" && !$cancel && $usercanupdatestock) { if (!(GETPOSTINT("id_entrepot") > 0) || !(GETPOSTINT("id_entrepot_destination") > 0)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); $error++; From 7b779967e8cbe1660d15cb5e0333bacf570c48ed Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 1 Sep 2024 12:46:31 +0200 Subject: [PATCH 2/2] Fix phan --- htdocs/viewimage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/viewimage.php b/htdocs/viewimage.php index 18fb373eb55..aa4c2fe2463 100644 --- a/htdocs/viewimage.php +++ b/htdocs/viewimage.php @@ -326,7 +326,7 @@ if ($modulepart == 'barcode') { $vcffile = ''; if ($reg[1] == 'user') { $vcffile = $conf->user->dir_temp.'/'.$code; - } elseif ($reg[1] == 'user') { + } elseif ($reg[1] == 'contact') { $vcffile = $conf->contact->dir_temp.'/'.$code; }