c40462a7c268f1fa76b34be00baea3b38c996650
[ptitvelo/web/www.git] / www / plugins / agenda_3_5 / agenda_administrations.php
1 <?php
2 /**
3 * Plugin Agenda 4 pour Spip 3.0
4 * Licence GPL 3
5 *
6 * 2006-2011
7 * Auteurs : cf paquet.xml
8 */
9
10 if (!defined("_ECRIRE_INC_VERSION")) return;
11
12 /**
13 * Installation/maj des tables evenements et participants...
14 *
15 * @param string $nom_meta_base_version
16 * @param string $version_cible
17 */
18 function agenda_upgrade($nom_meta_base_version,$version_cible){
19
20
21 $maj = array();
22 $maj['create'] = array(
23 array('maj_tables',array('spip_evenements','spip_evenements_participants')),
24 array('sql_alter',"TABLE spip_rubriques ADD agenda tinyint(1) DEFAULT 0 NOT NULL"),
25 );
26 $maj['0.11'] = array(
27 array('sql_alter',"TABLE spip_evenements ADD `horaire` ENUM('oui','non') DEFAULT 'oui' NOT NULL AFTER `lieu`"),
28 );
29 $maj['0.12'] = array(
30 array('sql_alter',"TABLE spip_evenements ADD `id_article` bigint(21) DEFAULT '0' NOT NULL AFTER `id_evenement`"),
31 array('sql_alter',"TABLE spip_evenements ADD ADD INDEX ( `id_article` )"),
32 array('upgrade_evenements_articles_012'),
33 array('sql_drop_table',"spip_evenements_articles"),
34 );
35
36 $maj['0.13'] = array(
37 array('maj_tables',array('spip_evenements','spip_evenements_participants')),
38 );
39 $maj['0.18'] = array(
40 array('maj_tables',array('spip_evenements','spip_evenements_participants')),
41 array('sql_update',"spip_groupes_mots", array('tables_liees'=>"concat(tables_liees,'evenements,')"), "evenements='oui'"),
42 array('sql_alter',"TABLE spip_groupes_mots DROP evenements"),
43 );
44
45 $maj['0.20'] = array(
46 array('sql_alter',"TABLE spip_rubriques ADD agenda tinyint(1) DEFAULT 0 NOT NULL"),
47 );
48
49 $maj['0.21'] = array(
50 array('sql_alter',"TABLE spip_evenements ADD adresse text NOT NULL"),
51 array('sql_alter',"TABLE spip_evenements ADD inscription text NOT NULL"),
52 array('sql_alter',"TABLE spip_evenements ADD places text NOT NULL"),
53 );
54
55 $maj['0.22'] = array(
56 array('maj_tables',array('spip_evenements_participants')),
57 );
58
59 $maj['0.23'] = array(
60 array('sql_alter',"TABLE spip_evenements CHANGE titre titre text NOT NULL DEFAULT ''"),
61 array('sql_alter',"TABLE spip_evenements CHANGE descriptif descriptif text NOT NULL DEFAULT ''"),
62 array('sql_alter',"TABLE spip_evenements CHANGE lieu lieu text NOT NULL DEFAULT ''"),
63 array('sql_alter',"TABLE spip_evenements CHANGE adresse adresse text NOT NULL DEFAULT ''"),
64 );
65 include_spip('maj/svn10000');
66 $maj['0.24.0'] = array(
67 array('maj_liens','mot','evenement'),
68 array('sql_drop_table',"spip_mots_evenements"),
69 array('sql_alter',"TABLE spip_evenements ADD statut varchar(10) DEFAULT 0 NOT NULL"),
70 );
71 $maj['0.25.0'] = array(
72 array('upgrade_evenements_statut_025'),
73 );
74
75 include_spip('base/upgrade');
76 maj_plugin($nom_meta_base_version, $version_cible, $maj);
77 }
78
79 function agenda_vider_tables($nom_meta_base_version) {
80 sql_drop_table("spip_evenements");
81 #sql_drop_table("spip_mots_evenements"); // au cas ou ?
82 sql_alter("TABLE spip_rubriques DROP COLUMN agenda");
83 effacer_meta($nom_meta_base_version);
84 }
85
86 function upgrade_evenements_articles_012(){
87 $res = sql_select("*", "spip_evenements_articles");
88 while ($row = sql_fetch($res)){
89 $id_article = $row['id_article'];
90 $id_evenement = $row['id_evenement'];
91 sql_update("spip_evenements", array('id_article'=>$id_article),'id_evenement='.intval($id_evenement));
92 }
93 }
94
95 function upgrade_evenements_statut_025(){
96 include_spip('action/editer_evenement');
97 $res = sql_select('id_evenement','spip_evenements',"statut='0'");
98 while ($row = sql_fetch($res)){
99 evenement_modifier($row['id_evenement'],array());
100 }
101 }
102
103 ?>