[3447] | 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 | $dir_name = basename( dirname(__FILE__) ); |
---|
| 27 | $c = <<<EOD |
---|
| 28 | <?php |
---|
| 29 | define('PHPWG_ROOT_PATH','./'); |
---|
| 30 | include_once( PHPWG_ROOT_PATH. 'plugins/$dir_name/map.php'); |
---|
| 31 | ?> |
---|
| 32 | EOD; |
---|
| 33 | $fp = fopen( PHPWG_ROOT_PATH.'map.php', 'w' ); |
---|
| 34 | fwrite( $fp, $c); |
---|
| 35 | fclose( $fp ); |
---|
| 36 | |
---|
| 37 | $old = dirname(__FILE__).'/_rvgm_config.dat'; |
---|
| 38 | if ( is_file($old) ) |
---|
| 39 | { |
---|
| 40 | global $conf; |
---|
| 41 | $dest = $conf['local_data_dir'].'/plugins/'.basename(dirname(__FILE__)).'.dat'; |
---|
| 42 | if (!file_exists($dest) ) |
---|
| 43 | { |
---|
| 44 | mkgetdir( dirname($dest) ); |
---|
| 45 | copy( $old, $dest ); |
---|
| 46 | } |
---|
| 47 | unlink( $old ); |
---|
| 48 | } |
---|
| 49 | } |
---|
| 50 | |
---|
| 51 | function plugin_deactivate() |
---|
| 52 | { |
---|
| 53 | @unlink( PHPWG_ROOT_PATH.'map.php' ); |
---|
| 54 | rvm_invalidate_cache(); |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | function plugin_uninstall() |
---|
| 58 | { |
---|
| 59 | $q = ' |
---|
| 60 | ALTER TABLE '.IMAGES_TABLE.' DROP COLUMN `lat`'; |
---|
| 61 | pwg_query( $q ); |
---|
| 62 | |
---|
| 63 | $q = ' |
---|
| 64 | ALTER TABLE '.IMAGES_TABLE.' DROP COLUMN `lon`'; |
---|
| 65 | pwg_query( $q ); |
---|
| 66 | |
---|
| 67 | $q = ' |
---|
| 68 | DELETE FROM '.CONFIG_TABLE.' WHERE param="gmaps_api_key" LIMIT 1'; |
---|
| 69 | pwg_query( $q ); |
---|
| 70 | |
---|
| 71 | global $conf; |
---|
| 72 | $dest = $conf['local_data_dir'].'/plugins/'.basename(dirname(__FILE__)).'.dat'; |
---|
| 73 | @unlink( $dest ); |
---|
| 74 | } |
---|
| 75 | |
---|
| 76 | ?> |
---|