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