[3447] | 1 | <?php |
---|
[26331] | 2 | function rvgm_drop_old_columns() |
---|
[3447] | 3 | { |
---|
| 4 | $q = ' |
---|
[26331] | 5 | ALTER TABLE '.IMAGES_TABLE.' DROP COLUMN `lat`'; |
---|
| 6 | pwg_query( $q ); |
---|
| 7 | |
---|
[3447] | 8 | $q = ' |
---|
[26331] | 9 | ALTER TABLE '.IMAGES_TABLE.' DROP COLUMN `lon`'; |
---|
| 10 | pwg_query( $q ); |
---|
| 11 | } |
---|
[3447] | 12 | |
---|
[26331] | 13 | function plugin_install() |
---|
| 14 | { |
---|
[3447] | 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 | { |
---|
[16974] | 25 | global $conf; |
---|
| 26 | |
---|
[26331] | 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 | |
---|
[16974] | 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 |
---|
[3447] | 37 | <?php |
---|
| 38 | define('PHPWG_ROOT_PATH','./'); |
---|
| 39 | include_once( PHPWG_ROOT_PATH. 'plugins/$dir_name/map.php'); |
---|
| 40 | ?> |
---|
| 41 | EOD; |
---|
[16974] | 42 | $fp = fopen( PHPWG_ROOT_PATH.'map.php', 'w' ); |
---|
| 43 | fwrite( $fp, $c); |
---|
| 44 | fclose( $fp ); |
---|
| 45 | } |
---|
[3447] | 46 | |
---|
| 47 | $old = dirname(__FILE__).'/_rvgm_config.dat'; |
---|
| 48 | if ( is_file($old) ) |
---|
| 49 | { |
---|
| 50 | global $conf; |
---|
[13092] | 51 | $dest = PHPWG_ROOT_PATH.$conf['data_location'].'/plugins/'.basename(dirname(__FILE__)).'.dat'; |
---|
[3447] | 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 | { |
---|
[16974] | 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 | |
---|
[3447] | 70 | rvm_invalidate_cache(); |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | function plugin_uninstall() |
---|
| 74 | { |
---|
[26331] | 75 | rvgm_drop_old_columns(); |
---|
[3447] | 76 | |
---|
| 77 | $q = ' |
---|
[12701] | 78 | DELETE FROM '.CONFIG_TABLE.' WHERE param IN("gmaps_api_key","gmaps_auto_sync")'; |
---|
[3447] | 79 | pwg_query( $q ); |
---|
| 80 | |
---|
| 81 | global $conf; |
---|
[13092] | 82 | $dest = PHPWG_ROOT_PATH.$conf['data_location'].'/plugins/'.basename(dirname(__FILE__)).'.dat'; |
---|
[3447] | 83 | @unlink( $dest ); |
---|
| 84 | } |
---|
| 85 | |
---|
| 86 | ?> |
---|