add function to detect always the timezone
This commit is contained in:
parent
3bb11db943
commit
e6739d230e
|
@ -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')));
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?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
|
* This file is licensed under the Affero General Public License version 3 or
|
||||||
* later.
|
* later.
|
||||||
* See the COPYING-README file.
|
* See the COPYING-README file.
|
||||||
|
@ -24,10 +24,19 @@ OC_JSON::checkAppEnabled('calendar');
|
||||||
$l = new OC_L10N('calendar');
|
$l = new OC_L10N('calendar');
|
||||||
$lat = $_GET['lat'];
|
$lat = $_GET['lat'];
|
||||||
$long = $_GET['long'];
|
$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);
|
$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
|
//Information are by Geonames (http://www.geonames.org) and licensed under the Creative Commons Attribution 3.0 License
|
||||||
$geoxml = simplexml_load_string($geolocation);
|
$geoxml = simplexml_load_string($geolocation);
|
||||||
$geoarray = make_array_out_of_xml($geoxml);
|
$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())){
|
if(in_array($geoarray['timezone']['timezoneId'], DateTimeZone::listIdentifiers())){
|
||||||
OC_Preferences::setValue(OC_USER::getUser(), 'calendar', 'timezone', $geoarray['timezone']['timezoneId']);
|
OC_Preferences::setValue(OC_USER::getUser(), 'calendar', 'timezone', $geoarray['timezone']['timezoneId']);
|
||||||
$message = array('message'=> $l->t('New 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();
|
OC_JSON::error();
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -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();
|
||||||
|
|
|
@ -32,7 +32,7 @@ if(OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'currentview', 'mont
|
||||||
|
|
||||||
OC_Util::addScript('3rdparty/fullcalendar', 'fullcalendar');
|
OC_Util::addScript('3rdparty/fullcalendar', 'fullcalendar');
|
||||||
OC_Util::addStyle('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', 'geo');
|
||||||
}
|
}
|
||||||
OC_Util::addScript('calendar', 'calendar');
|
OC_Util::addScript('calendar', 'calendar');
|
||||||
|
|
|
@ -8,7 +8,7 @@ if (navigator.geolocation) {
|
||||||
navigator.geolocation.getCurrentPosition(function(position) {
|
navigator.geolocation.getCurrentPosition(function(position) {
|
||||||
$.getJSON(OC.filePath('calendar', 'ajax', 'guesstimezone.php?lat=' + position.coords.latitude + '&long=' + position.coords.longitude + ''),
|
$.getJSON(OC.filePath('calendar', 'ajax', 'guesstimezone.php?lat=' + position.coords.latitude + '&long=' + position.coords.longitude + ''),
|
||||||
function(data){
|
function(data){
|
||||||
if (data.status == 'success'){
|
if (data.status == 'success' && typeof(data.message) != 'undefined'){
|
||||||
$('#notification').html(data.message);
|
$('#notification').html(data.message);
|
||||||
$('#notification').attr('title', 'CC BY 3.0 by Geonames.org');
|
$('#notification').attr('title', 'CC BY 3.0 by Geonames.org');
|
||||||
$('#notification').slideDown();
|
$('#notification').slideDown();
|
||||||
|
|
|
@ -8,6 +8,12 @@ $(document).ready(function(){
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
$('#timezonedetection').change( function(){
|
||||||
|
var post = $('#timezonedetection').serialize();
|
||||||
|
$.post( OC.filePath('calendar', 'ajax', 'timezonedetection.php'), post, function(data){
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
$("#timezone").chosen();
|
$("#timezone").chosen();
|
||||||
$("#firstdayofweek").change( function(){
|
$("#firstdayofweek").change( function(){
|
||||||
var data = $("#firstdayofweek").serialize();
|
var data = $("#firstdayofweek").serialize();
|
||||||
|
@ -52,6 +58,11 @@ $(document).ready(function(){
|
||||||
$.getJSON(OC.filePath('calendar', 'ajax', 'duration.php'), function(jsondata, status) {
|
$.getJSON(OC.filePath('calendar', 'ajax', 'duration.php'), function(jsondata, status) {
|
||||||
$("#duration").val(jsondata.duration);
|
$("#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(){
|
$("#weekend").change( function(){
|
||||||
var data = $("#weekend").serialize();
|
var data = $("#weekend").serialize();
|
||||||
$.post( OC.filePath('calendar', 'ajax', 'setdaysofweekend.php'), data, function(data){
|
$.post( OC.filePath('calendar', 'ajax', 'setdaysofweekend.php'), data, function(data){
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
$continent=$ex[0];
|
$continent=$ex[0];
|
||||||
echo '<option value="'.$timezone.'"'.($_['timezone'] == $timezone?' selected="selected"':'').'>'.$city.'</option>';
|
echo '<option value="'.$timezone.'"'.($_['timezone'] == $timezone?' selected="selected"':'').'>'.$city.'</option>';
|
||||||
endforeach;?>
|
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>
|
<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">
|
<select style="display: none;" id="timeformat" title="<?php echo "timeformat"; ?>" name="timeformat">
|
||||||
|
|
Loading…
Reference in New Issue