From b468e27bd359a3f8801a3ee5b635aed1a26ad792 Mon Sep 17 00:00:00 2001 From: schapron Date: Thu, 23 May 2019 15:41:46 +0200 Subject: [PATCH 1/4] enh(BE): optimizing the data sent when importing data --- .../configObject/contact/ldapImportContact.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/www/include/configuration/configObject/contact/ldapImportContact.php b/www/include/configuration/configObject/contact/ldapImportContact.php index 341e0ea1de7..6e3e8a314dd 100644 --- a/www/include/configuration/configObject/contact/ldapImportContact.php +++ b/www/include/configuration/configObject/contact/ldapImportContact.php @@ -116,7 +116,21 @@ if ($form->validate()) { if (isset($_POST["contact_select"]["select"])) { if ($form->getSubmitValue("submitA")) { - insertLdapContactInDB($_POST["contact_select"]); + // 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) { + $arrayToKeep[$key] = array_intersect_key($_POST["contact_select"][$key], $selectedUsers); + $arrayToReturn += $arrayToKeep; + } + + // restoring the $_POST['select'] array in the filtered results, in case we need it + $arrayToReturn += $selectedUsers; + + insertLdapContactInDB($arrayToReturn); } } $form->freeze(); From fb7584cf8ecf14886f8a0ecd77e0d71728eb7905 Mon Sep 17 00:00:00 2001 From: schapron Date: Thu, 23 May 2019 16:31:56 +0200 Subject: [PATCH 2/4] renaming variable and removing useless steps --- .../contact/ldapImportContact.php | 31 ++++++++----------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/www/include/configuration/configObject/contact/ldapImportContact.php b/www/include/configuration/configObject/contact/ldapImportContact.php index 6e3e8a314dd..befdecd0834 100644 --- a/www/include/configuration/configObject/contact/ldapImportContact.php +++ b/www/include/configuration/configObject/contact/ldapImportContact.php @@ -114,30 +114,25 @@ $valid = false; if ($form->validate()) { - if (isset($_POST["contact_select"]["select"])) { - if ($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) { - $arrayToKeep[$key] = array_intersect_key($_POST["contact_select"][$key], $selectedUsers); - $arrayToReturn += $arrayToKeep; - } - - // restoring the $_POST['select'] array in the filtered results, in case we need it - $arrayToReturn += $selectedUsers; - - insertLdapContactInDB($arrayToReturn); + 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 $_POST['select'] array in the filtered results, in case we need it + $arrayToReturn['select'] = $selectedUsers; + insertLdapContactInDB($arrayToReturn); } $form->freeze(); $valid = true; } - if ($valid) { require_once($path . "listContact.php"); } else { From 04e51d8715891ee1f909ecd178f10af01cac4fd3 Mon Sep 17 00:00:00 2001 From: schapron Date: Fri, 24 May 2019 11:20:00 +0200 Subject: [PATCH 3/4] udpating the composer.lock --- composer.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 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", From 252efb30500632ea14e85727a5acaacf2a325676 Mon Sep 17 00:00:00 2001 From: schapron Date: Mon, 27 May 2019 11:15:23 +0200 Subject: [PATCH 4/4] fix(ldap): login after manual import --- .../configObject/contact/ldapImportContact.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/www/include/configuration/configObject/contact/ldapImportContact.php b/www/include/configuration/configObject/contact/ldapImportContact.php index befdecd0834..1d656f4efa9 100644 --- a/www/include/configuration/configObject/contact/ldapImportContact.php +++ b/www/include/configuration/configObject/contact/ldapImportContact.php @@ -125,9 +125,13 @@ $arrayToReturn[$key] = array_intersect_key($_POST["contact_select"][$key], $selectedUsers); } - // restoring the $_POST['select'] array in the filtered results, in case we need it + // restoring the filtered $_POST['contact_select']['select'] as it's needed in some DB-Func.php functions $arrayToReturn['select'] = $selectedUsers; - insertLdapContactInDB($arrayToReturn); + $_POST['contact_select'] = $arrayToReturn; + unset($selectedUsers); + unset($arrayToReturn); + + insertLdapContactInDB($_POST["contact_select"]); } $form->freeze(); $valid = true;