From 47676de959a368f9a294226188fc7cc66fa924e7 Mon Sep 17 00:00:00 2001 From: sc979 <34628915+sc979@users.noreply.github.com> Date: Mon, 3 Jun 2019 14:31:30 +0200 Subject: [PATCH] enh(BE): optimizing the data sent when importing contact (#7559) * enh(BE): optimizing the data sent when importing data * renaming variable and removing useless steps * udpating the composer.lock * fix(ldap): login after manual import --- composer.lock | 8 +++---- .../contact/ldapImportContact.php | 21 +++++++++++++++---- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/composer.lock b/composer.lock index 0e8bc2372a8..de64f10b6c4 100644 --- a/composer.lock +++ b/composer.lock @@ -1043,12 +1043,12 @@ "source": { "type": "git", "url": "https://github.com/centreon/centreon-test-lib.git", - "reference": "b049251c41d1548bd544f927dd2efa629c830e15" + "reference": "3ec040d64b8a5315866f0d0bb24a459f0e081b80" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/centreon/centreon-test-lib/zipball/b049251c41d1548bd544f927dd2efa629c830e15", - "reference": "b049251c41d1548bd544f927dd2efa629c830e15", + "url": "https://api.github.com/repos/centreon/centreon-test-lib/zipball/3ec040d64b8a5315866f0d0bb24a459f0e081b80", + "reference": "3ec040d64b8a5315866f0d0bb24a459f0e081b80", "shasum": "" }, "require": { @@ -1084,7 +1084,7 @@ "phpunit", "testing" ], - "time": "2019-05-06 08:43:43" + "time": "2019-05-24 08:06:44" }, { "name": "container-interop/container-interop", diff --git a/www/include/configuration/configObject/contact/ldapImportContact.php b/www/include/configuration/configObject/contact/ldapImportContact.php index 341e0ea1de7..1d656f4efa9 100644 --- a/www/include/configuration/configObject/contact/ldapImportContact.php +++ b/www/include/configuration/configObject/contact/ldapImportContact.php @@ -114,16 +114,29 @@ $valid = false; if ($form->validate()) { - if (isset($_POST["contact_select"]["select"])) { - if ($form->getSubmitValue("submitA")) { - insertLdapContactInDB($_POST["contact_select"]); + if (isset($_POST["contact_select"]["select"]) && $form->getSubmitValue("submitA")) { + // extracting the chosen contacts Id from the POST + $selectedUsers = $_POST["contact_select"]['select']; + unset($_POST["contact_select"]['select']); + + // removing the useless data sent + $arrayToReturn = array(); + foreach ($_POST["contact_select"] as $key => $subKey) { + $arrayToReturn[$key] = array_intersect_key($_POST["contact_select"][$key], $selectedUsers); } + + // restoring the filtered $_POST['contact_select']['select'] as it's needed in some DB-Func.php functions + $arrayToReturn['select'] = $selectedUsers; + $_POST['contact_select'] = $arrayToReturn; + unset($selectedUsers); + unset($arrayToReturn); + + insertLdapContactInDB($_POST["contact_select"]); } $form->freeze(); $valid = true; } - if ($valid) { require_once($path . "listContact.php"); } else {