Merge branch 'fix-password-function' into 'master'

issue 240 desactivation checkbox resultat public

Closes #240

See merge request framasoft/framadate!216
This commit is contained in:
Thomas Citharel 2018-02-20 11:56:46 +01:00
commit 05e4b820fb
11 changed files with 40 additions and 3 deletions

View File

@ -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;
}

View File

@ -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');
}
});
});

View File

@ -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",

View File

@ -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",

View File

@ -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",

View File

@ -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",

View File

@ -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",

View File

@ -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",

View File

@ -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",

View File

@ -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",

View File

@ -154,8 +154,8 @@
{/if}
<div id="password_information">
<div class="input-group">
<input type="checkbox" id="resultsPubliclyVisible" name="resultsPubliclyVisible" {if $poll->results_publicly_visible}checked="checked"{/if}/>
<label for="resultsPubliclyVisible">{__('PollInfo', 'Results are visible')}</label>
<input type="checkbox" id="resultsPubliclyVisible" name="resultsPubliclyVisible" {if $poll->results_publicly_visible && $poll->hidden == false && (!empty($poll->password_hash))}checked="checked" {elseif ($poll->hidden == true || empty($poll->password_hash))} disabled="disabled"{/if}/>
<label for="resultsPubliclyVisible">{__('PollInfo', 'Only votes are protected')}</label>
</div>
<div class="input-group">
<input type="text" class="form-control" id="password" name="password"/>