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