From 0d50402803850e0f52dee278062efe461694be68 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Mon, 23 Nov 2020 23:31:46 +0100 Subject: [PATCH] Update api_contacts.class.php --- htdocs/societe/class/api_contacts.class.php | 41 +++++++++++---------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/htdocs/societe/class/api_contacts.class.php b/htdocs/societe/class/api_contacts.class.php index 1ebcf3fecb8..ee131a5c40f 100644 --- a/htdocs/societe/class/api_contacts.class.php +++ b/htdocs/societe/class/api_contacts.class.php @@ -63,13 +63,13 @@ class Contacts extends DolibarrApi * Return an array with contact informations * * @param int $id ID of contact - * @param int $includeroles Includes roles of the contact * @param int $includecount Count and return also number of elements the contact is used as a link for + * @param int $includeroles Includes roles of the contact * @return array|mixed data without useless information * * @throws RestException */ - public function get($id, $includeroles = 0, $includecount = 0) + public function get($id, $includecount = 0, $includeroles = 0) { if (!DolibarrApiAccess::$user->rights->societe->contact->lire) { @@ -91,15 +91,15 @@ class Contacts extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if ($includeroles) - { - $this->contact->fetchRoles(); - } - if ($includecount) { $this->contact->load_ref_elements(); } + + if ($includeroles) + { + $this->contact->fetchRoles(); + } return $this->_cleanObjectDatas($this->contact); } @@ -108,8 +108,8 @@ class Contacts extends DolibarrApi * Get properties of a contact object by Email * * @param string $email Email of contact - * @param int $includeroles Includes roles of the contact * @param int $includecount Count and return also number of elements the contact is used as a link for + * @param int $includeroles Includes roles of the contact * @return array|mixed data without useless information * * @url GET email/{email} @@ -117,7 +117,7 @@ class Contacts extends DolibarrApi * @throws RestException 401 Insufficient rights * @throws RestException 404 User or group not found */ - public function getByEmail($email, $includeroles = 0, $includecount = 0) + public function getByEmail($email, $includecount = 0, $includeroles = 0) { if (!DolibarrApiAccess::$user->rights->societe->contact->lire) { @@ -140,16 +140,16 @@ class Contacts extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if ($includeroles) - { - $this->contact->fetchRoles(); - } - if ($includecount) { $this->contact->load_ref_elements(); } + if ($includeroles) + { + $this->contact->fetchRoles(); + } + return $this->_cleanObjectDatas($this->contact); } @@ -165,13 +165,13 @@ class Contacts extends DolibarrApi * @param string $thirdparty_ids Thirdparty ids to filter contacts of (example '1' or '1,2,3') {@pattern /^[0-9,]*$/i} * @param int $category Use this param to filter list by category * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" - * @param int $includeroles Includes roles of the contact * @param int $includecount Count and return also number of elements the contact is used as a link for + * @param int $includeroles Includes roles of the contact * @return array Array of contact objects * * @throws RestException */ - public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $category = 0, $sqlfilters = '', $includeroles = 0, $includecount = 0) + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $category = 0, $sqlfilters = '', $includecount = 0, $includeroles = 0) { global $db, $conf; @@ -256,14 +256,15 @@ class Contacts extends DolibarrApi if ($contact_static->fetch($obj->rowid)) { $contact_static->fetchRoles(); + if ($includecount) + { + $contact_static->load_ref_elements(); + } if ($includeroles) { $contact_static->fetchRoles(); } - if ($includecount) - { - $contact_static->load_ref_elements(); - } + $obj_ret[] = $this->_cleanObjectDatas($contact_static); }