summaryrefslogtreecommitdiff
path: root/controllers
diff options
context:
space:
mode:
authorAaron Parecki <aaron@parecki.com>2017-01-15 08:07:54 -0800
committerAaron Parecki <aaron@parecki.com>2017-01-15 08:07:54 -0800
commit3310a85ac8f276ad270388a4242b623f30abe74d (patch)
tree8e9da2a1861432e361bb5ac2dc5245015b8c11f1 /controllers
parentfa06932a9c1bb289cae6cbaa046c6b9c07bf5b1a (diff)
store the user's timezone after their location is found
Diffstat (limited to 'controllers')
-rw-r--r--controllers/controllers.php19
1 files changed, 19 insertions, 0 deletions
diff --git a/controllers/controllers.php b/controllers/controllers.php
index 4de4aee..505589f 100644
--- a/controllers/controllers.php
+++ b/controllers/controllers.php
@@ -213,6 +213,25 @@ $app->post('/prefs', function() use($app) {
)));
});
+$app->post('/prefs/timezone', function() use($app) {
+ // Called when the interface finds the user's location.
+ // Look up the timezone for this location and store it as their default.
+ $timezone = false;
+ if($user=require_login($app)) {
+ $params = $app->request()->params();
+ $timezone = p3k\Timezone::timezone_for_location($params['latitude'], $params['longitude']);
+ if($timezone) {
+ $user->default_timezone = $timezone;
+ $user->save();
+ }
+ }
+ $app->response()['Content-type'] = 'application/json';
+ $app->response()->body(json_encode(array(
+ 'result' => 'ok',
+ 'timezone' => $timezone,
+ )));
+});
+
$app->get('/add-to-home', function() use($app) {
$params = $app->request()->params();
header("Cache-Control: no-cache, must-revalidate");