Fixed expiry date edition
This commit is contained in:
parent
d3db76ccd7
commit
fa5014de32
@ -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.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user