Added new editable possibility at poll creation
This commit is contained in:
parent
6d31f180e3
commit
1f55167e2c
25
app/classes/Framadate/Editable.php
Normal file
25
app/classes/Framadate/Editable.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: antonin
|
||||
* Date: 05/04/15
|
||||
* Time: 14:28
|
||||
*/
|
||||
|
||||
namespace Framadate;
|
||||
|
||||
|
||||
/**
|
||||
* Class Editable
|
||||
*
|
||||
* Is used to specify the poll's edition permissions.
|
||||
*
|
||||
* @package Framadate
|
||||
*/
|
||||
class Editable { // extends SplEnum
|
||||
const __default = self::EDITABLE_BY_ALL;
|
||||
|
||||
const NOT_EDITABLE = 0;
|
||||
const EDITABLE_BY_ALL = 1;
|
||||
const EDITABLE_BY_OWN = 2;
|
||||
}
|
@ -18,6 +18,8 @@
|
||||
*/
|
||||
namespace Framadate;
|
||||
|
||||
use Framadate\Editable;
|
||||
|
||||
class Form
|
||||
{
|
||||
|
||||
@ -31,6 +33,7 @@ class Form
|
||||
|
||||
/**
|
||||
* Tells if users can modify their choices.
|
||||
* @var \Framadate\Editable
|
||||
*/
|
||||
public $editable;
|
||||
|
||||
@ -50,7 +53,7 @@ class Form
|
||||
private $choices;
|
||||
|
||||
public function __construct(){
|
||||
$this->editable = true;
|
||||
$this->editable = Editable::NOT_EDITABLE;
|
||||
$this->clearChoices();
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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<EFBFBD>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<EFBFBD>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<EFBFBD>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 <EFBFBD>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);
|
||||
|
@ -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.",
|
||||
|
@ -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.",
|
||||
|
@ -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"
|
||||
},
|
||||
|
@ -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"
|
||||
|
@ -90,9 +90,17 @@
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-4 col-sm-8">
|
||||
<div class="checkbox">
|
||||
<div class="radio">
|
||||
<label>
|
||||
<input type=checkbox name="editable" {if $poll_editable}checked{/if} id="editable">
|
||||
<input type="radio" name="editable" {if empty($poll_editable) or $poll_editable==constant("Framadate\Editable::NOT_EDITABLE")}checked{/if} value="{constant("Framadate\Editable::NOT_EDITABLE")}">
|
||||
{__('Step 1', 'Votes cannot be modified.')}
|
||||
</label>
|
||||
<label>
|
||||
<input type="radio" name="editable" {if $poll_editable==constant("Framadate\Editable::EDITABLE_BY_ALL")}checked{/if} value="{constant("Framadate\Editable::EDITABLE_BY_ALL")}">
|
||||
{__('Step 1', 'All voters can modify any vote.')}
|
||||
</label>
|
||||
<label>
|
||||
<input type="radio" name="editable" {if $poll_editable==constant("Framadate\Editable::EDITABLE_BY_OWN")}checked{/if} value="{constant("Framadate\Editable::EDITABLE_BY_OWN")}">
|
||||
{__('Step 1', 'Voters can modify their vote themselves.')}
|
||||
</label>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user