3 * Plugin Agenda 4 pour Spip 3.0
7 * Auteurs : cf paquet.xml
10 if (!defined("_ECRIRE_INC_VERSION")) return;
13 * Installation/maj des tables evenements et participants...
15 * @param string $nom_meta_base_version
16 * @param string $version_cible
18 function agenda_upgrade($nom_meta_base_version,$version_cible){
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"),
27 array('sql_alter',"TABLE spip_evenements ADD `horaire` ENUM('oui','non') DEFAULT 'oui' NOT NULL AFTER `lieu`"),
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"),
37 array('maj_tables',array('spip_evenements','spip_evenements_participants')),
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"),
46 array('sql_alter',"TABLE spip_rubriques ADD agenda tinyint(1) DEFAULT 0 NOT NULL"),
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"),
56 array('maj_tables',array('spip_evenements_participants')),
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 ''"),
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"),
72 $maj['0.25.0'] = array(
73 array('upgrade_evenements_statut_025'),
76 $maj['0.26.0'] = array(
77 array('maj_tables',array('spip_evenements')),
78 array('sql_update',"spip_evenements", array('date_creation'=>'maj')),
81 $maj['0.27.0'] = array(
82 // modification de la cle primaire (id_evenement,id_auteur) : les participants peuvent ne pas être des auteurs
83 // ajout d'une clé primaire "neutre" auto-incrémentée
84 array('sql_alter','TABLE spip_evenements_participants DROP PRIMARY KEY'),
85 array('sql_alter','TABLE spip_evenements_participants ADD id_evenement_participant BIGINT(21) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST'),
86 array('maj_tables',array('spip_evenements_participants')),
89 include_spip('base/upgrade');
90 maj_plugin($nom_meta_base_version, $version_cible, $maj);
93 function agenda_vider_tables($nom_meta_base_version) {
94 sql_drop_table("spip_evenements");
95 #sql_drop_table("spip_mots_evenements"); // au cas ou ?
96 sql_alter("TABLE spip_rubriques DROP COLUMN agenda");
97 effacer_meta($nom_meta_base_version);
100 function upgrade_evenements_articles_012(){
101 $res = sql_select("*", "spip_evenements_articles");
102 while ($row = sql_fetch($res)){
103 $id_article = $row['id_article'];
104 $id_evenement = $row['id_evenement'];
105 sql_update("spip_evenements", array('id_article'=>$id_article),'id_evenement='.intval($id_evenement));
109 function upgrade_evenements_statut_025(){
110 include_spip('action/editer_evenement');
111 $res = sql_select('id_evenement','spip_evenements',"statut='0'");
112 while ($row = sql_fetch($res)){
113 evenement_modifier($row['id_evenement'],array());