Sondage 1.2 Wip

This commit is contained in:
Fred Tempez 2024-08-27 20:26:07 +02:00
parent 5459c52e6b
commit 3cadf4db58

View File

@ -15,9 +15,10 @@
*/
class sondage extends common {
class sondage extends common
{
const VERSION = '1.2';
const VERSION = '1.3';
const REALNAME = 'Sondage';
const DELETE = true;
const UPDATE = '0.0';
@ -69,7 +70,8 @@ class sondage extends common {
/**
* Configuration
*/
public function config() {
public function config()
{
// Liste des utilisateurs
$userIdsFirstnames = helper::arraycollumn($this->getData(['user']), 'firstname');
ksort($userIdsFirstnames);
@ -100,6 +102,7 @@ class sondage extends common {
$this->setData(['module', $this->getUrl(0), 'data', []]);
// Génération des champs
$inputs = [];
if (is_array($this->getInput('formConfigPosition', null))) {
foreach ($this->getInput('formConfigPosition', null) as $index => $position) {
$inputs[] = [
'name' => $this->getInput('formConfigName[' . $index . ']'),
@ -109,6 +112,8 @@ class sondage extends common {
'values' => $this->getInput('formConfigValues[' . $index . ']')
];
}
}
$this->setData(['module', $this->getUrl(0), 'input', $inputs]);
// Valeurs en sortie
$this->addOutput([
@ -138,7 +143,8 @@ class sondage extends common {
/**
* Données enregistrées
*/
public function data() {
public function data()
{
$data = $this->getData(['module', $this->getUrl(0), 'data']);
if (is_array($data)) {
// Pagination
@ -174,7 +180,8 @@ class sondage extends common {
/**
* Réponses enregistrées
*/
public function result() {
public function result()
{
$data = $this->getData(['module', $this->getUrl(0), 'data']);
if ($data) {
// Pagination
@ -207,7 +214,8 @@ class sondage extends common {
* @author Frédéric Tempez <frederic.tempez@outlook.com>
* @copyright Copyright (C) 2018-2020, Frédéric Tempez
*/
public function export2csv() {
public function export2csv()
{
// Jeton incorrect
if ($this->getUrl(2) !== $_SESSION['csrf']) {
// Valeurs en sortie
@ -247,7 +255,8 @@ class sondage extends common {
/**
* Suppression
*/
public function deleteall() {
public function deleteall()
{
// Jeton incorrect
if ($this->getUrl(2) !== $_SESSION['csrf']) {
// Valeurs en sortie
@ -282,7 +291,8 @@ class sondage extends common {
/**
* Suppression
*/
public function delete() {
public function delete()
{
// Jeton incorrect
if ($this->getUrl(3) !== $_SESSION['csrf']) {
// Valeurs en sortie
@ -317,14 +327,15 @@ class sondage extends common {
/**
* Accueil
*/
public function index() {
public function index()
{
// Soumission du formulaire
if ($this->isPost()) {
// Check la capcha
if (
$this->getData(['module', $this->getUrl(0), 'config', 'capcha'])
AND $this->getInput('formCapcha', helper::FILTER_INT) !== $this->getInput('formCapchaFirstNumber', helper::FILTER_INT) + $this->getInput('formCapchaSecondNumber', helper::FILTER_INT))
{
and $this->getInput('formCapcha', helper::FILTER_INT) !== $this->getInput('formCapchaFirstNumber', helper::FILTER_INT) + $this->getInput('formCapchaSecondNumber', helper::FILTER_INT)
) {
self::$inputNotices['formCapcha'] = 'Incorrect';
}
@ -343,7 +354,7 @@ class sondage extends common {
case self::TYPE_DATETIME:
$filter = helper::FILTER_STRING_SHORT; // Mettre TYPE_DATETIME pour récupérer un TIMESTAMP
break;
CASE self::TYPE_CHECKBOX:
case self::TYPE_CHECKBOX:
$filter = helper::FILTER_BOOLEAN;
break;
default:
@ -360,9 +371,11 @@ class sondage extends common {
// Envoi du mail
// Rechercher l'adresse en fonction du mail
$sent = true;
$singleuser = $this->getData(['user',
$singleuser = $this->getData([
'user',
$this->getData(['module', $this->getUrl(0), 'config', 'user']),
'mail']);
'mail'
]);
$singlemail = $this->getData(['module', $this->getUrl(0), 'config', 'mail']);
$group = $this->getData(['module', $this->getUrl(0), 'config', 'group']);
// Verification si le mail peut être envoyé