Adds some comments to understand the logic
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
e9deb8d22e
commit
2310333f8d
|
@ -149,14 +149,29 @@ 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 ($poll->password_hash === null || $poll->hidden === true){
|
||||
$poll->results_publicly_visible = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
|
|
@ -103,8 +103,14 @@ $(document).ready(function () {
|
|||
return false;
|
||||
});
|
||||
|
||||
$('#password').on('keyup change', function () {
|
||||
if($('#password').val() && !($('#hidden').attr('checked'))){$('#resultsPubliclyVisible').removeAttr('disabled');}
|
||||
else {$('#resultsPubliclyVisible').attr('disabled','disabled');};
|
||||
});
|
||||
/**
|
||||
* 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');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user