]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Introduced common_location_shared() to check if location sharing is always,
authorRoland Haeder <roland@mxchange.org>
Sun, 24 Jan 2016 15:10:23 +0000 (16:10 +0100)
committerRoland Häder <roland@mxchange.org>
Sun, 29 Mar 2020 22:21:23 +0000 (00:21 +0200)
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 1f50351d3a2aa53d66f36aa84d9993f6041823ff..62a1a13ec00d8551a9044d8ea324b6e79ca75798 100644 (file)
@@ -1466,6 +1466,9 @@ class Action extends HTMLOutputter // lawsuit
             if (Event::handle('StartShowStatusNetScripts', array($this))) {
                 $this->script('util.js');
                 $this->script('xbImportNode.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 5ab33e9c971e3962eadf6609d2da3e49918a1f90..4b958654f733d8b08293f562da422095e9604221 100644 (file)
@@ -2711,3 +2711,35 @@ function _ve($var)
 {
     return var_export($var, true);
 }
+
+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');
+}