Skip to content

Commit

Permalink
Fix: add parameter $includecount
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Feb 14, 2019
1 parent 6c3e244 commit aedf91b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions htdocs/societe/class/api_contacts.class.php
Expand Up @@ -61,20 +61,21 @@ function __construct()
*
* Return an array with contact informations
*
* @param int $id ID of contact
* @param int $id ID of contact
* @param int $includecount Count and return also number of elements the contact is used as a link for
* @return array|mixed data without useless information
*
* @throws RestException
*/
function get($id)
function get($id, $includecount = 0)
{
if (!DolibarrApiAccess::$user->rights->societe->contact->lire)
{
throw new RestException(401, 'No permission to read contacts');
}

$result = $this->contact->fetch($id);
$this->contact->load_ref_elements();

if (!$result)
{
throw new RestException(404, 'Contact not found');
Expand All @@ -85,6 +86,11 @@ function get($id)
throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login);
}

if ($includecount)
{
$this->contact->load_ref_elements();
}

return $this->_cleanObjectDatas($this->contact);
}

Expand Down

0 comments on commit aedf91b

Please sign in to comment.