4 * Déclarations relatives à la base de données
6 * @package SPIP\Formidable\Pipelines
10 if (!defined('_ECRIRE_INC_VERSION')) return;
13 * Déclarer les interfaces des tables de formidable pour le compilateur
15 * @pipeline declarer_tables_interfaces
17 * @param array $interfaces
18 * Déclarations d'interface pour le compilateur
20 * Déclarations d'interface pour le compilateur
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';
28 $interfaces['tables_jointures']['spip_formulaires'][] = 'formulaires_liens';
29 $interfaces['tables_jointures']['spip_articles'][] = 'formulaires_liens';
30 $interfaces['tables_jointures']['spip_rubriques'][] = 'formulaires_liens';
32 $interfaces['table_des_traitements']['MESSAGE_RETOUR']['formulaires']= _TRAITEMENT_RACCOURCIS
;
33 $interfaces['table_des_traitements']['URL_REDIRECT']['formulaires']= 'vider_url(%s)';
40 * Déclarer les objets éditoriaux des formulaires
42 * @pipeline declarer_tables_objets_sql
43 * @param array $tables
44 * Description des tables
46 * Description complétée des tables
48 function formidable_declarer_tables_objets_sql($tables) {
49 include_spip('inc/config');
50 $tables['spip_formulaires'] = array(
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',
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'),
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'",
79 "PRIMARY KEY" => "id_formulaire"
82 'id_formulaire' => 'id_formulaire'
88 'previsu' => 'publie,prop',
89 'exception' => array('statut', 'tout'),
92 'texte_changer_statut' => 'formidable:changer_statut',
93 'rechercher_champs' => array(
94 'titre' => 5, 'descriptif' => 3
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'
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',
108 'page' => (lire_config('formidable/analyse/activer_pages')=='on') ?
'formulaire' : false,
112 $tables['spip_formulaires_reponses'] = array(
113 'type'=>'formulaires_reponse',
114 'titre' => "'' AS titre, '' AS lang",
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',
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 ''",
132 "PRIMARY KEY" => "id_formulaires_reponse",
133 "KEY id_formulaire" => "id_formulaire",
134 "KEY id_auteur" => "id_auteur",
135 "KEY cookie" => "cookie"
138 'id_formulaires_reponse' => 'id_formulaires_reponse',
139 'id_formulaire' => 'id_formulaire',
140 'id_auteur' => 'id_auteur'
145 'publie' => 'publie',
146 'previsu' => 'publie,prop',
147 'exception' => array('statut', 'tout'),
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),
155 'statut_titres' => array(
156 'prop'=>'formidable:info_reponse_proposee',
157 'publie'=>'formidable:info_reponse_publiee',
158 'refuse'=>'formidable:info_reponse_supprimee'
160 'statut_textes_instituer' => array(
161 'prop' => 'formidable:texte_statut_propose_evaluation',
162 'publie' => 'formidable:texte_statut_publie',
163 'refuse' => 'formidable:texte_statut_poubelle',
170 * Déclarer les tables principales de formidable
172 * @pipeline declarer_tables_principales
173 * @param array $tables_principales
174 * Description des tables
176 * Description complétée des tables
178 function formidable_declarer_tables_principales($tables_principales){
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 ''",
188 $formulaires_reponses_champs_cles = array(
189 "PRIMARY KEY" => "id_formulaires_reponses_champ",
190 "KEY id_formulaires_reponse" => "id_formulaires_reponse",
192 "UNIQUE reponse" => "id_formulaires_reponse,nom",
194 $tables_principales['spip_formulaires_reponses_champs'] = array(
195 'field' => &$formulaires_reponses_champs,
196 'key' => &$formulaires_reponses_champs_cles
199 return $tables_principales;
203 * Déclarer les tables auxiliaires de formidable
205 * @pipeline declarer_tables_auxiliaires
206 * @param array $tables_auxiliaires
207 * Description des tables
209 * Description complétée des tables
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"
218 $formulaires_liens_cles = array(
219 "PRIMARY KEY" => "id_formulaire,id_objet,objet",
220 "KEY id_formulaire" => "id_formulaire"
223 $tables_auxiliaires['spip_formulaires_liens'] = array(
224 'field' => &$formulaires_liens,
225 'key' => &$formulaires_liens_cles
228 return $tables_auxiliaires;