Hidden results option is taken into account.

- Also added possibility for the poll's maker to edit this hidden results option.
This commit is contained in:
Antonin 2015-04-06 12:39:58 +02:00
parent 0c2ba20bfa
commit a135f74383
12 changed files with 166 additions and 100 deletions

View File

@ -70,7 +70,7 @@ if (!$poll) {
if (isset($_POST['update_poll_info'])) {
$updated = false;
$field = $inputService->filterAllowedValues($_POST['update_poll_info'], ['title', 'admin_mail', 'description', 'rules', 'expiration_date', 'name']);
$field = $inputService->filterAllowedValues($_POST['update_poll_info'], ['title', 'admin_mail', 'description', 'rules', 'expiration_date', 'name', 'hidden']);
// Update the right poll field
if ($field == 'title') {
@ -128,6 +128,13 @@ if (isset($_POST['update_poll_info'])) {
$poll->admin_name = $admin_name;
$updated = true;
}
} elseif ($field == 'hidden') {
$hidden = filter_input(INPUT_POST, 'hidden', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => BOOLEAN_REGEX]]);
$hidden = $hidden==null?false:true;
if ($hidden != $poll->hidden) {
$poll->hidden = $hidden;
$updated = true;
}
}
// Update poll in database

View File

@ -90,9 +90,9 @@ class FramaDB {
}
function updatePoll($poll) {
$prepared = $this->prepare('UPDATE `' . Utils::table('poll') . '` SET title=?, admin_name=?, admin_mail=?, description=?, end_date=?, active=?, editable=? WHERE id = ?');
$prepared = $this->prepare('UPDATE `' . Utils::table('poll') . '` SET title=?, admin_name=?, admin_mail=?, description=?, end_date=?, active=?, editable=?, hidden=? WHERE id = ?');
return $prepared->execute([$poll->title, $poll->admin_name, $poll->admin_mail, $poll->description, $poll->end_date, $poll->active, $poll->editable, $poll->id]);
return $prepared->execute([$poll->title, $poll->admin_name, $poll->admin_mail, $poll->description, $poll->end_date, $poll->active, $poll->editable, $poll->hidden, $poll->id]);
}
function allCommentsByPollId($poll_id) {

View File

@ -124,6 +124,7 @@ caption {
#email-form .btn-edit,
#description-form .btn-edit,
#poll-rules-form .btn-edit,
#poll-hidden-form .btn-edit,
#expiration-form .btn-edit,
#name-form .btn-edit {
position:absolute;
@ -138,6 +139,8 @@ caption {
#description-form:hover .btn-edit,
#poll-rules-form .btn-edit:focus,
#poll-rules-form:hover .btn-edit,
#poll-hidden-form .btn-edit:focus,
#poll-hidden-form:hover .btn-edit,
#expiration-form .btn-edit:focus,
#expiration-form:hover .btn-edit,
#name-form .btn-edit:focus,
@ -155,7 +158,7 @@ caption {
margin-bottom:0;
}
#poll-rules-form p,
#poll-rules-form p, #poll-hidden-form p,
.jumbotron p.well {
font-size:16px;
}

View File

@ -98,6 +98,20 @@ $(document).ready(function() {
return false;
});
$('#poll-hidden-form .btn-edit').on('click', function() {
$('#poll-hidden-form p').hide();
$('#poll-hidden-form .js-poll-hidden').removeClass("hidden");
$('.js-poll-hidden input[type=checkbox]').focus();
return false;
});
$('#poll-hidden-form .btn-cancel').on('click', function() {
$('#poll-hidden-form p').show();
$('#poll-hidden-form .js-poll-hidden').addClass("hidden");
$('.js-poll-hidden .btn-edit').focus();
return false;
});
$('#expiration-form .btn-edit').on('click', function() {
$('#expiration-form p').hide();
$('.js-expiration').removeClass("hidden");

View File

@ -114,7 +114,9 @@
"Votes are editable solely by their owner.": "DE_Les votes sont modifiables uniquement par leur créateur",
"Save the new rules": "Neue Regeln speichern",
"Cancel the rules edit": "Neue Regeln nicht speichern",
"The name is invalid.": "Der Name ist ungültig."
"The name is invalid.": "Der Name ist ungültig.",
"Results are hidden.": "DE_Les résultats sont cachés.",
"Results are visible.": "DE_Les résultats sont visibles."
},
"Poll results": {
"Votes of the poll": "Abstimmungen der Umfrage ",
@ -302,7 +304,7 @@
"Framadate is not properly installed, please check the \"INSTALL\" to setup the database before continuing.": "Framadate ist nicht richtig installiert, überprüfen Sie bitte die Schaltfläche \"INSTALL\", um das Setup der Datenbank, bevor Sie fortfahren.",
"Failed to save poll": "Fehlgeschlagen Umfrage sparen",
"Update vote failed": "Update vote failed",
"Adding vote failed": "Adding vote failed"
"Adding vote failed": "Adding vote failed",
"You can't create a poll with hidden results with the following edition option : ": "DE_Vous ne pouvez pas créer de sondage avec résulats cachés avec les options d'éditions suivantes : "
}
}

View File

@ -115,7 +115,9 @@
"Votes are editable solely by their owner.": "Votes are editable solely by their owner",
"Save the new rules": "Save the new rules",
"Cancel the rules edit": "Cancel the rules edit",
"The name is invalid.": "The name is invalid."
"The name is invalid.": "The name is invalid.",
"Results are hidden.": "Results are hidden.",
"Results are visible.": "Results are visible."
},
"Poll results": {
"Votes of the poll": "Votes of the poll",

View File

@ -114,7 +114,9 @@
"Votes are editable solely by their owner.": "ES_Les votes sont modifiables uniquement par leur créateur",
"Save the new rules": "ES_Enregistrer les nouvelles permissions",
"Cancel the rules edit": "ES_Annuler le changement de permissions",
"The name is invalid.": "ES_Le nom n'est pas valide."
"The name is invalid.": "ES_Le nom n'est pas valide.",
"Results are hidden.": "ES_Les résultats sont cachés.",
"Results are visible.": "ES_Les résultats sont visibles."
},
"Poll results": {
"Votes of the poll": "ES_Votes du sondage",

View File

@ -114,7 +114,9 @@
"Votes are editable solely by their owner.": "Les votes sont modifiables uniquement par leur créateur",
"Save the new rules": "Enregistrer les nouvelles permissions",
"Cancel the rules edit": "Annuler le changement de permissions",
"The name is invalid.": "Le nom n'est pas valide."
"The name is invalid.": "Le nom n'est pas valide.",
"Results are hidden.": "Les résultats sont cachés.",
"Results are visible.": "Les résultats sont visibles."
},
"Poll results": {
"Votes of the poll": "Votes du sondage",

View File

@ -212,6 +212,7 @@ $smarty->assign('comments', $comments);
$smarty->assign('editingVoteId', $editingVoteId);
$smarty->assign('message', $message);
$smarty->assign('admin', false);
$smarty->assign('hidden', $poll->hidden);
$smarty->assign('parameter_name_regex', NAME_REGEX);
$smarty->display('studs.tpl');

View File

@ -118,14 +118,41 @@
</div>
{if $admin}
<div class="row">
<div class="col-md-4 col-md-offset-8" >
<div class="col-md-4 col-md-offset-4" >
<div id="poll-hidden-form">
{if $poll->hidden}
{$hidden_icon = "glyphicon-eye-close"}
{$hidden_text = __('PollInfo', 'Results are hidden.')}
{else}
{$hidden_icon = "glyphicon-eye-open"}
{$hidden_text = __('PollInfo', 'Results are visible.')}
{/if}
<p class=""><span class="glyphicon {$hidden_icon}"> </span> {$hidden_text}<button class="btn btn-link btn-sm btn-edit" title="{__('PollInfo', 'Edit the poll rules')}"><span class="glyphicon glyphicon-pencil"></span><span class="sr-only">{__('Generic', 'Edit')}</span></button></p>
<div class="hidden js-poll-hidden">
<div class="input-group">
<input type="checkbox" id="hidden" name="hidden" {if $poll->hidden}checked="checked"{/if}/>
<label for="hidden">{__('PollInfo', 'Results are hidden.')}</label>
<span class="input-group-btn">
<button type="submit" name="update_poll_info" value="hidden" class="btn btn-success" title="{__('PollInfo', 'Save the new rules')}"><span class="glyphicon glyphicon-ok"></span><span class="sr-only">{__('Generic', 'Save')}</span></button>
<button class="btn btn-link btn-cancel" title="{__('PollInfo', 'Cancel the rules edit')}"><span class="glyphicon glyphicon-remove"></span><span class="sr-only">{__('Generic', 'Cancel')}</span></button>
</span>
</div>
</div>
</div>
</div>
<div class="col-md-4" >
<div id="poll-rules-form">
{if $poll->active}
{if $poll->editable}
{$rule_id = 2}
{if $poll->editable == constant("Framadate\Editable::EDITABLE_BY_ALL")}
{$rule_id = 2}
{$rule_txt = __('PollInfo', 'Votes are editable')}
{else}
{$rule_id = 3}
{$rule_txt = __('PollInfo', 'Votes are editable solely by their owner.')}
{/if}
{$rule_icon = '<span class="glyphicon glyphicon-edit"></span>'}
{$rule_txt = __('PollInfo', 'Votes are editable')}
{else}
{else}
{$rule_id = 1}
{$rule_icon = '<span class="glyphicon glyphicon-check"></span>'}
{$rule_txt = __('PollInfo', 'Votes and comments are open')}

View File

@ -2,7 +2,7 @@
{$best_choices = [0]}
{/if}
<h3>{__('Poll results', 'Votes of the poll')}</h3>
<h3>{__('Poll results', 'Votes of the poll')} {if $hidden}<i>({__('PollInfo', 'Results are hidden.')})</i>{/if}</h3>
<div id="tableContainer" class="tableContainer">
<form action="{poll_url id=$poll_id}" method="POST" id="poll_form">
@ -69,7 +69,7 @@
</td>
{/foreach}
<td style="padding:5px"><button type="submit" class="btn btn-success btn-xs" name="save" value="{$vote->id|html}" title="{__('Poll results', 'Save the choices')} {$vote->name|html}">{__('Generic', 'Save')}</button></td>
{else}
{elseif !$hidden}
{* Voted line *}
<th class="bg-info">{$vote->name|html}</th>
@ -142,55 +142,58 @@
</tr>
{/if}
{* Line displaying best moments *}
{$count_bests = 0}
{$max = max($best_choices)}
{if $max > 0}
<tr id="addition">
<td>{__('Poll results', 'Addition')}</td>
{foreach $best_choices as $best_choice}
{if $max == $best_choice}
{$count_bests = $count_bests +1}
<td><span class="glyphicon glyphicon-star text-warning"></span>{$best_choice|html}</td>
{elseif $best_choice > 0}
<td>{$best_choice|html}</td>
{else}
<td></td>
{/if}
{/foreach}
</tr>
{if !$hidden}
{* Line displaying best moments *}
{$count_bests = 0}
{$max = max($best_choices)}
{if $max > 0}
<tr id="addition">
<td>{__('Poll results', 'Addition')}</td>
{foreach $best_choices as $best_choice}
{if $max == $best_choice}
{$count_bests = $count_bests +1}
<td><span class="glyphicon glyphicon-star text-warning"></span>{$best_choice|html}</td>
{elseif $best_choice > 0}
<td>{$best_choice|html}</td>
{else}
<td></td>
{/if}
{/foreach}
</tr>
{/if}
{/if}
</tbody>
</table>
</form>
</div>
{* Best votes listing *}
{$max = max($best_choices)}
{if $max > 0}
<div class="row">
{if $count_bests == 1}
<div class="col-sm-12"><h3>{__('Poll results', 'Best choice')}</h3></div>
<div class="col-sm-6 col-sm-offset-3 alert alert-success">
<p><span class="glyphicon glyphicon-star text-warning"></span>{__('Poll results', 'The best choice at this time is:')}</p>
{elseif $count_bests > 1}
<div class="col-sm-12"><h3>{__('Poll results', 'Best choices')}</h3></div>
{if !$hidden}
{* Best votes listing *}
{$max = max($best_choices)}
{if $max > 0}
<div class="row">
{if $count_bests == 1}
<div class="col-sm-12"><h3>{__('Poll results', 'Best choice')}</h3></div>
<div class="col-sm-6 col-sm-offset-3 alert alert-success">
<p><span class="glyphicon glyphicon-star text-warning"></span>{__('Poll results', 'The bests choices at this time are:')}</p>
{/if}
<p><span class="glyphicon glyphicon-star text-warning"></span>{__('Poll results', 'The best choice at this time is:')}</p>
{elseif $count_bests > 1}
<div class="col-sm-12"><h3>{__('Poll results', 'Best choices')}</h3></div>
<div class="col-sm-6 col-sm-offset-3 alert alert-success">
<p><span class="glyphicon glyphicon-star text-warning"></span>{__('Poll results', 'The bests choices at this time are:')}</p>
{/if}
{$i = 0}
<ul style="list-style:none">
{foreach $slots as $slot}
{if $best_choices[$i] == $max}
<li><strong>{$slot->title|html|markdown:true}</strong></li>
{/if}
{$i = $i+1}
{/foreach}
</ul>
<p>{__('Generic', 'with')} <b>{$max|html}</b> {if $max==1}{__('Generic', 'vote')}{else}{__('Generic', 'votes')}{/if}.</p>
{$i = 0}
<ul style="list-style:none">
{foreach $slots as $slot}
{if $best_choices[$i] == $max}
<li><strong>{$slot->title|html|markdown:true}</strong></li>
{/if}
{$i = $i+1}
{/foreach}
</ul>
<p>{__('Generic', 'with')} <b>{$max|html}</b> {if $max==1}{__('Generic', 'vote')}{else}{__('Generic', 'votes')}{/if}.</p>
</div>
</div>
</div>
{/if}
{/if}

View File

@ -2,7 +2,7 @@
{$best_choices = [0]}
{/if}
<h3>{__('Poll results', 'Votes of the poll')}</h3>
<h3>{__('Poll results', 'Votes of the poll')} {if $hidden}<i>({__('PollInfo', 'Results are hidden.')})</i>{/if}</h3>
<div id="tableContainer" class="tableContainer">
<form action="{poll_url id=$poll_id}" method="POST" id="poll_form">
@ -115,7 +115,7 @@
</td>
{/foreach}
<td style="padding:5px"><button type="submit" class="btn btn-success btn-xs" name="save" value="{$vote->id|html}" title="{__('Poll results', 'Save the choices')} {$vote->name|html}">{__('Generic', 'Save')}</button></td>
{else}
{elseif !$hidden}
{* Voted line *}
@ -193,57 +193,60 @@
</tr>
{/if}
{* Line displaying best moments *}
{$count_bests = 0}
{$max = max($best_choices)}
{if $max > 0}
<tr id="addition">
<td>{__('Poll results', 'Addition')}</td>
{foreach $best_choices as $best_moment}
{if $max == $best_moment}
{$count_bests = $count_bests +1}
<td><i class="glyphicon glyphicon-star text-warning"></i>{$best_moment|html}</td>
{elseif $best_moment > 0}
<td>{$best_moment|html}</td>
{else}
<td></td>
{/if}
{/foreach}
</tr>
{if !$hidden}
{* Line displaying best moments *}
{$count_bests = 0}
{$max = max($best_choices)}
{if $max > 0}
<tr id="addition">
<td>{__('Poll results', 'Addition')}</td>
{foreach $best_choices as $best_moment}
{if $max == $best_moment}
{$count_bests = $count_bests +1}
<td><i class="glyphicon glyphicon-star text-warning"></i>{$best_moment|html}</td>
{elseif $best_moment > 0}
<td>{$best_moment|html}</td>
{else}
<td></td>
{/if}
{/foreach}
</tr>
{/if}
{/if}
</tbody>
</table>
</form>
</div>
{* Best votes listing *}
{$max = max($best_choices)}
{if $max > 0}
<div class="row">
{if $count_bests == 1}
<div class="col-sm-12"><h3>{__('Poll results', 'Best choice')}</h3></div>
<div class="col-sm-6 col-sm-offset-3 alert alert-success">
<p><span class="glyphicon glyphicon-star text-warning"></span>{__('Poll results', 'The best choice at this time is:')}</p>
{elseif $count_bests > 1}
<div class="col-sm-12"><h3>{__('Poll results', 'Best choices')}</h3></div>
{if !$hidden}
{* Best votes listing *}
{$max = max($best_choices)}
{if $max > 0}
<div class="row">
{if $count_bests == 1}
<div class="col-sm-12"><h3>{__('Poll results', 'Best choice')}</h3></div>
<div class="col-sm-6 col-sm-offset-3 alert alert-success">
<p><span class="glyphicon glyphicon-star text-warning"></span>{__('Poll results', 'The bests choices at this time are:')}</p>
{/if}
<p><span class="glyphicon glyphicon-star text-warning"></span>{__('Poll results', 'The best choice at this time is:')}</p>
{elseif $count_bests > 1}
<div class="col-sm-12"><h3>{__('Poll results', 'Best choices')}</h3></div>
<div class="col-sm-6 col-sm-offset-3 alert alert-success">
<p><span class="glyphicon glyphicon-star text-warning"></span>{__('Poll results', 'The bests choices at this time are:')}</p>
{/if}
{$i = 0}
<ul style="list-style:none">
{foreach $slots as $slot}
{foreach $slot->moments as $moment}
{if $best_choices[$i] == $max}
<li><strong>{$slot->day|date_format:$date_format.txt_full|html} - {$moment|html}</strong></li>
{/if}
{$i = $i+1}
{$i = 0}
<ul style="list-style:none">
{foreach $slots as $slot}
{foreach $slot->moments as $moment}
{if $best_choices[$i] == $max}
<li><strong>{$slot->day|date_format:$date_format.txt_full|html} - {$moment|html}</strong></li>
{/if}
{$i = $i+1}
{/foreach}
{/foreach}
{/foreach}
</ul>
<p>{__('Generic', 'with')} <b>{$max|html}</b> {if $max==1}{__('Generic', 'vote')}{else}{__('Generic', 'votes')}{/if}.</p>
</ul>
<p>{__('Generic', 'with')} <b>{$max|html}</b> {if $max==1}{__('Generic', 'vote')}{else}{__('Generic', 'votes')}{/if}.</p>
</div>
</div>
</div>
{/if}
{/if}