diff --git a/app/classes/Framadate/Services/InputService.php b/app/classes/Framadate/Services/InputService.php index 0a06a686fd400ba8a80804a3fe2e6e312fd1d52f..2c5e1dabdcadc16f3d15216a5d458c4a1fdfd523 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 48d67b94982f3491270a5876b69df73217d10cfd..91b8ed0080f3e4bffdd817b1b6b38fb82377f3c9 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 8068fa0c84078dda910b1f71f9f1f8698b8d8ae1..ab63d52522df3bcb26b5919547301a775868991e 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 01ca765b179c8eea74ddf994f326f20d978dcb06..11cdead98a0b711c3a9f3d43dd5ff49f82a09eb3 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 281e4ada9e03f34b59defd5d42a9c25c3d14d5e3..cd131084a394028bd6d00019985d8779ed733e25 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 1d23cb863594cfcc9562f6dedf43a6963ddf7e33..2925cd4e3969ae254631fd4ca80d7dd4185124e3 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 c47caa93251d47c5fc9db7a46d75e4e5e552b5c3..66f9aae14a3ad69d8798ec60f80598f154d09ad4 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 0e28bcd10f875836d21cf2b9b5ecc26df13b2bc6..919c970000d51a930d8c6a0408fe129ba1cda864 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 0e28bcd10f875836d21cf2b9b5ecc26df13b2bc6..f9959550b2628df9b7b7ceee085679580a15c9f2 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 de4939f3e51de8a6c8417c469a25ee32b93a0869..6bfa5193c0cd550af278ea691271019a071c5f65 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 1c54aa58d220f8006c562021103bcfe43c07c2a8..df179072a32cd0920f0893581897dd5d3aeeb9ff 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 1b0f45a8f71f4f4fc0047cb3f0994119bd40e4fb..1bb797cc2b4ae5f6c869745a33f7f5f4e9000247 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 fe87f9a4ea466818926e3af1b48fac95bd8989f8..59353e3993705f5417a6889c713cd8c7895d13f9 100644 --- a/tpl/create_poll.tpl +++ b/tpl/create_poll.tpl @@ -28,7 +28,7 @@ {if $useRemoteUser} <input type="hidden" name="name" value="{$form->admin_name}" />{$form->admin_name} {else} - <input id="yourname" type="text" name="name" class="form-control" {$errors['name']['aria']} value="{$poll_name|html}" /> + <input id="yourname" type="text" required name="name" class="form-control" {$errors['name']['aria']} value="{$poll_name|html}" /> {/if} </div> </div> @@ -51,7 +51,7 @@ {if $useRemoteUser} <input type="hidden" name="mail" value="{$form->admin_mail}">{$form->admin_mail} {else} - <input id="email" type="text" name="mail" class="form-control" {$errors['email']['aria']} value="{$poll_mail|html}" /> + <input id="email" required type="email" name="mail" class="form-control" {$errors['email']['aria']} value="{$poll_mail|html}" /> {/if} </div> </div> @@ -69,7 +69,7 @@ <label for="poll_title" class="col-sm-4 control-label">{__('Step 1', 'Poll title')} *</label> <div class="col-sm-8"> - <input id="poll_title" type="text" name="title" class="form-control" {$errors['title']['aria']} + <input id="poll_title" type="text" name="title" class="form-control" required {$errors['title']['aria']} value="{$poll_title|html}"/> </div> </div> @@ -111,7 +111,7 @@ <span class="lead visible-xs-inline"> <i class="glyphicon glyphicon-cog" aria-hidden="true"></i> </span> - <a class="optionnal-parameters collapsed lead" role="button" data-toggle="collapse" href="#optionnal" aria-expanded="false" aria-controls="optionnal"> + <a class="optionnal-parameters {if !$advanced_errors}collapsed{/if} lead" role="button" data-toggle="collapse" href="#optionnal" aria-expanded="{if $advanced_errors}false{else}true{/if}" aria-controls="optionnal"> {__('Step 1', "Optional parameters")} <i class="caret" aria-hidden="true"></i> <i class="caret caret-up" aria-hidden="true"></i> @@ -121,32 +121,32 @@ <div class="clearfix"></div> - <div class="collapse" id="optionnal"> + <div class="collapse{if $advanced_errors} in{/if}" id="optionnal" {if $advanced_errors}aria-expanded="true"{/if}> {* Poll identifier *} <div class="form-group {$errors['customized_url']['class']}"> {* Value MAX *} - <div class="form-group"> + <div class="form-group {$errors['ValueMax']['class']}"> <label for="use_valueMax" class="col-sm-4 control-label"> {__('Step 1', 'Value Max')}<br/> </label> <div class="col-sm-8"> <div class="checkbox"> <label> - <input id="use_ValueMax" name="use_ValueMax" type="checkbox" > - {__('Step 1', "Limit the ammount of voters per option")} + <input id="use_ValueMax" name="use_ValueMax" type="checkbox" {if $use_ValueMax}checked{/if}> + {__('Step 1', "Limit the amount of voters per option")} </label> </div> </div> </div> - <div class="form-group"> - <div id="ValueMax"{if !$use_ValueMax} class="hidden"{/if}> + <div class="form-group {$errors['ValueMax']['class']}"> + <div id="ValueMax" {if !$use_ValueMax}class="hidden"{/if}> <div class="col-sm-offset-4 col-sm-8"> <label> - <input id="ValueMax" type="number" min= "0" name="ValueMax"> + <input id="ValueMax" type="number" min="0" name="ValueMax" value="{$ValueMax|html}" {$errors['ValueMax']['aria']}> {__('Step 1', "ValueMax instructions")} </label> @@ -155,6 +155,14 @@ </div> </div> + {if !empty($errors['ValueMax']['msg'])} + <div class="alert alert-danger"> + <p id="poll_customized_url_error"> + {$errors['ValueMax']['msg']} + </p> + </div> + {/if} + {* Poll identifier *} <div class="form-group {$errors['customized_url']['class']}">