diff --git a/app/classes/Framadate/Services/InputService.php b/app/classes/Framadate/Services/InputService.php index 0a06a68..2c5e1da 100644 --- a/app/classes/Framadate/Services/InputService.php +++ b/app/classes/Framadate/Services/InputService.php @@ -76,12 +76,14 @@ class InputService { public function filterMD5($control) { return filter_var($control, FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => MD5_REGEX]]); } - + public function filterInteger($int) { - if (filter_var($int, FILTER_VALIDATE_INT)) { - return $int; - } - return null; + return filter_var($int, FILTER_VALIDATE_INT); + } + + public function filterValueMax($int) + { + return $this->filterInteger($int) >= 1; } public function filterBoolean($boolean) { diff --git a/create_poll.php b/create_poll.php index 48d67b9..91b8ed0 100644 --- a/create_poll.php +++ b/create_poll.php @@ -57,7 +57,7 @@ if ($goToStep2) { $title = $inputService->filterTitle($_POST['title']); $use_ValueMax = isset($_POST['use_ValueMax']) ? $inputService->filterBoolean($_POST['use_ValueMax']) : false; - $ValueMax = $use_ValueMax === true ? $inputService->filterInteger($_POST['ValueMax']) : null; + $ValueMax = $use_ValueMax === true ? $inputService->filterValueMax($_POST['ValueMax']) : null; $use_customized_url = isset($_POST['use_customized_url']) ? $inputService->filterBoolean($_POST['use_customized_url']) : false; $customized_url = $use_customized_url === true ? $inputService->filterId($_POST['customized_url']) : null; @@ -98,10 +98,8 @@ if ($goToStep2) { $_SESSION['form']->use_password = ($use_password !== null); $_SESSION['form']->results_publicly_visible = ($results_publicly_visible !== null); - if ($config['use_smtp'] === true) { - if (empty($mail)) { - $error_on_mail = true; - } + if ($config['use_smtp'] === true && empty($mail)) { + $error_on_mail = true; } if ($title !== $_POST['title']) { @@ -117,11 +115,8 @@ if ($goToStep2) { } } - if ($use_ValueMax) { - if ($use_ValueMax === false) { - $error_on_ValueMax = true; - $error_on_customized_url_msg = __('Error', 'Mauvaise valeur'); - } + if ($use_ValueMax && $ValueMax === false) { + $error_on_ValueMax = true; } if ($name !== $_POST['name']) { @@ -234,7 +229,7 @@ if (!empty($_POST[GO_TO_STEP_2])) { if ($error_on_customized_url) { $errors['customized_url']['aria'] = 'aria-describeby="customized_url" '; $errors['customized_url']['class'] = ' has-error'; - $errors['customized_url']['msg'] = isset($error_on_customized_url_msg) ? $error_on_customized_url_msg : __('Error', 'Something is wrong with the format'); + $errors['customized_url']['msg'] = isset($error_on_customized_url_msg) ? $error_on_customized_url_msg : __('Error', "Something is wrong with the format: customized urls should only consist of alphanumeric characters and hyphens."); } if ($error_on_description) { @@ -250,7 +245,7 @@ if (!empty($_POST[GO_TO_STEP_2])) { } elseif ($error_on_name) { $errors['name']['aria'] = 'aria-describeby="poll_name_error" '; $errors['name']['class'] = ' has-error'; - $errors['name']['msg'] = __('Error', 'Something is wrong with the format'); + $errors['name']['msg'] = __('Error', "Something is wrong with the format: name shouldn't have any spaces before or after"); } if (empty($_POST['mail'])) { @@ -276,7 +271,7 @@ if (!empty($_POST[GO_TO_STEP_2])) { if ($error_on_ValueMax) { $errors['ValueMax']['aria'] = 'aria-describeby="poll_ValueMax" '; $errors['ValueMax']['class'] = ' has-error'; - $errors['ValueMax']['msg'] = __('Error', 'error on ValueMax'); + $errors['ValueMax']['msg'] = __('Error', 'Error on amount of voters limitation : value must be an integer greater than 0'); } } @@ -285,6 +280,7 @@ $useRemoteUser = USE_REMOTE_USER && isset($_SERVER['REMOTE_USER']); $smarty->assign('title', $title); $smarty->assign('useRemoteUser', $useRemoteUser); $smarty->assign('errors', $errors); +$smarty->assign('advanced_errors', $goToStep2 && ($error_on_ValueMax || $error_on_customized_url || $error_on_password || $error_on_password_repeat)); $smarty->assign('use_smtp', $config['use_smtp']); $smarty->assign('default_to_marldown_editor', $config['markdown_editor_by_default']); $smarty->assign('goToStep2', GO_TO_STEP_2); diff --git a/locale/ar.json b/locale/ar.json index 8068fa0..ab63d52 100644 --- a/locale/ar.json +++ b/locale/ar.json @@ -328,7 +328,7 @@ "All voters can modify any vote": "All voters can modify any vote", "Customize the URL": "Customize the URL", "Go to step 2": "الإنتقال إلى الخطوة 2", - "Limit the ammount of voters per option": "Limit the amount of voters per option", + "Limit the amount of voters per option": "Limit the amount of voters per option", "More informations here:": "المزيد من التفاصيل هنا :", "Only the poll maker can see the poll's results": "Only the poll maker can see the poll results", "Optional parameters": "Optional parameters", diff --git a/locale/br.json b/locale/br.json index 01ca765..11cdead 100644 --- a/locale/br.json +++ b/locale/br.json @@ -328,7 +328,7 @@ "All voters can modify any vote": "An holl vouezhierien a c'hall kemmañ an holl vouezhioù", "Customize the URL": "Personelaat an ere", "Go to step 2": "Mont d'ar bazenn 2", - "Limit the ammount of voters per option": "Limit the amount of voters per option", + "Limit the amount of voters per option": "Limit the amount of voters per option", "More informations here:": "Titouroù ouzhpenn amañ:", "Only the poll maker can see the poll's results": "N'eus nemet krouer ar sontadeg a c'hell gwelet an disoc'hoù", "Optional parameters": "Arventennoù diret", diff --git a/locale/de.json b/locale/de.json index 281e4ad..cd13108 100644 --- a/locale/de.json +++ b/locale/de.json @@ -328,7 +328,7 @@ "All voters can modify any vote": "Jeder Teilnehmer kann jede abgegebene Wertung ändern", "Customize the URL": "Link anpassen", "Go to step 2": "Weiter zum 2. Schritt", - "Limit the ammount of voters per option": "Begrenzung der anzahl der aähler pro option", + "Limit the amount of voters per option": "Begrenzung der anzahl der aähler pro option", "More informations here:": "DE_Plus d'informations ici :", "Only the poll maker can see the poll's results": "Einzig der Autor der Abstimmung kann die Ergebnisse einsehen", "Optional parameters": "Optionale Einstellungen", diff --git a/locale/en.json b/locale/en.json index 1d23cb8..2925cd4 100644 --- a/locale/en.json +++ b/locale/en.json @@ -142,7 +142,10 @@ "Poll id already used": "Identifier is already used", "Something is going wrong...": "Something has gone wrong...", "Something is wrong with the format": "Something is wrong with the format", + "Something is wrong with the format: customized urls should only consist of alphanumeric characters and hyphens.": "Something is wrong with the format: customized urls should only consist of alphanumeric characters and hyphens.", + "Something is wrong with the format: name shouldn't have any spaces before or after": "Something is wrong with the format: name shouldn't have any spaces before or after", "The address is not correct! You should enter a valid email address (like r.stallman@outlock.com) in order to receive the link to your poll.": "The address is not correct! You should enter a valid email address (like r.stallman@outlock.com) in order to receive the link to your poll.", + "Error on amount of voters limitation : value must be an integer greater than 0": "Error on amount of voters limitation : value must be an integer greater than 0", "The column already exists": "The column already exists", "The name is invalid.": "The name is invalid.", "The name you've chosen already exist in this poll!": "The name you've chosen already exists in this poll!", @@ -328,7 +331,7 @@ "All voters can modify any vote": "All voters can modify any vote", "Customize the URL": "Customize the URL", "Go to step 2": "Go to step 2", - "Limit the ammount of voters per option": "Limit the amount of voters per option", + "Limit the amount of voters per option": "Limit the amount of voters per option", "More informations here:": "More informations here:", "Only the poll maker can see the poll's results": "Only the poll maker can see the poll results", "Optional parameters": "Optional parameters", diff --git a/locale/es.json b/locale/es.json index c47caa9..66f9aae 100644 --- a/locale/es.json +++ b/locale/es.json @@ -328,7 +328,7 @@ "All voters can modify any vote": "Los votos pueden ser modificados por cualquiera", "Customize the URL": "ES_Personnaliser le lien", "Go to step 2": "Ir al paso número 2", - "Limit the ammount of voters per option": "Limitar el número de votantes por opción", + "Limit the amount of voters per option": "Limitar el número de votantes por opción", "More informations here:": "ES_Plus d'informations ici :", "Only the poll maker can see the poll's results": "Solo el creador de la encuesta puede ver los resultados", "Optional parameters": "ES_Paramètres optionnels", diff --git a/locale/fr.json b/locale/fr.json index 0e28bcd..919c970 100644 --- a/locale/fr.json +++ b/locale/fr.json @@ -142,7 +142,10 @@ "Poll id already used": "L'identifiant est déjà utilisé", "Something is going wrong...": "Quelque chose ne va pas...", "Something is wrong with the format": "Quelque chose ne va pas avec le format", + "Something is wrong with the format: customized urls should only consist of alphanumeric characters and hyphens.": "Quelque chose ne va pas avec le format: les urls personalisées devraient contenir uniquement des caractères alphanumériques et des tirets.", + "Something is wrong with the format: name shouldn't have any spaces before or after": "Quelque chose ne va pas avec le format : le nom ne devrait pas contenir d'espaces avant ou après", "The address is not correct! You should enter a valid email address (like r.stallman@outlock.com) in order to receive the link to your poll.": "L'adresse saisie n'est pas correcte ! Il faut une adresse électronique valide (par exemple r.stallman@outlock.com) pour recevoir le lien vers le sondage.", + "Error on amount of voters limitation : value must be an integer greater than 0": "Erreur sur le nombre maximum de votants : la valeur doit être un entier supérieur à 0", "The column already exists": "La colonne existe déjà", "The name is invalid.": "Le nom n'est pas valide.", "The name you've chosen already exist in this poll!": "Le nom que vous avez choisi existe déjà !", @@ -328,7 +331,7 @@ "All voters can modify any vote": "Tou·te·s les sondé·e·s peuvent modifier tous les votes", "Customize the URL": "Personnaliser le lien", "Go to step 2": "Aller à l'étape 2", - "Limit the ammount of voters per option": "limiter le nombre de votants par option", + "Limit the amount of voters per option": "limiter le nombre de votants par option", "More informations here:": "Plus d'informations ici :", "Only the poll maker can see the poll's results": "Seul le ou la créateur·rice du sondage peut voir les résultats", "Optional parameters": "Paramètres facultatifs", diff --git a/locale/fr_FR.json b/locale/fr_FR.json index 0e28bcd..f995955 100644 --- a/locale/fr_FR.json +++ b/locale/fr_FR.json @@ -142,7 +142,10 @@ "Poll id already used": "L'identifiant est déjà utilisé", "Something is going wrong...": "Quelque chose ne va pas...", "Something is wrong with the format": "Quelque chose ne va pas avec le format", + "Something is wrong with the format: customized urls should only consist of alphanumeric characters and hyphens.": "Quelque chose ne va pas avec le format : les urls personalisées devraient contenir uniquement des caractères alphanumériques et des tirets.", + "Something is wrong with the format: name shouldn't have any spaces before or after": "Quelque chose ne va pas avec le format : le nom ne devrait pas contenir d'espaces avant ou après", "The address is not correct! You should enter a valid email address (like r.stallman@outlock.com) in order to receive the link to your poll.": "L'adresse saisie n'est pas correcte ! Il faut une adresse électronique valide (par exemple r.stallman@outlock.com) pour recevoir le lien vers le sondage.", + "Error on amount of voters limitation : value must be an integer greater than 0": "Erreur sur le nombre maximum de votants : la valeur doit être un entier supérieur à 0", "The column already exists": "La colonne existe déjà", "The name is invalid.": "Le nom n'est pas valide.", "The name you've chosen already exist in this poll!": "Le nom que vous avez choisi existe déjà !", @@ -328,7 +331,7 @@ "All voters can modify any vote": "Tou·te·s les sondé·e·s peuvent modifier tous les votes", "Customize the URL": "Personnaliser le lien", "Go to step 2": "Aller à l'étape 2", - "Limit the ammount of voters per option": "limiter le nombre de votants par option", + "Limit the amount of voters per option": "limiter le nombre de votants par option", "More informations here:": "Plus d'informations ici :", "Only the poll maker can see the poll's results": "Seul le ou la créateur·rice du sondage peut voir les résultats", "Optional parameters": "Paramètres facultatifs", diff --git a/locale/it.json b/locale/it.json index de4939f..6bfa519 100644 --- a/locale/it.json +++ b/locale/it.json @@ -328,7 +328,7 @@ "All voters can modify any vote": "Tutti i votanti possono cambiare tutti i voti", "Customize the URL": "Personalizzare il link", "Go to step 2": "Andare al punto 2", - "Limit the ammount of voters per option": "Limitare la quantità di elettori per opzione", + "Limit the amount of voters per option": "Limitare la quantità di elettori per opzione", "More informations here:": "IT_Plus d'informations ici :", "Only the poll maker can see the poll's results": "Solo il creatore sondaggio possono vedere i risultati", "Optional parameters": "Parametri opzionali", diff --git a/locale/nl.json b/locale/nl.json index 1c54aa5..df17907 100644 --- a/locale/nl.json +++ b/locale/nl.json @@ -328,7 +328,7 @@ "All voters can modify any vote": "Alle stemmers kunnen elke stem aanpassen", "Customize the URL": "Link verpersoonlijken", "Go to step 2": "Ga naar stap 2", - "Limit the ammount of voters per option": "Limit the amount of voters per option", + "Limit the amount of voters per option": "Limit the amount of voters per option", "More informations here:": "More informations here:", "Only the poll maker can see the poll's results": "Alleen degene die de poll aangemaakt heeft kan de resultaten zien", "Optional parameters": "Optionele parameters", diff --git a/locale/oc.json b/locale/oc.json index 1b0f45a..1bb797c 100644 --- a/locale/oc.json +++ b/locale/oc.json @@ -328,7 +328,7 @@ "All voters can modify any vote": "Totes los votants pòdon modificar sos vòtes", "Customize the URL": "Personalizar lo ligam", "Go to step 2": "Anar a l’etapa 2", - "Limit the ammount of voters per option": "Limitar lo nombre de votants per opcion", + "Limit the amount of voters per option": "Limitar lo nombre de votants per opcion", "More informations here:": "Mai d’informacion aquí :", "Only the poll maker can see the poll's results": "Solament lo creator del sondatge pòt veire los resultats", "Optional parameters": "Paramètres opcionals", diff --git a/tpl/create_poll.tpl b/tpl/create_poll.tpl index fe87f9a..59353e3 100644 --- a/tpl/create_poll.tpl +++ b/tpl/create_poll.tpl @@ -28,7 +28,7 @@ {if $useRemoteUser} {$form->admin_name} {else} - + {/if} @@ -51,7 +51,7 @@ {if $useRemoteUser} {$form->admin_mail} {else} - + {/if} @@ -69,7 +69,7 @@
-
@@ -111,7 +111,7 @@ - {__('Step 1', "Optional parameters")} @@ -121,32 +121,32 @@
-
+
{* Poll identifier *}
{* Value MAX *} -
+
-
-