b72d2ceb90a679a8e4a7d0dacf526eca674fdc3d
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, 'identifiant' => 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 'poubelle' => 'formidable:info_reponse_poubelle',
169 'refuse'=>'formidable:info_reponse_refusee'
171 'statut_textes_instituer' => array(
172 'prop' => 'formidable:texte_statut_propose_evaluation',
173 'publie' => 'formidable:texte_statut_publie',
174 'refuse' => 'formidable:texte_statut_refusee',
175 'poubelle' => 'formidable:texte_statut_poubelle'
182 * Déclarer les tables principales de formidable
184 * @pipeline declarer_tables_principales
185 * @param array $tables_principales
186 * Description des tables
188 * Description complétée des tables
190 function formidable_declarer_tables_principales($tables_principales) {
192 // Table formulaires_reponses_champs
193 $formulaires_reponses_champs = array(
194 'id_formulaires_reponses_champ' => 'bigint(21) NOT NULL',
195 'id_formulaires_reponse' => 'bigint(21) NOT NULL default 0',
196 'nom' => "varchar(255) NOT NULL default ''",
197 'valeur' => "text NOT NULL DEFAULT ''",
200 $formulaires_reponses_champs_cles = array(
201 'PRIMARY KEY' => 'id_formulaires_reponses_champ',
202 'KEY id_formulaires_reponse' => 'id_formulaires_reponse',
204 'UNIQUE reponse' => 'id_formulaires_reponse,nom',
206 $tables_principales['spip_formulaires_reponses_champs'] = array(
207 'field' => &$formulaires_reponses_champs,
208 'key' => &$formulaires_reponses_champs_cles
211 return $tables_principales;
215 * Déclarer les tables auxiliaires de formidable
217 * @pipeline declarer_tables_auxiliaires
218 * @param array $tables_auxiliaires
219 * Description des tables
221 * Description complétée des tables
223 function formidable_declarer_tables_auxiliaires($tables_auxiliaires) {
224 $formulaires_liens = array(
225 'id_formulaire' => "bigint(21) DEFAULT '0' NOT NULL",
226 'id_objet' => "bigint(21) DEFAULT '0' NOT NULL",
227 'objet' => "VARCHAR (25) DEFAULT '' NOT NULL"
230 $formulaires_liens_cles = array(
231 'PRIMARY KEY' => 'id_formulaire,id_objet,objet',
232 'KEY id_formulaire' => 'id_formulaire'
235 $tables_auxiliaires['spip_formulaires_liens'] = array(
236 'field' => &$formulaires_liens,
237 'key' => &$formulaires_liens_cles
240 return $tables_auxiliaires;