]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/Notice.php
Merge branch '0.9.x' into location
[quix0rs-gnu-social.git] / classes / Notice.php
index 7d4e6182387e8b2a412478fc9f7616f968568ad4..fdf5cd4c87fa6deb9801f754c8b3d71c4a99b341 100644 (file)
@@ -66,9 +66,15 @@ class Notice extends Memcached_DataObject
     public $is_local;                        // tinyint(1)
     public $source;                          // varchar(32)
     public $conversation;                    // int(4)
+    public $lat;                             // decimal(10,7)
+    public $lon;                             // decimal(10,7)
+    public $location_id;                     // int(4)
+    public $location_ns;                     // int(4)
 
     /* Static get */
-    function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Notice',$k,$v); }
+    function staticGet($k,$v=NULL) {
+        return Memcached_DataObject::staticGet('Notice',$k,$v);
+    }
 
     /* the code above is auto generated do not remove the tag below */
     ###END_AUTOCODE
@@ -162,7 +168,8 @@ class Notice extends Memcached_DataObject
     }
 
     static function saveNew($profile_id, $content, $source=null,
-                            $is_local=Notice::LOCAL_PUBLIC, $reply_to=null, $uri=null, $created=null) {
+                            $is_local=Notice::LOCAL_PUBLIC, $reply_to=null, $uri=null, $created=null,
+                            $lat=null, $lon=null, $location_id=null, $location_ns=null) {
 
         $profile = Profile::staticGet($profile_id);
 
@@ -228,6 +235,26 @@ class Notice extends Memcached_DataObject
             $notice->conversation = $reply->conversation;
         }
 
+        if (!empty($lat) && !empty($lon)) {
+            $notice->lat = $lat;
+            $notice->lon = $lon;
+            $notice->location_id = $location_id;
+            $notice->location_ns = $location_ns;
+        } else if (!empty($location_ns) && !empty($location_id)) {
+            $location = Location::fromId($location_id, $location_ns);
+            if (!empty($location)) {
+                $notice->lat = $location->lat;
+                $notice->lon = $location->lon;
+                $notice->location_id = $location_id;
+                $notice->location_ns = $location_ns;
+            }
+        } else {
+            $notice->lat         = $profile->lat;
+            $notice->lon         = $profile->lon;
+            $notice->location_id = $profile->location_id;
+            $notice->location_ns = $profile->location_ns;
+        }
+
         if (Event::handle('StartNoticeSave', array(&$notice))) {
 
             // XXX: some of these functions write to the DB