From c9b9bca732dfd243ee5f29954af93e775af2e51c Mon Sep 17 00:00:00 2001 From: Meteor-Furet Date: Sat, 26 May 2018 14:07:33 +0200 Subject: [PATCH] =?UTF-8?q?Impl=C3=A9mentation=20fonctionnalit=C3=A9=20adm?= =?UTF-8?q?in=20'Select=20a=20choice'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- adminstuds.php | 35 +++++++++++++++++-- .../AddColumn_admin_choice_In_poll.php | 2 +- locale/en.json | 7 ++-- tpl/part/poll_info.tpl | 23 +++++++++++- tpl/part/vote_table_classic.tpl | 35 +++++++++++-------- tpl/part/vote_table_date.tpl | 12 ++++++- 6 files changed, 92 insertions(+), 22 deletions(-) diff --git a/adminstuds.php b/adminstuds.php index 89d2b81..f730231 100644 --- a/adminstuds.php +++ b/adminstuds.php @@ -492,20 +492,49 @@ if (isset($_POST['close_poll'])) { } if (isset($_POST['confirm_close_poll'])) { $poll->closed="1"; - if ($adminPollService->updatePoll($poll)) { + if ($adminPollService->updatePoll($poll)) { $message = new Message('success', __('adminstuds', 'Poll closed')); - } else { + } else { $message = new Message('danger', __('Error', 'Failed to close the poll')); $poll = $pollService->findById($poll_id); - } + } } +// ------------------------------- +// Select admin choice +// ------------------------------- +if (isset($_GET['select_choice'])) { + $column = filter_input(INPUT_GET, 'select_choice', FILTER_DEFAULT); + $column = Utils::base64url_decode($column); + /*if ($poll->format === 'D') { + $ex = explode('@', $column); + + $slot = new stdClass(); + $slot->title = $ex[0]; + $slot->moment = $ex[1]; + + $result = $adminPollService->deleteDateSlot($poll, $slot); + } +*/ + $poll->admin_choice=$column; + if ($adminPollService->updatePoll($poll)) { + $message = new Message('success', __('adminstuds', 'Choice selected')); + } else { + $message = new Message('danger', __('Error', 'Failed to select the choice')); + $poll = $pollService->findById($poll_id); + } +} + + + // Retrieve data $slots = $pollService->allSlotsByPoll($poll); $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_In_poll.php b/app/classes/Framadate/Migration/AddColumn_admin_choice_In_poll.php index 7b72668..6e9ef6c 100644 --- a/app/classes/Framadate/Migration/AddColumn_admin_choice_In_poll.php +++ b/app/classes/Framadate/Migration/AddColumn_admin_choice_In_poll.php @@ -65,6 +65,6 @@ class AddColumn_admin_choice_In_poll implements Migration { private function alterPollTable(\PDO $pdo) { $pdo->exec(' ALTER TABLE `' . Utils::table('poll') . '` - ADD `admin_choice` VARCHAR(50) DEFAULT NULL;'); + ADD `admin_choice` VARCHAR(50) DEFAULT "";'); } } diff --git a/locale/en.json b/locale/en.json index dd6224c..cece068 100644 --- a/locale/en.json +++ b/locale/en.json @@ -305,6 +305,7 @@ "polled users": "polled users" }, "PollInfo": { + "Admin choice": "Admin choice", "Admin link for the poll": "Admin link for the poll", "Cancel the description edit": "Cancel the description edit", "Cancel the email address edit": "Cancel the email address edit", @@ -350,7 +351,7 @@ "Votes protected by password": "Votes protected by password", "The poll is still opened": "The poll is still opened", "The poll is closed": "The poll is closed", - "Close the poll": "Close the poll" + "Close the poll": "Close the poll", }, "Step 1": { "All voters can modify any vote": "All voters can modify any vote", @@ -472,7 +473,9 @@ "remove a column or a line with": "remove a column or a line with", "Poll closed" : "Poll closed", "Confirm close of the poll" : "Confirm close of the poll", - "Keep the poll opened": "Keep the poll opened" + "Keep the poll opened": "Keep the poll opened", + "Select this choice": "Select this choice", + "Choice selected": "Choice selected", }, "display_mails": { "Users who voted \"If need be\" for this option have left those email addresses:": "Users who voted \"If need be\" for this option have left those email addresses:", diff --git a/tpl/part/poll_info.tpl b/tpl/part/poll_info.tpl index e89d4d7..76c501b 100644 --- a/tpl/part/poll_info.tpl +++ b/tpl/part/poll_info.tpl @@ -280,7 +280,28 @@ {/if}

{$closed_icon} {$closed_txt|html}

- + + {if $poll->closed} +
+
+ + {if strcmp($poll->admin_choice, "")==0} +

__('PollInfo', 'No choice has been selected by the admin yet')

+ {else} + {if $poll->format === 'D'} + {$choice = explode('@', $poll->admin_choice)} +

{$choice[0]|date_format:$date_format.txt_short|html} + {if strcmp($choice[1], "")!=0} + - {$choice[1]} + {/if} +

+ {else} +

{$poll->admin_choice}

+ {/if} + {/if} +
+
+ {/if} {if $admin && !$poll->closed}
diff --git a/tpl/part/vote_table_classic.tpl b/tpl/part/vote_table_classic.tpl index 422306e..0cb5fe0 100644 --- a/tpl/part/vote_table_classic.tpl +++ b/tpl/part/vote_table_classic.tpl @@ -19,26 +19,33 @@ - {if $admin && !$expired && !$poll->closed} + {if $admin && !$expired} {$headersDCount=0} {foreach $slots as $id=>$slot} - {$headersDCount = $headersDCount+1} + {else} + + {/if} {/foreach} - {if $admin && !$expired && !$poll->closed} + {if $admin && !$expired} {$headersDCount=0} {foreach $slots as $slot} {foreach $slot->moments as $id=>$moment} + {if !$poll->closed} + {else} + + {/if} {$headersDCount = $headersDCount+1} {/foreach} {/foreach}
{__('Poll results', 'Votes')} {$poll->title|html}
- - {__('Generic', 'Remove')} - - {if $poll->collect_users_mail != constant("Framadate\CollectMail::NO_COLLECT")} - - {__('Generic', 'Collect emails')} - - {/if} + {if !$poll->closed} + + + {__('Generic', 'Remove')} + + {if $poll->collect_users_mail != constant("Framadate\CollectMail::NO_COLLECT")} + + {__('Generic', 'Collect emails')} + + {/if} + + {__('Generic', 'Select')} + +
{__('Poll results', 'Votes')} {$poll->title|html}
{/if} + + {__('Generic', 'Remove')} + +