summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorg Ehrke <dev@georgswebsite.de>2012-02-26 13:45:51 +0100
committerGeorg Ehrke <dev@georgswebsite.de>2012-02-26 13:45:51 +0100
commit89865cb8a0ca668f628e6e3e6a43bca7e72eab63 (patch)
treec19925c96dd0ed45f39e8bc16bccd49e4e92703a
parent92c7b2717d4cff555ac8037b2b7dc5c59a79f493 (diff)
downloadnextcloud-server-89865cb8a0ca668f628e6e3e6a43bca7e72eab63.tar.gz
nextcloud-server-89865cb8a0ca668f628e6e3e6a43bca7e72eab63.zip
stop using 3rdparty services for timezone detection
-rwxr-xr-xapps/calendar/ajax/settings/guesstimezone.php45
-rwxr-xr-xapps/calendar/js/geo.js1
2 files changed, 12 insertions, 34 deletions
diff --git a/apps/calendar/ajax/settings/guesstimezone.php b/apps/calendar/ajax/settings/guesstimezone.php
index cfa92e1aee8..d45a70e1ce3 100755
--- a/apps/calendar/ajax/settings/guesstimezone.php
+++ b/apps/calendar/ajax/settings/guesstimezone.php
@@ -5,44 +5,23 @@
* later.
* See the COPYING-README file.
*/
-function make_array_out_of_xml ($xml){
- $returnarray = array();
- $xml = (array)$xml ;
- foreach ($xml as $property => $value){
- $value = (array)$value;
- if(!isset($value[0])){
- $returnarray[$property] = make_array_out_of_xml($value);
- }else{
- $returnarray[$property] = trim($value[0]);
- }
- }
- return $returnarray;
-}
require_once('../../../../lib/base.php');
+
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('calendar');
+
$l = new OC_L10N('calendar');
+
$lat = $_GET['lat'];
-$long = $_GET['long'];
-if(OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'position') == $lat . '-' . $long && OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone') != null){
- OC_JSON::success();
- exit;
-}
-OC_Preferences::setValue(OC_USER::getUser(), 'calendar', 'position', $lat . '-' . $long);
-$geolocation = file_get_contents('http://ws.geonames.org/timezone?lat=' . $lat . '&lng=' . $long);
-//Information are by Geonames (http://www.geonames.org) and licensed under the Creative Commons Attribution 3.0 License
-$geoxml = simplexml_load_string($geolocation);
-$geoarray = make_array_out_of_xml($geoxml);
-if($geoarray['timezone']['timezoneId'] == OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone')){
+$lng = $_GET['long'];
+
+$timezone = OC_Geo::timezone($lat, $lng);
+
+if($timezone == OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone')){
OC_JSON::success();
exit;
}
-if(in_array($geoarray['timezone']['timezoneId'], DateTimeZone::listIdentifiers())){
- OC_Preferences::setValue(OC_USER::getUser(), 'calendar', 'timezone', $geoarray['timezone']['timezoneId']);
- $message = array('message'=> $l->t('New Timezone:') . $geoarray['timezone']['timezoneId']);
- OC_JSON::success($message);
-}else{
- OC_JSON::error();
-}
-
-?>
+OC_Preferences::setValue(OC_USER::getUser(), 'calendar', 'timezone', $timezone);
+$message = array('message'=> $l->t('New Timezone:') . $timezone);
+OC_JSON::success($message);
+?> \ No newline at end of file
diff --git a/apps/calendar/js/geo.js b/apps/calendar/js/geo.js
index c9cc5dd0955..7018c6298a2 100755
--- a/apps/calendar/js/geo.js
+++ b/apps/calendar/js/geo.js
@@ -10,7 +10,6 @@ if (navigator.geolocation) {
function(data){
if (data.status == 'success' && typeof(data.message) != 'undefined'){
$('#notification').html(data.message);
- $('#notification').attr('title', 'CC BY 3.0 by Geonames.org');
$('#notification').slideDown();
window.setTimeout(function(){$('#notification').slideUp();}, 5000);
}else{