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 "lat";'; |
---|
28 | if (pwg_db_num_rows(pwg_query($query))) |
---|
29 | rvgm_drop_old_columns(); |
---|
30 | pwg_query('DELETE FROM '.CONFIG_TABLE.' WHERE param IN("gmaps_auto_sync")'); |
---|
31 | |
---|
32 | if (!isset($conf['rv_gmaps_add_map.php']) or $conf['rv_gmaps_add_map.php']) |
---|
33 | { |
---|
34 | $dir_name = basename( dirname(__FILE__) ); |
---|
35 | $c = <<<EOD |
---|
36 | <?php |
---|
37 | define('PHPWG_ROOT_PATH','./'); |
---|
38 | include_once( PHPWG_ROOT_PATH. 'plugins/$dir_name/map.php'); |
---|
39 | ?> |
---|
40 | EOD; |
---|
41 | $fp = fopen( PHPWG_ROOT_PATH.'map.php', 'w' ); |
---|
42 | fwrite( $fp, $c); |
---|
43 | fclose( $fp ); |
---|
44 | } |
---|
45 | |
---|
46 | $old = dirname(__FILE__).'/_rvgm_config.dat'; |
---|
47 | if ( is_file($old) ) |
---|
48 | { |
---|
49 | global $conf; |
---|
50 | $dest = PHPWG_ROOT_PATH.$conf['data_location'].'/plugins/'.basename(dirname(__FILE__)).'.dat'; |
---|
51 | if (!file_exists($dest) ) |
---|
52 | { |
---|
53 | mkgetdir( dirname($dest) ); |
---|
54 | copy( $old, $dest ); |
---|
55 | } |
---|
56 | unlink( $old ); |
---|
57 | } |
---|
58 | } |
---|
59 | |
---|
60 | function plugin_deactivate() |
---|
61 | { |
---|
62 | global $conf; |
---|
63 | |
---|
64 | if (!isset($conf['rv_gmaps_remove_map.php']) or $conf['rv_gmaps_remove_map.php']) |
---|
65 | { |
---|
66 | @unlink( PHPWG_ROOT_PATH.'map.php' ); |
---|
67 | } |
---|
68 | } |
---|
69 | |
---|
70 | function plugin_uninstall() |
---|
71 | { |
---|
72 | rvgm_drop_old_columns(); |
---|
73 | |
---|
74 | $q = ' |
---|
75 | DELETE FROM '.CONFIG_TABLE.' WHERE param IN("gmaps_api_key","gmaps_auto_sync")'; |
---|
76 | pwg_query( $q ); |
---|
77 | |
---|
78 | global $conf; |
---|
79 | $dest = PHPWG_ROOT_PATH.$conf['data_location'].'/plugins/'.basename(dirname(__FILE__)).'.dat'; |
---|
80 | @unlink( $dest ); |
---|
81 | } |
---|
82 | |
---|
83 | ?> |
---|