diff options
author | Georg Ehrke <ownclouddev@georgswebsite.de> | 2012-01-02 11:35:50 +0100 |
---|---|---|
committer | Georg Ehrke <ownclouddev@georgswebsite.de> | 2012-01-02 11:35:50 +0100 |
commit | e6739d230eec61af1ee99c4c17b53195552fe809 (patch) | |
tree | 50c94babbe204cabcc2f6b4422319642bce7e334 /apps/calendar | |
parent | 3bb11db943490e3f9cc1643c30f23f81ee976319 (diff) | |
download | nextcloud-server-e6739d230eec61af1ee99c4c17b53195552fe809.tar.gz nextcloud-server-e6739d230eec61af1ee99c4c17b53195552fe809.zip |
add function to detect always the timezone
Diffstat (limited to 'apps/calendar')
-rw-r--r-- | apps/calendar/ajax/gettimezonedetection.php | 11 | ||||
-rwxr-xr-x | apps/calendar/ajax/guesstimezone.php | 13 | ||||
-rw-r--r-- | apps/calendar/ajax/timezonedetection.php | 17 | ||||
-rw-r--r-- | apps/calendar/index.php | 2 | ||||
-rwxr-xr-x | apps/calendar/js/geo.js | 2 | ||||
-rw-r--r-- | apps/calendar/js/settings.js | 11 | ||||
-rw-r--r-- | apps/calendar/templates/settings.php | 2 |
7 files changed, 53 insertions, 5 deletions
diff --git a/apps/calendar/ajax/gettimezonedetection.php b/apps/calendar/ajax/gettimezonedetection.php new file mode 100644 index 00000000000..ae58370712d --- /dev/null +++ b/apps/calendar/ajax/gettimezonedetection.php @@ -0,0 +1,11 @@ +<?php +/** + * Copyright (c) 2011, 2012 Georg Ehrke <ownclouddev at georgswebsite dot de> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ +require_once ("../../../lib/base.php"); +OC_JSON::checkLoggedIn(); +OC_JSON::checkAppEnabled('calendar'); +OC_JSON::success(array('detection' => OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezonedetection')));
\ No newline at end of file diff --git a/apps/calendar/ajax/guesstimezone.php b/apps/calendar/ajax/guesstimezone.php index 07aadc5cb12..41aea26985f 100755 --- a/apps/calendar/ajax/guesstimezone.php +++ b/apps/calendar/ajax/guesstimezone.php @@ -1,6 +1,6 @@ <?php /** - * Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de> + * Copyright (c) 2011, 2012 Georg Ehrke <ownclouddev at georgswebsite dot de> * This file is licensed under the Affero General Public License version 3 or * later. * See the COPYING-README file. @@ -24,10 +24,19 @@ 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')){ + 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']); @@ -36,4 +45,4 @@ if(in_array($geoarray['timezone']['timezoneId'], DateTimeZone::listIdentifiers() OC_JSON::error(); } -?>
\ No newline at end of file +?> diff --git a/apps/calendar/ajax/timezonedetection.php b/apps/calendar/ajax/timezonedetection.php new file mode 100644 index 00000000000..77e4c4f6ebe --- /dev/null +++ b/apps/calendar/ajax/timezonedetection.php @@ -0,0 +1,17 @@ +<?php +/** + * Copyright (c) 2011, 2012 Georg Ehrke <ownclouddev at georgswebsite dot de> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ +require_once ("../../../lib/base.php"); +OC_JSON::checkLoggedIn(); +OC_JSON::checkAppEnabled('calendar'); +if($_POST['timezonedetection'] == 'on'){ + OC_Preferences::setValue(OC_USER::getUser(), 'calendar', 'timezonedetection', 'true'); +}else{ + OC_Preferences::setValue(OC_USER::getUser(), 'calendar', 'timezonedetection', 'false'); +} +OC_JSON::success(); + diff --git a/apps/calendar/index.php b/apps/calendar/index.php index 7561f987b21..a2042afddf1 100644 --- a/apps/calendar/index.php +++ b/apps/calendar/index.php @@ -32,7 +32,7 @@ if(OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'currentview', 'mont OC_Util::addScript('3rdparty/fullcalendar', 'fullcalendar'); OC_Util::addStyle('3rdparty/fullcalendar', 'fullcalendar'); -if(OC_Preferences::getValue(OC_USER::getUser(), "calendar", "timezone") == null){ +if(OC_Preferences::getValue(OC_USER::getUser(), "calendar", "timezone") == null || OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezonedetection') == 'true'){ OC_UTIL::addScript('calendar', 'geo'); } OC_Util::addScript('calendar', 'calendar'); diff --git a/apps/calendar/js/geo.js b/apps/calendar/js/geo.js index 744d960b75f..ae6a971e938 100755 --- a/apps/calendar/js/geo.js +++ b/apps/calendar/js/geo.js @@ -8,7 +8,7 @@ if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(function(position) { $.getJSON(OC.filePath('calendar', 'ajax', 'guesstimezone.php?lat=' + position.coords.latitude + '&long=' + position.coords.longitude + ''), function(data){ - if (data.status == 'success'){ + if (data.status == 'success' && typeof(data.message) != 'undefined'){ $('#notification').html(data.message); $('#notification').attr('title', 'CC BY 3.0 by Geonames.org'); $('#notification').slideDown(); diff --git a/apps/calendar/js/settings.js b/apps/calendar/js/settings.js index 6c00be06b39..613e2d030db 100644 --- a/apps/calendar/js/settings.js +++ b/apps/calendar/js/settings.js @@ -8,6 +8,12 @@ $(document).ready(function(){ }); return false; }); + $('#timezonedetection').change( function(){ + var post = $('#timezonedetection').serialize(); + $.post( OC.filePath('calendar', 'ajax', 'timezonedetection.php'), post, function(data){ + + }); + }); $("#timezone").chosen(); $("#firstdayofweek").change( function(){ var data = $("#firstdayofweek").serialize(); @@ -52,6 +58,11 @@ $(document).ready(function(){ $.getJSON(OC.filePath('calendar', 'ajax', 'duration.php'), function(jsondata, status) { $("#duration").val(jsondata.duration); }); + $.getJSON(OC.filePath('calendar', 'ajax', 'gettimezonedetection.php'), function(jsondata, status){ + if(jsondata.detection == 'true'){ + $('#timezonedetection').attr('checked', 'checked'); + } + }); $("#weekend").change( function(){ var data = $("#weekend").serialize(); $.post( OC.filePath('calendar', 'ajax', 'setdaysofweekend.php'), data, function(data){ diff --git a/apps/calendar/templates/settings.php b/apps/calendar/templates/settings.php index 56fb55d235c..fc8e0e061d9 100644 --- a/apps/calendar/templates/settings.php +++ b/apps/calendar/templates/settings.php @@ -27,7 +27,7 @@ $continent=$ex[0]; echo '<option value="'.$timezone.'"'.($_['timezone'] == $timezone?' selected="selected"':'').'>'.$city.'</option>'; endforeach;?> - </select></td></tr> + </select><input type="checkbox" name="timezonedetection" id="timezonedetection"><label for="timezonedetection"><?php echo $l->t('Check always for changes of the timezone'); ?></label></td></tr> <tr><td><label for="timeformat" class="bold"><?php echo $l->t('Timeformat');?></label></td><td> <select style="display: none;" id="timeformat" title="<?php echo "timeformat"; ?>" name="timeformat"> |