From dfc1ed7d7297fdb6e42de3d75f3e9f7bf6866217 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 16 Mar 2017 22:36:44 +0100 Subject: [PATCH] FIX #6535 --- .../categories/class/api_categories.class.php | 45 +++++++++++++++++-- .../class/api_deprecated_category.class.php | 2 +- htdocs/product/class/api_products.class.php | 2 +- htdocs/societe/class/api_contacts.class.php | 2 +- .../societe/class/api_thirdparties.class.php | 2 +- 5 files changed, 46 insertions(+), 7 deletions(-) diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index 1f37623544b..a08abdfc545 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -248,6 +248,7 @@ class Categories extends DolibarrApi if( ! count($obj_ret)) { throw new RestException(404, 'No category found'); } + return $obj_ret; } @@ -351,9 +352,47 @@ class Categories extends DolibarrApi $object = parent::_cleanObjectDatas($object); - // Remove the subscriptions because they are handled as a subresource. - //unset($object->subscriptions); - + // Remove fields not relevent to categories + unset($object->country); + unset($object->country_id); + unset($object->country_code); + unset($object->total_ht); + unset($object->total_ht); + unset($object->total_localtax1); + unset($object->total_localtax2); + unset($object->total_ttc); + unset($object->total_tva); + unset($object->lines); + unset($object->fk_incoterms); + unset($object->libelle_incoterms); + unset($object->location_incoterms); + unset($object->civility_id); + unset($object->name); + unset($object->lastname); + unset($object->firstname); + unset($object->shipping_method_id); + unset($object->fk_delivery_address); + unset($object->cond_reglement); + unset($object->cond_reglement_id); + unset($object->mode_reglement_id); + unset($object->barcode_type_coder); + unset($object->barcode_type_label); + unset($object->barcode_type_code); + unset($object->barcode_type); + unset($object->canvas); + unset($object->cats); + unset($object->motherof); + unset($object->context); + unset($object->socid); + unset($object->thirdparty); + unset($object->contact); + unset($object->contact_id); + unset($object->user); + unset($object->fk_account); + unset($object->fk_project); + unset($object->note); + unset($object->statut); + return $object; } diff --git a/htdocs/categories/class/api_deprecated_category.class.php b/htdocs/categories/class/api_deprecated_category.class.php index 6f2f16bb222..271f2900502 100644 --- a/htdocs/categories/class/api_deprecated_category.class.php +++ b/htdocs/categories/class/api_deprecated_category.class.php @@ -291,7 +291,7 @@ class CategoryApi extends DolibarrApi * @url GET /customer/{cusid}/categories */ function getListCustomerCategories($cusid, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { - return $this->getListForItem('customer', $sortfield, $sortorder, $limit, $page, $cusid); + return $this->getListForItem($sortfield, $sortorder, $limit, $page, 'customer', $cusid); } /** diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 90bc9d7296f..38b65ddfb4b 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -264,7 +264,7 @@ class Products extends DolibarrApi */ function getCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { $categories = new Categories(); - return $categories->getListForItem('product', $sortfield, $sortorder, $limit, $page, $id); + return $categories->getListForItem($sortfield, $sortorder, $limit, $page, 'product', $id); } /** diff --git a/htdocs/societe/class/api_contacts.class.php b/htdocs/societe/class/api_contacts.class.php index d758d9ac3f4..de50799e430 100644 --- a/htdocs/societe/class/api_contacts.class.php +++ b/htdocs/societe/class/api_contacts.class.php @@ -318,7 +318,7 @@ class Contacts extends DolibarrApi */ function getCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { $categories = new Categories(); - return $categories->getListForItem('contact', $sortfield, $sortorder, $limit, $page, $id); + return $categories->getListForItem($sortfield, $sortorder, $limit, $page, 'contact', $id); } /** diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index cedd30c5209..f8e96d82e47 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -267,7 +267,7 @@ class Thirdparties extends DolibarrApi */ function getCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { $categories = new Categories(); - return $categories->getListForItem('customer', $sortfield, $sortorder, $limit, $page, $id); + return $categories->getListForItem($sortfield, $sortorder, $limit, $page, 'customer', $id); } /**