From 51d53f3feca946fceac58a0f8d9752940de6b3e5 Mon Sep 17 00:00:00 2001 From: Damien <damien.burel@maarch.org> Date: Wed, 23 May 2018 10:28:43 +0200 Subject: [PATCH] FEAT #7721 Fix update label --- src/app/contact/controllers/ContactGroupController.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/app/contact/controllers/ContactGroupController.php b/src/app/contact/controllers/ContactGroupController.php index a633899810a..9a5f2f9aa53 100644 --- a/src/app/contact/controllers/ContactGroupController.php +++ b/src/app/contact/controllers/ContactGroupController.php @@ -105,7 +105,8 @@ class ContactGroupController } $data = $request->getParams(); - $check = Validator::stringType()->notEmpty()->validate($data['label']); + $check = Validator::intVal()->notEmpty()->validate($data['id']); + $check = $check && Validator::stringType()->notEmpty()->validate($data['label']); $check = $check && Validator::stringType()->notEmpty()->validate($data['description']); $check = $check && Validator::boolType()->validate($data['public']); if (!$check) { @@ -113,7 +114,7 @@ class ContactGroupController } $user = UserModel::getByUserId(['select' => ['id'], 'userId' => $GLOBALS['userId']]); - $existingGroup = ContactGroupModel::get(['select' => [1], 'where' => ['label = ?', 'owner = ?'], 'data' => [$data['label'], $user['id']]]); + $existingGroup = ContactGroupModel::get(['select' => [1], 'where' => ['label = ?', 'owner = ?', 'id != ?'], 'data' => [$data['label'], $user['id'], $data['id']]]); if (!empty($existingGroup)) { return $response->withStatus(400)->withJson(['errors' => _CONTACTS_GROUP_LABEL_ALREADY_EXISTS]); } -- GitLab