From 013aeaecd11cbc9fa711a56f8d67b5e6f1a02b95 Mon Sep 17 00:00:00 2001 From: Olivier PEREZ Date: Sat, 5 Dec 2015 17:27:18 +0100 Subject: [PATCH] UrlNaming - Check if poll id is already used --- create_poll.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/create_poll.php b/create_poll.php index 15f4a80..fefdbe9 100644 --- a/create_poll.php +++ b/create_poll.php @@ -18,6 +18,7 @@ */ use Framadate\Form; +use Framadate\Repositories\RepositoryFactory; use Framadate\Security\PasswordHasher; use Framadate\Services\InputService; use Framadate\Utils; @@ -31,6 +32,7 @@ const GO_TO_STEP_2 = 'gotostep2'; /*----------*/ $inputService = new InputService(); +$pollRepository = RepositoryFactory::pollRepository(); /* PAGE */ /* ---- */ @@ -100,6 +102,9 @@ if ($goToStep2) { if ($id === false) { $error_on_id = true; + } else if ($pollRepository->existsById($id)) { + $error_on_id = true; + $error_on_id_msg = __('Error', 'Poll id already used'); } if ($name !== $_POST['name']) { @@ -209,7 +214,7 @@ if (!empty($_POST[GO_TO_STEP_2])) { if ($error_on_id) { $errors['id']['aria'] = 'aria-describeby="poll_comment_error" '; $errors['id']['class'] = ' has-error'; - $errors['id']['msg'] = __('Error', 'Something is wrong with the format'); + $errors['id']['msg'] = isset($error_on_id_msg) ? $error_on_id_msg : __('Error', 'Something is wrong with the format'); } if ($error_on_description) {