1 | <?php |
---|
2 | /* |
---|
3 | Version: 1.1 |
---|
4 | Plugin Name: Psli-BingMaps |
---|
5 | Author: psli |
---|
6 | Description: Maintenance function for plugin "Psli-BingMaps" |
---|
7 | */ |
---|
8 | |
---|
9 | // Chech whether we are indeed included by Piwigo. |
---|
10 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
11 | |
---|
12 | // Include define data |
---|
13 | include_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 | /********************************************************************************************/ |
---|
19 | function plugin_install($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 | $sql = 'INSERT INTO '.CONFIG_TABLE." (param, value) VALUES ('".PSLI_CONF_PATH."', 'http://".$_SERVER['HTTP_HOST'].substr($_SERVER['REQUEST_URI'],0, strrpos($_SERVER['REQUEST_URI'],"/"))."/');"; |
---|
70 | pwg_query($sql); |
---|
71 | |
---|
72 | } |
---|
73 | |
---|
74 | /********************************************************************************************/ |
---|
75 | // Plugin deactivation |
---|
76 | // Destroy tables and parameters created by plugin |
---|
77 | /********************************************************************************************/ |
---|
78 | function plugin_uninstall($plugin_id) |
---|
79 | { |
---|
80 | global $prefixeTable; |
---|
81 | $sql = 'DROP TABLE `'.PSLI_ENTITIES_TABLE.'`;'; |
---|
82 | pwg_query($sql); |
---|
83 | $sql = 'DROP TABLE `'.PSLI_DATAPOINT_TABLE.'`;'; |
---|
84 | pwg_query($sql); |
---|
85 | $sql = 'DELETE FROM `'.CONFIG_TABLE."` WHERE param = '".PSLI_CONF_LAT."';"; |
---|
86 | pwg_query($sql); |
---|
87 | $sql = 'DELETE FROM `'.CONFIG_TABLE."` WHERE param = '".PSLI_CONF_LON."';"; |
---|
88 | pwg_query($sql); |
---|
89 | $sql = 'DELETE FROM `'.CONFIG_TABLE."` WHERE param = '".PSLI_CONF_ZOOM."';"; |
---|
90 | pwg_query($sql); |
---|
91 | $sql = 'DELETE FROM `'.CONFIG_TABLE."` WHERE param = '".PSLI_CONF_KEY."';"; |
---|
92 | pwg_query($sql); |
---|
93 | $sql = 'DELETE FROM `'.CONFIG_TABLE."` WHERE param = '".PSLI_CONF_CATEGORY."';"; |
---|
94 | pwg_query($sql); |
---|
95 | $sql = 'DELETE FROM `'.CONFIG_TABLE."` WHERE param = '".PSLI_CONF_VERSION_MAJ."';"; |
---|
96 | pwg_query($sql); |
---|
97 | $sql = 'DELETE FROM `'.CONFIG_TABLE."` WHERE param = '".PSLI_CONF_VERSION_MIN."';"; |
---|
98 | pwg_query($sql); |
---|
99 | } |
---|
100 | |
---|
101 | ?> |
---|