Refactor contact deletion logic in API proposals (#35668)

* Refactor contact deletion logic in API proposals

* Fix formatting issue in delete contact logic

---------

Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
Charlène Benke
2025-10-07 20:50:45 +02:00
committed by GitHub
parent 345a256ef6
commit 07518a6865

View File

@@ -782,9 +782,8 @@ class Proposals extends DolibarrApi
if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) {
throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
foreach (array('internal', 'external') as $source) {
$contacts = $this->propal->liste_contact(); $contacts = $this->propal->liste_contact(-1, $source);
foreach ($contacts as $contact) { foreach ($contacts as $contact) {
if ($contact['id'] == $contactid && $contact['code'] == $type) { if ($contact['id'] == $contactid && $contact['code'] == $type) {
$result = $this->propal->delete_contact($contact['rowid']); $result = $this->propal->delete_contact($contact['rowid']);
@@ -794,7 +793,7 @@ class Proposals extends DolibarrApi
} }
} }
} }
}
return $this->_cleanObjectDatas($this->propal); return $this->_cleanObjectDatas($this->propal);
} }