From 1f55167e2c10ade4e169880c18980fc55a5bef39 Mon Sep 17 00:00:00 2001 From: Antonin Date: Sun, 5 Apr 2015 15:41:19 +0200 Subject: [PATCH] Added new editable possibility at poll creation --- app/classes/Framadate/Editable.php | 25 +++++++++++++++++++++++++ app/classes/Framadate/Form.php | 5 ++++- app/inc/constants.php | 1 + create_poll.php | 18 +++++++----------- locale/de.json | 2 ++ locale/en.json | 2 ++ locale/es.json | 6 ++++-- locale/fr.json | 4 +++- tpl/create_poll.tpl | 12 ++++++++++-- 9 files changed, 58 insertions(+), 17 deletions(-) create mode 100644 app/classes/Framadate/Editable.php diff --git a/app/classes/Framadate/Editable.php b/app/classes/Framadate/Editable.php new file mode 100644 index 0000000..df3c384 --- /dev/null +++ b/app/classes/Framadate/Editable.php @@ -0,0 +1,25 @@ +editable = true; + $this->editable = Editable::NOT_EDITABLE; $this->clearChoices(); } diff --git a/app/inc/constants.php b/app/inc/constants.php index fb5b618..cada2f8 100644 --- a/app/inc/constants.php +++ b/app/inc/constants.php @@ -25,6 +25,7 @@ const POLL_REGEX = '/^[a-zA-Z0-9]+$/'; const CHOICE_REGEX = '/^[012]$/'; const NAME_REGEX = '/^[áàâäãåçéèêëíìîïñóòôöõúùûüýÿæœa-z0-9_ -]+$/i'; const BOOLEAN_REGEX = '/^(on|off|true|false|1|0)$/'; +const EDITABLE_CHOICE_REGEX = '/^[0-2]$/'; // CSRF (300s = 5min) const TOKEN_TIME = 300; diff --git a/create_poll.php b/create_poll.php index c9b12f4..567bc0f 100644 --- a/create_poll.php +++ b/create_poll.php @@ -4,20 +4,21 @@ * is not distributed with this file, you can obtain one at * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt * - * Authors of STUdS (initial project): Guilhem BORGHESI (borghesi@unistra.fr) and Raphaël DROZ + * Authors of STUdS (initial project): Guilhem BORGHESI (borghesi@unistra.fr) and Rapha�l DROZ * Authors of Framadate/OpenSondate: Framasoft (https://github.com/framasoft) * * ============================= * - * Ce logiciel est régi par la licence CeCILL-B. Si une copie de cette licence + * Ce logiciel est r�gi par la licence CeCILL-B. Si une copie de cette licence * ne se trouve pas avec ce fichier vous pouvez l'obtenir sur * http://www.cecill.info/licences/Licence_CeCILL-B_V1-fr.txt * - * Auteurs de STUdS (projet initial) : Guilhem BORGHESI (borghesi@unistra.fr) et Raphaël DROZ + * Auteurs de STUdS (projet initial) : Guilhem BORGHESI (borghesi@unistra.fr) et Rapha�l DROZ * Auteurs de Framadate/OpenSondage : Framasoft (https://github.com/framasoft) */ use Framadate\Form; +use Framadate\Editable; use Framadate\Utils; include_once __DIR__ . '/app/inc/init.php'; @@ -45,12 +46,12 @@ $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]]); +$editable = filter_input(INPUT_POST, 'editable', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => EDITABLE_CHOICE_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 +// On initialise �galement les autres variables $error_on_mail = false; $error_on_title = false; $error_on_name = false; @@ -62,7 +63,7 @@ if (!empty($_POST[GO_TO_STEP_2])) { $_SESSION['form']->admin_name = $name; $_SESSION['form']->admin_mail = $mail; $_SESSION['form']->description = $description; - $_SESSION['form']->editable = ($editable !== null); + $_SESSION['form']->editable = $editable; $_SESSION['form']->receiveNewVotes = ($receiveNewVotes !== null); $_SESSION['form']->receiveNewComments = ($receiveNewComments !== null); @@ -175,10 +176,6 @@ if (!empty($_POST[GO_TO_STEP_2])) { } // Checkbox checked ? -if ($_SESSION['form']->editable) { - $editable = 'checked'; -} - if ($_SESSION['form']->receiveNewVotes) { $receiveNewVotes = 'checked'; } @@ -187,7 +184,6 @@ if ($_SESSION['form']->receiveNewComments) { $receiveNewComments = 'checked'; } - $useRemoteUser = USE_REMOTE_USER && isset($_SERVER['REMOTE_USER']); $smarty->assign('title', $title); diff --git a/locale/de.json b/locale/de.json index 03f6540..9a99039 100644 --- a/locale/de.json +++ b/locale/de.json @@ -186,6 +186,8 @@ "You are in the poll creation section.": "Sie können hier Umfragen erstellen", "Required fields cannot be left blank.": "Mit * markierte Felder müssen ausgefüllt sein.", "Poll title": "Umfragetitel", + "Votes cannot be modified.": "DE_Aucun vote ne peut être modifié", + "All voters can modify any vote.": "DE_Tous les sondés peuvent modifier tous les votes", "Voters can modify their vote themselves.": "Teilnehmer können ihre Antworten verändern", "To receive an email for each new vote.": "Bei jeder neuen Abstimmung eine E-Mail erhalten.", "To receive an email for each new comment.": "Um eine E-Mail für jede neue Kommentar zu empfangen.", diff --git a/locale/en.json b/locale/en.json index 5403eef..06d0297 100644 --- a/locale/en.json +++ b/locale/en.json @@ -187,6 +187,8 @@ "You are in the poll creation section.": "You are in the poll creation section.", "Required fields cannot be left blank.": "Required fields cannot be left blank.", "Poll title": "Poll title", + "Votes cannot be modified.": "Votes cannot be modified", + "All voters can modify any vote.": "All voters can modify any vote.", "Voters can modify their vote themselves.": "Voters can modify their vote themselves.", "To receive an email for each new vote.": "To receive an email for each new vote.", "To receive an email for each new comment.": "To receive an email for each new comment.", diff --git a/locale/es.json b/locale/es.json index a11b5c7..55aa455 100644 --- a/locale/es.json +++ b/locale/es.json @@ -186,8 +186,10 @@ "You are in the poll creation section.": "Usted ha eligiendo de crear une nueva encuesta!", "Required fields cannot be left blank.": "Gracias por completar los campos con una *.", "Poll title": "ES_Titre du sondage", - "Voters can modify their vote themselves.": " Los encuentados pueden cambiar su línea ellos mismos.", - "To receive an email for each new vote.": " Usted quiere recibir un correo electónico cada vez que alguien participe a la encuesta.", + "Votes cannot be modified.": "ES_Aucun vote ne peut être modifié", + "All voters can modify any vote.": "ES_Tous les sondés peuvent modifier tous les votes", + "Voters can modify their vote themselves.": "Los encuentados pueden cambiar su línea ellos mismos.", + "To receive an email for each new vote.": "Usted quiere recibir un correo electónico cada vez que alguien participe a la encuesta.", "To receive an email for each new comment.": "ES_Recevoir un courriel à chaque commentaire.", "Go to step 2": "ES_Aller à l'étape 2" }, diff --git a/locale/fr.json b/locale/fr.json index a962f1a..21261d1 100644 --- a/locale/fr.json +++ b/locale/fr.json @@ -186,7 +186,9 @@ "You are in the poll creation section.": "Vous avez choisi de créer un nouveau sondage.", "Required fields cannot be left blank.": "Merci de remplir les champs obligatoires, marqués d'une *.", "Poll title": "Titre du sondage", - "Voters can modify their vote themselves.": "Vous souhaitez que les sondés puissent modifier leur ligne eux-mêmes.", + "Votes cannot be modified.": "Aucun vote ne peut être modifié", + "All voters can modify any vote.": "Tous les sondés peuvent modifier tous les votes", + "Voters can modify their vote themselves.": "Chaque sondé peut modifier son propre vote.", "To receive an email for each new vote.": "Recevoir un courriel à chaque participation d'un sondé.", "To receive an email for each new comment.": "Recevoir un courriel à chaque commentaire.", "Go to step 2": "Aller à l'étape 2" diff --git a/tpl/create_poll.tpl b/tpl/create_poll.tpl index ec0e665..47156c6 100644 --- a/tpl/create_poll.tpl +++ b/tpl/create_poll.tpl @@ -90,9 +90,17 @@
-
+
+ +