[PLUGINS] +set de base
[lhc/web/www.git] / www / plugins / formidable_1_0 / 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 return $interfaces;
33 }
34
35 /**
36 * Déclarer les objets éditoriaux des formulaires
37 *
38 * @pipeline declarer_tables_objets_sql
39 * @param array $tables
40 * Description des tables
41 * @return array
42 * Description complétée des tables
43 */
44 function formidable_declarer_tables_objets_sql($tables) {
45 $tables['spip_formulaires'] = array(
46 'type'=>'formulaire',
47 'titre' => "titre, '' AS lang",
48 'date' => '',
49 'principale' => 'oui',
50
51 'field' => array(
52 "id_formulaire" => "bigint(21) NOT NULL",
53 "identifiant" => "varchar(200)",
54 "titre" => "text NOT NULL default ''",
55 "descriptif" => "text",
56 "message_retour" => "text NOT NULL default ''",
57 "saisies" => "text NOT NULL default ''",
58 "traitements" => "text NOT NULL default ''",
59 "public" => "enum('non', 'oui') DEFAULT 'non' NOT NULL",
60 "statut" => "varchar(10) NOT NULL default ''",
61 "maj" => "timestamp",
62 "apres" => "varchar(12) NOT NULL default ''",
63 "url_redirect" => "varchar(255)"
64 ),
65 'key' => array(
66 "PRIMARY KEY" => "id_formulaire"
67 ),
68 'join'=> array(
69 'id_formulaire' => 'id_formulaire'
70 ),
71 'rechercher_champs' => array(
72 'titre' => 5, 'descriptif' => 3
73 ),
74 );
75
76 $tables['spip_formulaires_reponses'] = array(
77 'type'=>'formulaires_reponse',
78 'titre' => "'' AS titre, '' AS lang",
79 'date' => 'date',
80 'principale' => 'oui',
81
82 'field' => array(
83 "id_formulaires_reponse" => "bigint(21) NOT NULL",
84 "id_formulaire" => "bigint(21) NOT NULL default 0",
85 "date" => "datetime NOT NULL default '0000-00-00 00:00:00'",
86 "ip" => "varchar(255) NOT NULL default ''",
87 "id_auteur" => "bigint(21) NOT NULL default 0",
88 "cookie" => "varchar(255) NOT NULL default ''",
89 "statut" => "varchar(10) NOT NULL default ''",
90 "maj" => "timestamp"
91 ),
92 'key' => array(
93 "PRIMARY KEY" => "id_formulaires_reponse",
94 "KEY id_formulaire" => "id_formulaire",
95 "KEY id_auteur" => "id_auteur",
96 "KEY cookie" => "cookie"
97 ),
98 'join' => array(
99 'id_formulaires_reponse' => 'id_formulaires_reponse',
100 'id_formulaire' => 'id_formulaire',
101 'id_auteur' => 'id_auteur'
102 ),
103 'statut'=> array(
104 array(
105 'champ' => 'statut',
106 'publie' => 'publie',
107 'previsu' => 'publie,prop',
108 'exception' => array('statut', 'tout'),
109 )
110 ),
111 'texte_changer_statut' => 'formulaires_reponse:changer_statut',
112 'statut_titres' => array(
113 'prop'=>'info_article_propose',
114 'publie'=>'info_article_publie',
115 'poubelle'=>'info_article_supprime'
116 ),
117 'statut_textes_instituer' => array(
118 'prop' => 'texte_statut_propose_evaluation',
119 'publie' => 'texte_statut_publie',
120 'refuse' => 'texte_statut_poubelle',
121 ),
122 );
123 return $tables;
124 }
125
126 /**
127 * Déclarer les tables principales de formidable
128 *
129 * @pipeline declarer_tables_principales
130 * @param array $tables_principales
131 * Description des tables
132 * @return array
133 * Description complétée des tables
134 **/
135 function formidable_declarer_tables_principales($tables_principales){
136
137 // Table formulaires_reponses_champs
138 $formulaires_reponses_champs = array(
139 "id_formulaires_reponse" => "bigint(21) NOT NULL default 0",
140 "nom" => "varchar(255) NOT NULL default ''",
141 "valeur" => "text NOT NULL DEFAULT ''",
142 "maj" => "timestamp"
143 );
144 $formulaires_reponses_champs_cles = array(
145 "PRIMARY KEY" => "id_formulaires_reponse, nom",
146 "KEY id_formulaires_reponse" => "id_formulaires_reponse"
147 );
148 $tables_principales['spip_formulaires_reponses_champs'] = array(
149 'field' => &$formulaires_reponses_champs,
150 'key' => &$formulaires_reponses_champs_cles
151 );
152
153 return $tables_principales;
154 }
155
156 /**
157 * Déclarer les tables auxiliaires de formidable
158 *
159 * @pipeline declarer_tables_auxiliaires
160 * @param array $tables_auxiliaires
161 * Description des tables
162 * @return array
163 * Description complétée des tables
164 **/
165 function formidable_declarer_tables_auxiliaires($tables_auxiliaires){
166 $formulaires_liens = array(
167 "id_formulaire" => "bigint(21) DEFAULT '0' NOT NULL",
168 "id_objet" => "bigint(21) DEFAULT '0' NOT NULL",
169 "objet" => "VARCHAR (25) DEFAULT '' NOT NULL"
170 );
171
172 $formulaires_liens_cles = array(
173 "PRIMARY KEY" => "id_formulaire,id_objet,objet",
174 "KEY id_formulaire" => "id_formulaire"
175 );
176
177 $tables_auxiliaires['spip_formulaires_liens'] = array(
178 'field' => &$formulaires_liens,
179 'key' => &$formulaires_liens_cles
180 );
181
182 return $tables_auxiliaires;
183 }
184
185
186
187 ?>