4 * Déclarations relatives à la base de données
6 * @package SPIP\Formidable\Pipelines
10 if (!defined('_ECRIRE_INC_VERSION')) {
15 * Déclarer les interfaces des tables de formidable pour le compilateur
17 * @pipeline declarer_tables_interfaces
19 * @param array $interfaces
20 * Déclarations d'interface pour le compilateur
22 * Déclarations d'interface pour le compilateur
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';
30 $interfaces['tables_jointures']['spip_formulaires'][] = 'formulaires_liens';
31 $interfaces['tables_jointures']['spip_articles'][] = 'formulaires_liens';
32 $interfaces['tables_jointures']['spip_rubriques'][] = 'formulaires_liens';
34 $interfaces['table_des_traitements']['MESSAGE_RETOUR']['formulaires']= _TRAITEMENT_RACCOURCIS
;
35 $interfaces['table_des_traitements']['URL_REDIRECT']['formulaires']= 'vider_url(%s)';
42 * Déclarer les objets éditoriaux des formulaires
44 * @pipeline declarer_tables_objets_sql
45 * @param array $tables
46 * Description des tables
48 * Description complétée des tables
50 function formidable_declarer_tables_objets_sql($tables) {
51 include_spip('inc/config');
52 $tables['spip_formulaires'] = array(
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',
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'),
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'",
86 'PRIMARY KEY' => 'id_formulaire'
89 'id_formulaire' => 'id_formulaire'
95 'previsu' => 'publie,prop',
96 'exception' => array('statut', 'tout'),
99 'texte_changer_statut' => 'formidable:changer_statut',
100 'rechercher_champs' => array(
101 'titre' => 5, 'descriptif' => 3
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'
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',
115 'page' => (lire_config('formidable/analyse/activer_pages')=='on') ?
'formulaire' : false,
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",
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',
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 ''",
142 'PRIMARY KEY' => 'id_formulaires_reponse',
143 'KEY id_formulaire' => 'id_formulaire',
144 'KEY id_auteur' => 'id_auteur',
145 'KEY cookie' => 'cookie'
148 'id_formulaires_reponse' => 'id_formulaires_reponse',
149 'id_formulaire' => 'id_formulaire',
150 'id_auteur' => 'id_auteur'
155 'publie' => 'publie',
156 'previsu' => 'publie,prop',
157 'exception' => array('statut', 'tout'),
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),
165 'statut_titres' => array(
166 'prop'=>'formidable:info_reponse_proposee',
167 'publie'=>'formidable:info_reponse_publiee',
168 'refuse'=>'formidable:info_reponse_supprimee'
170 'statut_textes_instituer' => array(
171 'prop' => 'formidable:texte_statut_propose_evaluation',
172 'publie' => 'formidable:texte_statut_publie',
173 'refuse' => 'formidable:texte_statut_poubelle',
180 * Déclarer les tables principales de formidable
182 * @pipeline declarer_tables_principales
183 * @param array $tables_principales
184 * Description des tables
186 * Description complétée des tables
188 function formidable_declarer_tables_principales($tables_principales) {
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 ''",
198 $formulaires_reponses_champs_cles = array(
199 'PRIMARY KEY' => 'id_formulaires_reponses_champ',
200 'KEY id_formulaires_reponse' => 'id_formulaires_reponse',
202 'UNIQUE reponse' => 'id_formulaires_reponse,nom',
204 $tables_principales['spip_formulaires_reponses_champs'] = array(
205 'field' => &$formulaires_reponses_champs,
206 'key' => &$formulaires_reponses_champs_cles
209 return $tables_principales;
213 * Déclarer les tables auxiliaires de formidable
215 * @pipeline declarer_tables_auxiliaires
216 * @param array $tables_auxiliaires
217 * Description des tables
219 * Description complétée des tables
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"
228 $formulaires_liens_cles = array(
229 'PRIMARY KEY' => 'id_formulaire,id_objet,objet',
230 'KEY id_formulaire' => 'id_formulaire'
233 $tables_auxiliaires['spip_formulaires_liens'] = array(
234 'field' => &$formulaires_liens,
235 'key' => &$formulaires_liens_cles
238 return $tables_auxiliaires;