diff --git a/adminstuds.php b/adminstuds.php index a6f22ef..0d03059 100644 --- a/adminstuds.php +++ b/adminstuds.php @@ -137,6 +137,7 @@ if (isset($_POST['update_poll_info'])) { $hidden = isset($_POST['hidden']) ? $inputService->filterBoolean($_POST['hidden']) : false; if ($hidden !== $poll->hidden) { $poll->hidden = $hidden; + $poll->results_publicly_visible = false; $updated = true; } } elseif ($field === 'removePassword') { @@ -148,12 +149,30 @@ if (isset($_POST['update_poll_info'])) { } } elseif ($field === 'password') { $password = isset($_POST['password']) ? $_POST['password'] : null; + + /** + * Did the user choose results to be publicly visible ? + */ $resultsPubliclyVisible = isset($_POST['resultsPubliclyVisible']) ? $inputService->filterBoolean($_POST['resultsPubliclyVisible']) : false; + /** + * If there's one, save the password + */ if (!empty($password)) { $poll->password_hash = PasswordHasher::hash($password); $updated = true; } - if ($resultsPubliclyVisible !== $poll->results_publicly_visible) { + + /** + * If not pasword was set and the poll should be hidden, hide the results + */ + if ($poll->password_hash === null || $poll->hidden === true) { + $poll->results_publicly_visible = false; + } + + /** + * We don't have a password, the poll is hidden and we change the results public visibility + */ + if ($resultsPubliclyVisible !== $poll->results_publicly_visible && $poll->password_hash !== null && $poll->hidden === false) { $poll->results_publicly_visible = $resultsPubliclyVisible; $updated = true; } diff --git a/js/app/studs.js b/js/app/studs.js index 71e360c..7ebef8c 100644 --- a/js/app/studs.js +++ b/js/app/studs.js @@ -103,4 +103,14 @@ $(document).ready(function () { return false; }); + /** + * Disable view public results option when there's a password and the poll is not hidden + */ + $('#password').on('keyup change', function () { + if($('#password').val() && !($('#hidden').attr('checked'))){ + $('#resultsPubliclyVisible').removeAttr('disabled'); + } else { + $('#resultsPubliclyVisible').attr('disabled','disabled'); + } + }); }); diff --git a/locale/br.json b/locale/br.json index e51dde2..9f8990a 100644 --- a/locale/br.json +++ b/locale/br.json @@ -128,6 +128,7 @@ "Cancel the rules edit": "Nullañ embann an aotreoù", "Results are hidden.": "Kuzhet eo an disoc'hoù.", "Results are visible.": "Gwelus eo an disoc'hoù.", + "Only votes are protected": "Only votes are protected", "Password protected": "Gwarezet gant ur ger-tremen", "Votes protected by password": "Gwarezet eo ar mouezhioù gant ur ger-tremen", "No password": "Ger-tremen ebet", diff --git a/locale/de.json b/locale/de.json index d79b339..8b32bb7 100644 --- a/locale/de.json +++ b/locale/de.json @@ -128,6 +128,7 @@ "Cancel the rules edit": "Abbruch, Regeln nicht ändern", "Results are hidden": "Ergebnisse werden ausgeblendet", "Results are visible": "Ergebnisse sind sichtbar", + "Only votes are protected": "Only votes are protected", "Password protected": "Passwortgeschützt", "Votes protected by password": "Wertungen sind passwortgeschützt", "No password": "Kein Passwort", diff --git a/locale/en.json b/locale/en.json index 75cc5a7..cf005a9 100644 --- a/locale/en.json +++ b/locale/en.json @@ -128,6 +128,7 @@ "Cancel the rules edit": "Cancel the rules edit", "Results are hidden": "Results are hidden", "Results are visible": "Results are visible", + "Only votes are protected": "Only votes are protected", "Password protected": "Password protected", "Votes protected by password": "Votes protected by password", "No password": "No password", diff --git a/locale/es.json b/locale/es.json index f9067e3..a267524 100644 --- a/locale/es.json +++ b/locale/es.json @@ -128,6 +128,7 @@ "Cancel the rules edit": "ES_Annuler le changement de permissions", "Results are hidden": "Los resutaldos no son visibles", "Results are visible": "Los resultados son visibles", + "Only votes are protected": "Only votes are protected", "Password protected": "ES_Protégé par mot de passe", "Votes protected by password": "ES_Votes protégés par mot de passe", "No password": "ES_Pas de mot de passe", diff --git a/locale/fr.json b/locale/fr.json index c1d67df..d6288a4 100644 --- a/locale/fr.json +++ b/locale/fr.json @@ -128,6 +128,7 @@ "Cancel the rules edit": "Annuler le changement de permissions", "Results are hidden": "Les résultats sont cachés", "Results are visible": "Les résultats sont visibles", + "Only votes are protected": "Seul les votes sont protégés", "Password protected": "Protégé par mot de passe", "Votes protected by password": "Votes protégés par mot de passe", "No password": "Pas de mot de passe", diff --git a/locale/it.json b/locale/it.json index 3299d08..112a881 100644 --- a/locale/it.json +++ b/locale/it.json @@ -128,6 +128,7 @@ "Cancel the rules edit": "Annullare le modifica dei permessi", "Results are hidden": "I risultati sono nascosti", "Results are visible": "I risultati sono visibili", + "Only votes are protected": "Solo voti sono protetti", "Password protected": "Protetto da una password", "Votes protected by password": "Voti protetti da una password", "No password": "Nessuna password", diff --git a/locale/nl.json b/locale/nl.json index 1ca27e4..3f17a53 100644 --- a/locale/nl.json +++ b/locale/nl.json @@ -128,6 +128,7 @@ "Cancel the rules edit": "Regels bewerken annuleren", "Results are hidden": "Resultaten zijn verborgen.", "Results are visible": "Resultaten zijn zichtbaar.", + "Only votes are protected": "Only votes are protected", "Password protected": "Beveiligd met een wachtwoord", "Votes protected by password": "Stemmen beveiligd met een wachtwoord", "No password": "Geen wachtwoord", diff --git a/locale/oc.json b/locale/oc.json index 18cd661..e2a9811 100644 --- a/locale/oc.json +++ b/locale/oc.json @@ -128,6 +128,7 @@ "Cancel the rules edit": "Anullar lo cambiament de permissions", "Results are hidden": "Los resultats son amagats", "Results are visible": "Los resultats son visibles", + "Only votes are protected": "Only votes are protected", "Password protected": "Protegit per senhal", "Votes protected by password": "Vòtes protegits per senhal", "No password": "Pas cap de senhal", diff --git a/tpl/part/poll_info.tpl b/tpl/part/poll_info.tpl index ebf3562..51a43de 100644 --- a/tpl/part/poll_info.tpl +++ b/tpl/part/poll_info.tpl @@ -154,8 +154,8 @@ {/if}
- results_publicly_visible}checked="checked"{/if}/> - + results_publicly_visible && $poll->hidden == false && (!empty($poll->password_hash))}checked="checked" {elseif ($poll->hidden == true || empty($poll->password_hash))} disabled="disabled"{/if}/> +