source: extensions/Psli_BingMaps/maintain.inc.php @ 14872

Last change on this file since 14872 was 14872, checked in by psli, 9 years ago
File size: 3.6 KB
Line 
1<?php
2/*
3Version: 1.1
4Plugin Name: Psli-BingMaps
5Author: psli
6Description: Maintenance function for plugin "Psli-BingMaps"
7*/
8
9// Chech whether we are indeed included by Piwigo.
10if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
11
12// Include define data
13include_once(dirname(__FILE__).'/include/const.inc.php');
14
15/********************************************************************************************/
16//               Plugin activation
17// Create all needed tables and parameters ( with value by default) in CONFIG_TABLE
18/********************************************************************************************/
19function plugin_activate($plugin_id, $plugin_version, &$errors)
20{
21        global $prefixeTable;
22       
23        $sql = '
24                CREATE TABLE IF NOT EXISTS `'.PSLI_ENTITIES_TABLE."` (
25                        `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
26                        `lat` decimal(15,12) DEFAULT '0.000000000000',
27                        `lon` decimal(15,12) DEFAULT '0.000000000000',
28                        `title` text,
29                        `id_category` smallint(5) unsigned DEFAULT NULL,
30                        `zoomMin` smallint(6) DEFAULT NULL,
31                        `zoomMax` smallint(6) DEFAULT NULL,
32                        `action` smallint(6) DEFAULT NULL,
33                        PRIMARY KEY (`id`),
34                        UNIQUE KEY `psli_i10` (`id_category`)
35                ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;";
36        pwg_query($sql);
37       
38        $sql = '
39                CREATE TABLE IF NOT EXISTS `'.PSLI_DATAPOINT_TABLE.'` (
40                        `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
41                        `id_entity` smallint(5) unsigned,
42                        `lat` decimal(20,17) DEFAULT NULL,
43                        `lon` decimal(20,17) DEFAULT NULL,
44                        PRIMARY KEY (`id`)
45                ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;';
46        pwg_query($sql);
47       
48        $sql = 'INSERT INTO '.CONFIG_TABLE." (param, value) VALUES ('".PSLI_CONF_LON."', '0');";
49    pwg_query($sql);
50       
51        $sql = 'INSERT INTO '.CONFIG_TABLE." (param, value) VALUES ('".PSLI_CONF_LAT."', '0');";
52    pwg_query($sql);
53       
54        $sql = 'INSERT INTO '.CONFIG_TABLE." (param, value) VALUES ('".PSLI_CONF_ZOOM."', '2');";
55    pwg_query($sql);
56       
57        $sql = 'INSERT INTO '.CONFIG_TABLE." (param, value) VALUES ('".PSLI_CONF_KEY."', 'to define');";
58    pwg_query($sql);
59       
60        $sql = 'INSERT INTO '.CONFIG_TABLE." (param, value) VALUES ('".PSLI_CONF_CATEGORY."', 'to define');";
61    pwg_query($sql);
62
63        $sql = 'INSERT INTO '.CONFIG_TABLE." (param, value) VALUES ('".PSLI_CONF_VERSION_MAJ."', '".PSLI_VERSION_MAJ."');";
64    pwg_query($sql);
65       
66        $sql = 'INSERT INTO '.CONFIG_TABLE." (param, value) VALUES ('".PSLI_CONF_VERSION_MIN."', '".PSLI_VERSION_MIN."');";
67    pwg_query($sql);   
68}
69
70/********************************************************************************************/
71//               Plugin deactivation
72// Destroy tables and parameters created by plugin
73/********************************************************************************************/
74function plugin_deactivate($plugin_id)
75{
76        global $prefixeTable;
77        $sql = 'DROP TABLE `'.PSLI_ENTITIES_TABLE.'`;';
78        pwg_query($sql);
79        $sql = 'DROP TABLE `'.PSLI_DATAPOINT_TABLE.'`;';
80        pwg_query($sql);
81        $sql = 'DELETE FROM `'.CONFIG_TABLE."` WHERE param = '".PSLI_CONF_LAT."';";
82        pwg_query($sql);
83        $sql = 'DELETE FROM `'.CONFIG_TABLE."` WHERE param = '".PSLI_CONF_LON."';";
84        pwg_query($sql);
85        $sql = 'DELETE FROM `'.CONFIG_TABLE."` WHERE param = '".PSLI_CONF_ZOOM."';";
86        pwg_query($sql);
87        $sql = 'DELETE FROM `'.CONFIG_TABLE."` WHERE param = '".PSLI_CONF_KEY."';";
88        pwg_query($sql);
89        $sql = 'DELETE FROM `'.CONFIG_TABLE."` WHERE param = '".PSLI_CONF_CATEGORY."';";
90        pwg_query($sql);
91        $sql = 'DELETE FROM `'.CONFIG_TABLE."` WHERE param = '".PSLI_CONF_VERSION_MAJ."';";
92        pwg_query($sql);
93        $sql = 'DELETE FROM `'.CONFIG_TABLE."` WHERE param = '".PSLI_CONF_VERSION_MIN."';";
94        pwg_query($sql);
95}
96
97?>
Note: See TracBrowser for help on using the repository browser.