Modification collect_users_mail de bool à int (MAJ de la création d'un sondage)
This commit is contained in:
parent
bcd5acdea5
commit
feb0c1e6ce
37
app/classes/Framadate/Collect_mail.php
Normal file
37
app/classes/Framadate/Collect_mail.php
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This software is governed by the CeCILL-B license. If a copy of this license
|
||||||
|
* 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 Framadate/OpenSondage: Framasoft (https://github.com/framasoft)
|
||||||
|
*
|
||||||
|
* =============================
|
||||||
|
*
|
||||||
|
* 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 Framadate/OpenSondage : Framasoft (https://github.com/framasoft)
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Framadate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Collect_mail
|
||||||
|
*
|
||||||
|
* Is used to specify the poll's edition permissions.
|
||||||
|
* @TODO : wait to use the SplEnum
|
||||||
|
*
|
||||||
|
* @package Framadate
|
||||||
|
*/
|
||||||
|
class Collect_mail { // extends SplEnum
|
||||||
|
const __default = self::NO_COLLECT;
|
||||||
|
|
||||||
|
const NO_COLLECT = 0;
|
||||||
|
const COLLECT = 1;
|
||||||
|
const COLLECT_REQUIRED = 2;
|
||||||
|
const COLLECT_REQUIRED_VERIFIED = 3;
|
||||||
|
}
|
@ -83,8 +83,8 @@ class Form
|
|||||||
public $results_publicly_visible;
|
public $results_publicly_visible;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If true, the users can leave an email address while voting in the poll
|
* Tells if voters email addresses are collected or not.
|
||||||
* @var boolean
|
* @var \Framadate\Collect_mail
|
||||||
*/
|
*/
|
||||||
public $collect_users_mail;
|
public $collect_users_mail;
|
||||||
|
|
||||||
@ -95,6 +95,7 @@ class Form
|
|||||||
|
|
||||||
public function __construct(){
|
public function __construct(){
|
||||||
$this->editable = Editable::EDITABLE_BY_ALL;
|
$this->editable = Editable::EDITABLE_BY_ALL;
|
||||||
|
$this->collect_users_mail = Collect_mail::NO_COLLECT;
|
||||||
$this->clearChoices();
|
$this->clearChoices();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ class PollRepository extends AbstractRepository {
|
|||||||
'password_hash' => $form->password_hash,
|
'password_hash' => $form->password_hash,
|
||||||
'results_publicly_visible' => $form->results_publicly_visible ? 1 : 0,
|
'results_publicly_visible' => $form->results_publicly_visible ? 1 : 0,
|
||||||
'ValueMax' => $form->ValueMax,
|
'ValueMax' => $form->ValueMax,
|
||||||
'collect_users_mail' => $form->collect_users_mail? 1 : 0,
|
'collect_users_mail' => ($form->collect_users_mail >= 0 && $form->collect_users_mail <= 3) ? $form->collect_users_mail : 0,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,6 +115,10 @@ class InputService {
|
|||||||
return filter_var($editable, FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => EDITABLE_CHOICE_REGEX]]);
|
return filter_var($editable, FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => EDITABLE_CHOICE_REGEX]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function filterCollect_mail($collect_mail) {
|
||||||
|
return filter_var($collect_mail, FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => COLLECT_MAIL_CHOICE_REGEX]]);
|
||||||
|
}
|
||||||
|
|
||||||
public function filterComment($comment) {
|
public function filterComment($comment) {
|
||||||
$comment = str_replace("\r\n", "\n", $comment);
|
$comment = str_replace("\r\n", "\n", $comment);
|
||||||
return $this->returnIfNotBlank($comment);
|
return $this->returnIfNotBlank($comment);
|
||||||
|
@ -33,6 +33,7 @@ const CHOICE_REGEX = '/^[ 012]$/';
|
|||||||
const BOOLEAN_REGEX = '/^(on|off|true|false|1|0)$/i';
|
const BOOLEAN_REGEX = '/^(on|off|true|false|1|0)$/i';
|
||||||
const BOOLEAN_TRUE_REGEX = '/^(on|true|1)$/i';
|
const BOOLEAN_TRUE_REGEX = '/^(on|true|1)$/i';
|
||||||
const EDITABLE_CHOICE_REGEX = '/^[0-2]$/';
|
const EDITABLE_CHOICE_REGEX = '/^[0-2]$/';
|
||||||
|
const COLLECT_MAIL_CHOICE_REGEX = '/^[0-3]$/';
|
||||||
const BASE64_REGEX = '/^[A-Za-z0-9]+$/';
|
const BASE64_REGEX = '/^[A-Za-z0-9]+$/';
|
||||||
const MD5_REGEX = '/^[A-Fa-f0-9]{32}$/';
|
const MD5_REGEX = '/^[A-Fa-f0-9]{32}$/';
|
||||||
|
|
||||||
|
@ -59,7 +59,6 @@ if ($goToStep2) {
|
|||||||
$ValueMax = $use_ValueMax === true ? $inputService->filterValueMax($_POST['ValueMax']) : null;
|
$ValueMax = $use_ValueMax === true ? $inputService->filterValueMax($_POST['ValueMax']) : null;
|
||||||
|
|
||||||
$collect_users_mail = isset($_POST['collect_users_mail']) ? $inputService->filterBoolean($_POST['collect_users_mail']) : false;
|
$collect_users_mail = isset($_POST['collect_users_mail']) ? $inputService->filterBoolean($_POST['collect_users_mail']) : false;
|
||||||
|
|
||||||
$use_customized_url = isset($_POST['use_customized_url']) ? $inputService->filterBoolean($_POST['use_customized_url']) : false;
|
$use_customized_url = isset($_POST['use_customized_url']) ? $inputService->filterBoolean($_POST['use_customized_url']) : false;
|
||||||
$customized_url = $use_customized_url === true ? $inputService->filterId($_POST['customized_url']) : null;
|
$customized_url = $use_customized_url === true ? $inputService->filterId($_POST['customized_url']) : null;
|
||||||
$name = $inputService->filterName($_POST['name']);
|
$name = $inputService->filterName($_POST['name']);
|
||||||
@ -70,7 +69,7 @@ if ($goToStep2) {
|
|||||||
$receiveNewComments = isset($_POST['receiveNewComments']) ? $inputService->filterBoolean($_POST['receiveNewComments']) : false;
|
$receiveNewComments = isset($_POST['receiveNewComments']) ? $inputService->filterBoolean($_POST['receiveNewComments']) : false;
|
||||||
$hidden = isset($_POST['hidden']) ? $inputService->filterBoolean($_POST['hidden']) : false;
|
$hidden = isset($_POST['hidden']) ? $inputService->filterBoolean($_POST['hidden']) : false;
|
||||||
$use_password = filter_input(INPUT_POST, 'use_password', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => BOOLEAN_REGEX]]);
|
$use_password = filter_input(INPUT_POST, 'use_password', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => BOOLEAN_REGEX]]);
|
||||||
$collect_users_mail = isset($_POST['collect_users_mail']) ? $inputService->filterBoolean($_POST['collect_users_mail']) : false;
|
$collect_users_mail = $inputService->filterCollect_mail($_POST['collect_users_mail']);
|
||||||
$use_password = filter_input(INPUT_POST, 'use_password', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => BOOLEAN_REGEX]]);
|
$use_password = filter_input(INPUT_POST, 'use_password', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => BOOLEAN_REGEX]]);
|
||||||
$password = isset($_POST['password']) ? $_POST['password'] : null;
|
$password = isset($_POST['password']) ? $_POST['password'] : null;
|
||||||
$password_repeat = isset($_POST['password_repeat']) ? $_POST['password_repeat'] : null;
|
$password_repeat = isset($_POST['password_repeat']) ? $_POST['password_repeat'] : null;
|
||||||
|
@ -81,8 +81,8 @@ $(document).ready(function () {
|
|||||||
/**
|
/**
|
||||||
* Hide/Show Warning collect_users_mail + editable by all
|
* Hide/Show Warning collect_users_mail + editable by all
|
||||||
*/
|
*/
|
||||||
$("#collect_users_mail").change(function(){
|
$("input[name='collect_users_mail']").change(function(){
|
||||||
if ($(this).prop("checked") && $("input[name='editable']:checked").val() == 1) {
|
if (($("input[name='collect_users_mail']:checked").val() != 0) && ($("input[name='editable']:checked").val() == 1)) {
|
||||||
$("#collect_warning").removeClass("hidden");
|
$("#collect_warning").removeClass("hidden");
|
||||||
} else {
|
} else {
|
||||||
$("#collect_warning").addClass("hidden");
|
$("#collect_warning").addClass("hidden");
|
||||||
@ -90,7 +90,7 @@ $(document).ready(function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$("input[name='editable']").change(function(){
|
$("input[name='editable']").change(function(){
|
||||||
if ($("#collect_users_mail").prop("checked") && $("input[name='editable']:checked").val() == 1) {
|
if ($("input[name='collect_users_mail']:checked").val() != 0 && $("input[name='editable']:checked").val() == 1) {
|
||||||
$("#collect_warning").removeClass("hidden");
|
$("#collect_warning").removeClass("hidden");
|
||||||
} else {
|
} else {
|
||||||
$("#collect_warning").addClass("hidden");
|
$("#collect_warning").addClass("hidden");
|
||||||
|
@ -309,6 +309,7 @@
|
|||||||
"Vote no for": "Vote \"no\" for",
|
"Vote no for": "Vote \"no\" for",
|
||||||
"Vote yes for": "Vote \"yes\" for",
|
"Vote yes for": "Vote \"yes\" for",
|
||||||
"Votes of the poll": "Votes",
|
"Votes of the poll": "Votes",
|
||||||
|
"Warning : anyone can access to your email address after voting": "Warning : anyone can access to your email address after voting",
|
||||||
"polled user": "polled user",
|
"polled user": "polled user",
|
||||||
"polled users": "polled users"
|
"polled users": "polled users"
|
||||||
},
|
},
|
||||||
@ -320,6 +321,7 @@
|
|||||||
"Cancel the name edit": "Cancel the name edit",
|
"Cancel the name edit": "Cancel the name edit",
|
||||||
"Cancel the rules edit": "Cancel the rules edit",
|
"Cancel the rules edit": "Cancel the rules edit",
|
||||||
"Cancel the title edit": "Cancel the title edit",
|
"Cancel the title edit": "Cancel the title edit",
|
||||||
|
"Collect of the polled users email addresses": "Collect of the polled users email addresses",
|
||||||
"Collecting the polled users emails": "Collecting the polled users email addresses",
|
"Collecting the polled users emails": "Collecting the polled users email addresses",
|
||||||
"Edit the description": "Edit the description",
|
"Edit the description": "Edit the description",
|
||||||
"Edit the email adress": "Edit the email address",
|
"Edit the email adress": "Edit the email address",
|
||||||
@ -331,6 +333,7 @@
|
|||||||
"Expiration date": "Expiry date",
|
"Expiration date": "Expiry date",
|
||||||
"Export to CSV": "Export to CSV",
|
"Export to CSV": "Export to CSV",
|
||||||
"Initiator of the poll": "Creator of the poll",
|
"Initiator of the poll": "Creator of the poll",
|
||||||
|
"No collect of the polled users email addresses": "No collect of the polled users email addresses",
|
||||||
"No password": "No password",
|
"No password": "No password",
|
||||||
"Only votes are protected": "Only votes are protected",
|
"Only votes are protected": "Only votes are protected",
|
||||||
"Password protected": "Password protected",
|
"Password protected": "Password protected",
|
||||||
@ -358,8 +361,13 @@
|
|||||||
"Step 1": {
|
"Step 1": {
|
||||||
"All voters can modify any vote": "All voters can modify any vote",
|
"All voters can modify any vote": "All voters can modify any vote",
|
||||||
"Collect the polled users email addresses": "Collecting the polled users' email addresses",
|
"Collect the polled users email addresses": "Collecting the polled users' email addresses",
|
||||||
"Collect users email": "Collect users' email addresses",
|
"Collect users email": "Collect users email",
|
||||||
|
"Collect voters email": "Collect voters email",
|
||||||
"Customize the URL": "Customize the URL",
|
"Customize the URL": "Customize the URL",
|
||||||
|
"Email addresses are collected but not required": "Email addresses are collected but not required",
|
||||||
|
"Email addresses are not collected": "Email addresses are not collected",
|
||||||
|
"Email addresses are required": "Email addresses are required",
|
||||||
|
"Email addresses are required and verified": "Email addresses are required and verified",
|
||||||
"Go to step 2": "Go to step 2",
|
"Go to step 2": "Go to step 2",
|
||||||
"Limit the amount of voters per option": "Limit the amount of voters per option",
|
"Limit the amount of voters per option": "Limit the amount of voters per option",
|
||||||
"More informations here:": "More informations here:",
|
"More informations here:": "More informations here:",
|
||||||
@ -384,6 +392,7 @@
|
|||||||
"ValueMax instructions": "votes per option",
|
"ValueMax instructions": "votes per option",
|
||||||
"Voters can modify their vote themselves": "Voters can modify their vote themselves",
|
"Voters can modify their vote themselves": "Voters can modify their vote themselves",
|
||||||
"Votes cannot be modified": "Votes cannot be modified",
|
"Votes cannot be modified": "Votes cannot be modified",
|
||||||
|
"Warning : anyone can access to the polled users's email addresses.": "Warning : anyone can access to the polled users's email addresses.",
|
||||||
"Warning: anyone can access the polled users email addresses since all voters can modify any vote. You should restrict permission rules.": "Warning: Anyone can see the polled users' email addresses since all voters can modify any vote. You should restrict permission rules.",
|
"Warning: anyone can access the polled users email addresses since all voters can modify any vote. You should restrict permission rules.": "Warning: Anyone can see the polled users' email addresses since all voters can modify any vote. You should restrict permission rules.",
|
||||||
"You are in the poll creation section.": "You are in the poll creation section.",
|
"You are in the poll creation section.": "You are in the poll creation section.",
|
||||||
"You can enable or disable the editor at will.": "You can enable or disable the editor at will."
|
"You can enable or disable the editor at will.": "You can enable or disable the editor at will."
|
||||||
@ -442,6 +451,7 @@
|
|||||||
"Back to the poll": "Back to the poll",
|
"Back to the poll": "Back to the poll",
|
||||||
"Choice added": "Choice added",
|
"Choice added": "Choice added",
|
||||||
"Collect the emails of the polled users for the choice": "Collect the emails of the polled users for the choice",
|
"Collect the emails of the polled users for the choice": "Collect the emails of the polled users for the choice",
|
||||||
|
"Collect the emails of the polled users for this column": "Collect the emails of the polled users for this column",
|
||||||
"Column removed": "Column deleted",
|
"Column removed": "Column deleted",
|
||||||
"Column's adding": "Adding a column",
|
"Column's adding": "Adding a column",
|
||||||
"Comment deleted": "Comment deleted",
|
"Comment deleted": "Comment deleted",
|
||||||
@ -473,12 +483,12 @@
|
|||||||
"remove a column or a line with": "remove a column or a line with"
|
"remove a column or a line with": "remove a column or a line with"
|
||||||
},
|
},
|
||||||
"display_mails": {
|
"display_mails": {
|
||||||
"No one voted 'If need be' to this option.": "No one voted \"If need be\" for this option.",
|
"People who have answered 'If need be' to this option have left those email addresses :": "People who have answered 'If need be' to this option have left those email addresses :",
|
||||||
"No one voted 'No' to this option.": "No one voted \"No\" for this option.",
|
"People who have answered 'If need be' to this option have not left any email addresses.": "People who have answered 'If need be' to this option have not left any email addresses.",
|
||||||
"No one voted 'Yes' to this option.": "No one voted \"Yes\" for this option.",
|
"People who have answered 'No' to this option have left those email addresses :": "People who have answered 'No' to this option have left those email addresses :",
|
||||||
"People who have answered 'If need be' to this option have left these email addresses:": "Email addresses of all users who voted \"If need be\" for this option:",
|
"People who have answered 'No' to this option have not left any email addresses.": "People who have answered 'No' to this option have not left any email addresses.",
|
||||||
"People who have answered 'No' to this option have left these email addresses:": "Email addresses of all users who voted \"No\" for this option:",
|
"People who have answered 'Yes' to this option have left those email addresses :": "People who have answered 'Yes' to this option have left those email addresses :",
|
||||||
"People who have answered 'Yes' to this option have left these email addresses:": "Email addresses of all users who voted \"Yes\" for this option:"
|
"People who have answered 'Yes' to this option have not left any email addresses.": "People who have answered 'Yes' to this option have not left any email addresses."
|
||||||
},
|
},
|
||||||
"studs": {
|
"studs": {
|
||||||
"Adding the vote succeeded": "Vote added",
|
"Adding the vote succeeded": "Vote added",
|
||||||
|
@ -329,17 +329,28 @@
|
|||||||
{* Collect users email *}
|
{* Collect users email *}
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="collect_mail" class="col-sm-4 control-label">
|
<label for="poll_id" class="col-sm-4 control-label">
|
||||||
{__('Step 1', 'Collect users email')}
|
{__('Step 1', 'Collect voters email')}
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<div class="checkbox">
|
<div class="radio">
|
||||||
<label>
|
<label>
|
||||||
<input type="checkbox" name="collect_users_mail"
|
<input type="radio" name="collect_users_mail" id="no_collect" {if $collect_users_mail==constant("Framadate\Collect_mail::NO_COLLECT")}checked{/if} value="{constant("Framadate\Collect_mail::NO_COLLECT")}">
|
||||||
id="collect_users_mail">
|
{__('Step 1', 'Email addresses are not collected')}
|
||||||
{__('Step 1', "Collect the polled users email addresses")}
|
|
||||||
</label>
|
</label>
|
||||||
|
<label>
|
||||||
|
<input type="radio" name="collect_users_mail" {if $collect_users_mail==constant("Framadate\Collect_mail::COLLECT")}checked{/if} value="{constant("Framadate\Collect_mail::COLLECT")}">
|
||||||
|
{__('Step 1', 'Email addresses are collected but not required')}
|
||||||
|
</label>
|
||||||
|
<label>
|
||||||
|
<input type="radio" name="collect_users_mail" {if $collect_users_mail==constant("Framadate\Collect_mail::COLLECT_REQUIRED")}checked{/if} value="{constant("Framadate\Collect_mail::COLLECT_REQUIRED")}">
|
||||||
|
{__('Step 1', 'Email addresses are required')}
|
||||||
|
</label>
|
||||||
|
<label>
|
||||||
|
<input type="radio" name="collect_users_mail" {if $collect_users_mail==constant("Framadate\Collect_mail::COLLECT_REQUIRED_VERIFIED")}checked{/if} value="{constant("Framadate\Collect_mail::COLLECT_REQUIRED_VERIFIED")}">
|
||||||
|
{__('Step 1', 'Email addresses are required and verified')}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user