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} +__('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} +| {$headersDCount=0} {foreach $slots as $id=>$slot} - | - - {__('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} | {$headersDCount = $headersDCount+1} + {else} ++ + {__('Generic', 'Select')} + + | + {/if} {/foreach}
|
{$headersDCount=0}
{foreach $slots as $slot}
{foreach $slot->moments as $id=>$moment}
+ {if !$poll->closed}
|
{/if}
|
+ {else}
+
+
+ {__('Generic', 'Remove')}
+
+ |
+ {/if}
{$headersDCount = $headersDCount+1}
{/foreach}
{/foreach}
|
|---|