[SPIP] ~maj v3.0.14-->v3.0.17
[ptitvelo/web/www.git] / www / plugins-dist / petitions / base / petitions.php
1 <?php
2
3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
5 * *
6 * Copyright (c) 2001-2014 *
7 * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
8 * *
9 * Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
10 * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
11 \***************************************************************************/
12
13 if (!defined('_ECRIRE_INC_VERSION')) return;
14
15 /**
16 * Interfaces des tables petitions et signatures pour le compilateur
17 *
18 * @param array $interfaces
19 * @return array
20 */
21 function petitions_declarer_tables_interfaces($interfaces){
22
23 $interfaces['table_des_tables']['petitions']='petitions';
24 $interfaces['table_des_tables']['signatures']='signatures';
25
26 $interfaces['exceptions_des_tables']['signatures']['date']='date_time';
27 $interfaces['exceptions_des_tables']['signatures']['nom']='nom_email';
28 $interfaces['exceptions_des_tables']['signatures']['email']='ad_email';
29
30 $interfaces['tables_jointures']['spip_articles'][]= 'petitions';
31 $interfaces['tables_jointures']['spip_articles'][]= 'signatures';
32
33 $interfaces['exceptions_des_jointures']['petition'] = array('spip_petitions', 'texte');
34 $interfaces['exceptions_des_jointures']['id_signature']= array('spip_signatures', 'id_signature');
35
36 $interfaces['table_des_traitements']['MESSAGE'][]= _TRAITEMENT_RACCOURCIS;
37
38 // Signatures : passage des donnees telles quelles, sans traitement typo
39 // la securite et conformite XHTML de ces champs est assuree par safehtml()
40 foreach(array('NOM_EMAIL','AD_EMAIL','NOM_SITE','URL_SITE','MESSAGE') as $balise)
41 if (!isset($interfaces['table_des_traitements'][$balise]['signatures']))
42 $interfaces['table_des_traitements'][$balise]['signatures'] = 'liens_nofollow(safehtml(%s))';
43 else
44 if (strpos($interfaces['table_des_traitements'][$balise]['signatures'],'safehtml')==false)
45 $interfaces['table_des_traitements'][$balise]['signatures'] = 'liens_nofollow(safehtml('.$interfaces['table_des_traitements'][$balise]['signatures'].'))';
46
47 return $interfaces;
48 }
49
50 function petitions_declarer_tables_objets_sql($tables){
51 $tables['spip_petitions'] = array(
52 'url_voir'=>'controler_petition',
53 'url_edit'=>'controler_petition',
54 'editable'=>'non',
55 'principale' => 'oui',
56 'page'=>'', // pas de page editoriale pour une petition
57
58 'texte_retour' => 'icone_retour',
59 'texte_objets' => 'petitions:titre_petitions',
60 'texte_objet' => 'petitions:titre_petition',
61
62 'titre' => "texte as titre, '' AS lang",
63
64 'field'=> array(
65 "id_petition" => "bigint(21) NOT NULL",
66 "id_article" => "bigint(21) DEFAULT '0' NOT NULL",
67 "email_unique" => "CHAR (3) DEFAULT '' NOT NULL",
68 "site_obli" => "CHAR (3) DEFAULT '' NOT NULL",
69 "site_unique" => "CHAR (3) DEFAULT '' NOT NULL",
70 "message" => "CHAR (3) DEFAULT '' NOT NULL",
71 "texte" => "LONGTEXT DEFAULT '' NOT NULL",
72 "statut" => "VARCHAR (10) DEFAULT 'publie' NOT NULL",
73 "maj" => "TIMESTAMP"
74 ),
75 'key' => array(
76 "PRIMARY KEY" => "id_petition",
77 "UNIQUE id_article" => "id_article"
78 ),
79 'statut' => array(
80 array('champ'=>'statut','publie'=>'publie,off','previsu'=>'publie,off','exception'=>array('statut')),
81 ),
82 );
83
84 $tables['spip_signatures'] = array(
85 'url_voir'=>'controler_petition',
86 'url_edit'=>'controler_petition',
87 'editable'=>'non',
88 'principale' => 'oui',
89 'page'=>'', // pas de page editoriale pour une signature
90
91 'texte_retour' => 'icone_retour',
92 'texte_objets' => 'public:signatures_petition',
93 'texte_objet' => 'entree_signature',
94 'info_aucun_objet'=> 'petitions:aucune_signature',
95 'info_1_objet' => 'petitions:une_signature',
96 'info_nb_objets' => 'petitions:nombre_signatures',
97 'titre' => "nom_email as titre, '' AS lang",
98 'date' => 'date_time',
99
100 'field'=> array(
101 "id_signature" => "bigint(21) NOT NULL",
102 "id_petition" => "bigint(21) DEFAULT '0' NOT NULL",
103 # "id_article" => "bigint(21) DEFAULT '0' NOT NULL",
104 "date_time" => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
105 "nom_email" => "text DEFAULT '' NOT NULL",
106 "ad_email" => "text DEFAULT '' NOT NULL",
107 "nom_site" => "text DEFAULT '' NOT NULL",
108 "url_site" => "text DEFAULT '' NOT NULL",
109 "message" => "mediumtext DEFAULT '' NOT NULL",
110 "statut" => "varchar(10) DEFAULT '0' NOT NULL",
111 "maj" => "TIMESTAMP"
112 ),
113 'key' => array(
114 "PRIMARY KEY" => "id_signature",
115 "KEY id_petition" => "id_petition",
116 # "KEY id_article" => "id_article",
117 "KEY statut" => "statut"
118 ),
119 'join' => array(
120 "id_signature"=>"id_signature",
121 "id_petition"=>"id_petition"
122 ),
123 'tables_jointures'=> array(
124 'petitions'
125 ),
126 'statut' => array(
127 array('champ'=>'statut','publie'=>'publie','previsu'=>'publie','exception'=>array('statut','tout')),
128 ),
129 'rechercher_champs' => array(
130 'nom_email' => 2, 'ad_email' => 4,
131 'nom_site' => 2, 'url_site' => 4,
132 'message' => 1
133 ),
134 'icone_objet' => 'petition',
135 );
136
137 return $tables;
138 }
139 ?>