3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
6 * Copyright (c) 2001-2019 *
7 * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
9 * Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
10 * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
11 \***************************************************************************/
14 * Déclarations relatives à la base de données
16 * @package SPIP\Petitions\Pipelines
19 if (!defined('_ECRIRE_INC_VERSION')) {
24 * Interfaces des tables petitions et signatures pour le compilateur
26 * @pipeline declarer_tables_interfaces
27 * @param array $interfaces
28 * Déclarations d'interface pour le compilateur
30 * Déclarations d'interface pour le compilateur
32 function petitions_declarer_tables_interfaces($interfaces) {
34 $interfaces['table_des_tables']['petitions'] = 'petitions';
35 $interfaces['table_des_tables']['signatures'] = 'signatures';
37 $interfaces['exceptions_des_tables']['signatures']['date'] = 'date_time';
38 $interfaces['exceptions_des_tables']['signatures']['nom'] = 'nom_email';
39 $interfaces['exceptions_des_tables']['signatures']['email'] = 'ad_email';
41 $interfaces['tables_jointures']['spip_articles'][] = 'petitions';
42 $interfaces['tables_jointures']['spip_articles'][] = 'signatures';
44 $interfaces['exceptions_des_jointures']['petition'] = array('spip_petitions', 'texte');
45 $interfaces['exceptions_des_jointures']['id_signature'] = array('spip_signatures', 'id_signature');
47 $interfaces['table_des_traitements']['MESSAGE'][] = _TRAITEMENT_RACCOURCIS
;
49 // Signatures : passage des donnees telles quelles, sans traitement typo
50 // la securite et conformite XHTML de ces champs est assuree par safehtml()
51 foreach (array('NOM_EMAIL', 'AD_EMAIL', 'NOM_SITE', 'URL_SITE', 'MESSAGE') as $balise) {
52 if (!isset($interfaces['table_des_traitements'][$balise]['signatures'])) {
53 $interfaces['table_des_traitements'][$balise]['signatures'] = 'liens_nofollow(safehtml(%s))';
55 if (strpos($interfaces['table_des_traitements'][$balise]['signatures'], 'safehtml') == false) {
56 $interfaces['table_des_traitements'][$balise]['signatures'] = 'liens_nofollow(safehtml(' . $interfaces['table_des_traitements'][$balise]['signatures'] . '))';
65 * Déclarer les objets éditoriaux des pétitions et signatures
67 * @pipeline declarer_tables_objets_sql
68 * @param array $tables
69 * Description des tables
71 * Description complétée des tables
73 function petitions_declarer_tables_objets_sql($tables) {
74 $tables['spip_petitions'] = array(
75 'url_voir' => 'controler_petition',
76 'url_edit' => 'controler_petition',
78 'principale' => 'oui',
79 'page' => '', // pas de page editoriale pour une petition
81 'texte_retour' => 'icone_retour',
82 'texte_objets' => 'petitions:titre_petitions',
83 'texte_objet' => 'petitions:titre_petition',
85 'titre' => "texte as titre, '' AS lang",
88 "id_petition" => "bigint(21) NOT NULL",
89 "id_article" => "bigint(21) DEFAULT '0' NOT NULL",
90 "email_unique" => "CHAR (3) DEFAULT '' NOT NULL",
91 "site_obli" => "CHAR (3) DEFAULT '' NOT NULL",
92 "site_unique" => "CHAR (3) DEFAULT '' NOT NULL",
93 "message" => "CHAR (3) DEFAULT '' NOT NULL",
94 "texte" => "LONGTEXT DEFAULT '' NOT NULL",
95 "statut" => "VARCHAR (10) DEFAULT 'publie' NOT NULL",
99 "PRIMARY KEY" => "id_petition",
100 "UNIQUE KEY id_article" => "id_article"
103 array('champ' => 'statut', 'publie' => 'publie,off', 'previsu' => 'publie,off', 'exception' => array('statut')),
107 $tables['spip_signatures'] = array(
108 'url_voir' => 'controler_petition',
109 'url_edit' => 'controler_petition',
111 'principale' => 'oui',
112 'page' => '', // pas de page editoriale pour une signature
114 'texte_retour' => 'icone_retour',
115 'texte_objets' => 'public:signatures_petition',
116 'texte_objet' => 'entree_signature',
117 'info_aucun_objet' => 'petitions:aucune_signature',
118 'info_1_objet' => 'petitions:une_signature',
119 'info_nb_objets' => 'petitions:nombre_signatures',
120 'titre' => "nom_email as titre, '' AS lang",
121 'date' => 'date_time',
124 "id_signature" => "bigint(21) NOT NULL",
125 "id_petition" => "bigint(21) DEFAULT '0' NOT NULL",
126 # "id_article" => "bigint(21) DEFAULT '0' NOT NULL",
127 "date_time" => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
128 "nom_email" => "text DEFAULT '' NOT NULL",
129 "ad_email" => "text DEFAULT '' NOT NULL",
130 "nom_site" => "text DEFAULT '' NOT NULL",
131 "url_site" => "text DEFAULT '' NOT NULL",
132 "message" => "mediumtext DEFAULT '' NOT NULL",
133 "statut" => "varchar(10) DEFAULT '0' NOT NULL",
137 "PRIMARY KEY" => "id_signature",
138 "KEY id_petition" => "id_petition",
139 # "KEY id_article" => "id_article",
140 "KEY statut" => "statut"
143 "id_signature" => "id_signature",
144 "id_petition" => "id_petition"
146 'tables_jointures' => array(
150 array('champ' => 'statut', 'publie' => 'publie', 'previsu' => 'publie', 'exception' => array('statut', 'tout')),
152 'rechercher_champs' => array(
159 'icone_objet' => 'petition',