From 132cdd9ed414c67752229b9d8744c9a3be0a4899 Mon Sep 17 00:00:00 2001 From: nka11 <nicolas@karageuzian.com> Date: Sun, 10 Apr 2016 14:15:38 +0200 Subject: [PATCH] Fix coding style errors --- .../categories/class/api_category.class.php | 39 ++++++++++++++++++- htdocs/commande/class/api_commande.class.php | 3 +- htdocs/societe/class/api_thirdparty.class.php | 3 +- 3 files changed, 42 insertions(+), 3 deletions(-) diff --git a/htdocs/categories/class/api_category.class.php b/htdocs/categories/class/api_category.class.php index d66875185a4..71e727aac4a 100644 --- a/htdocs/categories/class/api_category.class.php +++ b/htdocs/categories/class/api_category.class.php @@ -18,6 +18,7 @@ use Luracast\Restler\RestException; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; /** * API class for category object @@ -276,6 +277,7 @@ class CategoryApi extends DolibarrApi /** * Get categories for a customer * + * @param int $cusid Customer id filter * @param string $sortfield Sort field * @param string $sortorder Sort order * @param int $limit Limit for list @@ -285,9 +287,44 @@ class CategoryApi extends DolibarrApi * * @url GET /customer/{cusid}/categories */ - function getListCustomerCategories($sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $cusid) { + function getListCustomerCategories($cusid, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { return $this->getListForItem('customer', $sortfield, $sortorder, $limit, $page, $cusid); } + + /** + * Add category to customer + * + * @param int $cusid Id of customer + * @param int $catid Id of category + * + * @return mixed + * + * @url GET /customer/{cusid}/addCategory/{catid} + */ + + function addCustomerCategory($cusid,$catid) { + if(! DolibarrApiAccess::$user->rights->societe->creer) { + throw new RestException(401); + } + $customer = new Client($this->db); + $customer->fetch($cusid); + if( ! $customer ) { + throw new RestException(404, 'customer not found'); + } + $result = $this->category->fetch($catid); + if( ! $result ) { + throw new RestException(404, 'category not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('societe',$customer->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + if( ! DolibarrApi::_checkAccessToResource('category',$this->category->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + $this->category->add_type($customer,'customer'); + return $customer; + } /** * Get supplier categories list diff --git a/htdocs/commande/class/api_commande.class.php b/htdocs/commande/class/api_commande.class.php index 8ed6de4dda2..c449210de73 100644 --- a/htdocs/commande/class/api_commande.class.php +++ b/htdocs/commande/class/api_commande.class.php @@ -98,6 +98,7 @@ class CommandeApi extends DolibarrApi * Get a list of orders * * @param int $mode Use this param to filter list + * @param string $societe Societe filter field * @param string $sortfield Sort field * @param string $sortorder Sort order * @param int $limit Limit for list @@ -202,7 +203,7 @@ class CommandeApi extends DolibarrApi * * @url POST order/ * - * @return string ID of commande + * @return int ID of commande */ function post($request_data = NULL) { diff --git a/htdocs/societe/class/api_thirdparty.class.php b/htdocs/societe/class/api_thirdparty.class.php index 430dc1aaf0a..9c65d08ac43 100644 --- a/htdocs/societe/class/api_thirdparty.class.php +++ b/htdocs/societe/class/api_thirdparty.class.php @@ -147,6 +147,7 @@ class ThirdpartyApi extends DolibarrApi * @param int $mode Set to 1 to show only customers * Set to 2 to show only prospects * Set to 3 to show only those are not customer neither prospect + * @param Text $email Search by email filter * @param string $sortfield Sort field * @param string $sortorder Sort order * @param int $limit Limit for list @@ -369,7 +370,7 @@ class ThirdpartyApi extends DolibarrApi * Delete thirdparty * * @param int $id Thirparty ID - * @return integer + * @return type * * @url DELETE thirdparty/{id} * @url DELETE customer/{id} -- GitLab