diff --git a/app/classes/Framadate/Utils.php b/app/classes/Framadate/Utils.php
index 9eb11ef..7491c4f 100644
--- a/app/classes/Framadate/Utils.php
+++ b/app/classes/Framadate/Utils.php
@@ -183,7 +183,7 @@ class Utils {
return $cleaned;
}
- public static function fromPostOrEmpty($postKey) {
- return !empty($_POST[$postKey]) ? Utils::htmlEscape($_POST[$postKey]) : '';
+ public static function fromPostOrDefault($postKey, $default = '') {
+ return !empty($_POST[$postKey]) ? Utils::htmlEscape($_POST[$postKey]) : $default;
}
}
diff --git a/create_classic_poll.php b/create_classic_poll.php
index f35c1fc..ef26cda 100644
--- a/create_classic_poll.php
+++ b/create_classic_poll.php
@@ -262,7 +262,7 @@ if (empty($_SESSION['form']->title) || empty($_SESSION['form']->admin_name) || (
diff --git a/create_date_poll.php b/create_date_poll.php
index 365d053..8960962 100644
--- a/create_date_poll.php
+++ b/create_date_poll.php
@@ -284,7 +284,7 @@ if (!isset($_SESSION['form']->title) || !isset($_SESSION['form']->admin_name) ||
'. __('Step 2 date', 'Remove all hours') .'
- '. __('Generic', 'Back') . '
+ '. __('Generic', 'Back') . '
'. __('Generic', 'Next') .'
diff --git a/create_poll.php b/create_poll.php
index 5ae484e..c9b12f4 100644
--- a/create_poll.php
+++ b/create_poll.php
@@ -136,7 +136,6 @@ $errors = array(
)
);
-// TODO Move it to TPL
if (!empty($_POST[GO_TO_STEP_2])) {
if (empty($_POST['title'])) {
$errors['title']['aria'] = 'aria-describeby="poll_title_error" ';
@@ -198,13 +197,13 @@ $smarty->assign('use_smtp', $config['use_smtp']);
$smarty->assign('goToStep2', GO_TO_STEP_2);
$smarty->assign('poll_type', $poll_type);
-$smarty->assign('poll_title', Utils::fromPostOrEmpty('title'));
-$smarty->assign('poll_description', Utils::fromPostOrEmpty('description'));
-$smarty->assign('poll_name', Utils::fromPostOrEmpty('name'));
-$smarty->assign('poll_mail', Utils::fromPostOrEmpty('mail'));
-$smarty->assign('poll_editable', Utils::fromPostOrEmpty('editable'));
-$smarty->assign('poll_receiveNewVotes', Utils::fromPostOrEmpty('receiveNewVotes'));
-$smarty->assign('poll_receiveNewComments', Utils::fromPostOrEmpty('receiveNewComments'));
+$smarty->assign('poll_title', Utils::fromPostOrDefault('title', $_SESSION['form']->title));
+$smarty->assign('poll_description', Utils::fromPostOrDefault('description', $_SESSION['form']->description));
+$smarty->assign('poll_name', Utils::fromPostOrDefault('name', $_SESSION['form']->admin_name));
+$smarty->assign('poll_mail', Utils::fromPostOrDefault('mail', $_SESSION['form']->admin_mail));
+$smarty->assign('poll_editable', Utils::fromPostOrDefault('editable', $_SESSION['form']->editable));
+$smarty->assign('poll_receiveNewVotes', Utils::fromPostOrDefault('receiveNewVotes', $_SESSION['form']->receiveNewVotes));
+$smarty->assign('poll_receiveNewComments', Utils::fromPostOrDefault('receiveNewComments', $_SESSION['form']->receiveNewComments));
$smarty->assign('form', $_SESSION['form']);
$smarty->display('create_poll.tpl');
diff --git a/doc/TREEVIEW.md b/doc/TREEVIEW.md
index af26b43..51444d6 100644
--- a/doc/TREEVIEW.md
+++ b/doc/TREEVIEW.md
@@ -27,11 +27,11 @@ Here are the main files and directories you need to know in order to develop on
* La page de présentation de sondage
* adminstuds.php
* La page d'administration réservée à l'auteur du sondage
-* infos_sondage.php
+* create_poll.php
* La page (1/2) de création de sondage récupérant les informations générales
-* choix_date.php
+* create_date_poll.php
* La page de création (2/2) pour un sondage pour déterminer une date
-* choix_autre.php
+* crete_classic_poll.php
* La page de création (2/2) pour un sondage sur un sujet quelconque
* creation_sondage.php
* Le fichier qui récupérent les informations des pages précédentes pour procéder à l'insertion du nouveau sondage dans la base PostgreSQL
diff --git a/infos_sondage.php b/infos_sondage.php
deleted file mode 100644
index c22592e..0000000
--- a/infos_sondage.php
+++ /dev/null
@@ -1,337 +0,0 @@
-choix_sondage">
-if ((isset($_GET['choix_sondage']) && $_GET['choix_sondage'] == 'date') ||
- (isset($_POST["choix_sondage"]) && $_POST["choix_sondage"] == 'creation_sondage_date')) {
- $choix_sondage = "creation_sondage_date";
- $_SESSION['form']->choix_sondage = $choix_sondage;
-} else {
- $choix_sondage = "creation_sondage_autre";
- $_SESSION['form']->choix_sondage = $choix_sondage;
-}
-
-// We clean the data
-$poursuivre = filter_input(INPUT_POST, 'poursuivre', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => '/^(creation_sondage_date|creation_sondage_autre)$/']]);
-$title = filter_input(INPUT_POST, 'title', FILTER_SANITIZE_STRING);
-$name = filter_input(INPUT_POST, 'name', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => NAME_REGEX]]);
-$mail = filter_input(INPUT_POST, 'mail', FILTER_VALIDATE_EMAIL);
-$description = filter_input(INPUT_POST, 'description', FILTER_SANITIZE_STRING);
-$editable = filter_input(INPUT_POST, 'editable', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => BOOLEAN_REGEX]]);
-$receiveNewVotes = filter_input(INPUT_POST, 'receiveNewVotes', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => BOOLEAN_REGEX]]);
-$receiveNewComments = filter_input(INPUT_POST, 'receiveNewComments', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => BOOLEAN_REGEX]]);
-
-
-// On initialise également les autres variables
-$error_on_mail = false;
-$error_on_title = false;
-$error_on_name = false;
-$error_on_description = false;
-
-#tests
-if (!empty($_POST['poursuivre'])) {
- $_SESSION['form']->title = $title;
- $_SESSION['form']->admin_name = $name;
- $_SESSION['form']->admin_mail = $mail;
- $_SESSION['form']->description = $description;
- $_SESSION['form']->editable = ($editable !== null) ? true : false;
- $_SESSION['form']->receiveNewVotes = ($receiveNewVotes !== null) ? true : false;
- $_SESSION['form']->receiveNewComments = ($receiveNewComments !== null) ? true : false;
-
- if ($config['use_smtp']==true) {
- if (empty($mail)) {
- $error_on_mail = true;
- }
- }
-
- if ($title !== $_POST['title']) {
- $error_on_title = true;
- }
-
- if ($name !== $_POST['name']) {
- $error_on_name = true;
- }
-
- if ($description !== $_POST['description']) {
- $error_on_description = true;
- }
-
- // Si pas d'erreur dans l'adresse alors on change de page vers date ou autre
- if ($config['use_smtp'] == true) {
- $email_OK = $mail && !$error_on_mail;
- } else {
- $email_OK = true;
- }
-
- if ($title && $name && $email_OK && ! $error_on_title && ! $error_on_description && ! $error_on_name) {
-
- if ( $poursuivre == 'creation_sondage_date' ) {
- header('Location:create_date_poll.php');
- exit();
- }
-
- if ( $poursuivre == 'creation_sondage_autre' ) {
- header('Location:create_classic_poll.php');
- exit();
- }
-
- } else {
- // Title Erreur !
- Utils::print_header( __('Generic', 'Error!').' - '.__('Step 1', 'Poll creation (1 on 3)') );
- }
-} else {
- // Title OK (formulaire pas encore rempli)
- Utils::print_header( __('Step 1', 'Poll creation (1 on 3)') );
-}
-
-bandeau_titre( __('Step 1', 'Poll creation (1 on 3)') );
-
-/*
- * Préparation des messages d'erreur
- */
-
-$errors = array (
- 'title' => array (
- 'msg' => '',
- 'aria' => '',
- 'class' => ''
- ),
- 'description' => array (
- 'msg' => '',
- 'aria' => '',
- 'class' => ''
- ),
- 'name' => array (
- 'msg' => '',
- 'aria' => '',
- 'class' => ''
- ),
- 'email' => array (
- 'msg' => '',
- 'aria' => '',
- 'class' => ''
- )
-);
-
-if (!empty($_POST['poursuivre'])) {
- if (empty($_POST['title'])) {
- $errors['title']['aria'] = 'aria-describeby="poll_title_error" ';
- $errors['title']['class'] = ' has-error';
- $errors['title']['msg'] = '' . __('Error', 'Enter a title') . '
';
- } elseif ($error_on_title) {
- $errors['title']['aria'] = 'aria-describeby="poll_title_error" ';
- $errors['title']['class'] = ' has-error';
- $errors['title']['msg'] = '' . __('Error', 'Something is wrong with the format') . '
';
- }
-
- if ($error_on_description) {
- $errors['description']['aria'] = 'aria-describeby="poll_comment_error" ';
- $errors['description']['class'] = ' has-error';
- $errors['description']['msg'] = '
';
- }
-
- if (empty($_POST['name'])) {
- $errors['name']['aria'] = 'aria-describeby="poll_name_error" ';
- $errors['name']['class'] = ' has-error';
- $errors['name']['msg'] = '' . __('Error', 'Enter a name') . '
';
- } elseif ($error_on_name) {
- $errors['name']['aria'] = 'aria-describeby="poll_name_error" ';
- $errors['name']['class'] = ' has-error';
- $errors['name']['msg'] = '' . __('Error', 'Something is wrong with the format') . '
';
- }
-
- if (empty($_POST['mail'])) {
- $errors['email']['aria'] = 'aria-describeby="poll_name_error" ';
- $errors['email']['class'] = ' has-error';
- $errors['email']['msg'] = '' . __('Error', 'Enter an email address') . '
';
- } elseif ($error_on_mail) {
- $errors['email']['aria'] = 'aria-describeby="poll_email_error" ';
- $errors['email']['class'] = ' has-error';
- $errors['email']['msg'] = '' . __('Error', 'The address is not correct! You should enter a valid email address (like r.stallman@outlock.com) in order to receive the link to your poll.') . '
';
- }
-}
-/*
- * Préparation en fonction des paramètres de session
- */
-
-// REMOTE_USER ?
-/**
- * @return string
- */
-
-if (USE_REMOTE_USER && isset($_SERVER['REMOTE_USER'])) {
- $input_name = ' '.$_SESSION['form']->admin_name;
- $input_email = ' '.$_SESSION['form']->admin_mail;
-} else {
- $input_name = ' ';
- $input_email = ' ';
-}
-
-// Checkbox checked ?
-if ($_SESSION['form']->editable) {
- $editable = 'checked';
-}
-
-if ($_SESSION['form']->receiveNewVotes) {
- $receiveNewVotes = 'checked';
-}
-
-if ($_SESSION['form']->receiveNewComments) {
- $receiveNewComments = 'checked';
-}
-
-// Display form
-echo '
-
-
- '.
- __('Step 1', 'Javascript is disabled on your browser. Its activation is required to create a poll.')
- .'
-
-'.
- __('Step 1', 'Cookies are disabled on your browser. Theirs activation is required to create a poll.')
- .'
-';
-
-echo '
-
-';
-
-
-bandeau_pied();
diff --git a/robots.txt b/robots.txt
index c95a7c6..e469987 100644
--- a/robots.txt
+++ b/robots.txt
@@ -3,5 +3,5 @@ Allow: /
Allow: /index.php
Allow: /apropos.php
Allow: /contacts.php
-Allow: /infos_sondage.php
+Allow: /create_poll.php
Disallow: /*
\ No newline at end of file