mirror of
https://framagit.org/framasoft/framadate/framadate
synced 2026-07-21 00:58:53 +00:00
Implémentation fonctionnalité admin 'Select a choice'
This commit is contained in:
parent
8baa21fed3
commit
c9b9bca732
6 changed files with 92 additions and 22 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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 "";');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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:",
|
||||
|
|
|
|||
|
|
@ -280,7 +280,28 @@
|
|||
{/if}
|
||||
<p class="">{$closed_icon} {$closed_txt|html} </p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{if $poll->closed}
|
||||
<div class="col-md-4 ">
|
||||
<div id="admin-choice">
|
||||
<label class="control-label">{__('PollInfo', 'Admin choice')}</label>
|
||||
{if strcmp($poll->admin_choice, "")==0}
|
||||
<p> __('PollInfo', 'No choice has been selected by the admin yet') </p>
|
||||
{else}
|
||||
{if $poll->format === 'D'}
|
||||
{$choice = explode('@', $poll->admin_choice)}
|
||||
<p> {$choice[0]|date_format:$date_format.txt_short|html}
|
||||
{if strcmp($choice[1], "")!=0}
|
||||
- {$choice[1]}
|
||||
{/if}
|
||||
</p>
|
||||
{else}
|
||||
<p> {$poll->admin_choice} </p>
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{if $admin && !$poll->closed}
|
||||
<div class="row">
|
||||
|
|
|
|||
|
|
@ -19,26 +19,33 @@
|
|||
<table class="results">
|
||||
<caption class="sr-only">{__('Poll results', 'Votes')} {$poll->title|html}</caption>
|
||||
<thead>
|
||||
{if $admin && !$expired && !$poll->closed}
|
||||
{if $admin && !$expired}
|
||||
<tr class="hidden-print">
|
||||
<th role="presentation"></th>
|
||||
{$headersDCount=0}
|
||||
{foreach $slots as $id=>$slot}
|
||||
<td headers="C{$id}">
|
||||
<a href="{poll_url id=$admin_poll_id admin=true action='delete_column' action_value=$slot->title}"
|
||||
data-remove-confirmation="{__('adminstuds', 'Confirm removal of the column.')}"
|
||||
class="btn btn-link btn-sm remove-column" title="{__('adminstuds', 'Remove column')} {$slot->title|html}">
|
||||
<i class="glyphicon glyphicon-remove text-danger"></i><span class="sr-only">{__('Generic', 'Remove')}</span>
|
||||
</a>
|
||||
{if $poll->collect_users_mail != constant("Framadate\CollectMail::NO_COLLECT")}
|
||||
<a href="{poll_url id=$admin_poll_id admin=true action='collect_mail' action_value=($headersDCount)}"
|
||||
class="btn btn-link btn-sm collect-mail"
|
||||
title="{__('adminstuds', 'Collect the emails of the polled users for the choice')} {$slot->title|html}">
|
||||
<i class="glyphicon glyphicon-envelope"></i><span class="sr-only">{__('Generic', 'Collect emails')}</span>
|
||||
</a>
|
||||
{/if}
|
||||
{if !$poll->closed}
|
||||
<td headers="C{$id}">
|
||||
<a href="{poll_url id=$admin_poll_id admin=true action='delete_column' action_value=$slot->title}"
|
||||
data-remove-confirmation="{__('adminstuds', 'Confirm removal of the column.')}"
|
||||
class="btn btn-link btn-sm remove-column" title="{__('adminstuds', 'Remove the column')} {$slot->title|html}">
|
||||
<i class="glyphicon glyphicon-remove text-danger"></i><span class="sr-only">{__('Generic', 'Remove')}</span>
|
||||
</a>
|
||||
{if $poll->collect_users_mail != constant("Framadate\CollectMail::NO_COLLECT")}
|
||||
<a href="{poll_url id=$admin_poll_id admin=true action='collect_mail' action_value=($headersDCount)}" class="btn btn-link btn-sm collect-mail" title="{__('adminstuds', 'Collect the emails of the polled users for the choice')} {$slot->title|html}">
|
||||
<i class="glyphicon glyphicon-envelope"></i><span class="sr-only">{__('Generic', 'Collect emails')}</span>
|
||||
</a>
|
||||
{/if}
|
||||
</td>
|
||||
{$headersDCount = $headersDCount+1}
|
||||
{else}
|
||||
<td headers="C{$id}">
|
||||
<a href="{poll_url id=$admin_poll_id admin=true action='select_choice' action_value=$slot->title}"
|
||||
class="btn btn-link btn-sm select_choice" title="{__('adminstuds', 'Select this choice')} {$slot->title|html}">
|
||||
<i class="glyphicon glyphicon-check text-success"></i><span class="sr-only">{__('Generic', 'Select')}</span>
|
||||
</a>
|
||||
</td>
|
||||
{/if}
|
||||
{/foreach}
|
||||
<td>
|
||||
<a href="{poll_url id=$admin_poll_id admin=true action='add_column'}"
|
||||
|
|
|
|||
|
|
@ -19,12 +19,13 @@
|
|||
<table class="results">
|
||||
<caption class="sr-only">{__('Poll results', 'Votes')} {$poll->title|html}</caption>
|
||||
<thead>
|
||||
{if $admin && !$expired && !$poll->closed}
|
||||
{if $admin && !$expired}
|
||||
<tr class="hidden-print">
|
||||
<th role="presentation"></th>
|
||||
{$headersDCount=0}
|
||||
{foreach $slots as $slot}
|
||||
{foreach $slot->moments as $id=>$moment}
|
||||
{if !$poll->closed}
|
||||
<td headers="M{$slot@key} D{$headersDCount} H{$headersDCount}">
|
||||
<a href="{poll_url id=$admin_poll_id admin=true action='delete_column' action_value=$slot->day|cat:'@'|cat:$moment}"
|
||||
data-remove-confirmation="{__('adminstuds', 'Confirm removal of the column.')}"
|
||||
|
|
@ -40,6 +41,15 @@
|
|||
</a>
|
||||
{/if}
|
||||
</td>
|
||||
{else}
|
||||
<td headers="M{$slot@key} D{$headersDCount} H{$headersDCount}">
|
||||
<a href="{poll_url id=$admin_poll_id admin=true action='select_choice' action_value=$slot->day|cat:'@'|cat:$moment}"
|
||||
class="btn btn-link btn-sm select_choice"
|
||||
title="{__('adminstuds', 'Select this choice')} {$slot->day|date_format:$date_format.txt_short|html} - {$moment|html}">
|
||||
<i class="glyphicon glyphicon-check text-success"></i><span class="sr-only">{__('Generic', 'Remove')}</span>
|
||||
</a>
|
||||
</td>
|
||||
{/if}
|
||||
{$headersDCount = $headersDCount+1}
|
||||
{/foreach}
|
||||
{/foreach}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue