]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/util.php
Introduced common_location_shared() to check if location sharing is always,
[quix0rs-gnu-social.git] / lib / util.php
index 1da9cc3c17551e091c55350726bb45e33f9a3d35..a1f6fe2bd1666b86f10f1928cfe061531fdb7968 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');
+}