From e1b4d9e97159035661f668711072b6712540e391 Mon Sep 17 00:00:00 2001 From: "florian.azizian" <florian.azizian@maarch.org> Date: Fri, 27 Dec 2019 11:55:02 +0100 Subject: [PATCH] FEAT #12635 TIME 0:15 delete contact from contact group list + fix tu configuration --- src/app/contact/controllers/ContactController.php | 3 +++ .../contact/models/ContactGroupModelAbstract.php | 14 ++++++++++++++ .../configuration/ConfigurationControllerTest.php | 8 +++++--- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/app/contact/controllers/ContactController.php b/src/app/contact/controllers/ContactController.php index b7782956fa1..cf3c5c1013e 100755 --- a/src/app/contact/controllers/ContactController.php +++ b/src/app/contact/controllers/ContactController.php @@ -15,6 +15,7 @@ namespace Contact\controllers; use Contact\models\ContactCustomFieldListModel; use Contact\models\ContactFillingModel; +use Contact\models\ContactGroupModel; use Contact\models\ContactModel; use Contact\models\ContactParameterModel; use Entity\models\EntityModel; @@ -379,6 +380,8 @@ class ContactController 'data' => [$args['id']] ]); + ContactGroupModel::deleteByContactId(['contactId' => $args['id']]); + $historyInfoContact = ''; if (!empty($contact[0]['firstname']) || !empty($contact[0]['lastname'])) { $historyInfoContact .= $contact[0]['firstname'] . ' ' . $contact[0]['lastname']; diff --git a/src/app/contact/models/ContactGroupModelAbstract.php b/src/app/contact/models/ContactGroupModelAbstract.php index d7969083281..a1ed7996bda 100755 --- a/src/app/contact/models/ContactGroupModelAbstract.php +++ b/src/app/contact/models/ContactGroupModelAbstract.php @@ -157,4 +157,18 @@ abstract class ContactGroupModelAbstract return true; } + + public static function deleteByContactId(array $aArgs) + { + ValidatorModel::notEmpty($aArgs, ['contactId']); + ValidatorModel::intVal($aArgs, ['contactId']); + + DatabaseModel::delete([ + 'table' => 'contacts_groups_lists', + 'where' => ['contact_id = ?'], + 'data' => [$aArgs['contactId']] + ]); + + return true; + } } diff --git a/test/unitTests/app/configuration/ConfigurationControllerTest.php b/test/unitTests/app/configuration/ConfigurationControllerTest.php index 6f11dde8836..f6628ab5382 100755 --- a/test/unitTests/app/configuration/ConfigurationControllerTest.php +++ b/test/unitTests/app/configuration/ConfigurationControllerTest.php @@ -120,7 +120,8 @@ class ConfigurationControllerTest extends TestCase $request = \Slim\Http\Request::createFromEnvironment($environment); $aArgs = [ - 'type' => 'sendmail' + 'type' => 'sendmail', + 'from' => 'notifications@maarch.org' ]; $fullRequest = \httpRequestCustom::addContentInBody($aArgs, $request); @@ -141,9 +142,10 @@ class ConfigurationControllerTest extends TestCase $jsonTest = json_encode( [ - 'type' => 'sendmail', + 'type' => 'sendmail', + 'from' => 'notifications@maarch.org', 'passwordAlreadyExists' => false, - 'charset' => 'utf-8' + 'charset' => 'utf-8' ] ); -- GitLab