From 9b59445e39b75dd8771a18254b4f7eecda9baaa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 7 Mar 2024 18:48:50 +0100 Subject: [PATCH] fix unknown $user (#28687) * fix unknown $user * fix @param * fix @param * fix @param * fix @param --- htdocs/fourn/class/fournisseur.commande.class.php | 11 +++++------ htdocs/hrm/class/establishment.class.php | 1 - htdocs/ticket/class/api_tickets.class.php | 3 ++- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index b2a5140c9e1..13e43b59165 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -2316,6 +2316,8 @@ class CommandeFournisseur extends CommonOrder */ public function deleteLine($idline, $notrigger = 0) { + global $user; + if ($this->statut == 0) { $line = new CommandeFournisseurLigne($this->db); @@ -2333,12 +2335,11 @@ class CommandeFournisseur extends CommonOrder } } - if ($line->delete($notrigger) > 0) { + if ($line->delete($user, $notrigger) > 0) { $this->update_price(1); return 1; } else { - $this->error = $line->error; - $this->errors = $line->errors; + $this->setErrorsFromObject($line); return -1; } } else { @@ -4162,10 +4163,8 @@ class CommandeFournisseurLigne extends CommonOrderLine * @param int $notrigger 1=Disable call to triggers * @return int Return integer <0 if KO, >0 if OK */ - public function delete($notrigger = 0) + public function delete($user, $notrigger = 0) { - global $user; - $error = 0; $this->db->begin(); diff --git a/htdocs/hrm/class/establishment.class.php b/htdocs/hrm/class/establishment.class.php index 8acbb128987..37ab22b84a9 100644 --- a/htdocs/hrm/class/establishment.class.php +++ b/htdocs/hrm/class/establishment.class.php @@ -327,7 +327,6 @@ class Establishment extends CommonObject * Delete record * * @param User $user User making the change - * @param int $id Id of record to delete * @return int Return integer <0 if KO, >0 if OK */ public function delete($user) diff --git a/htdocs/ticket/class/api_tickets.class.php b/htdocs/ticket/class/api_tickets.class.php index d89decb1ac7..a9ed23f8d61 100644 --- a/htdocs/ticket/class/api_tickets.class.php +++ b/htdocs/ticket/class/api_tickets.class.php @@ -1,5 +1,6 @@ + * Copyright (C) 2024 Frédéric France * * 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 @@ -410,7 +411,7 @@ class Tickets extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if (!$this->ticket->delete($user)) { + if (!$this->ticket->delete(DolibarrApiAccess::$user)) { throw new RestException(500, 'Error when deleting ticket'); }