[PLUGINS] ~maj globale
[lhc/web/www.git] / www / plugins / formidable / base / formidable_tables.php
1 <?php
2
3 /**
4 * Déclarations relatives à la base de données
5 *
6 * @package SPIP\Formidable\Pipelines
7 **/
8
9 // Sécurité
10 if (!defined('_ECRIRE_INC_VERSION')) {
11 return;
12 }
13
14 /**
15 * Déclarer les interfaces des tables de formidable pour le compilateur
16 *
17 * @pipeline declarer_tables_interfaces
18 *
19 * @param array $interfaces
20 * Déclarations d'interface pour le compilateur
21 * @return array
22 * Déclarations d'interface pour le compilateur
23 **/
24 function formidable_declarer_tables_interfaces($interfaces) {
25 // 'spip_' dans l'index de $tables_principales
26 $interfaces['table_des_tables']['formulaires'] = 'formulaires';
27 $interfaces['table_des_tables']['formulaires_reponses'] = 'formulaires_reponses';
28 $interfaces['table_des_tables']['formulaires_reponses_champs'] = 'formulaires_reponses_champs';
29
30 $interfaces['tables_jointures']['spip_formulaires'][] = 'formulaires_liens';
31 $interfaces['tables_jointures']['spip_articles'][] = 'formulaires_liens';
32 $interfaces['tables_jointures']['spip_rubriques'][] = 'formulaires_liens';
33
34 $interfaces['table_des_traitements']['MESSAGE_RETOUR']['formulaires']= _TRAITEMENT_RACCOURCIS;
35 $interfaces['table_des_traitements']['URL_REDIRECT']['formulaires']= 'vider_url(%s)';
36
37
38 return $interfaces;
39 }
40
41 /**
42 * Déclarer les objets éditoriaux des formulaires
43 *
44 * @pipeline declarer_tables_objets_sql
45 * @param array $tables
46 * Description des tables
47 * @return array
48 * Description complétée des tables
49 */
50 function formidable_declarer_tables_objets_sql($tables) {
51 include_spip('inc/config');
52 $tables['spip_formulaires'] = array(
53 'type'=>'formulaire',
54 'titre' => "titre, '' AS lang",
55 'date' => 'date_creation',
56 'principale' => 'oui',
57 'texte_modifier' => 'formidable:editer_modifier_formulaire',
58 'info_aucun_objet'=> 'formidable:info_aucun_formulaire',
59 'info_1_objet' => 'formidable:info_1_formulaire',
60 'info_nb_objets' => 'formidable:info_nb_formulaires',
61 'texte_creer_associer' => 'formidable:liens_creer_associer',
62 'texte_ajouter' => 'formidable:liens_ajouter',
63
64 'champs_editables' => array('titre', 'identifiant', 'descriptif', 'css', 'message_retour', 'saisies', 'traitements', 'public','apres','unicite','message_erreur_unicite','url_redirect','resume_reponse'),
65 'champs_versionnes' => array('titre', 'identifiant', 'descriptif', 'css', 'message_retour', 'saisies', 'traitements', 'public','apres','unicite','message_erreur_unicite','url_redirect','resume_reponse'),
66 'field' => array(
67 'id_formulaire' => 'bigint(21) NOT NULL',
68 'identifiant' => 'varchar(200)',
69 'titre' => "text NOT NULL default ''",
70 'descriptif' => 'text',
71 'css' => 'varchar(255) not null default ""',
72 'message_retour' => "text NOT NULL default ''",
73 'saisies' => "longtext NOT NULL default ''",
74 'traitements' => "text NOT NULL default ''",
75 'public' => "enum('non', 'oui') DEFAULT 'non' NOT NULL",
76 'apres' => "varchar(12) NOT NULL default ''",
77 'unicite' => "text NOT NULL default ''",
78 'message_erreur_unicite' => "text NOT NULL default ''",
79 'url_redirect' => 'varchar(255)',
80 'statut' => "varchar(10) NOT NULL default ''",
81 'resume_reponse' => "text NOT NULL default ''",
82 'date_creation' => "datetime NOT NULL DEFAULT '0000-00-00 00:00:00'",
83 'maj' => 'timestamp',
84 ),
85 'key' => array(
86 'PRIMARY KEY' => 'id_formulaire'
87 ),
88 'join'=> array(
89 'id_formulaire' => 'id_formulaire'
90 ),
91 'statut'=> array(
92 array(
93 'champ' => 'statut',
94 'publie' => 'publie',
95 'previsu' => 'publie,prop',
96 'exception' => array('statut', 'tout'),
97 )
98 ),
99 'texte_changer_statut' => 'formidable:changer_statut',
100 'rechercher_champs' => array(
101 'titre' => 5, 'descriptif' => 3
102 ),
103 'statut_titres' => array(
104 'prop'=>'info_article_propose',
105 'publie'=>'info_article_publie',
106 'refuse'=>'formidable:info_formulaire_refuse',
107 'poubelle'=>'info_article_supprime'
108 ),
109 'statut_textes_instituer' => array(
110 'prop' => 'texte_statut_propose_evaluation',
111 'publie' => 'texte_statut_publie',
112 'refuse'=>'formidable:texte_statut_refuse',
113 'poubelle' => 'texte_statut_poubelle',
114 ),
115 'page' => (lire_config('formidable/analyse/activer_pages')=='on') ? 'formulaire' : false,
116
117 );
118
119 $tables['spip_formulaires_reponses'] = array(
120 'type_objet'=>'formulaires_reponse',
121 'table_objet_surnoms' => array('formulairesreponse'),
122 'type'=>'formulaires_reponse',
123 'type_surnoms' => array('formulairesreponse'),
124 'titre' => "'' AS titre, '' AS lang",
125 'date' => 'date',
126 'principale' => 'oui',
127 'info_aucun_objet'=> 'formidable:info_aucune_reponse',
128 'info_1_objet' => 'formidable:info_1_reponse',
129 'info_nb_objets' => 'formidable:info_nb_reponses',
130
131 'field' => array(
132 'id_formulaires_reponse' => 'bigint(21) NOT NULL',
133 'id_formulaire' => 'bigint(21) NOT NULL default 0',
134 'date' => "datetime NOT NULL default '0000-00-00 00:00:00'",
135 'ip' => "varchar(255) NOT NULL default ''",
136 'id_auteur' => 'bigint(21) NOT NULL default 0',
137 'cookie' => "varchar(255) NOT NULL default ''",
138 'statut' => "varchar(10) NOT NULL default ''",
139 'maj' => 'timestamp'
140 ),
141 'key' => array(
142 'PRIMARY KEY' => 'id_formulaires_reponse',
143 'KEY id_formulaire' => 'id_formulaire',
144 'KEY id_auteur' => 'id_auteur',
145 'KEY cookie' => 'cookie'
146 ),
147 'join' => array(
148 'id_formulaires_reponse' => 'id_formulaires_reponse',
149 'id_formulaire' => 'id_formulaire',
150 'id_auteur' => 'id_auteur'
151 ),
152 'statut'=> array(
153 array(
154 'champ' => 'statut',
155 'publie' => 'publie',
156 'previsu' => 'publie,prop',
157 'exception' => array('statut', 'tout'),
158 )
159 ),
160 'texte_changer_statut' => 'formulaires_reponse:changer_statut',
161 'rechercher_champs' => array('ip'=>1),
162 'rechercher_jointures' => array(
163 'formulaires_reponses_champ' => array('valeur' => 4),
164 ),
165 'statut_titres' => array(
166 'prop'=>'formidable:info_reponse_proposee',
167 'publie'=>'formidable:info_reponse_publiee',
168 'refuse'=>'formidable:info_reponse_supprimee'
169 ),
170 'statut_textes_instituer' => array(
171 'prop' => 'formidable:texte_statut_propose_evaluation',
172 'publie' => 'formidable:texte_statut_publie',
173 'refuse' => 'formidable:texte_statut_poubelle',
174 ),
175 );
176 return $tables;
177 }
178
179 /**
180 * Déclarer les tables principales de formidable
181 *
182 * @pipeline declarer_tables_principales
183 * @param array $tables_principales
184 * Description des tables
185 * @return array
186 * Description complétée des tables
187 **/
188 function formidable_declarer_tables_principales($tables_principales) {
189
190 // Table formulaires_reponses_champs
191 $formulaires_reponses_champs = array(
192 'id_formulaires_reponses_champ' => 'bigint(21) NOT NULL',
193 'id_formulaires_reponse' => 'bigint(21) NOT NULL default 0',
194 'nom' => "varchar(255) NOT NULL default ''",
195 'valeur' => "text NOT NULL DEFAULT ''",
196 'maj' => 'timestamp'
197 );
198 $formulaires_reponses_champs_cles = array(
199 'PRIMARY KEY' => 'id_formulaires_reponses_champ',
200 'KEY id_formulaires_reponse' => 'id_formulaires_reponse',
201 'KEY nom' => 'nom',
202 'UNIQUE reponse' => 'id_formulaires_reponse,nom',
203 );
204 $tables_principales['spip_formulaires_reponses_champs'] = array(
205 'field' => &$formulaires_reponses_champs,
206 'key' => &$formulaires_reponses_champs_cles
207 );
208
209 return $tables_principales;
210 }
211
212 /**
213 * Déclarer les tables auxiliaires de formidable
214 *
215 * @pipeline declarer_tables_auxiliaires
216 * @param array $tables_auxiliaires
217 * Description des tables
218 * @return array
219 * Description complétée des tables
220 **/
221 function formidable_declarer_tables_auxiliaires($tables_auxiliaires) {
222 $formulaires_liens = array(
223 'id_formulaire' => "bigint(21) DEFAULT '0' NOT NULL",
224 'id_objet' => "bigint(21) DEFAULT '0' NOT NULL",
225 'objet' => "VARCHAR (25) DEFAULT '' NOT NULL"
226 );
227
228 $formulaires_liens_cles = array(
229 'PRIMARY KEY' => 'id_formulaire,id_objet,objet',
230 'KEY id_formulaire' => 'id_formulaire'
231 );
232
233 $tables_auxiliaires['spip_formulaires_liens'] = array(
234 'field' => &$formulaires_liens,
235 'key' => &$formulaires_liens_cles
236 );
237
238 return $tables_auxiliaires;
239 }