From 704533fca7d695a71a46ac27ab9ae8f1de58d915 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20S=CC=8Ckoda?= Date: Sun, 19 Aug 2012 20:07:27 +0200 Subject: [PATCH] MDL-34960 drop deprecated Google Maps API V2 --- admin/settings/location.php | 1 - iplookup/index.php | 18 ++++-------------- iplookup/module.js | 21 +-------------------- lang/en/admin.php | 2 -- lib/db/upgrade.php | 7 +++++++ lib/upgrade.txt | 1 + version.php | 2 +- 7 files changed, 14 insertions(+), 38 deletions(-) diff --git a/admin/settings/location.php b/admin/settings/location.php index 9f74d519bb0..607090a529a 100644 --- a/admin/settings/location.php +++ b/admin/settings/location.php @@ -14,7 +14,6 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page $temp->add(new admin_setting_heading('iplookup', new lang_string('iplookup', 'admin'), new lang_string('iplookupinfo', 'admin'))); $temp->add(new admin_setting_configfile('geoipfile', new lang_string('geoipfile', 'admin'), new lang_string('configgeoipfile', 'admin', $CFG->dataroot.'/geoip/'), $CFG->dataroot.'/geoip/GeoLiteCity.dat')); - $temp->add(new admin_setting_configtext('googlemapkey', new lang_string('googlemapkey', 'admin'), new lang_string('configgooglemapkey', 'admin', $CFG->wwwroot), '', PARAM_RAW, 60)); $temp->add(new admin_setting_configtext('googlemapkey3', new lang_string('googlemapkey3', 'admin'), new lang_string('googlemapkey3_help', 'admin'), '', PARAM_RAW, 60)); $temp->add(new admin_setting_configtext('allcountrycodes', new lang_string('allcountrycodes', 'admin'), new lang_string('configallcountrycodes', 'admin'), '', '/^(?:\w+(?:,\w+)*)?$/')); diff --git a/iplookup/index.php b/iplookup/index.php index 40ec4c5ce62..92dd51ea462 100644 --- a/iplookup/index.php +++ b/iplookup/index.php @@ -1,5 +1,4 @@ iplookup)) { - //clean up of old settings + // Clean up of old settings. set_config('iplookup', NULL); } @@ -61,7 +59,7 @@ if ($match[1] == '127' or $match[1] == '10' or ($match[1] == '172' and $match[2] $info = iplookup_find_location($ip); if ($info['error']) { - // can not display + // Can not display. notice($info['error']); } @@ -80,7 +78,7 @@ $PAGE->set_title(get_string('iplookup', 'admin').': '.$title); $PAGE->set_heading($title); echo $OUTPUT->header(); -if (empty($CFG->googlemapkey) and empty($CFG->googlemapkey3)) { +if (empty($CFG->googlemapkey3)) { $imgwidth = 620; $imgheight = 310; $dotwidth = 18; @@ -95,14 +93,6 @@ if (empty($CFG->googlemapkey) and empty($CFG->googlemapkey3)) { echo ''; echo '
'.$info['note'].'
'; -} else if (empty($CFG->googlemapkey3)) { - $PAGE->requires->js(new moodle_url("http://maps.google.com/maps?file=api&v=2&key=$CFG->googlemapkey")); - $module = array('name'=>'core_iplookup', 'fullpath'=>'/iplookup/module.js'); - $PAGE->requires->js_init_call('M.core_iplookup.init', array($info['latitude'], $info['longitude']), true, $module); - - echo '
'; - echo '
'.$info['note'].'
'; - } else { if (strpos($CFG->wwwroot, 'https:') === 0) { $PAGE->requires->js(new moodle_url('https://maps.googleapis.com/maps/api/js', array('key'=>$CFG->googlemapkey3, 'sensor'=>'false'))); diff --git a/iplookup/module.js b/iplookup/module.js index 004b7d24706..d706caf270d 100644 --- a/iplookup/module.js +++ b/iplookup/module.js @@ -16,32 +16,13 @@ /** * Iplookup utility functions * - * @package core - * @subpackage iplookup + * @package core_iplookup * @copyright 2008 Petr Skoda (http://skodak.org) * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ M.core_iplookup = {}; -M.core_iplookup.init = function(Y, latitude, longitude) { - if (GBrowserIsCompatible()) { - var map = new GMap2(document.getElementById("map")); - map.addControl(new GSmallMapControl()); - map.addControl(new GMapTypeControl()); - var point = new GLatLng(latitude, longitude); - map.setCenter(point, 4); - map.addOverlay(new GMarker(point)); - map.setMapType(G_HYBRID_MAP); - - Y.on('unload', function() { - if (GBrowserIsCompatible()) { - GUnload(); - } - }, document.body); - } -}; - M.core_iplookup.init3 = function(Y, latitude, longitude, ip) { var ipLatlng = new google.maps.LatLng(latitude, longitude); diff --git a/lang/en/admin.php b/lang/en/admin.php index 75d531e1a58..b7670dd0b8f 100644 --- a/lang/en/admin.php +++ b/lang/en/admin.php @@ -219,7 +219,6 @@ $string['configfullnamedisplay'] = 'This defines how names are shown when they a $string['configgdversion'] = 'Indicate the version of GD that is installed. The version shown by default is the one that has been auto-detected. Don\'t change this unless you really know what you\'re doing.'; $string['configgeoipfile'] = 'Location of GeoIP City binary data file. This file is not part of Moodle distribution and must be obtained separately from MaxMind. You can either buy a commercial version or use the free version.
Simply download http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz and extract it into "{$a}" directory on your server.'; $string['configgetremoteaddrconf'] = 'If your server is behind a reverse proxy, you can use this setting to specify which HTTP headers can be trusted to contain the remote IP address. The headers are read in order, using the first one that is available.'; -$string['configgooglemapkey'] = 'You need to enter a special key to use Google Maps for IP address lookup visualization. You can obtain the key free of charge at https://developers.google.com/maps/documentation/javascript/v2/introduction#Obtaining_Key.
Your web site URL is: {$a}'; $string['configgradebookroles'] = 'This setting allows you to control who appears on the gradebook. Users need to have at least one of these roles in a course to be shown in the gradebook for that course.'; $string['configgradeexport'] = 'Choose which gradebook export formats are your primary methods for exporting grades. Chosen plugins will then set and use a "last exported" field for every grade. For example, this might result in exported records being identified as being "new" or "updated". If you are not sure about this then leave everything unchecked.'; $string['confighiddenuserfields'] = 'Select which user information fields you wish to hide from other users other than course teachers/admins. This will increase student privacy. Hold CTRL key to select multiple fields.'; @@ -546,7 +545,6 @@ $string['globalsquoteswarning'] = '

Security Warning: to oper $string['globalswarning'] = '

SECURITY WARNING!

To operate properly, Moodle requires
that you make certain changes to your current PHP settings.

You must set register_globals=off.

This setting is controlled by editing your php.ini, Apache/IIS
configuration or .htaccess file.

'; $string['groupenrolmentkeypolicy'] = 'Group enrolment key policy'; $string['groupenrolmentkeypolicy_desc'] = 'Turning this on will make Moodle check group enrolment keys against a valid password policy.'; -$string['googlemapkey'] = 'Google Maps API V2 key'; $string['googlemapkey3'] = 'Google Maps API V3 key'; $string['googlemapkey3_help'] = 'You need to enter a special key to use Google Maps for IP address lookup visualization. You can obtain the key free of charge at https://developers.google.com/maps/documentation/javascript/tutorial#api_key'; $string['gotofirst'] = 'Go to first missing string'; diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 6315ca1b870..d5b98563d2c 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -1113,5 +1113,12 @@ function xmldb_main_upgrade($oldversion) { upgrade_main_savepoint(true, 2012081400.01); } + if ($oldversion < 2012081600.01) { + // Delete removed setting - Google Maps API V2 will not work in 2013. + unset_config('googlemapkey'); + upgrade_main_savepoint(true, 2012081600.01); + } + + return true; } diff --git a/lib/upgrade.txt b/lib/upgrade.txt index 36e54e4ab0d..34db5a016a0 100644 --- a/lib/upgrade.txt +++ b/lib/upgrade.txt @@ -5,6 +5,7 @@ information provided here is intended especially for developers. * Pagelib: Numerous deprecated functions were removed as classes page_base, page_course and page_generic_activity. +* use $CFG->googlemapkey3 instead of removed $CFG->googlemapkey and migrate to Google Maps API V3 YUI changes: * moodle-enrol-notification has been renamed to moodle-core-notification diff --git a/version.php b/version.php index f1e652ea222..782b4a60621 100644 --- a/version.php +++ b/version.php @@ -30,7 +30,7 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2012081600.00; // YYYYMMDD = weekly release date of this DEV branch +$version = 2012081600.01; // YYYYMMDD = weekly release date of this DEV branch // RR = release increments - 00 in DEV branches // .XX = incremental changes