]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
get location from a Profile
authorEvan Prodromou <evan@status.net>
Thu, 29 Oct 2009 18:43:25 +0000 (14:43 -0400)
committerEvan Prodromou <evan@status.net>
Thu, 29 Oct 2009 18:43:25 +0000 (14:43 -0400)
classes/Profile.php

index 53d07fb2ffa3aea1b1400fa13ba5eb9a39f4342b..7c1e9db332cb420b970b866e2efa62e3fc54c56b 100644 (file)
@@ -562,4 +562,29 @@ class Profile extends Memcached_DataObject
         $block->blocked = $this->id;
         $block->delete();
     }
+
+    // XXX: identical to Notice::getLocation.
+
+    function getLocation()
+    {
+        $location = null;
+
+        if (!empty($this->location_id) && !empty($this->location_ns)) {
+            $location = Location::fromId($this->location_id, $this->location_ns);
+        }
+
+        if (is_null($location)) { // no ID, or Location::fromId() failed
+            if (!empty($this->lat) && !empty($this->lon)) {
+                $location = Location::fromLatLon($this->lat, $this->lon);
+            }
+        }
+
+        if (is_null($location)) { // still haven't found it!
+            if (!empty($this->location)) {
+                $location = Location::fromName($this->location);
+            }
+        }
+
+        return $location;
+    }
 }