Commit 3f8e7443 authored by Guillaume Heurtier's avatar Guillaume Heurtier
Browse files

FIX #18428 TIME 2:45 fix update contact + fix use m2m with old config

parent 2c0671b1
......@@ -334,11 +334,16 @@ class ContactController
return $response->withStatus(400)->withJson(['errors' => $control['errors']]);
}
$contact = ContactModel::getById(['id' => $args['id'], 'select' => [1]]);
$contact = ContactModel::getById(['id' => $args['id'], 'select' => ['communication_means']]);
if (empty($contact)) {
return $response->withStatus(400)->withJson(['errors' => 'Contact does not exist']);
}
$contact['communication_means'] = json_decode($contact['communication_means'], true);
$contactBody = [];
if (!empty($contact['communication_means']['password'])) {
$contactBody['password'] = $contact['communication_means']['password'];
}
if (!empty($body['communicationMeans'])) {
if (filter_var($body['communicationMeans']['email'], FILTER_VALIDATE_EMAIL)) {
$contactBody['email'] = $body['communicationMeans']['email'];
......
......@@ -246,9 +246,13 @@ class SendMessageExchangeController
return $response->withStatus(403)->withJson(['errors' => 'http or https missing']);
}
$url = str_replace($prefix, '', $ArchivalAgencyCommunicationType['value']);
$login = $aArchivalAgencyCommunicationType['login'];
$password = PasswordModel::decrypt(['cryptedPassword' => $aArchivalAgencyCommunicationType['password']]);
$ArchivalAgencyCommunicationType['value'] = $prefix . $login . ':' . $password . '@' . $url;
$login = $aArchivalAgencyCommunicationType['login'] ?? '';
$password = !empty($aArchivalAgencyCommunicationType['password']) ? PasswordModel::decrypt(['cryptedPassword' => $aArchivalAgencyCommunicationType['password']]) : '';
$ArchivalAgencyCommunicationType['value'] = $prefix;
if (!empty($login) && !empty($password)) {
$ArchivalAgencyCommunicationType['value'] .= $login . ':' . $password . '@';
}
$ArchivalAgencyCommunicationType['value'] .= $url;
}
}
$ArchivalAgencyContactInformations = ContactModel::getById(['select' => ['*'], 'id' => $contactId]);
......
......@@ -839,7 +839,7 @@ class AutoCompleteController
$externalId = json_decode($contact['external_id'], true);
$communicationMeans = json_decode($contact['communication_means'], true);
$autoContact['m2m'] = $externalId['m2m'];
$autoContact['communicationMeans'] = $communicationMeans['uri'] ?? $communicationMeans['email'];
$autoContact['communicationMeans'] = $communicationMeans['url'] ?? $communicationMeans['email'];
$autocompleteData[] = $autoContact;
}
......@@ -905,8 +905,8 @@ class AutoCompleteController
}
}
return $response->withJson($unitOrganizations);
}
return $response->withJson($unitOrganizations);
}
public static function getFolders(Request $request, Response $response)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment