]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Introduced common_location_shared() to check if location sharing is always, features-enhancing-privacy/geometa-js-disabled
authorRoland Haeder <roland@mxchange.org>
Sun, 24 Jan 2016 15:10:23 +0000 (16:10 +0100)
committerRoland Haeder <roland@mxchange.org>
Sun, 24 Jan 2016 15:11:03 +0000 (16:11 +0100)
never or by-user enabled. This commit also excluded geometa.js if location
sharing is for any reason disabled as this loads an external reference from
Google.

Signed-off-by: Roland Haeder <roland@mxchange.org>
lib/action.php
lib/util.php

index ca8ece7ebc1a075aa9d5e3e9813e72948d3b8db9..5f12b4e94b4791b2ffb194f2c7ea1a3fa98bb402 100644 (file)
@@ -423,7 +423,9 @@ class Action extends HTMLOutputter // lawsuit
             if (Event::handle('StartShowStatusNetScripts', array($this))) {
                 $this->script('util.js');
                 $this->script('xbImportNode.js');
-                $this->script('geometa.js');
+                if (common_location_shared()) {
+                    $this->script('geometa.js');
+                }
 
                 // This route isn't available in single-user mode.
                 // Not sure why, but it causes errors here.
index 13283975f5c67cd643380e1d19dd5dac7ea2e473..322b8821ae767588fd8c595212958c6a5bcd7191 100644 (file)
@@ -2454,3 +2454,35 @@ function html_sprintf()
     }
     return call_user_func_array('sprintf', $args);
 }
+
+function common_location_shared()
+{
+    // Get default setting
+    $cfg = common_config('location', 'share');
+
+    if ($cfg == 'always') {
+        // Always enabled
+        return true;
+    } elseif ($cfg == 'never') {
+        // Never enabled
+        return false;
+    }
+
+    // Is the user logged-in?
+    if (common_logged_in()) {
+        // Get current user
+        $user = common_current_user();
+
+        // Is it there?
+        if ($user instanceof User) {
+            // Yes, get profile
+            $profile = $user->getProfile();
+
+            // Get it from the profile
+            return $profile->shareLocation();
+        }
+    }
+
+    // User is not logged in, get default
+    return common_config('location', 'sharedefault');
+}