From 0e51a7a5292849dffef81bbb6760d01b010205b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Sat, 24 Jan 2026 13:42:54 +0100 Subject: [PATCH] Add source parameter to getContacts on api interventional (#36931) Added a new parameter 'source' to the getContacts method to filter contacts based on their source (internal or external). Updated the method to handle the new parameter appropriately. propose to add this feature on all getContacts method. Co-authored-by: Laurent Destailleur --- .../class/api_interventions.class.php | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) 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);