1 | <?php |
---|
2 | /** |
---|
3 | * Plugin Contacts & Organisations pour Spip 2.0 |
---|
4 | * Licence GPL (c) 2009 - 2010- Ateliers CYM |
---|
5 | */ |
---|
6 | |
---|
7 | function contacts_declarer_tables_interfaces($interface){ |
---|
8 | $interface['table_des_tables']['organisations'] = 'organisations'; |
---|
9 | $interface['table_des_tables']['contacts'] = 'contacts'; |
---|
10 | $interface['table_des_tables']['organisations_contacts'] = 'organisations_contacts'; |
---|
11 | |
---|
12 | // -- Liaisons comptes/auteurs, contacts/auteurs et comptes/contacts |
---|
13 | $interface['tables_jointures']['spip_contacts'][]= 'contacts_liens'; |
---|
14 | $interface['tables_jointures']['spip_auteurs'][]= 'contacts_liens'; |
---|
15 | $interface['tables_jointures']['spip_organisations'][] = 'auteurs'; |
---|
16 | $interface['tables_jointures']['spip_auteurs'][]= 'organisations'; |
---|
17 | $interface['tables_jointures']['spip_organisations_contacts'][]= 'contacts'; |
---|
18 | $interface['tables_jointures']['spip_organisations_contacts'][]= 'organisations'; |
---|
19 | $interface['tables_jointures']['spip_contacts'][]= 'organisations_contacts'; |
---|
20 | $interface['tables_jointures']['spip_organisations'][]= 'organisations_contacts'; |
---|
21 | |
---|
22 | |
---|
23 | /** |
---|
24 | * Objectif : autoriser les traitements SPIP sur certains champs texte... |
---|
25 | * |
---|
26 | */ |
---|
27 | $interface['table_des_traitements']['NOM'][] = _TRAITEMENT_TYPO; |
---|
28 | $interface['table_des_traitements']['PRENOM'][] = _TRAITEMENT_TYPO; |
---|
29 | $interface['table_des_traitements']['CIVILITE'][] = _TRAITEMENT_TYPO; |
---|
30 | $interface['table_des_traitements']['FONCTION'][] = _TRAITEMENT_TYPO; |
---|
31 | $interface['table_des_traitements']['ACTIVITE'][] = _TRAITEMENT_TYPO; |
---|
32 | |
---|
33 | // gerer le critere de date |
---|
34 | $interface['table_date']['contacts'] = 'date_naissance'; |
---|
35 | $interface['table_date']['organisations'] = 'date_creation'; |
---|
36 | |
---|
37 | // titre |
---|
38 | $interface['table_titre']['contacts'] = "CONCAT(nom,' ',prenom) AS titre, '' AS lang"; |
---|
39 | $interface['table_titre']['organisations'] = "nom AS titre, '' AS lang"; |
---|
40 | |
---|
41 | return $interface; |
---|
42 | } |
---|
43 | |
---|
44 | |
---|
45 | function contacts_declarer_tables_principales($tables_principales){ |
---|
46 | //-- Table organisations ------------------------------------------ |
---|
47 | $organisations = array( |
---|
48 | "id_organisation" => "bigint(21) NOT NULL auto_increment", |
---|
49 | "id_auteur" => "bigint(21) NOT NULL default 0", |
---|
50 | "id_parent" => "bigint(21) NOT NULL default 0", |
---|
51 | "nom" => "tinytext DEFAULT '' NOT NULL", |
---|
52 | "statut_juridique" => "tinytext DEFAULT '' NOT NULL", // forme juridique : SA, SARL, association, etc. |
---|
53 | "identification" => "tinytext DEFAULT '' NOT NULL", // N° d'identification : SIRET, SIREN, N° TVA... |
---|
54 | "activite" => "tinytext DEFAULT '' NOT NULL", // Secteur d'activité : humanitaire, formation... |
---|
55 | "date_creation" => "datetime NOT NULL default '0000-00-00 00:00:00'", |
---|
56 | "descriptif" => "TEXT DEFAULT '' NOT NULL", |
---|
57 | "maj" => "TIMESTAMP" |
---|
58 | ); |
---|
59 | $organisations_key = array( |
---|
60 | "PRIMARY KEY" => "id_organisation", |
---|
61 | "KEY id_auteur" => "id_auteur" |
---|
62 | ); |
---|
63 | $organisations_join = array( |
---|
64 | // sinon (ORGANISATIONS){auteurs.statut = xxx} ne fonctionne pas... |
---|
65 | // va comprendre... |
---|
66 | "id_auteur" => "id_auteur", |
---|
67 | "id_organisation" => "id_organisation" |
---|
68 | ); |
---|
69 | $tables_principales['spip_organisations'] = |
---|
70 | array('field' => &$organisations, 'key' => &$organisations_key, 'join' => &$organisations_join); |
---|
71 | |
---|
72 | //-- Table contacts ------------------------------------------ |
---|
73 | $contacts = array( |
---|
74 | "id_contact" => "bigint(21) NOT NULL auto_increment", |
---|
75 | "civilite" => "tinytext DEFAULT '' NOT NULL", |
---|
76 | "nom" => "tinytext DEFAULT '' NOT NULL", |
---|
77 | "prenom" => "tinytext NOT NULL DEFAULT ''", |
---|
78 | "fonction" => "tinytext DEFAULT '' NOT NULL", // gérant, membre, trésorier, etc. |
---|
79 | "date_naissance"=> "datetime NOT NULL default '0000-00-00 00:00:00'", |
---|
80 | "descriptif" => "text DEFAULT '' NOT NULL", |
---|
81 | "maj" => "TIMESTAMP" |
---|
82 | ); |
---|
83 | $contacts_key = array( |
---|
84 | "PRIMARY KEY" => "id_contact", |
---|
85 | ); |
---|
86 | /* $contacts_join = array( |
---|
87 | "id_contact" => "id_contact" |
---|
88 | );*/ |
---|
89 | $tables_principales['spip_contacts'] = |
---|
90 | array('field' => &$contacts, 'key' => &$contacts_key, /*'join' => &$contacts_join*/); |
---|
91 | |
---|
92 | return $tables_principales; |
---|
93 | |
---|
94 | } |
---|
95 | |
---|
96 | |
---|
97 | function contacts_declarer_tables_auxiliaires($tables_auxiliaires){ |
---|
98 | |
---|
99 | //-- Table organisations_contacts ------------------------------------- |
---|
100 | $organisations_contacts = array( |
---|
101 | "id_organisation" => "BIGINT(21) NOT NULL", |
---|
102 | "id_contact" => "BIGINT(21) NOT NULL", |
---|
103 | "type_liaison" => "tinytext NOT NULL DEFAULT ''", |
---|
104 | ); |
---|
105 | $organisations_contacts_key = array( |
---|
106 | "PRIMARY KEY" => "id_organisation, id_contact", |
---|
107 | "KEY id_organisation" => "id_organisation", |
---|
108 | "KEY id_contact" => "id_contact" |
---|
109 | ); |
---|
110 | $tables_auxiliaires['spip_organisations_contacts'] = |
---|
111 | array('field' => &$organisations_contacts, 'key' => &$organisations_contacts_key); |
---|
112 | |
---|
113 | |
---|
114 | //-- Table organisations_contacts ------------------------------------- |
---|
115 | $contacts_liens = array( |
---|
116 | "id_contact" => "BIGINT(21) NOT NULL", |
---|
117 | "id_objet" => "BIGINT(21) NOT NULL", |
---|
118 | "objet" => "VARCHAR(25) NOT NULL", |
---|
119 | ); |
---|
120 | $contacts_liens_key = array( |
---|
121 | "PRIMARY KEY" => "id_contact, id_objet, objet", |
---|
122 | "KEY id_contact" => "id_contact" |
---|
123 | ); |
---|
124 | $tables_auxiliaires['spip_contacts_liens'] = |
---|
125 | array('field' => &$contacts_liens, 'key' => &$contacts_liens_key); |
---|
126 | |
---|
127 | |
---|
128 | return $tables_auxiliaires; |
---|
129 | } |
---|
130 | |
---|
131 | ?> |
---|