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

index fdf5cd4c87fa6deb9801f754c8b3d71c4a99b341..c08a66790fe18698550f34374fe3181c8e538df2 100644 (file)
@@ -1412,4 +1412,21 @@ class Notice extends Memcached_DataObject
         $contentlimit = self::maxContent();
         return ($contentlimit > 0 && !empty($content) && (mb_strlen($content) > $contentlimit));
     }
+
+    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);
+            }
+        }
+
+        return $location;
+    }
 }