diff --git a/htdocs/fichinter/class/api_interventions.class.php b/htdocs/fichinter/class/api_interventions.class.php index fc4dec547c2..de5af981fe6 100644 --- a/htdocs/fichinter/class/api_interventions.class.php +++ b/htdocs/fichinter/class/api_interventions.class.php @@ -1,8 +1,8 @@ - * Copyright (C) 2016 Laurent Destailleur - * Copyright (C) 2025 William Mead - * Copyright (C) 2025 Charlene Benke +/* Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2016 Laurent Destailleur + * Copyright (C) 2025 William Mead + * Copyright (C) 2025-2026 Charlene Benke * Copyright (C) 2025 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -707,13 +707,14 @@ class Interventions extends DolibarrApi * * @param int $id ID of interventional * @param string $type Type of the interventional + * @param string $source Source of the contact (internal, external) * @return array Object with cleaned properties * * @url GET {id}/contacts * * @throws RestException */ - public function getContacts($id, $type = '') + public function getContacts($id, $type = '', $source = '') { if (!DolibarrApiAccess::$user->hasRight('ficheinter', 'lire')) { throw new RestException(403); @@ -728,8 +729,16 @@ class Interventions extends DolibarrApi throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - $contacts = $this->fichinter->liste_contact(-1, 'external', 0, $type); - $socpeoples = $this->fichinter->liste_contact(-1, 'internal', 0, $type); + if (empty($source) || $source == 'external') { + $contacts = $this->fichinter->liste_contact(-1, 'external', 0, $type); + } else { + $contacts = array(); + } + if (empty($source) || $source == 'internal') { + $socpeoples = $this->fichinter->liste_contact(-1, 'internal', 0, $type); + } else { + $socpeoples = array(); + } $contacts = array_merge($contacts, $socpeoples);