Merge branch 'fix/Issue116_allow_user_to_edit_his_own_private_vote_on_the_fly' into 'master'
On permet d'éditer son vote à la volée. Dans le cas d'un vote ou l'utilisateur ne peut modifier que son propre vote, après qu'il ait ajouté (ou édité) son vote, on affiche le crayon qui permet d'éditer. Fix #116 See merge request !86
This commit is contained in:
commit
76161240c2
@ -39,6 +39,7 @@ $poll_id = null;
|
|||||||
$poll = null;
|
$poll = null;
|
||||||
$message = null;
|
$message = null;
|
||||||
$editingVoteId = 0;
|
$editingVoteId = 0;
|
||||||
|
$editedVoteUniqueId = null;
|
||||||
|
|
||||||
/* Services */
|
/* Services */
|
||||||
/*----------*/
|
/*----------*/
|
||||||
@ -133,8 +134,8 @@ if (!empty($_POST['save'])) { // Save edition of an old vote
|
|||||||
$result = $pollService->updateVote($poll_id, $editedVote, $name, $choices);
|
$result = $pollService->updateVote($poll_id, $editedVote, $name, $choices);
|
||||||
if ($result) {
|
if ($result) {
|
||||||
if ($poll->editable == Editable::EDITABLE_BY_OWN) {
|
if ($poll->editable == Editable::EDITABLE_BY_OWN) {
|
||||||
$editedVoteUniqId = filter_input(INPUT_POST, 'edited_vote', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => POLL_REGEX]]);
|
$editedVoteUniqueId = filter_input(INPUT_POST, 'edited_vote', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => POLL_REGEX]]);
|
||||||
$urlEditVote = Utils::getUrlSondage($poll_id, false, $editedVoteUniqId);
|
$urlEditVote = Utils::getUrlSondage($poll_id, false, $editedVoteUniqueId);
|
||||||
$message = new Message('success', __('studs', 'Your vote has been registered successfully, but be careful: regarding this poll options, you need to keep this personal link to edit your own vote:'), $urlEditVote);
|
$message = new Message('success', __('studs', 'Your vote has been registered successfully, but be careful: regarding this poll options, you need to keep this personal link to edit your own vote:'), $urlEditVote);
|
||||||
} else {
|
} else {
|
||||||
$message = new Message('success', __('studs', 'Update vote succeeded'));
|
$message = new Message('success', __('studs', 'Update vote succeeded'));
|
||||||
@ -161,6 +162,7 @@ if (!empty($_POST['save'])) { // Save edition of an old vote
|
|||||||
if ($result) {
|
if ($result) {
|
||||||
if ($poll->editable == Editable::EDITABLE_BY_OWN) {
|
if ($poll->editable == Editable::EDITABLE_BY_OWN) {
|
||||||
$urlEditVote = Utils::getUrlSondage($poll_id, false, $result->uniqId);
|
$urlEditVote = Utils::getUrlSondage($poll_id, false, $result->uniqId);
|
||||||
|
$editedVoteUniqueId = $result->uniqId;
|
||||||
$message = new Message('success', __('studs', 'Your vote has been registered successfully, but be careful: regarding this poll options, you need to keep this personal link to edit your own vote:'), $urlEditVote);
|
$message = new Message('success', __('studs', 'Your vote has been registered successfully, but be careful: regarding this poll options, you need to keep this personal link to edit your own vote:'), $urlEditVote);
|
||||||
} else {
|
} else {
|
||||||
$message = new Message('success', __('studs', 'Adding the vote succeeded'));
|
$message = new Message('success', __('studs', 'Adding the vote succeeded'));
|
||||||
@ -216,5 +218,6 @@ $smarty->assign('editingVoteId', $editingVoteId);
|
|||||||
$smarty->assign('message', $message);
|
$smarty->assign('message', $message);
|
||||||
$smarty->assign('admin', false);
|
$smarty->assign('admin', false);
|
||||||
$smarty->assign('hidden', $poll->hidden);
|
$smarty->assign('hidden', $poll->hidden);
|
||||||
|
$smarty->assign('editedVoteUniqueId', $editedVoteUniqueId);
|
||||||
|
|
||||||
$smarty->display('studs.tpl');
|
$smarty->display('studs.tpl');
|
||||||
|
@ -94,7 +94,14 @@
|
|||||||
|
|
||||||
{/foreach}
|
{/foreach}
|
||||||
|
|
||||||
{if $active && !$expired && ($poll->editable == constant('Framadate\Editable::EDITABLE_BY_ALL') or $admin)}
|
{if $active && !$expired &&
|
||||||
|
(
|
||||||
|
$poll->editable == constant('Framadate\Editable::EDITABLE_BY_ALL')
|
||||||
|
or ($poll->editable == constant('Framadate\Editable::EDITABLE_BY_OWN') && $editedVoteUniqueId == $vote->uniqId)
|
||||||
|
or $admin
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
<td class="hidden-print">
|
<td class="hidden-print">
|
||||||
<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="{__('Poll results', 'Edit the line:')|html} {$vote->name|html}">
|
<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="{__('Poll results', 'Edit the line:')|html} {$vote->name|html}">
|
||||||
<i class="glyphicon glyphicon-pencil"></i><span class="sr-only">{__('Generic', 'Edit')}</span>
|
<i class="glyphicon glyphicon-pencil"></i><span class="sr-only">{__('Generic', 'Edit')}</span>
|
||||||
|
@ -145,7 +145,13 @@
|
|||||||
|
|
||||||
{/foreach}
|
{/foreach}
|
||||||
|
|
||||||
{if $active && !$expired && ($poll->editable == constant('Framadate\Editable::EDITABLE_BY_ALL') or $admin)}
|
{if $active && !$expired &&
|
||||||
|
(
|
||||||
|
$poll->editable == constant('Framadate\Editable::EDITABLE_BY_ALL')
|
||||||
|
or ($poll->editable == constant('Framadate\Editable::EDITABLE_BY_OWN') && $editedVoteUniqueId == $vote->uniqId)
|
||||||
|
or $admin
|
||||||
|
)
|
||||||
|
}
|
||||||
<td class="hidden-print">
|
<td class="hidden-print">
|
||||||
<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="{__('Poll results', 'Edit the line:')|escape} {$vote->name|html}">
|
<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="{__('Poll results', 'Edit the line:')|escape} {$vote->name|html}">
|
||||||
<i class="glyphicon glyphicon-pencil"></i><span class="sr-only">{__('Generic', 'Edit')}</span>
|
<i class="glyphicon glyphicon-pencil"></i><span class="sr-only">{__('Generic', 'Edit')}</span>
|
||||||
|
Loading…
Reference in New Issue
Block a user