Merge branch 'framadate-bug/limit_end_date_when_updating_poll' into 'develop'

Limit end date when updating poll (#336)

See merge request framasoft/framadate/framadate!372
This commit is contained in:
Thomas Citharel 2019-04-16 16:14:15 +02:00
commit ec939a8a30

View File

@ -33,10 +33,16 @@ class AdminPollService {
function updatePoll($poll) { function updatePoll($poll) {
global $config; global $config;
if ($poll->end_date > $poll->creation_date) {
return $this->pollRepository->update($poll); $end_date = strtotime($poll->end_date);
if ($end_date < strtotime($poll->creation_date)) {
$poll->end_date = $poll->creation_date;
} elseif ($end_date > $this->pollService->maxExpiryDate()) {
$poll->end_date = utf8_encode(strftime('%Y-%m-%d', $this->pollService->maxExpiryDate()));
} }
return false;
return $this->pollRepository->update($poll);
} }
/** /**