[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 | |
---|
[29335] | 27 | $query = 'SHOW COLUMNS FROM '. IMAGES_TABLE .' LIKE "lat";'; |
---|
| 28 | if (pwg_db_num_rows(pwg_query($query))) |
---|
[26331] | 29 | rvgm_drop_old_columns(); |
---|
| 30 | pwg_query('DELETE FROM '.CONFIG_TABLE.' WHERE param IN("gmaps_auto_sync")'); |
---|
| 31 | |
---|
[16974] | 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 |
---|
[3447] | 36 | <?php |
---|
| 37 | define('PHPWG_ROOT_PATH','./'); |
---|
| 38 | include_once( PHPWG_ROOT_PATH. 'plugins/$dir_name/map.php'); |
---|
| 39 | ?> |
---|
| 40 | EOD; |
---|
[16974] | 41 | $fp = fopen( PHPWG_ROOT_PATH.'map.php', 'w' ); |
---|
| 42 | fwrite( $fp, $c); |
---|
| 43 | fclose( $fp ); |
---|
| 44 | } |
---|
[3447] | 45 | |
---|
| 46 | $old = dirname(__FILE__).'/_rvgm_config.dat'; |
---|
| 47 | if ( is_file($old) ) |
---|
| 48 | { |
---|
| 49 | global $conf; |
---|
[13092] | 50 | $dest = PHPWG_ROOT_PATH.$conf['data_location'].'/plugins/'.basename(dirname(__FILE__)).'.dat'; |
---|
[3447] | 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 | { |
---|
[16974] | 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 | } |
---|
[3447] | 68 | } |
---|
| 69 | |
---|
| 70 | function plugin_uninstall() |
---|
| 71 | { |
---|
[26331] | 72 | rvgm_drop_old_columns(); |
---|
[3447] | 73 | |
---|
| 74 | $q = ' |
---|
[12701] | 75 | DELETE FROM '.CONFIG_TABLE.' WHERE param IN("gmaps_api_key","gmaps_auto_sync")'; |
---|
[3447] | 76 | pwg_query( $q ); |
---|
| 77 | |
---|
| 78 | global $conf; |
---|
[13092] | 79 | $dest = PHPWG_ROOT_PATH.$conf['data_location'].'/plugins/'.basename(dirname(__FILE__)).'.dat'; |
---|
[3447] | 80 | @unlink( $dest ); |
---|
| 81 | } |
---|
| 82 | |
---|
| 83 | ?> |
---|