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';
36 * Déclarer les objets éditoriaux des formulaires
38 * @pipeline declarer_tables_objets_sql
39 * @param array $tables
40 * Description des tables
42 * Description complétée des tables
44 function formidable_declarer_tables_objets_sql($tables) {
45 $tables['spip_formulaires'] = array(
47 'titre' => "titre, '' AS lang",
48 'date' => 'date_creation',
49 'principale' => 'oui',
50 'texte_modifier' => 'formidable:editer_modifier_formulaire',
53 "id_formulaire" => "bigint(21) NOT NULL",
54 "identifiant" => "varchar(200)",
55 "titre" => "text NOT NULL default ''",
56 "descriptif" => "text",
57 "message_retour" => "text NOT NULL default ''",
58 "saisies" => "longtext NOT NULL default ''",
59 "traitements" => "text NOT NULL default ''",
60 "public" => "enum('non', 'oui') DEFAULT 'non' NOT NULL",
61 "statut" => "varchar(10) NOT NULL default ''",
62 "date_creation" => "datetime NOT NULL DEFAULT '0000-00-00 00:00:00'",
64 "apres" => "varchar(12) NOT NULL default ''",
65 "url_redirect" => "varchar(255)"
68 "PRIMARY KEY" => "id_formulaire"
71 'id_formulaire' => 'id_formulaire'
73 'rechercher_champs' => array(
74 'titre' => 5, 'descriptif' => 3
78 $tables['spip_formulaires_reponses'] = array(
79 'type'=>'formulaires_reponse',
80 'titre' => "'' AS titre, '' AS lang",
82 'principale' => 'oui',
85 "id_formulaires_reponse" => "bigint(21) NOT NULL",
86 "id_formulaire" => "bigint(21) NOT NULL default 0",
87 "date" => "datetime NOT NULL default '0000-00-00 00:00:00'",
88 "ip" => "varchar(255) NOT NULL default ''",
89 "id_auteur" => "bigint(21) NOT NULL default 0",
90 "cookie" => "varchar(255) NOT NULL default ''",
91 "statut" => "varchar(10) NOT NULL default ''",
95 "PRIMARY KEY" => "id_formulaires_reponse",
96 "KEY id_formulaire" => "id_formulaire",
97 "KEY id_auteur" => "id_auteur",
98 "KEY cookie" => "cookie"
101 'id_formulaires_reponse' => 'id_formulaires_reponse',
102 'id_formulaire' => 'id_formulaire',
103 'id_auteur' => 'id_auteur'
108 'publie' => 'publie',
109 'previsu' => 'publie,prop',
110 'exception' => array('statut', 'tout'),
113 'texte_changer_statut' => 'formulaires_reponse:changer_statut',
114 'statut_titres' => array(
115 'prop'=>'info_article_propose',
116 'publie'=>'info_article_publie',
117 'poubelle'=>'info_article_supprime'
119 'statut_textes_instituer' => array(
120 'prop' => 'texte_statut_propose_evaluation',
121 'publie' => 'texte_statut_publie',
122 'refuse' => 'texte_statut_poubelle',
129 * Déclarer les tables principales de formidable
131 * @pipeline declarer_tables_principales
132 * @param array $tables_principales
133 * Description des tables
135 * Description complétée des tables
137 function formidable_declarer_tables_principales($tables_principales){
139 // Table formulaires_reponses_champs
140 $formulaires_reponses_champs = array(
141 "id_formulaires_reponse" => "bigint(21) NOT NULL default 0",
142 "nom" => "varchar(255) NOT NULL default ''",
143 "valeur" => "text NOT NULL DEFAULT ''",
146 $formulaires_reponses_champs_cles = array(
147 "PRIMARY KEY" => "id_formulaires_reponse, nom",
148 "KEY id_formulaires_reponse" => "id_formulaires_reponse"
150 $tables_principales['spip_formulaires_reponses_champs'] = array(
151 'field' => &$formulaires_reponses_champs,
152 'key' => &$formulaires_reponses_champs_cles
155 return $tables_principales;
159 * Déclarer les tables auxiliaires de formidable
161 * @pipeline declarer_tables_auxiliaires
162 * @param array $tables_auxiliaires
163 * Description des tables
165 * Description complétée des tables
167 function formidable_declarer_tables_auxiliaires($tables_auxiliaires){
168 $formulaires_liens = array(
169 "id_formulaire" => "bigint(21) DEFAULT '0' NOT NULL",
170 "id_objet" => "bigint(21) DEFAULT '0' NOT NULL",
171 "objet" => "VARCHAR (25) DEFAULT '' NOT NULL"
174 $formulaires_liens_cles = array(
175 "PRIMARY KEY" => "id_formulaire,id_objet,objet",
176 "KEY id_formulaire" => "id_formulaire"
179 $tables_auxiliaires['spip_formulaires_liens'] = array(
180 'field' => &$formulaires_liens,
181 'key' => &$formulaires_liens_cles
184 return $tables_auxiliaires;