1 | <?php |
---|
2 | function plugin_install() |
---|
3 | { |
---|
4 | $q = ' |
---|
5 | ALTER TABLE '.IMAGES_TABLE.' ADD COLUMN `lat` DOUBLE(8,6)'; |
---|
6 | pwg_query($q); |
---|
7 | |
---|
8 | $q = ' |
---|
9 | ALTER TABLE '.IMAGES_TABLE.' ADD INDEX images_lat(`lat`)'; |
---|
10 | pwg_query($q); |
---|
11 | |
---|
12 | $q = ' |
---|
13 | ALTER TABLE '.IMAGES_TABLE.' ADD COLUMN `lon` DOUBLE(9,6)'; |
---|
14 | pwg_query($q); |
---|
15 | |
---|
16 | $q = ' |
---|
17 | INSERT INTO '.CONFIG_TABLE.' (param,value,comment) |
---|
18 | VALUES |
---|
19 | ("gmaps_api_key","","Google Maps API key") |
---|
20 | ;'; |
---|
21 | pwg_query($q); |
---|
22 | } |
---|
23 | |
---|
24 | function plugin_activate() |
---|
25 | { |
---|
26 | global $conf; |
---|
27 | |
---|
28 | if (!isset($conf['rv_gmaps_add_map.php']) or $conf['rv_gmaps_add_map.php']) |
---|
29 | { |
---|
30 | $dir_name = basename( dirname(__FILE__) ); |
---|
31 | $c = <<<EOD |
---|
32 | <?php |
---|
33 | define('PHPWG_ROOT_PATH','./'); |
---|
34 | include_once( PHPWG_ROOT_PATH. 'plugins/$dir_name/map.php'); |
---|
35 | ?> |
---|
36 | EOD; |
---|
37 | $fp = fopen( PHPWG_ROOT_PATH.'map.php', 'w' ); |
---|
38 | fwrite( $fp, $c); |
---|
39 | fclose( $fp ); |
---|
40 | } |
---|
41 | |
---|
42 | $old = dirname(__FILE__).'/_rvgm_config.dat'; |
---|
43 | if ( is_file($old) ) |
---|
44 | { |
---|
45 | global $conf; |
---|
46 | $dest = PHPWG_ROOT_PATH.$conf['data_location'].'/plugins/'.basename(dirname(__FILE__)).'.dat'; |
---|
47 | if (!file_exists($dest) ) |
---|
48 | { |
---|
49 | mkgetdir( dirname($dest) ); |
---|
50 | copy( $old, $dest ); |
---|
51 | } |
---|
52 | unlink( $old ); |
---|
53 | } |
---|
54 | } |
---|
55 | |
---|
56 | function plugin_deactivate() |
---|
57 | { |
---|
58 | global $conf; |
---|
59 | |
---|
60 | if (!isset($conf['rv_gmaps_remove_map.php']) or $conf['rv_gmaps_remove_map.php']) |
---|
61 | { |
---|
62 | @unlink( PHPWG_ROOT_PATH.'map.php' ); |
---|
63 | } |
---|
64 | |
---|
65 | rvm_invalidate_cache(); |
---|
66 | } |
---|
67 | |
---|
68 | function plugin_uninstall() |
---|
69 | { |
---|
70 | $q = ' |
---|
71 | ALTER TABLE '.IMAGES_TABLE.' DROP COLUMN `lat`'; |
---|
72 | pwg_query( $q ); |
---|
73 | |
---|
74 | $q = ' |
---|
75 | ALTER TABLE '.IMAGES_TABLE.' DROP COLUMN `lon`'; |
---|
76 | pwg_query( $q ); |
---|
77 | |
---|
78 | $q = ' |
---|
79 | DELETE FROM '.CONFIG_TABLE.' WHERE param IN("gmaps_api_key","gmaps_auto_sync")'; |
---|
80 | pwg_query( $q ); |
---|
81 | |
---|
82 | global $conf; |
---|
83 | $dest = PHPWG_ROOT_PATH.$conf['data_location'].'/plugins/'.basename(dirname(__FILE__)).'.dat'; |
---|
84 | @unlink( $dest ); |
---|
85 | } |
---|
86 | |
---|
87 | ?> |
---|