Merge branch 'fix-#267' into 'develop'

Fix everybody can vote

Closes #267

See merge request framasoft/framadate!244
This commit is contained in:
Thomas Citharel 2018-03-21 15:31:05 +01:00
commit 0e9075a985
4 changed files with 19 additions and 8 deletions

View File

@ -65,7 +65,6 @@ class AddColumn_ValueMax_In_poll_For_1_1 implements Migration {
private function alterPollTable(\PDO $pdo) {
$pdo->exec('
ALTER TABLE `' . Utils::table('poll') . '`
ADD `ValueMax` TINYINT,
ADD CHECK (ValueMax > 0)');
ADD `ValueMax` TINYINT NULL;');
}
}

View File

@ -168,7 +168,7 @@ if ($accessGranted) {
try {
$result = $pollService->addVote($poll_id, $name, $choices, $slots_hash);
if ($result) {
if ($poll->editable === Editable::EDITABLE_BY_OWN) {
if (intval($poll->editable) === Editable::EDITABLE_BY_OWN) {
$editedVoteUniqueId = $result->uniqId;
$message = getMessageForOwnVoteEditableVote($sessionService, $smarty, $editedVoteUniqueId, $config['use_smtp'], $poll_id, $name);
} else {

View File

@ -101,7 +101,13 @@
<tr>
<th class="bg-info">{$vote->name|html}
{if $slots gt 4}
{if $active && !$expired && $accessGranted &&
(
$poll->editable == constant('Framadate\Editable::EDITABLE_BY_ALL')
or $admin
or ($poll->editable == constant('Framadate\Editable::EDITABLE_BY_OWN') && $editedVoteUniqueId == $vote->uniqId)
) && $slots gt 4
}
<span class="edit-username-left">
<a href="{if $admin}{poll_url id=$poll->admin_id vote_id=$vote->uniqId admin=true}{else}{poll_url id=$poll->id vote_id=$vote->uniqId}{/if}" class="btn btn-default btn-sm" title="{__f('Poll results', 'Edit the line: %s', $vote->name)|html}">
<i class="glyphicon glyphicon-pencil"></i><span class="sr-only">{__('Generic', 'Edit')}</span>
@ -168,7 +174,7 @@
{foreach $slots as $id=>$slot}
<td class="bg-info" headers="C{$id}">
<ul class="list-unstyled choice">
{if $best_choices['y'][$i] lt $poll->ValueMax || $poll->ValueMax eq NULL}
{if $poll->ValueMax eq NULL || $best_choices['y'][$i] lt $poll->ValueMax}
<li class="yes">
<input type="radio" id="y-choice-{$id}" name="choices[{$id}]" value="2" />
<label class="btn btn-default btn-xs" for="y-choice-{$id}" title="{__('Poll results', 'Vote yes for')|html} {$slot->title|html}">

View File

@ -153,9 +153,15 @@
<tr>
{* Voted line *}
<th class="bg-info">{$vote->name|html}
{if $slots gt 4}
{if $active && !$expired && $accessGranted &&
(
$poll->editable == constant('Framadate\Editable::EDITABLE_BY_ALL')
or $admin
or ($poll->editable == constant('Framadate\Editable::EDITABLE_BY_OWN') && $editedVoteUniqueId == $vote->uniqId)
) &&
$slots|count gt 4
}
<span class="edit-username-left">
<a href="{if $admin}{poll_url id=$poll->admin_id vote_id=$vote->uniqId admin=true}{else}{poll_url id=$poll->id vote_id=$vote->uniqId}{/if}" class="btn btn-default btn-sm" title="{__f('Poll results', 'Edit the line: %s', $vote->name)|html}">
<i class="glyphicon glyphicon-pencil"></i><span class="sr-only">{__('Generic', 'Edit')}</span>
@ -232,7 +238,7 @@
<td class="bg-info" headers="M{$headersM[$i]} D{$headersD[$i]} H{$headersH[$i]}">
<ul class="list-unstyled choice">
{if $best_choices['y'][$i] lt $poll->ValueMax || $poll->ValueMax eq NULL}
{if $poll->ValueMax eq NULL || $best_choices['y'][$i] lt $poll->ValueMax}
<li class="yes">
<input type="radio" id="y-choice-{$i}" name="choices[{$i}]" value="2" />
<label class="btn btn-default btn-xs" for="y-choice-{$i}" title="{__('Poll results', 'Vote yes for')|html} {$slot->day|date_format:$date_format.txt_short|html} - {$moment|html}">