Amélioration de la déclaration des champs recherchés.
[spip_souscriptions.git] / base / souscription.php
1 <?php
2 /**
3  * Déclarations relatives à la base de données
4  *
5  * @plugin     Souscription
6  * @copyright  2013
7  * @author     Olivier Tétard
8  * @licence    GNU/GPL
9  * @package    SPIP\Souscription\Pipelines
10  */
11
12 if (!defined('_ECRIRE_INC_VERSION')) return;
13
14
15 /**
16  * Déclaration des alias de tables et filtres automatiques de champs
17  *
18  * @pipeline declarer_tables_interfaces
19  * @param array $interfaces
20  *     Déclarations d'interface pour le compilateur
21  * @return array
22  *     Déclarations d'interface pour le compilateur
23  */
24 function souscription_declarer_tables_interfaces($interfaces) {
25   $interfaces['table_des_tables']['souscriptions'] = 'souscriptions';
26   $interfaces['table_des_tables']['souscription_campagnes'] = 'souscription_campagnes';
27
28   return $interfaces;
29 }
30
31
32 /**
33  * Déclaration des objets éditoriaux
34  *
35  * @pipeline declarer_tables_objets_sql
36  * @param array $tables
37  *     Description des tables
38  * @return array
39  *     Description complétée des tables
40  */
41 function souscription_declarer_tables_objets_sql($tables) {
42
43   $tables['spip_souscriptions'] =
44     array('type' => 'souscription',
45           'principale' => "oui",
46           'table_objet_surnoms' => array('souscription'), // table_objet('souscription') => 'souscription'
47           'field'=> array("id_souscription" => "bigint(21) NOT NULL",
48                           "id_transaction"      => "bigint(21) NOT NULL DEFAULT 0",
49                           "id_souscription_campagne" => "bigint(21) NOT NULL DEFAULT 0",
50                           "courriel"            => "text NOT NULL DEFAULT ''",
51                           "nom"                 => "text NOT NULL DEFAULT ''",
52                           "prenom"              => "text NOT NULL DEFAULT ''",
53                           "code_postal"         => "text NOT NULL DEFAULT ''",
54                           "adresse"             => "text NOT NULL DEFAULT ''",
55                           "ville"               => "text NOT NULL DEFAULT ''",
56                           "pays"                => "text NOT NULL DEFAULT ''",
57                           "telephone"           => "text NOT NULL DEFAULT ''",
58                           "recu_fiscal"         => "varchar(3) NOT NULL DEFAULT ''",
59                           "type_souscription"   => "varchar(255) NOT NULL DEFAULT ''",
60                           "informer_comite_local" => "varchar(3) NOT NULL DEFAULT ''",
61                           "envoyer_info"        => "varchar(3) NOT NULL DEFAULT ''",
62                           "date_souscription "  => "datetime NOT NULL DEFAULT '0000-00-00 00:00:00'",
63                           "maj"                 => "TIMESTAMP"
64                           ),
65           'key' => array("PRIMARY KEY"          => "id_souscription",
66                          "KEY id_transaction"   => "id_transaction",
67                          "KEY id_souscription_campagne" => "id_souscription_campagne"),
68           'titre' => "nom AS titre, '' AS lang",
69           'date' => "date_souscription",
70           'champs_editables'  => array('courriel', 'nom', 'prenom', 'code_postal', 'adresse', 'ville', 'pays', 'recu_fiscal', 'envoyer_info'),
71           'champs_versionnes' => array('courriel', 'nom', 'prenom', 'code_postal', 'adresse', 'ville', 'pays', 'recu_fiscal', 'envoyer_info'),
72           'rechercher_champs' => array("id_souscription" => 1,
73                                        "courriel" => 1,
74                                        "nom" => 1,
75                                        "prenom" => 1,
76                                        "adresse" => 1,
77                                        "ville" => 1,
78                                        "code_postal" => 1
79                                        ),
80           'join' => array("id_transaction" => "id_transaction"),
81           'tables_jointures'  => array('spip_transactions'),
82           );
83
84   $tables['spip_souscription_campagnes'] =
85     array('type' => 'souscription_campagne',
86           'principale' => "oui",
87           'table_objet_surnoms' => array('souscriptioncampagne'),
88           'field'=> array("id_souscription_campagne" => "bigint(21) NOT NULL",
89                           "objectif"                 => "int(11) NOT NULL DEFAULT 0",
90                           "objectif_initial"         => "int(11) NOT NULL DEFAULT 0",
91                           "type_objectif"            => "varchar(255) NOT NULL DEFAULT 0",
92                           "objectif_limiter"         => "varchar(3) NOT NULL DEFAULT ''",
93                           "titre"                    => "text NOT NULL DEFAULT ''",
94                           "texte"                    => "longtext NOT NULL DEFAULT ''",
95                           "configuration_specifique" => "varchar(3) NOT NULL DEFAULT ''",
96                           "type_saisie"              => "varchar(255) NOT NULL DEFAULT ''",
97                           "montants"                 => "text NOT NULL DEFAULT ''",
98                           "statut"                   => "varchar(255) NOT NULL DEFAULT 0",
99                           "date"                     => "datetime NOT NULL DEFAULT '0000-00-00 00:00:00'",
100                           "maj"                      => "TIMESTAMP"
101                           ),
102           'key' => array("PRIMARY KEY"               => "id_souscription_campagne",
103                          "KEY id_souscription_campagne" => "id_souscription_campagne",
104                          ),
105           'titre' => "titre AS titre, '' AS lang",
106           'date' => "date",
107           'champs_editables'  => array('objectif', 'titre', 'texte', 'objectif_initial', 'type_objectif', 'objectif_limiter', 'configuration_specifique', 'type_saisie', 'montants'),
108           'champs_versionnes' => array('objectif', 'titre', 'texte', 'objectif_initial', 'type_objectif', 'objectif_limiter', 'configuration_specifique', 'type_saisie', 'montants'),
109           'rechercher_champs' => array(),
110           );
111
112   return $tables;
113 }