diff options
author | Georg Ehrke <ownclouddev@georgswebsite.de> | 2012-02-20 11:26:22 +0100 |
---|---|---|
committer | Georg Ehrke <dev@georgswebsite.de> | 2012-02-23 21:58:39 +0100 |
commit | b7de1850a00b91be34af062957df73424c95469b (patch) | |
tree | 975943d8ca3d11298fa090e24d9b814b0464e8f9 /apps/calendar/ajax/settings | |
parent | e188b96596f7562e73b2974e640ff77b3e165629 (diff) | |
download | nextcloud-server-b7de1850a00b91be34af062957df73424c95469b.tar.gz nextcloud-server-b7de1850a00b91be34af062957df73424c95469b.zip |
add moved files to clean up ajax folder
Diffstat (limited to 'apps/calendar/ajax/settings')
-rw-r--r-- | apps/calendar/ajax/settings/gettimezonedetection.php | 11 | ||||
-rwxr-xr-x | apps/calendar/ajax/settings/guesstimezone.php | 48 | ||||
-rw-r--r-- | apps/calendar/ajax/settings/settimeformat.php | 17 | ||||
-rw-r--r-- | apps/calendar/ajax/settings/settimezone.php | 27 | ||||
-rw-r--r-- | apps/calendar/ajax/settings/timeformat.php | 12 | ||||
-rw-r--r-- | apps/calendar/ajax/settings/timezonedetection.php | 17 |
6 files changed, 132 insertions, 0 deletions
diff --git a/apps/calendar/ajax/settings/gettimezonedetection.php b/apps/calendar/ajax/settings/gettimezonedetection.php new file mode 100644 index 00000000000..11255fe8ef3 --- /dev/null +++ b/apps/calendar/ajax/settings/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/settings/guesstimezone.php b/apps/calendar/ajax/settings/guesstimezone.php new file mode 100755 index 00000000000..cfa92e1aee8 --- /dev/null +++ b/apps/calendar/ajax/settings/guesstimezone.php @@ -0,0 +1,48 @@ +<?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. + */ +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')){ + 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(); +} + +?> diff --git a/apps/calendar/ajax/settings/settimeformat.php b/apps/calendar/ajax/settings/settimeformat.php new file mode 100644 index 00000000000..8f65447065c --- /dev/null +++ b/apps/calendar/ajax/settings/settimeformat.php @@ -0,0 +1,17 @@ +<?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. + */ +require_once('../../../../lib/base.php'); +OC_JSON::checkLoggedIn(); +if(isset($_POST["timeformat"])){ + OC_Preferences::setValue(OC_User::getUser(), 'calendar', 'timeformat', $_POST["timeformat"]); + OC_JSON::success(); +}else{ + OC_JSON::error(); +} +?> + diff --git a/apps/calendar/ajax/settings/settimezone.php b/apps/calendar/ajax/settings/settimezone.php new file mode 100644 index 00000000000..c639753fe2f --- /dev/null +++ b/apps/calendar/ajax/settings/settimezone.php @@ -0,0 +1,27 @@ +<?php +/** + * Copyright (c) 2011 Bart Visscher <bartv@thisnet.nl> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +// Init owncloud +require_once('../../../../lib/base.php'); + +$l=new OC_L10N('calendar'); + +// Check if we are a user +OC_JSON::checkLoggedIn(); +OC_JSON::checkAppEnabled('calendar'); + +// Get data +if( isset( $_POST['timezone'] ) ){ + $timezone=$_POST['timezone']; + OC_Preferences::setValue( OC_User::getUser(), 'calendar', 'timezone', $timezone ); + OC_JSON::success(array('data' => array( 'message' => $l->t('Timezone changed') ))); +}else{ + OC_JSON::error(array('data' => array( 'message' => $l->t('Invalid request') ))); +} + +?> diff --git a/apps/calendar/ajax/settings/timeformat.php b/apps/calendar/ajax/settings/timeformat.php new file mode 100644 index 00000000000..e0dbe8d3cd7 --- /dev/null +++ b/apps/calendar/ajax/settings/timeformat.php @@ -0,0 +1,12 @@ +<?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. + */ +require_once('../../../../lib/base.php'); +OC_JSON::checkLoggedIn(); +$timeformat = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'timeformat', "24"); +OC_JSON::encodedPrint(array("timeformat" => $timeformat)); +?> diff --git a/apps/calendar/ajax/settings/timezonedetection.php b/apps/calendar/ajax/settings/timezonedetection.php new file mode 100644 index 00000000000..f67bab901e7 --- /dev/null +++ b/apps/calendar/ajax/settings/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(); + |