Browse Source

Passage de phpcs

master
Matthieu Marcillaud 8 months ago
parent
commit
34b94f113a
  1. 21
      action/confirmer_signature.php
  2. 80
      action/editer_petition.php
  3. 94
      action/editer_signature.php
  4. 22
      action/relancer_signature.php
  5. 10
      action/supprimer_signature.php
  6. 15
      action/traiter_lot_signature.php
  7. 4
      action/valider_signature.php
  8. 14
      balise/formulaire_signature.php
  9. 122
      base/petitions.php
  10. 27
      formulaires/activer_petition_article.php
  11. 96
      formulaires/signature.php
  12. 75
      petitions_administrations.php
  13. 19
      petitions_autoriser.php
  14. 36
      petitions_fonctions.php
  15. 2
      petitions_options.php
  16. 17
      petitions_pipelines.php
  17. 52
      tests/unit/abstract_sql/99_sql_types_tables_id.php
  18. 87
      tests/unit/connect_sql/id_table_objet.php
  19. 87
      tests/unit/connect_sql/objet_type.php
  20. 86
      tests/unit/connect_sql/table_objet.php
  21. 86
      tests/unit/connect_sql/table_objet_sql.php

21
action/confirmer_signature.php

@ -10,7 +10,7 @@
* Pour plus de détails voir le fichier COPYING.txt ou l'aide en ligne. *
\***************************************************************************/
if (!defined("_ECRIRE_INC_VERSION")) {
if (!defined('_ECRIRE_INC_VERSION')) {
return;
}
@ -63,7 +63,8 @@ function action_confirmer_signature_dist($var_confirm = null) {
// verifier validite de la cle de suppression
// l'id_signature est dans var_confirm
include_spip('inc/securiser_action');
if ($id_signature = intval($var_confirm)
if (
$id_signature = intval($var_confirm)
and (
$_GET['refus'] == _action_auteur("supprimer signature $id_signature", '', '', 'alea_ephemere')
or
@ -71,7 +72,7 @@ function action_confirmer_signature_dist($var_confirm = null) {
)
) {
include_spip('action/editer_signature');
signature_modifier($id_signature, array("statut" => 'poubelle'));
signature_modifier($id_signature, ['statut' => 'poubelle']);
$confirm = _T('petitions:info_signature_supprimee');
} else {
$confirm = _T('petitions:info_signature_supprimee_erreur');
@ -80,7 +81,7 @@ function action_confirmer_signature_dist($var_confirm = null) {
return '';
}
$row = sql_fetsel('*', 'spip_signatures', "statut=" . sql_quote($var_confirm), '', "1");
$row = sql_fetsel('*', 'spip_signatures', 'statut=' . sql_quote($var_confirm), '', '1');
if (!$row) {
$confirm = _T('petitions:form_pet_aucune_signature');
@ -93,24 +94,24 @@ function action_confirmer_signature_dist($var_confirm = null) {
$adresse_email = $row['ad_email'];
$url_site = $row['url_site'];
$row = sql_fetsel('email_unique, site_unique, id_article', 'spip_petitions', "id_petition=" . intval($id_petition));
$row = sql_fetsel('email_unique, site_unique, id_article', 'spip_petitions', 'id_petition=' . intval($id_petition));
$email_unique = $row['email_unique'] == "oui";
$site_unique = $row['site_unique'] == "oui";
$email_unique = $row['email_unique'] == 'oui';
$site_unique = $row['site_unique'] == 'oui';
$id_article = $row['id_article'];
include_spip('action/editer_signature');
signature_modifier($id_signature, array('statut' => 'publie'));
signature_modifier($id_signature, ['statut' => 'publie']);
if ($email_unique) {
$r = "id_petition=" . intval($id_petition) . " AND ad_email=" . sql_quote($adresse_email);
$r = 'id_petition=' . intval($id_petition) . ' AND ad_email=' . sql_quote($adresse_email);
if (signature_entrop($r)) {
$confirm = _T('petitions:form_pet_deja_signe');
}
}
if ($site_unique) {
$r = "id_petition=" . intval($id_petition) . " AND url_site=" . sql_quote($url_site);
$r = 'id_petition=' . intval($id_petition) . ' AND url_site=' . sql_quote($url_site);
if (signature_entrop($r)) {
$confirm = _T('petitions:form_pet_site_deja_enregistre');
}

80
action/editer_petition.php

@ -16,7 +16,7 @@
* @package SPIP\Petitions\Actions
**/
if (!defined("_ECRIRE_INC_VERSION")) {
if (!defined('_ECRIRE_INC_VERSION')) {
return;
}
@ -43,7 +43,7 @@ function action_editer_petition_dist($arg = null) {
$err = petition_modifier($id_petition);
}
return array($id_petition, $err);
return [$id_petition, $err];
}
/**
@ -62,22 +62,26 @@ function petition_modifier($id_petition, $set = null) {
// white list
objet_info('petition', 'champs_editables'),
// black list
array('statut', 'id_article'),
['statut', 'id_article'],
// donnees eventuellement fournies
$set
);
if ($err = objet_modifier_champs('petition', $id_petition,
array(
if (
$err = objet_modifier_champs(
'petition',
$id_petition,
[
'data' => $set,
),
$c)
],
$c
)
) {
return $err;
}
// changement d'article ou de statut ?
$c = collecter_requests(array('statut', 'id_article'), array(), $set);
$c = collecter_requests(['statut', 'id_article'], [], $set);
$err .= petition_instituer($id_petition, $c);
return $err;
@ -99,34 +103,36 @@ function petition_inserer($id_article, $set = null) {
return 0;
}
$champs = array(
$champs = [
'id_article' => $id_article,
);
];
if ($set) {
$champs = array_merge($champs, $set);
}
// Envoyer aux plugins
$champs = pipeline('pre_insertion',
array(
'args' => array(
$champs = pipeline(
'pre_insertion',
[
'args' => [
'table' => 'spip_petitions',
),
],
'data' => $champs
)
]
);
$id_petition = sql_insertq("spip_petitions", $champs);
$id_petition = sql_insertq('spip_petitions', $champs);
pipeline('post_insertion',
array(
'args' => array(
pipeline(
'post_insertion',
[
'args' => [
'table' => 'spip_petitions',
'id_objet' => $id_petition
),
],
'data' => $champs
)
]
);
return $id_petition;
@ -147,10 +153,10 @@ function petition_instituer($id_petition, $c) {
include_spip('inc/autoriser');
include_spip('inc/modifier');
$row = sql_fetsel("id_article,statut", "spip_petitions", "id_petition=" . intval($id_petition));
$row = sql_fetsel('id_article,statut', 'spip_petitions', 'id_petition=' . intval($id_petition));
$statut_ancien = $statut = $row['statut'];
#$date_ancienne = $date = $row['date_time'];
$champs = array();
$champs = [];
$s = $c['statut'] ?? $statut;
@ -172,16 +178,17 @@ function petition_instituer($id_petition, $c) {
}
// Envoyer aux plugins
$champs = pipeline('pre_edition',
array(
'args' => array(
$champs = pipeline(
'pre_edition',
[
'args' => [
'table' => 'spip_petitions',
'id_objet' => $id_petition,
'action' => 'instituer',
'statut_ancien' => $statut_ancien,
),
],
'data' => $champs
)
]
);
if (!(is_countable($champs) ? count($champs) : 0)) {
@ -197,22 +204,25 @@ function petition_instituer($id_petition, $c) {
suivre_invalideur("id='article/" . $row['id_article'] . "'");
// Pipeline
pipeline('post_edition',
array(
'args' => array(
pipeline(
'post_edition',
[
'args' => [
'table' => 'spip_petitions',
'id_objet' => $id_petition,
'action' => 'instituer',
'statut_ancien' => $statut_ancien,
),
],
'data' => $champs
)
]
);
// Notifications
if ($notifications = charger_fonction('notifications', 'inc')) {
$notifications('instituerpetition', $id_petition,
array('statut' => $statut, 'statut_ancien' => $statut_ancien)
$notifications(
'instituerpetition',
$id_petition,
['statut' => $statut, 'statut_ancien' => $statut_ancien]
);
}

94
action/editer_signature.php

@ -10,7 +10,7 @@
* Pour plus de détails voir le fichier COPYING.txt ou l'aide en ligne. *
\***************************************************************************/
if (!defined("_ECRIRE_INC_VERSION")) {
if (!defined('_ECRIRE_INC_VERSION')) {
return;
}
@ -27,7 +27,7 @@ function action_editer_signature_dist($arg = null) {
if (!$id_signature = intval($arg)) {
$id_petition = _request('id_petition');
if (!($id_petition)) {
return array(0, '');
return [0, ''];
}
$id_signature = signature_inserer($id_petition);
}
@ -37,7 +37,7 @@ function action_editer_signature_dist($arg = null) {
$err = signature_modifier($id_signature);
}
return array($id_signature, $err);
return [$id_signature, $err];
}
/**
@ -56,23 +56,27 @@ function signature_modifier($id_signature, $set = null) {
// white list
objet_info('signature', 'champs_editables'),
// black list
array('statut', 'id_petition', 'date_time'),
['statut', 'id_petition', 'date_time'],
// donnees eventuellement fournies
$set
);
if ($err = objet_modifier_champs('signature', $id_signature,
array(
if (
$err = objet_modifier_champs(
'signature',
$id_signature,
[
'data' => $set,
'nonvide' => array('nom_email' => _T('info_sans_titre'))
),
$c)
'nonvide' => ['nom_email' => _T('info_sans_titre')]
],
$c
)
) {
return $err;
}
// Modification de statut
$c = collecter_requests(array('statut', 'id_petition', 'date_time'), array(), $set);
$c = collecter_requests(['statut', 'id_petition', 'date_time'], [], $set);
$err .= signature_instituer($id_signature, $c);
return $err;
@ -92,36 +96,38 @@ function signature_inserer($id_petition, $set = null) {
return 0;
}
$champs = array(
$champs = [
'id_petition' => $id_petition,
'statut' => 'prepa',
'date_time' => date('Y-m-d H:i:s')
);
];
if ($set) {
$champs = array_merge($champs, $set);
}
// Envoyer aux plugins
$champs = pipeline('pre_insertion',
array(
'args' => array(
$champs = pipeline(
'pre_insertion',
[
'args' => [
'table' => 'spip_signatures',
),
],
'data' => $champs
)
]
);
$id_signature = sql_insertq("spip_signatures", $champs);
$id_signature = sql_insertq('spip_signatures', $champs);
pipeline('post_insertion',
array(
'args' => array(
pipeline(
'post_insertion',
[
'args' => [
'table' => 'spip_signatures',
'id_objet' => $id_signature
),
],
'data' => $champs
)
]
);
return $id_signature;
@ -136,12 +142,14 @@ function signature_instituer($id_signature, $c, $calcul_rub = true) {
include_spip('inc/autoriser');
include_spip('inc/modifier');
$row = sql_fetsel("S.statut, S.date_time, P.id_article",
"spip_signatures AS S JOIN spip_petitions AS P ON S.id_petition=P.id_petition",
"S.id_signature=" . intval($id_signature));
$row = sql_fetsel(
'S.statut, S.date_time, P.id_article',
'spip_signatures AS S JOIN spip_petitions AS P ON S.id_petition=P.id_petition',
'S.id_signature=' . intval($id_signature)
);
$statut_ancien = $statut = $row['statut'];
$date_ancienne = $date = $row['date_time'];
$champs = array();
$champs = [];
$d = $c['date_time'] ?? null;
$s = $c['statut'] ?? $statut;
@ -167,16 +175,17 @@ function signature_instituer($id_signature, $c, $calcul_rub = true) {
}
// Envoyer aux plugins
$champs = pipeline('pre_edition',
array(
'args' => array(
$champs = pipeline(
'pre_edition',
[
'args' => [
'table' => 'spip_signatures',
'id_objet' => $id_signature,
'action' => 'instituer',
'statut_ancien' => $statut_ancien,
),
],
'data' => $champs
)
]
);
if (!(is_countable($champs) ? count($champs) : 0)) {
@ -192,22 +201,25 @@ function signature_instituer($id_signature, $c, $calcul_rub = true) {
suivre_invalideur("id='article/" . $row['id_article'] . "'");
// Pipeline
pipeline('post_edition',
array(
'args' => array(
pipeline(
'post_edition',
[
'args' => [
'table' => 'spip_signatures',
'id_objet' => $id_signature,
'action' => 'instituer',
'statut_ancien' => $statut_ancien,
),
],
'data' => $champs
)
]
);
// Notifications
if ($notifications = charger_fonction('notifications', 'inc')) {
$notifications('instituersignature', $id_signature,
array('statut' => $statut, 'statut_ancien' => $statut_ancien, 'date' => $date)
$notifications(
'instituersignature',
$id_signature,
['statut' => $statut, 'statut_ancien' => $statut_ancien, 'date' => $date]
);
}
@ -229,9 +241,9 @@ function signature_instituer($id_signature, $c, $calcul_rub = true) {
* @return array
*/
function signature_entrop($where) {
$entrop = array();
$entrop = [];
$where .= " AND statut='publie'";
$res = sql_select('id_signature', 'spip_signatures', $where, '', "date_time desc");
$res = sql_select('id_signature', 'spip_signatures', $where, '', 'date_time desc');
$n = sql_count($res);
if ($n > 1) {
while ($r = sql_fetch($res)) {

22
action/relancer_signature.php

@ -10,7 +10,7 @@
* Pour plus de détails voir le fichier COPYING.txt ou l'aide en ligne. *
\***************************************************************************/
if (!defined("_ECRIRE_INC_VERSION")) {
if (!defined('_ECRIRE_INC_VERSION')) {
return;
}
@ -23,15 +23,27 @@ function action_relancer_signature_dist($id_signature = null) {
if (autoriser('relancer', 'signature', $id_signature)) {
$row = sql_fetsel('*', 'spip_signatures', 'id_signature=' . intval($id_signature));
$id_article = sql_getfetsel('id_article', 'spip_petitions', 'id_petition=' . intval($row['id_petition']));
if ($id_article = intval($id_article)
if (
$id_article = intval($id_article)
and autoriser('mordererpetition', 'article', $id_article)
) {
include_spip('action/editer_signature');
include_spip('formulaires/signature');
$url = generer_url_entite_absolue($id_article, 'article', '', '', true);
if (signature_a_confirmer($id_article, $url, $row['nom_email'], $row['ad_email'], $row['nom_site'],
$row['url_site'], $row['message'], $row['lang'], $row['statut'])) {
signature_modifier($id_signature, array("date_time" => date('Y-m-d H:i:s')));
if (
signature_a_confirmer(
$id_article,
$url,
$row['nom_email'],
$row['ad_email'],
$row['nom_site'],
$row['url_site'],
$row['message'],
$row['lang'],
$row['statut']
)
) {
signature_modifier($id_signature, ['date_time' => date('Y-m-d H:i:s')]);
}
}
}

10
action/supprimer_signature.php

@ -10,7 +10,7 @@
* Pour plus de détails voir le fichier COPYING.txt ou l'aide en ligne. *
\***************************************************************************/
if (!defined("_ECRIRE_INC_VERSION")) {
if (!defined('_ECRIRE_INC_VERSION')) {
return;
}
@ -21,12 +21,14 @@ function action_supprimer_signature_dist($id_signature = null) {
}
if (autoriser('supprimer', 'signature', $id_signature)) {
$id_article = sql_getfetsel('P.id_article',
$id_article = sql_getfetsel(
'P.id_article',
'spip_signatures AS S JOIN spip_petitions AS P ON S.id_petition=P.id_petition',
'S.id_signature=' . intval($id_signature));
'S.id_signature=' . intval($id_signature)
);
if ($id_article and autoriser('modererpetition', 'article', $id_article)) {
include_spip('action/editer_signature');
signature_modifier($id_signature, array('statut' => 'poubelle'));
signature_modifier($id_signature, ['statut' => 'poubelle']);
}
}
}

15
action/traiter_lot_signature.php

@ -10,7 +10,7 @@
* Pour plus de détails voir le fichier COPYING.txt ou l'aide en ligne. *
\***************************************************************************/
if (!defined("_ECRIRE_INC_VERSION")) {
if (!defined('_ECRIRE_INC_VERSION')) {
return;
}
@ -25,15 +25,16 @@ function action_traiter_lot_signature_dist($arg = null) {
* $arg contient l'action relancer/supprimer/valider
* les id sont dans un tableau non signe ids[]
*/
if (preg_match(",^(\w+)$,", $arg, $match)
and in_array($statut = $match[1], array('relancer', 'supprimer', 'valider'))
if (
preg_match(',^(\w+)$,', $arg, $match)
and in_array($statut = $match[1], ['relancer', 'supprimer', 'valider'])
and autoriser('modererlot', 'petition')
) {
$where = '';
if (intval($id_petition = _request('id_petition'))) {
$where = "id_petition=" . intval($id_petition);
$where = 'id_petition=' . intval($id_petition);
// pour relancer ou valider on ne prend que celles en attente
if (in_array($statut, array('relancer', 'valider'))) {
if (in_array($statut, ['relancer', 'valider'])) {
$where .= " AND statut!='publie' AND statut!='poubelle'";
}
} else {
@ -45,12 +46,12 @@ function action_traiter_lot_signature_dist($arg = null) {
}
if ($where) {
$rows = sql_allfetsel("id_signature", "spip_signatures", $where);
$rows = sql_allfetsel('id_signature', 'spip_signatures', $where);
if (!(is_countable($rows) ? count($rows) : 0)) {
return;
}
$rows = array_column($rows, 'id_signature');
if ($action = charger_fonction($statut . "_signature", 'action', true)) {
if ($action = charger_fonction($statut . '_signature', 'action', true)) {
foreach ($rows as $id_signature) {
$action($id_signature);
}

4
action/valider_signature.php

@ -10,7 +10,7 @@
* Pour plus de détails voir le fichier COPYING.txt ou l'aide en ligne. *
\***************************************************************************/
if (!defined("_ECRIRE_INC_VERSION")) {
if (!defined('_ECRIRE_INC_VERSION')) {
return;
}
@ -22,6 +22,6 @@ function action_valider_signature_dist($id_signature = null) {
if (autoriser('publier', 'signature', $id_signature)) {
include_spip('action/editer_signature');
signature_modifier($id_signature, array('statut' => 'publie'));
signature_modifier($id_signature, ['statut' => 'publie']);
}
}

14
balise/formulaire_signature.php

@ -10,7 +10,7 @@
* Pour plus de détails voir le fichier COPYING.txt ou l'aide en ligne. *
\***************************************************************************/
if (!defined("_ECRIRE_INC_VERSION")) {
if (!defined('_ECRIRE_INC_VERSION')) {
return;
} #securite
@ -23,12 +23,12 @@ include_spip('base/abstract_sql');
// Contexte necessaire lors de la compilation
// Il *faut* demander petition, meme si on ne s'en sert pas dans l'affichage,
// car on doit obtenir la jointure avec la table des petitions pour verifier
// car on doit obtenir la jointure avec la table des petitions pour verifier
// si une petition est attachee a l'article.
// https://code.spip.net/@balise_FORMULAIRE_SIGNATURE
function balise_FORMULAIRE_SIGNATURE($p) {
return calculer_balise_dynamique($p, 'FORMULAIRE_SIGNATURE', array('id_article', 'petition'));
return calculer_balise_dynamique($p, 'FORMULAIRE_SIGNATURE', ['id_article', 'petition']);
}
// Verification des arguments (contexte + filtres)
@ -37,13 +37,13 @@ function balise_FORMULAIRE_SIGNATURE_stat($args, $context_compil) {
// pas d'id_article => erreur de contexte
if (!$args[0]) {
$msg = array(
$msg = [
'zbug_champ_hors_motif',
array(
[
'champ' => 'FORMULAIRE_SIGNATURE',
'motif' => 'ARTICLES'
)
);
]
];
erreur_squelette($msg, $context_compil);
return '';

122
base/petitions.php

@ -41,14 +41,14 @@ function petitions_declarer_tables_interfaces($interfaces) {
$interfaces['tables_jointures']['spip_articles'][] = 'petitions';
$interfaces['tables_jointures']['spip_articles'][] = 'signatures';
$interfaces['exceptions_des_jointures']['petition'] = array('spip_petitions', 'texte');
$interfaces['exceptions_des_jointures']['id_signature'] = array('spip_signatures', 'id_signature');
$interfaces['exceptions_des_jointures']['petition'] = ['spip_petitions', 'texte'];
$interfaces['exceptions_des_jointures']['id_signature'] = ['spip_signatures', 'id_signature'];
$interfaces['table_des_traitements']['MESSAGE'][] = _TRAITEMENT_RACCOURCIS;
// Signatures : passage des donnees telles quelles, sans traitement typo
// la securite et conformite XHTML de ces champs est assuree par safehtml()
foreach (array('NOM_EMAIL', 'AD_EMAIL', 'NOM_SITE', 'URL_SITE', 'MESSAGE') as $balise) {
foreach (['NOM_EMAIL', 'AD_EMAIL', 'NOM_SITE', 'URL_SITE', 'MESSAGE'] as $balise) {
if (!isset($interfaces['table_des_traitements'][$balise]['signatures'])) {
$interfaces['table_des_traitements'][$balise]['signatures'] = 'liens_nofollow(safehtml(%s))';
} else {
@ -71,7 +71,7 @@ function petitions_declarer_tables_interfaces($interfaces) {
* Description complétée des tables
*/
function petitions_declarer_tables_objets_sql($tables) {
$tables['spip_petitions'] = array(
$tables['spip_petitions'] = [
'url_voir' => 'controler_petition',
'url_edit' => 'controler_petition',
'editable' => 'non',
@ -84,41 +84,41 @@ function petitions_declarer_tables_objets_sql($tables) {
'titre' => "texte as titre, '' AS lang",
'field' => array(
"id_petition" => "bigint(21) NOT NULL",
"id_article" => "bigint(21) DEFAULT '0' NOT NULL",
"email_unique" => "CHAR (3) DEFAULT '' NOT NULL",
"site_obli" => "CHAR (3) DEFAULT '' NOT NULL",
"site_unique" => "CHAR (3) DEFAULT '' NOT NULL",
"message" => "CHAR (3) DEFAULT '' NOT NULL",
"texte" => "LONGTEXT DEFAULT '' NOT NULL",
"statut" => "VARCHAR (10) DEFAULT 'publie' NOT NULL",
"maj" => "TIMESTAMP"
),
'key' => array(
"PRIMARY KEY" => "id_petition",
"UNIQUE KEY id_article" => "id_article"
),
'statut' => array(
array('champ' => 'statut', 'publie' => 'publie,off', 'previsu' => 'publie,off', 'exception' => array('statut')),
),
'champs_editables' => array(
'field' => [
'id_petition' => 'bigint(21) NOT NULL',
'id_article' => "bigint(21) DEFAULT '0' NOT NULL",
'email_unique' => "CHAR (3) DEFAULT '' NOT NULL",
'site_obli' => "CHAR (3) DEFAULT '' NOT NULL",
'site_unique' => "CHAR (3) DEFAULT '' NOT NULL",
'message' => "CHAR (3) DEFAULT '' NOT NULL",
'texte' => "LONGTEXT DEFAULT '' NOT NULL",
'statut' => "VARCHAR (10) DEFAULT 'publie' NOT NULL",
'maj' => 'TIMESTAMP'
],
'key' => [
'PRIMARY KEY' => 'id_petition',
'UNIQUE KEY id_article' => 'id_article'
],
'statut' => [
['champ' => 'statut', 'publie' => 'publie,off', 'previsu' => 'publie,off', 'exception' => ['statut']],
],
'champs_editables' => [
'email_unique',
'site_obli',
'site_unique',
'message',
'texte',
),
'champs_versionnes' => array(
],
'champs_versionnes' => [
'email_unique',
'site_obli',
'site_unique',
'message',
'texte',
),
);
],
];
$tables['spip_signatures'] = array(
$tables['spip_signatures'] = [
'url_voir' => 'controler_petition',
'url_edit' => 'controler_petition',
'editable' => 'non',
@ -134,58 +134,58 @@ function petitions_declarer_tables_objets_sql($tables) {
'titre' => "nom_email as titre, '' AS lang",
'date' => 'date_time',
'field' => array(
"id_signature" => "bigint(21) NOT NULL",
"id_petition" => "bigint(21) DEFAULT '0' NOT NULL",
'field' => [
'id_signature' => 'bigint(21) NOT NULL',
'id_petition' => "bigint(21) DEFAULT '0' NOT NULL",
# "id_article" => "bigint(21) DEFAULT '0' NOT NULL",
"date_time" => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
"nom_email" => "text DEFAULT '' NOT NULL",
"ad_email" => "text DEFAULT '' NOT NULL",
"nom_site" => "text DEFAULT '' NOT NULL",
"url_site" => "text DEFAULT '' NOT NULL",
"message" => "mediumtext DEFAULT '' NOT NULL",
"statut" => "varchar(10) DEFAULT '0' NOT NULL",
"maj" => "TIMESTAMP"
),
'key' => array(
"PRIMARY KEY" => "id_signature",
"KEY id_petition" => "id_petition",
'date_time' => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
'nom_email' => "text DEFAULT '' NOT NULL",
'ad_email' => "text DEFAULT '' NOT NULL",
'nom_site' => "text DEFAULT '' NOT NULL",
'url_site' => "text DEFAULT '' NOT NULL",
'message' => "mediumtext DEFAULT '' NOT NULL",
'statut' => "varchar(10) DEFAULT '0' NOT NULL",
'maj' => 'TIMESTAMP'
],
'key' => [
'PRIMARY KEY' => 'id_signature',
'KEY id_petition' => 'id_petition',
# "KEY id_article" => "id_article",
"KEY statut" => "statut"
),
'join' => array(
"id_signature" => "id_signature",
"id_petition" => "id_petition"
),
'tables_jointures' => array(
'KEY statut' => 'statut'
],
'join' => [
'id_signature' => 'id_signature',
'id_petition' => 'id_petition'
],
'tables_jointures' => [
'petitions'
),
'statut' => array(
array('champ' => 'statut', 'publie' => 'publie', 'previsu' => 'publie', 'exception' => array('statut', 'tout')),
),
'rechercher_champs' => array(
],
'statut' => [
['champ' => 'statut', 'publie' => 'publie', 'previsu' => 'publie', 'exception' => ['statut', 'tout']],
],
'rechercher_champs' => [
'nom_email' => 2,
'ad_email' => 4,
'nom_site' => 2,
'url_site' => 4,
'message' => 1
),
'champs_editables' => array(
],
'champs_editables' => [
'nom_email',
'ad_email',
'nom_site',
'url_site',
'message',
),
'champs_versionnes' => array(
],
'champs_versionnes' => [
'nom_email',
'ad_email',
'nom_site',
'url_site',
'message',
),
],
'icone_objet' => 'petition',
);
];
return $tables;
}

27
formulaires/activer_petition_article.php

@ -10,7 +10,7 @@
* Pour plus de détails voir le fichier COPYING.txt ou l'aide en ligne. *
\***************************************************************************/
if (!defined("_ECRIRE_INC_VERSION")) {
if (!defined('_ECRIRE_INC_VERSION')) {
return;
}
@ -22,7 +22,7 @@ if (!defined("_ECRIRE_INC_VERSION")) {
*/
function formulaires_activer_petition_article_charger_dist($id_article) {
$valeurs = array();
$valeurs = [];
$valeurs['editable'] = true;
@ -33,18 +33,20 @@ function formulaires_activer_petition_article_charger_dist($id_article) {
include_spip('inc/presentation');
include_spip('base/abstract_sql');
$nb_signatures = 0;
$petition = sql_fetsel("*", "spip_petitions", "id_article=$id_article");
$petition = sql_fetsel('*', 'spip_petitions', "id_article=$id_article");
if ($petition) {
$nb_signatures = sql_countsel("spip_signatures", "id_petition=" . intval($petition['id_petition']));
$nb_signatures = sql_countsel('spip_signatures', 'id_petition=' . intval($petition['id_petition']));
}
$valeurs['id_article'] = $id_article;
$valeurs['petition'] = $petition;
$valeurs['_controle_petition'] = $nb_signatures ? singulier_ou_pluriel($nb_signatures, 'petitions:une_signature',
'petitions:nombre_signatures') : "";
$valeurs['_controle_petition'] = $nb_signatures ? singulier_ou_pluriel(
$nb_signatures,
'petitions:une_signature',
'petitions:nombre_signatures'
) : '';
return $valeurs;
}
/**
@ -60,7 +62,7 @@ function formulaires_activer_petition_article_traiter_dist($id_article) {
if (autoriser('modererpetition', 'article', $id_article)) {
switch (_request('change_petition')) {
case 'on':
foreach (array('email_unique', 'site_obli', 'site_unique', 'message') as $k) {
foreach (['email_unique', 'site_obli', 'site_unique', 'message'] as $k) {
if (_request($k) != 'oui') {
set_request($k, 'non');
}
@ -73,25 +75,24 @@ function formulaires_activer_petition_article_traiter_dist($id_article) {
petition_modifier(
$id_petition,
array(
[
'email_unique' => _request('email_unique'),
'site_obli' => _request('site_obli'),
'site_unique' => _request('site_unique'),
'message' => _request('message'),
'texte' => _request('texte_petition'),
'statut' => 'publie',
)
]
);
break;
case 'off':
if ($id_petition = sql_getfetsel('id_petition', 'spip_petitions', 'id_article=' . intval($id_article))) {
include_spip('action/editer_petition');
petition_modifier($id_petition, array('statut' => 'poubelle'));
petition_modifier($id_petition, ['statut' => 'poubelle']);
}
break;
}
}
return array('message_ok' => _T('config_info_enregistree'));
return ['message_ok' => _T('config_info_enregistree')];
}

96
formulaires/signature.php

@ -10,7 +10,7 @@
* Pour plus de détails voir le fichier COPYING.txt ou l'aide en ligne. *
\***************************************************************************/
if (!defined("_ECRIRE_INC_VERSION")) {
if (!defined('_ECRIRE_INC_VERSION')) {
return;
}
@ -22,12 +22,12 @@ function formulaires_signature_charger_dist($id_article) {
return false;
}
// pas de signature sur une petition fermee (TODO) ou poubelle
if (isset($r['statut']) and in_array($r['statut'], array('off', 'poubelle'))) {
if (isset($r['statut']) and in_array($r['statut'], ['off', 'poubelle'])) {
return false;
}
$id_petition = $r['id_petition'];
$valeurs = array(
$valeurs = [
'id_petition' => $id_petition,
'id_article' => $id_article, # pour compat
'session_nom' => $GLOBALS['visiteur_session']['session_nom'] ?? $GLOBALS['visiteur_session']['nom'] ?? '',
@ -39,7 +39,7 @@ function formulaires_signature_charger_dist($id_article) {
'message' => '',
'site_obli' => ($r['site_obli'] == 'oui' ? ' ' : ''),
'debut_signatures' => '' // pour le nettoyer de l'url d'action !
);
];
if ($c = _request('var_confirm')) {
$valeurs['_confirm'] = $c;
@ -60,8 +60,8 @@ function affiche_reponse_confirmation($confirm) {
function formulaires_signature_verifier_dist($id_article) {
$url_site = null;
$erreurs = array();
$oblis = array('session_nom', 'session_email');
$erreurs = [];
$oblis = ['session_nom', 'session_email'];
include_spip('base/abstract_sql');
$row = sql_fetsel('*', 'spip_petitions', 'id_article=' . intval($id_article));
if (!$row) {
@ -89,11 +89,13 @@ function formulaires_signature_verifier_dist($id_article) {
$erreurs['session_email'] = _T('form_indiquer_email');
} elseif ($mail and !email_valide($mail)) {
$erreurs['session_email'] = _T('form_email_non_valide');
} elseif (strlen(_request('nobot'))
or (@preg_match_all(',\bhref=[\'"]?http,i', // bug PHP
_request('message')
} elseif (
strlen(_request('nobot'))
or (@preg_match_all(
',\bhref=[\'"]?http,i', // bug PHP
_request('message')
# , PREG_PATTERN_ORDER
)
)
> 2)
) {
#$envoyer_mail = charger_fonction('envoyer_mail','inc');
@ -113,8 +115,8 @@ function formulaires_signature_verifier_dist($id_article) {
if (!count($erreurs)) {
// tout le monde est la.
$email_unique = $row['email_unique'] == "oui";
$site_unique = $row['site_unique'] == "oui";
$email_unique = $row['email_unique'] == 'oui';
$site_unique = $row['site_unique'] == 'oui';
// Refuser si deja signe par le mail ou le site quand demande
// Il y a un acces concurrent potentiel,
@ -122,16 +124,20 @@ function formulaires_signature_verifier_dist($id_article) {
// On traite donc le probleme a la confirmation.
if ($email_unique) {
$r = sql_countsel('spip_signatures',
"id_petition=" . intval($id_petition) . " AND ad_email=" . sql_quote($mail) . " AND statut='publie'");
$r = sql_countsel(
'spip_signatures',
'id_petition=' . intval($id_petition) . ' AND ad_email=' . sql_quote($mail) . " AND statut='publie'"
);
if ($r) {
$erreurs['message_erreur'] = _T('petitions:form_pet_deja_signe');
}
}
if ($site_unique) {
$r = sql_countsel('spip_signatures',
"id_petition=" . intval($id_petition) . " AND url_site=" . sql_quote($url_site) . " AND (statut='publie' OR statut='poubelle')");
$r = sql_countsel(
'spip_signatures',
'id_petition=' . intval($id_petition) . ' AND url_site=' . sql_quote($url_site) . " AND (statut='publie' OR statut='poubelle')"
);
if ($r) {
$erreurs['message_erreur'] = _T('petitions:form_pet_site_deja_enregistre');
}
@ -146,32 +152,47 @@ function formulaires_signature_traiter_dist($id_article) {
include_spip('base/abstract_sql');
if (spip_connect()) {
$controler_signature = charger_fonction('controler_signature', 'inc');
$reponse = $controler_signature($id_article,
_request('session_nom'), _request('session_email'),
_request('message'), _request('signature_nom_site'),
_request('signature_url_site'), _request('url_page'));
$reponse = $controler_signature(
$id_article,
_request('session_nom'),
_request('session_email'),
_request('message'),
_request('signature_nom_site'),
_request('signature_url_site'),
_request('url_page')
);
}
return array('message_ok' => $reponse);
return ['message_ok' => $reponse];
}
//
// Recevabilite de la signature d'une petition
// les controles devraient mantenant etre faits dans formulaires_signature_verifier()
//
//
// https://code.spip.net/@inc_controler_signature_dist
function inc_controler_signature_dist($id_article, $nom, $mail, $message, $site, $url_site, $url_page) {
// tout le monde est la.
// cela a ete verifie en amont, dans formulaires_signature_verifier()
if (!$row = sql_fetsel('*', 'spip_petitions', "id_article=" . intval($id_article))) {
if (!$row = sql_fetsel('*', 'spip_petitions', 'id_article=' . intval($id_article))) {
return _T('petitions:form_pet_probleme_technique');
}
$statut = "";
if (!$ret = signature_a_confirmer($id_article, $url_page, $nom, $mail, $site, $url_site, $message, 'fr'/*inutilise*/,
$statut)
$statut = '';
if (
!$ret = signature_a_confirmer(
$id_article,
$url_page,
$nom,
$mail,
$site,
$url_site,
$message,
'fr'/*inutilise*/,
$statut
)
) {
return _T('petitions:form_pet_probleme_technique');
}
@ -183,15 +204,16 @@ function inc_controler_signature_dist($id_article, $nom, $mail, $message, $site,
return _T('petitions:form_pet_probleme_technique');
}
signature_modifier($id_signature,
array(
signature_modifier(
$id_signature,
[
'statut' => $statut,
'nom_email' => $nom,
'ad_email' => $mail,
'message' => $message,
'nom_site' => $site,
'url_site' => $url_site
)
]
);
return $ret;
@ -238,7 +260,7 @@ function signature_a_confirmer($id_article, $url_page, $nom, $mail, $site, $url,
//
// Cas normal : envoi d'une demande de confirmation
//
$row = sql_fetsel('titre,lang', 'spip_articles', "id_article=" . intval($id_article));
$row = sql_fetsel('titre,lang', 'spip_articles', 'id_article=' . intval($id_article));
$lang = lang_select($row['lang']);
$titre = textebrut(typo($row['titre']));
if ($lang) {
@ -250,26 +272,28 @@ function signature_a_confirmer($id_article, $url_page, $nom, $mail, $site, $url,
}
if ($lang != $GLOBALS['meta']['langue_site']) {
$url_page = parametre_url($url_page, "lang", $lang, '&');
$url_page = parametre_url($url_page, 'lang', $lang, '&');
}
$url_page = parametre_url($url_page, 'var_confirm', $statut, '&')
. "#sp$id_article";
$r = _T('petitions:form_pet_mail_confirmation',
array(
$r = _T(
'petitions:form_pet_mail_confirmation',
[
'titre' => $titre,
'nom_email' => $nom,
'nom_site' => $site,
'url_site' => $url,
'url' => $url_page,
'message' => $msg
));
]
);
$titre = _T('petitions:form_pet_confirmation') . " " . $titre;
$titre = _T('petitions:form_pet_confirmation') . ' ' . $titre;
$envoyer_mail = charger_fonction('envoyer_mail', 'inc');
if ($envoyer_mail($mail, $titre, $r)) {
return _T('petitions:form_pet_envoi_mail_confirmation', array('email' => $mail));
return _T('petitions:form_pet_envoi_mail_confirmation', ['email' => $mail]);
}
return false; # erreur d'envoi de l'email

75
petitions_administrations.php

@ -27,7 +27,8 @@ function petitions_upgrade($nom_meta_base_version, $version_cible) {
// pour gerer l'historique des installations SPIP <=2.1
if (!isset($GLOBALS['meta'][$nom_meta_base_version])) {
$trouver_table = charger_fonction('trouver_table', 'base');
if ($desc = $trouver_table('spip_signatures')
if (
$desc = $trouver_table('spip_signatures')
and isset($desc['field']['id_article'])
) {
ecrire_meta($nom_meta_base_version, '1.0.0');
@ -35,39 +36,39 @@ function petitions_upgrade($nom_meta_base_version, $version_cible) {
// si pas de table en base, on fera une simple creation de base
}
$maj = array();
$maj['create'] = array(
array('maj_tables', array('spip_petitions', 'spip_signatures')),
);
$maj = [];
$maj['create'] = [
['maj_tables', ['spip_petitions', 'spip_signatures']],
];
$maj['1.1.0'] = array(
array('sql_alter', "TABLE spip_petitions DROP PRIMARY KEY"),
);
$maj['1.1.1'] = array(
array('sql_alter', "TABLE spip_petitions ADD UNIQUE id_article (id_article)"),
);
$maj['1.1.2'] = array(
array('sql_alter', "TABLE spip_petitions ADD id_petition BIGINT(21) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST"),
array('sql_alter', "TABLE spip_petitions ADD PRIMARY KEY (id_petition)"),
);
$maj['1.1.3'] = array(
array('sql_alter', "TABLE spip_petitions ADD statut VARCHAR (10) DEFAULT 'publie' NOT NULL"),
);
$maj['1.1.4'] = array(
array('sql_alter', "TABLE spip_signatures ADD id_petition bigint(21) DEFAULT '0' NOT NULL"),
array('sql_alter', "TABLE spip_signatures ADD INDEX id_petition (id_petition)"),
array('sql_updateq', 'spip_signatures', array('id_petition' => -1)),
);
$maj['1.1.5'] = array(
array('upgrade_index_signatures'),
);
$maj['1.1.6'] = array(
array('sql_alter', "TABLE spip_signatures DROP INDEX id_article"),
array('sql_alter', "TABLE spip_signatures DROP id_article"),
);
$maj['1.1.7'] = array(
array('petitions_maj_117'),
);
$maj['1.1.0'] = [
['sql_alter', 'TABLE spip_petitions DROP PRIMARY KEY'],
];
$maj['1.1.1'] = [
['sql_alter', 'TABLE spip_petitions ADD UNIQUE id_article (id_article)'],
];
$maj['1.1.2'] = [
['sql_alter', 'TABLE spip_petitions ADD id_petition BIGINT(21) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST'],
['sql_alter', 'TABLE spip_petitions ADD PRIMARY KEY (id_petition)'],
];
$maj['1.1.3'] = [
['sql_alter', "TABLE spip_petitions ADD statut VARCHAR (10) DEFAULT 'publie' NOT NULL"],
];
$maj['1.1.4'] = [
['sql_alter', "TABLE spip_signatures ADD id_petition bigint(21) DEFAULT '0' NOT NULL"],
['sql_alter', 'TABLE spip_signatures ADD INDEX id_petition (id_petition)'],
['sql_updateq', 'spip_signatures', ['id_petition' => -1]],
];
$maj['1.1.5'] = [
['upgrade_index_signatures'],
];
$maj['1.1.6'] = [
['sql_alter', 'TABLE spip_signatures DROP INDEX id_article'],
['sql_alter', 'TABLE spip_signatures DROP id_article'],
];
$maj['1.1.7'] = [
['petitions_maj_117'],
];
include_spip('base/upgrade');
maj_plugin($nom_meta_base_version, $version_cible, $maj);
@ -81,9 +82,9 @@ function upgrade_index_signatures() {
if (!$id_petition) {
include_spip('action/editer_petition');
$id_petition = petition_inserer($id_article);
sql_updateq('spip_petitions', array('statut' => 'poubelle'), 'id_petition=' . $id_petition);
sql_updateq('spip_petitions', ['statut' => 'poubelle'], 'id_petition=' . $id_petition);
}
sql_updateq('spip_signatures', array('id_petition' => $id_petition), 'id_article=' . $id_article);
sql_updateq('spip_signatures', ['id_petition' => $id_petition], 'id_article=' . $id_article);
}
}
}
@ -94,8 +95,8 @@ function upgrade_index_signatures() {
* @param string $nom_meta_base_version
*/
function petitions_vider_tables($nom_meta_base_version) {
sql_drop_table("spip_petitions");
sql_drop_table("spip_signatures");
sql_drop_table('spip_petitions');
sql_drop_table('spip_signatures');
effacer_meta($nom_meta_base_version);
}

19
petitions_autoriser.php

@ -24,7 +24,8 @@ if (!defined('_ECRIRE_INC_VERSION')) {
*
* @pipeline autoriser
*/
function petitions_autoriser() { }
function petitions_autoriser() {
}
/**
@ -63,8 +64,11 @@ function autoriser_modererpetition_dist($faire, $type, $id, $qui, $opt) {
* @return bool true s'il a le droit, false sinon
*/
function autoriser_signature_publier($faire, $type, $id, $qui, $opt) {
$id_article = sql_getfetsel('P.id_article',
'spip_signatures AS S JOIN spip_petitions AS P ON P.id_petition=S.id_petition', 'S.id_signature=' . intval($id));
$id_article = sql_getfetsel(
'P.id_article',
'spip_signatures AS S JOIN spip_petitions AS P ON P.id_petition=S.id_petition',
'S.id_signature=' . intval($id)
);
return
autoriser('modererpetition', 'article', $id_article, $qui, $opt);
@ -83,8 +87,11 @@ function autoriser_signature_publier($faire, $type, $id, $qui, $opt) {
* @return bool true s'il a le droit, false sinon
*/
function autoriser_signature_supprimer($faire, $type, $id, $qui, $opt) {
$id_article = sql_getfetsel('P.id_article',
'spip_signatures AS S JOIN spip_petitions AS P ON P.id_petition=S.id_petition', 'S.id_signature=' . intval($id));
$id_article = sql_getfetsel(
'P.id_article',
'spip_signatures AS S JOIN spip_petitions AS P ON P.id_petition=S.id_petition',
'S.id_signature=' . intval($id)
);
return
autoriser('modererpetition', 'article', $id_article, $qui, $opt);
@ -105,7 +112,7 @@ function autoriser_signature_supprimer($faire, $type, $id, $qui, $opt) {
function autoriser_signature_relancer($faire, $type, $id, $qui, $opt) {
$statut = sql_getfetsel('statut', 'spip_signatures', 'id_signature=' . intval($id));
return ($qui['id_auteur'] && !in_array($statut, array('poubelle', 'publie')));
return ($qui['id_auteur'] && !in_array($statut, ['poubelle', 'publie']));
}
/**

36
petitions_fonctions.php

@ -37,27 +37,27 @@ function balise_PETITION_dist($p) {
($nom === '' or empty($p->boucles[$nom]))
and $p->nom_champ !== 'FORMULAIRE_SIGNATURE'
) {
$msg = array(
$msg = [
'zbug_champ_hors_boucle',
array('champ' => '#PETITION')
);
['champ' => '#PETITION']
];
erreur_squelette($msg, $p);
}
else {
if (!empty($p->boucles[$nom])) {
$p->code = "quete_petitions(" .
$p->code = 'quete_petitions(' .
champ_sql('id_article', $p)
. ",'" .$p->boucles[$nom]->type_requete . "'"
. ",'$nom',"
. ",'" . $p->boucles[$nom]->type_requete . "'"
. ",'$nom',"
. "'" . $p->boucles[$nom]->sql_serveur . "'"
. ", \$Cache)";
. ', $Cache)';
} else {
$p->code = "quete_petitions(" .
$p->code = 'quete_petitions(' .
champ_sql('id_article', $p)
. ",''"
. ",'$nom',"
. "\$connect"
. ", \$Cache)";
. ",''"
. ",'$nom',"
. '$connect'
. ', $Cache)';
}
$p->interdire_scripts = false;
@ -78,8 +78,16 @@ if (!function_exists('quete_petitions')) {
* @return array|bool|null|string
*/
function quete_petitions($id_article, $table, $id_boucle, $serveur, &$cache) {
$retour = sql_getfetsel('texte', 'spip_petitions', ("id_article=" . intval($id_article)), '', array(), '', '',
$serveur);
$retour = sql_getfetsel(
'texte',
'spip_petitions',
('id_article=' . intval($id_article)),
'',
[],
'',
'',
$serveur
);
if ($retour === null) {
return '';

2
petitions_options.php

@ -10,7 +10,7 @@
* Pour plus de détails voir le fichier COPYING.txt ou l'aide en ligne. *
\***************************************************************************/
if (!defined("_ECRIRE_INC_VERSION")) {
if (!defined('_ECRIRE_INC_VERSION')) {
return;
}

17
petitions_pipelines.php

@ -27,13 +27,14 @@ if (!defined('_ECRIRE_INC_VERSION')) {
* @return array
*/
function petitions_afficher_config_objet($flux) {
if ((($type = $flux['args']['type']) == 'article')
if (
(($type = $flux['args']['type']) == 'article')
and ($id = $flux['args']['id'])
) {
if (autoriser('modererpetition', $type, $id)) {
$table = table_objet($type);
$id_table_objet = id_table_objet($type);
$flux['data'] .= recuperer_fond("prive/configurer/petitionner", array($id_table_objet => $id));
$flux['data'] .= recuperer_fond('prive/configurer/petitionner', [$id_table_objet => $id]);
}
}
@ -55,7 +56,7 @@ function petitions_afficher_config_objet($flux) {
function petitions_affiche_milieu($flux) {
if ($flux['args']['exec'] == 'configurer_contenu') {
$flux['data'] .= recuperer_fond('prive/squelettes/inclure/configurer', array('configurer' => 'configurer_petitions'));
$flux['data'] .= recuperer_fond('prive/squelettes/inclure/configurer', ['configurer' => 'configurer_petitions']);
}
return $flux;
@ -75,16 +76,18 @@ function petitions_optimiser_base_disparus($flux) {
// Signatures poubelles
//
sql_delete("spip_petitions", "statut=" . sql_quote('poubelle') . " AND maj < " . sql_quote($mydate));
sql_delete('spip_petitions', 'statut=' . sql_quote('poubelle') . ' AND maj < ' . sql_quote($mydate));
// rejeter les signatures non confirmees trop vieilles (20jours)
if (!defined('_PETITIONS_DELAI_SIGNATURES_REJETEES')) {
define('_PETITIONS_DELAI_SIGNATURES_REJETEES', 20);
}
sql_delete("spip_signatures", "NOT (statut='publie' OR statut='poubelle') AND NOT(" . sql_date_proche('date_time',
-_PETITIONS_DELAI_SIGNATURES_REJETEES, ' DAY') . ')');
sql_delete('spip_signatures', "NOT (statut='publie' OR statut='poubelle') AND NOT(" . sql_date_proche(
'date_time',
-_PETITIONS_DELAI_SIGNATURES_REJETEES,
' DAY'
) . ')');
return $flux;
}

52
tests/unit/abstract_sql/99_sql_types_tables_id.php

@ -3,45 +3,45 @@
// nom du test
$test = 'sql/sql_types_tables_id';
$remonte = "../";
while (!is_dir($remonte."ecrire"))
$remonte = '../';
while (!is_dir($remonte . 'ecrire')) {
$remonte = "../$remonte";
require $remonte.'tests/test.inc';
}
require $remonte . 'tests/test.inc';
include_spip('base/connect_sql');
// Des tests
$essais['table_objet'] = array(
array('petitions','petition'),
array('signatures','signature'),
);
$essais['table_objet'] = [
['petitions','petition'],
['signatures','signature'],
];
$essais['table_objet_sql'] = array(
array('spip_petitions','petition'),
array('spip_signatures','signature'),
);
$essais['table_objet_sql'] = [
['spip_petitions','petition'],
['spip_signatures','signature'],
];
$essais['id_table_objet'] = array(
array('id_petition','petition'),
array('id_signature','signature'),
);
$essais['id_table_objet'] = [
['id_petition','petition'],
['id_signature','signature'],
];
$essais['objet_type'] = array(
array('petition','petitions'),
array('signature','signatures'),
);
$essais['objet_type'] = [
['petition','petitions'],
['signature','signatures'],
];
// hop ! on y va
$err = array();
foreach($essais as $f=>$essai)
$err = array_merge(tester_fun($f, $essai),$err);
$err = [];
foreach ($essais as $f => $essai) {
$err = array_merge(tester_fun($f, $essai), $err);
}
// si le tableau $err est pas vide ca va pas
if ($err) {