Poll creation: Fix + Improve end date choice
This commit is contained in:
parent
bb3d10583d
commit
6fff5f107a
@ -57,13 +57,31 @@ if (empty($_SESSION['form']->title) || empty($_SESSION['form']->admin_name) || (
|
||||
// Step 4 : Data prepare before insert in DB
|
||||
if (isset($_POST['confirmecreation'])) {
|
||||
|
||||
$registredate = explode('/', $_POST['champdatefin']);
|
||||
if (is_array($registredate) == true && count($registredate) == 3) {
|
||||
// Define expiration date
|
||||
$enddate = filter_input(INPUT_POST, 'enddate', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => '#^[0-9]{2}/[0-9]{2}/[0-9]{4}$#']]);
|
||||
$min_time = time() + (24 * 60 * 60);
|
||||
$max_time = time() + (86400 * $config['default_poll_duration']);
|
||||
|
||||
if (!empty($enddate)) {
|
||||
$registredate = explode('/', $enddate);
|
||||
|
||||
if (is_array($registredate) && count($registredate) == 3) {
|
||||
$time = mktime(0, 0, 0, $registredate[1], $registredate[0], $registredate[2]);
|
||||
if ($time > time() + (24 * 60 * 60)) {
|
||||
$_SESSION['form']->champdatefin = $time;
|
||||
|
||||
if ($time < $min_time) {
|
||||
$_SESSION['form']->end_date = $min_time;
|
||||
} elseif ($max_time < $time) {
|
||||
$_SESSION['form']->end_date = $max_time;
|
||||
} else {
|
||||
$_SESSION['form']->end_date = $time;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($_SESSION['form']->end_date)) {
|
||||
// By default, expiration date is 6 months after last day
|
||||
$_SESSION['form']->end_date = $max_time;
|
||||
}
|
||||
|
||||
// format du sondage AUTRE
|
||||
$_SESSION['form']->format = 'A';
|
||||
@ -156,7 +174,7 @@ if (empty($_SESSION['form']->title) || empty($_SESSION['form']->admin_name) || (
|
||||
}
|
||||
$summary .= '</ol>';
|
||||
|
||||
$end_date_str = utf8_encode(strftime('%d/%M/%Y', $_SESSION['form']->end_date)); //textual date
|
||||
$end_date_str = utf8_encode(strftime('%d/%m/%Y', $_SESSION['form']->end_date)); //textual date
|
||||
|
||||
echo '
|
||||
<form name="formulaire" action="' . Utils::get_server_name() . 'choix_autre.php" method="POST" class="form-horizontal" role="form">
|
||||
@ -167,23 +185,23 @@ if (empty($_SESSION['form']->title) || empty($_SESSION['form']->admin_name) || (
|
||||
' . $summary . '
|
||||
</div>
|
||||
<div class="alert alert-info">
|
||||
<p>' . _('Your poll will be automatically removed after') . ' ' . $config['default_poll_duration'] . ' ' . _('days') . '.<br />' . _("You can fix another removal date for it.") . '</p>
|
||||
<p>' . _('Your poll will be automatically removed after') . ' ' . $config['default_poll_duration'] . ' ' . _('days') . '.<br />' . _('You can set a closer removal date for it.') . '</p>
|
||||
<div class="form-group">
|
||||
<label for="champdatefin" class="col-sm-5 control-label">' . _('Removal date (optional)') . '</label>
|
||||
<label for="enddate" class="col-sm-5 control-label">' . _('Removal date (optional)') . '</label>
|
||||
<div class="col-sm-6">
|
||||
<div class="input-group date">
|
||||
<span class="input-group-addon"><i class="glyphicon glyphicon-calendar text-info"></i></span>
|
||||
<input type="text" class="form-control" id="champdatefin" data-date-format="' . _("dd/mm/yyyy") . '" aria-describedby="dateformat" name="champdatefin" value="' . $end_date_str . '" size="10" maxlength="10" placeholder="' . _("dd/mm/yyyy") . '" />
|
||||
<input type="text" class="form-control" id="enddate" data-date-format="' . _('dd/mm/yyyy') . '" aria-describedby="dateformat" name="enddate" value="' . $end_date_str . '" size="10" maxlength="10" placeholder="' . _("dd/mm/yyyy") . '" />
|
||||
</div>
|
||||
</div>
|
||||
<span id="dateformat" class="sr-only">' . _("(dd/mm/yyyy)") . '</span>
|
||||
<span id="dateformat" class="sr-only">' . _('(dd/mm/yyyy)') . '</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="alert alert-warning">
|
||||
<p>' . _("Once you have confirmed the creation of your poll, you will be automatically redirected on the administration page of your poll.") . '</p>';
|
||||
<p>' . _('Once you have confirmed the creation of your poll, you will be automatically redirected on the administration page of your poll.') . '</p>';
|
||||
if ($config['use_smtp'] == true) {
|
||||
echo '
|
||||
<p>' . _("Then, you will receive quickly two emails: one contening the link of your poll for sending it to the voters, the other contening the link to the administration page of your poll.") . '</p>';
|
||||
<p>' . _('Then, you will receive quickly two emails: one contening the link of your poll for sending it to the voters, the other contening the link to the administration page of your poll.') . '</p>';
|
||||
}
|
||||
echo '
|
||||
</div>
|
||||
|
@ -58,22 +58,29 @@ if (!isset($_SESSION['form']->title) || !isset($_SESSION['form']->admin_name) ||
|
||||
if (!empty($_POST['confirmation'])) {
|
||||
|
||||
// Define expiration date
|
||||
if (!empty($_POST['champdatefin']))
|
||||
{
|
||||
$registredate = explode('/', $_POST['champdatefin']);
|
||||
if (is_array($registredate) && count($registredate) == 3)
|
||||
{
|
||||
$time = mktime(0,0,0, $registredate[1], $registredate[0], $registredate[2]);
|
||||
if ($time > time() + (24*60*60))
|
||||
{
|
||||
$_SESSION['form']->end_date=$time;
|
||||
$enddate = filter_input(INPUT_POST, 'enddate', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => '#^[0-9]{2}/[0-9]{2}/[0-9]{4}$#']]);
|
||||
$min_time = time() + (24 * 60 * 60);
|
||||
$max_time = time() + (86400 * $config['default_poll_duration']);
|
||||
|
||||
if (!empty($enddate)) {
|
||||
$registredate = explode('/', $enddate);
|
||||
|
||||
if (is_array($registredate) && count($registredate) == 3) {
|
||||
$time = mktime(0, 0, 0, $registredate[1], $registredate[0], $registredate[2]);
|
||||
|
||||
if ($time < $min_time) {
|
||||
$_SESSION['form']->end_date = $min_time;
|
||||
} elseif ($max_time < $time) {
|
||||
$_SESSION['form']->end_date = $max_time;
|
||||
} else {
|
||||
$_SESSION['form']->end_date = $time;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(empty($_SESSION['form']->end_date)) {
|
||||
if (empty($_SESSION['form']->end_date)) {
|
||||
// By default, expiration date is 6 months after last day
|
||||
$_SESSION['form']->end_date=end($temp_results)+(86400 * $config['default_poll_duration']);
|
||||
$_SESSION['form']->end_date = $max_time;
|
||||
}
|
||||
|
||||
// Insert poll in database
|
||||
@ -165,6 +172,8 @@ if (!isset($_SESSION['form']->title) || !isset($_SESSION['form']->admin_name) ||
|
||||
}
|
||||
$summary .= '</ul>';
|
||||
|
||||
$end_date_str = utf8_encode(strftime('%d/%m/%Y', $_SESSION['form']->end_date)); //textual date
|
||||
|
||||
echo '
|
||||
<form name="formulaire" action="' . Utils::get_server_name() . 'choix_date.php" method="POST" class="form-horizontal" role="form">
|
||||
<div class="row" id="selected-days">
|
||||
@ -175,13 +184,13 @@ if (!isset($_SESSION['form']->title) || !isset($_SESSION['form']->admin_name) ||
|
||||
'. $summary .'
|
||||
</div>
|
||||
<div class="alert alert-info clearfix">
|
||||
<p>' . _('Your poll will be automatically removed '). $config['default_poll_duration'] . ' ' . _("days") . ' ' ._('after the last date of your poll') . '.<br />' . _('You can fix another removal date for it.') .'</p>
|
||||
<p>' . _('Your poll will be automatically removed '). $config['default_poll_duration'] . ' ' . _('days') . ' ' ._('after the last date of your poll') . '.<br />' . _('You can set a closer removal date for it.') .'</p>
|
||||
<div class="form-group">
|
||||
<label for="champdatefin" class="col-sm-5 control-label">'. _('Removal date') .'</label>
|
||||
<label for="enddate" class="col-sm-5 control-label">'. _('Removal date') .'</label>
|
||||
<div class="col-sm-6">
|
||||
<div class="input-group date">
|
||||
<span class="input-group-addon"><i class="glyphicon glyphicon-calendar text-info"></i></span>
|
||||
<input type="text" class="form-control" id="champdatefin" data-date-format="'. _("dd/mm/yyyy") .'" aria-describedby="dateformat" name="champdatefin" value="'.strftime('%d/%m/%Y', $removal_date).'" size="10" maxlength="10" placeholder="'. _('dd/mm/yyyy') .'" />
|
||||
<input type="text" class="form-control" id="enddate" data-date-format="'. _('dd/mm/yyyy') .'" aria-describedby="dateformat" name="enddate" value="'.$end_date_str.'" size="10" maxlength="10" placeholder="'. _('dd/mm/yyyy') .'" />
|
||||
</div>
|
||||
</div>
|
||||
<span id="dateformat" class="sr-only">'. _("(dd/mm/yyyy)") .'</span>
|
||||
|
Binary file not shown.
@ -567,7 +567,7 @@ msgstr "Löschdatum:"
|
||||
msgid "Your poll will be automatically removed after 6 months."
|
||||
msgstr "Ihre Umfrage wird automatisch nach 6 Monaten gelöscht."
|
||||
|
||||
msgid "You can fix another removal date for it."
|
||||
msgid "You can set a closer removal date for it."
|
||||
msgstr "Sie können jedoch auch ein anderes Löschdatum festlegen."
|
||||
|
||||
msgid "Removal date (optional)"
|
||||
|
Binary file not shown.
@ -576,8 +576,8 @@ msgstr "Removal date:"
|
||||
msgid "Your poll will be automatically removed after"
|
||||
msgstr "Your poll will be automatically removed after"
|
||||
|
||||
msgid "You can fix another removal date for it."
|
||||
msgstr "You can fix another removal date for it."
|
||||
msgid "You can set a closer removal date for it."
|
||||
msgstr "You can set a closer removal date for it."
|
||||
|
||||
msgid "Removal date (optional)"
|
||||
msgstr "Removal date (optional)"
|
||||
|
Binary file not shown.
@ -526,7 +526,7 @@ msgid "Characters \" < and > are not permitted"
|
||||
msgstr "Los caracteres \" < y > no estan autorizados!"
|
||||
|
||||
#: choix_autre.php:191
|
||||
msgid "Your poll will be automatically removed after 6 months.<br> You can fix another removal date for it."
|
||||
msgid "Your poll will be automatically removed after 6 months.<br> You can set a closer removal date for it."
|
||||
msgstr "Su encuesta será automaticamente borrado dentro de 6 meses.<br> Mientras, usted puede cambiar este fecha aquí."
|
||||
|
||||
#: choix_autre.php:193
|
||||
|
Binary file not shown.
@ -576,8 +576,8 @@ msgstr "Date de suppression :"
|
||||
msgid "Your poll will be automatically removed after"
|
||||
msgstr "Votre sondage sera automatiquement effacé dans"
|
||||
|
||||
msgid "You can fix another removal date for it."
|
||||
msgstr "Néanmoins vous pouvez décider ci-dessous d'une date plus rapprochée pour la suppression de votre sondage."
|
||||
msgid "You can set a closer removal date for it."
|
||||
msgstr "Vous pouvez décider d'une date de suppression plus proche."
|
||||
|
||||
msgid "Removal date (optional)"
|
||||
msgstr "Date de fin (facultative)"
|
||||
|
Loading…
Reference in New Issue
Block a user