4e266b1f77de0b8e405b3785dd6692b005f29306
[lhc/web/www.git] / www / plugins-dist / petitions / base / petitions.php
1 <?php
2
3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
5 * *
6 * Copyright (c) 2001-2016 *
7 * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
8 * *
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 \***************************************************************************/
12
13 /**
14 * Déclarations relatives à la base de données
15 *
16 * @package SPIP\Petitions\Pipelines
17 **/
18
19 if (!defined('_ECRIRE_INC_VERSION')) {
20 return;
21 }
22
23 /**
24 * Interfaces des tables petitions et signatures pour le compilateur
25 *
26 * @pipeline declarer_tables_interfaces
27 * @param array $interfaces
28 * Déclarations d'interface pour le compilateur
29 * @return array
30 * Déclarations d'interface pour le compilateur
31 */
32 function petitions_declarer_tables_interfaces($interfaces) {
33
34 $interfaces['table_des_tables']['petitions'] = 'petitions';
35 $interfaces['table_des_tables']['signatures'] = 'signatures';
36
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';
40
41 $interfaces['tables_jointures']['spip_articles'][] = 'petitions';
42 $interfaces['tables_jointures']['spip_articles'][] = 'signatures';
43
44 $interfaces['exceptions_des_jointures']['petition'] = array('spip_petitions', 'texte');
45 $interfaces['exceptions_des_jointures']['id_signature'] = array('spip_signatures', 'id_signature');
46
47 $interfaces['table_des_traitements']['MESSAGE'][] = _TRAITEMENT_RACCOURCIS;
48
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))';
54 } else {
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'] . '))';
57 }
58 }
59 }
60
61 return $interfaces;
62 }
63
64 /**
65 * Déclarer les objets éditoriaux des pétitions et signatures
66 *
67 * @pipeline declarer_tables_objets_sql
68 * @param array $tables
69 * Description des tables
70 * @return array
71 * Description complétée des tables
72 */
73 function petitions_declarer_tables_objets_sql($tables) {
74 $tables['spip_petitions'] = array(
75 'url_voir' => 'controler_petition',
76 'url_edit' => 'controler_petition',
77 'editable' => 'non',
78 'principale' => 'oui',
79 'page' => '', // pas de page editoriale pour une petition
80
81 'texte_retour' => 'icone_retour',
82 'texte_objets' => 'petitions:titre_petitions',
83 'texte_objet' => 'petitions:titre_petition',
84
85 'titre' => "texte as titre, '' AS lang",
86
87 'field' => array(
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",
96 "maj" => "TIMESTAMP"
97 ),
98 'key' => array(
99 "PRIMARY KEY" => "id_petition",
100 "UNIQUE KEY id_article" => "id_article"
101 ),
102 'statut' => array(
103 array('champ' => 'statut', 'publie' => 'publie,off', 'previsu' => 'publie,off', 'exception' => array('statut')),
104 ),
105 );
106
107 $tables['spip_signatures'] = array(
108 'url_voir' => 'controler_petition',
109 'url_edit' => 'controler_petition',
110 'editable' => 'non',
111 'principale' => 'oui',
112 'page' => '', // pas de page editoriale pour une signature
113
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',
122
123 'field' => array(
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",
134 "maj" => "TIMESTAMP"
135 ),
136 'key' => array(
137 "PRIMARY KEY" => "id_signature",
138 "KEY id_petition" => "id_petition",
139 # "KEY id_article" => "id_article",
140 "KEY statut" => "statut"
141 ),
142 'join' => array(
143 "id_signature" => "id_signature",
144 "id_petition" => "id_petition"
145 ),
146 'tables_jointures' => array(
147 'petitions'
148 ),
149 'statut' => array(
150 array('champ' => 'statut', 'publie' => 'publie', 'previsu' => 'publie', 'exception' => array('statut', 'tout')),
151 ),
152 'rechercher_champs' => array(
153 'nom_email' => 2,
154 'ad_email' => 4,
155 'nom_site' => 2,
156 'url_site' => 4,
157 'message' => 1
158 ),
159 'icone_objet' => 'petition',
160 );
161
162 return $tables;
163 }