automatic timezone detection
This commit is contained in:
parent
b095859a92
commit
26272c4252
|
@ -0,0 +1,39 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Copyright (c) 2011 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.
|
||||||
|
*/
|
||||||
|
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'];
|
||||||
|
$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(isset($geoarray['timezone']['timezoneId']) && $geoarray['timezone']['timezoneId'] != ''){
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -32,6 +32,9 @@ 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){
|
||||||
|
OC_UTIL::addScript('calendar', 'geo');
|
||||||
|
}
|
||||||
OC_Util::addScript('calendar', 'calendar');
|
OC_Util::addScript('calendar', 'calendar');
|
||||||
OC_Util::addStyle('calendar', 'style');
|
OC_Util::addStyle('calendar', 'style');
|
||||||
OC_Util::addScript('', 'jquery.multiselect');
|
OC_Util::addScript('', 'jquery.multiselect');
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
/**
|
||||||
|
* Copyright (c) 2011 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.
|
||||||
|
*/
|
||||||
|
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'){
|
||||||
|
$('#notification').html(data.message);
|
||||||
|
$('#notification').slideDown();
|
||||||
|
window.setTimeout(function(){$('#notification').slideUp();}, 5000);
|
||||||
|
}else{
|
||||||
|
console.log('Can\'t set new timezone.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
|
@ -1,21 +1,21 @@
|
||||||
<script type='text/javascript'>
|
<script type='text/javascript'>
|
||||||
var defaultView = '<?php echo OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'currentview', 'month') ?>';
|
var defaultView = '<?php echo OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'currentview', 'month') ?>';
|
||||||
var eventSources = <?php echo json_encode($_['eventSources']) ?>;
|
var eventSources = <?php echo json_encode($_['eventSources']) ?>;
|
||||||
var dayNames = <?php echo json_encode($l->tA(array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'))) ?>;
|
var dayNames = <?php echo json_encode($l->tA(array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'))) ?>;
|
||||||
var dayNamesShort = <?php echo json_encode($l->tA(array('Sun.', 'Mon.', 'Tue.', 'Wed.', 'Thu.', 'Fri.', 'Sat.'))) ?>;
|
var dayNamesShort = <?php echo json_encode($l->tA(array('Sun.', 'Mon.', 'Tue.', 'Wed.', 'Thu.', 'Fri.', 'Sat.'))) ?>;
|
||||||
var monthNames = <?php echo json_encode($l->tA(array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'))) ?>;
|
var monthNames = <?php echo json_encode($l->tA(array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'))) ?>;
|
||||||
var monthNamesShort = <?php echo json_encode($l->tA(array('Jan.', 'Feb.', 'Mar.', 'Apr.', 'May.', 'Jun.', 'Jul.', 'Aug.', 'Sep.', 'Oct.', 'Nov.', 'Dec.'))) ?>;
|
var monthNamesShort = <?php echo json_encode($l->tA(array('Jan.', 'Feb.', 'Mar.', 'Apr.', 'May.', 'Jun.', 'Jul.', 'Aug.', 'Sep.', 'Oct.', 'Nov.', 'Dec.'))) ?>;
|
||||||
var allDayText = '<?php echo $l->t('All day') ?>';
|
var allDayText = '<?php echo $l->t('All day') ?>';
|
||||||
var missing_field = '<?php echo $l->t('Missing fields') ?>';
|
var missing_field = '<?php echo $l->t('Missing fields') ?>';
|
||||||
var missing_field_title = '<?php echo $l->t('Title') ?>';
|
var missing_field_title = '<?php echo $l->t('Title') ?>';
|
||||||
var missing_field_calendar = '<?php echo $l->t('Calendar') ?>';
|
var missing_field_calendar = '<?php echo $l->t('Calendar') ?>';
|
||||||
var missing_field_fromdate = '<?php echo $l->t('From Date') ?>';
|
var missing_field_fromdate = '<?php echo $l->t('From Date') ?>';
|
||||||
var missing_field_fromtime = '<?php echo $l->t('From Time') ?>';
|
var missing_field_fromtime = '<?php echo $l->t('From Time') ?>';
|
||||||
var missing_field_todate = '<?php echo $l->t('To Date') ?>';
|
var missing_field_todate = '<?php echo $l->t('To Date') ?>';
|
||||||
var missing_field_totime = '<?php echo $l->t('To Time') ?>';
|
var missing_field_totime = '<?php echo $l->t('To Time') ?>';
|
||||||
var missing_field_startsbeforeends = '<?php echo $l->t('The event ends before it starts') ?>';
|
var missing_field_startsbeforeends = '<?php echo $l->t('The event ends before it starts') ?>';
|
||||||
var missing_field_dberror = '<?php echo $l->t('There was a database fail') ?>';
|
var missing_field_dberror = '<?php echo $l->t('There was a database fail') ?>';
|
||||||
</script>
|
</script>
|
||||||
<div id="controls">
|
<div id="controls">
|
||||||
<div>
|
<div>
|
||||||
<form>
|
<form>
|
||||||
|
@ -40,6 +40,7 @@ var missing_field_dberror = '<?php echo $l->t('There was a database fail') ?>';
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="notification" style="display:none;"></div>
|
||||||
<div id="calendar_holder">
|
<div id="calendar_holder">
|
||||||
</div>
|
</div>
|
||||||
<!-- Dialogs -->
|
<!-- Dialogs -->
|
||||||
|
|
Loading…
Reference in New Issue