]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/newnotice.php
remove namespace setting from location; it's unused
[quix0rs-gnu-social.git] / actions / newnotice.php
index c014f1781cd9b380b46a160e3113bc846057327f..8591522dc55e9c8f9476a42aab52a0cc3e672989 100644 (file)
@@ -164,19 +164,6 @@ class NewnoticeAction extends Action
             $replyto = 'false';
         }
 
-        $lat = $this->trimmed('lat');
-        $lon = $this->trimmed('lon');
-        $location_id = $this->trimmed('location_id');
-        $location_ns = $this->trimmed('location_ns');
-
-        if (!empty($lat) && !empty($lon) && empty($location_id)) {
-            $location = Location::fromLatLon($lat, $lon);
-            if (!empty($location)) {
-                $location_id = $location->location_id;
-                $location_ns = $location->location_ns;
-            }
-        }
-
         $upload = null;
         $upload = MediaFile::fromUpload('attach');
 
@@ -195,12 +182,30 @@ class NewnoticeAction extends Action
             }
         }
 
-        $notice = Notice::saveNew($user->id, $content_shortened, 'web',
-                                  array('reply_to' => ($replyto == 'false') ? null : $replyto,
-                                        'lat' => $lat,
-                                        'lon' => $lon,
-                                        'location_id' => $location_id,
-                                        'location_ns' => $location_ns));
+        $options = array('reply_to' => ($replyto == 'false') ? null : $replyto);
+
+        if ($user->shareLocation()) {
+
+            $lat = $this->trimmed('lat');
+            $lon = $this->trimmed('lon');
+            $location_id = $this->trimmed('location_id');
+            $location_ns = $this->trimmed('location_ns');
+
+            if (!empty($lat) && !empty($lon) && empty($location_id)) {
+                $location = Location::fromLatLon($lat, $lon);
+                if (!empty($location)) {
+                    $location_id = $location->location_id;
+                    $location_ns = $location->location_ns;
+                }
+            }
+
+            $options['lat'] = $lat;
+            $options['lon'] = $lon;
+            $options['location_id'] = $location_id;
+            $options['location_ns'] = $location_ns;
+        }
+
+        $notice = Notice::saveNew($user->id, $content_shortened, 'web', $options);
 
         if (isset($upload)) {
             $upload->attachToNotice($notice);