From 73fe991aedd84b49953efe48b2b92983417dac1e Mon Sep 17 00:00:00 2001 From: Neil Orley Date: Fri, 10 Nov 2017 15:46:53 +0100 Subject: [PATCH] NEW Return the order object when validate Return the order object when the order is validated using the REST API --- htdocs/commande/class/api_orders.class.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index a6788f95698..298333e1fb8 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -492,13 +492,17 @@ class Orders extends DolibarrApi if ($result < 0) { throw new RestException(500, 'Error when validating Order: '.$this->commande->error); } + $result = $this->commande->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Order not found'); + } - return array( - 'success' => array( - 'code' => 200, - 'message' => 'Order validated (Ref='.$this->commande->ref.')' - ) - ); + if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $this->commande->fetchObjectLinked(); + return $this->_cleanObjectDatas($this->commande); } /**