Commit fe96aba0 authored by Mathieu's avatar Mathieu
Browse files

FIX #18428 TIME 20:00 hide credentials maarch2maarch

parent 4832ff73
......@@ -10,7 +10,9 @@
<attachment_type>simple_attachment</attachment_type>
</res_attachments>
<basketRedirection_afterUpload>NumericBasket</basketRedirection_afterUpload><!--basketId-->
<m2m_communication>https://cchaplin:maarch@demo.maarchcourrier.com</m2m_communication><!--moyen de communication de l'instance : email ou uri -->
<m2m_communication>https://demo.maarchcourrier.com</m2m_communication><!-- moyen de communication de l'instance : email ou uri -->
<m2m_login>cchaplin</m2m_login>
<m2m_password>maarch</m2m_password>
<annuaries>
<enabled>false</enabled>
<organization>organization</organization>
......
......@@ -274,7 +274,9 @@ class ConfigurationController
'basketToRedirect' => $xmlConfig['basketRedirection_afterUpload'][0],
'communications' => [
'email' => $xmlConfig['m2m_communication_type']['email'],
'uri' => $xmlConfig['m2m_communication_type']['url']
'uri' => $xmlConfig['m2m_communication_type']['url'],
'login' => $xmlConfig['m2m_login']
// 'password' => $xmlConfig['m2m_communication']['password']
]
];
......@@ -377,6 +379,8 @@ class ConfigurationController
$loadedXml->res_attachments->attachment_type = $attachmentType['type_id'];
$loadedXml->basketRedirection_afterUpload = $body['basketToRedirect'];
$loadedXml->m2m_communication = implode(',', $communication);
$loadedXml->m2m_login = $body['m2mLogin'];
$loadedXml->m2m_password = $body['m2mPassword'];
unset($loadedXml->annuaries);
$loadedXml->annuaries->enabled = $body['annuary']['enabled'] ? 'true' : 'false';
......
......@@ -36,6 +36,7 @@ use Slim\Http\Response;
use SrcCore\controllers\AutoCompleteController;
use SrcCore\models\CoreConfigModel;
use SrcCore\models\DatabaseModel;
use SrcCore\models\PasswordModel;
use SrcCore\models\TextFormatModel;
use SrcCore\models\ValidatorModel;
use User\models\UserModel;
......@@ -152,13 +153,19 @@ class ContactController
}
if (!empty($body['communicationMeans'])) {
if (filter_var($body['communicationMeans'], FILTER_VALIDATE_EMAIL)) {
$body['communicationMeans'] = ['email' => $body['communicationMeans']];
} elseif (filter_var($body['communicationMeans'], FILTER_VALIDATE_URL)) {
$body['communicationMeans'] = ['url' => $body['communicationMeans']];
if (filter_var($body['communicationMeans']['email'], FILTER_VALIDATE_EMAIL)) {
$contactBody['email'] = $body['communicationMeans']['email'];
} elseif (filter_var($body['communicationMeans']['uri'], FILTER_VALIDATE_URL)) {
$contactBody['uri'] = $body['communicationMeans']['uri'];
} else {
return $response->withStatus(400)->withJson(['errors' => _COMMUNICATION_MEANS_VALIDATOR]);
}
if (!empty($body['communicationMeans']['login'])) {
$contactBody['login'] = $body['communicationMeans']['login'];
}
if (!empty($body['communicationMeans']['password'])) {
$contactBody['password'] = PasswordModel::encrypt(['password' => $body['communicationMeans']['password']]);
}
}
$annuaryReturn = ContactController::addContactToM2MAnnuary(['body' => $body]);
......@@ -273,7 +280,13 @@ class ContactController
}
if (!empty($rawContact['communication_means'])) {
$communicationMeans = json_decode($rawContact['communication_means'], true);
$contact['communicationMeans'] = $communicationMeans['url'] ?? $communicationMeans['email'];
// $communicationMeans[] = ??
if(!empty($communicationMeans['uri'])) {
$contact['communicationMeans']['uri'] = $communicationMeans['uri'];
} elseif (!empty($communicationMeans['email'])) {
$contact['communicationMeans']['email'] = $communicationMeans['email'];
}
$contact['communicationMeans']['login'] = $communicationMeans['login'];
}
$filling = ContactController::getFillingRate(['contactId' => $rawContact['id']]);
......@@ -328,14 +341,23 @@ class ContactController
}
if (!empty($body['communicationMeans'])) {
if (filter_var($body['communicationMeans'], FILTER_VALIDATE_EMAIL)) {
$body['communicationMeans'] = ['email' => $body['communicationMeans']];
} elseif (filter_var($body['communicationMeans'], FILTER_VALIDATE_URL)) {
$body['communicationMeans'] = ['url' => $body['communicationMeans']];
if (filter_var($body['communicationMeans']['email'], FILTER_VALIDATE_EMAIL)) {
$contactBody['email'] = $body['communicationMeans']['email'];
} elseif (filter_var($body['communicationMeans']['uri'], FILTER_VALIDATE_URL)) {
$contactBody['uri'] = $body['communicationMeans']['uri'];
} else {
unset($body['communicationMeans']);
unset($contactBody);
}
if (!empty($body['communicationMeans']['login'])) {
$contactBody['login'] = $body['communicationMeans']['login'];
}
if (!empty($body['communicationMeans']['password'])) {
$contactBody['password'] = PasswordModel::encrypt(['password' => $body['communicationMeans']['password']]);
}
}
$annuaryReturn = ContactController::addContactToM2MAnnuary(['body' => $body]);
$body = $annuaryReturn['body'];
......@@ -365,7 +387,7 @@ class ContactController
'address_country' => $body['addressCountry'] ?? null,
'email' => $body['email'] ?? null,
'phone' => $body['phone'] ?? null,
'communication_means' => !empty($body['communicationMeans']) ? json_encode($body['communicationMeans']) : null,
'communication_means' => !empty($contactBody) ? json_encode($contactBody) : null,
'notes' => $body['notes'] ?? null,
'modification_date' => 'CURRENT_TIMESTAMP',
'custom_fields' => !empty($body['customFields']) ? json_encode($body['customFields']) : null,
......
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