--- /dev/null
+<?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
<?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.
$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']);
OC_JSON::error();
}
-?>
\ No newline at end of file
+?>
--- /dev/null
+<?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();
+
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');
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();
});
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();
$.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){
$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">