mirror of
https://framagit.org/framasoft/framadate/framadate
synced 2026-07-25 19:03:50 +00:00
Merge branch 'Fix_edition_of_expired_poll' into 'release'
Fix edition limits for expired polls Fix #129 See merge request !117
This commit is contained in:
commit
b3ecf1262f
4 changed files with 22 additions and 11 deletions
|
|
@ -122,8 +122,7 @@ if (isset($_POST['update_poll_info'])) {
|
|||
break;
|
||||
}
|
||||
} elseif ($field == 'expiration_date') {
|
||||
$expiration_date = filter_input(INPUT_POST, 'expiration_date', FILTER_VALIDATE_REGEXP,
|
||||
['options' => ['regexp' => '#^[0-9]{4}-[0-9]{2}-[0-9]{2}$#']]);
|
||||
$expiration_date = $inputService->filterDate($_POST['expiration_date']);
|
||||
if ($expiration_date) {
|
||||
$poll->end_date = $expiration_date;
|
||||
$updated = true;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ namespace Framadate\Services;
|
|||
use Framadate\Exception\MomentAlreadyExistsException;
|
||||
use Framadate\FramaDB;
|
||||
use Framadate\Repositories\RepositoryFactory;
|
||||
use Framadate\Utils;
|
||||
|
||||
/**
|
||||
* Class AdminPollService
|
||||
|
|
@ -33,7 +34,7 @@ class AdminPollService {
|
|||
|
||||
function updatePoll($poll) {
|
||||
global $config;
|
||||
if ($poll->end_date > $poll->creation_date && $poll->end_date <= strtotime($poll->creation_date) + (86400 * $config['default_poll_duration'])) {
|
||||
if ($poll->end_date > $poll->creation_date) {
|
||||
return $this->pollRepository->update($poll);
|
||||
} else {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
* Auteurs de Framadate/OpenSondage : Framasoft (https://github.com/framasoft)
|
||||
*/
|
||||
namespace Framadate\Services;
|
||||
use DateTime;
|
||||
|
||||
/**
|
||||
* This class helps to clean all inputs from the users or external services.
|
||||
|
|
@ -90,6 +91,11 @@ class InputService {
|
|||
return $this->returnIfNotBlank($comment);
|
||||
}
|
||||
|
||||
public function filterDate($date) {
|
||||
$dDate = DateTime::createFromFormat(__('Date', 'datetime_parseformat'), $date)->setTime(0, 0, 0);
|
||||
return $dDate->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the value if it's not blank.
|
||||
*
|
||||
|
|
@ -107,4 +113,4 @@ class InputService {
|
|||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,8 @@
|
|||
<div class="btn-group pull-right">
|
||||
<button onclick="print(); return false;" class="btn btn-default"><span class="glyphicon glyphicon-print"></span> {__('PollInfo', 'Print')}</button>
|
||||
<a href="{$SERVER_URL|html}exportcsv.php?poll={$poll_id|html}" class="btn btn-default"><span class="glyphicon glyphicon-download-alt"></span> {__('PollInfo', 'Export to CSV')}</a>
|
||||
{if $admin && !$expired}
|
||||
{if $admin}
|
||||
{if !$expired}
|
||||
<button type="button" class="btn btn-danger dropdown-toggle" data-toggle="dropdown">
|
||||
<span class="glyphicon glyphicon-trash"></span> <span class="sr-only">{__('Generic', 'Remove')}</span> <span class="caret"></span>
|
||||
</button>
|
||||
|
|
@ -32,6 +33,12 @@
|
|||
<li class="divider" role="presentation"></li>
|
||||
<li><button class="btn btn-link" type="submit" name="delete_poll">{__('PollInfo', 'Remove the poll')}</button></li>
|
||||
</ul>
|
||||
{else}
|
||||
<button class="btn btn-danger" type="submit" name="delete_poll" title="{__('PollInfo', 'Remove the poll')}">
|
||||
<span class="glyphicon glyphicon-trash"></span>
|
||||
<span class="sr-only">{__('PollInfo', 'Remove the poll')}</span>
|
||||
</button>
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -102,8 +109,8 @@
|
|||
</div>
|
||||
<div id="expiration-form" class="form-group col-md-4">
|
||||
<label class="control-label">{__('PollInfo', 'Expiration date')}</label>
|
||||
<p>{$poll->end_date|date_format:$date_format['txt_date']|html}{if !$expired} <button class="btn btn-link btn-sm btn-edit" title="{__('PollInfo', 'Edit the expiration date')}"><span class="glyphicon glyphicon-pencil"></span><span class="sr-only">{__('Generic', 'Edit')}</span></button>{/if}</p>
|
||||
{if !$expired}
|
||||
<p>{$poll->end_date|date_format:$date_format['txt_date']|html} <button class="btn btn-link btn-sm btn-edit" title="{__('PollInfo', 'Edit the expiration date')}"><span class="glyphicon glyphicon-pencil"></span><span class="sr-only">{__('Generic', 'Edit')}</span></button></p>
|
||||
|
||||
<div class="hidden js-expiration">
|
||||
<label class="sr-only" for="newexpirationdate">{__('PollInfo', 'Expiration date')}</label>
|
||||
<div class="input-group">
|
||||
|
|
@ -114,7 +121,7 @@
|
|||
</span>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
|
@ -199,8 +206,7 @@
|
|||
{$rule_icon = '<span class="glyphicon glyphicon-lock"></span>'}
|
||||
{$rule_txt = __('PollInfo', 'Votes and comments are locked')}
|
||||
{/if}
|
||||
<p class="">{$rule_icon} {$rule_txt|html}{if !$expired} <button class="btn btn-link btn-sm btn-edit" title="{__('PollInfo', 'Edit the poll rules')}"><span class="glyphicon glyphicon-pencil"></span><span class="sr-only">{__('Generic', 'Edit')}</span></button>{/if}</p>
|
||||
{if !$expired}
|
||||
<p class="">{$rule_icon} {$rule_txt|html} <button class="btn btn-link btn-sm btn-edit" title="{__('PollInfo', 'Edit the poll rules')}"><span class="glyphicon glyphicon-pencil"></span><span class="sr-only">{__('Generic', 'Edit')}</span></button></p>
|
||||
<div class="hidden js-poll-rules">
|
||||
<label class="sr-only" for="rules">{__('PollInfo', 'Poll rules')}</label>
|
||||
<div class="input-group">
|
||||
|
|
@ -216,7 +222,6 @@
|
|||
</span>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue