diff --git a/adminstuds.php b/adminstuds.php index fb7ca43..a7b4d87 100644 --- a/adminstuds.php +++ b/adminstuds.php @@ -91,7 +91,7 @@ if ($messagePollCreated) { if (isset($_POST['update_poll_info'])) { $updated = false; $field = $inputService->filterAllowedValues($_POST['update_poll_info'], ['title', 'admin_mail', 'description', - 'rules', 'expiration_date', 'name', 'hidden', 'removePassword', 'password']); + 'rules', 'expiration_date', 'name', 'hidden', 'removePassword', 'password', 'explanation']); // Update the right poll field if ($field === 'title') { @@ -111,7 +111,13 @@ if (isset($_POST['update_poll_info'])) { if ($description) { $poll->description = $description; $updated = true; - } + } + } elseif ($field === 'explanation') { + $explanation = $inputService->filterDescription($_POST['explanation']); + if ($explanation) { + $poll->admin_choice_exp = $explanation; + $updated = true; + } } elseif ($field === 'rules') { $rules = strip_tags($_POST['rules']); switch ($rules) { @@ -531,8 +537,6 @@ $votes = $pollService->allVotesByPollId($poll_id); $comments = $pollService->allCommentsByPollId($poll_id); // Assign data to template -var_dump($poll); -var_dump($pollService->splitSlots($slots)); $smarty->assign('poll_id', $poll_id); $smarty->assign('admin_poll_id', $admin_poll_id); $smarty->assign('poll', $poll); diff --git a/app/classes/Framadate/Migration/AddColumn_admin_choice_exp_In_poll.php b/app/classes/Framadate/Migration/AddColumn_admin_choice_exp_In_poll.php new file mode 100644 index 0000000..1720670 --- /dev/null +++ b/app/classes/Framadate/Migration/AddColumn_admin_choice_exp_In_poll.php @@ -0,0 +1,70 @@ +alterPollTable($pdo); + + return true; + } + + private function alterPollTable(\PDO $pdo) { + $pdo->exec(' + ALTER TABLE `' . Utils::table('poll') . '` + ADD `admin_choice_exp` VARCHAR(250) DEFAULT "";'); + } +} diff --git a/app/classes/Framadate/Repositories/PollRepository.php b/app/classes/Framadate/Repositories/PollRepository.php index c20522d..582b5e2 100644 --- a/app/classes/Framadate/Repositories/PollRepository.php +++ b/app/classes/Framadate/Repositories/PollRepository.php @@ -106,6 +106,7 @@ class PollRepository extends AbstractRepository { 'results_publicly_visible' => $poll->results_publicly_visible ? 1 : 0, 'closed' => $poll->closed ? 1 : 0, 'admin_choice' => $poll->admin_choice ? $poll->admin_choice : NULL, + 'admin_choice_exp' => $poll->admin_choice_exp ? $poll->admin_choice_exp : "", ], [ 'id' => $poll->id ]) > 0; diff --git a/js/app/adminstuds.js b/js/app/adminstuds.js index cd1e988..b99fa89 100644 --- a/js/app/adminstuds.js +++ b/js/app/adminstuds.js @@ -189,6 +189,28 @@ $(document).ready(function() { return false; }); + $('#explanation-form .btn-edit').on('click', function() { + $('#explanation-form .well').hide(); + $('#explanation-form .control-label .btn-edit').hide(); + $('#explanation-form .js-exp').removeClass('hidden'); + $('.js-exp textarea').focus(); + if (firstOpening) { + firstOpening = false; + if ($('#rich-editor-button').hasClass('active')) { + wrapper.enable(); + } + } + return false; + }); + + $('#explanation-form .btn-cancel').on('click', function() { + $('#explanation-form .well').show(); + $('#explanation-form .control-label .btn-edit').show(); + $('#explanation-form .js-exp').addClass('hidden'); + $('.js-exp .btn-edit').focus(); + return false; + }); + $('#poll-rules-form .btn-edit').on('click', function() { $('#poll-rules-form p').hide(); $('#poll-rules-form .js-poll-rules').removeClass('hidden'); diff --git a/locale/en.json b/locale/en.json index cece068..42dc600 100644 --- a/locale/en.json +++ b/locale/en.json @@ -223,7 +223,8 @@ "seconds": "seconds", "vote": "vote", "votes": "votes", - "with": "with" + "with": "with", + "Explanation of the choice" : "Explanation of the choice", }, "Homepage": { "Make a standard poll": "Make a standard poll", @@ -352,6 +353,9 @@ "The poll is still opened": "The poll is still opened", "The poll is closed": "The poll is closed", "Close the poll": "Close the poll", + "Edit the explanation": "Edit the explanation", + "Save the explanation": "Save the explanation", + "Cancel the explanation edit": "Cancel the explanation edit", }, "Step 1": { "All voters can modify any vote": "All voters can modify any vote", diff --git a/tpl/part/poll_info.tpl b/tpl/part/poll_info.tpl index 76c501b..85b1b6e 100644 --- a/tpl/part/poll_info.tpl +++ b/tpl/part/poll_info.tpl @@ -280,7 +280,9 @@ {/if}

{$closed_icon} {$closed_txt|html}

+ +
{if $poll->closed}
@@ -301,6 +303,20 @@ {/if}
+ {if strcmp($poll->admin_choice,"")!=0} +
+ +
{$poll->admin_choice_exp|markdown:false:false}
+ {if $admin && !$expired} + + {/if} +
+ {/if} {/if}
{if $admin && !$poll->closed}